[PATCH 0/8] Remove object-like target macros

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/8] Remove object-like target macros

Tom Tromey-2
target.h has a number of object-like macros that expand to function
calls, for example

    #define target_has_memory target_has_memory_1 ()

This has long seemed confusing to me.  This series replaces these
macros either with function-like macros, or with ordinary function
calls.

Other such macros exist in gdb (exec.h and progspace.h hold the ones
I'm aware of).  I have a separate series to remove these.

Let me know what you think.

Tom


Reply | Threaded
Open this post in threaded view
|

[PATCH 1/8] Remove target_has_all_memory

Tom Tromey-2
target_has_all_memory isn't used anywhere, so this patch removes it.

gdb/ChangeLog
2020-07-20  Tom Tromey  <[hidden email]>

        * target.c (target_has_all_memory_1): Remove.
        * target.h (target_has_all_memory): Remove define.
        (target_has_all_memory_1): Don't declare.
---
 gdb/ChangeLog |  6 ++++++
 gdb/target.c  | 10 ----------
 gdb/target.h  |  7 -------
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/gdb/target.c b/gdb/target.c
index cd66675e8a4..afd1d5b327d 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -169,16 +169,6 @@ show_targetdebug (struct ui_file *file, int from_tty,
   fprintf_filtered (file, _("Target debugging is %s.\n"), value);
 }
 
-int
-target_has_all_memory_1 (void)
-{
-  for (target_ops *t = current_top_target (); t != NULL; t = t->beneath ())
-    if (t->has_all_memory ())
-      return 1;
-
-  return 0;
-}
-
 int
 target_has_memory_1 (void)
 {
diff --git a/gdb/target.h b/gdb/target.h
index 4e8d4cccd5c..208866a9c05 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1792,13 +1792,6 @@ extern void default_target_pass_ctrlc (struct target_ops *ops);
      (current_top_target ()->rcmd) (command, outbuf)
 
 
-/* Does the target include all of memory, or only part of it?  This
-   determines whether we look up the target chain for other parts of
-   memory if this target can't satisfy a request.  */
-
-extern int target_has_all_memory_1 (void);
-#define target_has_all_memory target_has_all_memory_1 ()
-
 /* Does the target include memory?  (Dummy targets don't.)  */
 
 extern int target_has_memory_1 (void);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 2/8] Remove target_has_memory macro

Tom Tromey-2
In reply to this post by Tom Tromey-2
This removes the target_has_memory object-like macro, replacing it
with the underlying function.

gdb/ChangeLog
2020-07-20  Tom Tromey  <[hidden email]>

        * target.c (target_has_memory): Rename from target_has_memory_1.
        * 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):
        Update.
        * frame.c (get_current_frame, has_stack_frames): Update.
        * target.h (target_has_memory): Remove macro.
        (target_has_memory): Rename from target_has_memory_1.
---
 gdb/ChangeLog      | 11 +++++++++++
 gdb/frame.c        |  4 ++--
 gdb/target.c       |  2 +-
 gdb/target.h       |  3 +--
 gdb/thread.c       |  4 ++--
 gdb/tui/tui-regs.c |  2 +-
 6 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/gdb/frame.c b/gdb/frame.c
index ac1016b083f..44989a35193 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1605,7 +1605,7 @@ get_current_frame (void)
     error (_("No registers."));
   if (!target_has_stack)
     error (_("No stack."));
-  if (!target_has_memory)
+  if (!target_has_memory ())
     error (_("No memory."));
   /* Traceframes are effectively a substitute for the live inferior.  */
   if (get_traceframe_number () < 0)
@@ -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/target.c b/gdb/target.c
index afd1d5b327d..352d5aa61c6 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -170,7 +170,7 @@ show_targetdebug (struct ui_file *file, int from_tty,
 }
 
 int
-target_has_memory_1 (void)
+target_has_memory ()
 {
   for (target_ops *t = current_top_target (); t != NULL; t = t->beneath ())
     if (t->has_memory ())
diff --git a/gdb/target.h b/gdb/target.h
index 208866a9c05..122c8631b5d 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1794,8 +1794,7 @@ extern void default_target_pass_ctrlc (struct target_ops *ops);
 
 /* Does the target include memory?  (Dummy targets don't.)  */
 
-extern int target_has_memory_1 (void);
-#define target_has_memory target_has_memory_1 ()
+extern int target_has_memory ();
 
 /* Does the target have a stack?  (Exec files don't, VxWorks doesn't, until
    we start a process.)  */
diff --git a/gdb/thread.c b/gdb/thread.c
index 4dce1ef82aa..958888e1d82 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1407,7 +1407,7 @@ scoped_restore_current_thread::restore ()
       && m_thread->state == THREAD_STOPPED
       && target_has_registers
       && target_has_stack
-      && target_has_memory)
+      && target_has_memory ())
     restore_selected_frame (m_selected_frame_id, m_selected_frame_level);
 }
 
