How to configure gdb watchpoints in a program consisting of many C ++ files?

I am trying to set a watchpoint to monitor a variable in a package consisting of many C ++ files.

There are many files.

abc.cpp qwe.cpp .. xyz.cpp etc.

I want to control the variable "temp" in some qwerty () function in the abc.cpp file. How to set the watchpoint?

I tried

watch abc.cpp :: temp watch abc.cpp: temp watch time

but I see errors There are no characters 'abc.cpp :: temp', 'abc.cpp: temp', 'temp' not in the current context Also, the information checkpoints tell me that no watchpoints are set. Please note that I can successfully set breakpoints for the same variable

+3
source share
2 answers

I always set a breakpoint in the function, then set the watchpoint when I delete it so that I am in context, and then delete the breakpoint if necessary.

+3
source

Do you want to make conditional breakpoints? If you can use the commands below.

(gdb) break abc :: qwerty ()
(gdb) 1 temp = 1 // If you want to break when the value is temp = 1.

0
source

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


All Articles