Convert default_child_has_foo functions to process_stratum_target methods
authorPedro Alves <palves@redhat.com>
Fri, 30 Nov 2018 14:53:40 +0000 (14:53 +0000)
committerPedro Alves <palves@redhat.com>
Fri, 30 Nov 2018 16:28:11 +0000 (16:28 +0000)
This patch converts the default_child_has_foo functions to
process_stratum_target methods.  This simplifies "regular"
non-inf_child process_stratum targets, since they no longer have to
override the target_ops::has_foo methods to call the default_child_foo
functions.  A couple targets need to override the new defaults
(corelow and tracefiles), but it still seems like a good tradeoff,
since those are expected to be little different (target doesn't run).

gdb/ChangeLog:
2018-11-30  Pedro Alves  <palves@redhat.com>

* corelow.c (core_target) <has_all_memory, has_execution>: New
overrides.
* inf-child.c (inf_child_target::has_all_memory)
(inf_child_target::has_memory, inf_child_target::has_stack)
(inf_child_target::has_registers)
(inf_child_target::has_execution): Delete.
* inf-child.h (inf_child_target) <has_all_memory, has_memory,
has_stack, has_registers, has_execution>: Delete.
* process-stratum-target.c
(process_stratum_target::has_all_memory)
(process_stratum_target::has_memory)
(process_stratum_target::has_stack)
(process_stratum_target::has_registers)
(process_stratum_target::has_execution): New.
* process-stratum-target.h (process_stratum_target)
<has_all_memory, has_memory, has_stack, has_registers,
has_execution>: New method overrides.
* ravenscar-thread.c (ravenscar_thread_target) <has_all_memory,
has_memory, has_stack, has_registers, has_execution>: Delete.
* remote-sim.c (gdbsim_target) <has_stack, has_registers,
has_execution>: Delete.
* remote.c (remote_target) <has_all_memory, has_memory, has_stack,
has_registers, has_execution>: Delete.
* target.c (default_child_has_all_memory)
(default_child_has_memory, default_child_has_stack)
(default_child_has_registers, default_child_has_execution):
Delete.
* target.h (default_child_has_all_memory)
(default_child_has_memory, default_child_has_stack)
(default_child_has_registers, default_child_has_execution):
Delete.
* tracefile.h (tracefile_target) <has_execution>: New override.

12 files changed:
gdb/ChangeLog
gdb/corelow.c
gdb/inf-child.c
gdb/inf-child.h
gdb/process-stratum-target.c
gdb/process-stratum-target.h
gdb/ravenscar-thread.c
gdb/remote-sim.c
gdb/remote.c
gdb/target.c
gdb/target.h
gdb/tracefile.h

index faed74bb838495df2e706f3b0d7bbe6bd5c2e3de..8fdf04a9d2c87ed80107cf8709ae47599fb0a188 100644 (file)
@@ -1,3 +1,38 @@
+2018-11-30  Pedro Alves  <palves@redhat.com>
+
+       * corelow.c (core_target) <has_all_memory, has_execution>: New
+       overrides.
+       * inf-child.c (inf_child_target::has_all_memory)
+       (inf_child_target::has_memory, inf_child_target::has_stack)
+       (inf_child_target::has_registers)
+       (inf_child_target::has_execution): Delete.
+       * inf-child.h (inf_child_target) <has_all_memory, has_memory,
+       has_stack, has_registers, has_execution>: Delete.
+       * process-stratum-target.c
+       (process_stratum_target::has_all_memory)
+       (process_stratum_target::has_memory)
+       (process_stratum_target::has_stack)
+       (process_stratum_target::has_registers)
+       (process_stratum_target::has_execution): New.
+       * process-stratum-target.h (process_stratum_target)
+       <has_all_memory, has_memory, has_stack, has_registers,
+       has_execution>: New method overrides.
+       * ravenscar-thread.c (ravenscar_thread_target) <has_all_memory,
+       has_memory, has_stack, has_registers, has_execution>: Delete.
+       * remote-sim.c (gdbsim_target) <has_stack, has_registers,
+       has_execution>: Delete.
+       * remote.c (remote_target) <has_all_memory, has_memory, has_stack,
+       has_registers, has_execution>: Delete.
+       * target.c (default_child_has_all_memory)
+       (default_child_has_memory, default_child_has_stack)
+       (default_child_has_registers, default_child_has_execution):
+       Delete.
+       * target.h (default_child_has_all_memory)
+       (default_child_has_memory, default_child_has_stack)
+       (default_child_has_registers, default_child_has_execution):
+       Delete.
+       * tracefile.h (tracefile_target) <has_execution>: New override.
+
 2018-11-30  Pedro Alves  <palves@redhat.com>
 
        * Makefile.in (COMMON_SFILES): Add process-stratum-target.c.
index deabf84def9cd26c65fc04f62a4aec4b54346861..7cc177c9d619e01fcaa66fa606191a207825019c 100644 (file)
@@ -90,9 +90,12 @@ public:
 
   const char *thread_name (struct thread_info *) override;
 
+  bool has_all_memory () override { return false; }
   bool has_memory () override;
   bool has_stack () override;
   bool has_registers () override;
+  bool has_execution (ptid_t) override { return false; }
+
   bool info_proc (const char *, enum info_proc_what) override;
 
   /* A few helpers.  */
index 8cdfa051469645292210e0dc1145e284dfff791a..fc704455b319232a5ed4f468983845f4456bab07 100644 (file)
@@ -243,36 +243,6 @@ inf_child_target::pid_to_exec_file (int pid)
   return NULL;
 }
 
