Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to name a break point in GDB?

Tags:

gdb

Is there any way to label/name breakpoints in GDB, in order to more easily identify them in, for instance, info b? And if so, how?

like image 829
brianmearns Avatar asked Mar 23 '13 02:03

brianmearns


2 Answers

No, there is no way to do this.

http://users.ece.utexas.edu/~adnan/gdb-refcard.pdf

like image 184
Chris White Avatar answered Sep 22 '22 16:09

Chris White


While this doesn't help with the output of info b, for other purposes where you need to reference the breakpoint later in commands you can store the breakpoint number of the last breakpoint from $bpnum in another convenience variable, e.g.:

b foo.c:123
set $im_a_breakpoint = $bpnum
# ... set some more breakpoints and do some other stuff ...
disable $im_a_breakpoint

As a further example, I'm using this pattern right now for a task: I'm using normal gdb breakpoints in code emitted by a JIT, which requires setting the breakpoint on the address after the code has actually been emitted as gdb modifies the code. For this purpose I actually disable the initial set-up breakpoint from within its own commands block:

set $cur_stop_point = 0x41aaa
b basic_jit_cache::copy_block if ((uint32_t)this->code_ptr()) > ($gencode + $cur_stop_point)
set $cur_stop_point_setup_bp = $bpnum
commands
  b *($gencode + $cur_stop_point)
  disable $cur_stop_point_setup_bp
  cont
end
like image 23
rakslice Avatar answered Sep 21 '22 16:09

rakslice