This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC v2 28/38] convert to_insn_history


2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
	* target.c (target_insn_history): Unconditionally delegate.
	* target.h (struct target_ops) <to_insn_history>: Use
	TARGET_DEFAULT_NORETURN.

convert to_goto_record

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
	* target.c (target_goto_record): Unconditionally delegate.
	* target.h (struct target_ops) <to_goto_record>: Use
	TARGET_DEFAULT_NORETURN.

convert to_goto_record_end

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
	* target.c (target_goto_record_end): Unconditionally delegate.
	* target.h (struct target_ops) <to_goto_record_end>: Use
	TARGET_DEFAULT_NORETURN.

convert to_goto_record_begin

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
	* target.c (target_goto_record_begin): Unconditionally delegate.
	* target.h (struct target_ops) <to_goto_record_begin>: Use
	TARGET_DEFAULT_NORETURN.

convert to_record_is_replaying

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
	* target.c (target_record_is_replaying): Unconditionally
	delegate.
	* target.h (struct target_ops) <to_record_is_replaying>: Use
	TARGET_DEFAULT_RETURN.

convert to_delete_record

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
	* target.c (target_delete_record): Unconditionally delegate.
	* target.h (struct target_ops) <to_delete_record>: Use
	TARGET_DEFAULT_NORETURN.

convert to_save_record

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
	* target.c (target_save_record): Unconditionally delegate.
	* target.h (struct target_ops) <to_save_record>: Use
	TARGET_DEFAULT_NORETURN.

convert to_thread_alive

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
	* target.c (target_thread_alive): Unconditionally delegate.
	* target.h (struct target_ops) <to_thread_alive>: Use
	TARGET_DEFAULT_RETURN.

convert to_memory_map

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
	* target.c (target_memory_map): Unconditionally delegate.
	* target.h (struct target_ops) <to_memory_map>: Use
	TARGET_DEFAULT_RETURN.

convert to_auxv_parse

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* auxv.c (default_auxv_parse): No longer static.
	(target_auxv_parse): Unconditionally delegate.
	* auxv.h (default_auxv_parse): Declare.
	* target-delegates.c: Rebuild.
	* target.c: Include auxv.h.
	* target.h (struct target_ops) <to_auxv_parse>: Use
	TARGET_DEFAULT_FUNC.
---
 gdb/ChangeLog          |  74 ++++++++++++++++++++++++
 gdb/auxv.c             |  11 +---
 gdb/auxv.h             |   7 +++
 gdb/target-delegates.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           | 106 +++++-----------------------------
 gdb/target.h           |  30 ++++++----
 6 files changed, 273 insertions(+), 109 deletions(-)

diff --git a/gdb/auxv.c b/gdb/auxv.c
index dd13237..7d4d606 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -237,7 +237,7 @@ memory_xfer_auxv (struct target_ops *ops,
    Return 0 if *READPTR is already at the end of the buffer.
    Return -1 if there is insufficient buffer for a whole entry.
    Return 1 if an entry was read into *TYPEP and *VALP.  */
-static int
+int
 default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
 		   gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
@@ -269,13 +269,8 @@ int
 target_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
                   gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
-  struct target_ops *t;
-
-  for (t = ops; t != NULL; t = t->beneath)
-    if (t->to_auxv_parse != NULL)
-      return t->to_auxv_parse (t, readptr, endptr, typep, valp);
-  
-  return default_auxv_parse (ops, readptr, endptr, typep, valp);
+  return current_target.to_auxv_parse (&current_target, readptr, endptr,
+				       typep, valp);
 }
 
 
diff --git a/gdb/auxv.h b/gdb/auxv.h
index c3f2322..ace6c04 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -24,6 +24,13 @@
 
 /* See "include/elf/common.h" for the definition of valid AT_* values.  */
 
