[RFC] Setting breakpoint commands from the Python API
Martin Galvan
omgalvan.86@gmail.com
Mon Dec 19 18:51:00 GMT 2016
Hi everyone,
I'm working on a Python script to implement a new gdb command that
takes a 'source' breakpoint and applies its commands to a list of
'destination' breakpoints. Something like:
(gdb) commands 1
echo "Hello World"
end
(gdb) copycmd 1, 2 3 4
I'm having a bit of trouble setting the commands from the Python side.
>From what I saw, a gdb.Breakpoint's 'commands' attribute is read-only,
which leaves me with the option of using gdb.execute() to set the
commands manually. However, doing gdb.execute('commands') shows me the
usual "commands" prompt for entering the commands as if I was on an
interactive session (even though from_tty is False). Doing
gdb.execute('commands 2 3 4\necho "Hello World"\nend') doesn't work
either.
In view of this I'm thinking of adding a new 'set_commands' method to
gdb.Breakpoint. For the implementation I was looking at
do_map_commands_command, which is called when issuing 'commands' from
the gdb CLI, but can also take an already parsed command (when
info->control != NULL). However, before I went any further I wanted to
ask you guys if there's another way to do this that I'm missing, or if
there are any suggestions.
Thanks!
More information about the Gdb
mailing list