severity 681533 minor
retitle 681533 Better available documentation for use of Python gdb module for
scripting
thanks
sorry about the noise -- but apparently this is RTFM and might need a
bit of docs improvement to make things clearer (e.g slight tune up of
the manpage) -- thus downgrading to minor and retitling
as far as I see it (and I am a new to python scripting of gdb)
gdb "Python module" is not intended to be imported outside of the
gdb process. That is why it was not made available publicly and
PYTHONPATH'ing it is an incorrect course of action. Two ways I see to
use it:
1. in gdb shell:
(gdb) python import gdb
(gdb) python print dir(gdb)
['ARCH_FRAME', 'BP_ACCESS_WATCHPOINT', ....
2. in gdb scripts to be passed to gdb via -x cmdline option (must have .py
extension). Such scripts could thus just have a shebang:
#!/usr/bin/gdb -x
and be executed from a cmdline, e.g.:
$> cat ~/deb/troubleshoot_segfault.py
#!/usr/bin/gdb -x
import gdb
def on_stop(p):
gdb.execute("bt full")
gdb.execute("handle SIGUSR1 nostop")
gdb.execute("handle SIGPIPE nostop")
gdb.events.stop.connect(on_stop)
gdb.execute("r")
$> ~/deb/troubleshoot_segfault.py --batch ./c
Program received signal SIGSEGV, Segmentation fault.
0x00000000004004bc in f () at c.c:4
4 v = *k;
#0 0x00000000004004bc in f () at c.c:4
k = 0x0
v = 0
#1 0x00000000004004d1 in main () at c.c:8
No locals.
On Mon, 23 Jul 2012, Debian Bug Tracking System wrote:
> Processing commands for [email protected]:
> > severity 681533 important
> Bug #681533 [gdb] gdb Python module doesn't load
> Severity set to 'important' from 'normal'
> > thanks
> Stopping processing here.
> Please contact me if you need assistance.
--
Yaroslav O. Halchenko
Postdoctoral Fellow, Department of Psychological and Brain Sciences
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834 Fax: +1 (603) 646-1419
WWW: http://www.linkedin.com/in/yarik
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]