diff options
author | Andrew Burgess <aburgess@redhat.com> | 2021-11-08 12:25:56 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2021-12-14 10:57:19 +0000 |
commit | 3be0fed62e0dfb36d674944fe85eaebbf70b9029 (patch) | |
tree | bb000902e8d72aafb1a74b493c09f66352116d13 | |
parent | f76d800be844dd2aa4aa8f189a3ace16c5e931bc (diff) | |
download | binutils-3be0fed62e0dfb36d674944fe85eaebbf70b9029.zip binutils-3be0fed62e0dfb36d674944fe85eaebbf70b9029.tar.gz binutils-3be0fed62e0dfb36d674944fe85eaebbf70b9029.tar.bz2 |
gdb/mi: int to bool conversion in mi_execute_cli_command
Change an argument of mi_execute_cli_command from int to bool. Update
the callers to take this into account. Within mi_execute_cli_command,
update a comparison of a pointer to 0 with a comparison to nullptr,
and add an assert, if we are not using the argument string then the
string should be nullptr. Also removed a cryptic 'gdb_????' comment,
which isn't really helpful.
There should be no user visible changes after this commit.
-rw-r--r-- | gdb/mi/mi-main.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 311697b..269c01d 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -90,7 +90,7 @@ int mi_proceeded; static void mi_cmd_execute (struct mi_parse *parse); -static void mi_execute_cli_command (const char *cmd, int args_p, +static void mi_execute_cli_command (const char *cmd, bool args_p, const char *args); static void mi_execute_async_cli_command (const char *cli_command, char **argv, int argc); @@ -408,7 +408,7 @@ run_one_inferior (inferior *inf, bool start_p) { const char *run_cmd = start_p ? "start" : "run"; struct target_ops *run_target = find_run_target (); - int async_p = mi_async && target_can_async_p (run_target); + bool async_p = mi_async && target_can_async_p (run_target); if (inf->pid != 0) { @@ -473,7 +473,7 @@ mi_cmd_exec_run (const char *command, char **argv, int argc) { const char *run_cmd = start_p ? "start" : "run"; struct target_ops *run_target = find_run_target (); - int async_p = mi_async && target_can_async_p (run_target); + bool async_p = mi_async && target_can_async_p (run_target); mi_execute_cli_command (run_cmd, async_p, async_p ? "&" : NULL); @@ -2088,8 +2088,9 @@ mi_cmd_execute (struct mi_parse *parse) /* FIXME: DELETE THIS. */ /* The operation is still implemented by a cli command. */ /* Must be a synchronous one. */ - mi_execute_cli_command (parse->cmd->cli.cmd, parse->cmd->cli.args_p, - parse->args); + bool args_p = parse->cmd->cli.args_p != 0; + const char *args = args_p ? parse->args : nullptr; + mi_execute_cli_command (parse->cmd->cli.cmd, args_p, args); } else { @@ -2109,18 +2110,21 @@ mi_cmd_execute (struct mi_parse *parse) Use only for synchronous commands. */ void -mi_execute_cli_command (const char *cmd, int args_p, const char *args) +mi_execute_cli_command (const char *cmd, bool args_p, const char *args) { - if (cmd != 0) + if (cmd != nullptr) { - std::string run = cmd; + std::string run (cmd); if (args_p) run = run + " " + args; + else + gdb_assert (args == nullptr); + if (mi_debug_p) - /* FIXME: gdb_???? */ fprintf_unfiltered (gdb_stdout, "cli=%s run=%s\n", cmd, run.c_str ()); + execute_command (run.c_str (), 0 /* from_tty */ ); } } |