@@ -1441,7 +1441,7 @@ scoped_restore_current_thread::scoped_restore_current_thread ()
       if (m_was_stopped
   && target_has_registers
   && target_has_stack
-  && target_has_memory)
+  && target_has_memory ())
  {
   /* When processing internal events, there might not be a
      selected frame.  If we naively call get_selected_frame
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 04d7469de5a..d7d13045d09 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);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 3/8] Remove target_has_stack macro

Tom Tromey-2
In reply to this post by Tom Tromey-2
This removes the target_has_stack object-like macro, replacing it with
the underlying function.

gdb/ChangeLog
2020-07-20  Tom Tromey  <[hidden email]>

        * 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(-)

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);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 4/8] Remove target_has_registers macro

Tom Tromey-2
In reply to this post by Tom Tromey-2
This removes the target_has_registers object-like macro, replacing it
with the underlying function.

gdb/ChangeLog
2020-07-20  Tom Tromey  <[hidden email]>

        * 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

Reply | Threaded
Open this post in threaded view
|

[PATCH 5/8] Turn target_can_execute_reverse into function-like macro

Tom Tromey-2
In reply to this post by Tom Tromey-2
This changes target_can_execute_reverse from an object-like macro to a
function-like macro.

gdb/ChangeLog
2020-07-20  Tom Tromey  <[hidden email]>

        * mi/mi-main.c (exec_reverse_continue)
        (mi_cmd_list_target_features): Update.
        * infrun.c (set_exec_direction_func): Update.
        * target.c (default_execution_direction): Update.
        * reverse.c (exec_reverse_once): Update.
        * target.h (target_can_execute_reverse): Now a function-like
        macro.
---
 gdb/ChangeLog    | 10 ++++++++++
 gdb/infrun.c     |  2 +-
 gdb/mi/mi-main.c |  4 ++--
 gdb/reverse.c    |  2 +-
 gdb/target.c     |  2 +-
 gdb/target.h     |  2 +-
 6 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 4178e54051d..2298088910e 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -9409,7 +9409,7 @@ static void
 set_exec_direction_func (const char *args, int from_tty,
  struct cmd_list_element *cmd)
 {
-  if (target_can_execute_reverse)
+  if (target_can_execute_reverse ())
     {
       if (!strcmp (exec_direction, exec_forward))
  execution_direction = EXEC_FORWARD;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 99da554c444..c5c7be7246a 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -321,7 +321,7 @@ exec_reverse_continue (char **argv, int argc)
   if (dir == EXEC_REVERSE)
     error (_("Already in reverse mode."));
 
-  if (!target_can_execute_reverse)
+  if (!target_can_execute_reverse ())
     error (_("Target %s does not support this command."), target_shortname);
 
   scoped_restore save_exec_dir = make_scoped_restore (&execution_direction,
@@ -1684,7 +1684,7 @@ mi_cmd_list_target_features (const char *command, char **argv, int argc)
       ui_out_emit_list list_emitter (uiout, "features");
       if (mi_async_p ())
  uiout->field_string (NULL, "async");
-      if (target_can_execute_reverse)
+      if (target_can_execute_reverse ())
  uiout->field_string (NULL, "reverse");
       return;
     }
diff --git a/gdb/reverse.c b/gdb/reverse.c
index 583e0d02da2..4aa22251b27 100644
--- a/gdb/reverse.c
+++ b/gdb/reverse.c
@@ -44,7 +44,7 @@ exec_reverse_once (const char *cmd, const char *args, int from_tty)
     error (_("Already in reverse mode.  Use '%s' or 'set exec-dir forward'."),
    cmd);
 
-  if (!target_can_execute_reverse)
+  if (!target_can_execute_reverse ())
     error (_("Target %s does not support this command."), target_shortname);
 
   std::string reverse_command = string_printf ("%s %s", cmd, args ? args : "");
diff --git a/gdb/target.c b/gdb/target.c
index ba9532dcb27..a186b1b163c 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -525,7 +525,7 @@ default_get_ada_task_ptid (struct target_ops *self, long lwp, long tid)
 static enum exec_direction_kind
 default_execution_direction (struct target_ops *self)
 {
-  if (!target_can_execute_reverse)
+  if (!target_can_execute_reverse ())
     return EXEC_FORWARD;
   else if (!target_can_async_p ())
     return EXEC_FORWARD;
diff --git a/gdb/target.h b/gdb/target.h
index c9291ab59f1..a0a8d082f0d 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -2099,7 +2099,7 @@ extern int target_ranged_break_num_registers (void);
 extern int target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask);
 
 /* Target can execute in reverse?  */
-#define target_can_execute_reverse \
+#define target_can_execute_reverse() \
       current_top_target ()->can_execute_reverse ()
 
 extern const struct target_desc *target_read_description (struct target_ops *);
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 6/8] Remove target_has_execution macro

Tom Tromey-2
In reply to this post by Tom Tromey-2
This removes the object-like macro target_has_execution, repalcing it
with a function call.  target_has_execution_current is also now
handled by this function.

gdb/ChangeLog
2020-07-20  Tom Tromey  <[hidden email]>

        * inferior.h (class inferior) <has_execution>: Update.
        * windows-tdep.c (windows_solib_create_inferior_hook): Update.
        * valops.c (find_function_in_inferior)
        (value_allocate_space_in_inferior): Update.
        * top.c (kill_or_detach): Update.
        * target.c (target_preopen, set_target_permissions): Update.
        (target_has_execution_current): Remove.
        * sparc64-tdep.c (adi_examine_command, adi_assign_command):
        Update.
        * solib.c (update_solib_list, reload_shared_libraries): Update.
        * solib-svr4.c (svr4_solib_create_inferior_hook): Update.
        * solib-dsbt.c (enable_break): Update.
        * score-tdep.c (score7_fetch_inst): Update.
        * rs6000-nat.c (rs6000_nat_target::xfer_shared_libraries):
        Update.
        * remote.c (remote_target::start_remote)
        (remote_target::remote_check_symbols, remote_target::open_1)
        (remote_target::remote_detach_1, remote_target::verify_memory)
        (remote_target::xfer_partial, remote_target::read_description)
        (remote_target::get_min_fast_tracepoint_insn_len): Update.
        * record-full.c (record_full_open_1): Update.
        * record-btrace.c (record_btrace_target_open): Update.
        * objc-lang.c (lookup_objc_class, lookup_child_selector)
        (value_nsstring): Update.
        * linux-thread-db.c (add_thread_db_info)
        (thread_db_find_new_threads_silently, check_thread_db_callback)
        (try_thread_db_load_1, record_thread): Update.
        * linux-tdep.c (linux_info_proc, linux_vsyscall_range_raw):
        Update.
        * linux-fork.c (checkpoint_command): Update.
        * infrun.c (set_non_stop, set_observer_mode)
        (check_multi_target_resumption, for_each_just_stopped_thread)
        (maybe_remove_breakpoints, normal_stop)
        (class infcall_suspend_state): Update.
        * infcmd.c (ERROR_NO_INFERIOR, kill_if_already_running)
        (info_program_command, attach_command): Update.
        * infcall.c (call_function_by_hand_dummy): Update.
        * inf-loop.c (inferior_event_handler): Update.
        * gcore.c (gcore_command, derive_heap_segment): Update.
        * exec.c (exec_file_command): Update.
        * eval.c (evaluate_subexp): Update.
        * compile/compile.c (compile_to_object): Update.
        * cli/cli-dump.c (restore_command): Update.
        * breakpoint.c (update_watchpoint)
        (update_inserted_breakpoint_locations)
        (insert_breakpoint_locations, get_bpstat_thread): Update.
        * target.h (target_has_execution): Remove macro.
        (target_has_execution_current): Don't declare.
        (target_has_execution): Rename from target_has_execution_1.  Add
        argument default.
