Numerous formatting changes.

(mi_cmd_data_write_register_values): Replace clause inadvertantly
removed in my previous change.
This commit is contained in:
Nick Roberts 2007-02-03 05:41:15 +00:00
parent 79f0a97a21
commit 41296c9282

View file

@ -22,7 +22,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */ Boston, MA 02110-1301, USA. */
/* Work in progress */ /* Work in progress. */
#include "defs.h" #include "defs.h"
#include "target.h" #include "target.h"
@ -40,7 +40,7 @@
#include "interps.h" #include "interps.h"
#include "event-loop.h" #include "event-loop.h"
#include "event-top.h" #include "event-top.h"
#include "gdbcore.h" /* for write_memory() */ #include "gdbcore.h" /* For write_memory(). */
#include "value.h" #include "value.h"
#include "regcache.h" #include "regcache.h"
#include "gdb.h" #include "gdb.h"
@ -64,7 +64,7 @@ enum
}; };
/* Enumerations of the actions that may result from calling /* Enumerations of the actions that may result from calling
captured_mi_execute_command */ captured_mi_execute_command. */
enum captured_mi_execute_command_actions enum captured_mi_execute_command_actions
{ {
@ -76,13 +76,13 @@ enum captured_mi_execute_command_actions
to mi_execute_command. */ to mi_execute_command. */
struct captured_mi_execute_command_args struct captured_mi_execute_command_args
{ {
/* This return result of the MI command (output) */ /* This return result of the MI command (output). */
enum mi_cmd_result rc; enum mi_cmd_result rc;
/* What action to perform when the call is finished (output) */ /* What action to perform when the call is finished (output). */
enum captured_mi_execute_command_actions action; enum captured_mi_execute_command_actions action;
/* The command context to be executed (input) */ /* The command context to be executed (input). */
struct mi_parse *command; struct mi_parse *command;
}; };
@ -95,7 +95,7 @@ static struct mi_timestamp *current_command_ts;
static int do_timings = 0; static int do_timings = 0;
/* The token of the last asynchronous command */ /* The token of the last asynchronous command. */
static char *last_async_command; static char *last_async_command;
static char *previous_async_command; static char *previous_async_command;
char *mi_error_message; char *mi_error_message;
@ -125,12 +125,12 @@ static void print_diff (struct mi_timestamp *start, struct mi_timestamp *end);
enum mi_cmd_result enum mi_cmd_result
mi_cmd_gdb_exit (char *command, char **argv, int argc) mi_cmd_gdb_exit (char *command, char **argv, int argc)
{ {
/* We have to print everything right here because we never return */ /* We have to print everything right here because we never return. */
if (last_async_command) if (last_async_command)
fputs_unfiltered (last_async_command, raw_stdout); fputs_unfiltered (last_async_command, raw_stdout);
fputs_unfiltered ("^exit\n", raw_stdout); fputs_unfiltered ("^exit\n", raw_stdout);
mi_out_put (uiout, raw_stdout); mi_out_put (uiout, raw_stdout);
/* FIXME: The function called is not yet a formal libgdb function */ /* FIXME: The function called is not yet a formal libgdb function. */
quit_force (NULL, FROM_TTY); quit_force (NULL, FROM_TTY);
return MI_CMD_DONE; return MI_CMD_DONE;
} }
@ -138,49 +138,49 @@ mi_cmd_gdb_exit (char *command, char **argv, int argc)
enum mi_cmd_result enum mi_cmd_result
mi_cmd_exec_run (char *args, int from_tty) mi_cmd_exec_run (char *args, int from_tty)
{ {
/* FIXME: Should call a libgdb function, not a cli wrapper */ /* FIXME: Should call a libgdb function, not a cli wrapper. */
return mi_execute_async_cli_command ("run", args, from_tty); return mi_execute_async_cli_command ("run", args, from_tty);
} }
enum mi_cmd_result enum mi_cmd_result
mi_cmd_exec_next (char *args, int from_tty) mi_cmd_exec_next (char *args, int from_tty)
{ {
/* FIXME: Should call a libgdb function, not a cli wrapper */ /* FIXME: Should call a libgdb function, not a cli wrapper. */
return mi_execute_async_cli_command ("next", args, from_tty); return mi_execute_async_cli_command ("next", args, from_tty);
} }
enum mi_cmd_result enum mi_cmd_result
mi_cmd_exec_next_instruction (char *args, int from_tty) mi_cmd_exec_next_instruction (char *args, int from_tty)
{ {
/* FIXME: Should call a libgdb function, not a cli wrapper */ /* FIXME: Should call a libgdb function, not a cli wrapper. */
return mi_execute_async_cli_command ("nexti", args, from_tty); return mi_execute_async_cli_command ("nexti", args, from_tty);
} }
enum mi_cmd_result enum mi_cmd_result
mi_cmd_exec_step (char *args, int from_tty) mi_cmd_exec_step (char *args, int from_tty)
{ {
/* FIXME: Should call a libgdb function, not a cli wrapper */ /* FIXME: Should call a libgdb function, not a cli wrapper. */
return mi_execute_async_cli_command ("step", args, from_tty); return mi_execute_async_cli_command ("step", args, from_tty);
} }
enum mi_cmd_result enum mi_cmd_result
mi_cmd_exec_step_instruction (char *args, int from_tty) mi_cmd_exec_step_instruction (char *args, int from_tty)
{ {
/* FIXME: Should call a libgdb function, not a cli wrapper */ /* FIXME: Should call a libgdb function, not a cli wrapper. */
return mi_execute_async_cli_command ("stepi", args, from_tty); return mi_execute_async_cli_command ("stepi", args, from_tty);
} }
enum mi_cmd_result enum mi_cmd_result
mi_cmd_exec_finish (char *args, int from_tty) mi_cmd_exec_finish (char *args, int from_tty)
{ {
/* FIXME: Should call a libgdb function, not a cli wrapper */ /* FIXME: Should call a libgdb function, not a cli wrapper. */
return mi_execute_async_cli_command ("finish", args, from_tty); return mi_execute_async_cli_command ("finish", args, from_tty);
} }
enum mi_cmd_result enum mi_cmd_result
mi_cmd_exec_until (char *args, int from_tty) mi_cmd_exec_until (char *args, int from_tty)
{ {
/* FIXME: Should call a libgdb function, not a cli wrapper */ /* FIXME: Should call a libgdb function, not a cli wrapper. */
return mi_execute_async_cli_command ("until", args, from_tty); return mi_execute_async_cli_command ("until", args, from_tty);
} }
@ -208,7 +208,7 @@ mi_cmd_exec_return (char *args, int from_tty)
enum mi_cmd_result enum mi_cmd_result
mi_cmd_exec_continue (char *args, int from_tty) mi_cmd_exec_continue (char *args, int from_tty)
{ {
/* FIXME: Should call a libgdb function, not a cli wrapper */ /* FIXME: Should call a libgdb function, not a cli wrapper. */
return mi_execute_async_cli_command ("continue", args, from_tty); return mi_execute_async_cli_command ("continue", args, from_tty);
} }
@ -299,7 +299,7 @@ mi_cmd_data_list_register_names (char *command, char **argv, int argc)
cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-names"); cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-names");
if (argc == 0) /* No args, just do all the regs */ if (argc == 0) /* No args, just do all the regs. */
{ {
for (regnum = 0; for (regnum = 0;
regnum < numregs; regnum < numregs;
@ -313,7 +313,7 @@ mi_cmd_data_list_register_names (char *command, char **argv, int argc)
} }
} }
/* Else, list of register #s, just do listed regs */ /* Else, list of register #s, just do listed regs. */
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
{ {
regnum = atoi (argv[i]); regnum = atoi (argv[i]);
@ -350,7 +350,7 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changed-registers"); cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changed-registers");
if (argc == 0) /* No args, just do all the regs */ if (argc == 0) /* No args, just do all the regs. */
{ {
for (regnum = 0; for (regnum = 0;
regnum < numregs; regnum < numregs;
@ -371,7 +371,7 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
} }
} }
/* Else, list of register #s, just do listed regs */ /* Else, list of register #s, just do listed regs. */
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
{ {
regnum = atoi (argv[i]); regnum = atoi (argv[i]);
@ -454,7 +454,7 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc)
list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-values"); list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-values");
if (argc == 1) /* No args, beside the format: do all the regs */ if (argc == 1) /* No args, beside the format: do all the regs. */
{ {
for (regnum = 0; for (regnum = 0;
regnum < numregs; regnum < numregs;
@ -475,7 +475,7 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc)
} }
} }
/* Else, list of register #s, just do listed regs */ /* Else, list of register #s, just do listed regs. */
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
regnum = atoi (argv[i]); regnum = atoi (argv[i]);
@ -613,7 +613,7 @@ mi_cmd_data_write_register_values (char *command, char **argv, int argc)
/* Get the value as a number. */ /* Get the value as a number. */
value = parse_and_eval_address (argv[i + 1]); value = parse_and_eval_address (argv[i + 1]);
/* Write it down */ /* Write it down. */
regcache_cooked_write_signed (current_regcache, regnum, value); regcache_cooked_write_signed (current_regcache, regnum, value);
} }
else else
@ -630,7 +630,7 @@ mi_cmd_data_write_register_values (char *command, char **argv, int argc)
it, just in case. ezannoni:1999-12-08 */ it, just in case. ezannoni:1999-12-08 */
/* Assign a value to a variable. The expression argument must be in /* Assign a value to a variable. The expression argument must be in
the form A=2 or "A = 2" (I.e. if there are spaces it needs to be the form A=2 or "A = 2" i.e. if there are spaces it needs to be
quoted. */ quoted. */
enum mi_cmd_result enum mi_cmd_result
mi_cmd_data_assign (char *command, char **argv, int argc) mi_cmd_data_assign (char *command, char **argv, int argc)
@ -717,7 +717,7 @@ mi_cmd_target_select (char *args, int from_tty)
run = xstrprintf ("target %s", args); run = xstrprintf ("target %s", args);
old_cleanups = make_cleanup (xfree, run); old_cleanups = make_cleanup (xfree, run);
/* target-select is always synchronous. once the call has returned /* target-select is always synchronous. Once the call has returned
we know that we are connected. */ we know that we are connected. */
/* NOTE: At present all targets that are connected are also /* NOTE: At present all targets that are connected are also
(implicitly) talking to a halted target. In the future this may (implicitly) talking to a halted target. In the future this may
@ -742,7 +742,7 @@ mi_cmd_target_select (char *args, int from_tty)
ADDR: start address of data to be dumped. ADDR: start address of data to be dumped.
WORD-FORMAT: a char indicating format for the ``word''. See WORD-FORMAT: a char indicating format for the ``word''. See
the ``x'' command. the ``x'' command.
WORD-SIZE: size of each ``word''; 1,2,4, or 8 bytes WORD-SIZE: size of each ``word''; 1,2,4, or 8 bytes.
NR_ROW: Number of rows. NR_ROW: Number of rows.
NR_COL: The number of colums (words per row). NR_COL: The number of colums (words per row).
ASCHAR: (OPTIONAL) Append an ascii character dump to each row. Use ASCHAR: (OPTIONAL) Append an ascii character dump to each row. Use
@ -837,14 +837,14 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
word_type = builtin_type_int8; word_type = builtin_type_int8;
word_asize = 'b'; word_asize = 'b';
} }
/* The number of rows */ /* The number of rows. */
nr_rows = atol (argv[3]); nr_rows = atol (argv[3]);
if (nr_rows <= 0) if (nr_rows <= 0)
{ {
mi_error_message = xstrprintf ("mi_cmd_data_read_memory: invalid number of rows."); mi_error_message = xstrprintf ("mi_cmd_data_read_memory: invalid number of rows.");
return MI_CMD_ERROR; return MI_CMD_ERROR;
} }
/* number of bytes per row. */ /* Number of bytes per row. */
nr_cols = atol (argv[4]); nr_cols = atol (argv[4]);
if (nr_cols <= 0) if (nr_cols <= 0)
{ {
@ -857,7 +857,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
else else
aschar = 0; aschar = 0;
/* create a buffer and read it in. */ /* Create a buffer and read it in. */
total_bytes = word_size * nr_rows * nr_cols; total_bytes = word_size * nr_rows * nr_cols;
mbuf = xcalloc (total_bytes, 1); mbuf = xcalloc (total_bytes, 1);
make_cleanup (xfree, mbuf); make_cleanup (xfree, mbuf);
@ -871,7 +871,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
return MI_CMD_ERROR; return MI_CMD_ERROR;
} }
/* output the header information. */ /* Output the header information. */
ui_out_field_core_addr (uiout, "addr", addr); ui_out_field_core_addr (uiout, "addr", addr);
ui_out_field_int (uiout, "nr-bytes", nr_bytes); ui_out_field_int (uiout, "nr-bytes", nr_bytes);
ui_out_field_int (uiout, "total-bytes", total_bytes); ui_out_field_int (uiout, "total-bytes", total_bytes);
@ -1018,13 +1018,13 @@ mi_cmd_data_write_memory (char *command, char **argv, int argc)
/* Calculate the real address of the write destination. */ /* Calculate the real address of the write destination. */
addr += (offset * word_size); addr += (offset * word_size);
/* Get the value as a number */ /* Get the value as a number. */
value = parse_and_eval_address (argv[3]); value = parse_and_eval_address (argv[3]);
/* Get the value into an array */ /* Get the value into an array. */
buffer = xmalloc (word_size); buffer = xmalloc (word_size);
old_chain = make_cleanup (xfree, buffer); old_chain = make_cleanup (xfree, buffer);
store_signed_integer (buffer, word_size, value); store_signed_integer (buffer, word_size, value);
/* Write it down to memory */ /* Write it down to memory. */
write_memory (addr, buffer, word_size); write_memory (addr, buffer, word_size);
/* Free the buffer. */ /* Free the buffer. */
do_cleanups (old_chain); do_cleanups (old_chain);
@ -1076,7 +1076,7 @@ captured_mi_execute_command (struct ui_out *uiout, void *data)
{ {
case MI_COMMAND: case MI_COMMAND:
/* A MI command was read from the input stream */ /* A MI command was read from the input stream. */
if (mi_debug_p) if (mi_debug_p)
/* FIXME: gdb_???? */ /* FIXME: gdb_???? */
fprintf_unfiltered (raw_stdout, " token=`%s' command=`%s' args=`%s'\n", fprintf_unfiltered (raw_stdout, " token=`%s' command=`%s' args=`%s'\n",
@ -1097,7 +1097,7 @@ captured_mi_execute_command (struct ui_out *uiout, void *data)
if (!target_can_async_p () || !target_executing) if (!target_can_async_p () || !target_executing)
{ {
/* print the result if there were no errors /* Print the result if there were no errors.
Remember that on the way out of executing a command, you have Remember that on the way out of executing a command, you have
to directly use the mi_interp's uiout, since the command could to directly use the mi_interp's uiout, since the command could
@ -1248,7 +1248,7 @@ mi_execute_command (char *cmd, int from_tty)
fputs_unfiltered ("(gdb) \n", raw_stdout); fputs_unfiltered ("(gdb) \n", raw_stdout);
gdb_flush (raw_stdout); gdb_flush (raw_stdout);
/* print any buffered hook code */ /* Print any buffered hook code. */
/* ..... */ /* ..... */
} }
@ -1263,7 +1263,7 @@ mi_cmd_execute (struct mi_parse *parse)
/* FIXME: We need to save the token because the command executed /* FIXME: We need to save the token because the command executed
may be asynchronous and need to print the token again. may be asynchronous and need to print the token again.
In the future we can pass the token down to the func In the future we can pass the token down to the func
and get rid of the last_async_command */ and get rid of the last_async_command. */
/* The problem here is to keep the token around when we launch /* The problem here is to keep the token around when we launch
the target, and we want to interrupt it later on. The the target, and we want to interrupt it later on. The
interrupt command will have its own token, but when the interrupt command will have its own token, but when the
@ -1300,8 +1300,8 @@ mi_cmd_execute (struct mi_parse *parse)
else if (parse->cmd->cli.cmd != 0) else if (parse->cmd->cli.cmd != 0)
{ {
/* FIXME: DELETE THIS. */ /* FIXME: DELETE THIS. */
/* The operation is still implemented by a cli command */ /* The operation is still implemented by a cli command. */
/* Must be a synchronous one */ /* Must be a synchronous one. */
mi_execute_cli_command (parse->cmd->cli.cmd, parse->cmd->cli.args_p, mi_execute_cli_command (parse->cmd->cli.cmd, parse->cmd->cli.args_p,
parse->args); parse->args);
return MI_CMD_DONE; return MI_CMD_DONE;
@ -1320,8 +1320,8 @@ mi_cmd_execute (struct mi_parse *parse)
} }
/* FIXME: This is just a hack so we can get some extra commands going. /* FIXME: This is just a hack so we can get some extra commands going.
We don't want to channel things through the CLI, but call libgdb directly */ We don't want to channel things through the CLI, but call libgdb directly.
/* Use only for synchronous commands */ Use only for synchronous commands. */
void void
mi_execute_cli_command (const char *cmd, int args_p, const char *args) mi_execute_cli_command (const char *cmd, int args_p, const char *args)