[RFC v2 27/38] convert to_get_section_table
Tom Tromey
tromey@redhat.com
Thu Feb 6 20:56:00 GMT 2014
2014-02-06 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.c (target_get_section_table): Unconditionally delegate.
* target.h (struct target_ops) <to_get_section_table>: Use
TARGET_DEFAULT_RETURN.
convert to_flash_erase
2014-02-06 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.c (target_flash_erase): Unconditionally delegate.
* target.h (struct target_ops) <to_flash_erase>: Use
TARGET_DEFAULT_NORETURN.
convert to_flash_done
2014-02-06 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.c (target_flash_done): Unconditionally delegate.
* target.h (struct target_ops) <to_flash_done>: Use
TARGET_DEFAULT_NORETURN.
convert to_core_of_thread
2014-02-06 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.c (target_core_of_thread): Unconditionally delegate.
* target.h (struct target_ops) <to_core_of_thread>: Use
TARGET_DEFAULT_RETURN.
convert to_verify_memory
2014-02-06 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.c (target_verify_memory): Unconditionally delegate.
* target.h (struct target_ops) <to_verify_memory>: Use
TARGET_DEFAULT_NORETURN.
convert to_call_history_range
2014-02-06 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.c (target_call_history_range): Unconditionally delegate.
* target.h (struct target_ops) <to_call_history_range>: Use
TARGET_DEFAULT_NORETURN.
convert to_call_history_from
2014-02-06 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.c (target_call_history_from): Unconditionally delegate.
* target.h (struct target_ops) <to_call_history_from>: Use
TARGET_DEFAULT_NORETURN.
convert to_call_history
2014-02-06 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.c (target_call_history): Unconditionally delegate.
* target.h (struct target_ops) <to_call_history>: Use
TARGET_DEFAULT_NORETURN.
convert to_insn_history_range
2014-02-06 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.c (target_insn_history_range): Unconditionally delegate.
* target.h (struct target_ops) <to_insn_history_range>: Use
TARGET_DEFAULT_NORETURN.
convert to_insn_history_from
2014-02-06 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.c (target_insn_history_from): Unconditionally delegate.
* target.h (struct target_ops) <to_insn_history_from>: Use
TARGET_DEFAULT_NORETURN.
---
gdb/ChangeLog | 70 ++++++++++++++++++++++
gdb/target-delegates.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++
gdb/target.c | 144 +++++++++-----------------------------------
gdb/target.h | 30 ++++++----
4 files changed, 278 insertions(+), 126 deletions(-)
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index b59f199..e6c0cf3 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -630,6 +630,19 @@ tdefault_log_command (struct target_ops *self, const char *arg1)
{
}
+static struct target_section_table *
+delegate_get_section_table (struct target_ops *self)
+{
+ self = self->beneath;
+ return self->to_get_section_table (self);
+}
+
+static struct target_section_table *
+tdefault_get_section_table (struct target_ops *self)
+{
+ return 0;
+}
+
static int
delegate_can_async_p (struct target_ops *self)
{
@@ -710,6 +723,32 @@ tdefault_xfer_partial (struct target_ops *self, enum target_object arg1, const
return -1;
}
+static void
+delegate_flash_erase (struct target_ops *self, ULONGEST arg1, LONGEST arg2)
+{
+ self = self->beneath;
+ self->to_flash_erase (self, arg1, arg2);
+}
+
+static void
+tdefault_flash_erase (struct target_ops *self, ULONGEST arg1, LONGEST arg2)
+{
+ tcomplain ();
+}
+
+static void
+delegate_flash_done (struct target_ops *self)
+{
+ self = self->beneath;
+ self->to_flash_done (self);
+}
+
+static void
+tdefault_flash_done (struct target_ops *self)
+{
+ tcomplain ();
+}
+
static ptid_t
delegate_get_ada_task_ptid (struct target_ops *self, long arg1, long arg2)
{
@@ -1093,6 +1132,32 @@ tdefault_set_trace_notes (struct target_ops *self, const char *arg1, const char
}
static int
+delegate_core_of_thread (struct target_ops *self, ptid_t arg1)
+{
+ self = self->beneath;
+ return self->to_core_of_thread (self, arg1);
+}
+
+static int
+tdefault_core_of_thread (struct target_ops *self, ptid_t arg1)
+{
+ return -1;
+}
+
+static int
+delegate_verify_memory (struct target_ops *self, const gdb_byte *arg1, CORE_ADDR arg2, ULONGEST arg3)
+{
+ self = self->beneath;
+ return self->to_verify_memory (self, arg1, arg2, arg3);
+}
+
+static int
+tdefault_verify_memory (struct target_ops *self, const gdb_byte *arg1, CORE_ADDR arg2, ULONGEST arg3)
+{
+ tcomplain ();
+}
+
+static int
delegate_get_tib_address (struct target_ops *self, ptid_t arg1, CORE_ADDR *arg2)
{
self = self->beneath;
@@ -1195,6 +1260,71 @@ tdefault_supports_btrace (struct target_ops *self)
return 0;
}
+static void
+delegate_insn_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
+{
+ self = self->beneath;
+ self->to_insn_history_from (self, arg1, arg2, arg3);
+}
+
+static void
+tdefault_insn_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
+{
+ tcomplain ();
+}
+
+static void
+delegate_insn_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
+{
+ self = self->beneath;
+ self->to_insn_history_range (self, arg1, arg2, arg3);
+}
+
+static void
+tdefault_insn_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
+{
+ tcomplain ();
+}
+
+static void
+delegate_call_history (struct target_ops *self, int arg1, int arg2)
+{
+ self = self->beneath;
+ self->to_call_history (self, arg1, arg2);
+}
+
+static void
+tdefault_call_history (struct target_ops *self, int arg1, int arg2)
+{
+ tcomplain ();
+}
+
+static void
+delegate_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
+{
+ self = self->beneath;
+ self->to_call_history_from (self, arg1, arg2, arg3);
+}
+
+static void
+tdefault_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
+{
+ tcomplain ();
+}
+
+static void
+delegate_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
+{
+ self = self->beneath;
+ self->to_call_history_range (self, arg1, arg2, arg3);
+}
+
+static void
+tdefault_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
+{
+ tcomplain ();
+}
+
static int
delegate_augmented_libraries_svr4_read (struct target_ops *self)
{
@@ -1319,6 +1449,8 @@ install_delegators (struct target_ops *ops)
ops->to_pid_to_exec_file = delegate_pid_to_exec_file;
if (ops->to_log_command == NULL)
ops->to_log_command = delegate_log_command;
+ if (ops->to_get_section_table == NULL)
+ ops->to_get_section_table = delegate_get_section_table;
if (ops->to_can_async_p == NULL)
ops->to_can_async_p = delegate_can_async_p;
if (ops->to_is_async_p == NULL)
@@ -1335,6 +1467,10 @@ 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_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_can_execute_reverse == NULL)
@@ -1397,6 +1533,10 @@ install_delegators (struct target_ops *ops)
ops->to_set_trace_buffer_size = delegate_set_trace_buffer_size;
if (ops->to_set_trace_notes == NULL)
ops->to_set_trace_notes = delegate_set_trace_notes;
+ if (ops->to_core_of_thread == NULL)
+ ops->to_core_of_thread = delegate_core_of_thread;
+ if (ops->to_verify_memory == NULL)
+ ops->to_verify_memory = delegate_verify_memory;
if (ops->to_get_tib_address == NULL)
ops->to_get_tib_address = delegate_get_tib_address;
if (ops->to_set_permissions == NULL)
@@ -1413,6 +1553,16 @@ 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_insn_history_from == NULL)
+ ops->to_insn_history_from = delegate_insn_history_from;
+ if (ops->to_insn_history_range == NULL)
+ ops->to_insn_history_range = delegate_insn_history_range;
+ if (ops->to_call_history == NULL)
+ ops->to_call_history = delegate_call_history;
+ if (ops->to_call_history_from == NULL)
+ ops->to_call_history_from = delegate_call_history_from;
+ if (ops->to_call_history_range == NULL)
+ ops->to_call_history_range = delegate_call_history_range;
if (ops->to_augmented_libraries_svr4_read == NULL)
ops->to_augmented_libraries_svr4_read = delegate_augmented_libraries_svr4_read;
}
@@ -1474,6 +1624,7 @@ install_dummy_methods (struct target_ops *ops)
ops->to_rcmd = default_rcmd;
ops->to_pid_to_exec_file = tdefault_pid_to_exec_file;
ops->to_log_command = tdefault_log_command;
+ ops->to_get_section_table = tdefault_get_section_table;
ops->to_can_async_p = find_default_can_async_p;
ops->to_is_async_p = find_default_is_async_p;
ops->to_async = tdefault_async;
@@ -1482,6 +1633,8 @@ 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_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_can_execute_reverse = tdefault_can_execute_reverse;
ops->to_execution_direction = default_execution_direction;
@@ -1513,6 +1666,8 @@ install_dummy_methods (struct target_ops *ops)
ops->to_set_circular_trace_buffer = tdefault_set_circular_trace_buffer;
ops->to_set_trace_buffer_size = tdefault_set_trace_buffer_size;
ops->to_set_trace_notes = tdefault_set_trace_notes;
+ ops->to_core_of_thread = tdefault_core_of_thread;
+ ops->to_verify_memory = tdefault_verify_memory;
ops->to_get_tib_address = tdefault_get_tib_address;
ops->to_set_permissions = tdefault_set_permissions;
ops->to_static_tracepoint_marker_at = tdefault_static_tracepoint_marker_at;
@@ -1521,5 +1676,10 @@ 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_insn_history_from = tdefault_insn_history_from;
+ ops->to_insn_history_range = tdefault_insn_history_range;
+ ops->to_call_history = tdefault_call_history;
+ ops->to_call_history_from = tdefault_call_history_from;
+ ops->to_call_history_range = tdefault_call_history_range;
ops->to_augmented_libraries_svr4_read = tdefault_augmented_libraries_svr4_read;
}
diff --git a/gdb/target.c b/gdb/target.c
index 9fbe19f..0ef82b3 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1088,16 +1088,10 @@ done:
struct target_section_table *
target_get_section_table (struct target_ops *target)
{
- struct target_ops *t;
-
if (targetdebug)
fprintf_unfiltered (gdb_stdlog, "target_get_section_table ()\n");
- for (t = target; t != NULL; t = t->beneath)
- if (t->to_get_section_table != NULL)
- return (*t->to_get_section_table) (t);
-
- return NULL;
+ return (*target->to_get_section_table) (target);
}
/* Find a section containing ADDR. */
@@ -1729,36 +1723,18 @@ target_memory_map (void)
void
target_flash_erase (ULONGEST address, LONGEST length)
{
- struct target_ops *t;
-
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- if (t->to_flash_erase != NULL)
- {
- if (targetdebug)
- fprintf_unfiltered (gdb_stdlog, "target_flash_erase (%s, %s)\n",
- hex_string (address), phex (length, 0));
- t->to_flash_erase (t, address, length);
- return;
- }
-
- tcomplain ();
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog, "target_flash_erase (%s, %s)\n",
+ hex_string (address), phex (length, 0));
+ current_target.to_flash_erase (¤t_target, address, length);
}
void
target_flash_done (void)
{
- struct target_ops *t;
-
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- if (t->to_flash_done != NULL)
- {
- if (targetdebug)
- fprintf_unfiltered (gdb_stdlog, "target_flash_done\n");
- t->to_flash_done (t);
- return;
- }
-
- tcomplain ();
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog, "target_flash_done\n");
+ current_target.to_flash_done (¤t_target);
}
static void
@@ -3674,47 +3650,28 @@ target_store_registers (struct regcache *regcache, int regno)
int
target_core_of_thread (ptid_t ptid)
{
- struct target_ops *t;
+ int retval = current_target.to_core_of_thread (¤t_target, ptid);
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- {
- if (t->to_core_of_thread != NULL)
- {
- int retval = t->to_core_of_thread (t, ptid);
-
- if (targetdebug)
- fprintf_unfiltered (gdb_stdlog,
- "target_core_of_thread (%d) = %d\n",
- ptid_get_pid (ptid), retval);
- return retval;
- }
- }
-
- return -1;
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog,
+ "target_core_of_thread (%d) = %d\n",
+ ptid_get_pid (ptid), retval);
+ return retval;
}
int
target_verify_memory (const gdb_byte *data, CORE_ADDR memaddr, ULONGEST size)
{
- struct target_ops *t;
-
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- {
- if (t->to_verify_memory != NULL)
- {
- int retval = t->to_verify_memory (t, data, memaddr, size);
-
- if (targetdebug)
- fprintf_unfiltered (gdb_stdlog,
- "target_verify_memory (%s, %s) = %d\n",
- paddress (target_gdbarch (), memaddr),
- pulongest (size),
- retval);
- return retval;
- }
- }
+ int retval = current_target.to_verify_memory (¤t_target,
+ data, memaddr, size);
- tcomplain ();
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog,
+ "target_verify_memory (%s, %s) = %d\n",
+ paddress (target_gdbarch (), memaddr),
+ pulongest (size),
+ retval);
+ return retval;
}
/* The documentation for this function is in its prototype declaration in
@@ -4011,16 +3968,7 @@ target_insn_history (int size, int flags)
void
target_insn_history_from (ULONGEST from, int size, int flags)
{
- struct target_ops *t;
-
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- if (t->to_insn_history_from != NULL)
- {
- t->to_insn_history_from (t, from, size, flags);
- return;
- }
-
- tcomplain ();
+ current_target.to_insn_history_from (¤t_target, from, size, flags);
}
/* See target.h. */
@@ -4028,16 +3976,7 @@ target_insn_history_from (ULONGEST from, int size, int flags)
void
target_insn_history_range (ULONGEST begin, ULONGEST end, int flags)
{
- struct target_ops *t;
-
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- if (t->to_insn_history_range != NULL)
- {
- t->to_insn_history_range (t, begin, end, flags);
- return;
- }
-
- tcomplain ();
+ current_target.to_insn_history_range (¤t_target, begin, end, flags);
}
/* See target.h. */
@@ -4045,16 +3984,7 @@ target_insn_history_range (ULONGEST begin, ULONGEST end, int flags)
void
target_call_history (int size, int flags)
{
- struct target_ops *t;
-
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- if (t->to_call_history != NULL)
- {
- t->to_call_history (t, size, flags);
- return;
- }
-
- tcomplain ();
+ current_target.to_call_history (¤t_target, size, flags);
}
/* See target.h. */
@@ -4062,16 +3992,7 @@ target_call_history (int size, int flags)
void
target_call_history_from (ULONGEST begin, int size, int flags)
{
- struct target_ops *t;
-
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- if (t->to_call_history_from != NULL)
- {
- t->to_call_history_from (t, begin, size, flags);
- return;
- }
-
- tcomplain ();
+ current_target.to_call_history_from (¤t_target, begin, size, flags);
}
/* See target.h. */
@@ -4079,16 +4000,7 @@ target_call_history_from (ULONGEST begin, int size, int flags)
void
target_call_history_range (ULONGEST begin, ULONGEST end, int flags)
{
- struct target_ops *t;
-
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- if (t->to_call_history_range != NULL)
- {
- t->to_call_history_range (t, begin, end, flags);
- return;
- }
-
- tcomplain ();
+ current_target.to_call_history_range (¤t_target, begin, end, flags);
}
static void
diff --git a/gdb/target.h b/gdb/target.h
index 0e3ce22..45bc361 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -567,7 +567,8 @@ struct target_ops
TARGET_DEFAULT_RETURN (0);
void (*to_log_command) (struct target_ops *, const char *)
TARGET_DEFAULT_IGNORE ();
- struct target_section_table *(*to_get_section_table) (struct target_ops *);
+ struct target_section_table *(*to_get_section_table) (struct target_ops *)
+ TARGET_DEFAULT_RETURN (0);
enum strata to_stratum;
int (*to_has_all_memory) (struct target_ops *);
int (*to_has_memory) (struct target_ops *);
@@ -662,13 +663,15 @@ struct target_ops
Precondition: both ADDRESS and ADDRESS+LENGTH should be aligned
on flash block boundaries, as reported by 'to_memory_map'. */
void (*to_flash_erase) (struct target_ops *,
- ULONGEST address, LONGEST length);
+ ULONGEST address, LONGEST length)
+ TARGET_DEFAULT_NORETURN (tcomplain ());
/* Finishes a flash memory write sequence. After this operation
all flash memory should be available for writing and the result
of reading from areas written by 'to_flash_write' should be
equal to what was written. */
- void (*to_flash_done) (struct target_ops *);
+ void (*to_flash_done) (struct target_ops *)
+ TARGET_DEFAULT_NORETURN (tcomplain ());
/* Describe the architecture-specific features of this target.
Returns the description found, or NULL if no description
@@ -917,14 +920,16 @@ struct target_ops
If the core cannot be determined -- either for the specified
thread, or right now, or in this debug session, or for this
target -- return -1. */
- int (*to_core_of_thread) (struct target_ops *, ptid_t ptid);
+ int (*to_core_of_thread) (struct target_ops *, ptid_t ptid)
+ TARGET_DEFAULT_RETURN (-1);
/* Verify that the memory in the [MEMADDR, MEMADDR+SIZE) range
matches the contents of [DATA,DATA+SIZE). Returns 1 if there's
a match, 0 if there's a mismatch, and -1 if an error is
encountered while reading memory. */
int (*to_verify_memory) (struct target_ops *, const gdb_byte *data,
- CORE_ADDR memaddr, ULONGEST size);
+ CORE_ADDR memaddr, ULONGEST size)
+ TARGET_DEFAULT_NORETURN (tcomplain ());
/* Return the address of the start of the Thread Information Block
a Windows OS specific feature. */
@@ -1036,29 +1041,34 @@ struct target_ops
If SIZE < 0, disassemble abs (SIZE) instructions before FROM; otherwise,
disassemble SIZE instructions after FROM. */
void (*to_insn_history_from) (struct target_ops *,
- ULONGEST from, int size, int flags);
+ ULONGEST from, int size, int flags)
+ TARGET_DEFAULT_NORETURN (tcomplain ());
/* Disassemble a section of the recorded execution trace from instruction
BEGIN (inclusive) to instruction END (inclusive). */
void (*to_insn_history_range) (struct target_ops *,
- ULONGEST begin, ULONGEST end, int flags);
+ ULONGEST begin, ULONGEST end, int flags)
+ TARGET_DEFAULT_NORETURN (tcomplain ());
/* Print a function trace of the recorded execution trace.
If SIZE < 0, print abs (SIZE) preceding functions; otherwise, print SIZE
succeeding functions. */
- void (*to_call_history) (struct target_ops *, int size, int flags);
+ void (*to_call_history) (struct target_ops *, int size, int flags)
+ TARGET_DEFAULT_NORETURN (tcomplain ());
/* Print a function trace of the recorded execution trace starting
at function FROM.
If SIZE < 0, print abs (SIZE) functions before FROM; otherwise, print
SIZE functions after FROM. */
void (*to_call_history_from) (struct target_ops *,
- ULONGEST begin, int size, int flags);
+ ULONGEST begin, int size, int flags)
+ TARGET_DEFAULT_NORETURN (tcomplain ());
/* Print a function trace of an execution trace section from function BEGIN
(inclusive) to function END (inclusive). */
void (*to_call_history_range) (struct target_ops *,
- ULONGEST begin, ULONGEST end, int flags);
+ ULONGEST begin, ULONGEST end, int flags)
+ TARGET_DEFAULT_NORETURN (tcomplain ());
/* Nonzero if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a
non-empty annex. */
--
1.8.1.4
More information about the Gdb-patches
mailing list