导航

    全志在线开发者论坛

    • 注册
    • 登录
    • 搜索
    • 版块
    • 话题
    • 在线文档
    • 社区主页

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

    其它全志芯片讨论区
    xr806 xr872 faq 技术支持
    1
    1
    1360
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • q1215200171
      budbool LV 9 最后由 编辑

      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 条回复 最后回复 回复 引用 分享 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 © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

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