`
iunknown
  • 浏览: 407980 次
社区版块
存档分类
最新评论

[zz]break when opening certain file

阅读更多
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

    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 ZZ561401.CAB

    wincc AX NF ZZ

    wincc SIMATIC WinCC是第一个使用最新的32位技术的过程监视系统,具有良好的开放性和灵活性。 从面市伊始,用户就对SIMATIC WinCC印象深刻。

    超出NLO QCD的高横向动量的ZZ产生

    我们研究了四轻子最终状态ℓ+ℓ-ℓ+ℓ-的产生,这些状态主要由一对弱电Z玻色子ZZ产生。 使用LoopSim方法,我们合并ZZ和ZZ + jet的NLO QCD结果,并获得ZZ产生的近似NNLO预测。 还包括对ZZ过程的精确胶子融合环平方的...

    zz CAD快速计算长度插件

    在CAD中想要快速测量长度,在CAD工具栏找到加载应用程序,再点击加载 加载成功后在输入栏输入“zz”(不分大小写)在选择你需要测量的线段即可。

    Zz归零.LSP

    cad标高归零,好用的

    ZZ_MODIFIED_GEEBINF.ENS.zip endnote的样式文件

    标题中的“ZZ_MODIFIED_GEEBINF.ENS.zip”是一个压缩包文件,主要包含一个名为“ZZ_MODIFIED_GEEBINF.ENS”的文件。这个文件是一种特殊格式,用于定义EndNote的引用样式。EndNote是一款强大的文献管理软件,广泛应用...

    中医大夫助理信息系统 zz-doctor

    《中医大夫助理信息系统 zz-doctor 深度解析》 中医大夫助理信息系统“zz-doctor”是一款基于Android平台的应用程序,旨在为中医医生提供智能化、便捷化的诊疗辅助工具。通过深入剖析这款应用的源码,我们可以了解...

    3_Level_ZZ_Semafor.zip_3 level_zz_3_Level_ZZ_semafor_ZZ Semafor_

    ,主图指标,顶底信号,突破,转折信号,都很明显

    ZZ Fibo Trader - MetaTrader 5EA.zip

    《ZZ Fibo Trader - MetaTrader 5 EA 深度解析》 ZZ Fibo Trader 是一款专为 MetaTrader 5(MT5)平台设计的自动交易专家顾问(EA),其核心在于结合了斐波那契回调线分析和抛物线止损系统,为交易者提供了智能化的...

    zz809.com留言本

    《zz809.com留言本》是一款基于网络的互动交流平台,源于柏图留言本BTB 1.2版本,并经过管理员zz809的定制和优化。这个平台旨在为用户提供一个简便、实用的在线留言功能,使得用户可以方便地在网站上发表评论、交流...

    变形版SD ZZ高达 纸模型

    "变形版SD ZZ高达"是一款深受高达爱好者喜爱的纸模型,它源于日本著名的机器人动漫《机动战士Z高达》中的角色。SD(Super Deformed)是日本动漫中的一个术语,意为超级变形,通常指的是角色被夸张地简化和可爱化,...

    DT_ZZ_optimized - MetaTrader 4脚本.zip

    《DT_ZZ_optimized - MetaTrader 4脚本:深入解析与优化技术》 MetaTrader 4(MT4)是一款广泛应用于外汇、期货和股票交易的交易平台,它提供了丰富的技术分析工具和自动化交易功能。在MT4平台中,用户可以编写...

    zz_layer.rar

    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

    我的资源zzzzzzzzzzzzz

    ZZ_MODIFIED_GEEBINF.ENS

    基于国家标准的endnote的输出样式,适用于学生党论文插入文献参考,较为方便。endnote论文神器。

    geebinf modified by zz.ens

    写中文文章,或者外文,参考文献格式。例如:[1] Niu M, Hu Y, Sun S, et al. A novel hybrid decomposition-ensemble model based on VMD and HGWO for container throughput forecasting[J]. Applied Mathematical...

    ZZ18000/25.5/50型四柱支撑掩护式支架的研制与应用

    ZZ18000/25.5/50型四柱支撑掩护式支架是一款专为煤矿快速搬家和回撤巷道支护设计的高效设备。这款支架在煤炭开采中扮演着至关重要的角色,特别是在高产高效矿井中,其有效提升了综采设备的利用率和搬家倒面的速度。 ...

    ZZ-2021030 网络搭建与应用赛项赛卷《网络环境》.pdf

    ZZ-2021030 网络搭建与应用赛项赛卷《网络环境》.pdf

Global site tag (gtag.js) - Google Analytics