简体   繁体   中英

GDB break on object function call

I'm debugging an issue, and I want to break on every method call that has a specific object as the 'this' parameter. Is this possible in GDB?

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

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

This means that you want to break on every member function of a particular class for which the object has been instantiated.

Let's say for convenience that all the member functions are defined in a particular cpp file such as myclass_implementation.cpp

You can use gdb to apply breakpoint on every function inside myclass_implementation.cpp this way:

rbreak myclass_implementation.cpp:.

Let's say you want to break on some specific functions such as getter functions which start with Get, then you can use gdb to apply breakpoints this way:

rbreak myclass_implementation.cpp:Get*

The this parameter should only be the methods that are included in the class itself. So you should just need to set breakpoints for all Of the methods of the class you are looking at. I'm not sure there is a simple way to do that though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM