This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gdb user defined function


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]