[RFC] Setting breakpoint commands from the Python API
Martin Galvan <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <CAN19L9E4D5xMZwEiEmG_57cdSiBM_VCg1eY1gyFcqzN24J_5zg@mail.gmail.com> |
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!