Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    【FAQ】全志XR806芯片 如何使用watchpoint功能?

    其它全志芯片讨论区
    xr806 xr872 faq 技术支持
    1
    1
    216
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • q1215200171
      budbool LV 8 last edited by

      1.问题背景
      watchpoint,一般用来观察某个变量/内存地址的状态(也可以是表达式),如可以监控该变量/内存值是否被程序读/写情况。

      2.问题描述
      在程序运行异常的时候,可以借助watchpoint来进行辅助调试。

      3.问题分析
      在XR MCU SDK中,支持了watchpoint功能,通过使能指定宏以及调用指定函数来使用该功能。

      4.解决办法
      (1)使能watchpoint的宏开关:export __CONFIG_WATCHPOINT:=y
      (2)调用watchpoint_add函数添加观察点
      以下是代码使用示例:

      #include <debug/watchpoint.h>
      static int watchpoint_test_value;
      static struct watchpoint wp;
      static enum cmd_status cmd_watchpoint_value_init(char *cmd)
      {
          int ret;
          watchpoint_test_value = 1;
          wp.address = (unsigned int)&watchpoint_test_value;
          wp.length = sizeof(watchpoint_test_value);
          wp.rw = DWT_WRITE;
          ret = watchpoint_add(&wp);
          if (ret) {
              printf("watchpoint_add fail.\n");
          }
          return CMD_STATUS_OK;
      }
      static enum cmd_status cmd_watchpoint_value_change(char *cmd)
      {
          watchpoint_test_value = 0;
          return CMD_STATUS_OK;
      }
      
      1 Reply Last reply Reply Quote Share 0
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • 1 / 1
      • First post
        Last post

      Copyright © 2022 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

      行为准则 | 用户协议 | 隐私权政策