http://www.nabble.com/break-when-opening-certain-file-td21428195.html
You want a "conditional breakpoint".
Assuming you're on i386-linux or similar (adjustments are
straightforward for most other platforms),
#include <fcntl.h>
int
main (int argc, char *argv[])
{
int i;
for (i = 1; i < argc; ++i)
open (argv[i], O_RDONLY);
return 0;
}
bash$ gcc -g foo.c
bash$ gdb --args a.out foo bar baz
(gdb) start
(gdb) break open
(gdb) condition 2 strcmp (((char**)$esp)[1], "bar") == 0
(gdb) c
Continuing.
Breakpoint 2, 0x42ce0e80 in open () from /lib/tls/i686/cmov/libc.so.6
(gdb) x/s ((char**)$esp)[1]
0xffffdafe: "bar"
(gdb) c
Continuing.
Program exited normally.
(gdb)
You kinda have to know the i386 calling convention to know that on
entry to open the file name is at ((char**)$esp)[1].
The use of "start" above simplifies a few things, it runs the program
to the start of main(). At this point libc is loaded and any open
calls made while trying to get to main() are skipped.
One caveat is that specifying the condition this way will call
malloc() to allocate space for "bar" so that the call to strcmp will
work. If you don't want to call malloc when testing the breakpoint
condition then one alternative is to manually compare the characters.
A real pain, but if you're debugging a problem and you just need to
have gdb stop at the right file you often don't need to compare every
character in the file name, just enough to get you close. You can
keep hitting continue until the breakpoint hits the right one.
Starting over,
bash$ gdb --args a.out foo bar baz
(gdb) start
(gdb) break open
(gdb) condition 2 ((char**)$esp)[1][0] == 'b'
(gdb) commands 2
x/s ((char**)$esp)[1]
end
(gdb) c
Continuing.
Breakpoint 2, 0x42ce0e80 in open () from /lib/tls/i686/cmov/libc.so.6
0xffffdafe: "bar"
(gdb) c
Continuing.
Breakpoint 2, 0x42ce0e80 in open () from /lib/tls/i686/cmov/libc.so.6
0xffffdb02: "baz"
(gdb) c
Continuing.
Program exited normally.
(gdb)
分享到:
相关推荐
base zz zz zz zz zz base zz zz zz zz zz base zz zz zz zz zz base zz zz zz zz zz
ZZ561401.CAB ZZ561401.CAB ZZ561401.CAB
wincc SIMATIC WinCC是第一个使用最新的32位技术的过程监视系统,具有良好的开放性和灵活性。 从面市伊始,用户就对SIMATIC WinCC印象深刻。
在CAD中想要快速测量长度,在CAD工具栏找到加载应用程序,再点击加载 加载成功后在输入栏输入“zz”(不分大小写)在选择你需要测量的线段即可。
我们研究了四轻子最终状态ℓ+ℓ-ℓ+ℓ-的产生,这些状态主要由一对弱电Z玻色子ZZ产生。 使用LoopSim方法,我们合并ZZ和ZZ + jet的NLO QCD结果,并获得ZZ产生的近似NNLO预测。 还包括对ZZ过程的精确胶子融合环平方的...
,主图指标,顶底信号,突破,转折信号,都很明显
程序员的编辑器——VIM(zz) - 饮水思源
留言本改自柏图留言本 BTB 1.2 管理员:zz809 密 码:zz809.com
zz_layer.il是源代码,install.bat是安装的 使用举例:zz 1-3 4 126 127 层号定义,与PADS类似:1~120是etch ;SolderMask: 121(top) 128(bot) ;Silkscreen: 126(top) 129(bot) ;Assembly: 127(top) 130(bot) ;Paste...
我的资源zzzzzzzzzzzzz
2023年全国职业院校技能大赛--ZZ058 动漫制作赛项赛题
基于国家标准的endnote的输出样式,适用于学生党论文插入文献参考,较为方便。endnote论文神器。
ZZ-2021030 网络搭建与应用赛项赛卷《网络环境》.pdf
ZZ公司安全生产守则.docx
zz;ldkfjntmtmsbggyyessdd
ZZ Fibo Trader 简单地展示了 Simple ZZ Fibo 的使用, 它在之字转向的波动中绘制斐波那契线。另外,算法还展示了通过抛物线系统进行移动止损的操作。
博途V16授权 博途V16授权 博途V16授权 博途V16授权 TIA V16 AX NF ZZ TIA V16 AX NF ZZ TIA V16 AX NF ZZ TIA V16 AX NF ZZ TIA V16 AX NF ZZ
ZZ-2022004 建筑CAD赛项赛题 中职赛项 适合正在准备技能大赛的人群
cad标高归零,好用的
ZZ-2022010 机器人技术应用赛项赛题 中职赛项 适合正在准备技能大赛的人群