gdb user defined function

Tom Tromey
Tue Jan 17 16:29:00 GMT 2012

>>>>> "Sinbad" == Sinbad  <> 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:

What you want is the stuff about writing a function:

and also the Value API.

The core of your function will probably be something along these lines:

      arg = arg.deref()
      return 1
      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

Sinbad> Please don't yell ;)

Don't worry.


More information about the Gdb mailing list