Questions tagged [gdb-python]

Questions related to GDB's Python API.

Questions related to GDB's Python API.

121 questions
0
votes
0 answers

How to get Python code visible in GDB TUI window?

For debugging Python code I use PDB++. It is a nice drop-in replacement for PDB and allows me (in sticky mode) to step through code and interact with it in a text terminal in a visual way. However, when a Python program is already running, it is not…
0
votes
0 answers

Get source line of a struct definition in GDB python script?

There is gdb.lookup_type("SomeType") in GDB python API as listed blow, but I cannot find a way to get the source file and line number where the type is defined, much like what the GDB command info types ^SomeType$ does. Is it possible via GDB python…
Thomson
  • 20,586
  • 28
  • 90
  • 134
0
votes
0 answers

Looking up templated type in gdb's Python

I've loaded up two versions of a C++ library in gdb, opened up the built-in Python interpreter, and run import gdb gdb.lookup_type('Foo') In one version, it works just fine. However, in the other, I get gdb.error: No type named…
Daniel Walker
  • 6,380
  • 5
  • 22
  • 45
0
votes
0 answers

GDB-python register_changed event handler

I am creating a GDB TUI python extension for embedded debugging. The python script is being run by the GDB. Trying to create a handler for register_changed event in GDB according to the documentation like so: def reg_changed_handler(event): …
peter_esp
  • 31
  • 2
0
votes
1 answer

gdb-multiarch lx-symbols failed

I am trying to debug an aarch64 Linux kernel loaded in QEMU from x86 host. When 'lx-symbols' command executed for loading the symbols from gdb, it has shown Undefined command: "lx-symbols" The I have tried executing 'add-auto-load-safe-path'…
Little Tree
  • 63
  • 1
  • 6
0
votes
0 answers

Python gdb show full backtrace

I'm writing a debug script for GDB using python and faced some weird behavior. I made a mistake somewhere in the script and everything that got printed when calling this command from GDB was: (gdb) some-command Python Exception
Some Name
  • 8,555
  • 5
  • 27
  • 77
0
votes
1 answer

Cast a struct member in GDB Pretty Print?

I want to pretty print this struct struct MyStruct { char buffer[16]; }. Depending on buffer[15] I want to print buffer as a 10 byte string or treat it as a pointer. The 10 byte case is simple and works return self.val['buffer'].string(length =…
0
votes
0 answers

how to iterate a std:map using python in gdb

I'm using python to analysis a core dump, and there is a variable named my_map having type std:map. I have got the gdb.Value object: py_val = gdb.parse_and_eval('my_map') and when I tried to iterate it with following code: for…
jasonxia
  • 321
  • 1
  • 8
0
votes
1 answer

Sending an automated Ctrl+D within GDB

I have a Python program that is feeding JSON input to a binary running in GDB which then reads that input using the C function fread(). The problem is that fread() needs a EOF/Ctrl-D to stop reading but the JSON input I am passing to the binary in…
Ben S
  • 1
  • 1
  • 1
0
votes
1 answer

gdb gef not working after fresh compilation of gdb 12.1 and gef 2022.06

I recently compiled gdb to 12.1 and attempted to install gef via the following cmd bash -c "$(curl -fsSL https://gef.blah.cat/sh)" the code on line 52 in the image is import abc the screenshot can be viewed here https://i.stack.imgur.com/vuGk7.png
pi0
  • 1
  • 1
0
votes
0 answers

How to let Python interact with the stdout/stdin of GDB console?

I am trying to make some automation testing with an embedded application running in an ARM Microcontroller. For the I/O exchange I have setup the Semihosting using arm-none-eabi-gdb as GDB client: arm-none-eabi-gdb my_binary.axf -ex "target…
0
votes
0 answers

gdb: how to make a filtering query for displaying a structure in a container?

In gdb currently I can print the contents of a container, such as std::list, which contains a structure type. This type, however, is quite large and I need only values of some selected fields in every item from the container. So, let's say, I have a…
Ethouris
  • 1,791
  • 13
  • 18
0
votes
0 answers

GDB, Delegating to an existing builtin pretty printer

I have a structure that wraps a std::map, whcih gdb knows how to pretty-print. I want to write a custom pretty-printer (with python), that delegates to the inner std:::map and maybe shows the count of existing entries in the map (and hoping that…
Ben Müker
  • 31
  • 5
0
votes
1 answer

How do I use the second Value constructor in gdb's python API?

In gdb's Values From Inferior documentation, there's a second constructor for creating objects within python. It states: Function: Value.__init__ (val, type) This second form of the gdb.Value constructor returns a gdb.Value of type type where the…
Adrian
  • 10,246
  • 4
  • 44
  • 110
0
votes
0 answers

gdb python: turn expression into address

I want to get the address from a value in the same way that the x examine command works. Internally, this seems to use value_as_address, which turns any gdb expression into a core address. I have not managed to find a binding for this anywhere in…
Yet Another User
  • 2,627
  • 3
  • 18
  • 27
1 2 3
8 9