Questions tagged [gdb-python]

Questions related to GDB's Python API.

Questions related to GDB's Python API.

121 questions
42
votes
5 answers

How to enable gdb pretty printing for C++ STL objects in Eclipse CDT?

I'm trying to add pretty printing for STL objects in eclipse cdt. I tried to follow the steps described here: http://sourceware.org/gdb/wiki/STLSupport I checked out the python folder, but I can't seem to get this done... I created a gdbinit and…
AlejandroVK
  • 7,373
  • 13
  • 54
  • 77
17
votes
4 answers

How to script gdb (with python)? Example add breakpoints, run, what breakpoint did we hit?

I'm trying to create a little unit test with gdb, for a embedded mcu that is controlled by OpenOCD (that gives me control over my target via a gdb server). So I would like to automate this with some scripting of gdb. I would like to write some kind…
Johan
  • 20,067
  • 28
  • 92
  • 110
12
votes
4 answers

gdb python api: is it possible to make a call to a class/struct method

In Python, I have a a variable var of type gdb.Value that corresponds to a C++ struct. The struct has a method void foo(). I can evaluate this expression var['foo']. But var['foo']\() will complain saying RuntimeError: Value is not callable (not…
aayupov
  • 267
  • 1
  • 10
9
votes
1 answer

python-gdb error: Python Exception Type does not have a target

I'm running python 3.6.6-debug (installed via pyenv) and I've copied the associated libpython.py from cpython/Tools/gdb/libpython.py to ~/.config/gdb (with the v3.6.6 tag checked out). In my .gdbinit I have: source ~/.config/gdb/libpython.py For…
Dylan Cali
  • 1,463
  • 1
  • 13
  • 17
9
votes
1 answer

Error printing variables while debugging Cython

I'm trying to debug some Cython code with gdb that is wrapping C++ code to be called from Python. I followed the instructions in the documentation but I'm getting some errors while debugging that are unrelated to my code. Example: (gdb) cy print…
hygorxaraujo
  • 659
  • 6
  • 19
8
votes
1 answer

How to debug a stuck asyncio coroutine in Python?

There are lots of coroutines in my production code, which are stuck at unknown position while processing request. I attached gdb with Python support extension to the process, but it doesn't show the exact line in the coroutine where the process is…
shoraii
  • 81
  • 3
7
votes
1 answer

Does pdb has the layout src like gdb?

In gdb, we can use layout src to get a pretty good debug text-UI. Does pdb(The Python Debugger) have something equivalent? In pdb, I can only see the next line that is going to be executed, which is annoying. gdb text ui is shown below:
youkaichao
  • 1,938
  • 1
  • 14
  • 26
7
votes
1 answer

gdb.execute blocks all the threads in python scripts

I am scripting GDB with Python 2.7. I am simply stepping instructions with gdb.execute("stepi"). If the debugged program is idling and waiting for user interaction, gdb.execute("stepi") doesn't return. If there is such a situation, I want to stop…
Antoine C.
  • 3,730
  • 5
  • 32
  • 56
7
votes
2 answers

How to debug python script in C level using GDB. Give me a simple example for this

How to debug python script in C level using GDB. Give me a simple example for this.My primary goal is to get the trace of libc function called from my python script.
ankit jain
  • 350
  • 2
  • 12
6
votes
1 answer

Can GDB set a breakpoint on a sequence of function calls?

I'd like to inspect some global variables before a crash happens. The issue only reproduces on a certain stack trace and setting a breakpoint on the innermost function (or any other from the stack) will not get me close enough. Can I achieve the…
patraulea
  • 652
  • 2
  • 5
  • 26
6
votes
0 answers

In GDB Python script, array indexing fails if frame’s language is Ada

I have a script to work out how much free stack space there is in each FreeRTOS task. GDB’s language is set to auto. The script works fine when the current language is c, but fails when the current language is ada. I have, in the class Stacks, tcb_t…
Simon Wright
  • 25,108
  • 2
  • 35
  • 62
6
votes
1 answer

GDB pretty-printing: returning string from a children()'s iterator, but displayed as a char[]

I have a handy class that I use to allow me to easily add a set of "summariser" functions to a GDB pretty printer (for example, a Rect class could have an [Area] field, computed by Python). it then prints all the existing children as well, so you…
Inductiveload
  • 6,094
  • 4
  • 29
  • 55
4
votes
2 answers

Is it possible to generate a pseudo-type so that I can fake out gdb's pretty printing system?

I'm writing a pretty printer in python for gdb, and am slowly getting the hang of the methodology. Trying to find actual documentation as to how this system works with examples of what is expected coming out of the methods is like pulling teeth. …
Adrian
  • 10,246
  • 4
  • 44
  • 110
4
votes
2 answers

How to pass arguments to a python gdb script launched from command line

I'd like to pass some command line arguments to a python script run via gdb command, but importing the gdb module in python removes the argv attribute from sys. How do I access arg1 and arg2 within my python script shown in my example? Command line…
user3407196
4
votes
1 answer

gdb-python : Parsing structure's each field and print them with proper value, if exists

I am writing a python script to automate debugging core dump from gdb. i am trying to print data structure which includes kernel data structures and lists(e.g. struct list_head). For example the structure is something like this: struct my_struct { …
Baijnath Jaiswal
  • 377
  • 5
  • 17
1
2 3
8 9