+/* The default implementation of to_auxv_parse, used by the target
+   stack.  */
+
+extern int default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
+			       gdb_byte *endptr, CORE_ADDR *typep,
+			       CORE_ADDR *valp);
+
 /* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
    Return 0 if *READPTR is already at the end of the buffer.
    Return -1 if there is insufficient buffer for a whole entry.
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index e6c0cf3..50f04c8 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -541,6 +541,19 @@ tdefault_program_signals (struct target_ops *self, int arg1, unsigned char *arg2
 {
 }
 
+static int
+delegate_thread_alive (struct target_ops *self, ptid_t arg1)
+{
+  self = self->beneath;
+  return self->to_thread_alive (self, arg1);
+}
+
+static int
+tdefault_thread_alive (struct target_ops *self, ptid_t arg1)
+{
+  return 0;
+}
+
 static void
 delegate_find_new_threads (struct target_ops *self)
 {
@@ -723,6 +736,19 @@ tdefault_xfer_partial (struct target_ops *self, enum target_object  arg1, const
   return -1;
 }
 
+static VEC(mem_region_s) *
+delegate_memory_map (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_memory_map (self);
+}
+
+static VEC(mem_region_s) *
+tdefault_memory_map (struct target_ops *self)
+{
+  return 0;
+}
+
 static void
 delegate_flash_erase (struct target_ops *self, ULONGEST arg1, LONGEST arg2)
 {
@@ -757,6 +783,13 @@ delegate_get_ada_task_ptid (struct target_ops *self, long arg1, long arg2)
 }
 
 static int
+delegate_auxv_parse (struct target_ops *self, gdb_byte **arg1, gdb_byte *arg2, CORE_ADDR *arg3, CORE_ADDR *arg4)
+{
+  self = self->beneath;
+  return self->to_auxv_parse (self, arg1, arg2, arg3, arg4);
+}
+
+static int
 delegate_can_execute_reverse (struct target_ops *self)
 {
   self = self->beneath;
@@ -1261,6 +1294,97 @@ tdefault_supports_btrace (struct target_ops *self)
 }
 
 static void
+delegate_save_record (struct target_ops *self, const char *arg1)
+{
+  self = self->beneath;
+  self->to_save_record (self, arg1);
+}
+
+static void
+tdefault_save_record (struct target_ops *self, const char *arg1)
+{
+  tcomplain ();
+}
+
+static void
+delegate_delete_record (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_delete_record (self);
+}
+
+static void
+tdefault_delete_record (struct target_ops *self)
+{
+  tcomplain ();
+}
+
+static int
+delegate_record_is_replaying (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_record_is_replaying (self);
+}
+
+static int
+tdefault_record_is_replaying (struct target_ops *self)
+{
+  return 0;
+}
+
+static void
+delegate_goto_record_begin (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_goto_record_begin (self);
+}
+
+static void
+tdefault_goto_record_begin (struct target_ops *self)
+{
+  tcomplain ();
+}
+
+static void
+delegate_goto_record_end (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_goto_record_end (self);
+}
+
+static void
+tdefault_goto_record_end (struct target_ops *self)
+{
+  tcomplain ();
+}
+
+static void
+delegate_goto_record (struct target_ops *self, ULONGEST arg1)
+{
+  self = self->beneath;
+  self->to_goto_record (self, arg1);
+}
+
+static void
+tdefault_goto_record (struct target_ops *self, ULONGEST arg1)
+{
+  tcomplain ();
+}
+
+static void
+delegate_insn_history (struct target_ops *self, int arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_insn_history (self, arg1, arg2);
+}
+
+static void
+tdefault_insn_history (struct target_ops *self, int arg1, int arg2)
+{
+  tcomplain ();
+}
+
+static void
 delegate_insn_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
 {
   self = self->beneath;
@@ -1433,6 +1557,8 @@ install_delegators (struct target_ops *ops)
     ops->to_pass_signals = delegate_pass_signals;
   if (ops->to_program_signals == NULL)
     ops->to_program_signals = delegate_program_signals;
+  if (ops->to_thread_alive == NULL)
+    ops->to_thread_alive = delegate_thread_alive;
   if (ops->to_find_new_threads == NULL)
     ops->to_find_new_threads = delegate_find_new_threads;
   if (ops->to_pid_to_str == NULL)
@@ -1467,12 +1593,16 @@ install_delegators (struct target_ops *ops)
     ops->to_goto_bookmark = delegate_goto_bookmark;
   if (ops->to_xfer_partial == NULL)
     ops->to_xfer_partial = delegate_xfer_partial;
+  if (ops->to_memory_map == NULL)
+    ops->to_memory_map = delegate_memory_map;
   if (ops->to_flash_erase == NULL)
     ops->to_flash_erase = delegate_flash_erase;
   if (ops->to_flash_done == NULL)
     ops->to_flash_done = delegate_flash_done;
   if (ops->to_get_ada_task_ptid == NULL)
     ops->to_get_ada_task_ptid = delegate_get_ada_task_ptid;
+  if (ops->to_auxv_parse == NULL)
+    ops->to_auxv_parse = delegate_auxv_parse;
   if (ops->to_can_execute_reverse == NULL)
     ops->to_can_execute_reverse = delegate_can_execute_reverse;
   if (ops->to_execution_direction == NULL)
@@ -1553,6 +1683,20 @@ install_delegators (struct target_ops *ops)
     ops->to_can_use_agent = delegate_can_use_agent;
   if (ops->to_supports_btrace == NULL)
     ops->to_supports_btrace = delegate_supports_btrace;
+  if (ops->to_save_record == NULL)
+    ops->to_save_record = delegate_save_record;
+  if (ops->to_delete_record == NULL)
+    ops->to_delete_record = delegate_delete_record;
+  if (ops->to_record_is_replaying == NULL)
+    ops->to_record_is_replaying = delegate_record_is_replaying;
+  if (ops->to_goto_record_begin == NULL)
+    ops->to_goto_record_begin = delegate_goto_record_begin;
+  if (ops->to_goto_record_end == NULL)
+    ops->to_goto_record_end = delegate_goto_record_end;
+  if (ops->to_goto_record == NULL)
+    ops->to_goto_record = delegate_goto_record;
+  if (ops->to_insn_history == NULL)
+    ops->to_insn_history = delegate_insn_history;
   if (ops->to_insn_history_from == NULL)
     ops->to_insn_history_from = delegate_insn_history_from;
   if (ops->to_insn_history_range == NULL)
@@ -1616,6 +1760,7 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_mourn_inferior = default_mourn_inferior;
   ops->to_pass_signals = tdefault_pass_signals;
   ops->to_program_signals = tdefault_program_signals;
+  ops->to_thread_alive = tdefault_thread_alive;
   ops->to_find_new_threads = tdefault_find_new_threads;
   ops->to_pid_to_str = default_pid_to_str;
   ops->to_extra_thread_info = tdefault_extra_thread_info;
@@ -1633,9 +1778,11 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_get_bookmark = tdefault_get_bookmark;
   ops->to_goto_bookmark = tdefault_goto_bookmark;
   ops->to_xfer_partial = tdefault_xfer_partial;
+  ops->to_memory_map = tdefault_memory_map;
   ops->to_flash_erase = tdefault_flash_erase;
   ops->to_flash_done = tdefault_flash_done;
   ops->to_get_ada_task_ptid = default_get_ada_task_ptid;
+  ops->to_auxv_parse = default_auxv_parse;
   ops->to_can_execute_reverse = tdefault_can_execute_reverse;
   ops->to_execution_direction = default_execution_direction;
   ops->to_supports_multi_process = tdefault_supports_multi_process;
@@ -1676,6 +1823,13 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_use_agent = tdefault_use_agent;
   ops->to_can_use_agent = tdefault_can_use_agent;
   ops->to_supports_btrace = tdefault_supports_btrace;
+  ops->to_save_record = tdefault_save_record;
+  ops->to_delete_record = tdefault_delete_record;
+  ops->to_record_is_replaying = tdefault_record_is_replaying;
+  ops->to_goto_record_begin = tdefault_goto_record_begin;
+  ops->to_goto_record_end = tdefault_goto_record_end;
+  ops->to_goto_record = tdefault_goto_record;
+  ops->to_insn_history = tdefault_insn_history;
   ops->to_insn_history_from = tdefault_insn_history_from;
   ops->to_insn_history_range = tdefault_insn_history_range;
   ops->to_call_history = tdefault_call_history;
diff --git a/gdb/target.c b/gdb/target.c
index 0ef82b3..c51e3ec 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -44,6 +44,7 @@
 #include "tracepoint.h"
 #include "gdb/fileio.h"
 #include "agent.h"
+#include "auxv.h"
 
 static void target_info (char *, int);
 
@@ -1685,14 +1686,7 @@ target_memory_map (void)
   if (targetdebug)
     fprintf_unfiltered (gdb_stdlog, "target_memory_map ()\n");
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_memory_map != NULL)
-      break;
-
-  if (t == NULL)
-    return NULL;
-
-  result = t->to_memory_map (t);
+  result = current_target.to_memory_map (&current_target);
   if (result == NULL)
     return NULL;
 
@@ -3491,24 +3485,14 @@ target_attach (char *args, int from_tty)
 int
 target_thread_alive (ptid_t ptid)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_thread_alive != NULL)
-	{
-	  int retval;
-
-	  retval = t->to_thread_alive (t, ptid);
-	  if (targetdebug)
-	    fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
-				ptid_get_pid (ptid), retval);
+  int retval;
 
-	  return retval;
-	}
-    }
+  retval = current_target.to_thread_alive (&current_target, ptid);
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
+			ptid_get_pid (ptid), retval);
 
-  return 0;
+  return retval;
 }
 
 void
@@ -3838,16 +3822,7 @@ target_info_record (void)
 void
 target_save_record (const char *filename)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_save_record != NULL)
-      {
-	t->to_save_record (t, filename);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_save_record (&current_target, filename);
 }
 
 /* See target.h.  */
