gdb - What is the difference between dprintf vs break + commands + continue? -
for example:
dprintf main,"hello\n" run
generates same output as:
break main commands silent printf "hello\n" continue end run
is there significant advantage using dprintf
on commands
, e.g. considerably faster (if why?), or has different functionality?
or convenience command?
source
in 7.9.1 source, breakpoint.c:dprintf_command
, defines dprintf
, calls create_breakpoint
break_command
calls, both seem use same underlying mechanism.
the main difference dprintf
passes dprintf_breakpoint_ops
structure, has different callbacks , gets initialized @ initialize_breakpoint_ops
.
dprintf
stores list of command strings of commands
command, depending on settings. are:
- set @
update_dprintf_command_list
- which gets called on after
type == bp_dprintf
check insideinit_breakpoint_sal
- which gets called
create_breakpoint
.
when breakpoint reached:
bpstat_stop_status
gets called , invokesb->ops->after_condition_true (bs);
breakpoint reachedafter_condition_true
dprintf
dprintf_after_condition_true
bpstat_do_actions_1
runs commands
there 2 main differences.
first, dprintf
has additional output modes can used make work in other ways. see help set dprintf-channel
, or manual, more information. think these modes reason dprintf
added separate entity; though @ same time specialized , unlikely of general interest.
more usefully, though, dprintf
doesn't interfere next
. if write breakpoint , use commands
, , next
on such breakpoint, gdb forget next
, act if had typed continue
. longstanding oddity in gdb scripting language. dprintf
doesn't suffer problem. (if need similar functionality ordinary breakpoint, can python.)
Comments
Post a Comment