-bool
-inf_child_target::has_all_memory ()
-{
-  return default_child_has_all_memory ();
-}
-
-bool
-inf_child_target::has_memory ()
-{
-  return default_child_has_memory ();
-}
-
-bool
-inf_child_target::has_stack ()
-{
-  return default_child_has_stack ();
-}
-
-bool
-inf_child_target::has_registers ()
-{
-  return default_child_has_registers ();
-}
-
-bool
-inf_child_target::has_execution (ptid_t ptid)
-{
-  return default_child_has_execution (ptid);
-}
-
 /* Implementation of to_fileio_open.  */
 
 int
index d301d398eb6828f9b47cf919eb6d62597a81d040..a0bb40b958455523e8748fb7f629b0a4cb475c3c 100644 (file)
@@ -72,12 +72,6 @@ public:
 
   char *pid_to_exec_file (int pid) override;
 
-  bool has_all_memory () override;
-  bool has_memory () override;
-  bool has_stack () override;
-  bool has_registers () override;
-  bool has_execution (ptid_t) override;
-
   int fileio_open (struct inferior *inf, const char *filename,
                   int flags, int mode, int warn_if_slow,
                   int *target_errno) override;
index 9ce8d3dd47adb543c790999eac8b73360c8a76d4..ca9d13a7b322b200700b4a6b27f3637125e74a39 100644 (file)
@@ -47,3 +47,39 @@ process_stratum_target::thread_architecture (ptid_t ptid)
   gdb_assert (inf != NULL);
   return inf->gdbarch;
 }
+
+bool
+process_stratum_target::has_all_memory ()
+{
+  /* If no inferior selected, then we can't read memory here.  */
+  return inferior_ptid != null_ptid;
+}
+
+bool
+process_stratum_target::has_memory ()
+{
+  /* If no inferior selected, then we can't read memory here.  */
+  return inferior_ptid != null_ptid;
+}
+
+bool
+process_stratum_target::has_stack ()
+{
+  /* If no inferior selected, there's no stack.  */
+  return inferior_ptid != null_ptid;
+}
+
+bool
+process_stratum_target::has_registers ()
+{
+  /* Can't read registers from no inferior.  */
+  return inferior_ptid != null_ptid;
+}
+
+bool
+process_stratum_target::has_execution (ptid_t the_ptid)
+{
+  /* If there's no thread selected, then we can't make it run through
+     hoops.  */
+  return the_ptid != null_ptid;
+}
index 0a799f7a28ef8b049d2e8a1869ab9a8abf136cf1..74640aa1ed5f90a7bfcb1251a9898a5eeb2d3de0 100644 (file)
@@ -46,6 +46,14 @@ public:
 
   /* This default implementation always returns target_gdbarch ().  */
   struct gdbarch *thread_architecture (ptid_t ptid) override;
+
+  /* Default implementations for process_stratum targets.  Return true
+     if there's a selected inferior, false otherwise.  */
+  bool has_all_memory () override;
+  bool has_memory () override;
+  bool has_stack () override;
+  bool has_registers () override;
+  bool has_execution (ptid_t the_ptid) override;
 };
 
 #endif /* !defined (PROCESS_STRATUM_TARGET_H) */
index e60fad874669c6bfa5595e130210912f3fade8b0..0f2889cf0e2615dea1ccc978a74594afc0cdaf3c 100644 (file)
@@ -116,13 +116,6 @@ struct ravenscar_thread_target final : public target_ops
   ptid_t get_ada_task_ptid (long lwp, long thread) override;
 
   void mourn_inferior () override;
-
-  bool has_all_memory ()  override { return default_child_has_all_memory (); }
-  bool has_memory ()  override { return default_child_has_memory (); }
-  bool has_stack ()  override { return default_child_has_stack (); }
-  bool has_registers ()  override { return default_child_has_registers (); }
-  bool has_execution (ptid_t ptid) override
-  { return default_child_has_execution (ptid); }
 };
 
 /* This module's target-specific operations.  */
index 1ceecaae2cee420fbdb14d24dbb2f45a55aa6d5d..b3fb95a77f067106108b9e4e48eb1bfefc005bf3 100644 (file)
@@ -128,15 +128,6 @@ struct gdbsim_target final
 
   bool has_all_memory ()  override;
   bool has_memory ()  override;
-
-  bool has_stack ()  override
-  { return default_child_has_stack (); }
-
-  bool has_registers ()  override
-  { return default_child_has_registers (); }
-
-  bool has_execution (ptid_t ptid) override
-  { return default_child_has_execution (ptid); }
 };
 
 static struct gdbsim_target gdbsim_ops;
index ae35bec451bb98229360195ecf4caedc0fa3a42f..4324452abab35fbf30b755b5d71cc20c86d9a512 100644 (file)
@@ -525,12 +525,6 @@ public:
                                      CORE_ADDR load_module_addr,
                                      CORE_ADDR offset) override;
 
-  bool has_all_memory ()  override { return default_child_has_all_memory (); }
-  bool has_memory ()  override { return default_child_has_memory (); }
-  bool has_stack ()  override { return default_child_has_stack (); }
-  bool has_registers ()  override { return default_child_has_registers (); }
-  bool has_execution (ptid_t ptid)  override { return default_child_has_execution (ptid); }
-
   bool can_execute_reverse () override;
 
   std::vector<mem_region> memory_map () override;
index 8905ce3630c72dcc0e71fdcba6bcf505516dca82..ecfdde93a1ba5d1d194cf825578d7951cb9f8ad9 100644 (file)
@@ -186,60 +186,6 @@ target_command (const char *arg, int from_tty)
                  gdb_stdout);
 }
 
-/* Default target_has_* methods for process_stratum targets.  */
-
-int
-default_child_has_all_memory ()
-{
-  /* If no inferior selected, then we can't read memory here.  */
-  if (inferior_ptid == null_ptid)
-    return 0;
-
-  return 1;
-}
-
-int
-default_child_has_memory ()
-{
-  /* If no inferior selected, then we can't read memory here.  */
-  if (inferior_ptid == null_ptid)
-    return 0;
-
-  return 1;
-}
-
-int
-default_child_has_stack ()
-{
-  /* If no inferior selected, there's no stack.  */
-  if (inferior_ptid == null_ptid)
-    return 0;
-
-  return 1;
-}
-
-int
-default_child_has_registers ()
-{
-  /* Can't read registers from no inferior.  */
-  if (inferior_ptid == null_ptid)
-    return 0;
-
-  return 1;
-}
-
-int
-default_child_has_execution (ptid_t the_ptid)
-{
-  /* If there's no thread selected, then we can't make it run through
-     hoops.  */
-  if (the_ptid == null_ptid)
-    return 0;
-
-  return 1;
-}
-
-
 int
 target_has_all_memory_1 (void)
 {
index 36f8d5e5a2d8047053848f7121b7631af43fd773..b0469bba1482793c29e9211c811aada3cd98836b 100644 (file)
@@ -1790,15 +1790,6 @@ extern int target_has_execution_current (void);
 
 #define target_has_execution target_has_execution_current ()
 
-/* Default implementations for process_stratum targets.  Return true
-   if there's a selected inferior, false otherwise.  */
-
-extern int default_child_has_all_memory ();
-extern int default_child_has_memory ();
-extern int default_child_has_stack ();
-extern int default_child_has_registers ();
-extern int default_child_has_execution (ptid_t the_ptid);
-
 /* Can the target support the debugger control of thread execution?
    Can it lock the thread scheduler?  */
 
index 3ae3e7d0e53adfc98b6b54dd529b327bf1a6c37f..8f9dc0e06d7de9210d51747908ecd8ce46b7a525 100644 (file)
@@ -127,6 +127,7 @@ public:
   bool has_memory () override;
   bool has_stack () override;
   bool has_registers () override;
+  bool has_execution (ptid_t) override { return false; }
   bool thread_alive (ptid_t ptid) override;
 };
 
This page took 0.045036 seconds and 4 git commands to generate.