Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB: Assign breakpoint to change of symbol

Tags:

c

debugging

gdb

I'm debugging a C application that has a segmentation fault. I already identified the variable that causes the problem. However, I do not know yet, when the variable is assigned so that it causes the Segmentation Fault.

Is there a way to set a breakpoint in GDB if a new value is being assigned to an existing variable?

like image 315
Frank Vilea Avatar asked Dec 27 '22 18:12

Frank Vilea


1 Answers

You need a watchpoint:

(gdb) watch my_var
like image 123
Nikolai Fetissov Avatar answered Dec 31 '22 14:12

Nikolai Fetissov