Questions tagged [gdb-python]

Questions related to GDB's Python API.

Questions related to GDB's Python API.

121 questions
2
votes
2 answers

How to quit python script in gdb-python?

I am writing a python(v2.7) script in GDB(v7.5.1-0.7.29). I want to quit the python script when certain condition got false. But i do not want to quit GDB. I tried using sys.exit(), exit() and quit(), but in those case they also quit GDB. Is there…
2
votes
2 answers

GDB pretty-printer: printing an array when the size is known by the parent struct

I have a struct in C++ something like this: struct HeapBlock { char* data; } struct DataBlock { int size; HeapBlock hb; } These are part of a framework and have several other members, helpers and so on, but these are are the important…
Inductiveload
  • 6,094
  • 4
  • 29
  • 55
2
votes
1 answer

gdb python: Walking through array of structures

Can't we traverse the array of structs ? I mean for each index by checking the content of structs and print each field accordingly? As we can do for a struct like s = gdb.parse_and_eval(expr) for k in s.type.keys(): v = s[k] if…
Baijnath Jaiswal
  • 377
  • 5
  • 17
2
votes
1 answer

Adding source instrumentation code - Is source-to-source compiler right approach? How to build one?

I am working on a project where I need to track changes to particular set of variables in any given application code to model memory access patterns. I can think of two approaches mainly, please give your thoughts on them. My initial thought is…
Microkernel
  • 1,347
  • 4
  • 17
  • 38
1
vote
0 answers

Find a Rust enum variant name from a GDB-Python Value

Rust recently introduced #![debugger_visualizer(gdb_script_file = "...")] to allow embedding GDB pretty-printers in libraries. I'm playing around with this feature, with not that much knowledge in GDB pretty-printers in the first place, and I'm…
MrAnima
  • 555
  • 1
  • 4
  • 13
1
vote
1 answer

How do I debug through a gdb helper script written in python?

there may very well be an answer to this question, but it's really hard to google for. you can add commands to gdb by writing them in python. I am interested in debugging one of those python scripts that's running in gdb session. my best guess is to…
stu
  • 8,461
  • 18
  • 74
  • 112
1
vote
2 answers

Can I use a variable in place of a math operator?

What I'm trying to do is ask the user for a type of math operator(Not sure if I used the correct term. I'm new to python.), and use that in place of a math operator in an equation. Here I tried: math_thing = int(input('Enter a type of math…
1
vote
0 answers

Print output with color style in GDB python script?

I'd like to call print('somestr') in a python script called in GDB ((gdb) source my_script.py), and style the output in console colors. I tried the python colorama package which works in terminal, but not when invoking from GDB. Is there a way to…
Thomson
  • 20,586
  • 28
  • 90
  • 134
1
vote
1 answer

How to implement a GDB function depending on the architecture

I'm writing a GDB script in python to print some debug information of the application. The thing is multiple architectures are supported: x86, alpha, aarch64, and probably some more later. The function printing the debug information varies from the…
Some Name
  • 8,555
  • 5
  • 27
  • 77
1
vote
0 answers

How to specify the python version gdb use

I need to run gdb with python script, like ~/.gdb/qtprinters.py which require a high version python. our system gdb use default python version 2.7 and I installed a new gdb in my home with version 12.1 and also install an anaconda3 tool, but seems I…
BruceSun
  • 144
  • 9
1
vote
1 answer

How does GDB pretty printer know the output format the user is requesting?

I have a few complex classes generated by a third party domain-specific tool. The classes are complex because the tool tries to be generic as much as possible, so that I was asked to design a GDB pretty printer python script to improve the debugging…
1
vote
0 answers

Debug symbols when using poetry install

Can I install a python package with binary extension compiled with debug symbols when using poetry? For example, this way a gdb or py-spy will get the necessary pretty-printing output
Ojomio
  • 843
  • 1
  • 8
  • 17
1
vote
0 answers

How to get info from crash dump of python

I have a python server running (cherrypy webserver). When a URL /a is hit, it uses ctypes to call a C library function. The library function is causing a seg-fault which results in the python server crashing and generating a 250MB crash dump. If I…
lucifer
  • 369
  • 6
  • 19
1
vote
1 answer

Listing members of value in gdb using python api

I'm trying to find a way to get a list of members of a c++ class object from the python api in GDB. So far, the only solution I've been able to find has been to use the ptype and then try to parse it for the members, and I was wondering if…
anirudh
  • 4,116
  • 2
  • 20
  • 35
1
vote
0 answers

How to examine a gdb.Type

I'm writing some specialized gdb scripting in python, and I have some questions about the gdb.Type class. I see a lot of methods for producing related types, like Type.const and Type.volatile, but how do I examine a Type instance, and ask "is this…
1 2
3
8 9