From: Elena Zannoni Date: Mon, 6 Mar 2000 22:57:52 +0000 (+0000) Subject: 2000-03-06 Elena Zannoni X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=24e8cecf494110cb8a911820ff27340981b517a4;p=binutils-gdb.git 2000-03-06 Elena Zannoni * 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. --- diff --git a/gdb/mi/ChangeLog-mi b/gdb/mi/ChangeLog-mi index 61bfafe2dbb..6abbfa2b564 100644 --- a/gdb/mi/ChangeLog-mi +++ b/gdb/mi/ChangeLog-mi @@ -1,5 +1,17 @@ 2000-03-06 Elena Zannoni + * 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 + + * mi-cmds.h: + * gdbmi.texinfo: Update data-disassemble documentation. 2000-03-01 Elena Zannoni diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index 8cf38a9adfc..1361b7c3883 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 6815a4af9e8..2f6b3867b75 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 3fbf7c5d5b6..3153da7e0d3 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 #include @@ -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 [ ... ]*/ +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 [ ... ]"); + 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);