[PATCH 4/8] Remove target_has_registers macro

Tom Tromey tom@tromey.com
Tue Jul 21 01:49:10 GMT 2020


This removes the target_has_registers object-like macro, replacing it
with the underlying function.

gdb/ChangeLog
2020-07-20  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_get_register)
	(tui_data_window::show_registers): Update.
	* thread.c (scoped_restore_current_thread::restore)
	(scoped_restore_current_thread::scoped_restore_current_thread):
	Update.
	* regcache-dump.c (regcache_print): Update.
	* python/py-finishbreakpoint.c (bpfinishpy_detect_out_scope_cb):
	Update.
	* mi/mi-main.c (mi_cmd_data_write_register_values): Update.
	* mep-tdep.c (current_me_module, current_options): Update.
	* linux-thread-db.c (thread_db_load): Update.
	* infcmd.c (registers_info, info_vector_command)
	(info_float_command): Update.
	* ia64-tdep.c (ia64_frame_prev_register)
	(ia64_sigtramp_frame_prev_register): Update.
	* ia64-libunwind-tdep.c (libunwind_frame_prev_register): Update.
	* gcore.c (derive_stack_segment): Update.
	* frame.c (get_current_frame, has_stack_frames): Update.
	* findvar.c (language_defn::read_var_value): Update.
	* arm-tdep.c (arm_pc_is_thumb): Update.
	* target.c (target_has_registers): Rename from
	target_has_registers_1.
	* target.h (target_has_registers): Remove macro.
	(target_has_registers): Rename from target_has_registers_1.
---
 gdb/ChangeLog                    | 27 +++++++++++++++++++++++++++
 gdb/arm-tdep.c                   |  2 +-
 gdb/findvar.c                    |  2 +-
 gdb/frame.c                      |  5 +++--
 gdb/gcore.c                      |  2 +-
 gdb/ia64-libunwind-tdep.c        |  2 +-
 gdb/ia64-tdep.c                  |  4 ++--
 gdb/infcmd.c                     |  6 +++---
 gdb/linux-thread-db.c            |  2 +-
 gdb/mep-tdep.c                   |  4 ++--
 gdb/mi/mi-main.c                 |  2 +-
 gdb/python/py-finishbreakpoint.c |  2 +-
 gdb/regcache-dump.c              |  4 ++--
 gdb/target.c                     |  2 +-
 gdb/target.h                     |  3 +--
 gdb/thread.c                     |  4 ++--
 gdb/tui/tui-regs.c               |  4 ++--
 17 files changed, 52 insertions(+), 25 deletions(-)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 9cedcc85755..7e7fb77bd54 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -459,7 +459,7 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr)
      "display/i $pc" always show the correct mode (though if there is
      a symbol table we will not reach here, so it still may not be
      displayed in the mode it will be executed).  */
