Let gdb.execute handle multi-line commands
This changes the Python API so that gdb.execute can now handle multi-line commands, like "commands" or "define". ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> PR python/22730: * NEWS: Mention gdb.execute change. * gdbcmd.h (execute_control_command): Don't declare. * python/python.c (execute_gdb_command): Use read_command_lines_1, execute_control_commands, execute_control_commands_to_string. * cli/cli-script.h (execute_control_commands) (execute_control_commands_to_string): Declare. (execute_control_command): Add from_tty parameter. * cli/cli-script.c (execute_control_commands) (execute_control_commands_to_string): New functions. (execute_user_command): Use execute_control_commands. (execute_control_command_1): Add "from_tty" parameter. Update. (execute_control_command): Likewise. testsuite/ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> PR python/22730: * gdb.python/python.exp: Test multi-line execute.
This commit is contained in:
parent
a913fffbde
commit
56bcdbea2b
8 changed files with 123 additions and 32 deletions
|
@ -588,6 +588,20 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
|
|||
{
|
||||
struct interp *interp;
|
||||
|
||||
std::string arg_copy = arg;
|
||||
bool first = true;
|
||||
char *save_ptr = nullptr;
|
||||
auto reader
|
||||
= [&] ()
|
||||
{
|
||||
const char *result = strtok_r (first ? &arg_copy[0] : nullptr,
|
||||
"\n", &save_ptr);
|
||||
first = false;
|
||||
return result;
|
||||
};
|
||||
|
||||
counted_command_line lines = read_command_lines_1 (reader, 1, nullptr);
|
||||
|
||||
scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0);
|
||||
|
||||
scoped_restore save_uiout = make_scoped_restore (¤t_uiout);
|
||||
|
@ -599,9 +613,10 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
|
|||
|
||||
scoped_restore preventer = prevent_dont_repeat ();
|
||||
if (to_string)
|
||||
to_string_res = execute_command_to_string (arg, from_tty);
|
||||
to_string_res = execute_control_commands_to_string (lines.get (),
|
||||
from_tty);
|
||||
else
|
||||
execute_command (arg, from_tty);
|
||||
execute_control_commands (lines.get (), from_tty);
|
||||
}
|
||||
CATCH (except, RETURN_MASK_ALL)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue