GDB break on object function call

I am debugging a problem and I want to break every call to a method that has a specific object as the 'this' parameter. Is this possible in GDB?

+6
source share
3 answers

It is easy. You can use a command like b A::a if (this==0x28ff1e) .

+5
source

This parameter should only be methods that are included in the class itself. Therefore, you just need to set breakpoints for all the class methods you are looking at. I'm not sure there is an easy way to do this.

0
source

I want to break every call to a method that has a specific object as the 'this' parameter

This means that you want to break down each member function of a particular class for which the object was created.

For convenience, we myclass_implementation.cpp that all member functions are defined in a specific cpp file, such as myclass_implementation.cpp

You can use gdb to apply a breakpoint for each function inside myclass_implementation.cpp as follows:

 rbreak myclass_implementation.cpp:. 

Let's say you want to break up some specific functions, such as getter functions that start with Get, then you can use gdb to apply breakpoints as follows:

 rbreak myclass_implementation.cpp:Get* 
0
source

Source: https://habr.com/ru/post/898421/


All Articles