aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2017-11-24 10:47:27 +0000
committerYao Qi <yao.qi@linaro.org>2017-11-24 10:47:27 +0000
commit62ad7ce71b243df3e8d7d4f8b8560a7316233a9e (patch)
tree1c9eb8b15cec7b79fdf40e67632131d13a543898
parent506fe5f4996738f25b7c26f126a84b231429ba95 (diff)
downloadgdb-62ad7ce71b243df3e8d7d4f8b8560a7316233a9e.zip
gdb-62ad7ce71b243df3e8d7d4f8b8560a7316233a9e.tar.gz
gdb-62ad7ce71b243df3e8d7d4f8b8560a7316233a9e.tar.bz2
Change register_changed_p returns bool
register_changed_p actually returns bool, but return type is still int. This patch changes the return type to bool. The caller of register_changed_p also checked whether the return value can be negative, which is not needed now. Such check was added in fb40c2090 in 2000, at that moment, register_changed_p returns -1 when read_relative_register_raw_bytes fails. I can tell from its name that it reads register contents, but we don't have this function called inside register_changed_p, and the regcache is read-only. gdb: 2017-11-24 Yao Qi <yao.qi@linaro.org> * mi/mi-main.c (mi_cmd_data_list_changed_registers): Remove local 'changed'. Remove error. (register_changed_p): Change return type to bool.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/mi/mi-main.c32
2 files changed, 18 insertions, 20 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d430141..cbcd2de 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2017-11-24 Yao Qi <yao.qi@linaro.org>
+ * mi/mi-main.c (mi_cmd_data_list_changed_registers): Remove
+ local 'changed'. Remove error.
+ (register_changed_p): Change return type to bool.
+
+2017-11-24 Yao Qi <yao.qi@linaro.org>
+
* arch/tic6x.c: New file.
* arch/tic6x.h: New file.
* features/Makefile (FEATURE_XMLFILES): Add tic6x-c6xp.xml,
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 3ca3500..6933d172 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -96,8 +96,8 @@ static void mi_execute_cli_command (const char *cmd, int args_p,
const char *args);
static void mi_execute_async_cli_command (const char *cli_command,
char **argv, int argc);
-static int register_changed_p (int regnum, struct regcache *,
- struct regcache *);
+static bool register_changed_p (int regnum, regcache *,
+ regcache *);
static void output_register (struct frame_info *, int regnum, int format,
int skip_unavailable);
@@ -935,7 +935,7 @@ mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc)
struct ui_out *uiout = current_uiout;
std::unique_ptr<struct regcache> prev_regs;
struct gdbarch *gdbarch;
- int regnum, numregs, changed;
+ int regnum, numregs;
int i;
/* The last time we visited this function, the current frame's
@@ -968,12 +968,9 @@ mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc)
if (gdbarch_register_name (gdbarch, regnum) == NULL
|| *(gdbarch_register_name (gdbarch, regnum)) == '\0')
continue;
- changed = register_changed_p (regnum, prev_regs.get (),
- this_regs.get ());
- if (changed < 0)
- error (_("-data-list-changed-registers: "
- "Unable to read register contents."));
- else if (changed)
+
+ if (register_changed_p (regnum, prev_regs.get (),
+ this_regs.get ()))
uiout->field_int (NULL, regnum);
}
}
@@ -988,12 +985,8 @@ mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc)
&& gdbarch_register_name (gdbarch, regnum) != NULL
&& *gdbarch_register_name (gdbarch, regnum) != '\000')
{
- changed = register_changed_p (regnum, prev_regs.get (),
- this_regs.get ());
- if (changed < 0)
- error (_("-data-list-changed-registers: "
- "Unable to read register contents."));
- else if (changed)
+ if (register_changed_p (regnum, prev_regs.get (),
+ this_regs.get ()))
uiout->field_int (NULL, regnum);
}
else
@@ -1001,18 +994,17 @@ mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc)
}
}
-static int
+static bool
register_changed_p (int regnum, struct regcache *prev_regs,
struct regcache *this_regs)
{
struct gdbarch *gdbarch = this_regs->arch ();
struct value *prev_value, *this_value;
- int ret;
/* First time through or after gdbarch change consider all registers
as changed. */
if (!prev_regs || prev_regs->arch () != gdbarch)
- return 1;
+ return true;
/* Get register contents and compare. */
prev_value = prev_regs->cooked_read_value (regnum);
@@ -1020,8 +1012,8 @@ register_changed_p (int regnum, struct regcache *prev_regs,
gdb_assert (prev_value != NULL);
gdb_assert (this_value != NULL);
- ret = value_contents_eq (prev_value, 0, this_value, 0,
- register_size (gdbarch, regnum)) == 0;
+ auto ret = value_contents_eq (prev_value, 0, this_value, 0,
+ register_size (gdbarch, regnum)) == 0;
release_value (prev_value);
release_value (this_value);