如何监控变量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?
推荐答案
在柜台上设置观察点:
(gdb) watch var
和作出这样的观察点条件:
And make that watchpoint conditional:
(gdb) cond <watchpoint_number> var>=value
如果你想记录到一个文件:
If you want to log to a file:
(gdb) set logging file <filename>
(gdb) set logging on
在默认情况下GDB日志gdb.txt
By default gdb logs to gdb.txt
这篇关于如何监控变量GDB并记录它,如果它符合一定的条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文