views:

47

answers:

1

How to break with GDB at object destruction if there is no destructor?

+1  A: 

If there's no destructor, you cannot break on the destructor, as there is no op-code for the destructor. You have two choices on where to break:

  • If the object is allocated on the stack, break on the closing brace of the scope defining the variable.
  • If the object is allocated on the heap, break on the delete statement.
  • If the object is statically allocated in a data segment, then you can't.
Didier Trosset