aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.h
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2014-06-15 21:28:57 -0600
committerTom Tromey <tromey@redhat.com>2014-07-24 07:39:47 -0600
commita7068b601288f8f5df45ca1113069b44dc759b11 (patch)
treee7f627f17e4d98f06b82138a3a57b356da148da9 /gdb/target.h
parent2c51604d3adbcc77a25d78ce900f5be4597c2504 (diff)
downloadgdb-a7068b601288f8f5df45ca1113069b44dc759b11.zip
gdb-a7068b601288f8f5df45ca1113069b44dc759b11.tar.gz
gdb-a7068b601288f8f5df45ca1113069b44dc759b11.tar.bz2
auto-generate most target debug methods
The target debug methods are inconsistently maintained. Most to_* methods have some kind of targetdebug awareness, but not all of them do. The ones that do vary in the quantity and quality of output they generate. This patch changes most of the target debug methods to be automatically generated. All the arguments are printed, and separate lines are printed for entering and existing the outermost call to the target stack. For example now you'd see: -> multi-thread->to_terminal_ours (...) -> multi-thread->to_is_async_p (...) <- multi-thread->to_is_async_p (0x1ebb580) = 1 <- multi-thread->to_terminal_ours (0x1ebb580) -> multi-thread->to_thread_address_space (...) <- multi-thread->to_thread_address_space (0x1ebb580, 26802) = 1 In this case you can see nested calls. The "multi-thread" on the left hand side is the topmost target's shortname. There are some oddities with this patch. I'm on the fence about it all, I really just wrote it on a whim. It's not simple to convert every possible method, since a few don't participate in target delegation. Printing is done by type, so I introduced some new debug-printing-specific typedefs to handle cases where it is nicer to do something else. On the plus side, this lays the groundwork for making targetdebug affect every layer of the target stack. The idea would be to wrap each target_ops in the stack with its own debug_target, and then you could see calls propagate down the stack and back up; I suppose with indentation to make it prettier. (That said there are some gotchas lurking in this idea due to target stack introspection.) Regtested on x86-64 Fedora 20. 2014-07-24 Tom Tromey <tromey@redhat.com> * make-target-delegates (munge_type, write_debugmethod): New functions. (debug_names): New global. ($TARGET_DEBUG_PRINTER): New global. (write_function_header): Strip TARGET_DEBUG_PRINTER from the type name. Write debug methods. Generate init_debug_target. * target-debug.h: New file. * target-delegates.c: Rebuild. * target.c: Include target-debug.h. (debug_target): Hoist definition. (target_kill, target_get_section_table, target_memory_map) (target_flash_erase, target_flash_done, target_detach) (target_disconnect, target_wait, target_resume) (target_pass_signals, target_program_signals, target_follow_fork) (target_mourn_inferior, target_search_memory) (target_thread_address_space, target_close) (target_find_new_threads, target_core_of_thread) (target_verify_memory, target_insert_mask_watchpoint) (target_remove_mask_watchpoint): Remove targetdebug code. (debug_to_post_attach, debug_to_prepare_to_store) (debug_to_files_info, debug_to_insert_breakpoint) (debug_to_remove_breakpoint, debug_to_can_use_hw_breakpoint) (debug_to_region_ok_for_hw_watchpoint) (debug_to_can_accel_watchpoint_condition) (debug_to_stopped_by_watchpoint, debug_to_stopped_data_address) (debug_to_watchpoint_addr_within_range) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint) (debug_to_insert_watchpoint, debug_to_remove_watchpoint) (debug_to_terminal_init, debug_to_terminal_inferior) (debug_to_terminal_ours_for_output, debug_to_terminal_ours) (debug_to_terminal_save_ours, debug_to_terminal_info) (debug_to_load, debug_to_post_startup_inferior) (debug_to_insert_fork_catchpoint) (debug_to_remove_fork_catchpoint) (debug_to_insert_vfork_catchpoint) (debug_to_remove_vfork_catchpoint) (debug_to_insert_exec_catchpoint) (debug_to_remove_exec_catchpoint, debug_to_has_exited) (debug_to_can_run, debug_to_thread_architecture, debug_to_stop) (debug_to_rcmd, debug_to_pid_to_exec_file): Remove. (setup_target_debug): Call init_debug_target. * target.h (TARGET_DEBUG_PRINTER): New macro. (struct target_ops) <to_resume, to_wait, to_pass_signals, to_program_signals>: Use TARGET_DEBUG_PRINTER.
Diffstat (limited to 'gdb/target.h')
-rw-r--r--gdb/target.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/gdb/target.h b/gdb/target.h
index 35a7d7d..e4aade7 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -357,6 +357,16 @@ struct thread_info; /* fwd decl for parameter list below: */
typedef void async_callback_ftype (enum inferior_event_type event_type,
void *context);
+/* Normally target debug printing is purely type-based. However,
+ sometimes it is necessary to override the debug printing on a
+ per-argument basis. This macro can be used, attribute-style, to
+ name the target debug printing function for a particular method
+ argument. FUNC is the name of the function. The macro's
+ definition is empty because it is only used by the
+ make-target-delegates script. */
+
+#define TARGET_DEBUG_PRINTER(FUNC)
+
/* These defines are used to mark target_ops methods. The script
make-target-delegates scans these and auto-generates the base
method implementations. There are four macros that can be used:
@@ -416,10 +426,13 @@ struct target_ops
TARGET_DEFAULT_IGNORE ();
void (*to_disconnect) (struct target_ops *, const char *, int)
TARGET_DEFAULT_NORETURN (tcomplain ());
- void (*to_resume) (struct target_ops *, ptid_t, int, enum gdb_signal)
+ void (*to_resume) (struct target_ops *, ptid_t,
+ int TARGET_DEBUG_PRINTER (target_debug_print_step),
+ enum gdb_signal)
TARGET_DEFAULT_NORETURN (noprocess ());
ptid_t (*to_wait) (struct target_ops *,
- ptid_t, struct target_waitstatus *, int)
+ ptid_t, struct target_waitstatus *,
+ int TARGET_DEBUG_PRINTER (target_debug_print_options))
TARGET_DEFAULT_NORETURN (noprocess ());
void (*to_fetch_registers) (struct target_ops *, struct regcache *, int)
TARGET_DEFAULT_IGNORE ();
@@ -539,12 +552,14 @@ struct target_ops
/* Documentation of this routine is provided with the corresponding
target_* macro. */
- void (*to_pass_signals) (struct target_ops *, int, unsigned char *)
+ void (*to_pass_signals) (struct target_ops *, int,
+ unsigned char * TARGET_DEBUG_PRINTER (target_debug_print_signals))
TARGET_DEFAULT_IGNORE ();
/* Documentation of this routine is provided with the
corresponding target_* function. */
- void (*to_program_signals) (struct target_ops *, int, unsigned char *)
+ void (*to_program_signals) (struct target_ops *, int,
+ unsigned char * TARGET_DEBUG_PRINTER (target_debug_print_signals))
TARGET_DEFAULT_IGNORE ();
int (*to_thread_alive) (struct target_ops *, ptid_t ptid)