---
 gdb/ChangeLog         | 53 +++++++++++++++++++++++++++++++++++++++++++
 gdb/breakpoint.c      |  8 +++----
 gdb/cli/cli-dump.c    |  2 +-
 gdb/compile/compile.c |  2 +-
 gdb/eval.c            |  2 +-
 gdb/exec.c            |  2 +-
 gdb/gcore.c           |  4 ++--
 gdb/inf-loop.c        |  2 +-
 gdb/infcall.c         |  4 ++--
 gdb/infcmd.c          |  8 +++----
 gdb/inferior.h        |  2 +-
 gdb/infrun.c          | 16 ++++++-------
 gdb/linux-fork.c      |  2 +-
 gdb/linux-tdep.c      |  4 ++--
 gdb/linux-thread-db.c | 10 ++++----
 gdb/objc-lang.c       |  8 +++----
 gdb/record-btrace.c   |  2 +-
 gdb/record-full.c     |  2 +-
 gdb/remote.c          | 17 +++++++-------
 gdb/rs6000-nat.c      |  2 +-
 gdb/score-tdep.c      |  2 +-
 gdb/solib-dsbt.c      |  2 +-
 gdb/solib-svr4.c      |  2 +-
 gdb/solib.c           |  4 ++--
 gdb/sparc64-tdep.c    |  4 ++--
 gdb/target.c          | 17 ++++++--------
 gdb/target.h          | 12 +++-------
 gdb/top.c             |  2 +-
 gdb/valops.c          |  4 ++--
 gdb/windows-tdep.c    |  2 +-
 30 files changed, 124 insertions(+), 79 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 6d81323dd92..37f490e4c86 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1751,7 +1751,7 @@ update_watchpoint (struct watchpoint *b, int reparse)
      don't try to insert watchpoint.  We don't automatically delete
      such watchpoint, though, since failure to parse expression
      is different from out-of-scope watchpoint.  */
