<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 設置讀寫觀察點 ## 例子 #include <stdio.h> #include <pthread.h> int a = 0; void *thread1_func(void *p_arg) { while (1) { a++; sleep(10); } } void *thread2_func(void *p_arg) { while (1) { printf("%d\n", a);; sleep(10); } } int main(void) { pthread_t t1, t2; pthread_create(&t1, NULL, thread1_func, "Thread 1"); pthread_create(&t2, NULL, thread2_func, "Thread 2"); sleep(1000); return; } ## 技巧 gdb可以使用“`awatch`”命令設置讀寫觀察點,也就是當發生讀取變量或改變變量值的行為時,程序就會暫停住。以上面程序為例: (gdb) aw a Hardware access (read/write) watchpoint 1: a (gdb) r Starting program: /data2/home/nanxiao/a [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". [New Thread 0x7ffff782c700 (LWP 16938)] [Switching to Thread 0x7ffff782c700 (LWP 16938)] Hardware access (read/write) watchpoint 1: a Value = 0 0x00000000004005c6 in thread1_func (p_arg=0x40076c) at a.c:10 10 a++; (gdb) c Continuing. Hardware access (read/write) watchpoint 1: a Old value = 0 New value = 1 thread1_func (p_arg=0x40076c) at a.c:11 11 sleep(10); (gdb) c Continuing. [New Thread 0x7ffff6e2b700 (LWP 16939)] [Switching to Thread 0x7ffff6e2b700 (LWP 16939)] Hardware access (read/write) watchpoint 1: a Value = 1 0x00000000004005f2 in thread2_func (p_arg=0x400775) at a.c:19 19 printf("%d\n", a);; (gdb) c Continuing. 1 [Switching to Thread 0x7ffff782c700 (LWP 16938)] Hardware access (read/write) watchpoint 1: a Value = 1 0x00000000004005c6 in thread1_func (p_arg=0x40076c) at a.c:10 10 a++; 可以看到,使用“`aw a`”命令(`aw`是`awatch`命令的縮寫)以后,每次讀取或改變`a`的值都會讓程序停下來。 需要注意的是`awatch`命令只對硬件觀察點才生效,參見[gdb手冊](https://sourceware.org/gdb/onlinedocs/gdb/Set-Watchpoints.html). ## 貢獻者 nanxiao
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看