@@ -3869,16 +3844,7 @@ target_supports_delete_record (void)
 void
 target_delete_record (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_delete_record != NULL)
-      {
-	t->to_delete_record (t);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_delete_record (&current_target);
 }
 
 /* See target.h.  */
@@ -3886,13 +3852,7 @@ target_delete_record (void)
 int
 target_record_is_replaying (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_record_is_replaying != NULL)
-	return t->to_record_is_replaying (t);
-
-  return 0;
+  return current_target.to_record_is_replaying (&current_target);
 }
 
 /* See target.h.  */
@@ -3900,16 +3860,7 @@ target_record_is_replaying (void)
 void
 target_goto_record_begin (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_goto_record_begin != NULL)
-      {
-	t->to_goto_record_begin (t);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_goto_record_begin (&current_target);
 }
 
 /* See target.h.  */
@@ -3917,16 +3868,7 @@ target_goto_record_begin (void)
 void
 target_goto_record_end (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_goto_record_end != NULL)
-      {
-	t->to_goto_record_end (t);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_goto_record_end (&current_target);
 }
 
 /* See target.h.  */
@@ -3934,16 +3876,7 @@ target_goto_record_end (void)
 void
 target_goto_record (ULONGEST insn)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_goto_record != NULL)
-      {
-	t->to_goto_record (t, insn);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_goto_record (&current_target, insn);
 }
 
 /* See target.h.  */