-  if (!target_has_execution)
+  if (!target_has_execution ())
     {
       /* Without execution, memory can't change.  No use to try and
  set watchpoint locations.  The watchpoint will be reset when
@@ -2871,7 +2871,7 @@ update_inserted_breakpoint_locations (void)
  if we aren't attached to any process yet, we should still
  insert breakpoints.  */
       if (!gdbarch_has_global_breakpoints (target_gdbarch ())
-  && (inferior_ptid == null_ptid || !target_has_execution))
+  && (inferior_ptid == null_ptid || !target_has_execution ()))
  continue;
 
       val = insert_bp_location (bl, &tmp_error_stream, &disabled_breaks,
@@ -2927,7 +2927,7 @@ insert_breakpoint_locations (void)
  if we aren't attached to any process yet, we should still
  insert breakpoints.  */
       if (!gdbarch_has_global_breakpoints (target_gdbarch ())
-  && (inferior_ptid == null_ptid || !target_has_execution))
+  && (inferior_ptid == null_ptid || !target_has_execution ()))
  continue;
 
       val = insert_bp_location (bl, &tmp_error_stream, &disabled_breaks,
@@ -4403,7 +4403,7 @@ bpstat_do_actions_1 (bpstat *bsp)
 static thread_info *
 get_bpstat_thread ()
 {
-  if (inferior_ptid == null_ptid || !target_has_execution)
+  if (inferior_ptid == null_ptid || !target_has_execution ())
     return NULL;
 
   thread_info *tp = inferior_thread ();
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 567ef2eeded..013d15528af 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -505,7 +505,7 @@ restore_command (const char *args, int from_tty)
   struct callback_data data;
   int binary_flag = 0;
 
-  if (!target_has_execution)
+  if (!target_has_execution ())
     noprocess ();
 
   data.load_offset = 0;
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 0c29a0476e7..59dc52e3b4c 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -683,7 +683,7 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
   struct gdbarch *gdbarch = get_current_arch ();
   std::string triplet_rx;
 
-  if (!target_has_execution)
+  if (!target_has_execution ())
     error (_("The program must be running for the compile command to "\
      "work."));
 
diff --git a/gdb/eval.c b/gdb/eval.c
index c62c35f3183..f93bbb0b78d 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -69,7 +69,7 @@ evaluate_subexp (struct type *expect_type, struct expression *exp,
   struct value *retval;
 
   gdb::optional<enable_thread_stack_temporaries> stack_temporaries;
-  if (*pos == 0 && target_has_execution
+  if (*pos == 0 && target_has_execution ()
       && exp->language_defn->la_language == language_cplus
       && !thread_stack_temporaries_enabled_p (inferior_thread ()))
     stack_temporaries.emplace (inferior_thread ());
diff --git a/gdb/exec.c b/gdb/exec.c
index 2ff5846c0e7..ba11c8e47ae 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -545,7 +545,7 @@ exec_file_attach (const char *filename, int from_tty)
 static void
 exec_file_command (const char *args, int from_tty)
 {
-  if (from_tty && target_has_execution
+  if (from_tty && target_has_execution ()
       && !query (_("A program is being debugged already.\n"
    "Are you sure you want to change the file? ")))
     error (_("File not changed."));
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 2ebc8df3f8b..bbd3478d96d 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -129,7 +129,7 @@ gcore_command (const char *args, int from_tty)
   gdb::unique_xmalloc_ptr<char> corefilename;
 
   /* No use generating a corefile without a target process.  */
-  if (!target_has_execution)
+  if (!target_has_execution ())
     noprocess ();
 
   if (args && *args)
@@ -316,7 +316,7 @@ derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
 
   /* This function depends on being able to call a function in the
      inferior.  */
-  if (!target_has_execution)
+  if (!target_has_execution ())
     return 0;
 
   /* The following code assumes that the link map is arranged as
diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c
index cf746b8588c..68c94d9e942 100644
--- a/gdb/inf-loop.c
+++ b/gdb/inf-loop.c
@@ -48,7 +48,7 @@ inferior_event_handler (enum inferior_event_type event_type)
   /* Unregister the inferior from the event loop.  This is done
      so that when the inferior is not running we don't get
      distracted by spurious inferior output.  */
-  if (target_has_execution && target_can_async_p ())
+  if (target_has_execution () && target_can_async_p ())
     target_async (0);
  }
 
diff --git a/gdb/infcall.c b/gdb/infcall.c
index cdb30137c35..0c603d717d2 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -786,7 +786,7 @@ call_function_by_hand_dummy (struct value *function,
     error (_("Cannot call functions in the program: "
      "may-call-functions is off."));
 
-  if (!target_has_execution)
+  if (!target_has_execution ())
     noprocess ();
 
   if (get_traceframe_number () >= 0)
@@ -1353,7 +1353,7 @@ When the function is done executing, GDB will silently stop."),
   /* If the program has exited, or we stopped at a different thread,
      exit and inform the user.  */
 
-  if (! target_has_execution)
+  if (! target_has_execution ())
     {
       const char *name = get_function_name (funaddr,
     name_buf, sizeof (name_buf));
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 86a680b8e52..07f2187a116 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -64,7 +64,7 @@ static void until_next_command (int);
 static void step_1 (int, int, const char *);
 
 #define ERROR_NO_INFERIOR \
-   if (!target_has_execution) error (_("The program is not being run."));
+   if (!target_has_execution ()) error (_("The program is not being run."));
 
 /* Scratch area where string containing arguments to give to the
    program will be stored by 'set args'.  As soon as anything is
@@ -358,7 +358,7 @@ post_create_inferior (struct target_ops *target, int from_tty)
 static void
 kill_if_already_running (int from_tty)
 {
-  if (inferior_ptid != null_ptid && target_has_execution)
+  if (inferior_ptid != null_ptid && target_has_execution ())
     {
       /* Bail out before killing the program if we will not be able to
  restart it.  */
@@ -1861,7 +1861,7 @@ info_program_command (const char *args, int from_tty)
   ptid_t ptid;
   process_stratum_target *proc_target;
 
-  if (!target_has_execution)
+  if (!target_has_execution ())
     {
       printf_filtered (_("The program being debugged is not being run.\n"));
       return;
@@ -2569,7 +2569,7 @@ attach_command (const char *args, int from_tty)
     /* Don't complain if all processes share the same symbol
        space.  */
     ;
-  else if (target_has_execution)
+  else if (target_has_execution ())
     {
       if (query (_("A program is being debugged already.  Kill it? ")))
  target_kill ();
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 606cece6c0b..70edf21b34b 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -377,7 +377,7 @@ class inferior : public refcounted_object
   { return m_target_stack.at (stratum); }
 
   bool has_execution ()
-  { return target_has_execution_1 (this); }
+  { return target_has_execution (this); }
 
   /* Pointer to next inferior in singly-linked list of inferiors.  */
   struct inferior *next = NULL;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 2298088910e..6f0154a0234 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -206,7 +206,7 @@ static void
 set_non_stop (const char *args, int from_tty,
       struct cmd_list_element *c)
 {
-  if (target_has_execution)
+  if (target_has_execution ())
     {
       non_stop_1 = non_stop;
       error (_("Cannot change this setting while the inferior is running."));
@@ -235,7 +235,7 @@ static void
 set_observer_mode (const char *args, int from_tty,
    struct cmd_list_element *c)
 {
-  if (target_has_execution)
+  if (target_has_execution ())
     {
       observer_mode_1 = observer_mode;
       error (_("Cannot change this setting while the inferior is running."));
@@ -2915,7 +2915,7 @@ check_multi_target_resumption (process_stratum_target *resume_target)
  {
   switch_to_inferior_no_thread (inf);
 
-  if (!target_has_execution)
+  if (!target_has_execution ())
     continue;
 
   process_stratum_target *proc_target
@@ -3353,7 +3353,7 @@ typedef void (*for_each_just_stopped_thread_callback_func)
 static void
 for_each_just_stopped_thread (for_each_just_stopped_thread_callback_func func)
 {
-  if (!target_has_execution || inferior_ptid == null_ptid)
+  if (!target_has_execution () || inferior_ptid == null_ptid)
     return;
 
   if (target_is_non_stop_p ())
@@ -8410,7 +8410,7 @@ print_stop_event (struct ui_out *uiout, bool displays)
 void
 maybe_remove_breakpoints (void)
 {
-  if (!breakpoints_should_be_inserted_now () && target_has_execution)
+  if (!breakpoints_should_be_inserted_now () && target_has_execution ())
     {
       if (remove_breakpoints ())
  {
@@ -8566,7 +8566,7 @@ normal_stop (void)
      informing of a stop.  */
   if (!non_stop
       && previous_inferior_ptid != inferior_ptid
-      && target_has_execution
+      && target_has_execution ()
       && last.kind != TARGET_WAITKIND_SIGNALLED
       && last.kind != TARGET_WAITKIND_EXITED
       && last.kind != TARGET_WAITKIND_NO_RESUMED)
@@ -8671,7 +8671,7 @@ normal_stop (void)
 
   annotate_stopped ();
 
-  if (target_has_execution)
+  if (target_has_execution ())
     {
       if (last.kind != TARGET_WAITKIND_SIGNALLED
   && last.kind != TARGET_WAITKIND_EXITED
@@ -9187,7 +9187,7 @@ class infcall_suspend_state
 
     /* The inferior can be gone if the user types "print exit(0)"
        (and perhaps other times).  */
-    if (target_has_execution)
+    if (target_has_execution ())
       /* NB: The register write goes through to the target.  */
       regcache->restore (registers ());
   }
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index e232d9c263a..b3d8fc1a174 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -645,7 +645,7 @@ checkpoint_command (const char *args, int from_tty)
   struct fork_info *fp;
   pid_t retpid;
 
-  if (!target_has_execution)
+  if (!target_has_execution ())
     error (_("The program is not being run."));
 
   /* Ensure that the inferior is not multithreaded.  */
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index fd4337f100d..ade37ae023e 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -753,7 +753,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
     }
   else
     {
-      if (!target_has_execution)
+      if (!target_has_execution ())
  error (_("No current process: you must name one."));
       if (current_inferior ()->fake_pid_p)
  error (_("Can't determine the current process's PID: you must name one."));
@@ -2216,7 +2216,7 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range)
   /* It doesn't make sense to access the host's /proc when debugging a
      core file.  Instead, look for the PT_LOAD segment that matches
      the vDSO.  */
-  if (!target_has_execution)
+  if (!target_has_execution ())
     {
       long phdrs_size;
       int num_phdrs, i;
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index ebb4022539d..839688faf0e 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -237,7 +237,7 @@ add_thread_db_info (void *handle)
 
   /* The workaround works by reading from /proc/pid/status, so it is
      disabled for core files.  */
-  if (target_has_execution)
+  if (target_has_execution ())
     info->need_stale_parent_threads_check = 1;
 
   info->next = thread_db_list;
@@ -531,7 +531,7 @@ thread_db_find_new_threads_silently (thread_info *stopped)
  corrupted.  For core files it does not apply, no 'later enumeration'
  is possible.  */
 
-      if (!target_has_execution || !inferior_has_bug ("nptl_version", 2, 7))
+      if (!target_has_execution () || !inferior_has_bug ("nptl_version", 2, 7))
  {
   exception_fprintf (gdb_stderr, except,
      _("Warning: couldn't activate thread debugging "
@@ -658,7 +658,7 @@ check_thread_db_callback (const td_thrhandle_t *th, void *arg)
   memset (&th2, 23, sizeof (td_thrhandle_t));
   CALL_UNCHECKED (td_ta_map_lwp2thr, th->th_ta_p, ti.ti_lid, &th2);
 
-  if (tdb_testinfo->last_result == TD_ERR && !target_has_execution)
+  if (tdb_testinfo->last_result == TD_ERR && !target_has_execution ())
     {
       /* Some platforms require execution for td_ta_map_lwp2thr.  */
       LOG (_("; can't map_lwp2thr"));
@@ -884,7 +884,7 @@ try_thread_db_load_1 (struct thread_db_info *info)
 
      td_ta_map_lwp2thr uses ps_get_thread_area, but we can't use that
      currently on core targets, as it uses ptrace directly.  */
-  if (target_has_execution
+  if (target_has_execution ()
       && linux_proc_task_list_dir_exists (inferior_ptid.pid ()))
     info->td_ta_thr_iter_p = NULL;
   else
@@ -1358,7 +1358,7 @@ record_thread (struct thread_db_info *info,
   else
     tp->priv.reset (priv);
 
-  if (target_has_execution)
+  if (target_has_execution ())
     check_thread_signals ();
 
   return tp;
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 63cdac1b035..7aeacc753ee 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -33,7 +33,7 @@
 #include "value.h"
 #include "symfile.h"
 #include "objfiles.h"
-#include "target.h" /* for target_has_execution */
+#include "target.h"
 #include "gdbcore.h"
 #include "gdbcmd.h"
 #include "frame.h"
@@ -112,7 +112,7 @@ lookup_objc_class (struct gdbarch *gdbarch, const char *classname)
   struct type *char_type = builtin_type (gdbarch)->builtin_char;
   struct value * function, *classval;
 
-  if (! target_has_execution)
+  if (! target_has_execution ())
     {
       /* Can't call into inferior to lookup class.  */
       return 0;
@@ -141,7 +141,7 @@ lookup_child_selector (struct gdbarch *gdbarch, const char *selname)
   struct type *char_type = builtin_type (gdbarch)->builtin_char;
   struct value * function, *selstring;
 
-  if (! target_has_execution)
+  if (! target_has_execution ())
     {
       /* Can't call into inferior to lookup selector.  */
       return 0;
@@ -172,7 +172,7 @@ value_nsstring (struct gdbarch *gdbarch, char *ptr, int len)
   struct symbol *sym;
   struct type *type;
 
-  if (!target_has_execution)
+  if (!target_has_execution ())
     return 0; /* Can't call into inferior to create NSString.  */
 
   stringValue[2] = value_string(ptr, len, char_type);
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 718de62f280..a402983babb 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -389,7 +389,7 @@ record_btrace_target_open (const char *args, int from_tty)
 
   record_preopen ();
 
-  if (!target_has_execution)
+  if (!target_has_execution ())
     error (_("The program is not being run."));
 
   for (thread_info *tp : current_inferior ()->non_exited_threads ())
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 1d8f1930a5b..527daadd5fb 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -947,7 +947,7 @@ record_full_open_1 (const char *name, int from_tty)
     fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open_1\n");
 
   /* check exec */
-  if (!target_has_execution)
+  if (!target_has_execution ())
     error (_("Process record: the program is not being run."));
   if (non_stop)
     error (_("Process record target can't debug inferior in non-stop mode "
diff --git a/gdb/remote.c b/gdb/remote.c
index 59075cb09f2..a8b12cc50aa 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4843,7 +4843,7 @@ remote_target::start_remote (int from_tty, int extended_p)
     }
 
   /* If we connected to a live target, do some additional setup.  */
-  if (target_has_execution)
+  if (target_has_execution ())
     {
       if (symfile_objfile) /* No use without a symbol-file.  */
  remote_check_symbols ();
@@ -4946,7 +4946,7 @@ remote_target::remote_check_symbols ()
      but our current inferior is not running, we should not invite the
      remote target to request symbol lookups related to its
      (unrelated) current process.  */
-  if (!target_has_execution)
+  if (!target_has_execution ())
     return;
 
   if (packet_support (PACKET_qSymbol) == PACKET_DISABLE)
@@ -5544,7 +5544,7 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
   /* If we're connected to a running target, target_preopen will kill it.
      Ask this question first, before target_preopen has a chance to kill
      anything.  */
-  if (curr_remote != NULL && !target_has_execution)
+  if (curr_remote != NULL && !target_has_execution ())
     {
       if (from_tty
   && !query (_("Already connected to a remote target.  Disconnect? ")))
@@ -5727,7 +5727,7 @@ remote_target::remote_detach_1 (inferior *inf, int from_tty)
   struct remote_state *rs = get_remote_state ();
   int is_fork_parent;
 
-  if (!target_has_execution)
+  if (!target_has_execution ())
     error (_("No process to detach from."));
 
   target_announce_detach (from_tty);
@@ -10715,7 +10715,8 @@ remote_target::verify_memory (const gdb_byte *data, CORE_ADDR lma, ULONGEST size
 
   /* It doesn't make sense to use qCRC if the remote target is
      connected but not running.  */
-  if (target_has_execution && packet_support (PACKET_qCRC) != PACKET_DISABLE)
+  if (target_has_execution ()
+      && packet_support (PACKET_qCRC) != PACKET_DISABLE)
     {
       enum packet_result result;
 
@@ -10977,7 +10978,7 @@ remote_target::xfer_partial (enum target_object object,
       /* If the remote target is connected but not running, we should
  pass this request down to a lower stratum (e.g. the executable
  file).  */
-      if (!target_has_execution)
+      if (!target_has_execution ())
  return TARGET_XFER_EOF;
 
       if (writebuf != NULL)
@@ -11717,7 +11718,7 @@ remote_target::read_description ()
 
   /* Do not try this during initial connection, when we do not know
      whether there is a running but stopped thread.  */
-  if (!target_has_execution || inferior_ptid == null_ptid)
+  if (!target_has_execution () || inferior_ptid == null_ptid)
     return beneath ()->read_description ();
 
   if (!data->guesses.empty ())
@@ -13581,7 +13582,7 @@ remote_target::get_min_fast_tracepoint_insn_len ()
 
   /* If we're not debugging a process yet, the IPA can't be
      loaded.  */
-  if (!target_has_execution)
+  if (!target_has_execution ())
     return 0;
 
   /* Make sure the remote is pointing at the right process.  */
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 654e06e3e4b..7280b048efa 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -650,7 +650,7 @@ rs6000_nat_target::xfer_shared_libraries
 
   /* This function assumes that it is being run with a live process.
      Core files are handled via gdbarch.  */
-  gdb_assert (target_has_execution);
+  gdb_assert (target_has_execution ());
 
   if (writebuf)
     return TARGET_XFER_E_IO;
diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index 90cb0fa312a..72cba90a27c 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -123,7 +123,7 @@ score7_fetch_inst (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *memblock)
   int big;
   int ret;
 
-  if (target_has_execution && memblock != NULL)
+  if (target_has_execution () && memblock != NULL)
     {
       /* Fetch instruction from local MEMBLOCK.  */
       memcpy (buf, memblock, SCORE_INSTLEN);
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index 94a6ac83754..0f146725dba 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -781,7 +781,7 @@ enable_break (void)
   if (exec_bfd == NULL)
     return 0;
 
-  if (!target_has_execution)
+  if (!target_has_execution ())
     return 0;
 
   info = get_dsbt_info ();
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 570450c5400..4ae21d190bf 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -3014,7 +3014,7 @@ svr4_solib_create_inferior_hook (int from_tty)
 
   /* No point setting a breakpoint in the dynamic linker if we can't
      hit it (e.g., a core file, or a trace file).  */
-  if (!target_has_execution)
+  if (!target_has_execution ())
     return;
 
   if (!svr4_have_link_map_offsets ())
diff --git a/gdb/solib.c b/gdb/solib.c
index cd410bb9e3e..cf5d05e83b2 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -729,7 +729,7 @@ update_solib_list (int from_tty)
 
   /* We can reach here due to changing solib-search-path or the
      sysroot, before having any inferior.  */
-  if (target_has_execution && inferior_ptid != null_ptid)
+  if (target_has_execution () && inferior_ptid != null_ptid)
     {
       struct inferior *inf = current_inferior ();
 
@@ -1351,7 +1351,7 @@ reload_shared_libraries (const char *ignored, int from_tty,
      Absent this call, if we've just connected to a target and set
      solib-absolute-prefix or solib-search-path, we'll lose all information
      about ld.so.  */
-  if (target_has_execution)
+  if (target_has_execution ())
     {
       /* Reset or free private data structures not associated with
  so_list entries.  */
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index f4810523dfa..6279c57a0ac 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -448,7 +448,7 @@ static void
 adi_examine_command (const char *args, int from_tty)
 {
   /* make sure program is active and adi is available */
-  if (!target_has_execution)
+  if (!target_has_execution ())
     error (_("ADI command requires a live process/thread"));
 
   if (!adi_available ())
@@ -484,7 +484,7 @@ adi_assign_command (const char *args, int from_tty)
     = N_("Usage: adi assign|a[/COUNT] ADDR = VERSION");
 
   /* make sure program is active and adi is available */
-  if (!target_has_execution)
+  if (!target_has_execution ())
     error (_("ADI command requires a live process/thread"));
 
   if (!adi_available ())
diff --git a/gdb/target.c b/gdb/target.c
index a186b1b163c..ad95044d0c8 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -200,8 +200,11 @@ target_has_registers ()
 }
 
 bool
-target_has_execution_1 (inferior *inf)
+target_has_execution (inferior *inf)
 {
+  if (inf == nullptr)
+    inf = current_inferior ();
+
   for (target_ops *t = inf->top_target ();
        t != nullptr;
        t = inf->find_target_beneath (t))
@@ -211,12 +214,6 @@ target_has_execution_1 (inferior *inf)
   return false;
 }
 
-int
-target_has_execution_current (void)
-{
-  return target_has_execution_1 (current_inferior ());
-}
-
 /* This is used to implement the various target commands.  */
 
 static void
@@ -1906,12 +1903,12 @@ target_preopen (int from_tty)
   if (current_inferior ()->pid != 0)
     {
       if (!from_tty
-  || !target_has_execution
+  || !target_has_execution ()
   || query (_("A program is being debugged already.  Kill it? ")))
  {
   /* Core inferiors actually should be detached, not
      killed.  */
-  if (target_has_execution)
+  if (target_has_execution ())
     target_kill ();
   else
     target_detach (current_inferior (), 0);
@@ -3923,7 +3920,7 @@ static void
 set_target_permissions (const char *args, int from_tty,
  struct cmd_list_element *c)
 {
-  if (target_has_execution)
+  if (target_has_execution ())
     {
       update_target_permissions ();
       error (_("Cannot change this setting while the inferior is running."));
diff --git a/gdb/target.h b/gdb/target.h
index a0a8d082f0d..7811f499f70 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1811,16 +1811,10 @@ extern int target_has_registers ();
    whether or not the target is capable of execution, but there are
    also targets which can be current while not executing.  In that
    case this will become true after to_create_inferior or
-   to_attach.  */
+   to_attach.  INF is the inferior to use; nullptr means to use the
+   current inferior.  */
 
-extern bool target_has_execution_1 (inferior *inf);
-
-/* Like target_has_execution_1, but always passes
-   current_inferior().  */
-
-extern int target_has_execution_current (void);
-
-#define target_has_execution target_has_execution_current ()
+extern bool target_has_execution (inferior *inf = nullptr);
 
 /* Can the target support the debugger control of thread execution?
    Can it lock the thread scheduler?  */
diff --git a/gdb/top.c b/gdb/top.c
index acd31afb9a9..6233575eed6 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1681,7 +1681,7 @@ kill_or_detach (inferior *inf, int from_tty)
       switch_to_thread (thread);
 
       /* Leave core files alone.  */
-      if (target_has_execution)
+      if (target_has_execution ())
  {
   if (inf->attach_flag)
     target_detach (inf, from_tty);
diff --git a/gdb/valops.c b/gdb/valops.c
index 033fd42036a..82dba2c89af 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -155,7 +155,7 @@ find_function_in_inferior (const char *name, struct objfile **objf_p)
  }
       else
  {
-  if (!target_has_execution)
+  if (!target_has_execution ())
     error (_("evaluation of this expression "
      "requires the target program to be active"));
   else
@@ -182,7 +182,7 @@ value_allocate_space_in_inferior (int len)
   val = call_function_by_hand (val, NULL, blocklen);
   if (value_logical_not (val))
     {
-      if (!target_has_execution)
+      if (!target_has_execution ())
  error (_("No memory available to program now: "
  "you need to start the target first"));
       else
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 8be95ab0f82..fc73ba7736e 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -898,7 +898,7 @@ windows_solib_create_inferior_hook (int from_tty)
     }
   CORE_ADDR tlb;
   gdb_byte buf[8];
-  if (target_has_execution
+  if (target_has_execution ()
       && target_get_tib_address (inferior_ptid, &tlb)
       && !target_read_memory (tlb + peb_offset, buf, ptr_bytes))
     {
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 7/8] Turn target_can_lock_scheduler into a function-like macro

Tom Tromey-2
In reply to this post by Tom Tromey-2
This changes the object-like macro target_can_lock_scheduler into a
function-like macro.

2020-07-20  Tom Tromey  <[hidden email]>

        * infrun.c (set_schedlock_func): Update.
        * target.h (target_can_lock_scheduler): Now a function-like
        macro.
---
 gdb/ChangeLog | 6 ++++++
 gdb/infrun.c  | 2 +-
 gdb/target.h  | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 6f0154a0234..ff9b34f12fd 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2101,7 +2101,7 @@ show_scheduler_mode (struct ui_file *file, int from_tty,
 static void
 set_schedlock_func (const char *args, int from_tty, struct cmd_list_element *c)
 {
-  if (!target_can_lock_scheduler)
+  if (!target_can_lock_scheduler ())
     {
       scheduler_mode = schedlock_off;
       error (_("Target '%s' cannot support this command."), target_shortname);
diff --git a/gdb/target.h b/gdb/target.h
index 7811f499f70..14c0aa366b8 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1819,7 +1819,7 @@ extern bool target_has_execution (inferior *inf = nullptr);
 /* Can the target support the debugger control of thread execution?
    Can it lock the thread scheduler?  */
 
-#define target_can_lock_scheduler \
+#define target_can_lock_scheduler() \
   (current_top_target ()->get_thread_control_capabilities () & tc_schedlock)
 
 /* Controls whether async mode is permitted.  */
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

[PATCH 8/8] Turn target_have_steppable_watchpoint into function-like macro

Tom Tromey-2
In reply to this post by Tom Tromey-2
This changes the object-like macro target_have_steppable_watchpoint
into a function-like macro.

2020-07-20  Tom Tromey  <[hidden email]>

        * infrun.c (displaced_step_fixup, thread_still_needs_step_over)
        (handle_signal_stop): Update.
        * procfs.c (procfs_target::insert_watchpoint): Update.
        * target.h (target_have_steppable_watchpoint): Now a function-like
        macro.
---
 gdb/ChangeLog | 8 ++++++++
 gdb/infrun.c  | 6 +++---
 gdb/procfs.c  | 2 +-
 gdb/target.h  | 2 +-
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index ff9b34f12fd..cbc92568459 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1887,7 +1887,7 @@ displaced_step_fixup (thread_info *event_thread, enum gdb_signal signal)
   if (signal == GDB_SIGNAL_TRAP
       && !(target_stopped_by_watchpoint ()
    && (gdbarch_have_nonsteppable_watchpoint (displaced->step_gdbarch)
-       || target_have_steppable_watchpoint)))
+       || target_have_steppable_watchpoint ())))
     {
       /* Fix up the resulting state.  */
       gdbarch_displaced_step_fixup (displaced->step_gdbarch,
@@ -2842,7 +2842,7 @@ thread_still_needs_step_over (struct thread_info *tp)
     what |= STEP_OVER_BREAKPOINT;
 
   if (tp->stepping_over_watchpoint
-      && !target_have_steppable_watchpoint)
+      && !target_have_steppable_watchpoint ())
     what |= STEP_OVER_WATCHPOINT;
 
   return what;
@@ -6092,7 +6092,7 @@ handle_signal_stop (struct execution_control_state *ecs)
   /* If necessary, step over this watchpoint.  We'll be back to display
      it in a moment.  */
   if (stopped_by_watchpoint
-      && (target_have_steppable_watchpoint
+      && (target_have_steppable_watchpoint ()
   || gdbarch_have_nonsteppable_watchpoint (gdbarch)))
     {
       /* At this point, we are stopped at an instruction which has
diff --git a/gdb/procfs.c b/gdb/procfs.c
index d3085a20fce..21de548bf41 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -3087,7 +3087,7 @@ procfs_target::insert_watchpoint (CORE_ADDR addr, int len,
   enum target_hw_bp_type type,
   struct expression *cond)
 {
-  if (!target_have_steppable_watchpoint
+  if (!target_have_steppable_watchpoint ()
       && !gdbarch_have_nonsteppable_watchpoint (target_gdbarch ()))
     /* When a hardware watchpoint fires off the PC will be left at
        the instruction following the one which caused the
diff --git a/gdb/target.h b/gdb/target.h
index 14c0aa366b8..bc48e5a4678 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1987,7 +1987,7 @@ extern gdb::byte_vector target_thread_info_to_thread_handle
 
 /* Non-zero if we have steppable watchpoints  */
 
-#define target_have_steppable_watchpoint \
+#define target_have_steppable_watchpoint() \
   (current_top_target ()->have_steppable_watchpoint ())
 
 /* Provide defaults for hardware watchpoint functions.  */
--
2.17.2

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 5/8] Turn target_can_execute_reverse into function-like macro

Simon Marchi-4
In reply to this post by Tom Tromey-2
On 2020-07-20 9:49 p.m., Tom Tromey wrote:
> This changes target_can_execute_reverse from an object-like macro to a
> function-like macro.

Why a macro and not a function here?

Simon
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 7/8] Turn target_can_lock_scheduler into a function-like macro

Simon Marchi-4
In reply to this post by Tom Tromey-2
On 2020-07-20 9:49 p.m., Tom Tromey wrote:
> This changes the object-like macro target_can_lock_scheduler into a
> function-like macro.

Same question here and for patch 8, why a macro and not a function?

Simon
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 7/8] Turn target_can_lock_scheduler into a function-like macro

Tom Tromey-2
>>>>> "Simon" == Simon Marchi <[hidden email]> writes:

Simon> On 2020-07-20 9:49 p.m., Tom Tromey wrote:
>> This changes the object-like macro target_can_lock_scheduler into a
>> function-like macro.

Simon> Same question here and for patch 8, why a macro and not a function?

Just that this way parallels other existing macros.

Tom
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 5/8] Turn target_can_execute_reverse into function-like macro

Sourceware - gdb-patches mailing list
In reply to this post by Tom Tromey-2
On Mon, Jul 20, 2020 at 8:49 PM Tom Tromey <[hidden email]> wrote:
>
> This changes target_can_execute_reverse from an object-like macro to a
> function-like macro.

Since there's only a few callers, and the implementation is simple,
why not remove the macro and call current_top_target
()->can_execute_reverse () directly? That makes this global variable
access more obvious.

Christian
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/8] Remove target_has_stack macro

Sourceware - gdb-patches mailing list
In reply to this post by Tom Tromey-2
On Mon, Jul 20, 2020 at 8:49 PM Tom Tromey <[hidden email]> 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