* [RFC] Setting breakpoint commands from the Python API
@ 2016-12-19 18:51 Martin Galvan
2016-12-19 19:08 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Martin Galvan @ 2016-12-19 18:51 UTC (permalink / raw)
To: gdb, tom, Pedro Alves, dgutson .
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!
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC] Setting breakpoint commands from the Python API
2016-12-19 18:51 [RFC] Setting breakpoint commands from the Python API Martin Galvan
@ 2016-12-19 19:08 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2016-12-19 19:08 UTC (permalink / raw)
To: Martin Galvan; +Cc: gdb, tom, Pedro Alves, dgutson .
>>>>> "Martin" == Martin Galvan <omgalvan.86@gmail.com> writes:
Martin> Doing gdb.execute('commands 2 3 4\necho "Hello World"\nend')
Martin> doesn't work either.
Yes, IIRC multi-line commands can't be evaluated with gdb.execute.
It would be nice to lift this restriction.
Martin> In view of this I'm thinking of adding a new 'set_commands' method to
Martin> gdb.Breakpoint. For the implementation I was looking at
Martin> do_map_commands_command, which is called when issuing 'commands' from
Martin> the gdb CLI, but can also take an already parsed command (when
info-> control != NULL). However, before I went any further I wanted to
Martin> ask you guys if there's another way to do this that I'm missing, or if
Martin> there are any suggestions.
How about just allowing assignment of the .commands attribute? I think
that would be more in keeping with the other attributes of
gdb.Breakpoint.
thanks,
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-19 19:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-19 18:51 [RFC] Setting breakpoint commands from the Python API Martin Galvan
2016-12-19 19:08 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox