127 questions
1
vote
1
answer
62
views
How can I resolve type traits in gdb Python API?
Consider a type like
#include <type_traits>
template<typename T>
struct Foo {
std::remove_cv_t<T> m;
};
which uses a type trait to deduce the type of one of its members from a ...
0
votes
0
answers
59
views
gdb: invoke custom python command without printing it
Since gdb has only one global set print elements that affects all array-like types, it has been necessary to use a very short value like set print elements 4. But in certain specific cases it can be ...
1
vote
0
answers
53
views
python gdb frame unwind does not recogonize structure member variables
I am trying to print the value of a member variable of a structure instantiated in the caller function as below. While the read_var on older() frame works for the structure variable itself, it doesn't ...
0
votes
1
answer
67
views
gdb pretty printing: How do I demangle a type using gdb python module?
Pretty much what the question says.
Context: in cuda-gdb, if you have a templated struct and want to know what type it is, you will get something like this: @something mangled_name. I want to write a ...
0
votes
0
answers
806
views
Issues Connecting Ghidra to GDBServer on Windows
all buttons non active
I'm trying to set up remote debugging for my application on Windows using Ghidra and GDBServer.
trying_connect_to_gdb
GDB successfully connects to GDBServer. However, when I ...
0
votes
0
answers
132
views
How to find memory address of a function which isn't called in main, but declared and defined outside main in gdb
tl,tr: Find memory address of an uncalled function, without having source code(or having function name) in gdb.
Issue: given a source code given to me, which looks like this:
#include<stdio.h>
...
0
votes
1
answer
74
views
python gdb extension: i'm trying to get the calling line and file info for a macro call but getting wrong values due to comments
I have the following C++ code:
main.cpp:
#include "a.h"
int main(){
int x[3];
some_macro(x)
// comment
// comment
return x[2];
}
a.h:
template <typename T>
inline ...
0
votes
0
answers
786
views
How to read in a (compressed) .gdb using R and or SF Package?
I want to open a GDB (A directory that ends with ".gdb") in R. I am assuming that some sublayers or the whole GDB is compressed, though I do not know how to confirm this. I have tried ...
2
votes
1
answer
167
views
Overwriting segfaulting instructions with NOPs doesn't fix segfault in gdb
I thought it would be cool to add a command to gdb that will look at the instruction pointer and overwrite the current instruction with NOPs. The idea being that if you are debugging, and your program ...
0
votes
1
answer
35
views
In gdb while debugging a core file, how do I read a structure given the address using a python gdb extension?
I am writing a python gdb extension. Given the address of a structure, I would like to read the core file and obtain a gdb.Value object out of it. How do I go about doing that?
0
votes
0
answers
27
views
Why can't I connect gdb to the main function by running a python script
enter image description here
gdb opens a local file and points to mian function without using a script. I hope this script I wrote will point to main function as well,Another question is does gdb ...
0
votes
1
answer
249
views
memset() does not work when called in GDB thru Python APIs
I'm trying to memset the data at some address in a gdb session.
Lets say it is initially filled with 1's and I'm trying to overwrite it with 0's.
(gdb) set $i = (int*)malloc(sizeof(int))
(gdb) set *$...
0
votes
1
answer
268
views
Get the char* value with python gdb
With GDB and Python I tried to get the char* value on x1 register
python
a= gdb.execute("x/s $x1", to_string=True)
print(a)
end
But I got
0xbb4aaa: "SomeString"
I want to ...
0
votes
1
answer
187
views
How do I run GDB with the arguments I normally write in the terminal manually?
I have some program, the essence of which is to analyze crashes, it works with GDB.
An example of how it works: I run an application in GDB which I want to analyze for crashes, then I load my program ...
0
votes
1
answer
3k
views
Apply material and texture image using python in blender 3.4
Code is working it is importing my files and exporting into .glb format
but issue when i open glb file it dose not contain texture image it shows grey...
here is my code
import bpy
import os
dir_path ...
0
votes
0
answers
38
views
Implement custom operators with GDB python API
As an example lets say I have a linked list implemented in C. Can I use the GDB python API to implement a custom array access operator so that I can get a value from the list like myList[0] while ...
0
votes
0
answers
125
views
writing a c++ script for using GDB commands and GDB results (like variable values) while running another c++ program
I need a c++ script to automate GDB debugging another c++ program. the c++ script has to be able to run gdb commands and get the results from it and use it inside the script to save variable values ...
1
vote
1
answer
724
views
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 ...
0
votes
0
answers
62
views
setting command alias through python API in gdb
I have written a small python script that adds new commands to gdb and for others to use it, they can just source the python file in their ~/.gdbinit, but I would now like to add some useful aliases ...
1
vote
2
answers
874
views
Can I use a variable in place of a math operator? [duplicate]
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:
...
0
votes
0
answers
177
views
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 ...
2
votes
0
answers
341
views
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, ...
0
votes
0
answers
162
views
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<Bar>')
In one version, it works just fine. However, in ...
0
votes
0
answers
66
views
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 ...
0
votes
1
answer
849
views
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"
...
1
vote
2
answers
335
views
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 ...
1
vote
1
answer
219
views
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 ...
0
votes
1
answer
166
views
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 ...
0
votes
1
answer
559
views
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 ...
0
votes
0
answers
258
views
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:
...
2
votes
0
answers
152
views
Viewing Data in Python Extensions GDB
Suppose I have a class:
class RawMessage(NamedTuple):
data: Dict
timestamp: float
...
The keys and values in this dictionary are probably all integers, but I don't want to state that with ...
1
vote
0
answers
1k
views
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....
2
votes
0
answers
370
views
Put a breakpoint in shared library with GEF GDB
I want to put a breakpoint in a Linux share library in specific offset ( in libTest.so in function 0x1234 ) while I debugging with GEF GDB. But I want to put it with gdb script.
If I run vmmap ...
2
votes
1
answer
246
views
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 ...
0
votes
0
answers
72
views
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 ...
1
vote
0
answers
124
views
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 ...
0
votes
1
answer
317
views
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 ...
4
votes
2
answers
455
views
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 ...
1
vote
0
answers
327
views
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
0
votes
0
answers
319
views
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 ...
2
votes
0
answers
232
views
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 ...
1
vote
1
answer
421
views
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 <value> and then ...
0
votes
1
answer
791
views
Makefile : no rule to make target '/constants.py.in' needed by '/constants.py'. Stop
i'm currently working on an ubuntu 18.0.4.5 machine and i've been trying to figure out the whole kernel debugging process.
I've stumbled upon the need to auto run GDB scripts along with the vmlinux ...
0
votes
0
answers
218
views
executing a function in the inferior process, and getting the returned result to python
As mentioned in a previous question (How to examine a gdb.Type) I'm writing some specialized gdb scripting in python.
I want to call a function pointer, obtained from the inferior process, on a value, ...
3
votes
2
answers
1k
views
How to set a gdb breakpoint on a label in all template function instantiations
Suppose I have the following C++:
template <int I> int bar(int i) {
++i;
label1:
return I * i;
}
int main(int argc, char **) { return bar<2>(argc); }
Is it possible to set a gdb ...
1
vote
0
answers
346
views
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 ...
2
votes
1
answer
1k
views
Can't insert hardware breakpoint with GDB
I tried to set watch into address
(gdb) watch 0x7536546 but I got an error
Warning:
Could not insert hardware watchpoint 6.
Could not insert hardware breakpoints:
You may have requests too many ...
0
votes
2
answers
625
views
Unload source file with GDB
(gdb) source script.py loaded script file to GDB
How to unload that script? How to unload all loaded script or view all script that loaded ?
0
votes
1
answer
371
views
Run python script with gdb with alias
When I want to run python into gdb I using
source /tmp/gdb/tmp/parser.py
Can I set an alias so in the next time I want to call this script I use only parser.py or parser (without setting the script ...
9
votes
2
answers
3k
views
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 ...