Linux 如何使用命令标志在未来的共享库上设置断点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/100444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 16:28:37  来源:igfitidea点击:

How to set breakpoints on future shared libraries with a command flag

c++clinuxunixgdb

提问by Shlomi Fish

I'm trying to automate a gdb session using the --commandflag. I'm trying to set a breakpoint on a function in a shared library (the Unix equivalent of a DLL) . My cmds.gdb looks like this:

我正在尝试使用该--command标志自动执行 gdb 会话。我正在尝试在共享库(与 DLL 的 Unix 等效项)中的函数上设置断点。我的 cmds.gdb 看起来像这样:

set args /home/shlomi/conf/bugs/kde/font-break.txt
b IA__FcFontMatch
r

However, I'm getting the following:

但是,我得到以下信息:

shlomi:~/progs/bugs-external/kde/font-breaking$ gdb --command=cmds.gdb...
GNU gdb 6.8-2mdv2009.0 (Mandriva Linux release 2009.0)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i586-mandriva-linux-gnu"...
(no debugging symbols found)
Function "IA__FcFontMatch" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]

So it doesn't set the breakpoint after all. How can I make it default to answer "y" to set breakpoints on pending future shared library load?

所以它毕竟没有设置断点。如何使其默认回答“y”以在未决的未来共享库加载时设置断点?

I recall that I was able to do something, but cannot recall what.

我记得我能够做某事,但不记得是什么。

采纳答案by Shlomi Fish

Replying to myself, I'd like to give the answer that someone gave me on IRC:

回复自己,我想给出IRC上有人给我的答案:

(gdb) apropos pending
actions -- Specify the actions to be taken at a tracepoint
set breakpoint -- Breakpoint specific settings
set breakpoint pending -- Set debugger's behavior regarding pending breakpoints
show breakpoint -- Breakpoint specific settings
show breakpoint pending -- Show debugger's behavior regarding pending breakpoints

And so set breakpoint pending ondoes the trick; it is used in cmds.gdblike e.g.

所以设置断点挂起就行了;它用于cmds.gdb例如

set breakpoint pending on
break <source file name>:<line number>

回答by RandomNickName42

With no symbols.

没有符号。

objdump -t /lib/libacl.so
SYMBOL TABLE:
no symbols
objdump -T /lib/libacl.so
...
00002bd0 g    DF .text  000000d0  ACL_1.0     acl_delete_entry
...


(gdb) break 0x0002bd0 

(gdb) x/20i acl_delete_entry
0x2bd0 <acl_delete_entry>:      stwu    r1,-32(r1)
0x2bd4 <acl_delete_entry+4>:    mflr    r0
0x2bd8 <acl_delete_entry+8>:    stw     r29,20(r1)
0x2bdc <acl_delete_entry+12>:   stw     r30,24(r1)
0x2be0 <acl_delete_entry+16>:   mr      r29,r4
0x2be4 <acl_delete_entry+20>:   li      r4,28972

回答by ?xl

OT: In terminal it would look like this to debug Caja in one line:

OT:在终端中,在一行中调试 Caja 看起来像这样:

gdb -ex "set breakpoint pending on" -ex "break gdk_x_error" -ex run --args caja --sync