aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorElena Zannoni <ezannoni@kwikemart.cygnus.com>2000-03-06 22:57:52 +0000
committerElena Zannoni <ezannoni@kwikemart.cygnus.com>2000-03-06 22:57:52 +0000
commit24e8cecf494110cb8a911820ff27340981b517a4 (patch)
treeeb7562f7b88d0566c015f1caca8401ec26f3b01c /gdb/mi
parent108213226d964e017d68138a54be936a649391c6 (diff)
downloadgdb-24e8cecf494110cb8a911820ff27340981b517a4.zip
gdb-24e8cecf494110cb8a911820ff27340981b517a4.tar.gz
gdb-24e8cecf494110cb8a911820ff27340981b517a4.tar.bz2
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.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/ChangeLog-mi12
-rw-r--r--gdb/mi/mi-cmds.c1
-rw-r--r--gdb/mi/mi-cmds.h1
-rw-r--r--gdb/mi/mi-main.c78
4 files changed, 91 insertions, 1 deletions
diff --git a/gdb/mi/ChangeLog-mi b/gdb/mi/ChangeLog-mi
index 61bfafe..6abbfa2 100644
--- a/gdb/mi/ChangeLog-mi
+++ b/gdb/mi/ChangeLog-mi
@@ -1,5 +1,17 @@
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>
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 8cf38a9..1361b7c 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -50,6 +50,7 @@ struct mi_cmd mi_cmds[] =
{"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},
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index 6815a4a..2f6b386 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -63,6 +63,7 @@ extern mi_cmd_argv_ftype mi_cmd_data_list_register_values;
extern mi_cmd_argv_ftype mi_cmd_data_list_changed_registers;
extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
+extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
extern mi_cmd_args_ftype mi_cmd_exec_continue;
extern mi_cmd_args_ftype mi_cmd_exec_finish;
extern mi_cmd_args_ftype mi_cmd_exec_next;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 3fbf7c5..3153da7 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -36,6 +36,7 @@
#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>
@@ -540,6 +541,81 @@ get_register (int regnum, int format)
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 */
@@ -1150,7 +1226,7 @@ mi_cmd_execute (struct mi_parse *parse)
}
}
-void
+void
free_and_reset (char **arg)
{
free (*arg);