3 ms·
A cool thing that you can do with gdb is to change the values of variables in programs that are already running, or calling their functions. For example you ca
by enriquto 6y ago
A cool thing that you can do with gdb is to change the values of variables in programs that are already running, or calling their functions. For example you can update a variable on your parent shell, e.g., "export" the variable $X to your parent (!) :
gdb --batch-silent -ex "attach $PPID" -ex "call (int)bind_variable(\"X\",\"$X\",0)"
I confess that I use this trick in my shell scripts more than strictly necessary, just for fun.
- mehrdadn 6y agoThat sounds both useful and horrifying. Do you use this for CI scripts? That's where I've needed this kind of functionality.
- enriquto 6y agoNever (yet) in production. I just use it for personal silly scripts, like changing the background color of my running xterms, and things like that.