<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[【FAQ】全志XR806芯片 如何使用watchpoint功能？]]></title><description><![CDATA[<p dir="auto"><strong>1.问题背景</strong><br />
watchpoint，一般用来观察某个变量/内存地址的状态(也可以是表达式），如可以监控该变量/内存值是否被程序读/写情况。</p>
<p dir="auto"><strong>2.问题描述</strong><br />
在程序运行异常的时候，可以借助watchpoint来进行辅助调试。</p>
<p dir="auto"><strong>3.问题分析</strong><br />
在XR MCU SDK中，支持了watchpoint功能，通过使能指定宏以及调用指定函数来使用该功能。</p>
<p dir="auto"><strong>4.解决办法</strong><br />
（1）使能watchpoint的宏开关：export __CONFIG_WATCHPOINT:=y<br />
（2）调用watchpoint_add函数添加观察点<br />
以下是代码使用示例：</p>
<pre><code>#include &lt;debug/watchpoint.h&gt;
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)&amp;watchpoint_test_value;
    wp.length = sizeof(watchpoint_test_value);
    wp.rw = DWT_WRITE;
    ret = watchpoint_add(&amp;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;
}
</code></pre>
]]></description><link>https://bbs.aw-ol.com/topic/735/faq-全志xr806芯片-如何使用watchpoint功能</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 01:48:55 GMT</lastBuildDate><atom:link href="https://bbs.aw-ol.com/topic/735.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 08 Dec 2021 01:42:24 GMT</pubDate><ttl>60</ttl></channel></rss>