-  if (target_has_registers)
+  if (target_has_registers ())
     return arm_frame_is_thumb (get_current_frame ());
 
   /* Otherwise we're out of luck; we assume ARM.  */
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 7e9dab567f6..78d727b07bb 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -608,7 +608,7 @@ language_defn::read_var_value (struct symbol *var,
   sym_need = symbol_read_needs (var);
   if (sym_need == SYMBOL_NEEDS_FRAME)
     gdb_assert (frame != NULL);
-  else if (sym_need == SYMBOL_NEEDS_REGISTERS && !target_has_registers)
+  else if (sym_need == SYMBOL_NEEDS_REGISTERS && !target_has_registers ())
     error (_("Cannot read `%s' without registers"), var->print_name ());
 
   if (frame != NULL)
diff --git a/gdb/frame.c b/gdb/frame.c
index 97d394de88b..9551c7f0d2a 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1601,7 +1601,7 @@ get_current_frame (void)
      have registers is very confusing.  Besides, "printcmd.exp"
      explicitly checks that ``print $pc'' with no registers prints "No
      registers".  */
-  if (!target_has_registers)
+  if (!target_has_registers ())
     error (_("No registers."));
   if (!target_has_stack ())
     error (_("No stack."));
@@ -1640,7 +1640,8 @@ static struct frame_info *selected_frame;
 int
 has_stack_frames (void)
 {
-  if (!target_has_registers || !target_has_stack () || !target_has_memory ())
+  if (!target_has_registers () || !target_has_stack ()
+      || !target_has_memory ())
     return 0;
 
   /* Traceframes are effectively a substitute for the live inferior.  */
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 7837ab52056..2ebc8df3f8b 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -219,7 +219,7 @@ derive_stack_segment (bfd_vma *bottom, bfd_vma *top)
   gdb_assert (top);
 
   /* Can't succeed without stack and registers.  */
-  if (!target_has_stack () || !target_has_registers)
+  if (!target_has_stack () || !target_has_registers ())
     return 0;
 
   /* Can't succeed without current frame.  */
diff --git a/gdb/ia64-libunwind-tdep.c b/gdb/ia64-libunwind-tdep.c
index 94881bbfb5d..39b069adeca 100644
--- a/gdb/ia64-libunwind-tdep.c
+++ b/gdb/ia64-libunwind-tdep.c
@@ -335,7 +335,7 @@ libunwind_frame_prev_register (struct frame_info *this_frame,
 
   gdb_assert (regnum >= 0);
 
-  if (!target_has_registers)
+  if (!target_has_registers ())
     error (_("No registers."));
 
   if (uw_regnum < 0)
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 5d68f7fb4ff..9614722a3cc 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -1913,7 +1913,7 @@ ia64_frame_prev_register (struct frame_info *this_frame, void **this_cache,
 
   gdb_assert (regnum >= 0);
 
-  if (!target_has_registers)
+  if (!target_has_registers ())
     error (_("No registers."));
 
   if (regnum == gdbarch_sp_regnum (gdbarch))
@@ -2284,7 +2284,7 @@ ia64_sigtramp_frame_prev_register (struct frame_info *this_frame,
 
   gdb_assert (regnum >= 0);
 
-  if (!target_has_registers)
+  if (!target_has_registers ())
     error (_("No registers."));
 
   if (regnum == IA64_IP_REGNUM)
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index cfc31699925..86a680b8e52 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2208,7 +2208,7 @@ registers_info (const char *addr_exp, int fpregs)
   struct frame_info *frame;
   struct gdbarch *gdbarch;
 
-  if (!target_has_registers)
+  if (!target_has_registers ())
     error (_("The program has no registers now."));
   frame = get_selected_frame (NULL);
   gdbarch = get_frame_arch (frame);
@@ -2349,7 +2349,7 @@ print_vector_info (struct ui_file *file,
 static void
 info_vector_command (const char *args, int from_tty)
 {
-  if (!target_has_registers)
+  if (!target_has_registers ())
     error (_("The program has no registers now."));
 
   print_vector_info (gdb_stdout, get_selected_frame (NULL), args);
@@ -2887,7 +2887,7 @@ info_float_command (const char *args, int from_tty)
 {
   struct frame_info *frame;
 
-  if (!target_has_registers)
+  if (!target_has_registers ())
     error (_("The program has no registers now."));
 
   frame = get_selected_frame (NULL);
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index b3cda05cd6e..ebb4022539d 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1194,7 +1194,7 @@ thread_db_load (void)
 
   /* Don't attempt to use thread_db on executables not running
      yet.  */
-  if (!target_has_registers)
+  if (!target_has_registers ())
     return false;
 
   /* Don't attempt to use thread_db for remote targets.  */
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index 7e8247cd642..0efcf8598f9 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -844,7 +844,7 @@ mep_pseudo_cr_index (int pseudo)
 static CONFIG_ATTR
 current_me_module (void)
 {
-  if (target_has_registers)
+  if (target_has_registers ())
     {
       ULONGEST regval;
       regcache_cooked_read_unsigned (get_current_regcache (),
@@ -867,7 +867,7 @@ current_me_module (void)
 static unsigned int
 current_options (void)
 {
-  if (target_has_registers)
+  if (target_has_registers ())
     {
       ULONGEST regval;
       regcache_cooked_read_unsigned (get_current_regcache (),
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 55bb777ef77..99da554c444 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1150,7 +1150,7 @@ mi_cmd_data_write_register_values (const char *command, char **argv, int argc)
     error (_("-data-write-register-values: Usage: -data-write-register-"
 	     "values <format> [<regnum1> <value1>...<regnumN> <valueN>]"));
 
-  if (!target_has_registers)
+  if (!target_has_registers ())
     error (_("-data-write-register-values: No registers."));
 
   if (!(argc - 1))
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 92ac5557d76..4badcd58f66 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -361,7 +361,7 @@ bpfinishpy_detect_out_scope_cb (struct breakpoint *b,
           try
             {
               if (b->pspace == current_inferior ()->pspace
-                  && (!target_has_registers
+                  && (!target_has_registers ()
                       || frame_find_by_id (b->frame_id) == NULL))
                 bpfinishpy_out_of_scope (finish_bp);
             }
diff --git a/gdb/regcache-dump.c b/gdb/regcache-dump.c
index 10f6e49a786..f1ba07be9bb 100644
--- a/gdb/regcache-dump.c
+++ b/gdb/regcache-dump.c
@@ -236,7 +236,7 @@ regcache_print (const char *args, enum regcache_dump_what what_to_dump)
   std::unique_ptr<regcache> regs;
   gdbarch *gdbarch;
 
-  if (target_has_registers)
+  if (target_has_registers ())
     gdbarch = get_current_regcache ()->arch ();
   else
     gdbarch = target_gdbarch ();
@@ -257,7 +257,7 @@ regcache_print (const char *args, enum regcache_dump_what what_to_dump)
       {
 	auto dump_pseudo = (what_to_dump == regcache_dump_cooked);
 
-	if (target_has_registers)
+	if (target_has_registers ())
 	  dump.reset (new register_dump_regcache (get_current_regcache (),
 						  dump_pseudo));
 	else
diff --git a/gdb/target.c b/gdb/target.c
index a6b4dce0de7..ba9532dcb27 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -190,7 +190,7 @@ target_has_stack ()
 }
 
 int
-target_has_registers_1 (void)
+target_has_registers ()
 {
   for (target_ops *t = current_top_target (); t != NULL; t = t->beneath ())
     if (t->has_registers ())
diff --git a/gdb/target.h b/gdb/target.h
index 7d4964aaf34..c9291ab59f1 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1803,8 +1803,7 @@ extern int target_has_stack ();
 
 /* Does the target have registers?  (Exec files don't.)  */
 
-extern int target_has_registers_1 (void);
-#define target_has_registers target_has_registers_1 ()
+extern int target_has_registers ();
 
 /* Does the target have execution?  Can we make it jump (through
    hoops), or pop its stack a few times?  This means that the current
diff --git a/gdb/thread.c b/gdb/thread.c
index 5a71eb9a992..a1fda4348b6 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1405,7 +1405,7 @@ scoped_restore_current_thread::restore ()
   if (inferior_ptid != null_ptid
       && m_was_stopped
       && m_thread->state == THREAD_STOPPED
-      && target_has_registers
+      && target_has_registers ()
       && target_has_stack ()
       && target_has_memory ())
     restore_selected_frame (m_selected_frame_id, m_selected_frame_level);
@@ -1439,7 +1439,7 @@ scoped_restore_current_thread::scoped_restore_current_thread ()
 
       m_was_stopped = m_thread->state == THREAD_STOPPED;
       if (m_was_stopped
-	  && target_has_registers
+	  && target_has_registers ()
 	  && target_has_stack ()
 	  && target_has_memory ())
 	{
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 6ff0d001854..4ba81b6f112 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -117,7 +117,7 @@ tui_get_register (struct frame_info *frame,
 {
   if (changedp)
     *changedp = false;
-  if (target_has_registers)
+  if (target_has_registers ())
     {
       std::string new_content = tui_register_format (frame, regnum);
 
@@ -182,7 +182,7 @@ tui_data_window::show_registers (struct reggroup *group)
   if (group == 0)
     group = general_reggroup;
 
-  if (target_has_registers && target_has_stack () && target_has_memory ())
+  if (target_has_registers () && target_has_stack () && target_has_memory ())
     {
       show_register_group (group, get_selected_frame (NULL),
 			   group == m_current_group);
-- 
2.17.2



More information about the Gdb-patches mailing list