<i id='V5d6V'><tr id='V5d6V'><dt id='V5d6V'><q id='V5d6V'><span id='V5d6V'><b id='V5d6V'><form id='V5d6V'><ins id='V5d6V'></ins><ul id='V5d6V'></ul><sub id='V5d6V'></sub></form><legend id='V5d6V'></legend><bdo id='V5d6V'><pre id='V5d6V'><center id='V5d6V'></center></pre></bdo></b><th id='V5d6V'></th></span></q></dt></tr></i><div id='V5d6V'><tfoot id='V5d6V'></tfoot><dl id='V5d6V'><fieldset id='V5d6V'></fieldset></dl></div>
  1. <legend id='V5d6V'><style id='V5d6V'><dir id='V5d6V'><q id='V5d6V'></q></dir></style></legend>
    <tfoot id='V5d6V'></tfoot>
      <bdo id='V5d6V'></bdo><ul id='V5d6V'></ul>

      <small id='V5d6V'></small><noframes id='V5d6V'>

      我可以在 GDB 中的“内存访问"上设置断点吗

      时间:2023-05-24
      <i id='GOACR'><tr id='GOACR'><dt id='GOACR'><q id='GOACR'><span id='GOACR'><b id='GOACR'><form id='GOACR'><ins id='GOACR'></ins><ul id='GOACR'></ul><sub id='GOACR'></sub></form><legend id='GOACR'></legend><bdo id='GOACR'><pre id='GOACR'><center id='GOACR'></center></pre></bdo></b><th id='GOACR'></th></span></q></dt></tr></i><div id='GOACR'><tfoot id='GOACR'></tfoot><dl id='GOACR'><fieldset id='GOACR'></fieldset></dl></div>
        <tbody id='GOACR'></tbody>

        <small id='GOACR'></small><noframes id='GOACR'>

        • <legend id='GOACR'><style id='GOACR'><dir id='GOACR'><q id='GOACR'></q></dir></style></legend>

            <bdo id='GOACR'></bdo><ul id='GOACR'></ul>

              <tfoot id='GOACR'></tfoot>

                本文介绍了我可以在 GDB 中的“内存访问"上设置断点吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我正在通过 gdb 运行一个应用程序,我想在任何时候访问/更改特定变量时设置断点.有没有好的方法可以做到这一点?我也对在 C/C++ 中监视变量的其他方法感兴趣,以查看它是否/何时发生变化.

                I am running an application through gdb and I want to set a breakpoint for any time a specific variable is accessed / changed. Is there a good method for doing this? I would also be interested in other ways to monitor a variable in C/C++ to see if/when it changes.

                推荐答案

                watch 只在写入时中断,rwatch 让你在读取时中断,awatch 让你中断读/写.

                watch only breaks on write, rwatch let you break on read, and awatch let you break on read/write.

                您可以在内存位置上设置读取观察点:

                You can set read watchpoints on memory locations:

                gdb$ rwatch *0xfeedface
                Hardware read watchpoint 2: *0xfeedface
                

                但有一个限制适用于 rwatch 和 awatch 命令;你不能使用 gdb 变量在表达式中:

                but one limitation applies to the rwatch and awatch commands; you can't use gdb variables in expressions:

                gdb$ rwatch $ebx+0xec1a04f
                Expression cannot be implemented with read/access watchpoint.
                

                所以你必须自己扩展它们:

                So you have to expand them yourself:

                gdb$ print $ebx 
                $13 = 0x135700
                gdb$ rwatch *0x135700+0xec1a04f
                Hardware read watchpoint 3: *0x135700 + 0xec1a04f
                gdb$ c
                Hardware read watchpoint 3: *0x135700 + 0xec1a04f
                
                Value = 0xec34daf
                0x9527d6e7 in objc_msgSend ()
                

                哦,顺便说一下.您需要硬件或软件支持.软件显然要慢得多.要了解您的操作系统是否支持硬件观察点,您可以查看 can-use-hw-watchpoints 环境设置.

                Oh, and by the way. You need either hardware or software support. Software is obviously much slower. To find out if your OS supports hardware watchpoints you can see the can-use-hw-watchpoints environment setting.

                gdb$ show can-use-hw-watchpoints
                Debugger's willingness to use watchpoint hardware is 1.
                

                这篇关于我可以在 GDB 中的“内存访问"上设置断点吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:将 C/C++ dll 头文件转换为 Delphi 的最佳资源? 下一篇:_DEBUG 与 NDEBUG

                相关文章

                最新文章

                <i id='wNwxN'><tr id='wNwxN'><dt id='wNwxN'><q id='wNwxN'><span id='wNwxN'><b id='wNwxN'><form id='wNwxN'><ins id='wNwxN'></ins><ul id='wNwxN'></ul><sub id='wNwxN'></sub></form><legend id='wNwxN'></legend><bdo id='wNwxN'><pre id='wNwxN'><center id='wNwxN'></center></pre></bdo></b><th id='wNwxN'></th></span></q></dt></tr></i><div id='wNwxN'><tfoot id='wNwxN'></tfoot><dl id='wNwxN'><fieldset id='wNwxN'></fieldset></dl></div>

              1. <tfoot id='wNwxN'></tfoot>
                • <bdo id='wNwxN'></bdo><ul id='wNwxN'></ul>

                <legend id='wNwxN'><style id='wNwxN'><dir id='wNwxN'><q id='wNwxN'></q></dir></style></legend>

                  <small id='wNwxN'></small><noframes id='wNwxN'>