From: Tom Tromey <tromey@redhat.com>
To: Sinbad <sinbad.sinbad@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: gdb user defined function
Date: Tue, 17 Jan 2012 16:29:00 -0000 [thread overview]
Message-ID: <m362gamgxt.fsf@fleche.redhat.com> (raw)
In-Reply-To: <CAOCFqOt9LA_FzGkYaeLciwHRjDZKnSLQxQ7mL40O1Yuh=cHk9Q@mail.gmail.com> (Sinbad's message of "Tue, 17 Jan 2012 11:40:17 +0530")
>>>>> "Sinbad" == Sinbad <sinbad.sinbad@gmail.com> writes:
Sinbad> i've never used python with gdb or python at all. but i want to learn
Sinbad> enough of python to achieve the following. how do one use python
Sinbad> with gdb, will gdb become slow, can you give me some pointers
Sinbad> on how to achieve the following using python.
There are plenty of docs:
http://sourceware.org/gdb/onlinedocs/gdb/Python.html
What you want is the stuff about writing a function:
http://sourceware.org/gdb/onlinedocs/gdb/Functions-In-Python.html#Functions-In-Python
and also the Value API.
The core of your function will probably be something along these lines:
try:
arg = arg.deref()
return 1
except:
return 0
Untested of course.
About speed... well, evaluating Python does have a cost. I wouldn't
worry about it in advance; especially if the alternative is using the
gdb CLI, which in general is less well-tuned than Python. If your
situation is truly performance critical, then (1) measure the effects of
Python, and (2) if it is too slow, write a convenience function in C
instead.
Sinbad> Please don't yell ;)
Don't worry.
Tom
next prev parent reply other threads:[~2012-01-17 16:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-15 2:51 Sinbad
2012-01-16 20:46 ` Tom Tromey
2012-01-17 6:10 ` Sinbad
2012-01-17 16:29 ` Tom Tromey [this message]
2012-01-17 16:31 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m362gamgxt.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb@sourceware.org \
--cc=sinbad.sinbad@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox