如果满足一定条件,如何监控 GDB 中的变量并记录? [英] How to monitor variables in GDB and log it if it meets certain conditions?
本文介绍了如果满足一定条件,如何监控 GDB 中的变量并记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有任何方法可以监视变量的值,直到例如计数器达到一个值,然后在每个计数器值期间记录变量值的输出?
I would like to know if there is any way in which I can monitor a value of a variable until for example a counter reaches a value and then log the output of variable value during each counter value?
推荐答案
在计数器上设置观察点:
Set a watch point on the counter:
(gdb) watch var
并使该观察点有条件:
(gdb) cond <watchpoint_number> var>=value
如果要登录到文件:
(gdb) set logging file <filename>
(gdb) set logging on
默认情况下 gdb 记录到 gdb.txt
By default gdb logs to gdb.txt
这篇关于如果满足一定条件,如何监控 GDB 中的变量并记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文