@@ -3951,16 +3884,7 @@ target_goto_record (ULONGEST insn)
 void
 target_insn_history (int size, int flags)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_insn_history != NULL)
-      {
-	t->to_insn_history (t, size, flags);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_insn_history (&current_target, size, flags);
 }
 
 /* See target.h.  */
diff --git a/gdb/target.h b/gdb/target.h
index 45bc361..91d620f 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -549,7 +549,8 @@ struct target_ops
     void (*to_program_signals) (struct target_ops *, int, unsigned char *)
       TARGET_DEFAULT_IGNORE ();
 
-    int (*to_thread_alive) (struct target_ops *, ptid_t ptid);
+    int (*to_thread_alive) (struct target_ops *, ptid_t ptid)
+      TARGET_DEFAULT_RETURN (0);
     void (*to_find_new_threads) (struct target_ops *)
       TARGET_DEFAULT_IGNORE ();
     char *(*to_pid_to_str) (struct target_ops *, ptid_t)
@@ -655,7 +656,8 @@ struct target_ops
        This method should not cache data; if the memory map could
        change unexpectedly, it should be invalidated, and higher
        layers will re-fetch it.  */
-    VEC(mem_region_s) *(*to_memory_map) (struct target_ops *);
+    VEC(mem_region_s) *(*to_memory_map) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Erases the region of flash memory starting at ADDRESS, of
        length LENGTH.
@@ -691,7 +693,8 @@ struct target_ops
        Return -1 if there is insufficient buffer for a whole entry.
        Return 1 if an entry was read into *TYPEP and *VALP.  */
     int (*to_auxv_parse) (struct target_ops *ops, gdb_byte **readptr,
-                         gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp);
+                         gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
+      TARGET_DEFAULT_FUNC (default_auxv_parse);
 
     /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the
        sequence of bytes in PATTERN with length PATTERN_LEN.
@@ -1013,28 +1016,35 @@ struct target_ops
     void (*to_info_record) (struct target_ops *);
 
     /* Save the recorded execution trace into a file.  */
-    void (*to_save_record) (struct target_ops *, const char *filename);
+    void (*to_save_record) (struct target_ops *, const char *filename)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Delete the recorded execution trace from the current position onwards.  */
-    void (*to_delete_record) (struct target_ops *);
+    void (*to_delete_record) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Query if the record target is currently replaying.  */
-    int (*to_record_is_replaying) (struct target_ops *);
+    int (*to_record_is_replaying) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Go to the begin of the execution trace.  */
-    void (*to_goto_record_begin) (struct target_ops *);
+    void (*to_goto_record_begin) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Go to the end of the execution trace.  */
-    void (*to_goto_record_end) (struct target_ops *);
+    void (*to_goto_record_end) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Go to a specific location in the recorded execution trace.  */
-    void (*to_goto_record) (struct target_ops *, ULONGEST insn);
+    void (*to_goto_record) (struct target_ops *, ULONGEST insn)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Disassemble SIZE instructions in the recorded execution trace from
        the current position.
        If SIZE < 0, disassemble abs (SIZE) preceding instructions; otherwise,
        disassemble SIZE succeeding instructions.  */
-    void (*to_insn_history) (struct target_ops *, int size, int flags);
+    void (*to_insn_history) (struct target_ops *, int size, int flags)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Disassemble SIZE instructions in the recorded execution trace around
        FROM.
-- 
1.8.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]