2000-03-06 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+ * mi-cmds.h: Export mi_cmd_data_write_register_values.
+
+ * mi-cmds.c (mi_cmds): Implement data-write-register-values with
+ mi_cmd_data_write_register_values.
+
+ * mi-main.c (mi_cmd_data_write_register_values): New
+ function. Write a value into a register.
+
+2000-03-06 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * mi-cmds.h:
+
* gdbmi.texinfo: Update data-disassemble documentation.
2000-03-01 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
{"data-list-register-values", 0, 0, mi_cmd_data_list_register_values},
{"data-read-memory", 0, 0, mi_cmd_data_read_memory},
{"data-write-memory", 0, 0, mi_cmd_data_write_memory},
+ {"data-write-register-values", 0, 0, mi_cmd_data_write_register_values},
{"display-delete", 0, 0},
{"display-disable", 0, 0},
{"display-enable", 0, 0},
#include "event-loop.h"
#include "event-top.h"
#include "gdbcore.h" /* for write_memory() */
+#include "value.h" /* for write_register_bytes() */
#include <ctype.h>
#include <sys/time.h>
return 1;
}
+/* Write given values into registers. The registers and values are
+ given as pairs. The corresponding MI command is
+ -data-write-register-values <format> [<regnum1> <value1>...<regnumN> <valueN>]*/
+enum mi_cmd_result
+mi_cmd_data_write_register_values (char *command, char **argv, int argc)
+{
+ int regnum;
+ int i;
+ int numregs;
+ char *buffer;
+ LONGEST value;
+ char format;
+
+ /* Note that the test for a valid register must include checking the
+ REGISTER_NAME because NUM_REGS may be allocated for the union of
+ the register sets within a family of related processors. In this
+ case, some entries of REGISTER_NAME will change depending upon
+ the particular processor being debugged. */
+
+ numregs = ARCH_NUM_REGS;
+
+ if (argc == 0)
+ {
+ asprintf (&mi_error_message,
+ "mi_cmd_data_write_register_values: Usage: -data-write-register-values <format> [<regnum1> <value1>...<regnumN> <valueN>]");
+ return MI_CMD_ERROR;
+ }
+
+ format = (int) argv[0][0];
+
+ if (!target_has_registers)
+ {
+ asprintf (&mi_error_message, "mi_cmd_data_write_register_values: No registers.");
+ return MI_CMD_ERROR;
+ }
+
+ if (!(argc - 1))
+ {
+ asprintf (&mi_error_message, "mi_cmd_data_write_register_values: No regs and values specified.");
+ return MI_CMD_ERROR;
+ }
+
+ if ((argc - 1) % 2)
+ {
+ asprintf (&mi_error_message, "mi_cmd_data_write_register_values: Regs and vals are not in pairs.");
+ return MI_CMD_ERROR;
+ }
+
+ for (i = 1; i < argc; i = i + 2)
+ {
+ regnum = atoi (argv[i]);
+
+ if (regnum >= 0
+ && regnum < numregs
+ && REGISTER_NAME (regnum) != NULL
+ && *REGISTER_NAME (regnum) != '\000')
+ {
+ /* Get the value as a number */
+ value = parse_and_eval_address (argv[i + 1]);
+ /* Get the value into an array */
+ buffer = (unsigned char *) xmalloc (REGISTER_SIZE);
+ store_signed_integer (buffer, REGISTER_SIZE, value);
+ /* Write it down */
+ write_register_bytes (REGISTER_BYTE (regnum), buffer, REGISTER_RAW_SIZE (regnum));
+ /* write_register_bytes (REGISTER_BYTE (regnum), buffer, REGISTER_SIZE); */
+ }
+ else
+ {
+ asprintf (&mi_error_message, "bad register number");
+ return MI_CMD_ERROR;
+ }
+ }
+ return MI_CMD_DONE;
+}
+
#if 0
/*This is commented out because we decided it was not useful. I leave
it, just in case. ezannoni:1999-12-08 */
}
}
-void
+void
free_and_reset (char **arg)
{
free (*arg);