当 char* x 指向值等于“hello"的字符串时,如何在 gdb 中设置条件断点? [英] How do I set a conditional breakpoint in gdb, when char* x points to a string whose value equals "hello"?
本文介绍了当 char* x 指向值等于“hello"的字符串时,如何在 gdb 中设置条件断点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当 char* x
指向值等于 "hello"
的字符串时,我可以指定我希望 gdb 在第 x 行中断吗?如果是,怎么做?
Can I specify that I want gdb to break at line x when char* x
points to a string whose value equals "hello"
? If yes, how?
推荐答案
可以使用strcmp
:
break x:20 if strcmp(y, "hello") == 0
20
是行号,x
可以是任何文件名,y
可以是任何变量.
20
is line number, x
can be any filename and y
can be any variable.
这篇关于当 char* x 指向值等于“hello"的字符串时,如何在 gdb 中设置条件断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文