[3/8] Remove target_has_stack macro

Message ID 20200721014914.29937-4-tom@tromey.com
State New
Headers show
Series
  • Remove object-like target macros
Related show

Commit Message

Tom Tromey July 21, 2020, 1:49 a.m.
This removes the target_has_stack object-like macro, replacing it with
the underlying function.

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

	* windows-tdep.c (tlb_make_value): Update.
	* tui/tui-regs.c (tui_data_window::show_registers): Update.
	* thread.c (scoped_restore_current_thread::restore)
	(scoped_restore_current_thread::scoped_restore_current_thread)
	(thread_command): Update.
	* stack.c (backtrace_command_1, frame_apply_level_command)
	(frame_apply_all_command, frame_apply_command): Update.
	* infrun.c (siginfo_make_value, restore_infcall_control_state):
	Update.
	* gcore.c (derive_stack_segment): Update.
	* frame.c (get_current_frame, has_stack_frames): Update.
	* auxv.c (info_auxv_command): Update.
	* ada-tasks.c (ada_build_task_list): Update.
	* target.c (target_has_stack): Rename from target_has_stack_1.
	* target.h (target_has_stack): Remove macro.
	(target_has_stack): Rename from target_has_stack_1.
---
 gdb/ChangeLog      | 19 +++++++++++++++++++
 gdb/ada-tasks.c    |  2 +-
 gdb/auxv.c         |  2 +-
 gdb/frame.c        |  4 ++--
 gdb/gcore.c        |  2 +-
 gdb/infrun.c       |  4 ++--
 gdb/stack.c        |  8 ++++----
 gdb/target.c       |  2 +-
 gdb/target.h       |  3 +--
 gdb/thread.c       |  6 +++---
 gdb/tui/tui-regs.c |  2 +-
 gdb/windows-tdep.c |  2 +-
 12 files changed, 37 insertions(+), 19 deletions(-)

-- 
2.17.2

Comments

Shahab Vahedi via Gdb-patches July 21, 2020, 5:12 p.m. | #1
On Mon, Jul 20, 2020 at 8:49 PM Tom Tromey <tom@tromey.com> wrote:
> --- a/gdb/ada-tasks.c

> +++ b/gdb/ada-tasks.c

> @@ -999,7 +999,7 @@ ada_build_task_list ()

>  {

>    struct ada_tasks_inferior_data *data;

>

> -  if (!target_has_stack)

> +  if (!target_has_stack ())

>      error (_("Cannot inspect Ada tasks when program is not running"));


A bit of a tangent, but either the check or the error message seems
wrong. Does this work when looking at a coredump? If yes, the error is
wrong; if not, the check is wrong.

Christian
Tom Tromey Sept. 29, 2020, 1:36 a.m. | #2
>> -  if (!target_has_stack)

>> +  if (!target_has_stack ())

>> error (_("Cannot inspect Ada tasks when program is not running"));


Christian> A bit of a tangent, but either the check or the error message seems
Christian> wrong. Does this work when looking at a coredump? If yes, the error is
Christian> wrong; if not, the check is wrong.

I suspect the wording is wrong but I am not completely certain.
I'll make a note to look into this.

Tom

Patch

diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 27b458767a7..ea40bcaaa0a 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -999,7 +999,7 @@  ada_build_task_list ()
 {
   struct ada_tasks_inferior_data *data;
 
-  if (!target_has_stack)
+  if (!target_has_stack ())
     error (_("Cannot inspect Ada tasks when program is not running"));
 
   data = get_ada_tasks_inferior_data (current_inferior ());
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 2ffcd73b988..87fc01db25c 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -576,7 +576,7 @@  fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
 static void
 info_auxv_command (const char *cmd, int from_tty)
 {
-  if (! target_has_stack)
+  if (! target_has_stack ())
     error (_("The program has no auxiliary information now."));
   else
     {
diff --git a/gdb/frame.c b/gdb/frame.c
index 44989a35193..97d394de88b 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1603,7 +1603,7 @@  get_current_frame (void)
      registers".  */
   if (!target_has_registers)
     error (_("No registers."));
-  if (!target_has_stack)
+  if (!target_has_stack ())
     error (_("No stack."));
   if (!target_has_memory ())
     error (_("No memory."));
@@ -1640,7 +1640,7 @@  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 7b653fb74e3..7837ab52056 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/infrun.c b/gdb/infrun.c
index 31266109a6d..4178e54051d 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -9107,7 +9107,7 @@  static struct value *
 siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var,
 		    void *ignore)
 {
-  if (target_has_stack
+  if (target_has_stack ()
       && inferior_ptid != null_ptid
       && gdbarch_get_siginfo_type_p (gdbarch))
     {
@@ -9342,7 +9342,7 @@  restore_infcall_control_state (struct infcall_control_state *inf_status)
   stop_stack_dummy = inf_status->stop_stack_dummy;
   stopped_by_random_signal = inf_status->stopped_by_random_signal;
 
-  if (target_has_stack)
+  if (target_has_stack ())
     {
       /* The point of the try/catch is that if the stack is clobbered,
          walking the stack might encounter a garbage pointer and
diff --git a/gdb/stack.c b/gdb/stack.c
index 265e764dc24..248d8890166 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1995,7 +1995,7 @@  backtrace_command_1 (const frame_print_options &fp_opts,
   int py_start = 0, py_end = 0;
   enum ext_lang_bt_status result = EXT_LANG_BT_ERROR;
 
-  if (!target_has_stack)
+  if (!target_has_stack ())
     error (_("No stack."));
 
   if (count_exp)
@@ -3158,7 +3158,7 @@  frame_apply_cmd_completer (struct cmd_list_element *ignore,
 static void
 frame_apply_level_command (const char *cmd, int from_tty)
 {
-  if (!target_has_stack)
+  if (!target_has_stack ())
     error (_("No stack."));
 
   bool level_found = false;
@@ -3206,7 +3206,7 @@  frame_apply_level_command (const char *cmd, int from_tty)
 static void
 frame_apply_all_command (const char *cmd, int from_tty)
 {
-  if (!target_has_stack)
+  if (!target_has_stack ())
     error (_("No stack."));
 
   frame_apply_command_count ("frame apply all", cmd, from_tty,
@@ -3221,7 +3221,7 @@  frame_apply_command (const char* cmd, int from_tty)
   int count;
   struct frame_info *trailing;
 
-  if (!target_has_stack)
+  if (!target_has_stack ())
     error (_("No stack."));
 
   if (cmd == NULL)
diff --git a/gdb/target.c b/gdb/target.c
index 352d5aa61c6..a6b4dce0de7 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -180,7 +180,7 @@  target_has_memory ()
 }
 
 int
-target_has_stack_1 (void)
+target_has_stack ()
 {
   for (target_ops *t = current_top_target (); t != NULL; t = t->beneath ())
     if (t->has_stack ())
diff --git a/gdb/target.h b/gdb/target.h
index 122c8631b5d..7d4964aaf34 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1799,8 +1799,7 @@  extern int target_has_memory ();
 /* Does the target have a stack?  (Exec files don't, VxWorks doesn't, until
    we start a process.)  */
 
-extern int target_has_stack_1 (void);
-#define target_has_stack target_has_stack_1 ()
+extern int target_has_stack ();
 
 /* Does the target have registers?  (Exec files don't.)  */
 
diff --git a/gdb/thread.c b/gdb/thread.c
index 958888e1d82..5a71eb9a992 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1406,7 +1406,7 @@  scoped_restore_current_thread::restore ()
       && m_was_stopped
       && m_thread->state == THREAD_STOPPED
       && target_has_registers
-      && target_has_stack
+      && target_has_stack ()
       && target_has_memory ())
     restore_selected_frame (m_selected_frame_id, m_selected_frame_level);
 }
@@ -1440,7 +1440,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_stack
+	  && target_has_stack ()
 	  && target_has_memory ())
 	{
 	  /* When processing internal events, there might not be a
@@ -1876,7 +1876,7 @@  thread_command (const char *tidstr, int from_tty)
       if (inferior_ptid == null_ptid)
 	error (_("No thread selected"));
 
-      if (target_has_stack)
+      if (target_has_stack ())
 	{
 	  struct thread_info *tp = inferior_thread ();
 
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index d7d13045d09..6ff0d001854 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -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);
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index aa0adeba99b..8be95ab0f82 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -431,7 +431,7 @@  static const struct lval_funcs tlb_value_funcs =
 static struct value *
 tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
 {
-  if (target_has_stack && inferior_ptid != null_ptid)
+  if (target_has_stack () && inferior_ptid != null_ptid)
     {
       struct type *type = windows_get_tlb_type (gdbarch);
       return allocate_computed_value (type, &tlb_value_funcs, NULL);