2013-12-20 00:38:11 +08:00
|
|
|
/* THIS FILE IS GENERATED -*- buffer-read-only: t -*- */
|
|
|
|
/* vi:set ro: */
|
|
|
|
|
|
|
|
/* To regenerate this file, run:*/
|
|
|
|
/* make-target-delegates target.h > target-delegates.c */
|
2013-12-19 00:42:24 +08:00
|
|
|
static void
|
|
|
|
delegate_post_attach (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_post_attach (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_post_attach (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_post_attach (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_post_attach (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_post_attach (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_post_attach (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-14 04:33:08 +08:00
|
|
|
static void
|
|
|
|
delegate_detach (struct target_ops *self, const char *arg1, int arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_detach (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_detach (struct target_ops *self, const char *arg1, int arg2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_detach (struct target_ops *self, const char *arg1, int arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_detach (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_detach (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_detach (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-21 01:30:13 +08:00
|
|
|
static void
|
2014-06-07 03:26:53 +08:00
|
|
|
delegate_disconnect (struct target_ops *self, const char *arg1, int arg2)
|
2013-12-21 01:30:13 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_disconnect (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-06-07 03:26:53 +08:00
|
|
|
tdefault_disconnect (struct target_ops *self, const char *arg1, int arg2)
|
2013-12-21 01:30:13 +08:00
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_disconnect (struct target_ops *self, const char *arg1, int arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_disconnect (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_disconnect (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_disconnect (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
static void
|
|
|
|
delegate_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_resume (self, arg1, arg2, arg3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3)
|
|
|
|
{
|
|
|
|
noprocess ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_resume (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_resume (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_resume (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_step (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_enum_gdb_signal (arg3);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
static ptid_t
|
|
|
|
delegate_wait (struct target_ops *self, ptid_t arg1, struct target_waitstatus *arg2, int arg3)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_wait (self, arg1, arg2, arg3);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static ptid_t
|
|
|
|
debug_wait (struct target_ops *self, ptid_t arg1, struct target_waitstatus *arg2, int arg3)
|
|
|
|
{
|
|
|
|
ptid_t result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_wait (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_wait (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_wait (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_target_waitstatus_p (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_options (arg3);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:30:22 +08:00
|
|
|
static void
|
|
|
|
delegate_fetch_registers (struct target_ops *self, struct regcache *arg1, int arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_fetch_registers (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_fetch_registers (struct target_ops *self, struct regcache *arg1, int arg2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_fetch_registers (struct target_ops *self, struct regcache *arg1, int arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_fetch_registers (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_fetch_registers (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_fetch_registers (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_regcache_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
static void
|
|
|
|
delegate_store_registers (struct target_ops *self, struct regcache *arg1, int arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_store_registers (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_store_registers (struct target_ops *self, struct regcache *arg1, int arg2)
|
|
|
|
{
|
|
|
|
noprocess ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_store_registers (struct target_ops *self, struct regcache *arg1, int arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_store_registers (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_store_registers (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_store_registers (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_regcache_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 00:47:18 +08:00
|
|
|
static void
|
|
|
|
delegate_prepare_to_store (struct target_ops *self, struct regcache *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_prepare_to_store (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_prepare_to_store (struct target_ops *self, struct regcache *arg1)
|
|
|
|
{
|
|
|
|
noprocess ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_prepare_to_store (struct target_ops *self, struct regcache *arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_prepare_to_store (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_prepare_to_store (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_prepare_to_store (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_regcache_p (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 00:51:47 +08:00
|
|
|
static void
|
|
|
|
delegate_files_info (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_files_info (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_files_info (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_files_info (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_files_info (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_files_info (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_files_info (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
static int
|
|
|
|
delegate_insert_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_insert_breakpoint (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_insert_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_insert_breakpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_insert_breakpoint (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_insert_breakpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_gdbarch_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_bp_target_info_p (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
static int
|
|
|
|
delegate_remove_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_remove_breakpoint (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_remove_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_remove_breakpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_remove_breakpoint (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_remove_breakpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_gdbarch_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_bp_target_info_p (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
Teach GDB about targets that can tell whether a trap is a breakpoint event
The moribund locations heuristics are problematic. This patch teaches
GDB about targets that can reliably tell whether a trap was caused by
a software or hardware breakpoint, and thus don't need moribund
locations, thus bypassing all the problems that mechanism has.
The non-stop-fair-events.exp test is frequently failing currently.
E.g., see https://sourceware.org/ml/gdb-testers/2015-q1/msg03148.html.
The root cause is a fundamental problem with moribund locations. For
example, the stepped_breakpoint logic added by af48d08f breaks in this
case (which is what happens with that test):
- Step thread A, no breakpoint is set at PC.
- The kernel doesn't schedule thread A yet.
- Insert breakpoint at A's PC, for some reason (e.g., a step-resume
breakpoint for thread B).
- Kernel finally schedules thread A.
- thread A's stepped_breakpoint flag is not set, even though it now
stepped a breakpoint instruction.
- adjust_pc_after_break gets the PC wrong, because PC == PREV_PC, but
stepped_breakpoint is not set.
We needed the stepped_breakpoint logic to workaround moribund
locations, because otherwise adjust_pc_after_break could apply an
adjustment when it shouldn't just because there _used_ to be a
breakpoint at PC (a moribund breakpoint location). For example, on
x86, that's wrong if the thread really hasn't executed an int3, but
instead executed some other 1-byte long instruction. Getting the PC
adjustment wrong of course leads to the inferior executing the wrong
instruction.
Other problems with moribund locations are:
- if a true SIGTRAP happens to be raised when the program is
executing the PC that used to have a breakpoint, GDB will assume
that is a trap for a breakpoint that has recently been removed, and
thus we miss reporting the random signal to the user.
- to minimize that, we get rid of moribund location after a while.
That while is defined as just a certain number of events being
processed. That number of events sometimes passes by before a
delayed breakpoint is processed, and GDB confuses the trap for a
random signal, thus reporting the random trap. Once the user
resumes the thread, the program crashes because the PC was not
adjusted...
The fix for all this is to bite the bullet and get rid of heuristics
and instead rely on the target knowing accurately what caused the
SIGTRAP. The target/kernel/stub is in the best position to know what
that, because it can e.g. consult priviledged CPU flags GDB has no
access to, or by knowing which exception vector entry was called when
the instruction trapped, etc. Most debug APIs I've seen to date
report breakpoint hits as a distinct event in some fashion. For
example, on the Linux kernel, whether a breakpoint was executed is
exposed to userspace in the si_code field of the SIGTRAP's siginfo.
On Windows, the debug API reports a EXCEPTION_BREAKPOINT exception
code.
We needed to keep around deleted breakpoints in an on-the-side list
(the moribund locations) for two main reasons:
- Know that a SIGTRAP actually is a delayed event for a hit of a
breakpoint that was removed before the event was processed, and
thus should not be reported as a random signal.
- So we still do the decr_pc_after_break adjustment in that case, so
that the thread is resumed at the correct address.
In the new model, if GDB processes an event the target tells is a
breakpoint trap, and GDB doesn't find the corresponding breakpoint in
its breakpoint tables, it means that event is a delayed event for a
breakpoint that has since been removed, and thus the event should be
ignored.
For the decr_pc_after_after issue, it ends up being much simpler that
on targets that can reliably tell whether a breakpoint trapped, for
the breakpoint trap to present the PC already adjusted. Proper
multi-threading support already implies that targets needs to be doing
decr_pc_after_break adjustment themselves, otherwise for example, in
all-stop if two threads hit a breakpoint simultaneously, and the user
does "info threads", he'll see the non-event thread that hit the
breakpoint stopped at the wrong PC.
This way (target adjusts) also ends up eliminating the need for some
awkward re-incrementing of the PC in the record-full and Linux targets
that we do today, and the need for the target_decr_pc_after_break
hook.
If the target always adjusts, then there's a case where GDB needs to
re-increment the PC. Say, on x86, an "int3" instruction that was
explicitly written in the program traps. In this case, GDB should
report a random SIGTRAP signal to the user, with the PC pointing at
the instruction past the int3, just like if GDB was not debugging the
program. The user may well decide to pass the SIGTRAP to the program
because the program being debugged has a SIGTRAP handler that handles
its own breakpoints, and expects the PC to be unadjusted.
Tested on x86-64 Fedora 20.
gdb/ChangeLog:
2015-03-04 Pedro Alves <palves@redhat.com>
* breakpoint.c (need_moribund_for_location_type): New function.
(bpstat_stop_status): Don't skipping checking moribund locations
of breakpoint types which the target tell caused a stop.
(program_breakpoint_here_p): New function, factored out from ...
(bp_loc_is_permanent): ... this.
(update_global_location_list): Don't create a moribund location if
the target supports reporting stops of the type of the removed
breakpoint.
* breakpoint.h (program_breakpoint_here_p): New declaration.
* infrun.c (adjust_pc_after_break): Return early if the target has
already adjusted the PC. Add comments.
(handle_signal_stop): If nothing explains a signal, and the target
tells us the stop was caused by a software breakpoint, check if
there's a breakpoint instruction in the memory. If so, adjust the
PC before presenting the stop to the user. Otherwise, ignore the
trap. If nothing explains a signal, and the target tells us the
stop was caused by a hardware breakpoint, ignore the trap.
* target.h (struct target_ops) <to_stopped_by_sw_breakpoint,
to_supports_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint,
to_supports_stopped_by_hw_breakpoint>: New fields.
(target_stopped_by_sw_breakpoint)
(target_supports_stopped_by_sw_breakpoint)
(target_stopped_by_hw_breakpoint)
(target_supports_stopped_by_hw_breakpoint): Define.
* target-delegates.c: Regenerate.
2015-03-05 04:41:15 +08:00
|
|
|
static int
|
|
|
|
delegate_stopped_by_sw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_stopped_by_sw_breakpoint (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_stopped_by_sw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
debug_stopped_by_sw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_stopped_by_sw_breakpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_stopped_by_sw_breakpoint (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_stopped_by_sw_breakpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
delegate_supports_stopped_by_sw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_supports_stopped_by_sw_breakpoint (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_supports_stopped_by_sw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
debug_supports_stopped_by_sw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_supports_stopped_by_sw_breakpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_supports_stopped_by_sw_breakpoint (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_supports_stopped_by_sw_breakpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
delegate_stopped_by_hw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_stopped_by_hw_breakpoint (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_stopped_by_hw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
debug_stopped_by_hw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_stopped_by_hw_breakpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_stopped_by_hw_breakpoint (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_stopped_by_hw_breakpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
delegate_supports_stopped_by_hw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_supports_stopped_by_hw_breakpoint (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_supports_stopped_by_hw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
debug_supports_stopped_by_hw_breakpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_supports_stopped_by_hw_breakpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_supports_stopped_by_hw_breakpoint (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_supports_stopped_by_hw_breakpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 00:58:16 +08:00
|
|
|
static int
|
2015-08-01 01:19:53 +08:00
|
|
|
delegate_can_use_hw_breakpoint (struct target_ops *self, enum bptype arg1, int arg2, int arg3)
|
2013-12-19 00:58:16 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_can_use_hw_breakpoint (self, arg1, arg2, arg3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-08-01 01:19:53 +08:00
|
|
|
tdefault_can_use_hw_breakpoint (struct target_ops *self, enum bptype arg1, int arg2, int arg3)
|
2013-12-19 00:58:16 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
2015-08-01 01:19:53 +08:00
|
|
|
debug_can_use_hw_breakpoint (struct target_ops *self, enum bptype arg1, int arg2, int arg3)
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_can_use_hw_breakpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_can_use_hw_breakpoint (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_can_use_hw_breakpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
2015-08-01 01:19:53 +08:00
|
|
|
target_debug_print_enum_bptype (arg1);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg3);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:31:42 +08:00
|
|
|
static int
|
|
|
|
delegate_ranged_break_num_registers (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_ranged_break_num_registers (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_ranged_break_num_registers (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_ranged_break_num_registers (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_ranged_break_num_registers (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_ranged_break_num_registers (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_ranged_break_num_registers (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:01:11 +08:00
|
|
|
static int
|
|
|
|
delegate_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_insert_hw_breakpoint (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_insert_hw_breakpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_insert_hw_breakpoint (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_insert_hw_breakpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_gdbarch_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_bp_target_info_p (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:05:18 +08:00
|
|
|
static int
|
|
|
|
delegate_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_remove_hw_breakpoint (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_remove_hw_breakpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_remove_hw_breakpoint (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_remove_hw_breakpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_gdbarch_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_bp_target_info_p (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:11:49 +08:00
|
|
|
static int
|
2015-08-01 01:19:53 +08:00
|
|
|
delegate_remove_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, enum target_hw_bp_type arg3, struct expression *arg4)
|
2013-12-19 01:11:49 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_remove_watchpoint (self, arg1, arg2, arg3, arg4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-08-01 01:19:53 +08:00
|
|
|
tdefault_remove_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, enum target_hw_bp_type arg3, struct expression *arg4)
|
2013-12-19 01:11:49 +08:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
2015-08-01 01:19:53 +08:00
|
|
|
debug_remove_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, enum target_hw_bp_type arg3, struct expression *arg4)
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_remove_watchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_remove_watchpoint (&debug_target, arg1, arg2, arg3, arg4);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_remove_watchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
2015-08-01 01:19:53 +08:00
|
|
|
target_debug_print_enum_target_hw_bp_type (arg3);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_expression_p (arg4);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:08:59 +08:00
|
|
|
static int
|
2015-08-01 01:19:53 +08:00
|
|
|
delegate_insert_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, enum target_hw_bp_type arg3, struct expression *arg4)
|
2013-12-19 01:08:59 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_insert_watchpoint (self, arg1, arg2, arg3, arg4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-08-01 01:19:53 +08:00
|
|
|
tdefault_insert_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, enum target_hw_bp_type arg3, struct expression *arg4)
|
2013-12-19 01:08:59 +08:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
2015-08-01 01:19:53 +08:00
|
|
|
debug_insert_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, enum target_hw_bp_type arg3, struct expression *arg4)
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_insert_watchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_insert_watchpoint (&debug_target, arg1, arg2, arg3, arg4);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_insert_watchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
2015-08-01 01:19:53 +08:00
|
|
|
target_debug_print_enum_target_hw_bp_type (arg3);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_expression_p (arg4);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:32:43 +08:00
|
|
|
static int
|
2015-11-04 02:33:12 +08:00
|
|
|
delegate_insert_mask_watchpoint (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, enum target_hw_bp_type arg3)
|
2013-12-19 05:32:43 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_insert_mask_watchpoint (self, arg1, arg2, arg3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-11-04 02:33:12 +08:00
|
|
|
tdefault_insert_mask_watchpoint (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, enum target_hw_bp_type arg3)
|
2013-12-19 05:32:43 +08:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
2015-11-04 02:33:12 +08:00
|
|
|
debug_insert_mask_watchpoint (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, enum target_hw_bp_type arg3)
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_insert_mask_watchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_insert_mask_watchpoint (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_insert_mask_watchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
2015-11-04 02:33:12 +08:00
|
|
|
target_debug_print_enum_target_hw_bp_type (arg3);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:33:28 +08:00
|
|
|
static int
|
2015-11-04 02:33:12 +08:00
|
|
|
delegate_remove_mask_watchpoint (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, enum target_hw_bp_type arg3)
|
2013-12-19 05:33:28 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_remove_mask_watchpoint (self, arg1, arg2, arg3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-11-04 02:33:12 +08:00
|
|
|
tdefault_remove_mask_watchpoint (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, enum target_hw_bp_type arg3)
|
2013-12-19 05:33:28 +08:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
2015-11-04 02:33:12 +08:00
|
|
|
debug_remove_mask_watchpoint (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, enum target_hw_bp_type arg3)
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_remove_mask_watchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_remove_mask_watchpoint (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_remove_mask_watchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
2015-11-04 02:33:12 +08:00
|
|
|
target_debug_print_enum_target_hw_bp_type (arg3);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
static int
|
|
|
|
delegate_stopped_by_watchpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_stopped_by_watchpoint (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_stopped_by_watchpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_stopped_by_watchpoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_stopped_by_watchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_stopped_by_watchpoint (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_stopped_by_watchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
static int
|
|
|
|
delegate_stopped_data_address (struct target_ops *self, CORE_ADDR *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_stopped_data_address (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_stopped_data_address (struct target_ops *self, CORE_ADDR *arg1)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_stopped_data_address (struct target_ops *self, CORE_ADDR *arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_stopped_data_address (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_stopped_data_address (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_stopped_data_address (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR_p (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:15:23 +08:00
|
|
|
static int
|
|
|
|
delegate_watchpoint_addr_within_range (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, int arg3)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_watchpoint_addr_within_range (self, arg1, arg2, arg3);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_watchpoint_addr_within_range (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, int arg3)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_watchpoint_addr_within_range (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_watchpoint_addr_within_range (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_watchpoint_addr_within_range (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg3);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:18:05 +08:00
|
|
|
static int
|
|
|
|
delegate_region_ok_for_hw_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_region_ok_for_hw_watchpoint (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_region_ok_for_hw_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_region_ok_for_hw_watchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_region_ok_for_hw_watchpoint (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_region_ok_for_hw_watchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:20:48 +08:00
|
|
|
static int
|
|
|
|
delegate_can_accel_watchpoint_condition (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_can_accel_watchpoint_condition (self, arg1, arg2, arg3, arg4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_can_accel_watchpoint_condition (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_can_accel_watchpoint_condition (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_can_accel_watchpoint_condition (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_can_accel_watchpoint_condition (&debug_target, arg1, arg2, arg3, arg4);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_can_accel_watchpoint_condition (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg3);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_expression_p (arg4);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:34:15 +08:00
|
|
|
static int
|
|
|
|
delegate_masked_watch_num_registers (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_masked_watch_num_registers (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_masked_watch_num_registers (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_masked_watch_num_registers (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_masked_watch_num_registers (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_masked_watch_num_registers (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_masked_watch_num_registers (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
Support single step by arch or target
Nowadays, GDB only knows whether architecture supports hardware single
step or software single step (through gdbarch hook software_single_step),
and for a given instruction or instruction sequence, GDB knows how to
do single step (hardware or software). However, GDB doesn't know whether
the target supports hardware single step. It is possible that the
architecture doesn't support hardware single step, such as arm, but
the target supports, such as simulator. This was discussed in this
thread https://www.sourceware.org/ml/gdb/2009-12/msg00033.html before.
I encounter this problem for aarch64 multi-arch support. When aarch64
debugs arm program, gdbarch is arm, so software single step is still
used. However, the underneath linux kernel does support hardware
single step, so IWBN to use it.
This patch is to add a new target_ops hook to_can_do_single_step, and
only use it in arm_linux_software_single_step to decide whether or not
to use hardware single step. On the native aarch64 linux target, 1 is
returned. On other targets, -1 is returned. On the remote target, if
the target supports s and S actions in the vCont? reply, then target
can do single step. However, old GDBserver will send s and S in the
reply to vCont?, which will confuse new GDB. For example, old GDBserver
on arm-linux will send s and S in the reply to vCont?, but it doesn't
support hardware single step. On the other hand, new GDBserver, on
arm-linux for example, will not send s and S in the reply to vCont?,
but old GDB thinks it doesn't support vCont packet at all. In order
to address this problem, I add a new qSupported feature vContSupported,
which indicates GDB wants to know the supported actions in the reply
to vCont?, and qSupported response contains vContSupported if the
stub is able tell supported vCont actions in the reply of vCont?.
If the patched GDB talks with patched GDBserver on x86, the RSP traffic
is like this:
-> $qSupported:...+;vContSupported+
<- ...+;vContSupported+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
then, GDB knows the stub can do single step, and may stop using software
single step even the architecture doesn't support hardware single step.
If the patched GDB talks with patched GDBserver on arm, the last vCont?
reply will become:
<- vCont;c;C;t
GDB thinks the target doesn't support single step, so it will use software
single step.
If the patched GDB talks with unpatched GDBserver, the RSP traffic is like
this:
-> $qSupported:...+;vContSupported+
<- ...+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
although GDBserver returns s and S, GDB still thinks GDBserver may not
support single step because it doesn't support vContSupported.
If the unpatched GDB talks with patched GDBserver on x86, the RSP traffic
is like:
-> $qSupported:...+;
<- ...+;vContSupported+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
Since GDB doesn't sent vContSupported in the qSupported feature, GDBserver
sends s and S regardless of the support of hardware single step.
gdb:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-nat.c (aarch64_linux_can_do_single_step): New
function.
(_initialize_aarch64_linux_nat): Install it to to_can_do_single_step.
* arm-linux-tdep.c (arm_linux_software_single_step): Return 0
if target_can_do_single_step returns 1.
* remote.c (struct vCont_action_support) <s, S>: New fields.
(PACKET_vContSupported): New enum.
(remote_protocol_features): New element for vContSupported.
(remote_query_supported): Append "vContSupported+".
(remote_vcont_probe): Remove support_s and support_S, use
rs->supports_vCont.s and rs->supports_vCont.S instead. Disable
vCont packet if c and C actions are not supported.
(remote_can_do_single_step): New function.
(init_remote_ops): Install it to to_can_do_single_step.
(_initialize_remote): Call add_packet_config_cmd.
* target.h (struct target_ops) <to_can_do_single_step>: New field.
(target_can_do_single_step): New macro.
* target-delegates.c: Re-generated.
gdb/gdbserver:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* server.c (vCont_supported): New global variable.
(handle_query): Set vCont_supported to 1 if "vContSupported+"
matches. Append ";vContSupported+" to own_buf.
(handle_v_requests): Append ";s;S" to own_buf if target supports
hardware single step or vCont_supported is false.
(capture_main): Set vCont_supported to zero.
gdb/doc:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* gdb.texinfo (General Query Packets): Add vContSupported to
tables of 'gdbfeatures' and 'stub features' supported in the
qSupported packet, as well as to the list containing stub
feature details.
2015-09-15 21:09:18 +08:00
|
|
|
static int
|
|
|
|
delegate_can_do_single_step (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_can_do_single_step (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_can_do_single_step (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
debug_can_do_single_step (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_can_do_single_step (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_can_do_single_step (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_can_do_single_step (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:24:07 +08:00
|
|
|
static void
|
|
|
|
delegate_terminal_init (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_terminal_init (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_terminal_init (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_terminal_init (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_terminal_init (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_terminal_init (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_terminal_init (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:29:01 +08:00
|
|
|
static void
|
|
|
|
delegate_terminal_inferior (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_terminal_inferior (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_terminal_inferior (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_terminal_inferior (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_terminal_inferior (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_terminal_inferior (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_terminal_inferior (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:29:46 +08:00
|
|
|
static void
|
|
|
|
delegate_terminal_ours_for_output (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_terminal_ours_for_output (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_terminal_ours_for_output (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_terminal_ours_for_output (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_terminal_ours_for_output (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_terminal_ours_for_output (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_terminal_ours_for_output (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:30:16 +08:00
|
|
|
static void
|
|
|
|
delegate_terminal_ours (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_terminal_ours (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_terminal_ours (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_terminal_ours (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_terminal_ours (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_terminal_ours (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_terminal_ours (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:31:10 +08:00
|
|
|
static void
|
|
|
|
delegate_terminal_info (struct target_ops *self, const char *arg1, int arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_terminal_info (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_terminal_info (struct target_ops *self, const char *arg1, int arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_terminal_info (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_terminal_info (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_terminal_info (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:35:15 +08:00
|
|
|
static void
|
|
|
|
delegate_kill (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_kill (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_kill (struct target_ops *self)
|
|
|
|
{
|
|
|
|
noprocess ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_kill (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_kill (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_kill (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_kill (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:31:48 +08:00
|
|
|
static void
|
2013-03-28 04:14:26 +08:00
|
|
|
delegate_load (struct target_ops *self, const char *arg1, int arg2)
|
2013-12-19 01:31:48 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_load (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-03-28 04:14:26 +08:00
|
|
|
tdefault_load (struct target_ops *self, const char *arg1, int arg2)
|
2013-12-19 01:31:48 +08:00
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_load (struct target_ops *self, const char *arg1, int arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_load (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_load (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_load (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:32:56 +08:00
|
|
|
static void
|
|
|
|
delegate_post_startup_inferior (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_post_startup_inferior (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_post_startup_inferior (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_post_startup_inferior (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_post_startup_inferior (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_post_startup_inferior (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_post_startup_inferior (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:33:43 +08:00
|
|
|
static int
|
|
|
|
delegate_insert_fork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_insert_fork_catchpoint (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_insert_fork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_insert_fork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_insert_fork_catchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_insert_fork_catchpoint (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_insert_fork_catchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:34:15 +08:00
|
|
|
static int
|
|
|
|
delegate_remove_fork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_remove_fork_catchpoint (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_remove_fork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_remove_fork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_remove_fork_catchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_remove_fork_catchpoint (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_remove_fork_catchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:44:22 +08:00
|
|
|
static int
|
|
|
|
delegate_insert_vfork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_insert_vfork_catchpoint (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_insert_vfork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_insert_vfork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_insert_vfork_catchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_insert_vfork_catchpoint (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_insert_vfork_catchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:44:57 +08:00
|
|
|
static int
|
|
|
|
delegate_remove_vfork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_remove_vfork_catchpoint (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_remove_vfork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_remove_vfork_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_remove_vfork_catchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_remove_vfork_catchpoint (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_remove_vfork_catchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:38:04 +08:00
|
|
|
static int
|
|
|
|
delegate_follow_fork (struct target_ops *self, int arg1, int arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_follow_fork (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_follow_fork (struct target_ops *self, int arg1, int arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_follow_fork (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_follow_fork (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_follow_fork (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:45:38 +08:00
|
|
|
static int
|
|
|
|
delegate_insert_exec_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_insert_exec_catchpoint (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_insert_exec_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_insert_exec_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_insert_exec_catchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_insert_exec_catchpoint (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_insert_exec_catchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:46:02 +08:00
|
|
|
static int
|
|
|
|
delegate_remove_exec_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_remove_exec_catchpoint (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_remove_exec_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_remove_exec_catchpoint (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_remove_exec_catchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_remove_exec_catchpoint (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_remove_exec_catchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
Extended-remote follow-exec
This patch implements support for exec events on extended-remote Linux
targets. Follow-exec-mode and rerun behave as expected. Catchpoints and
test updates are implemented in subsequent patches.
This patch was derived from a patch posted last October:
https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html.
It was originally based on some work done by Luis Machado in 2013.
IMPLEMENTATION
----------------
Exec events are enabled via ptrace options.
When an exec event is detected by gdbserver, the existing process
data, along with all its associated lwp and thread data, is deleted
and replaced by data for a new single-threaded process. The new
process data is initialized with the appropriate parts of the state
of the execing process. This approach takes care of several potential
pitfalls, including:
* deleting the data for an execing non-leader thread before any
wait/sigsuspend occurs
* correctly initializing the architecture of the execed process
We then report the exec event using a new RSP stop reason, "exec".
When GDB receives an "exec" event, it saves the status in the event
structure's target_waitstatus field, like what is done for remote fork
events. Because the original and execed programs may have different
architectures, we skip parsing the section of the stop reply packet
that contains register data. The register data will be retrieved
later after the inferior's architecture has been set up by
infrun.c:follow_exec.
At that point the exec event is handled by the existing event handling
in GDB. However, a few changes were necessary so that
infrun.c:follow_exec could accommodate the remote target.
* Where follow-exec-mode "new" is handled, we now call
add_inferior_with_spaces instead of add_inferior with separate calls
to set up the program and address spaces. The motivation for this
is that add_inferior_with_spaces also sets up the initial architecture
for the inferior, which is needed later by target_find_description
when it calls target_gdbarch.
* We call a new target function, target_follow_exec. This function
allows us to store the execd_pathname in the inferior, instead of
using the static string remote_exec_file from remote.c. The static
string didn't work for follow-exec-mode "new", since once you switched
to the execed program, the original remote exec-file was lost. The
execd_pathname is now stored in the inferior's program space as a
REGISTRY field. All of the requisite mechanisms for this are
defined in remote.c.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_mourn): Static declaration.
(linux_arch_setup): Move in front of
handle_extended_wait.
(linux_arch_setup_thread): New function.
(handle_extended_wait): Handle exec events. Call
linux_arch_setup_thread. Make event_lwp argument a
pointer-to-a-pointer.
(check_zombie_leaders): Do not check stopped threads.
(linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC.
(linux_low_filter_event): Add lwp and thread for exec'ing
non-leader thread if leader thread has been deleted.
Refactor code into linux_arch_setup_thread and call it.
Pass child lwp pointer by reference to handle_extended_wait.
(linux_wait_for_event_filtered): Update comment.
(linux_wait_1): Prevent clobbering exec event status.
(linux_supports_exec_events): New function.
(linux_target_ops) <supports_exec_events>: Initialize new member.
* lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize
new member.
* remote-utils.c (prepare_resume_reply): New stop reason 'exec'.
* server.c (report_exec_events): New global variable.
(handle_query): Handle qSupported query for exec-events feature.
(captured_main): Initialize report_exec_events.
* server.h (report_exec_events): Declare new global variable.
* target.h (struct target_ops) <supports_exec_events>: New
member.
(target_supports_exec_events): New macro.
* win32-low.c (win32_target_ops) <supports_exec_events>:
Initialize new member.
gdb/ChangeLog:
* infrun.c (follow_exec): Use process-style ptid for
exec message. Call add_inferior_with_spaces and
target_follow_exec.
* nat/linux-ptrace.c (linux_supports_traceexec): New function.
* nat/linux-ptrace.h (linux_supports_traceexec): Declare.
* remote.c (remote_pspace_data): New static variable.
(remote_pspace_data_cleanup): New function.
(get_remote_exec_file): New function.
(set_remote_exec_file_1): New function.
(set_remote_exec_file): New function.
(show_remote_exec_file): New function.
(remote_exec_file): Delete static variable.
(anonymous enum) <PACKET_exec_event_feature> New
enumeration constant.
(remote_protocol_features): Add entry for exec-events feature.
(remote_query_supported): Add client side of qSupported query
for exec-events feature.
(remote_follow_exec): New function.
(remote_parse_stop_reply): Handle 'exec' stop reason.
(extended_remote_run, extended_remote_create_inferior): Call
get_remote_exec_file and set_remote_exec_file_1.
(init_extended_remote_ops) <to_follow_exec>: Initialize new
member.
(_initialize_remote): Call
register_program_space_data_with_cleanup. Call
add_packet_config_cmd for remote exec-events feature.
Modify call to add_setshow_string_noescape_cmd for exec-file
to use new functions set_remote_exec_file and
show_remote_exec_file.
* target-debug.h, target-delegates.c: Regenerated.
* target.c (target_follow_exec): New function.
* target.h (struct target_ops) <to_follow_exec>: New member.
(target_follow_exec): Declare new function.
2015-09-12 02:06:02 +08:00
|
|
|
static void
|
|
|
|
delegate_follow_exec (struct target_ops *self, struct inferior *arg1, char *arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_follow_exec (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_follow_exec (struct target_ops *self, struct inferior *arg1, char *arg2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
debug_follow_exec (struct target_ops *self, struct inferior *arg1, char *arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_follow_exec (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_follow_exec (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_follow_exec (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_inferior_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_char_p (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:46:38 +08:00
|
|
|
static int
|
|
|
|
delegate_set_syscall_catchpoint (struct target_ops *self, int arg1, int arg2, int arg3, int arg4, int *arg5)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_set_syscall_catchpoint (self, arg1, arg2, arg3, arg4, arg5);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_set_syscall_catchpoint (struct target_ops *self, int arg1, int arg2, int arg3, int arg4, int *arg5)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_set_syscall_catchpoint (struct target_ops *self, int arg1, int arg2, int arg3, int arg4, int *arg5)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_set_syscall_catchpoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_set_syscall_catchpoint (&debug_target, arg1, arg2, arg3, arg4, arg5);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_set_syscall_catchpoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg3);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg4);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int_p (arg5);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:47:22 +08:00
|
|
|
static int
|
|
|
|
delegate_has_exited (struct target_ops *self, int arg1, int arg2, int *arg3)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_has_exited (self, arg1, arg2, arg3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_has_exited (struct target_ops *self, int arg1, int arg2, int *arg3)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_has_exited (struct target_ops *self, int arg1, int arg2, int *arg3)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_has_exited (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_has_exited (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_has_exited (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int_p (arg3);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:40:23 +08:00
|
|
|
static void
|
|
|
|
delegate_mourn_inferior (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_mourn_inferior (self);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_mourn_inferior (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_mourn_inferior (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_mourn_inferior (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_mourn_inferior (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-21 03:19:37 +08:00
|
|
|
static int
|
|
|
|
delegate_can_run (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_can_run (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_can_run (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_can_run (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_can_run (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_can_run (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_can_run (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:42:10 +08:00
|
|
|
static void
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
delegate_pass_signals (struct target_ops *self, int arg1, unsigned char * arg2)
|
2013-12-19 05:42:10 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_pass_signals (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
tdefault_pass_signals (struct target_ops *self, int arg1, unsigned char * arg2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
debug_pass_signals (struct target_ops *self, int arg1, unsigned char * arg2)
|
2013-12-19 05:42:10 +08:00
|
|
|
{
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_pass_signals (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_pass_signals (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_pass_signals (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_signals (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
2013-12-19 05:42:10 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:42:54 +08:00
|
|
|
static void
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
delegate_program_signals (struct target_ops *self, int arg1, unsigned char * arg2)
|
2013-12-19 05:42:54 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_program_signals (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
tdefault_program_signals (struct target_ops *self, int arg1, unsigned char * arg2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
debug_program_signals (struct target_ops *self, int arg1, unsigned char * arg2)
|
2013-12-19 05:42:54 +08:00
|
|
|
{
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_program_signals (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_program_signals (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_program_signals (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_signals (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
2013-12-19 05:42:54 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 22:21:56 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_thread_alive (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_thread_alive (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_thread_alive (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_thread_alive (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:44:20 +08:00
|
|
|
static void
|
Push pruning old threads down to the target
When GDB wants to sync the thread list with the target's (e.g., due to
"info threads"), it calls update_thread_list:
update_thread_list (void)
{
prune_threads ();
target_find_new_threads ();
update_threads_executing ();
}
And then prune_threads does:
prune_threads (void)
{
struct thread_info *tp, *next;
for (tp = thread_list; tp; tp = next)
{
next = tp->next;
if (!thread_alive (tp))
delete_thread (tp->ptid);
}
}
Calling thread_live on each thread one by one is expensive.
E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not
a big deal, but still a bunch of syscalls...
With the remote target, it's cumbersome. That thread_alive call ends
up generating one T packet per thread:
Sending packet: $Tp2141.2150#82...Packet received: OK
Sending packet: $Tp2141.214f#b7...Packet received: OK
Sending packet: $Tp2141.2141#82...Packet received: OK
Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n
That seems a bit silly when target_find_new_threads method
implementations will always fetch the whole current set of target
threads, and then add those that are not in GDB's thread list, to
GDB's thread list.
This patch thus pushes down the responsibility of pruning dead threads
to the target_find_new_threads method instead, so a target may
implement pruning dead threads however it wants.
Once we do that, target_find_new_threads becomes a misnomer, so the
patch renames it to target_update_thread_list.
The patch doesn't attempt to do any optimization to any target yet.
It simply exports prune_threads, and makes all implementations of
target_update_thread_list call that. It's meant to be a no-op.
gdb/
2014-10-15 Pedro Alves <palves@redhat.com>
* ada-tasks.c (print_ada_task_info, task_command_1): Adjust.
* bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ...
(bsd_uthread_update_thread_list): ... this. Call prune_threads.
(bsd_uthread_target): Adjust.
* corelow.c (core_open): Adjust.
* dec-thread.c (dec_thread_find_new_threads): Update comment.
(dec_thread_update_thread_list): New function.
(init_dec_thread_ops): Adjust.
* gdbthread.h (prune_threads): New declaration.
* linux-thread-db.c (thread_db_find_new_threads): Rename to ...
(thread_db_update_thread_list): ... this. Call prune_threads.
(init_thread_db_ops): Adjust.
* nto-procfs.c (procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
(procfs_attach, procfs_create_inferior, init_procfs_targets):
Adjust.
* obsd-nat.c (obsd_find_new_threads): Rename to ...
(obsd_update_thread_list): ... this. Call prune_threads.
(obsd_add_target): Adjust.
* procfs.c (procfs_target): Adjust.
(procfs_notice_thread): Update comment.
(procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
* ravenscar-thread.c (ravenscar_update_inferior_ptid): Update
comment.
(ravenscar_wait): Adjust.
(ravenscar_find_new_threads): Rename to ...
(ravenscar_update_thread_list): ... this. Call prune_threads.
(init_ravenscar_thread_ops): Adjust.
* record-btrace.c (record_btrace_find_new_threads): Rename to ...
(record_btrace_update_thread_list): ... this. Adjust comment.
(init_record_btrace_ops): Adjust.
* remote.c (remote_threads_info): Rename to ...
(remote_update_thread_list): ... this. Call prune_threads.
(remote_start_remote, extended_remote_attach_1, init_remote_ops):
Adjust.
* sol-thread.c (check_for_thread_db): Adjust.
(sol_find_new_threads_callback): Rename to ...
(sol_update_thread_list_callback): ... this.
(sol_find_new_threads): Rename to ...
(sol_update_thread_list): ... this. Call prune_threads. Adjust.
(sol_get_ada_task_ptid, init_sol_thread_ops): Adjust.
* target-delegates.c: Regenerate.
* target.c (target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* target.h (struct target_ops): Rename to_find_new_threads field
to to_update_thread_list.
(target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* thread.c (prune_threads): Make extern.
(update_thread_list): Adjust.
2014-10-16 05:44:00 +08:00
|
|
|
delegate_update_thread_list (struct target_ops *self)
|
2013-12-19 05:44:20 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
Push pruning old threads down to the target
When GDB wants to sync the thread list with the target's (e.g., due to
"info threads"), it calls update_thread_list:
update_thread_list (void)
{
prune_threads ();
target_find_new_threads ();
update_threads_executing ();
}
And then prune_threads does:
prune_threads (void)
{
struct thread_info *tp, *next;
for (tp = thread_list; tp; tp = next)
{
next = tp->next;
if (!thread_alive (tp))
delete_thread (tp->ptid);
}
}
Calling thread_live on each thread one by one is expensive.
E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not
a big deal, but still a bunch of syscalls...
With the remote target, it's cumbersome. That thread_alive call ends
up generating one T packet per thread:
Sending packet: $Tp2141.2150#82...Packet received: OK
Sending packet: $Tp2141.214f#b7...Packet received: OK
Sending packet: $Tp2141.2141#82...Packet received: OK
Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n
That seems a bit silly when target_find_new_threads method
implementations will always fetch the whole current set of target
threads, and then add those that are not in GDB's thread list, to
GDB's thread list.
This patch thus pushes down the responsibility of pruning dead threads
to the target_find_new_threads method instead, so a target may
implement pruning dead threads however it wants.
Once we do that, target_find_new_threads becomes a misnomer, so the
patch renames it to target_update_thread_list.
The patch doesn't attempt to do any optimization to any target yet.
It simply exports prune_threads, and makes all implementations of
target_update_thread_list call that. It's meant to be a no-op.
gdb/
2014-10-15 Pedro Alves <palves@redhat.com>
* ada-tasks.c (print_ada_task_info, task_command_1): Adjust.
* bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ...
(bsd_uthread_update_thread_list): ... this. Call prune_threads.
(bsd_uthread_target): Adjust.
* corelow.c (core_open): Adjust.
* dec-thread.c (dec_thread_find_new_threads): Update comment.
(dec_thread_update_thread_list): New function.
(init_dec_thread_ops): Adjust.
* gdbthread.h (prune_threads): New declaration.
* linux-thread-db.c (thread_db_find_new_threads): Rename to ...
(thread_db_update_thread_list): ... this. Call prune_threads.
(init_thread_db_ops): Adjust.
* nto-procfs.c (procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
(procfs_attach, procfs_create_inferior, init_procfs_targets):
Adjust.
* obsd-nat.c (obsd_find_new_threads): Rename to ...
(obsd_update_thread_list): ... this. Call prune_threads.
(obsd_add_target): Adjust.
* procfs.c (procfs_target): Adjust.
(procfs_notice_thread): Update comment.
(procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
* ravenscar-thread.c (ravenscar_update_inferior_ptid): Update
comment.
(ravenscar_wait): Adjust.
(ravenscar_find_new_threads): Rename to ...
(ravenscar_update_thread_list): ... this. Call prune_threads.
(init_ravenscar_thread_ops): Adjust.
* record-btrace.c (record_btrace_find_new_threads): Rename to ...
(record_btrace_update_thread_list): ... this. Adjust comment.
(init_record_btrace_ops): Adjust.
* remote.c (remote_threads_info): Rename to ...
(remote_update_thread_list): ... this. Call prune_threads.
(remote_start_remote, extended_remote_attach_1, init_remote_ops):
Adjust.
* sol-thread.c (check_for_thread_db): Adjust.
(sol_find_new_threads_callback): Rename to ...
(sol_update_thread_list_callback): ... this.
(sol_find_new_threads): Rename to ...
(sol_update_thread_list): ... this. Call prune_threads. Adjust.
(sol_get_ada_task_ptid, init_sol_thread_ops): Adjust.
* target-delegates.c: Regenerate.
* target.c (target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* target.h (struct target_ops): Rename to_find_new_threads field
to to_update_thread_list.
(target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* thread.c (prune_threads): Make extern.
(update_thread_list): Adjust.
2014-10-16 05:44:00 +08:00
|
|
|
self->to_update_thread_list (self);
|
2013-12-19 05:44:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Push pruning old threads down to the target
When GDB wants to sync the thread list with the target's (e.g., due to
"info threads"), it calls update_thread_list:
update_thread_list (void)
{
prune_threads ();
target_find_new_threads ();
update_threads_executing ();
}
And then prune_threads does:
prune_threads (void)
{
struct thread_info *tp, *next;
for (tp = thread_list; tp; tp = next)
{
next = tp->next;
if (!thread_alive (tp))
delete_thread (tp->ptid);
}
}
Calling thread_live on each thread one by one is expensive.
E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not
a big deal, but still a bunch of syscalls...
With the remote target, it's cumbersome. That thread_alive call ends
up generating one T packet per thread:
Sending packet: $Tp2141.2150#82...Packet received: OK
Sending packet: $Tp2141.214f#b7...Packet received: OK
Sending packet: $Tp2141.2141#82...Packet received: OK
Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n
That seems a bit silly when target_find_new_threads method
implementations will always fetch the whole current set of target
threads, and then add those that are not in GDB's thread list, to
GDB's thread list.
This patch thus pushes down the responsibility of pruning dead threads
to the target_find_new_threads method instead, so a target may
implement pruning dead threads however it wants.
Once we do that, target_find_new_threads becomes a misnomer, so the
patch renames it to target_update_thread_list.
The patch doesn't attempt to do any optimization to any target yet.
It simply exports prune_threads, and makes all implementations of
target_update_thread_list call that. It's meant to be a no-op.
gdb/
2014-10-15 Pedro Alves <palves@redhat.com>
* ada-tasks.c (print_ada_task_info, task_command_1): Adjust.
* bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ...
(bsd_uthread_update_thread_list): ... this. Call prune_threads.
(bsd_uthread_target): Adjust.
* corelow.c (core_open): Adjust.
* dec-thread.c (dec_thread_find_new_threads): Update comment.
(dec_thread_update_thread_list): New function.
(init_dec_thread_ops): Adjust.
* gdbthread.h (prune_threads): New declaration.
* linux-thread-db.c (thread_db_find_new_threads): Rename to ...
(thread_db_update_thread_list): ... this. Call prune_threads.
(init_thread_db_ops): Adjust.
* nto-procfs.c (procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
(procfs_attach, procfs_create_inferior, init_procfs_targets):
Adjust.
* obsd-nat.c (obsd_find_new_threads): Rename to ...
(obsd_update_thread_list): ... this. Call prune_threads.
(obsd_add_target): Adjust.
* procfs.c (procfs_target): Adjust.
(procfs_notice_thread): Update comment.
(procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
* ravenscar-thread.c (ravenscar_update_inferior_ptid): Update
comment.
(ravenscar_wait): Adjust.
(ravenscar_find_new_threads): Rename to ...
(ravenscar_update_thread_list): ... this. Call prune_threads.
(init_ravenscar_thread_ops): Adjust.
* record-btrace.c (record_btrace_find_new_threads): Rename to ...
(record_btrace_update_thread_list): ... this. Adjust comment.
(init_record_btrace_ops): Adjust.
* remote.c (remote_threads_info): Rename to ...
(remote_update_thread_list): ... this. Call prune_threads.
(remote_start_remote, extended_remote_attach_1, init_remote_ops):
Adjust.
* sol-thread.c (check_for_thread_db): Adjust.
(sol_find_new_threads_callback): Rename to ...
(sol_update_thread_list_callback): ... this.
(sol_find_new_threads): Rename to ...
(sol_update_thread_list): ... this. Call prune_threads. Adjust.
(sol_get_ada_task_ptid, init_sol_thread_ops): Adjust.
* target-delegates.c: Regenerate.
* target.c (target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* target.h (struct target_ops): Rename to_find_new_threads field
to to_update_thread_list.
(target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* thread.c (prune_threads): Make extern.
(update_thread_list): Adjust.
2014-10-16 05:44:00 +08:00
|
|
|
tdefault_update_thread_list (struct target_ops *self)
|
2013-12-19 05:44:20 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
Push pruning old threads down to the target
When GDB wants to sync the thread list with the target's (e.g., due to
"info threads"), it calls update_thread_list:
update_thread_list (void)
{
prune_threads ();
target_find_new_threads ();
update_threads_executing ();
}
And then prune_threads does:
prune_threads (void)
{
struct thread_info *tp, *next;
for (tp = thread_list; tp; tp = next)
{
next = tp->next;
if (!thread_alive (tp))
delete_thread (tp->ptid);
}
}
Calling thread_live on each thread one by one is expensive.
E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not
a big deal, but still a bunch of syscalls...
With the remote target, it's cumbersome. That thread_alive call ends
up generating one T packet per thread:
Sending packet: $Tp2141.2150#82...Packet received: OK
Sending packet: $Tp2141.214f#b7...Packet received: OK
Sending packet: $Tp2141.2141#82...Packet received: OK
Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n
That seems a bit silly when target_find_new_threads method
implementations will always fetch the whole current set of target
threads, and then add those that are not in GDB's thread list, to
GDB's thread list.
This patch thus pushes down the responsibility of pruning dead threads
to the target_find_new_threads method instead, so a target may
implement pruning dead threads however it wants.
Once we do that, target_find_new_threads becomes a misnomer, so the
patch renames it to target_update_thread_list.
The patch doesn't attempt to do any optimization to any target yet.
It simply exports prune_threads, and makes all implementations of
target_update_thread_list call that. It's meant to be a no-op.
gdb/
2014-10-15 Pedro Alves <palves@redhat.com>
* ada-tasks.c (print_ada_task_info, task_command_1): Adjust.
* bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ...
(bsd_uthread_update_thread_list): ... this. Call prune_threads.
(bsd_uthread_target): Adjust.
* corelow.c (core_open): Adjust.
* dec-thread.c (dec_thread_find_new_threads): Update comment.
(dec_thread_update_thread_list): New function.
(init_dec_thread_ops): Adjust.
* gdbthread.h (prune_threads): New declaration.
* linux-thread-db.c (thread_db_find_new_threads): Rename to ...
(thread_db_update_thread_list): ... this. Call prune_threads.
(init_thread_db_ops): Adjust.
* nto-procfs.c (procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
(procfs_attach, procfs_create_inferior, init_procfs_targets):
Adjust.
* obsd-nat.c (obsd_find_new_threads): Rename to ...
(obsd_update_thread_list): ... this. Call prune_threads.
(obsd_add_target): Adjust.
* procfs.c (procfs_target): Adjust.
(procfs_notice_thread): Update comment.
(procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
* ravenscar-thread.c (ravenscar_update_inferior_ptid): Update
comment.
(ravenscar_wait): Adjust.
(ravenscar_find_new_threads): Rename to ...
(ravenscar_update_thread_list): ... this. Call prune_threads.
(init_ravenscar_thread_ops): Adjust.
* record-btrace.c (record_btrace_find_new_threads): Rename to ...
(record_btrace_update_thread_list): ... this. Adjust comment.
(init_record_btrace_ops): Adjust.
* remote.c (remote_threads_info): Rename to ...
(remote_update_thread_list): ... this. Call prune_threads.
(remote_start_remote, extended_remote_attach_1, init_remote_ops):
Adjust.
* sol-thread.c (check_for_thread_db): Adjust.
(sol_find_new_threads_callback): Rename to ...
(sol_update_thread_list_callback): ... this.
(sol_find_new_threads): Rename to ...
(sol_update_thread_list): ... this. Call prune_threads. Adjust.
(sol_get_ada_task_ptid, init_sol_thread_ops): Adjust.
* target-delegates.c: Regenerate.
* target.c (target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* target.h (struct target_ops): Rename to_find_new_threads field
to to_update_thread_list.
(target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* thread.c (prune_threads): Make extern.
(update_thread_list): Adjust.
2014-10-16 05:44:00 +08:00
|
|
|
debug_update_thread_list (struct target_ops *self)
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
{
|
Push pruning old threads down to the target
When GDB wants to sync the thread list with the target's (e.g., due to
"info threads"), it calls update_thread_list:
update_thread_list (void)
{
prune_threads ();
target_find_new_threads ();
update_threads_executing ();
}
And then prune_threads does:
prune_threads (void)
{
struct thread_info *tp, *next;
for (tp = thread_list; tp; tp = next)
{
next = tp->next;
if (!thread_alive (tp))
delete_thread (tp->ptid);
}
}
Calling thread_live on each thread one by one is expensive.
E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not
a big deal, but still a bunch of syscalls...
With the remote target, it's cumbersome. That thread_alive call ends
up generating one T packet per thread:
Sending packet: $Tp2141.2150#82...Packet received: OK
Sending packet: $Tp2141.214f#b7...Packet received: OK
Sending packet: $Tp2141.2141#82...Packet received: OK
Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n
That seems a bit silly when target_find_new_threads method
implementations will always fetch the whole current set of target
threads, and then add those that are not in GDB's thread list, to
GDB's thread list.
This patch thus pushes down the responsibility of pruning dead threads
to the target_find_new_threads method instead, so a target may
implement pruning dead threads however it wants.
Once we do that, target_find_new_threads becomes a misnomer, so the
patch renames it to target_update_thread_list.
The patch doesn't attempt to do any optimization to any target yet.
It simply exports prune_threads, and makes all implementations of
target_update_thread_list call that. It's meant to be a no-op.
gdb/
2014-10-15 Pedro Alves <palves@redhat.com>
* ada-tasks.c (print_ada_task_info, task_command_1): Adjust.
* bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ...
(bsd_uthread_update_thread_list): ... this. Call prune_threads.
(bsd_uthread_target): Adjust.
* corelow.c (core_open): Adjust.
* dec-thread.c (dec_thread_find_new_threads): Update comment.
(dec_thread_update_thread_list): New function.
(init_dec_thread_ops): Adjust.
* gdbthread.h (prune_threads): New declaration.
* linux-thread-db.c (thread_db_find_new_threads): Rename to ...
(thread_db_update_thread_list): ... this. Call prune_threads.
(init_thread_db_ops): Adjust.
* nto-procfs.c (procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
(procfs_attach, procfs_create_inferior, init_procfs_targets):
Adjust.
* obsd-nat.c (obsd_find_new_threads): Rename to ...
(obsd_update_thread_list): ... this. Call prune_threads.
(obsd_add_target): Adjust.
* procfs.c (procfs_target): Adjust.
(procfs_notice_thread): Update comment.
(procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
* ravenscar-thread.c (ravenscar_update_inferior_ptid): Update
comment.
(ravenscar_wait): Adjust.
(ravenscar_find_new_threads): Rename to ...
(ravenscar_update_thread_list): ... this. Call prune_threads.
(init_ravenscar_thread_ops): Adjust.
* record-btrace.c (record_btrace_find_new_threads): Rename to ...
(record_btrace_update_thread_list): ... this. Adjust comment.
(init_record_btrace_ops): Adjust.
* remote.c (remote_threads_info): Rename to ...
(remote_update_thread_list): ... this. Call prune_threads.
(remote_start_remote, extended_remote_attach_1, init_remote_ops):
Adjust.
* sol-thread.c (check_for_thread_db): Adjust.
(sol_find_new_threads_callback): Rename to ...
(sol_update_thread_list_callback): ... this.
(sol_find_new_threads): Rename to ...
(sol_update_thread_list): ... this. Call prune_threads. Adjust.
(sol_get_ada_task_ptid, init_sol_thread_ops): Adjust.
* target-delegates.c: Regenerate.
* target.c (target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* target.h (struct target_ops): Rename to_find_new_threads field
to to_update_thread_list.
(target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* thread.c (prune_threads): Make extern.
(update_thread_list): Adjust.
2014-10-16 05:44:00 +08:00
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_update_thread_list (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_update_thread_list (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_update_thread_list (", debug_target.to_shortname);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:46:03 +08:00
|
|
|
static char *
|
|
|
|
delegate_pid_to_str (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_pid_to_str (self, arg1);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static char *
|
|
|
|
debug_pid_to_str (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
char * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_pid_to_str (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_pid_to_str (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_pid_to_str (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_char_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:48:36 +08:00
|
|
|
static char *
|
|
|
|
delegate_extra_thread_info (struct target_ops *self, struct thread_info *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_extra_thread_info (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
tdefault_extra_thread_info (struct target_ops *self, struct thread_info *arg1)
|
|
|
|
{
|
pass NULL to TARGET_DEFAULT_RETURN when appropriate
This changes instances of TARGET_DEFAULT_RETURN(0) to
TARGET_DEFAULT_RETURN(NULL) when appropriate. The use of "0" was a
relic from an earlier implementation of make-target-delegates; and I
didn't want to go back through the long patch series, fixing up
conflicts, just to change this small detail.
2014-02-19 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.h (struct target_ops) <to_extra_thread_info,
to_thread_name, to_pid_to_exec_file, to_get_section_table,
to_memory_map, to_read_description, to_traceframe_info>: Use NULL,
not 0, in TARGET_DEFAULT_RETURN.
2014-01-16 00:30:05 +08:00
|
|
|
return NULL;
|
2013-12-19 01:48:36 +08:00
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static char *
|
|
|
|
debug_extra_thread_info (struct target_ops *self, struct thread_info *arg1)
|
|
|
|
{
|
|
|
|
char * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_extra_thread_info (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_extra_thread_info (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_extra_thread_info (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_thread_info_p (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_char_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-11-26 22:49:03 +08:00
|
|
|
static const char *
|
2013-12-19 01:49:35 +08:00
|
|
|
delegate_thread_name (struct target_ops *self, struct thread_info *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_thread_name (self, arg1);
|
|
|
|
}
|
|
|
|
|
2015-11-26 22:49:03 +08:00
|
|
|
static const char *
|
2013-12-19 01:49:35 +08:00
|
|
|
tdefault_thread_name (struct target_ops *self, struct thread_info *arg1)
|
|
|
|
{
|
pass NULL to TARGET_DEFAULT_RETURN when appropriate
This changes instances of TARGET_DEFAULT_RETURN(0) to
TARGET_DEFAULT_RETURN(NULL) when appropriate. The use of "0" was a
relic from an earlier implementation of make-target-delegates; and I
didn't want to go back through the long patch series, fixing up
conflicts, just to change this small detail.
2014-02-19 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.h (struct target_ops) <to_extra_thread_info,
to_thread_name, to_pid_to_exec_file, to_get_section_table,
to_memory_map, to_read_description, to_traceframe_info>: Use NULL,
not 0, in TARGET_DEFAULT_RETURN.
2014-01-16 00:30:05 +08:00
|
|
|
return NULL;
|
2013-12-19 01:49:35 +08:00
|
|
|
}
|
|
|
|
|
2015-11-26 22:49:03 +08:00
|
|
|
static const char *
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
debug_thread_name (struct target_ops *self, struct thread_info *arg1)
|
|
|
|
{
|
2015-11-26 22:49:03 +08:00
|
|
|
const char * result;
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_thread_name (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_thread_name (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_thread_name (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_thread_info_p (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
2015-11-26 22:49:03 +08:00
|
|
|
target_debug_print_const_char_p (result);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:28:07 +08:00
|
|
|
static void
|
|
|
|
delegate_stop (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_stop (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_stop (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_stop (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_stop (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_stop (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_stop (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
Fix interrupt-noterm.exp on targets always in non-stop
With "maint set target-non-stop on" we get:
@@ -66,13 +66,16 @@ Continuing.
interrupt
(gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt
-Program received signal SIGINT, Interrupt.
-PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT
-testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds
+[process 12119] #1 stopped.
+0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81
+81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
+FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout)
+testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds
That is, we get "[$thread] #1 stopped" instead of SIGINT.
The issue is that we don't currently distinguish send
"interrupt/ctrl-c" to target terminal vs "stop/pause" thread well;
both cases go through "target_stop".
And then, the native Linux backend (linux-nat.c) implements
target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop
mode. Since "maint set target-non-stop on" forces the backend to be
always running in non-stop mode, even though the user-visible behavior
is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of
the SIGINT the test expects.
Fix this by introducing a target_interrupt method to use in the
"interrupt/ctrl-c" case, so "set non-stop off" can always work the
same irrespective of "maint set target-non-stop on/off". I'm
explictly considering changing the "set non-stop on" behavior as out
of scope here.
Most of the patch is an across-the-board rename of to_stop hook
implementations to to_interrupt. The only targets where something
more than a rename is being done are linux-nat.c and remote.c, which
are the only targets that support async, and thus are the only ones
the core side calls target_stop on.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_stop): Rename to ...
(darwin_interrupt): ... this.
(_initialize_darwin_inferior): Adjust.
* gnu-nat.c (gnu_stop): Delete.
(gnu_target): Don't install gnu_stop.
* inf-ptrace.c (inf_ptrace_stop): Rename to ...
(inf_ptrace_interrupt): ... this.
(inf_ptrace_target): Adjust.
* infcmd.c (interrupt_target_1): Use target_interrupt instead of
target_stop.
* linux-nat (linux_nat_stop): Rename to ...
(linux_nat_interrupt): ... this.
(linux_nat_stop): Reimplement.
(linux_nat_add_target): Install linux_nat_interrupt.
* nto-procfs.c (nto_interrupt_twice): Rename to ...
(nto_handle_sigint_twice): ... this.
(nto_interrupt): Rename to ...
(nto_handle_sigint): ... this. Call target_interrupt instead of
target_stop.
(procfs_wait): Adjust.
(procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(init_procfs_targets): Adjust.
* procfs.c (procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(procfs_target): Adjust.
* remote-m32r-sdi.c (m32r_stop): Rename to ...
(m32r_interrupt): ... this.
(init_m32r_ops): Adjust.
* remote-sim.c (gdbsim_stop_inferior): Rename to ...
(gdbsim_interrupt_inferior): ... this.
(gdbsim_stop): Rename to ...
(gdbsim_interrupt): ... this.
(gdbsim_cntrl_c): Adjust.
(init_gdbsim_ops): Adjust.
* remote.c (sync_remote_interrupt): Adjust comments.
(remote_stop_as): Rename to ...
(remote_interrupt_as): ... this.
(remote_stop): Adjust comment.
(remote_interrupt): New function.
(init_remote_ops): Install remote_interrupt.
* target.c (target_interrupt): New function.
* target.h (struct target_ops) <to_interrupt>: New field.
(target_interrupt): New declaration.
* windows-nat.c (windows_stop): Rename to ...
(windows_interrupt): ... this.
* target-delegates.c: Regenerate.
2015-08-07 01:22:58 +08:00
|
|
|
static void
|
|
|
|
delegate_interrupt (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_interrupt (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_interrupt (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
debug_interrupt (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_interrupt (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_interrupt (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_interrupt (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
remote: allow aborting long operations (e.g., file transfers)
Currently, when remote debugging, if you type Ctrl-C just while the
target stopped for an internal event, and GDB is busy doing something
that takes a while (e.g., fetching chunks of a shared library off of
the target, with vFile, to process ELF headers and debug info), the
Ctrl-C is lost.
The patch hooks up the QUIT macro to a new target method that lets the
target react to the double-Ctrl-C before the event loop is reached,
which allows reacting to a double-Ctrl-C even when GDB is busy doing
some long operation and not waiting for a stop reply. That end result
is:
(gdb) c
Continuing.
^C
^C
Interrupted while waiting for the program.
Give up waiting? (y or n) y
Quit
(gdb) info threads
Id Target Id Frame
* 1 Thread 11673 0x00007ffff7deb240 in _dl_debug_state () from target:/lib64/ld-linux-x86-64.so.2
(gdb)
If, however, GDB is waiting for a stop reply (because the target has
been resumed, with e.g., vCont;c), but the target isn't responding, we
now get:
(gdb) c
Continuing.
^C
^C
The target is not responding to interrupt requests.
Stop debugging it? (y or n) y
Disconnected from target.
(gdb) info threads
No threads.
This offers to disconnect, because when we're waiting for a stop
reply, there's nothing else we can send the target other than an
interrupt request. And if that doesn't work, there's nothing else we
can do.
The Ctrl-C is presently lost because until we get to a user-visible
stop, the SIGINT handler that is installed is the one that forwards
the interrupt to the remote side, with the \003 "packet" [1]. But,
gdbserver ignores an interrupt request if the program is stopped.
Still, even if it didn't, the server can only report back a
stop-because-of-SIGINT when the program is next resumed. And it may
take a while to actually re-resume the target.
[1] - In the old sync days, the remote target would react to a
double-Ctrl-C by asking users whether they wanted to give up waiting
and disconnect. The code is still there, but it it isn't reacheable
on most hosts, which support serial connections in async mode
(probably only DJGPP doesn't). Even then, in sync mode, remote.c's
SIGINT handler is only installed while the target is resumed, and is
removed as soon as the target sends back a stop reply. That means
that a Ctrl-C just while GDB is processing an internal event can end
up with an odd "Quit" at the prompt instead of "Program stopped by
SIGINT". In contrast, in async mode, remote.c's SIGINT handler is set
up as long as target_terminal_inferior or
target_terminal_ours_for_output are in effect (IOW, until we get a
user-visible stop and call target_terminal_ours), so the user
shouldn't get back a spurious Quit. However, it's still desirable to
be able to interrupt a long-running GDB operation, if GDB takes a
while to re-resume the target or get back to the event loop.
Tested on x86_64 Fedora 20.
gdb/ChangeLog:
2015-08-24 Pedro Alves <palves@redhat.com>
* defs.h (maybe_quit): Declare.
(QUIT): Now calls maybe_quit.
* event-loop.c (clear_async_signal_handler)
(async_signal_handler_is_marked): New functions.
* event-loop.h (async_signal_handler_is_marked)
(clear_async_signal_handler): New declarations.
* remote.c (remote_check_pending_interrupt): New function.
(interrupt_query): Use make_cleanup_restore_target_terminal. No
longer check whether the target is async. If waiting for a stop
reply, and a Ctrl-C as been sent to the target, offer to
disconnect, and throw TARGET_CLOSE_ERROR instead of a quit.
Otherwise do not disconnect and throw a quit.
(_initialize_remote): Install remote_check_pending_interrupt as
to_check_pending_interrupt.
* target.c (target_check_pending_interrupt): New function.
* target.h (struct target_ops) <to_check_pending_interrupt>: New
field.
(target_check_pending_interrupt): New declaration.
* utils.c (maybe_quit): New function.
* target-delegates.c: Regenerate.
2015-08-25 23:12:11 +08:00
|
|
|
static void
|
|
|
|
delegate_check_pending_interrupt (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_check_pending_interrupt (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_check_pending_interrupt (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
debug_check_pending_interrupt (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_check_pending_interrupt (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_check_pending_interrupt (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_check_pending_interrupt (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 00:35:21 +08:00
|
|
|
static void
|
2014-06-07 03:19:53 +08:00
|
|
|
delegate_rcmd (struct target_ops *self, const char *arg1, struct ui_file *arg2)
|
2013-12-19 00:35:21 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_rcmd (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_rcmd (struct target_ops *self, const char *arg1, struct ui_file *arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_rcmd (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_rcmd (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_rcmd (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_ui_file_p (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:51:10 +08:00
|
|
|
static char *
|
|
|
|
delegate_pid_to_exec_file (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_pid_to_exec_file (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
tdefault_pid_to_exec_file (struct target_ops *self, int arg1)
|
|
|
|
{
|
pass NULL to TARGET_DEFAULT_RETURN when appropriate
This changes instances of TARGET_DEFAULT_RETURN(0) to
TARGET_DEFAULT_RETURN(NULL) when appropriate. The use of "0" was a
relic from an earlier implementation of make-target-delegates; and I
didn't want to go back through the long patch series, fixing up
conflicts, just to change this small detail.
2014-02-19 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.h (struct target_ops) <to_extra_thread_info,
to_thread_name, to_pid_to_exec_file, to_get_section_table,
to_memory_map, to_read_description, to_traceframe_info>: Use NULL,
not 0, in TARGET_DEFAULT_RETURN.
2014-01-16 00:30:05 +08:00
|
|
|
return NULL;
|
2013-12-19 01:51:10 +08:00
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static char *
|
|
|
|
debug_pid_to_exec_file (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
char * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_pid_to_exec_file (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_pid_to_exec_file (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_pid_to_exec_file (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_char_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:52:58 +08:00
|
|
|
static void
|
|
|
|
delegate_log_command (struct target_ops *self, const char *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_log_command (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_log_command (struct target_ops *self, const char *arg1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_log_command (struct target_ops *self, const char *arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_log_command (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_log_command (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_log_command (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:47:06 +08:00
|
|
|
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)
|
|
|
|
{
|
pass NULL to TARGET_DEFAULT_RETURN when appropriate
This changes instances of TARGET_DEFAULT_RETURN(0) to
TARGET_DEFAULT_RETURN(NULL) when appropriate. The use of "0" was a
relic from an earlier implementation of make-target-delegates; and I
didn't want to go back through the long patch series, fixing up
conflicts, just to change this small detail.
2014-02-19 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.h (struct target_ops) <to_extra_thread_info,
to_thread_name, to_pid_to_exec_file, to_get_section_table,
to_memory_map, to_read_description, to_traceframe_info>: Use NULL,
not 0, in TARGET_DEFAULT_RETURN.
2014-01-16 00:30:05 +08:00
|
|
|
return NULL;
|
2013-12-19 05:47:06 +08:00
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static struct target_section_table *
|
|
|
|
debug_get_section_table (struct target_ops *self)
|
|
|
|
{
|
|
|
|
struct target_section_table * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_section_table (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_get_section_table (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_section_table (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_target_section_table_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
static int
|
|
|
|
delegate_can_async_p (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_can_async_p (self);
|
|
|
|
}
|
|
|
|
|
fix regressions with target-async
A patch in the target cleanup series caused a regression when using
record with target-async. Version 4 of the patch is here:
https://sourceware.org/ml/gdb-patches/2014-03/msg00159.html
The immediate problem is that record supplies to_can_async_p and
to_is_async_p methods, but does not supply a to_async method. So,
when target-async is set, record claims to support async -- but if the
underlying target does not support async, then the to_async method
call will end up in that method's default implementation, namely
tcomplain.
This worked previously because the record target used to provide a
to_async method; one that (erroneously, only at push time) checked the
other members of the target stack, and then simply dropped to_async
calls in the "does not implement async" case.
My first thought was to simply drop tcomplain as the default for
to_async. This works, but Pedro pointed out that the only reason
record has to supply to_can_async_p and to_is_async_p is that these
default to using the find_default_run_target machinery -- and these
defaults are only needed by "run" and "attach".
So, a nicer solution presents itself: change run and attach to
explicitly call into the default run target when needed; and change
to_is_async_p and to_can_async_p to default to "return 0". This makes
the target stack simpler to use and lets us remove the method
implementations from record. This is also in harmony with other plans
for the target stack; namely trying to reduce the impact of
find_default_run_target. This approach makes it clear that
find_default_is_async_p is not needed -- it is asking whether a target
that may not even be pushed is actually async, which seems like a
nonsensical question.
While an improvement, this approach proved to introduce the same bug
when using the core target. Looking a bit deeper, the issue is that
code in "attach" and "run" may need to use either the current target
stack or the default run target -- but different calls into the target
API in those functions could wind up querying different targets.
This new patch makes the target to use more explicit in "run" and
"attach". Then these commands explicitly make the needed calls
against that target. This ensures that a single target is used for
all relevant operations. This lets us remove a couple find_default_*
functions from various targets, including the dummy target. I think
this is a decent understandability improvement.
One issue I see with this patch is that the new calls in "run" and
"attach" are not very much like the rest of the target API. I think
fundamentally this is due to bad factoring in the target API, which
may need to be fixed for multi-target. Tackling that seemed ambitious
for a regression fix.
While working on this I noticed that there don't seem to be any test
cases that involve both target-async and record, so this patch changes
break-precsave.exp to add some. It also changes corefile.exp to add
some target-async tests; these pass with current trunk and with this
patch applied, but fail with the v1 patch.
This patch differs from v4 in that it moves initialization of
to_can_async_p and to_supports_non_stop into inf-child, adds some
assertions to complete_target_initialization, and adds some comments
to target.h.
Built and regtested on x86-64 Fedora 20.
2014-03-12 Tom Tromey <tromey@redhat.com>
* inf-child.c (return_zero): New function.
(inf_child_target): Set to_can_async_p, to_supports_non_stop.
* aix-thread.c (aix_thread_inferior_created): New function.
(aix_thread_attach): Remove.
(init_aix_thread_ops): Don't set to_attach.
(_initialize_aix_thread): Register inferior_created observer.
* corelow.c (init_core_ops): Don't set to_attach or
to_create_inferior.
* exec.c (init_exec_ops): Don't set to_attach or
to_create_inferior.
* infcmd.c (run_command_1): Use find_run_target. Make direct
target calls.
(attach_command): Use find_attach_target. Make direct target
calls.
* record-btrace.c (init_record_btrace_ops): Don't set
to_create_inferior.
* record-full.c (record_full_can_async_p, record_full_is_async_p):
Remove.
(init_record_full_ops, init_record_full_core_ops): Update. Don't
set to_create_inferior.
* target.c (complete_target_initialization): Add assertion.
(target_create_inferior): Remove.
(find_default_attach, find_default_create_inferior): Remove.
(find_attach_target, find_run_target): New functions.
(find_default_is_async_p, find_default_can_async_p)
(target_supports_non_stop, target_attach): Remove.
(init_dummy_target): Don't set to_create_inferior or
to_supports_non_stop.
* target.h (struct target_ops) <to_attach>: Add comment. Remove
TARGET_DEFAULT_FUNC.
<to_create_inferior>: Add comment.
<to_can_async_p, to_is_async_p, to_supports_non_stop>: Use
TARGET_DEFAULT_RETURN.
<to_can_async_p, to_supports_non_stop, to_can_run>: Add comments.
(find_attach_target, find_run_target): Declare.
(target_create_inferior): Remove.
(target_has_execution_1): Update comment.
(target_supports_non_stop): Remove.
* target-delegates.c: Rebuild.
2014-03-12 Tom Tromey <tromey@redhat.com>
* gdb.base/corefile.exp (corefile_test_run, corefile_test_attach):
New procs. Add target-async tests.
* gdb.reverse/break-precsave.exp (precsave_tests): New proc.
Add target-async tests.
2014-03-01 00:47:34 +08:00
|
|
|
static int
|
|
|
|
tdefault_can_async_p (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_can_async_p (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_can_async_p (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_can_async_p (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_can_async_p (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
static int
|
|
|
|
delegate_is_async_p (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_is_async_p (self);
|
|
|
|
}
|
|
|
|
|
fix regressions with target-async
A patch in the target cleanup series caused a regression when using
record with target-async. Version 4 of the patch is here:
https://sourceware.org/ml/gdb-patches/2014-03/msg00159.html
The immediate problem is that record supplies to_can_async_p and
to_is_async_p methods, but does not supply a to_async method. So,
when target-async is set, record claims to support async -- but if the
underlying target does not support async, then the to_async method
call will end up in that method's default implementation, namely
tcomplain.
This worked previously because the record target used to provide a
to_async method; one that (erroneously, only at push time) checked the
other members of the target stack, and then simply dropped to_async
calls in the "does not implement async" case.
My first thought was to simply drop tcomplain as the default for
to_async. This works, but Pedro pointed out that the only reason
record has to supply to_can_async_p and to_is_async_p is that these
default to using the find_default_run_target machinery -- and these
defaults are only needed by "run" and "attach".
So, a nicer solution presents itself: change run and attach to
explicitly call into the default run target when needed; and change
to_is_async_p and to_can_async_p to default to "return 0". This makes
the target stack simpler to use and lets us remove the method
implementations from record. This is also in harmony with other plans
for the target stack; namely trying to reduce the impact of
find_default_run_target. This approach makes it clear that
find_default_is_async_p is not needed -- it is asking whether a target
that may not even be pushed is actually async, which seems like a
nonsensical question.
While an improvement, this approach proved to introduce the same bug
when using the core target. Looking a bit deeper, the issue is that
code in "attach" and "run" may need to use either the current target
stack or the default run target -- but different calls into the target
API in those functions could wind up querying different targets.
This new patch makes the target to use more explicit in "run" and
"attach". Then these commands explicitly make the needed calls
against that target. This ensures that a single target is used for
all relevant operations. This lets us remove a couple find_default_*
functions from various targets, including the dummy target. I think
this is a decent understandability improvement.
One issue I see with this patch is that the new calls in "run" and
"attach" are not very much like the rest of the target API. I think
fundamentally this is due to bad factoring in the target API, which
may need to be fixed for multi-target. Tackling that seemed ambitious
for a regression fix.
While working on this I noticed that there don't seem to be any test
cases that involve both target-async and record, so this patch changes
break-precsave.exp to add some. It also changes corefile.exp to add
some target-async tests; these pass with current trunk and with this
patch applied, but fail with the v1 patch.
This patch differs from v4 in that it moves initialization of
to_can_async_p and to_supports_non_stop into inf-child, adds some
assertions to complete_target_initialization, and adds some comments
to target.h.
Built and regtested on x86-64 Fedora 20.
2014-03-12 Tom Tromey <tromey@redhat.com>
* inf-child.c (return_zero): New function.
(inf_child_target): Set to_can_async_p, to_supports_non_stop.
* aix-thread.c (aix_thread_inferior_created): New function.
(aix_thread_attach): Remove.
(init_aix_thread_ops): Don't set to_attach.
(_initialize_aix_thread): Register inferior_created observer.
* corelow.c (init_core_ops): Don't set to_attach or
to_create_inferior.
* exec.c (init_exec_ops): Don't set to_attach or
to_create_inferior.
* infcmd.c (run_command_1): Use find_run_target. Make direct
target calls.
(attach_command): Use find_attach_target. Make direct target
calls.
* record-btrace.c (init_record_btrace_ops): Don't set
to_create_inferior.
* record-full.c (record_full_can_async_p, record_full_is_async_p):
Remove.
(init_record_full_ops, init_record_full_core_ops): Update. Don't
set to_create_inferior.
* target.c (complete_target_initialization): Add assertion.
(target_create_inferior): Remove.
(find_default_attach, find_default_create_inferior): Remove.
(find_attach_target, find_run_target): New functions.
(find_default_is_async_p, find_default_can_async_p)
(target_supports_non_stop, target_attach): Remove.
(init_dummy_target): Don't set to_create_inferior or
to_supports_non_stop.
* target.h (struct target_ops) <to_attach>: Add comment. Remove
TARGET_DEFAULT_FUNC.
<to_create_inferior>: Add comment.
<to_can_async_p, to_is_async_p, to_supports_non_stop>: Use
TARGET_DEFAULT_RETURN.
<to_can_async_p, to_supports_non_stop, to_can_run>: Add comments.
(find_attach_target, find_run_target): Declare.
(target_create_inferior): Remove.
(target_has_execution_1): Update comment.
(target_supports_non_stop): Remove.
* target-delegates.c: Rebuild.
2014-03-12 Tom Tromey <tromey@redhat.com>
* gdb.base/corefile.exp (corefile_test_run, corefile_test_attach):
New procs. Add target-async tests.
* gdb.reverse/break-precsave.exp (precsave_tests): New proc.
Add target-async tests.
2014-03-01 00:47:34 +08:00
|
|
|
static int
|
|
|
|
tdefault_is_async_p (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_is_async_p (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_is_async_p (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_is_async_p (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_is_async_p (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
static void
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 19:28:31 +08:00
|
|
|
delegate_async (struct target_ops *self, int arg1)
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 19:28:31 +08:00
|
|
|
self->to_async (self, arg1);
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 19:28:31 +08:00
|
|
|
tdefault_async (struct target_ops *self, int arg1)
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 19:28:31 +08:00
|
|
|
debug_async (struct target_ops *self, int arg1)
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_async (...)\n", debug_target.to_shortname);
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 19:28:31 +08:00
|
|
|
debug_target.to_async (&debug_target, arg1);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_async (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
Simplify target_async hook interface
All callers of target_async pass it the same callback
(inferior_event_handler). Since both common code and target backends
need to be able to put the target in and out of target async mode at
any given time, there's really no way that a different callback could
be passed. This commit simplifies things, and removes the indirection
altogether. Bonus: with this, gdb's target_async method ends up with
the same signature as gdbserver's.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2015-03-25 Pedro Alves <palves@redhat.com>
* target.h <to_async>: Replace 'callback' and 'context' parameters
with boolean 'enable' parameter.
(target_async): Replace CALLBACK and CONTEXT parameters with
boolean ENABLE parameter.
* inf-loop.c (inferior_event_handler): Adjust.
* linux-nat.c (linux_nat_attach, linux_nat_resume)
(linux_nat_resume): Adjust.
(async_client_callback, async_client_context): Delete.
(handle_target_event): Call inferior_event_handler directly.
(linux_nat_async): Replace 'callback' and 'context' parameters
with boolean 'enable' parameter. Adjust. Remove references to
async_client_callback and async_client_context.
(linux_nat_close): Adjust.
* record-btrace.c (record_btrace_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_btrace_resume): Adjust.
* record-full.c (record_full_async): Replace 'callback' and
'context' parameters with boolean 'enable' parameter. Adjust.
(record_full_resume, record_full_core_resume): Adjust.
* remote.c (struct remote_state) <async_client_callback,
async_client_context>: Delete fields.
(remote_start_remote, extended_remote_attach_1, remote_resume)
(extended_remote_create_inferior): Adjust.
(remote_async_serial_handler): Call inferior_event_handler
directly.
(remote_async): Replace 'callback' and 'context' parameters with
boolean 'enable' parameter. Adjust.
* top.c (gdb_readline_wrapper_cleanup, gdb_readline_wrapper):
Adjust.
* target-delegates.c: Regenerate.
2015-03-25 19:28:31 +08:00
|
|
|
target_debug_print_int (arg1);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
fix regressions with target-async
A patch in the target cleanup series caused a regression when using
record with target-async. Version 4 of the patch is here:
https://sourceware.org/ml/gdb-patches/2014-03/msg00159.html
The immediate problem is that record supplies to_can_async_p and
to_is_async_p methods, but does not supply a to_async method. So,
when target-async is set, record claims to support async -- but if the
underlying target does not support async, then the to_async method
call will end up in that method's default implementation, namely
tcomplain.
This worked previously because the record target used to provide a
to_async method; one that (erroneously, only at push time) checked the
other members of the target stack, and then simply dropped to_async
calls in the "does not implement async" case.
My first thought was to simply drop tcomplain as the default for
to_async. This works, but Pedro pointed out that the only reason
record has to supply to_can_async_p and to_is_async_p is that these
default to using the find_default_run_target machinery -- and these
defaults are only needed by "run" and "attach".
So, a nicer solution presents itself: change run and attach to
explicitly call into the default run target when needed; and change
to_is_async_p and to_can_async_p to default to "return 0". This makes
the target stack simpler to use and lets us remove the method
implementations from record. This is also in harmony with other plans
for the target stack; namely trying to reduce the impact of
find_default_run_target. This approach makes it clear that
find_default_is_async_p is not needed -- it is asking whether a target
that may not even be pushed is actually async, which seems like a
nonsensical question.
While an improvement, this approach proved to introduce the same bug
when using the core target. Looking a bit deeper, the issue is that
code in "attach" and "run" may need to use either the current target
stack or the default run target -- but different calls into the target
API in those functions could wind up querying different targets.
This new patch makes the target to use more explicit in "run" and
"attach". Then these commands explicitly make the needed calls
against that target. This ensures that a single target is used for
all relevant operations. This lets us remove a couple find_default_*
functions from various targets, including the dummy target. I think
this is a decent understandability improvement.
One issue I see with this patch is that the new calls in "run" and
"attach" are not very much like the rest of the target API. I think
fundamentally this is due to bad factoring in the target API, which
may need to be fixed for multi-target. Tackling that seemed ambitious
for a regression fix.
While working on this I noticed that there don't seem to be any test
cases that involve both target-async and record, so this patch changes
break-precsave.exp to add some. It also changes corefile.exp to add
some target-async tests; these pass with current trunk and with this
patch applied, but fail with the v1 patch.
This patch differs from v4 in that it moves initialization of
to_can_async_p and to_supports_non_stop into inf-child, adds some
assertions to complete_target_initialization, and adds some comments
to target.h.
Built and regtested on x86-64 Fedora 20.
2014-03-12 Tom Tromey <tromey@redhat.com>
* inf-child.c (return_zero): New function.
(inf_child_target): Set to_can_async_p, to_supports_non_stop.
* aix-thread.c (aix_thread_inferior_created): New function.
(aix_thread_attach): Remove.
(init_aix_thread_ops): Don't set to_attach.
(_initialize_aix_thread): Register inferior_created observer.
* corelow.c (init_core_ops): Don't set to_attach or
to_create_inferior.
* exec.c (init_exec_ops): Don't set to_attach or
to_create_inferior.
* infcmd.c (run_command_1): Use find_run_target. Make direct
target calls.
(attach_command): Use find_attach_target. Make direct target
calls.
* record-btrace.c (init_record_btrace_ops): Don't set
to_create_inferior.
* record-full.c (record_full_can_async_p, record_full_is_async_p):
Remove.
(init_record_full_ops, init_record_full_core_ops): Update. Don't
set to_create_inferior.
* target.c (complete_target_initialization): Add assertion.
(target_create_inferior): Remove.
(find_default_attach, find_default_create_inferior): Remove.
(find_attach_target, find_run_target): New functions.
(find_default_is_async_p, find_default_can_async_p)
(target_supports_non_stop, target_attach): Remove.
(init_dummy_target): Don't set to_create_inferior or
to_supports_non_stop.
* target.h (struct target_ops) <to_attach>: Add comment. Remove
TARGET_DEFAULT_FUNC.
<to_create_inferior>: Add comment.
<to_can_async_p, to_is_async_p, to_supports_non_stop>: Use
TARGET_DEFAULT_RETURN.
<to_can_async_p, to_supports_non_stop, to_can_run>: Add comments.
(find_attach_target, find_run_target): Declare.
(target_create_inferior): Remove.
(target_has_execution_1): Update comment.
(target_supports_non_stop): Remove.
* target-delegates.c: Rebuild.
2014-03-12 Tom Tromey <tromey@redhat.com>
* gdb.base/corefile.exp (corefile_test_run, corefile_test_attach):
New procs. Add target-async tests.
* gdb.reverse/break-precsave.exp (precsave_tests): New proc.
Add target-async tests.
2014-03-01 00:47:34 +08:00
|
|
|
static int
|
|
|
|
delegate_supports_non_stop (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_supports_non_stop (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_supports_non_stop (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_supports_non_stop (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_supports_non_stop (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_supports_non_stop (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_supports_non_stop (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-08 00:24:01 +08:00
|
|
|
static int
|
|
|
|
delegate_always_non_stop_p (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_always_non_stop_p (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_always_non_stop_p (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
debug_always_non_stop_p (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_always_non_stop_p (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_always_non_stop_p (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_always_non_stop_p (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 01:55:34 +08:00
|
|
|
static int
|
|
|
|
delegate_find_memory_regions (struct target_ops *self, find_memory_region_ftype arg1, void *arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_find_memory_regions (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_find_memory_regions (struct target_ops *self, find_memory_region_ftype arg1, void *arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_find_memory_regions (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_find_memory_regions (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_find_memory_regions (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_find_memory_region_ftype (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_void_p (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-07-16 02:08:54 +08:00
|
|
|
static char *
|
2013-12-19 01:57:18 +08:00
|
|
|
delegate_make_corefile_notes (struct target_ops *self, bfd *arg1, int *arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_make_corefile_notes (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static char *
|
|
|
|
debug_make_corefile_notes (struct target_ops *self, bfd *arg1, int *arg2)
|
|
|
|
{
|
|
|
|
char * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_make_corefile_notes (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_make_corefile_notes (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_make_corefile_notes (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_bfd_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int_p (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_char_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-07-16 02:08:54 +08:00
|
|
|
static gdb_byte *
|
2013-04-15 22:59:03 +08:00
|
|
|
delegate_get_bookmark (struct target_ops *self, const char *arg1, int arg2)
|
2013-12-19 02:10:32 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_get_bookmark (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
2014-07-16 02:08:54 +08:00
|
|
|
static gdb_byte *
|
2013-04-15 22:59:03 +08:00
|
|
|
tdefault_get_bookmark (struct target_ops *self, const char *arg1, int arg2)
|
2013-12-19 02:10:32 +08:00
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static gdb_byte *
|
|
|
|
debug_get_bookmark (struct target_ops *self, const char *arg1, int arg2)
|
|
|
|
{
|
|
|
|
gdb_byte * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_bookmark (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_get_bookmark (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_bookmark (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_gdb_byte_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 02:11:25 +08:00
|
|
|
static void
|
2013-04-15 22:59:03 +08:00
|
|
|
delegate_goto_bookmark (struct target_ops *self, const gdb_byte *arg1, int arg2)
|
2013-12-19 02:11:25 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_goto_bookmark (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-15 22:59:03 +08:00
|
|
|
tdefault_goto_bookmark (struct target_ops *self, const gdb_byte *arg1, int arg2)
|
2013-12-19 02:11:25 +08:00
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_goto_bookmark (struct target_ops *self, const gdb_byte *arg1, int arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_goto_bookmark (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_goto_bookmark (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_goto_bookmark (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_gdb_byte_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2014-06-26 00:16:55 +08:00
|
|
|
static CORE_ADDR
|
|
|
|
delegate_get_thread_local_address (struct target_ops *self, ptid_t arg1, CORE_ADDR arg2, CORE_ADDR arg3)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_get_thread_local_address (self, arg1, arg2, arg3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
tdefault_get_thread_local_address (struct target_ops *self, ptid_t arg1, CORE_ADDR arg2, CORE_ADDR arg3)
|
|
|
|
{
|
|
|
|
generic_tls_error ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static CORE_ADDR
|
|
|
|
debug_get_thread_local_address (struct target_ops *self, ptid_t arg1, CORE_ADDR arg2, CORE_ADDR arg3)
|
|
|
|
{
|
|
|
|
CORE_ADDR result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_thread_local_address (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_get_thread_local_address (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_thread_local_address (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg3);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-07-16 02:08:54 +08:00
|
|
|
static enum target_xfer_status
|
|
|
|
delegate_xfer_partial (struct target_ops *self, enum target_object arg1, const char *arg2, gdb_byte *arg3, const gdb_byte *arg4, ULONGEST arg5, ULONGEST arg6, ULONGEST *arg7)
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_xfer_partial (self, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
|
|
|
|
}
|
|
|
|
|
2014-07-16 02:08:54 +08:00
|
|
|
static enum target_xfer_status
|
|
|
|
tdefault_xfer_partial (struct target_ops *self, enum target_object arg1, const char *arg2, gdb_byte *arg3, const gdb_byte *arg4, ULONGEST arg5, ULONGEST arg6, ULONGEST *arg7)
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
{
|
|
|
|
return TARGET_XFER_E_IO;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static enum target_xfer_status
|
|
|
|
debug_xfer_partial (struct target_ops *self, enum target_object arg1, const char *arg2, gdb_byte *arg3, const gdb_byte *arg4, ULONGEST arg5, ULONGEST arg6, ULONGEST *arg7)
|
|
|
|
{
|
|
|
|
enum target_xfer_status result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_xfer_partial (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_xfer_partial (&debug_target, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_xfer_partial (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_enum_target_object (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_gdb_byte_p (arg3);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_gdb_byte_p (arg4);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg5);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg6);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST_p (arg7);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_enum_target_xfer_status (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 22:47:11 +08:00
|
|
|
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)
|
|
|
|
{
|
pass NULL to TARGET_DEFAULT_RETURN when appropriate
This changes instances of TARGET_DEFAULT_RETURN(0) to
TARGET_DEFAULT_RETURN(NULL) when appropriate. The use of "0" was a
relic from an earlier implementation of make-target-delegates; and I
didn't want to go back through the long patch series, fixing up
conflicts, just to change this small detail.
2014-02-19 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.h (struct target_ops) <to_extra_thread_info,
to_thread_name, to_pid_to_exec_file, to_get_section_table,
to_memory_map, to_read_description, to_traceframe_info>: Use NULL,
not 0, in TARGET_DEFAULT_RETURN.
2014-01-16 00:30:05 +08:00
|
|
|
return NULL;
|
2013-12-19 22:47:11 +08:00
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static VEC(mem_region_s) *
|
|
|
|
debug_memory_map (struct target_ops *self)
|
|
|
|
{
|
|
|
|
VEC(mem_region_s) * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_memory_map (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_memory_map (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_memory_map (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_VEC_mem_region_s__p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:50:56 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_flash_erase (struct target_ops *self, ULONGEST arg1, LONGEST arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_flash_erase (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_flash_erase (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_flash_erase (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_LONGEST (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:02 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_flash_done (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_flash_done (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_flash_done (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_flash_done (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2014-01-14 00:30:30 +08:00
|
|
|
static const struct target_desc *
|
|
|
|
delegate_read_description (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_read_description (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct target_desc *
|
|
|
|
tdefault_read_description (struct target_ops *self)
|
|
|
|
{
|
pass NULL to TARGET_DEFAULT_RETURN when appropriate
This changes instances of TARGET_DEFAULT_RETURN(0) to
TARGET_DEFAULT_RETURN(NULL) when appropriate. The use of "0" was a
relic from an earlier implementation of make-target-delegates; and I
didn't want to go back through the long patch series, fixing up
conflicts, just to change this small detail.
2014-02-19 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
* target.h (struct target_ops) <to_extra_thread_info,
to_thread_name, to_pid_to_exec_file, to_get_section_table,
to_memory_map, to_read_description, to_traceframe_info>: Use NULL,
not 0, in TARGET_DEFAULT_RETURN.
2014-01-16 00:30:05 +08:00
|
|
|
return NULL;
|
2014-01-14 00:30:30 +08:00
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static const struct target_desc *
|
|
|
|
debug_read_description (struct target_ops *self)
|
|
|
|
{
|
|
|
|
const struct target_desc * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_read_description (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_read_description (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_read_description (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_const_struct_target_desc_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 04:53:09 +08:00
|
|
|
static ptid_t
|
|
|
|
delegate_get_ada_task_ptid (struct target_ops *self, long arg1, long arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_get_ada_task_ptid (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static ptid_t
|
|
|
|
debug_get_ada_task_ptid (struct target_ops *self, long arg1, long arg2)
|
|
|
|
{
|
|
|
|
ptid_t result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_ada_task_ptid (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_get_ada_task_ptid (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_ada_task_ptid (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_long (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_long (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 22:56:20 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_auxv_parse (struct target_ops *self, gdb_byte **arg1, gdb_byte *arg2, CORE_ADDR *arg3, CORE_ADDR *arg4)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_auxv_parse (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_auxv_parse (&debug_target, arg1, arg2, arg3, arg4);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_auxv_parse (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_gdb_byte_pp (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_gdb_byte_p (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR_p (arg3);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR_p (arg4);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 23:12:26 +08:00
|
|
|
static int
|
|
|
|
delegate_search_memory (struct target_ops *self, CORE_ADDR arg1, ULONGEST arg2, const gdb_byte *arg3, ULONGEST arg4, CORE_ADDR *arg5)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_search_memory (self, arg1, arg2, arg3, arg4, arg5);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_search_memory (struct target_ops *self, CORE_ADDR arg1, ULONGEST arg2, const gdb_byte *arg3, ULONGEST arg4, CORE_ADDR *arg5)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_search_memory (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_search_memory (&debug_target, arg1, arg2, arg3, arg4, arg5);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_search_memory (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_gdb_byte_p (arg3);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg4);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR_p (arg5);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 02:12:28 +08:00
|
|
|
static int
|
|
|
|
delegate_can_execute_reverse (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_can_execute_reverse (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_can_execute_reverse (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_can_execute_reverse (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_can_execute_reverse (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_can_execute_reverse (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_can_execute_reverse (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-07-16 02:08:54 +08:00
|
|
|
static enum exec_direction_kind
|
2013-12-19 02:15:21 +08:00
|
|
|
delegate_execution_direction (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_execution_direction (self);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static enum exec_direction_kind
|
|
|
|
debug_execution_direction (struct target_ops *self)
|
|
|
|
{
|
|
|
|
enum exec_direction_kind result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_execution_direction (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_execution_direction (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_execution_direction (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_enum_exec_direction_kind (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 04:54:06 +08:00
|
|
|
static int
|
|
|
|
delegate_supports_multi_process (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_supports_multi_process (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_supports_multi_process (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_supports_multi_process (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_supports_multi_process (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_supports_multi_process (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_supports_multi_process (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 04:54:59 +08:00
|
|
|
static int
|
|
|
|
delegate_supports_enable_disable_tracepoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_supports_enable_disable_tracepoint (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_supports_enable_disable_tracepoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_supports_enable_disable_tracepoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_supports_enable_disable_tracepoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_supports_enable_disable_tracepoint (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_supports_enable_disable_tracepoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 04:56:04 +08:00
|
|
|
static int
|
|
|
|
delegate_supports_string_tracing (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_supports_string_tracing (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_supports_string_tracing (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_supports_string_tracing (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_supports_string_tracing (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_supports_string_tracing (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_supports_string_tracing (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:20:06 +08:00
|
|
|
static int
|
|
|
|
delegate_supports_evaluation_of_breakpoint_conditions (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_supports_evaluation_of_breakpoint_conditions (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_supports_evaluation_of_breakpoint_conditions (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_supports_evaluation_of_breakpoint_conditions (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_supports_evaluation_of_breakpoint_conditions (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_supports_evaluation_of_breakpoint_conditions (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_supports_evaluation_of_breakpoint_conditions (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:20:36 +08:00
|
|
|
static int
|
|
|
|
delegate_can_run_breakpoint_commands (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_can_run_breakpoint_commands (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_can_run_breakpoint_commands (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_can_run_breakpoint_commands (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_can_run_breakpoint_commands (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_can_run_breakpoint_commands (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_can_run_breakpoint_commands (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 02:16:31 +08:00
|
|
|
static struct gdbarch *
|
|
|
|
delegate_thread_architecture (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_thread_architecture (self, arg1);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static struct gdbarch *
|
|
|
|
debug_thread_architecture (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
struct gdbarch * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_thread_architecture (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_thread_architecture (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_thread_architecture (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_gdbarch_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-02-22 01:33:42 +08:00
|
|
|
static struct address_space *
|
|
|
|
delegate_thread_address_space (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_thread_address_space (self, arg1);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static struct address_space *
|
|
|
|
debug_thread_address_space (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
struct address_space * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_thread_address_space (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_thread_address_space (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_thread_address_space (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_address_space_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-04-02 20:38:28 +08:00
|
|
|
static int
|
|
|
|
delegate_filesystem_is_local (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_filesystem_is_local (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_filesystem_is_local (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
debug_filesystem_is_local (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_filesystem_is_local (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_filesystem_is_local (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_filesystem_is_local (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 04:57:05 +08:00
|
|
|
static void
|
|
|
|
delegate_trace_init (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_trace_init (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_trace_init (struct target_ops *self)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_trace_init (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_trace_init (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_trace_init (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_trace_init (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 04:57:41 +08:00
|
|
|
static void
|
|
|
|
delegate_download_tracepoint (struct target_ops *self, struct bp_location *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_download_tracepoint (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_download_tracepoint (struct target_ops *self, struct bp_location *arg1)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_download_tracepoint (struct target_ops *self, struct bp_location *arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_download_tracepoint (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_download_tracepoint (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_download_tracepoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_bp_location_p (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:00:23 +08:00
|
|
|
static int
|
|
|
|
delegate_can_download_tracepoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_can_download_tracepoint (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_can_download_tracepoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_can_download_tracepoint (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_can_download_tracepoint (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_can_download_tracepoint (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_can_download_tracepoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:01:07 +08:00
|
|
|
static void
|
|
|
|
delegate_download_trace_state_variable (struct target_ops *self, struct trace_state_variable *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_download_trace_state_variable (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_download_trace_state_variable (struct target_ops *self, struct trace_state_variable *arg1)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_download_trace_state_variable (struct target_ops *self, struct trace_state_variable *arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_download_trace_state_variable (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_download_trace_state_variable (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_download_trace_state_variable (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_trace_state_variable_p (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:01:51 +08:00
|
|
|
static void
|
|
|
|
delegate_enable_tracepoint (struct target_ops *self, struct bp_location *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_enable_tracepoint (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_enable_tracepoint (struct target_ops *self, struct bp_location *arg1)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_enable_tracepoint (struct target_ops *self, struct bp_location *arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_enable_tracepoint (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_enable_tracepoint (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_enable_tracepoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_bp_location_p (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:02:30 +08:00
|
|
|
static void
|
|
|
|
delegate_disable_tracepoint (struct target_ops *self, struct bp_location *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_disable_tracepoint (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_disable_tracepoint (struct target_ops *self, struct bp_location *arg1)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_disable_tracepoint (struct target_ops *self, struct bp_location *arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_disable_tracepoint (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_disable_tracepoint (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_disable_tracepoint (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_bp_location_p (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:03:28 +08:00
|
|
|
static void
|
|
|
|
delegate_trace_set_readonly_regions (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_trace_set_readonly_regions (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_trace_set_readonly_regions (struct target_ops *self)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_trace_set_readonly_regions (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_trace_set_readonly_regions (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_trace_set_readonly_regions (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_trace_set_readonly_regions (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:04:27 +08:00
|
|
|
static void
|
|
|
|
delegate_trace_start (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_trace_start (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_trace_start (struct target_ops *self)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_trace_start (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_trace_start (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_trace_start (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_trace_start (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:06:18 +08:00
|
|
|
static int
|
|
|
|
delegate_get_trace_status (struct target_ops *self, struct trace_status *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_get_trace_status (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_get_trace_status (struct target_ops *self, struct trace_status *arg1)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_get_trace_status (struct target_ops *self, struct trace_status *arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_trace_status (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_get_trace_status (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_trace_status (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_trace_status_p (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:06:52 +08:00
|
|
|
static void
|
|
|
|
delegate_get_tracepoint_status (struct target_ops *self, struct breakpoint *arg1, struct uploaded_tp *arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_get_tracepoint_status (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_get_tracepoint_status (struct target_ops *self, struct breakpoint *arg1, struct uploaded_tp *arg2)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_get_tracepoint_status (struct target_ops *self, struct breakpoint *arg1, struct uploaded_tp *arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_tracepoint_status (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_get_tracepoint_status (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_tracepoint_status (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_breakpoint_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_uploaded_tp_p (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:07:28 +08:00
|
|
|
static void
|
|
|
|
delegate_trace_stop (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_trace_stop (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_trace_stop (struct target_ops *self)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_trace_stop (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_trace_stop (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_trace_stop (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_trace_stop (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:08:14 +08:00
|
|
|
static int
|
2014-07-16 02:08:54 +08:00
|
|
|
delegate_trace_find (struct target_ops *self, enum trace_find_type arg1, int arg2, CORE_ADDR arg3, CORE_ADDR arg4, int *arg5)
|
2013-12-19 05:08:14 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_trace_find (self, arg1, arg2, arg3, arg4, arg5);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-07-16 02:08:54 +08:00
|
|
|
tdefault_trace_find (struct target_ops *self, enum trace_find_type arg1, int arg2, CORE_ADDR arg3, CORE_ADDR arg4, int *arg5)
|
2013-12-19 05:08:14 +08:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_trace_find (struct target_ops *self, enum trace_find_type arg1, int arg2, CORE_ADDR arg3, CORE_ADDR arg4, int *arg5)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_trace_find (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_trace_find (&debug_target, arg1, arg2, arg3, arg4, arg5);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_trace_find (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_enum_trace_find_type (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg3);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg4);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int_p (arg5);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:09:04 +08:00
|
|
|
static int
|
|
|
|
delegate_get_trace_state_variable_value (struct target_ops *self, int arg1, LONGEST *arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_get_trace_state_variable_value (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_get_trace_state_variable_value (struct target_ops *self, int arg1, LONGEST *arg2)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_get_trace_state_variable_value (struct target_ops *self, int arg1, LONGEST *arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_trace_state_variable_value (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_get_trace_state_variable_value (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_trace_state_variable_value (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_LONGEST_p (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:09:37 +08:00
|
|
|
static int
|
|
|
|
delegate_save_trace_data (struct target_ops *self, const char *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_save_trace_data (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_save_trace_data (struct target_ops *self, const char *arg1)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_save_trace_data (struct target_ops *self, const char *arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_save_trace_data (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_save_trace_data (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_save_trace_data (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:10:14 +08:00
|
|
|
static int
|
|
|
|
delegate_upload_tracepoints (struct target_ops *self, struct uploaded_tp **arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_upload_tracepoints (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_upload_tracepoints (struct target_ops *self, struct uploaded_tp **arg1)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_upload_tracepoints (struct target_ops *self, struct uploaded_tp **arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_upload_tracepoints (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_upload_tracepoints (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_upload_tracepoints (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_uploaded_tp_pp (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:10:40 +08:00
|
|
|
static int
|
|
|
|
delegate_upload_trace_state_variables (struct target_ops *self, struct uploaded_tsv **arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_upload_trace_state_variables (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_upload_trace_state_variables (struct target_ops *self, struct uploaded_tsv **arg1)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_upload_trace_state_variables (struct target_ops *self, struct uploaded_tsv **arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_upload_trace_state_variables (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_upload_trace_state_variables (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_upload_trace_state_variables (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_uploaded_tsv_pp (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:11:12 +08:00
|
|
|
static LONGEST
|
|
|
|
delegate_get_raw_trace_data (struct target_ops *self, gdb_byte *arg1, ULONGEST arg2, LONGEST arg3)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_get_raw_trace_data (self, arg1, arg2, arg3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONGEST
|
|
|
|
tdefault_get_raw_trace_data (struct target_ops *self, gdb_byte *arg1, ULONGEST arg2, LONGEST arg3)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static LONGEST
|
|
|
|
debug_get_raw_trace_data (struct target_ops *self, gdb_byte *arg1, ULONGEST arg2, LONGEST arg3)
|
|
|
|
{
|
|
|
|
LONGEST result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_raw_trace_data (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_get_raw_trace_data (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_raw_trace_data (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_gdb_byte_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_LONGEST (arg3);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_LONGEST (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:11:53 +08:00
|
|
|
static int
|
|
|
|
delegate_get_min_fast_tracepoint_insn_len (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_get_min_fast_tracepoint_insn_len (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_get_min_fast_tracepoint_insn_len (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_get_min_fast_tracepoint_insn_len (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_min_fast_tracepoint_insn_len (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_get_min_fast_tracepoint_insn_len (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_min_fast_tracepoint_insn_len (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:12:29 +08:00
|
|
|
static void
|
|
|
|
delegate_set_disconnected_tracing (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_set_disconnected_tracing (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_set_disconnected_tracing (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_set_disconnected_tracing (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_set_disconnected_tracing (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_set_disconnected_tracing (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_set_disconnected_tracing (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:13:09 +08:00
|
|
|
static void
|
|
|
|
delegate_set_circular_trace_buffer (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_set_circular_trace_buffer (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_set_circular_trace_buffer (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_set_circular_trace_buffer (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_set_circular_trace_buffer (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_set_circular_trace_buffer (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_set_circular_trace_buffer (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:14:58 +08:00
|
|
|
static void
|
|
|
|
delegate_set_trace_buffer_size (struct target_ops *self, LONGEST arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_set_trace_buffer_size (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_set_trace_buffer_size (struct target_ops *self, LONGEST arg1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_set_trace_buffer_size (struct target_ops *self, LONGEST arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_set_trace_buffer_size (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_set_trace_buffer_size (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_set_trace_buffer_size (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_LONGEST (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:15:23 +08:00
|
|
|
static int
|
|
|
|
delegate_set_trace_notes (struct target_ops *self, const char *arg1, const char *arg2, const char *arg3)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_set_trace_notes (self, arg1, arg2, arg3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_set_trace_notes (struct target_ops *self, const char *arg1, const char *arg2, const char *arg3)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_set_trace_notes (struct target_ops *self, const char *arg1, const char *arg2, const char *arg3)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_set_trace_notes (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_set_trace_notes (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_set_trace_notes (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg3);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:55:06 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_core_of_thread (struct target_ops *self, ptid_t arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_core_of_thread (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_core_of_thread (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_core_of_thread (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:55:44 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_verify_memory (struct target_ops *self, const gdb_byte *arg1, CORE_ADDR arg2, ULONGEST arg3)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_verify_memory (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_verify_memory (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_verify_memory (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_gdb_byte_p (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg3);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:15:55 +08:00
|
|
|
static int
|
|
|
|
delegate_get_tib_address (struct target_ops *self, ptid_t arg1, CORE_ADDR *arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_get_tib_address (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_get_tib_address (struct target_ops *self, ptid_t arg1, CORE_ADDR *arg2)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_get_tib_address (struct target_ops *self, ptid_t arg1, CORE_ADDR *arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_tib_address (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_get_tib_address (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_tib_address (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR_p (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:16:24 +08:00
|
|
|
static void
|
|
|
|
delegate_set_permissions (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_set_permissions (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_set_permissions (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_set_permissions (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_set_permissions (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_set_permissions (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_set_permissions (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:16:51 +08:00
|
|
|
static int
|
|
|
|
delegate_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, struct static_tracepoint_marker *arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_static_tracepoint_marker_at (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, struct static_tracepoint_marker *arg2)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, struct static_tracepoint_marker *arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_static_tracepoint_marker_at (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_static_tracepoint_marker_at (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_static_tracepoint_marker_at (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_CORE_ADDR (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_static_tracepoint_marker_p (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:17:35 +08:00
|
|
|
static VEC(static_tracepoint_marker_p) *
|
|
|
|
delegate_static_tracepoint_markers_by_strid (struct target_ops *self, const char *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_static_tracepoint_markers_by_strid (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VEC(static_tracepoint_marker_p) *
|
|
|
|
tdefault_static_tracepoint_markers_by_strid (struct target_ops *self, const char *arg1)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static VEC(static_tracepoint_marker_p) *
|
|
|
|
debug_static_tracepoint_markers_by_strid (struct target_ops *self, const char *arg1)
|
|
|
|
{
|
|
|
|
VEC(static_tracepoint_marker_p) * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_static_tracepoint_markers_by_strid (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_static_tracepoint_markers_by_strid (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_static_tracepoint_markers_by_strid (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_VEC_static_tracepoint_marker_p__p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:18:10 +08:00
|
|
|
static struct traceframe_info *
|
|
|
|
delegate_traceframe_info (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_traceframe_info (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct traceframe_info *
|
|
|
|
tdefault_traceframe_info (struct target_ops *self)
|
|
|
|
{
|
2014-03-04 17:39:10 +08:00
|
|
|
tcomplain ();
|
2013-12-19 05:18:10 +08:00
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static struct traceframe_info *
|
|
|
|
debug_traceframe_info (struct target_ops *self)
|
|
|
|
{
|
|
|
|
struct traceframe_info * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_traceframe_info (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_traceframe_info (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_traceframe_info (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_traceframe_info_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:18:35 +08:00
|
|
|
static int
|
|
|
|
delegate_use_agent (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_use_agent (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_use_agent (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_use_agent (struct target_ops *self, int arg1)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_use_agent (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_use_agent (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_use_agent (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:19:04 +08:00
|
|
|
static int
|
|
|
|
delegate_can_use_agent (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_can_use_agent (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_can_use_agent (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_can_use_agent (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_can_use_agent (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_can_use_agent (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_can_use_agent (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-14 04:26:04 +08:00
|
|
|
static int
|
2014-01-17 20:29:19 +08:00
|
|
|
delegate_supports_btrace (struct target_ops *self, enum btrace_format arg1)
|
2013-12-14 04:26:04 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
2014-01-17 20:29:19 +08:00
|
|
|
return self->to_supports_btrace (self, arg1);
|
2013-12-14 04:26:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-01-17 20:29:19 +08:00
|
|
|
tdefault_supports_btrace (struct target_ops *self, enum btrace_format arg1)
|
2013-12-14 04:26:04 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
2014-01-17 20:29:19 +08:00
|
|
|
debug_supports_btrace (struct target_ops *self, enum btrace_format arg1)
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_supports_btrace (...)\n", debug_target.to_shortname);
|
2014-01-17 20:29:19 +08:00
|
|
|
result = debug_target.to_supports_btrace (&debug_target, arg1);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_supports_btrace (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
2014-01-17 20:29:19 +08:00
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_enum_btrace_format (arg1);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 23:19:41 +08:00
|
|
|
static struct btrace_target_info *
|
2013-11-28 22:44:13 +08:00
|
|
|
delegate_enable_btrace (struct target_ops *self, ptid_t arg1, const struct btrace_config *arg2)
|
2013-12-19 23:19:41 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
2013-11-28 22:44:13 +08:00
|
|
|
return self->to_enable_btrace (self, arg1, arg2);
|
2013-12-19 23:19:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct btrace_target_info *
|
2013-11-28 22:44:13 +08:00
|
|
|
tdefault_enable_btrace (struct target_ops *self, ptid_t arg1, const struct btrace_config *arg2)
|
2013-12-19 23:19:41 +08:00
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static struct btrace_target_info *
|
2013-11-28 22:44:13 +08:00
|
|
|
debug_enable_btrace (struct target_ops *self, ptid_t arg1, const struct btrace_config *arg2)
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
{
|
|
|
|
struct btrace_target_info * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_enable_btrace (...)\n", debug_target.to_shortname);
|
2013-11-28 22:44:13 +08:00
|
|
|
result = debug_target.to_enable_btrace (&debug_target, arg1, arg2);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_enable_btrace (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
2013-11-28 22:44:13 +08:00
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_struct_btrace_config_p (arg2);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_btrace_target_info_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 23:17:16 +08:00
|
|
|
static void
|
|
|
|
delegate_disable_btrace (struct target_ops *self, struct btrace_target_info *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_disable_btrace (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_disable_btrace (struct target_ops *self, struct btrace_target_info *arg1)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_disable_btrace (struct target_ops *self, struct btrace_target_info *arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_disable_btrace (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_disable_btrace (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_disable_btrace (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_btrace_target_info_p (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 23:18:04 +08:00
|
|
|
static void
|
|
|
|
delegate_teardown_btrace (struct target_ops *self, struct btrace_target_info *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_teardown_btrace (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_teardown_btrace (struct target_ops *self, struct btrace_target_info *arg1)
|
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_teardown_btrace (struct target_ops *self, struct btrace_target_info *arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_teardown_btrace (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_teardown_btrace (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_teardown_btrace (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_btrace_target_info_p (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2014-07-16 02:08:54 +08:00
|
|
|
static enum btrace_error
|
2013-11-13 22:31:07 +08:00
|
|
|
delegate_read_btrace (struct target_ops *self, struct btrace_data *arg1, struct btrace_target_info *arg2, enum btrace_read_type arg3)
|
2013-12-19 23:19:02 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_read_btrace (self, arg1, arg2, arg3);
|
|
|
|
}
|
|
|
|
|
2014-07-16 02:08:54 +08:00
|
|
|
static enum btrace_error
|
2013-11-13 22:31:07 +08:00
|
|
|
tdefault_read_btrace (struct target_ops *self, struct btrace_data *arg1, struct btrace_target_info *arg2, enum btrace_read_type arg3)
|
2013-12-19 23:19:02 +08:00
|
|
|
{
|
|
|
|
tcomplain ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static enum btrace_error
|
2013-11-13 22:31:07 +08:00
|
|
|
debug_read_btrace (struct target_ops *self, struct btrace_data *arg1, struct btrace_target_info *arg2, enum btrace_read_type arg3)
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
{
|
|
|
|
enum btrace_error result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_read_btrace (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_read_btrace (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_read_btrace (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
2013-11-13 22:31:07 +08:00
|
|
|
target_debug_print_struct_btrace_data_p (arg1);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_struct_btrace_target_info_p (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_enum_btrace_read_type (arg3);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_enum_btrace_error (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-11-28 22:44:13 +08:00
|
|
|
static const struct btrace_config *
|
|
|
|
delegate_btrace_conf (struct target_ops *self, const struct btrace_target_info *arg1)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_btrace_conf (self, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct btrace_config *
|
|
|
|
tdefault_btrace_conf (struct target_ops *self, const struct btrace_target_info *arg1)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct btrace_config *
|
|
|
|
debug_btrace_conf (struct target_ops *self, const struct btrace_target_info *arg1)
|
|
|
|
{
|
|
|
|
const struct btrace_config * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_btrace_conf (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_btrace_conf (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_btrace_conf (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_struct_btrace_target_info_p (arg1);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_const_struct_btrace_config_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-19 23:21:20 +08:00
|
|
|
static void
|
|
|
|
delegate_stop_recording (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_stop_recording (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_stop_recording (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_stop_recording (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_stop_recording (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_stop_recording (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_stop_recording (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2014-07-16 22:05:03 +08:00
|
|
|
static void
|
|
|
|
delegate_info_record (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_info_record (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_info_record (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_info_record (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_info_record (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_info_record (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_info_record (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:26:34 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_save_record (struct target_ops *self, const char *arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_save_record (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_save_record (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_save_record (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_const_char_p (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:25:47 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_delete_record (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_delete_record (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_delete_record (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_delete_record (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:25:01 +08:00
|
|
|
static int
|
2015-09-08 14:26:16 +08:00
|
|
|
delegate_record_is_replaying (struct target_ops *self, ptid_t arg1)
|
2013-12-19 11:25:01 +08:00
|
|
|
{
|
|
|
|
self = self->beneath;
|
2015-09-08 14:26:16 +08:00
|
|
|
return self->to_record_is_replaying (self, arg1);
|
2013-12-19 11:25:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-09-08 14:26:16 +08:00
|
|
|
tdefault_record_is_replaying (struct target_ops *self, ptid_t arg1)
|
2013-12-19 11:25:01 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
2015-09-08 14:26:16 +08:00
|
|
|
debug_record_is_replaying (struct target_ops *self, ptid_t arg1)
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_record_is_replaying (...)\n", debug_target.to_shortname);
|
2015-09-08 14:26:16 +08:00
|
|
|
result = debug_target.to_record_is_replaying (&debug_target, arg1);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_record_is_replaying (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
2015-09-08 14:26:16 +08:00
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-09-17 17:14:55 +08:00
|
|
|
static int
|
|
|
|
delegate_record_will_replay (struct target_ops *self, ptid_t arg1, int arg2)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_record_will_replay (self, arg1, arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_record_will_replay (struct target_ops *self, ptid_t arg1, int arg2)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
debug_record_will_replay (struct target_ops *self, ptid_t arg1, int arg2)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_record_will_replay (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_record_will_replay (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_record_will_replay (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ptid_t (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-09-08 15:42:20 +08:00
|
|
|
static void
|
|
|
|
delegate_record_stop_replaying (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_record_stop_replaying (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_record_stop_replaying (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
debug_record_stop_replaying (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_record_stop_replaying (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_record_stop_replaying (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_record_stop_replaying (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:24:04 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_goto_record_begin (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_goto_record_begin (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_goto_record_begin (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_goto_record_begin (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:23:23 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_goto_record_end (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_goto_record_end (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_goto_record_end (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_goto_record_end (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:22:36 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_goto_record (struct target_ops *self, ULONGEST arg1)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_goto_record (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_goto_record (&debug_target, arg1);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_goto_record (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg1);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:18:49 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_insn_history (struct target_ops *self, int arg1, int arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_insn_history (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_insn_history (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_insn_history (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:16:56 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_insn_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_insn_history_from (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_insn_history_from (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_insn_history_from (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg3);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:15:44 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_insn_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_insn_history_range (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_insn_history_range (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_insn_history_range (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg3);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:13:40 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_call_history (struct target_ops *self, int arg1, int arg2)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_call_history (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_call_history (&debug_target, arg1, arg2);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_call_history (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:11:49 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_call_history_from (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_call_history_from (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_call_history_from (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg3);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 11:10:20 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_call_history_range (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_call_history_range (&debug_target, arg1, arg2, arg3);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_call_history_range (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg1);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_ULONGEST (arg2);
|
|
|
|
fputs_unfiltered (", ", gdb_stdlog);
|
|
|
|
target_debug_print_int (arg3);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:19:33 +08:00
|
|
|
static int
|
|
|
|
delegate_augmented_libraries_svr4_read (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_augmented_libraries_svr4_read (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tdefault_augmented_libraries_svr4_read (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static int
|
|
|
|
debug_augmented_libraries_svr4_read (struct target_ops *self)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_augmented_libraries_svr4_read (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_augmented_libraries_svr4_read (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_augmented_libraries_svr4_read (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_int (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-01-17 04:00:07 +08:00
|
|
|
static const struct frame_unwind *
|
|
|
|
delegate_get_unwinder (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_get_unwinder (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct frame_unwind *
|
|
|
|
tdefault_get_unwinder (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static const struct frame_unwind *
|
|
|
|
debug_get_unwinder (struct target_ops *self)
|
|
|
|
{
|
|
|
|
const struct frame_unwind * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_unwinder (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_get_unwinder (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_unwinder (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_const_struct_frame_unwind_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-01-17 04:00:07 +08:00
|
|
|
static const struct frame_unwind *
|
|
|
|
delegate_get_tailcall_unwinder (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
return self->to_get_tailcall_unwinder (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct frame_unwind *
|
|
|
|
tdefault_get_tailcall_unwinder (struct target_ops *self)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static const struct frame_unwind *
|
|
|
|
debug_get_tailcall_unwinder (struct target_ops *self)
|
|
|
|
{
|
|
|
|
const struct frame_unwind * result;
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_get_tailcall_unwinder (...)\n", debug_target.to_shortname);
|
|
|
|
result = debug_target.to_get_tailcall_unwinder (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_get_tailcall_unwinder (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (") = ", gdb_stdlog);
|
|
|
|
target_debug_print_const_struct_frame_unwind_p (result);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdlog);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-05-20 21:22:53 +08:00
|
|
|
static void
|
|
|
|
delegate_prepare_to_generate_core (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_prepare_to_generate_core (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_prepare_to_generate_core (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_prepare_to_generate_core (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_prepare_to_generate_core (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_prepare_to_generate_core (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_prepare_to_generate_core (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2014-05-20 21:22:53 +08:00
|
|
|
static void
|
|
|
|
delegate_done_generating_core (struct target_ops *self)
|
|
|
|
{
|
|
|
|
self = self->beneath;
|
|
|
|
self->to_done_generating_core (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tdefault_done_generating_core (struct target_ops *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
static void
|
|
|
|
debug_done_generating_core (struct target_ops *self)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "-> %s->to_done_generating_core (...)\n", debug_target.to_shortname);
|
|
|
|
debug_target.to_done_generating_core (&debug_target);
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "<- %s->to_done_generating_core (", debug_target.to_shortname);
|
|
|
|
target_debug_print_struct_target_ops_p (&debug_target);
|
|
|
|
fputs_unfiltered (")\n", gdb_stdlog);
|
|
|
|
}
|
|
|
|
|
2013-12-20 00:38:11 +08:00
|
|
|
static void
|
|
|
|
install_delegators (struct target_ops *ops)
|
|
|
|
{
|
2013-12-19 00:42:24 +08:00
|
|
|
if (ops->to_post_attach == NULL)
|
|
|
|
ops->to_post_attach = delegate_post_attach;
|
2013-12-14 04:33:08 +08:00
|
|
|
if (ops->to_detach == NULL)
|
|
|
|
ops->to_detach = delegate_detach;
|
2013-12-21 01:30:13 +08:00
|
|
|
if (ops->to_disconnect == NULL)
|
|
|
|
ops->to_disconnect = delegate_disconnect;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
if (ops->to_resume == NULL)
|
|
|
|
ops->to_resume = delegate_resume;
|
|
|
|
if (ops->to_wait == NULL)
|
|
|
|
ops->to_wait = delegate_wait;
|
2013-12-19 05:30:22 +08:00
|
|
|
if (ops->to_fetch_registers == NULL)
|
|
|
|
ops->to_fetch_registers = delegate_fetch_registers;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
if (ops->to_store_registers == NULL)
|
|
|
|
ops->to_store_registers = delegate_store_registers;
|
2013-12-19 00:47:18 +08:00
|
|
|
if (ops->to_prepare_to_store == NULL)
|
|
|
|
ops->to_prepare_to_store = delegate_prepare_to_store;
|
2013-12-19 00:51:47 +08:00
|
|
|
if (ops->to_files_info == NULL)
|
|
|
|
ops->to_files_info = delegate_files_info;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
if (ops->to_insert_breakpoint == NULL)
|
|
|
|
ops->to_insert_breakpoint = delegate_insert_breakpoint;
|
|
|
|
if (ops->to_remove_breakpoint == NULL)
|
|
|
|
ops->to_remove_breakpoint = delegate_remove_breakpoint;
|
Teach GDB about targets that can tell whether a trap is a breakpoint event
The moribund locations heuristics are problematic. This patch teaches
GDB about targets that can reliably tell whether a trap was caused by
a software or hardware breakpoint, and thus don't need moribund
locations, thus bypassing all the problems that mechanism has.
The non-stop-fair-events.exp test is frequently failing currently.
E.g., see https://sourceware.org/ml/gdb-testers/2015-q1/msg03148.html.
The root cause is a fundamental problem with moribund locations. For
example, the stepped_breakpoint logic added by af48d08f breaks in this
case (which is what happens with that test):
- Step thread A, no breakpoint is set at PC.
- The kernel doesn't schedule thread A yet.
- Insert breakpoint at A's PC, for some reason (e.g., a step-resume
breakpoint for thread B).
- Kernel finally schedules thread A.
- thread A's stepped_breakpoint flag is not set, even though it now
stepped a breakpoint instruction.
- adjust_pc_after_break gets the PC wrong, because PC == PREV_PC, but
stepped_breakpoint is not set.
We needed the stepped_breakpoint logic to workaround moribund
locations, because otherwise adjust_pc_after_break could apply an
adjustment when it shouldn't just because there _used_ to be a
breakpoint at PC (a moribund breakpoint location). For example, on
x86, that's wrong if the thread really hasn't executed an int3, but
instead executed some other 1-byte long instruction. Getting the PC
adjustment wrong of course leads to the inferior executing the wrong
instruction.
Other problems with moribund locations are:
- if a true SIGTRAP happens to be raised when the program is
executing the PC that used to have a breakpoint, GDB will assume
that is a trap for a breakpoint that has recently been removed, and
thus we miss reporting the random signal to the user.
- to minimize that, we get rid of moribund location after a while.
That while is defined as just a certain number of events being
processed. That number of events sometimes passes by before a
delayed breakpoint is processed, and GDB confuses the trap for a
random signal, thus reporting the random trap. Once the user
resumes the thread, the program crashes because the PC was not
adjusted...
The fix for all this is to bite the bullet and get rid of heuristics
and instead rely on the target knowing accurately what caused the
SIGTRAP. The target/kernel/stub is in the best position to know what
that, because it can e.g. consult priviledged CPU flags GDB has no
access to, or by knowing which exception vector entry was called when
the instruction trapped, etc. Most debug APIs I've seen to date
report breakpoint hits as a distinct event in some fashion. For
example, on the Linux kernel, whether a breakpoint was executed is
exposed to userspace in the si_code field of the SIGTRAP's siginfo.
On Windows, the debug API reports a EXCEPTION_BREAKPOINT exception
code.
We needed to keep around deleted breakpoints in an on-the-side list
(the moribund locations) for two main reasons:
- Know that a SIGTRAP actually is a delayed event for a hit of a
breakpoint that was removed before the event was processed, and
thus should not be reported as a random signal.
- So we still do the decr_pc_after_break adjustment in that case, so
that the thread is resumed at the correct address.
In the new model, if GDB processes an event the target tells is a
breakpoint trap, and GDB doesn't find the corresponding breakpoint in
its breakpoint tables, it means that event is a delayed event for a
breakpoint that has since been removed, and thus the event should be
ignored.
For the decr_pc_after_after issue, it ends up being much simpler that
on targets that can reliably tell whether a breakpoint trapped, for
the breakpoint trap to present the PC already adjusted. Proper
multi-threading support already implies that targets needs to be doing
decr_pc_after_break adjustment themselves, otherwise for example, in
all-stop if two threads hit a breakpoint simultaneously, and the user
does "info threads", he'll see the non-event thread that hit the
breakpoint stopped at the wrong PC.
This way (target adjusts) also ends up eliminating the need for some
awkward re-incrementing of the PC in the record-full and Linux targets
that we do today, and the need for the target_decr_pc_after_break
hook.
If the target always adjusts, then there's a case where GDB needs to
re-increment the PC. Say, on x86, an "int3" instruction that was
explicitly written in the program traps. In this case, GDB should
report a random SIGTRAP signal to the user, with the PC pointing at
the instruction past the int3, just like if GDB was not debugging the
program. The user may well decide to pass the SIGTRAP to the program
because the program being debugged has a SIGTRAP handler that handles
its own breakpoints, and expects the PC to be unadjusted.
Tested on x86-64 Fedora 20.
gdb/ChangeLog:
2015-03-04 Pedro Alves <palves@redhat.com>
* breakpoint.c (need_moribund_for_location_type): New function.
(bpstat_stop_status): Don't skipping checking moribund locations
of breakpoint types which the target tell caused a stop.
(program_breakpoint_here_p): New function, factored out from ...
(bp_loc_is_permanent): ... this.
(update_global_location_list): Don't create a moribund location if
the target supports reporting stops of the type of the removed
breakpoint.
* breakpoint.h (program_breakpoint_here_p): New declaration.
* infrun.c (adjust_pc_after_break): Return early if the target has
already adjusted the PC. Add comments.
(handle_signal_stop): If nothing explains a signal, and the target
tells us the stop was caused by a software breakpoint, check if
there's a breakpoint instruction in the memory. If so, adjust the
PC before presenting the stop to the user. Otherwise, ignore the
trap. If nothing explains a signal, and the target tells us the
stop was caused by a hardware breakpoint, ignore the trap.
* target.h (struct target_ops) <to_stopped_by_sw_breakpoint,
to_supports_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint,
to_supports_stopped_by_hw_breakpoint>: New fields.
(target_stopped_by_sw_breakpoint)
(target_supports_stopped_by_sw_breakpoint)
(target_stopped_by_hw_breakpoint)
(target_supports_stopped_by_hw_breakpoint): Define.
* target-delegates.c: Regenerate.
2015-03-05 04:41:15 +08:00
|
|
|
if (ops->to_stopped_by_sw_breakpoint == NULL)
|
|
|
|
ops->to_stopped_by_sw_breakpoint = delegate_stopped_by_sw_breakpoint;
|
|
|
|
if (ops->to_supports_stopped_by_sw_breakpoint == NULL)
|
|
|
|
ops->to_supports_stopped_by_sw_breakpoint = delegate_supports_stopped_by_sw_breakpoint;
|
|
|
|
if (ops->to_stopped_by_hw_breakpoint == NULL)
|
|
|
|
ops->to_stopped_by_hw_breakpoint = delegate_stopped_by_hw_breakpoint;
|
|
|
|
if (ops->to_supports_stopped_by_hw_breakpoint == NULL)
|
|
|
|
ops->to_supports_stopped_by_hw_breakpoint = delegate_supports_stopped_by_hw_breakpoint;
|
2013-12-19 00:58:16 +08:00
|
|
|
if (ops->to_can_use_hw_breakpoint == NULL)
|
|
|
|
ops->to_can_use_hw_breakpoint = delegate_can_use_hw_breakpoint;
|
2013-12-19 05:31:42 +08:00
|
|
|
if (ops->to_ranged_break_num_registers == NULL)
|
|
|
|
ops->to_ranged_break_num_registers = delegate_ranged_break_num_registers;
|
2013-12-19 01:01:11 +08:00
|
|
|
if (ops->to_insert_hw_breakpoint == NULL)
|
|
|
|
ops->to_insert_hw_breakpoint = delegate_insert_hw_breakpoint;
|
2013-12-19 01:05:18 +08:00
|
|
|
if (ops->to_remove_hw_breakpoint == NULL)
|
|
|
|
ops->to_remove_hw_breakpoint = delegate_remove_hw_breakpoint;
|
2013-12-19 01:11:49 +08:00
|
|
|
if (ops->to_remove_watchpoint == NULL)
|
|
|
|
ops->to_remove_watchpoint = delegate_remove_watchpoint;
|
2013-12-19 01:08:59 +08:00
|
|
|
if (ops->to_insert_watchpoint == NULL)
|
|
|
|
ops->to_insert_watchpoint = delegate_insert_watchpoint;
|
2013-12-19 05:32:43 +08:00
|
|
|
if (ops->to_insert_mask_watchpoint == NULL)
|
|
|
|
ops->to_insert_mask_watchpoint = delegate_insert_mask_watchpoint;
|
2013-12-19 05:33:28 +08:00
|
|
|
if (ops->to_remove_mask_watchpoint == NULL)
|
|
|
|
ops->to_remove_mask_watchpoint = delegate_remove_mask_watchpoint;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
if (ops->to_stopped_by_watchpoint == NULL)
|
|
|
|
ops->to_stopped_by_watchpoint = delegate_stopped_by_watchpoint;
|
|
|
|
if (ops->to_stopped_data_address == NULL)
|
|
|
|
ops->to_stopped_data_address = delegate_stopped_data_address;
|
2013-12-19 01:15:23 +08:00
|
|
|
if (ops->to_watchpoint_addr_within_range == NULL)
|
|
|
|
ops->to_watchpoint_addr_within_range = delegate_watchpoint_addr_within_range;
|
2013-12-19 01:18:05 +08:00
|
|
|
if (ops->to_region_ok_for_hw_watchpoint == NULL)
|
|
|
|
ops->to_region_ok_for_hw_watchpoint = delegate_region_ok_for_hw_watchpoint;
|
2013-12-19 01:20:48 +08:00
|
|
|
if (ops->to_can_accel_watchpoint_condition == NULL)
|
|
|
|
ops->to_can_accel_watchpoint_condition = delegate_can_accel_watchpoint_condition;
|
2013-12-19 05:34:15 +08:00
|
|
|
if (ops->to_masked_watch_num_registers == NULL)
|
|
|
|
ops->to_masked_watch_num_registers = delegate_masked_watch_num_registers;
|
Support single step by arch or target
Nowadays, GDB only knows whether architecture supports hardware single
step or software single step (through gdbarch hook software_single_step),
and for a given instruction or instruction sequence, GDB knows how to
do single step (hardware or software). However, GDB doesn't know whether
the target supports hardware single step. It is possible that the
architecture doesn't support hardware single step, such as arm, but
the target supports, such as simulator. This was discussed in this
thread https://www.sourceware.org/ml/gdb/2009-12/msg00033.html before.
I encounter this problem for aarch64 multi-arch support. When aarch64
debugs arm program, gdbarch is arm, so software single step is still
used. However, the underneath linux kernel does support hardware
single step, so IWBN to use it.
This patch is to add a new target_ops hook to_can_do_single_step, and
only use it in arm_linux_software_single_step to decide whether or not
to use hardware single step. On the native aarch64 linux target, 1 is
returned. On other targets, -1 is returned. On the remote target, if
the target supports s and S actions in the vCont? reply, then target
can do single step. However, old GDBserver will send s and S in the
reply to vCont?, which will confuse new GDB. For example, old GDBserver
on arm-linux will send s and S in the reply to vCont?, but it doesn't
support hardware single step. On the other hand, new GDBserver, on
arm-linux for example, will not send s and S in the reply to vCont?,
but old GDB thinks it doesn't support vCont packet at all. In order
to address this problem, I add a new qSupported feature vContSupported,
which indicates GDB wants to know the supported actions in the reply
to vCont?, and qSupported response contains vContSupported if the
stub is able tell supported vCont actions in the reply of vCont?.
If the patched GDB talks with patched GDBserver on x86, the RSP traffic
is like this:
-> $qSupported:...+;vContSupported+
<- ...+;vContSupported+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
then, GDB knows the stub can do single step, and may stop using software
single step even the architecture doesn't support hardware single step.
If the patched GDB talks with patched GDBserver on arm, the last vCont?
reply will become:
<- vCont;c;C;t
GDB thinks the target doesn't support single step, so it will use software
single step.
If the patched GDB talks with unpatched GDBserver, the RSP traffic is like
this:
-> $qSupported:...+;vContSupported+
<- ...+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
although GDBserver returns s and S, GDB still thinks GDBserver may not
support single step because it doesn't support vContSupported.
If the unpatched GDB talks with patched GDBserver on x86, the RSP traffic
is like:
-> $qSupported:...+;
<- ...+;vContSupported+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
Since GDB doesn't sent vContSupported in the qSupported feature, GDBserver
sends s and S regardless of the support of hardware single step.
gdb:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-nat.c (aarch64_linux_can_do_single_step): New
function.
(_initialize_aarch64_linux_nat): Install it to to_can_do_single_step.
* arm-linux-tdep.c (arm_linux_software_single_step): Return 0
if target_can_do_single_step returns 1.
* remote.c (struct vCont_action_support) <s, S>: New fields.
(PACKET_vContSupported): New enum.
(remote_protocol_features): New element for vContSupported.
(remote_query_supported): Append "vContSupported+".
(remote_vcont_probe): Remove support_s and support_S, use
rs->supports_vCont.s and rs->supports_vCont.S instead. Disable
vCont packet if c and C actions are not supported.
(remote_can_do_single_step): New function.
(init_remote_ops): Install it to to_can_do_single_step.
(_initialize_remote): Call add_packet_config_cmd.
* target.h (struct target_ops) <to_can_do_single_step>: New field.
(target_can_do_single_step): New macro.
* target-delegates.c: Re-generated.
gdb/gdbserver:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* server.c (vCont_supported): New global variable.
(handle_query): Set vCont_supported to 1 if "vContSupported+"
matches. Append ";vContSupported+" to own_buf.
(handle_v_requests): Append ";s;S" to own_buf if target supports
hardware single step or vCont_supported is false.
(capture_main): Set vCont_supported to zero.
gdb/doc:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* gdb.texinfo (General Query Packets): Add vContSupported to
tables of 'gdbfeatures' and 'stub features' supported in the
qSupported packet, as well as to the list containing stub
feature details.
2015-09-15 21:09:18 +08:00
|
|
|
if (ops->to_can_do_single_step == NULL)
|
|
|
|
ops->to_can_do_single_step = delegate_can_do_single_step;
|
2013-12-19 01:24:07 +08:00
|
|
|
if (ops->to_terminal_init == NULL)
|
|
|
|
ops->to_terminal_init = delegate_terminal_init;
|
2013-12-19 01:29:01 +08:00
|
|
|
if (ops->to_terminal_inferior == NULL)
|
|
|
|
ops->to_terminal_inferior = delegate_terminal_inferior;
|
2013-12-19 01:29:46 +08:00
|
|
|
if (ops->to_terminal_ours_for_output == NULL)
|
|
|
|
ops->to_terminal_ours_for_output = delegate_terminal_ours_for_output;
|
2013-12-19 01:30:16 +08:00
|
|
|
if (ops->to_terminal_ours == NULL)
|
|
|
|
ops->to_terminal_ours = delegate_terminal_ours;
|
2013-12-19 01:31:10 +08:00
|
|
|
if (ops->to_terminal_info == NULL)
|
|
|
|
ops->to_terminal_info = delegate_terminal_info;
|
2013-12-19 05:35:15 +08:00
|
|
|
if (ops->to_kill == NULL)
|
|
|
|
ops->to_kill = delegate_kill;
|
2013-12-19 01:31:48 +08:00
|
|
|
if (ops->to_load == NULL)
|
|
|
|
ops->to_load = delegate_load;
|
2013-12-19 01:32:56 +08:00
|
|
|
if (ops->to_post_startup_inferior == NULL)
|
|
|
|
ops->to_post_startup_inferior = delegate_post_startup_inferior;
|
2013-12-19 01:33:43 +08:00
|
|
|
if (ops->to_insert_fork_catchpoint == NULL)
|
|
|
|
ops->to_insert_fork_catchpoint = delegate_insert_fork_catchpoint;
|
2013-12-19 01:34:15 +08:00
|
|
|
if (ops->to_remove_fork_catchpoint == NULL)
|
|
|
|
ops->to_remove_fork_catchpoint = delegate_remove_fork_catchpoint;
|
2013-12-19 01:44:22 +08:00
|
|
|
if (ops->to_insert_vfork_catchpoint == NULL)
|
|
|
|
ops->to_insert_vfork_catchpoint = delegate_insert_vfork_catchpoint;
|
2013-12-19 01:44:57 +08:00
|
|
|
if (ops->to_remove_vfork_catchpoint == NULL)
|
|
|
|
ops->to_remove_vfork_catchpoint = delegate_remove_vfork_catchpoint;
|
2013-12-19 05:38:04 +08:00
|
|
|
if (ops->to_follow_fork == NULL)
|
|
|
|
ops->to_follow_fork = delegate_follow_fork;
|
2013-12-19 01:45:38 +08:00
|
|
|
if (ops->to_insert_exec_catchpoint == NULL)
|
|
|
|
ops->to_insert_exec_catchpoint = delegate_insert_exec_catchpoint;
|
2013-12-19 01:46:02 +08:00
|
|
|
if (ops->to_remove_exec_catchpoint == NULL)
|
|
|
|
ops->to_remove_exec_catchpoint = delegate_remove_exec_catchpoint;
|
Extended-remote follow-exec
This patch implements support for exec events on extended-remote Linux
targets. Follow-exec-mode and rerun behave as expected. Catchpoints and
test updates are implemented in subsequent patches.
This patch was derived from a patch posted last October:
https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html.
It was originally based on some work done by Luis Machado in 2013.
IMPLEMENTATION
----------------
Exec events are enabled via ptrace options.
When an exec event is detected by gdbserver, the existing process
data, along with all its associated lwp and thread data, is deleted
and replaced by data for a new single-threaded process. The new
process data is initialized with the appropriate parts of the state
of the execing process. This approach takes care of several potential
pitfalls, including:
* deleting the data for an execing non-leader thread before any
wait/sigsuspend occurs
* correctly initializing the architecture of the execed process
We then report the exec event using a new RSP stop reason, "exec".
When GDB receives an "exec" event, it saves the status in the event
structure's target_waitstatus field, like what is done for remote fork
events. Because the original and execed programs may have different
architectures, we skip parsing the section of the stop reply packet
that contains register data. The register data will be retrieved
later after the inferior's architecture has been set up by
infrun.c:follow_exec.
At that point the exec event is handled by the existing event handling
in GDB. However, a few changes were necessary so that
infrun.c:follow_exec could accommodate the remote target.
* Where follow-exec-mode "new" is handled, we now call
add_inferior_with_spaces instead of add_inferior with separate calls
to set up the program and address spaces. The motivation for this
is that add_inferior_with_spaces also sets up the initial architecture
for the inferior, which is needed later by target_find_description
when it calls target_gdbarch.
* We call a new target function, target_follow_exec. This function
allows us to store the execd_pathname in the inferior, instead of
using the static string remote_exec_file from remote.c. The static
string didn't work for follow-exec-mode "new", since once you switched
to the execed program, the original remote exec-file was lost. The
execd_pathname is now stored in the inferior's program space as a
REGISTRY field. All of the requisite mechanisms for this are
defined in remote.c.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_mourn): Static declaration.
(linux_arch_setup): Move in front of
handle_extended_wait.
(linux_arch_setup_thread): New function.
(handle_extended_wait): Handle exec events. Call
linux_arch_setup_thread. Make event_lwp argument a
pointer-to-a-pointer.
(check_zombie_leaders): Do not check stopped threads.
(linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC.
(linux_low_filter_event): Add lwp and thread for exec'ing
non-leader thread if leader thread has been deleted.
Refactor code into linux_arch_setup_thread and call it.
Pass child lwp pointer by reference to handle_extended_wait.
(linux_wait_for_event_filtered): Update comment.
(linux_wait_1): Prevent clobbering exec event status.
(linux_supports_exec_events): New function.
(linux_target_ops) <supports_exec_events>: Initialize new member.
* lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize
new member.
* remote-utils.c (prepare_resume_reply): New stop reason 'exec'.
* server.c (report_exec_events): New global variable.
(handle_query): Handle qSupported query for exec-events feature.
(captured_main): Initialize report_exec_events.
* server.h (report_exec_events): Declare new global variable.
* target.h (struct target_ops) <supports_exec_events>: New
member.
(target_supports_exec_events): New macro.
* win32-low.c (win32_target_ops) <supports_exec_events>:
Initialize new member.
gdb/ChangeLog:
* infrun.c (follow_exec): Use process-style ptid for
exec message. Call add_inferior_with_spaces and
target_follow_exec.
* nat/linux-ptrace.c (linux_supports_traceexec): New function.
* nat/linux-ptrace.h (linux_supports_traceexec): Declare.
* remote.c (remote_pspace_data): New static variable.
(remote_pspace_data_cleanup): New function.
(get_remote_exec_file): New function.
(set_remote_exec_file_1): New function.
(set_remote_exec_file): New function.
(show_remote_exec_file): New function.
(remote_exec_file): Delete static variable.
(anonymous enum) <PACKET_exec_event_feature> New
enumeration constant.
(remote_protocol_features): Add entry for exec-events feature.
(remote_query_supported): Add client side of qSupported query
for exec-events feature.
(remote_follow_exec): New function.
(remote_parse_stop_reply): Handle 'exec' stop reason.
(extended_remote_run, extended_remote_create_inferior): Call
get_remote_exec_file and set_remote_exec_file_1.
(init_extended_remote_ops) <to_follow_exec>: Initialize new
member.
(_initialize_remote): Call
register_program_space_data_with_cleanup. Call
add_packet_config_cmd for remote exec-events feature.
Modify call to add_setshow_string_noescape_cmd for exec-file
to use new functions set_remote_exec_file and
show_remote_exec_file.
* target-debug.h, target-delegates.c: Regenerated.
* target.c (target_follow_exec): New function.
* target.h (struct target_ops) <to_follow_exec>: New member.
(target_follow_exec): Declare new function.
2015-09-12 02:06:02 +08:00
|
|
|
if (ops->to_follow_exec == NULL)
|
|
|
|
ops->to_follow_exec = delegate_follow_exec;
|
2013-12-19 01:46:38 +08:00
|
|
|
if (ops->to_set_syscall_catchpoint == NULL)
|
|
|
|
ops->to_set_syscall_catchpoint = delegate_set_syscall_catchpoint;
|
2013-12-19 01:47:22 +08:00
|
|
|
if (ops->to_has_exited == NULL)
|
|
|
|
ops->to_has_exited = delegate_has_exited;
|
2013-12-19 05:40:23 +08:00
|
|
|
if (ops->to_mourn_inferior == NULL)
|
|
|
|
ops->to_mourn_inferior = delegate_mourn_inferior;
|
2013-12-21 03:19:37 +08:00
|
|
|
if (ops->to_can_run == NULL)
|
|
|
|
ops->to_can_run = delegate_can_run;
|
2013-12-19 05:42:10 +08:00
|
|
|
if (ops->to_pass_signals == NULL)
|
|
|
|
ops->to_pass_signals = delegate_pass_signals;
|
2013-12-19 05:42:54 +08:00
|
|
|
if (ops->to_program_signals == NULL)
|
|
|
|
ops->to_program_signals = delegate_program_signals;
|
2013-12-19 22:21:56 +08:00
|
|
|
if (ops->to_thread_alive == NULL)
|
|
|
|
ops->to_thread_alive = delegate_thread_alive;
|
Push pruning old threads down to the target
When GDB wants to sync the thread list with the target's (e.g., due to
"info threads"), it calls update_thread_list:
update_thread_list (void)
{
prune_threads ();
target_find_new_threads ();
update_threads_executing ();
}
And then prune_threads does:
prune_threads (void)
{
struct thread_info *tp, *next;
for (tp = thread_list; tp; tp = next)
{
next = tp->next;
if (!thread_alive (tp))
delete_thread (tp->ptid);
}
}
Calling thread_live on each thread one by one is expensive.
E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not
a big deal, but still a bunch of syscalls...
With the remote target, it's cumbersome. That thread_alive call ends
up generating one T packet per thread:
Sending packet: $Tp2141.2150#82...Packet received: OK
Sending packet: $Tp2141.214f#b7...Packet received: OK
Sending packet: $Tp2141.2141#82...Packet received: OK
Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n
That seems a bit silly when target_find_new_threads method
implementations will always fetch the whole current set of target
threads, and then add those that are not in GDB's thread list, to
GDB's thread list.
This patch thus pushes down the responsibility of pruning dead threads
to the target_find_new_threads method instead, so a target may
implement pruning dead threads however it wants.
Once we do that, target_find_new_threads becomes a misnomer, so the
patch renames it to target_update_thread_list.
The patch doesn't attempt to do any optimization to any target yet.
It simply exports prune_threads, and makes all implementations of
target_update_thread_list call that. It's meant to be a no-op.
gdb/
2014-10-15 Pedro Alves <palves@redhat.com>
* ada-tasks.c (print_ada_task_info, task_command_1): Adjust.
* bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ...
(bsd_uthread_update_thread_list): ... this. Call prune_threads.
(bsd_uthread_target): Adjust.
* corelow.c (core_open): Adjust.
* dec-thread.c (dec_thread_find_new_threads): Update comment.
(dec_thread_update_thread_list): New function.
(init_dec_thread_ops): Adjust.
* gdbthread.h (prune_threads): New declaration.
* linux-thread-db.c (thread_db_find_new_threads): Rename to ...
(thread_db_update_thread_list): ... this. Call prune_threads.
(init_thread_db_ops): Adjust.
* nto-procfs.c (procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
(procfs_attach, procfs_create_inferior, init_procfs_targets):
Adjust.
* obsd-nat.c (obsd_find_new_threads): Rename to ...
(obsd_update_thread_list): ... this. Call prune_threads.
(obsd_add_target): Adjust.
* procfs.c (procfs_target): Adjust.
(procfs_notice_thread): Update comment.
(procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
* ravenscar-thread.c (ravenscar_update_inferior_ptid): Update
comment.
(ravenscar_wait): Adjust.
(ravenscar_find_new_threads): Rename to ...
(ravenscar_update_thread_list): ... this. Call prune_threads.
(init_ravenscar_thread_ops): Adjust.
* record-btrace.c (record_btrace_find_new_threads): Rename to ...
(record_btrace_update_thread_list): ... this. Adjust comment.
(init_record_btrace_ops): Adjust.
* remote.c (remote_threads_info): Rename to ...
(remote_update_thread_list): ... this. Call prune_threads.
(remote_start_remote, extended_remote_attach_1, init_remote_ops):
Adjust.
* sol-thread.c (check_for_thread_db): Adjust.
(sol_find_new_threads_callback): Rename to ...
(sol_update_thread_list_callback): ... this.
(sol_find_new_threads): Rename to ...
(sol_update_thread_list): ... this. Call prune_threads. Adjust.
(sol_get_ada_task_ptid, init_sol_thread_ops): Adjust.
* target-delegates.c: Regenerate.
* target.c (target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* target.h (struct target_ops): Rename to_find_new_threads field
to to_update_thread_list.
(target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* thread.c (prune_threads): Make extern.
(update_thread_list): Adjust.
2014-10-16 05:44:00 +08:00
|
|
|
if (ops->to_update_thread_list == NULL)
|
|
|
|
ops->to_update_thread_list = delegate_update_thread_list;
|
2013-12-19 05:46:03 +08:00
|
|
|
if (ops->to_pid_to_str == NULL)
|
|
|
|
ops->to_pid_to_str = delegate_pid_to_str;
|
2013-12-19 01:48:36 +08:00
|
|
|
if (ops->to_extra_thread_info == NULL)
|
|
|
|
ops->to_extra_thread_info = delegate_extra_thread_info;
|
2013-12-19 01:49:35 +08:00
|
|
|
if (ops->to_thread_name == NULL)
|
|
|
|
ops->to_thread_name = delegate_thread_name;
|
2013-12-19 05:28:07 +08:00
|
|
|
if (ops->to_stop == NULL)
|
|
|
|
ops->to_stop = delegate_stop;
|
Fix interrupt-noterm.exp on targets always in non-stop
With "maint set target-non-stop on" we get:
@@ -66,13 +66,16 @@ Continuing.
interrupt
(gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt
-Program received signal SIGINT, Interrupt.
-PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT
-testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds
+[process 12119] #1 stopped.
+0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81
+81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
+FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout)
+testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds
That is, we get "[$thread] #1 stopped" instead of SIGINT.
The issue is that we don't currently distinguish send
"interrupt/ctrl-c" to target terminal vs "stop/pause" thread well;
both cases go through "target_stop".
And then, the native Linux backend (linux-nat.c) implements
target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop
mode. Since "maint set target-non-stop on" forces the backend to be
always running in non-stop mode, even though the user-visible behavior
is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of
the SIGINT the test expects.
Fix this by introducing a target_interrupt method to use in the
"interrupt/ctrl-c" case, so "set non-stop off" can always work the
same irrespective of "maint set target-non-stop on/off". I'm
explictly considering changing the "set non-stop on" behavior as out
of scope here.
Most of the patch is an across-the-board rename of to_stop hook
implementations to to_interrupt. The only targets where something
more than a rename is being done are linux-nat.c and remote.c, which
are the only targets that support async, and thus are the only ones
the core side calls target_stop on.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_stop): Rename to ...
(darwin_interrupt): ... this.
(_initialize_darwin_inferior): Adjust.
* gnu-nat.c (gnu_stop): Delete.
(gnu_target): Don't install gnu_stop.
* inf-ptrace.c (inf_ptrace_stop): Rename to ...
(inf_ptrace_interrupt): ... this.
(inf_ptrace_target): Adjust.
* infcmd.c (interrupt_target_1): Use target_interrupt instead of
target_stop.
* linux-nat (linux_nat_stop): Rename to ...
(linux_nat_interrupt): ... this.
(linux_nat_stop): Reimplement.
(linux_nat_add_target): Install linux_nat_interrupt.
* nto-procfs.c (nto_interrupt_twice): Rename to ...
(nto_handle_sigint_twice): ... this.
(nto_interrupt): Rename to ...
(nto_handle_sigint): ... this. Call target_interrupt instead of
target_stop.
(procfs_wait): Adjust.
(procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(init_procfs_targets): Adjust.
* procfs.c (procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(procfs_target): Adjust.
* remote-m32r-sdi.c (m32r_stop): Rename to ...
(m32r_interrupt): ... this.
(init_m32r_ops): Adjust.
* remote-sim.c (gdbsim_stop_inferior): Rename to ...
(gdbsim_interrupt_inferior): ... this.
(gdbsim_stop): Rename to ...
(gdbsim_interrupt): ... this.
(gdbsim_cntrl_c): Adjust.
(init_gdbsim_ops): Adjust.
* remote.c (sync_remote_interrupt): Adjust comments.
(remote_stop_as): Rename to ...
(remote_interrupt_as): ... this.
(remote_stop): Adjust comment.
(remote_interrupt): New function.
(init_remote_ops): Install remote_interrupt.
* target.c (target_interrupt): New function.
* target.h (struct target_ops) <to_interrupt>: New field.
(target_interrupt): New declaration.
* windows-nat.c (windows_stop): Rename to ...
(windows_interrupt): ... this.
* target-delegates.c: Regenerate.
2015-08-07 01:22:58 +08:00
|
|
|
if (ops->to_interrupt == NULL)
|
|
|
|
ops->to_interrupt = delegate_interrupt;
|
remote: allow aborting long operations (e.g., file transfers)
Currently, when remote debugging, if you type Ctrl-C just while the
target stopped for an internal event, and GDB is busy doing something
that takes a while (e.g., fetching chunks of a shared library off of
the target, with vFile, to process ELF headers and debug info), the
Ctrl-C is lost.
The patch hooks up the QUIT macro to a new target method that lets the
target react to the double-Ctrl-C before the event loop is reached,
which allows reacting to a double-Ctrl-C even when GDB is busy doing
some long operation and not waiting for a stop reply. That end result
is:
(gdb) c
Continuing.
^C
^C
Interrupted while waiting for the program.
Give up waiting? (y or n) y
Quit
(gdb) info threads
Id Target Id Frame
* 1 Thread 11673 0x00007ffff7deb240 in _dl_debug_state () from target:/lib64/ld-linux-x86-64.so.2
(gdb)
If, however, GDB is waiting for a stop reply (because the target has
been resumed, with e.g., vCont;c), but the target isn't responding, we
now get:
(gdb) c
Continuing.
^C
^C
The target is not responding to interrupt requests.
Stop debugging it? (y or n) y
Disconnected from target.
(gdb) info threads
No threads.
This offers to disconnect, because when we're waiting for a stop
reply, there's nothing else we can send the target other than an
interrupt request. And if that doesn't work, there's nothing else we
can do.
The Ctrl-C is presently lost because until we get to a user-visible
stop, the SIGINT handler that is installed is the one that forwards
the interrupt to the remote side, with the \003 "packet" [1]. But,
gdbserver ignores an interrupt request if the program is stopped.
Still, even if it didn't, the server can only report back a
stop-because-of-SIGINT when the program is next resumed. And it may
take a while to actually re-resume the target.
[1] - In the old sync days, the remote target would react to a
double-Ctrl-C by asking users whether they wanted to give up waiting
and disconnect. The code is still there, but it it isn't reacheable
on most hosts, which support serial connections in async mode
(probably only DJGPP doesn't). Even then, in sync mode, remote.c's
SIGINT handler is only installed while the target is resumed, and is
removed as soon as the target sends back a stop reply. That means
that a Ctrl-C just while GDB is processing an internal event can end
up with an odd "Quit" at the prompt instead of "Program stopped by
SIGINT". In contrast, in async mode, remote.c's SIGINT handler is set
up as long as target_terminal_inferior or
target_terminal_ours_for_output are in effect (IOW, until we get a
user-visible stop and call target_terminal_ours), so the user
shouldn't get back a spurious Quit. However, it's still desirable to
be able to interrupt a long-running GDB operation, if GDB takes a
while to re-resume the target or get back to the event loop.
Tested on x86_64 Fedora 20.
gdb/ChangeLog:
2015-08-24 Pedro Alves <palves@redhat.com>
* defs.h (maybe_quit): Declare.
(QUIT): Now calls maybe_quit.
* event-loop.c (clear_async_signal_handler)
(async_signal_handler_is_marked): New functions.
* event-loop.h (async_signal_handler_is_marked)
(clear_async_signal_handler): New declarations.
* remote.c (remote_check_pending_interrupt): New function.
(interrupt_query): Use make_cleanup_restore_target_terminal. No
longer check whether the target is async. If waiting for a stop
reply, and a Ctrl-C as been sent to the target, offer to
disconnect, and throw TARGET_CLOSE_ERROR instead of a quit.
Otherwise do not disconnect and throw a quit.
(_initialize_remote): Install remote_check_pending_interrupt as
to_check_pending_interrupt.
* target.c (target_check_pending_interrupt): New function.
* target.h (struct target_ops) <to_check_pending_interrupt>: New
field.
(target_check_pending_interrupt): New declaration.
* utils.c (maybe_quit): New function.
* target-delegates.c: Regenerate.
2015-08-25 23:12:11 +08:00
|
|
|
if (ops->to_check_pending_interrupt == NULL)
|
|
|
|
ops->to_check_pending_interrupt = delegate_check_pending_interrupt;
|
2013-12-19 00:35:21 +08:00
|
|
|
if (ops->to_rcmd == NULL)
|
|
|
|
ops->to_rcmd = delegate_rcmd;
|
2013-12-19 01:51:10 +08:00
|
|
|
if (ops->to_pid_to_exec_file == NULL)
|
|
|
|
ops->to_pid_to_exec_file = delegate_pid_to_exec_file;
|
2013-12-19 01:52:58 +08:00
|
|
|
if (ops->to_log_command == NULL)
|
|
|
|
ops->to_log_command = delegate_log_command;
|
2013-12-19 05:47:06 +08:00
|
|
|
if (ops->to_get_section_table == NULL)
|
|
|
|
ops->to_get_section_table = delegate_get_section_table;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
if (ops->to_can_async_p == NULL)
|
|
|
|
ops->to_can_async_p = delegate_can_async_p;
|
|
|
|
if (ops->to_is_async_p == NULL)
|
|
|
|
ops->to_is_async_p = delegate_is_async_p;
|
|
|
|
if (ops->to_async == NULL)
|
|
|
|
ops->to_async = delegate_async;
|
fix regressions with target-async
A patch in the target cleanup series caused a regression when using
record with target-async. Version 4 of the patch is here:
https://sourceware.org/ml/gdb-patches/2014-03/msg00159.html
The immediate problem is that record supplies to_can_async_p and
to_is_async_p methods, but does not supply a to_async method. So,
when target-async is set, record claims to support async -- but if the
underlying target does not support async, then the to_async method
call will end up in that method's default implementation, namely
tcomplain.
This worked previously because the record target used to provide a
to_async method; one that (erroneously, only at push time) checked the
other members of the target stack, and then simply dropped to_async
calls in the "does not implement async" case.
My first thought was to simply drop tcomplain as the default for
to_async. This works, but Pedro pointed out that the only reason
record has to supply to_can_async_p and to_is_async_p is that these
default to using the find_default_run_target machinery -- and these
defaults are only needed by "run" and "attach".
So, a nicer solution presents itself: change run and attach to
explicitly call into the default run target when needed; and change
to_is_async_p and to_can_async_p to default to "return 0". This makes
the target stack simpler to use and lets us remove the method
implementations from record. This is also in harmony with other plans
for the target stack; namely trying to reduce the impact of
find_default_run_target. This approach makes it clear that
find_default_is_async_p is not needed -- it is asking whether a target
that may not even be pushed is actually async, which seems like a
nonsensical question.
While an improvement, this approach proved to introduce the same bug
when using the core target. Looking a bit deeper, the issue is that
code in "attach" and "run" may need to use either the current target
stack or the default run target -- but different calls into the target
API in those functions could wind up querying different targets.
This new patch makes the target to use more explicit in "run" and
"attach". Then these commands explicitly make the needed calls
against that target. This ensures that a single target is used for
all relevant operations. This lets us remove a couple find_default_*
functions from various targets, including the dummy target. I think
this is a decent understandability improvement.
One issue I see with this patch is that the new calls in "run" and
"attach" are not very much like the rest of the target API. I think
fundamentally this is due to bad factoring in the target API, which
may need to be fixed for multi-target. Tackling that seemed ambitious
for a regression fix.
While working on this I noticed that there don't seem to be any test
cases that involve both target-async and record, so this patch changes
break-precsave.exp to add some. It also changes corefile.exp to add
some target-async tests; these pass with current trunk and with this
patch applied, but fail with the v1 patch.
This patch differs from v4 in that it moves initialization of
to_can_async_p and to_supports_non_stop into inf-child, adds some
assertions to complete_target_initialization, and adds some comments
to target.h.
Built and regtested on x86-64 Fedora 20.
2014-03-12 Tom Tromey <tromey@redhat.com>
* inf-child.c (return_zero): New function.
(inf_child_target): Set to_can_async_p, to_supports_non_stop.
* aix-thread.c (aix_thread_inferior_created): New function.
(aix_thread_attach): Remove.
(init_aix_thread_ops): Don't set to_attach.
(_initialize_aix_thread): Register inferior_created observer.
* corelow.c (init_core_ops): Don't set to_attach or
to_create_inferior.
* exec.c (init_exec_ops): Don't set to_attach or
to_create_inferior.
* infcmd.c (run_command_1): Use find_run_target. Make direct
target calls.
(attach_command): Use find_attach_target. Make direct target
calls.
* record-btrace.c (init_record_btrace_ops): Don't set
to_create_inferior.
* record-full.c (record_full_can_async_p, record_full_is_async_p):
Remove.
(init_record_full_ops, init_record_full_core_ops): Update. Don't
set to_create_inferior.
* target.c (complete_target_initialization): Add assertion.
(target_create_inferior): Remove.
(find_default_attach, find_default_create_inferior): Remove.
(find_attach_target, find_run_target): New functions.
(find_default_is_async_p, find_default_can_async_p)
(target_supports_non_stop, target_attach): Remove.
(init_dummy_target): Don't set to_create_inferior or
to_supports_non_stop.
* target.h (struct target_ops) <to_attach>: Add comment. Remove
TARGET_DEFAULT_FUNC.
<to_create_inferior>: Add comment.
<to_can_async_p, to_is_async_p, to_supports_non_stop>: Use
TARGET_DEFAULT_RETURN.
<to_can_async_p, to_supports_non_stop, to_can_run>: Add comments.
(find_attach_target, find_run_target): Declare.
(target_create_inferior): Remove.
(target_has_execution_1): Update comment.
(target_supports_non_stop): Remove.
* target-delegates.c: Rebuild.
2014-03-12 Tom Tromey <tromey@redhat.com>
* gdb.base/corefile.exp (corefile_test_run, corefile_test_attach):
New procs. Add target-async tests.
* gdb.reverse/break-precsave.exp (precsave_tests): New proc.
Add target-async tests.
2014-03-01 00:47:34 +08:00
|
|
|
if (ops->to_supports_non_stop == NULL)
|
|
|
|
ops->to_supports_non_stop = delegate_supports_non_stop;
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-08 00:24:01 +08:00
|
|
|
if (ops->to_always_non_stop_p == NULL)
|
|
|
|
ops->to_always_non_stop_p = delegate_always_non_stop_p;
|
2013-12-19 01:55:34 +08:00
|
|
|
if (ops->to_find_memory_regions == NULL)
|
|
|
|
ops->to_find_memory_regions = delegate_find_memory_regions;
|
2013-12-19 01:57:18 +08:00
|
|
|
if (ops->to_make_corefile_notes == NULL)
|
|
|
|
ops->to_make_corefile_notes = delegate_make_corefile_notes;
|
2013-12-19 02:10:32 +08:00
|
|
|
if (ops->to_get_bookmark == NULL)
|
|
|
|
ops->to_get_bookmark = delegate_get_bookmark;
|
2013-12-19 02:11:25 +08:00
|
|
|
if (ops->to_goto_bookmark == NULL)
|
|
|
|
ops->to_goto_bookmark = delegate_goto_bookmark;
|
2014-06-26 00:16:55 +08:00
|
|
|
if (ops->to_get_thread_local_address == NULL)
|
|
|
|
ops->to_get_thread_local_address = delegate_get_thread_local_address;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
if (ops->to_xfer_partial == NULL)
|
|
|
|
ops->to_xfer_partial = delegate_xfer_partial;
|
2013-12-19 22:47:11 +08:00
|
|
|
if (ops->to_memory_map == NULL)
|
|
|
|
ops->to_memory_map = delegate_memory_map;
|
2013-12-19 05:50:56 +08:00
|
|
|
if (ops->to_flash_erase == NULL)
|
|
|
|
ops->to_flash_erase = delegate_flash_erase;
|
2013-12-19 05:52:02 +08:00
|
|
|
if (ops->to_flash_done == NULL)
|
|
|
|
ops->to_flash_done = delegate_flash_done;
|
2014-01-14 00:30:30 +08:00
|
|
|
if (ops->to_read_description == NULL)
|
|
|
|
ops->to_read_description = delegate_read_description;
|
2013-12-19 04:53:09 +08:00
|
|
|
if (ops->to_get_ada_task_ptid == NULL)
|
|
|
|
ops->to_get_ada_task_ptid = delegate_get_ada_task_ptid;
|
2013-12-19 22:56:20 +08:00
|
|
|
if (ops->to_auxv_parse == NULL)
|
|
|
|
ops->to_auxv_parse = delegate_auxv_parse;
|
2013-12-19 23:12:26 +08:00
|
|
|
if (ops->to_search_memory == NULL)
|
|
|
|
ops->to_search_memory = delegate_search_memory;
|
2013-12-19 02:12:28 +08:00
|
|
|
if (ops->to_can_execute_reverse == NULL)
|
|
|
|
ops->to_can_execute_reverse = delegate_can_execute_reverse;
|
2013-12-19 02:15:21 +08:00
|
|
|
if (ops->to_execution_direction == NULL)
|
|
|
|
ops->to_execution_direction = delegate_execution_direction;
|
2013-12-19 04:54:06 +08:00
|
|
|
if (ops->to_supports_multi_process == NULL)
|
|
|
|
ops->to_supports_multi_process = delegate_supports_multi_process;
|
2013-12-19 04:54:59 +08:00
|
|
|
if (ops->to_supports_enable_disable_tracepoint == NULL)
|
|
|
|
ops->to_supports_enable_disable_tracepoint = delegate_supports_enable_disable_tracepoint;
|
2013-12-19 04:56:04 +08:00
|
|
|
if (ops->to_supports_string_tracing == NULL)
|
|
|
|
ops->to_supports_string_tracing = delegate_supports_string_tracing;
|
2013-12-19 05:20:06 +08:00
|
|
|
if (ops->to_supports_evaluation_of_breakpoint_conditions == NULL)
|
|
|
|
ops->to_supports_evaluation_of_breakpoint_conditions = delegate_supports_evaluation_of_breakpoint_conditions;
|
2013-12-19 05:20:36 +08:00
|
|
|
if (ops->to_can_run_breakpoint_commands == NULL)
|
|
|
|
ops->to_can_run_breakpoint_commands = delegate_can_run_breakpoint_commands;
|
2013-12-19 02:16:31 +08:00
|
|
|
if (ops->to_thread_architecture == NULL)
|
|
|
|
ops->to_thread_architecture = delegate_thread_architecture;
|
2014-02-22 01:33:42 +08:00
|
|
|
if (ops->to_thread_address_space == NULL)
|
|
|
|
ops->to_thread_address_space = delegate_thread_address_space;
|
2015-04-02 20:38:28 +08:00
|
|
|
if (ops->to_filesystem_is_local == NULL)
|
|
|
|
ops->to_filesystem_is_local = delegate_filesystem_is_local;
|
2013-12-19 04:57:05 +08:00
|
|
|
if (ops->to_trace_init == NULL)
|
|
|
|
ops->to_trace_init = delegate_trace_init;
|
2013-12-19 04:57:41 +08:00
|
|
|
if (ops->to_download_tracepoint == NULL)
|
|
|
|
ops->to_download_tracepoint = delegate_download_tracepoint;
|
2013-12-19 05:00:23 +08:00
|
|
|
if (ops->to_can_download_tracepoint == NULL)
|
|
|
|
ops->to_can_download_tracepoint = delegate_can_download_tracepoint;
|
2013-12-19 05:01:07 +08:00
|
|
|
if (ops->to_download_trace_state_variable == NULL)
|
|
|
|
ops->to_download_trace_state_variable = delegate_download_trace_state_variable;
|
2013-12-19 05:01:51 +08:00
|
|
|
if (ops->to_enable_tracepoint == NULL)
|
|
|
|
ops->to_enable_tracepoint = delegate_enable_tracepoint;
|
2013-12-19 05:02:30 +08:00
|
|
|
if (ops->to_disable_tracepoint == NULL)
|
|
|
|
ops->to_disable_tracepoint = delegate_disable_tracepoint;
|
2013-12-19 05:03:28 +08:00
|
|
|
if (ops->to_trace_set_readonly_regions == NULL)
|
|
|
|
ops->to_trace_set_readonly_regions = delegate_trace_set_readonly_regions;
|
2013-12-19 05:04:27 +08:00
|
|
|
if (ops->to_trace_start == NULL)
|
|
|
|
ops->to_trace_start = delegate_trace_start;
|
2013-12-19 05:06:18 +08:00
|
|
|
if (ops->to_get_trace_status == NULL)
|
|
|
|
ops->to_get_trace_status = delegate_get_trace_status;
|
2013-12-19 05:06:52 +08:00
|
|
|
if (ops->to_get_tracepoint_status == NULL)
|
|
|
|
ops->to_get_tracepoint_status = delegate_get_tracepoint_status;
|
2013-12-19 05:07:28 +08:00
|
|
|
if (ops->to_trace_stop == NULL)
|
|
|
|
ops->to_trace_stop = delegate_trace_stop;
|
2013-12-19 05:08:14 +08:00
|
|
|
if (ops->to_trace_find == NULL)
|
|
|
|
ops->to_trace_find = delegate_trace_find;
|
2013-12-19 05:09:04 +08:00
|
|
|
if (ops->to_get_trace_state_variable_value == NULL)
|
|
|
|
ops->to_get_trace_state_variable_value = delegate_get_trace_state_variable_value;
|
2013-12-19 05:09:37 +08:00
|
|
|
if (ops->to_save_trace_data == NULL)
|
|
|
|
ops->to_save_trace_data = delegate_save_trace_data;
|
2013-12-19 05:10:14 +08:00
|
|
|
if (ops->to_upload_tracepoints == NULL)
|
|
|
|
ops->to_upload_tracepoints = delegate_upload_tracepoints;
|
2013-12-19 05:10:40 +08:00
|
|
|
if (ops->to_upload_trace_state_variables == NULL)
|
|
|
|
ops->to_upload_trace_state_variables = delegate_upload_trace_state_variables;
|
2013-12-19 05:11:12 +08:00
|
|
|
if (ops->to_get_raw_trace_data == NULL)
|
|
|
|
ops->to_get_raw_trace_data = delegate_get_raw_trace_data;
|
2013-12-19 05:11:53 +08:00
|
|
|
if (ops->to_get_min_fast_tracepoint_insn_len == NULL)
|
|
|
|
ops->to_get_min_fast_tracepoint_insn_len = delegate_get_min_fast_tracepoint_insn_len;
|
2013-12-19 05:12:29 +08:00
|
|
|
if (ops->to_set_disconnected_tracing == NULL)
|
|
|
|
ops->to_set_disconnected_tracing = delegate_set_disconnected_tracing;
|
2013-12-19 05:13:09 +08:00
|
|
|
if (ops->to_set_circular_trace_buffer == NULL)
|
|
|
|
ops->to_set_circular_trace_buffer = delegate_set_circular_trace_buffer;
|
2013-12-19 05:14:58 +08:00
|
|
|
if (ops->to_set_trace_buffer_size == NULL)
|
|
|
|
ops->to_set_trace_buffer_size = delegate_set_trace_buffer_size;
|
2013-12-19 05:15:23 +08:00
|
|
|
if (ops->to_set_trace_notes == NULL)
|
|
|
|
ops->to_set_trace_notes = delegate_set_trace_notes;
|
2013-12-19 05:55:06 +08:00
|
|
|
if (ops->to_core_of_thread == NULL)
|
|
|
|
ops->to_core_of_thread = delegate_core_of_thread;
|
2013-12-19 05:55:44 +08:00
|
|
|
if (ops->to_verify_memory == NULL)
|
|
|
|
ops->to_verify_memory = delegate_verify_memory;
|
2013-12-19 05:15:55 +08:00
|
|
|
if (ops->to_get_tib_address == NULL)
|
|
|
|
ops->to_get_tib_address = delegate_get_tib_address;
|
2013-12-19 05:16:24 +08:00
|
|
|
if (ops->to_set_permissions == NULL)
|
|
|
|
ops->to_set_permissions = delegate_set_permissions;
|
2013-12-19 05:16:51 +08:00
|
|
|
if (ops->to_static_tracepoint_marker_at == NULL)
|
|
|
|
ops->to_static_tracepoint_marker_at = delegate_static_tracepoint_marker_at;
|
2013-12-19 05:17:35 +08:00
|
|
|
if (ops->to_static_tracepoint_markers_by_strid == NULL)
|
|
|
|
ops->to_static_tracepoint_markers_by_strid = delegate_static_tracepoint_markers_by_strid;
|
2013-12-19 05:18:10 +08:00
|
|
|
if (ops->to_traceframe_info == NULL)
|
|
|
|
ops->to_traceframe_info = delegate_traceframe_info;
|
2013-12-19 05:18:35 +08:00
|
|
|
if (ops->to_use_agent == NULL)
|
|
|
|
ops->to_use_agent = delegate_use_agent;
|
2013-12-19 05:19:04 +08:00
|
|
|
if (ops->to_can_use_agent == NULL)
|
|
|
|
ops->to_can_use_agent = delegate_can_use_agent;
|
2013-12-14 04:26:04 +08:00
|
|
|
if (ops->to_supports_btrace == NULL)
|
|
|
|
ops->to_supports_btrace = delegate_supports_btrace;
|
2013-12-19 23:19:41 +08:00
|
|
|
if (ops->to_enable_btrace == NULL)
|
|
|
|
ops->to_enable_btrace = delegate_enable_btrace;
|
2013-12-19 23:17:16 +08:00
|
|
|
if (ops->to_disable_btrace == NULL)
|
|
|
|
ops->to_disable_btrace = delegate_disable_btrace;
|
2013-12-19 23:18:04 +08:00
|
|
|
if (ops->to_teardown_btrace == NULL)
|
|
|
|
ops->to_teardown_btrace = delegate_teardown_btrace;
|
2013-12-19 23:19:02 +08:00
|
|
|
if (ops->to_read_btrace == NULL)
|
|
|
|
ops->to_read_btrace = delegate_read_btrace;
|
2013-11-28 22:44:13 +08:00
|
|
|
if (ops->to_btrace_conf == NULL)
|
|
|
|
ops->to_btrace_conf = delegate_btrace_conf;
|
2013-12-19 23:21:20 +08:00
|
|
|
if (ops->to_stop_recording == NULL)
|
|
|
|
ops->to_stop_recording = delegate_stop_recording;
|
2014-07-16 22:05:03 +08:00
|
|
|
if (ops->to_info_record == NULL)
|
|
|
|
ops->to_info_record = delegate_info_record;
|
2013-12-19 11:26:34 +08:00
|
|
|
if (ops->to_save_record == NULL)
|
|
|
|
ops->to_save_record = delegate_save_record;
|
2013-12-19 11:25:47 +08:00
|
|
|
if (ops->to_delete_record == NULL)
|
|
|
|
ops->to_delete_record = delegate_delete_record;
|
2013-12-19 11:25:01 +08:00
|
|
|
if (ops->to_record_is_replaying == NULL)
|
|
|
|
ops->to_record_is_replaying = delegate_record_is_replaying;
|
2015-09-17 17:14:55 +08:00
|
|
|
if (ops->to_record_will_replay == NULL)
|
|
|
|
ops->to_record_will_replay = delegate_record_will_replay;
|
2015-09-08 15:42:20 +08:00
|
|
|
if (ops->to_record_stop_replaying == NULL)
|
|
|
|
ops->to_record_stop_replaying = delegate_record_stop_replaying;
|
2013-12-19 11:24:04 +08:00
|
|
|
if (ops->to_goto_record_begin == NULL)
|
|
|
|
ops->to_goto_record_begin = delegate_goto_record_begin;
|
2013-12-19 11:23:23 +08:00
|
|
|
if (ops->to_goto_record_end == NULL)
|
|
|
|
ops->to_goto_record_end = delegate_goto_record_end;
|
2013-12-19 11:22:36 +08:00
|
|
|
if (ops->to_goto_record == NULL)
|
|
|
|
ops->to_goto_record = delegate_goto_record;
|
2013-12-19 11:18:49 +08:00
|
|
|
if (ops->to_insn_history == NULL)
|
|
|
|
ops->to_insn_history = delegate_insn_history;
|
2013-12-19 11:16:56 +08:00
|
|
|
if (ops->to_insn_history_from == NULL)
|
|
|
|
ops->to_insn_history_from = delegate_insn_history_from;
|
2013-12-19 11:15:44 +08:00
|
|
|
if (ops->to_insn_history_range == NULL)
|
|
|
|
ops->to_insn_history_range = delegate_insn_history_range;
|
2013-12-19 11:13:40 +08:00
|
|
|
if (ops->to_call_history == NULL)
|
|
|
|
ops->to_call_history = delegate_call_history;
|
2013-12-19 11:11:49 +08:00
|
|
|
if (ops->to_call_history_from == NULL)
|
|
|
|
ops->to_call_history_from = delegate_call_history_from;
|
2013-12-19 11:10:20 +08:00
|
|
|
if (ops->to_call_history_range == NULL)
|
|
|
|
ops->to_call_history_range = delegate_call_history_range;
|
2013-12-19 05:19:33 +08:00
|
|
|
if (ops->to_augmented_libraries_svr4_read == NULL)
|
|
|
|
ops->to_augmented_libraries_svr4_read = delegate_augmented_libraries_svr4_read;
|
2014-01-17 04:00:07 +08:00
|
|
|
if (ops->to_get_unwinder == NULL)
|
|
|
|
ops->to_get_unwinder = delegate_get_unwinder;
|
|
|
|
if (ops->to_get_tailcall_unwinder == NULL)
|
|
|
|
ops->to_get_tailcall_unwinder = delegate_get_tailcall_unwinder;
|
2014-05-20 21:22:53 +08:00
|
|
|
if (ops->to_prepare_to_generate_core == NULL)
|
|
|
|
ops->to_prepare_to_generate_core = delegate_prepare_to_generate_core;
|
|
|
|
if (ops->to_done_generating_core == NULL)
|
|
|
|
ops->to_done_generating_core = delegate_done_generating_core;
|
2013-12-20 00:38:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
install_dummy_methods (struct target_ops *ops)
|
|
|
|
{
|
2013-12-19 00:42:24 +08:00
|
|
|
ops->to_post_attach = tdefault_post_attach;
|
2013-12-14 04:33:08 +08:00
|
|
|
ops->to_detach = tdefault_detach;
|
2013-12-21 01:30:13 +08:00
|
|
|
ops->to_disconnect = tdefault_disconnect;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
ops->to_resume = tdefault_resume;
|
Merge async and sync code paths some more
This patch makes the execution control code use largely the same
mechanisms in both sync- and async-capable targets. This means using
continuations and use the event loop to react to target events on sync
targets as well. The trick is to immediately mark infrun's event loop
source after resume instead of calling wait_for_inferior. Then
fetch_inferior_event is adjusted to do a blocking wait on sync
targets.
Tested on x86_64 Fedora 20, native and gdbserver, with and without
"maint set target-async off".
gdb/ChangeLog:
2015-09-09 Pedro Alves <palves@redhat.com>
* breakpoint.c (bpstat_do_actions_1, until_break_command): Don't
check whether the target can async.
* inf-loop.c (inferior_event_handler): Only call target_async if
the target can async.
* infcall.c: Include top.h and interps.h.
(run_inferior_call): For the interpreter to sync mode while
running the infcall. Call wait_sync_command_done instead of
wait_for_inferior plus normal_stop.
* infcmd.c (prepare_execution_command): Don't check whether the
target can async when running in the foreground.
(step_1): Delete synchronous case handling.
(step_once): Always install a continuation, even in sync mode.
(until_next_command, finish_forward): Don't check whether the
target can async.
(attach_command_post_wait, notice_new_inferior): Always install a
continuation, even in sync mode.
* infrun.c (mark_infrun_async_event_handler): New function.
(proceed): In sync mode, mark infrun's event source instead of
waiting for events here.
(fetch_inferior_event): If the target can't async, do a blocking
wait.
(prepare_to_wait): In sync mode, mark infrun's event source.
(infrun_async_inferior_event_handler): No longer bail out if the
target can't async.
* infrun.h (mark_infrun_async_event_handler): New declaration.
* linux-nat.c (linux_nat_wait_1): Remove calls to
set_sigint_trap/clear_sigint_trap.
(linux_nat_terminal_inferior): No longer check whether the target
can async.
* mi/mi-interp.c (mi_on_sync_execution_done): Update and simplify
comment.
(mi_execute_command_input_handler): No longer check whether the
target is async. Update and simplify comment.
* target.c (default_target_wait): New function.
* target.h (struct target_ops) <to_wait>: Now defaults to
default_target_wait.
(default_target_wait): Declare.
* top.c (wait_sync_command_done): New function, factored out from
...
(maybe_wait_sync_command_done): ... this.
* top.h (wait_sync_command_done): Declare.
* target-delegates.c: Regenerate.
2015-09-10 01:23:23 +08:00
|
|
|
ops->to_wait = default_target_wait;
|
2013-12-19 05:30:22 +08:00
|
|
|
ops->to_fetch_registers = tdefault_fetch_registers;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
ops->to_store_registers = tdefault_store_registers;
|
2013-12-19 00:47:18 +08:00
|
|
|
ops->to_prepare_to_store = tdefault_prepare_to_store;
|
2013-12-19 00:51:47 +08:00
|
|
|
ops->to_files_info = tdefault_files_info;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
ops->to_insert_breakpoint = memory_insert_breakpoint;
|
|
|
|
ops->to_remove_breakpoint = memory_remove_breakpoint;
|
Teach GDB about targets that can tell whether a trap is a breakpoint event
The moribund locations heuristics are problematic. This patch teaches
GDB about targets that can reliably tell whether a trap was caused by
a software or hardware breakpoint, and thus don't need moribund
locations, thus bypassing all the problems that mechanism has.
The non-stop-fair-events.exp test is frequently failing currently.
E.g., see https://sourceware.org/ml/gdb-testers/2015-q1/msg03148.html.
The root cause is a fundamental problem with moribund locations. For
example, the stepped_breakpoint logic added by af48d08f breaks in this
case (which is what happens with that test):
- Step thread A, no breakpoint is set at PC.
- The kernel doesn't schedule thread A yet.
- Insert breakpoint at A's PC, for some reason (e.g., a step-resume
breakpoint for thread B).
- Kernel finally schedules thread A.
- thread A's stepped_breakpoint flag is not set, even though it now
stepped a breakpoint instruction.
- adjust_pc_after_break gets the PC wrong, because PC == PREV_PC, but
stepped_breakpoint is not set.
We needed the stepped_breakpoint logic to workaround moribund
locations, because otherwise adjust_pc_after_break could apply an
adjustment when it shouldn't just because there _used_ to be a
breakpoint at PC (a moribund breakpoint location). For example, on
x86, that's wrong if the thread really hasn't executed an int3, but
instead executed some other 1-byte long instruction. Getting the PC
adjustment wrong of course leads to the inferior executing the wrong
instruction.
Other problems with moribund locations are:
- if a true SIGTRAP happens to be raised when the program is
executing the PC that used to have a breakpoint, GDB will assume
that is a trap for a breakpoint that has recently been removed, and
thus we miss reporting the random signal to the user.
- to minimize that, we get rid of moribund location after a while.
That while is defined as just a certain number of events being
processed. That number of events sometimes passes by before a
delayed breakpoint is processed, and GDB confuses the trap for a
random signal, thus reporting the random trap. Once the user
resumes the thread, the program crashes because the PC was not
adjusted...
The fix for all this is to bite the bullet and get rid of heuristics
and instead rely on the target knowing accurately what caused the
SIGTRAP. The target/kernel/stub is in the best position to know what
that, because it can e.g. consult priviledged CPU flags GDB has no
access to, or by knowing which exception vector entry was called when
the instruction trapped, etc. Most debug APIs I've seen to date
report breakpoint hits as a distinct event in some fashion. For
example, on the Linux kernel, whether a breakpoint was executed is
exposed to userspace in the si_code field of the SIGTRAP's siginfo.
On Windows, the debug API reports a EXCEPTION_BREAKPOINT exception
code.
We needed to keep around deleted breakpoints in an on-the-side list
(the moribund locations) for two main reasons:
- Know that a SIGTRAP actually is a delayed event for a hit of a
breakpoint that was removed before the event was processed, and
thus should not be reported as a random signal.
- So we still do the decr_pc_after_break adjustment in that case, so
that the thread is resumed at the correct address.
In the new model, if GDB processes an event the target tells is a
breakpoint trap, and GDB doesn't find the corresponding breakpoint in
its breakpoint tables, it means that event is a delayed event for a
breakpoint that has since been removed, and thus the event should be
ignored.
For the decr_pc_after_after issue, it ends up being much simpler that
on targets that can reliably tell whether a breakpoint trapped, for
the breakpoint trap to present the PC already adjusted. Proper
multi-threading support already implies that targets needs to be doing
decr_pc_after_break adjustment themselves, otherwise for example, in
all-stop if two threads hit a breakpoint simultaneously, and the user
does "info threads", he'll see the non-event thread that hit the
breakpoint stopped at the wrong PC.
This way (target adjusts) also ends up eliminating the need for some
awkward re-incrementing of the PC in the record-full and Linux targets
that we do today, and the need for the target_decr_pc_after_break
hook.
If the target always adjusts, then there's a case where GDB needs to
re-increment the PC. Say, on x86, an "int3" instruction that was
explicitly written in the program traps. In this case, GDB should
report a random SIGTRAP signal to the user, with the PC pointing at
the instruction past the int3, just like if GDB was not debugging the
program. The user may well decide to pass the SIGTRAP to the program
because the program being debugged has a SIGTRAP handler that handles
its own breakpoints, and expects the PC to be unadjusted.
Tested on x86-64 Fedora 20.
gdb/ChangeLog:
2015-03-04 Pedro Alves <palves@redhat.com>
* breakpoint.c (need_moribund_for_location_type): New function.
(bpstat_stop_status): Don't skipping checking moribund locations
of breakpoint types which the target tell caused a stop.
(program_breakpoint_here_p): New function, factored out from ...
(bp_loc_is_permanent): ... this.
(update_global_location_list): Don't create a moribund location if
the target supports reporting stops of the type of the removed
breakpoint.
* breakpoint.h (program_breakpoint_here_p): New declaration.
* infrun.c (adjust_pc_after_break): Return early if the target has
already adjusted the PC. Add comments.
(handle_signal_stop): If nothing explains a signal, and the target
tells us the stop was caused by a software breakpoint, check if
there's a breakpoint instruction in the memory. If so, adjust the
PC before presenting the stop to the user. Otherwise, ignore the
trap. If nothing explains a signal, and the target tells us the
stop was caused by a hardware breakpoint, ignore the trap.
* target.h (struct target_ops) <to_stopped_by_sw_breakpoint,
to_supports_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint,
to_supports_stopped_by_hw_breakpoint>: New fields.
(target_stopped_by_sw_breakpoint)
(target_supports_stopped_by_sw_breakpoint)
(target_stopped_by_hw_breakpoint)
(target_supports_stopped_by_hw_breakpoint): Define.
* target-delegates.c: Regenerate.
2015-03-05 04:41:15 +08:00
|
|
|
ops->to_stopped_by_sw_breakpoint = tdefault_stopped_by_sw_breakpoint;
|
|
|
|
ops->to_supports_stopped_by_sw_breakpoint = tdefault_supports_stopped_by_sw_breakpoint;
|
|
|
|
ops->to_stopped_by_hw_breakpoint = tdefault_stopped_by_hw_breakpoint;
|
|
|
|
ops->to_supports_stopped_by_hw_breakpoint = tdefault_supports_stopped_by_hw_breakpoint;
|
2013-12-19 00:58:16 +08:00
|
|
|
ops->to_can_use_hw_breakpoint = tdefault_can_use_hw_breakpoint;
|
2013-12-19 05:31:42 +08:00
|
|
|
ops->to_ranged_break_num_registers = tdefault_ranged_break_num_registers;
|
2013-12-19 01:01:11 +08:00
|
|
|
ops->to_insert_hw_breakpoint = tdefault_insert_hw_breakpoint;
|
2013-12-19 01:05:18 +08:00
|
|
|
ops->to_remove_hw_breakpoint = tdefault_remove_hw_breakpoint;
|
2013-12-19 01:11:49 +08:00
|
|
|
ops->to_remove_watchpoint = tdefault_remove_watchpoint;
|
2013-12-19 01:08:59 +08:00
|
|
|
ops->to_insert_watchpoint = tdefault_insert_watchpoint;
|
2013-12-19 05:32:43 +08:00
|
|
|
ops->to_insert_mask_watchpoint = tdefault_insert_mask_watchpoint;
|
2013-12-19 05:33:28 +08:00
|
|
|
ops->to_remove_mask_watchpoint = tdefault_remove_mask_watchpoint;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
ops->to_stopped_by_watchpoint = tdefault_stopped_by_watchpoint;
|
|
|
|
ops->to_stopped_data_address = tdefault_stopped_data_address;
|
2013-12-19 01:15:23 +08:00
|
|
|
ops->to_watchpoint_addr_within_range = default_watchpoint_addr_within_range;
|
2013-12-19 01:18:05 +08:00
|
|
|
ops->to_region_ok_for_hw_watchpoint = default_region_ok_for_hw_watchpoint;
|
2013-12-19 01:20:48 +08:00
|
|
|
ops->to_can_accel_watchpoint_condition = tdefault_can_accel_watchpoint_condition;
|
2013-12-19 05:34:15 +08:00
|
|
|
ops->to_masked_watch_num_registers = tdefault_masked_watch_num_registers;
|
Support single step by arch or target
Nowadays, GDB only knows whether architecture supports hardware single
step or software single step (through gdbarch hook software_single_step),
and for a given instruction or instruction sequence, GDB knows how to
do single step (hardware or software). However, GDB doesn't know whether
the target supports hardware single step. It is possible that the
architecture doesn't support hardware single step, such as arm, but
the target supports, such as simulator. This was discussed in this
thread https://www.sourceware.org/ml/gdb/2009-12/msg00033.html before.
I encounter this problem for aarch64 multi-arch support. When aarch64
debugs arm program, gdbarch is arm, so software single step is still
used. However, the underneath linux kernel does support hardware
single step, so IWBN to use it.
This patch is to add a new target_ops hook to_can_do_single_step, and
only use it in arm_linux_software_single_step to decide whether or not
to use hardware single step. On the native aarch64 linux target, 1 is
returned. On other targets, -1 is returned. On the remote target, if
the target supports s and S actions in the vCont? reply, then target
can do single step. However, old GDBserver will send s and S in the
reply to vCont?, which will confuse new GDB. For example, old GDBserver
on arm-linux will send s and S in the reply to vCont?, but it doesn't
support hardware single step. On the other hand, new GDBserver, on
arm-linux for example, will not send s and S in the reply to vCont?,
but old GDB thinks it doesn't support vCont packet at all. In order
to address this problem, I add a new qSupported feature vContSupported,
which indicates GDB wants to know the supported actions in the reply
to vCont?, and qSupported response contains vContSupported if the
stub is able tell supported vCont actions in the reply of vCont?.
If the patched GDB talks with patched GDBserver on x86, the RSP traffic
is like this:
-> $qSupported:...+;vContSupported+
<- ...+;vContSupported+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
then, GDB knows the stub can do single step, and may stop using software
single step even the architecture doesn't support hardware single step.
If the patched GDB talks with patched GDBserver on arm, the last vCont?
reply will become:
<- vCont;c;C;t
GDB thinks the target doesn't support single step, so it will use software
single step.
If the patched GDB talks with unpatched GDBserver, the RSP traffic is like
this:
-> $qSupported:...+;vContSupported+
<- ...+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
although GDBserver returns s and S, GDB still thinks GDBserver may not
support single step because it doesn't support vContSupported.
If the unpatched GDB talks with patched GDBserver on x86, the RSP traffic
is like:
-> $qSupported:...+;
<- ...+;vContSupported+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
Since GDB doesn't sent vContSupported in the qSupported feature, GDBserver
sends s and S regardless of the support of hardware single step.
gdb:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-nat.c (aarch64_linux_can_do_single_step): New
function.
(_initialize_aarch64_linux_nat): Install it to to_can_do_single_step.
* arm-linux-tdep.c (arm_linux_software_single_step): Return 0
if target_can_do_single_step returns 1.
* remote.c (struct vCont_action_support) <s, S>: New fields.
(PACKET_vContSupported): New enum.
(remote_protocol_features): New element for vContSupported.
(remote_query_supported): Append "vContSupported+".
(remote_vcont_probe): Remove support_s and support_S, use
rs->supports_vCont.s and rs->supports_vCont.S instead. Disable
vCont packet if c and C actions are not supported.
(remote_can_do_single_step): New function.
(init_remote_ops): Install it to to_can_do_single_step.
(_initialize_remote): Call add_packet_config_cmd.
* target.h (struct target_ops) <to_can_do_single_step>: New field.
(target_can_do_single_step): New macro.
* target-delegates.c: Re-generated.
gdb/gdbserver:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* server.c (vCont_supported): New global variable.
(handle_query): Set vCont_supported to 1 if "vContSupported+"
matches. Append ";vContSupported+" to own_buf.
(handle_v_requests): Append ";s;S" to own_buf if target supports
hardware single step or vCont_supported is false.
(capture_main): Set vCont_supported to zero.
gdb/doc:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* gdb.texinfo (General Query Packets): Add vContSupported to
tables of 'gdbfeatures' and 'stub features' supported in the
qSupported packet, as well as to the list containing stub
feature details.
2015-09-15 21:09:18 +08:00
|
|
|
ops->to_can_do_single_step = tdefault_can_do_single_step;
|
2013-12-19 01:24:07 +08:00
|
|
|
ops->to_terminal_init = tdefault_terminal_init;
|
2013-12-19 01:29:01 +08:00
|
|
|
ops->to_terminal_inferior = tdefault_terminal_inferior;
|
2013-12-19 01:29:46 +08:00
|
|
|
ops->to_terminal_ours_for_output = tdefault_terminal_ours_for_output;
|
2013-12-19 01:30:16 +08:00
|
|
|
ops->to_terminal_ours = tdefault_terminal_ours;
|
2013-12-19 01:31:10 +08:00
|
|
|
ops->to_terminal_info = default_terminal_info;
|
2013-12-19 05:35:15 +08:00
|
|
|
ops->to_kill = tdefault_kill;
|
2013-12-19 01:31:48 +08:00
|
|
|
ops->to_load = tdefault_load;
|
2013-12-19 01:32:56 +08:00
|
|
|
ops->to_post_startup_inferior = tdefault_post_startup_inferior;
|
2013-12-19 01:33:43 +08:00
|
|
|
ops->to_insert_fork_catchpoint = tdefault_insert_fork_catchpoint;
|
2013-12-19 01:34:15 +08:00
|
|
|
ops->to_remove_fork_catchpoint = tdefault_remove_fork_catchpoint;
|
2013-12-19 01:44:22 +08:00
|
|
|
ops->to_insert_vfork_catchpoint = tdefault_insert_vfork_catchpoint;
|
2013-12-19 01:44:57 +08:00
|
|
|
ops->to_remove_vfork_catchpoint = tdefault_remove_vfork_catchpoint;
|
2013-12-19 05:38:04 +08:00
|
|
|
ops->to_follow_fork = default_follow_fork;
|
2013-12-19 01:45:38 +08:00
|
|
|
ops->to_insert_exec_catchpoint = tdefault_insert_exec_catchpoint;
|
2013-12-19 01:46:02 +08:00
|
|
|
ops->to_remove_exec_catchpoint = tdefault_remove_exec_catchpoint;
|
Extended-remote follow-exec
This patch implements support for exec events on extended-remote Linux
targets. Follow-exec-mode and rerun behave as expected. Catchpoints and
test updates are implemented in subsequent patches.
This patch was derived from a patch posted last October:
https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html.
It was originally based on some work done by Luis Machado in 2013.
IMPLEMENTATION
----------------
Exec events are enabled via ptrace options.
When an exec event is detected by gdbserver, the existing process
data, along with all its associated lwp and thread data, is deleted
and replaced by data for a new single-threaded process. The new
process data is initialized with the appropriate parts of the state
of the execing process. This approach takes care of several potential
pitfalls, including:
* deleting the data for an execing non-leader thread before any
wait/sigsuspend occurs
* correctly initializing the architecture of the execed process
We then report the exec event using a new RSP stop reason, "exec".
When GDB receives an "exec" event, it saves the status in the event
structure's target_waitstatus field, like what is done for remote fork
events. Because the original and execed programs may have different
architectures, we skip parsing the section of the stop reply packet
that contains register data. The register data will be retrieved
later after the inferior's architecture has been set up by
infrun.c:follow_exec.
At that point the exec event is handled by the existing event handling
in GDB. However, a few changes were necessary so that
infrun.c:follow_exec could accommodate the remote target.
* Where follow-exec-mode "new" is handled, we now call
add_inferior_with_spaces instead of add_inferior with separate calls
to set up the program and address spaces. The motivation for this
is that add_inferior_with_spaces also sets up the initial architecture
for the inferior, which is needed later by target_find_description
when it calls target_gdbarch.
* We call a new target function, target_follow_exec. This function
allows us to store the execd_pathname in the inferior, instead of
using the static string remote_exec_file from remote.c. The static
string didn't work for follow-exec-mode "new", since once you switched
to the execed program, the original remote exec-file was lost. The
execd_pathname is now stored in the inferior's program space as a
REGISTRY field. All of the requisite mechanisms for this are
defined in remote.c.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_mourn): Static declaration.
(linux_arch_setup): Move in front of
handle_extended_wait.
(linux_arch_setup_thread): New function.
(handle_extended_wait): Handle exec events. Call
linux_arch_setup_thread. Make event_lwp argument a
pointer-to-a-pointer.
(check_zombie_leaders): Do not check stopped threads.
(linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC.
(linux_low_filter_event): Add lwp and thread for exec'ing
non-leader thread if leader thread has been deleted.
Refactor code into linux_arch_setup_thread and call it.
Pass child lwp pointer by reference to handle_extended_wait.
(linux_wait_for_event_filtered): Update comment.
(linux_wait_1): Prevent clobbering exec event status.
(linux_supports_exec_events): New function.
(linux_target_ops) <supports_exec_events>: Initialize new member.
* lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize
new member.
* remote-utils.c (prepare_resume_reply): New stop reason 'exec'.
* server.c (report_exec_events): New global variable.
(handle_query): Handle qSupported query for exec-events feature.
(captured_main): Initialize report_exec_events.
* server.h (report_exec_events): Declare new global variable.
* target.h (struct target_ops) <supports_exec_events>: New
member.
(target_supports_exec_events): New macro.
* win32-low.c (win32_target_ops) <supports_exec_events>:
Initialize new member.
gdb/ChangeLog:
* infrun.c (follow_exec): Use process-style ptid for
exec message. Call add_inferior_with_spaces and
target_follow_exec.
* nat/linux-ptrace.c (linux_supports_traceexec): New function.
* nat/linux-ptrace.h (linux_supports_traceexec): Declare.
* remote.c (remote_pspace_data): New static variable.
(remote_pspace_data_cleanup): New function.
(get_remote_exec_file): New function.
(set_remote_exec_file_1): New function.
(set_remote_exec_file): New function.
(show_remote_exec_file): New function.
(remote_exec_file): Delete static variable.
(anonymous enum) <PACKET_exec_event_feature> New
enumeration constant.
(remote_protocol_features): Add entry for exec-events feature.
(remote_query_supported): Add client side of qSupported query
for exec-events feature.
(remote_follow_exec): New function.
(remote_parse_stop_reply): Handle 'exec' stop reason.
(extended_remote_run, extended_remote_create_inferior): Call
get_remote_exec_file and set_remote_exec_file_1.
(init_extended_remote_ops) <to_follow_exec>: Initialize new
member.
(_initialize_remote): Call
register_program_space_data_with_cleanup. Call
add_packet_config_cmd for remote exec-events feature.
Modify call to add_setshow_string_noescape_cmd for exec-file
to use new functions set_remote_exec_file and
show_remote_exec_file.
* target-debug.h, target-delegates.c: Regenerated.
* target.c (target_follow_exec): New function.
* target.h (struct target_ops) <to_follow_exec>: New member.
(target_follow_exec): Declare new function.
2015-09-12 02:06:02 +08:00
|
|
|
ops->to_follow_exec = tdefault_follow_exec;
|
2013-12-19 01:46:38 +08:00
|
|
|
ops->to_set_syscall_catchpoint = tdefault_set_syscall_catchpoint;
|
2013-12-19 01:47:22 +08:00
|
|
|
ops->to_has_exited = tdefault_has_exited;
|
2013-12-19 05:40:23 +08:00
|
|
|
ops->to_mourn_inferior = default_mourn_inferior;
|
2013-12-21 03:19:37 +08:00
|
|
|
ops->to_can_run = tdefault_can_run;
|
2013-12-19 05:42:10 +08:00
|
|
|
ops->to_pass_signals = tdefault_pass_signals;
|
2013-12-19 05:42:54 +08:00
|
|
|
ops->to_program_signals = tdefault_program_signals;
|
2013-12-19 22:21:56 +08:00
|
|
|
ops->to_thread_alive = tdefault_thread_alive;
|
Push pruning old threads down to the target
When GDB wants to sync the thread list with the target's (e.g., due to
"info threads"), it calls update_thread_list:
update_thread_list (void)
{
prune_threads ();
target_find_new_threads ();
update_threads_executing ();
}
And then prune_threads does:
prune_threads (void)
{
struct thread_info *tp, *next;
for (tp = thread_list; tp; tp = next)
{
next = tp->next;
if (!thread_alive (tp))
delete_thread (tp->ptid);
}
}
Calling thread_live on each thread one by one is expensive.
E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not
a big deal, but still a bunch of syscalls...
With the remote target, it's cumbersome. That thread_alive call ends
up generating one T packet per thread:
Sending packet: $Tp2141.2150#82...Packet received: OK
Sending packet: $Tp2141.214f#b7...Packet received: OK
Sending packet: $Tp2141.2141#82...Packet received: OK
Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n
That seems a bit silly when target_find_new_threads method
implementations will always fetch the whole current set of target
threads, and then add those that are not in GDB's thread list, to
GDB's thread list.
This patch thus pushes down the responsibility of pruning dead threads
to the target_find_new_threads method instead, so a target may
implement pruning dead threads however it wants.
Once we do that, target_find_new_threads becomes a misnomer, so the
patch renames it to target_update_thread_list.
The patch doesn't attempt to do any optimization to any target yet.
It simply exports prune_threads, and makes all implementations of
target_update_thread_list call that. It's meant to be a no-op.
gdb/
2014-10-15 Pedro Alves <palves@redhat.com>
* ada-tasks.c (print_ada_task_info, task_command_1): Adjust.
* bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ...
(bsd_uthread_update_thread_list): ... this. Call prune_threads.
(bsd_uthread_target): Adjust.
* corelow.c (core_open): Adjust.
* dec-thread.c (dec_thread_find_new_threads): Update comment.
(dec_thread_update_thread_list): New function.
(init_dec_thread_ops): Adjust.
* gdbthread.h (prune_threads): New declaration.
* linux-thread-db.c (thread_db_find_new_threads): Rename to ...
(thread_db_update_thread_list): ... this. Call prune_threads.
(init_thread_db_ops): Adjust.
* nto-procfs.c (procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
(procfs_attach, procfs_create_inferior, init_procfs_targets):
Adjust.
* obsd-nat.c (obsd_find_new_threads): Rename to ...
(obsd_update_thread_list): ... this. Call prune_threads.
(obsd_add_target): Adjust.
* procfs.c (procfs_target): Adjust.
(procfs_notice_thread): Update comment.
(procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
* ravenscar-thread.c (ravenscar_update_inferior_ptid): Update
comment.
(ravenscar_wait): Adjust.
(ravenscar_find_new_threads): Rename to ...
(ravenscar_update_thread_list): ... this. Call prune_threads.
(init_ravenscar_thread_ops): Adjust.
* record-btrace.c (record_btrace_find_new_threads): Rename to ...
(record_btrace_update_thread_list): ... this. Adjust comment.
(init_record_btrace_ops): Adjust.
* remote.c (remote_threads_info): Rename to ...
(remote_update_thread_list): ... this. Call prune_threads.
(remote_start_remote, extended_remote_attach_1, init_remote_ops):
Adjust.
* sol-thread.c (check_for_thread_db): Adjust.
(sol_find_new_threads_callback): Rename to ...
(sol_update_thread_list_callback): ... this.
(sol_find_new_threads): Rename to ...
(sol_update_thread_list): ... this. Call prune_threads. Adjust.
(sol_get_ada_task_ptid, init_sol_thread_ops): Adjust.
* target-delegates.c: Regenerate.
* target.c (target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* target.h (struct target_ops): Rename to_find_new_threads field
to to_update_thread_list.
(target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* thread.c (prune_threads): Make extern.
(update_thread_list): Adjust.
2014-10-16 05:44:00 +08:00
|
|
|
ops->to_update_thread_list = tdefault_update_thread_list;
|
2013-12-19 05:46:03 +08:00
|
|
|
ops->to_pid_to_str = default_pid_to_str;
|
2013-12-19 01:48:36 +08:00
|
|
|
ops->to_extra_thread_info = tdefault_extra_thread_info;
|
2013-12-19 01:49:35 +08:00
|
|
|
ops->to_thread_name = tdefault_thread_name;
|
2013-12-19 05:28:07 +08:00
|
|
|
ops->to_stop = tdefault_stop;
|
Fix interrupt-noterm.exp on targets always in non-stop
With "maint set target-non-stop on" we get:
@@ -66,13 +66,16 @@ Continuing.
interrupt
(gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt
-Program received signal SIGINT, Interrupt.
-PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT
-testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds
+[process 12119] #1 stopped.
+0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81
+81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
+FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout)
+testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds
That is, we get "[$thread] #1 stopped" instead of SIGINT.
The issue is that we don't currently distinguish send
"interrupt/ctrl-c" to target terminal vs "stop/pause" thread well;
both cases go through "target_stop".
And then, the native Linux backend (linux-nat.c) implements
target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop
mode. Since "maint set target-non-stop on" forces the backend to be
always running in non-stop mode, even though the user-visible behavior
is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of
the SIGINT the test expects.
Fix this by introducing a target_interrupt method to use in the
"interrupt/ctrl-c" case, so "set non-stop off" can always work the
same irrespective of "maint set target-non-stop on/off". I'm
explictly considering changing the "set non-stop on" behavior as out
of scope here.
Most of the patch is an across-the-board rename of to_stop hook
implementations to to_interrupt. The only targets where something
more than a rename is being done are linux-nat.c and remote.c, which
are the only targets that support async, and thus are the only ones
the core side calls target_stop on.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_stop): Rename to ...
(darwin_interrupt): ... this.
(_initialize_darwin_inferior): Adjust.
* gnu-nat.c (gnu_stop): Delete.
(gnu_target): Don't install gnu_stop.
* inf-ptrace.c (inf_ptrace_stop): Rename to ...
(inf_ptrace_interrupt): ... this.
(inf_ptrace_target): Adjust.
* infcmd.c (interrupt_target_1): Use target_interrupt instead of
target_stop.
* linux-nat (linux_nat_stop): Rename to ...
(linux_nat_interrupt): ... this.
(linux_nat_stop): Reimplement.
(linux_nat_add_target): Install linux_nat_interrupt.
* nto-procfs.c (nto_interrupt_twice): Rename to ...
(nto_handle_sigint_twice): ... this.
(nto_interrupt): Rename to ...
(nto_handle_sigint): ... this. Call target_interrupt instead of
target_stop.
(procfs_wait): Adjust.
(procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(init_procfs_targets): Adjust.
* procfs.c (procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(procfs_target): Adjust.
* remote-m32r-sdi.c (m32r_stop): Rename to ...
(m32r_interrupt): ... this.
(init_m32r_ops): Adjust.
* remote-sim.c (gdbsim_stop_inferior): Rename to ...
(gdbsim_interrupt_inferior): ... this.
(gdbsim_stop): Rename to ...
(gdbsim_interrupt): ... this.
(gdbsim_cntrl_c): Adjust.
(init_gdbsim_ops): Adjust.
* remote.c (sync_remote_interrupt): Adjust comments.
(remote_stop_as): Rename to ...
(remote_interrupt_as): ... this.
(remote_stop): Adjust comment.
(remote_interrupt): New function.
(init_remote_ops): Install remote_interrupt.
* target.c (target_interrupt): New function.
* target.h (struct target_ops) <to_interrupt>: New field.
(target_interrupt): New declaration.
* windows-nat.c (windows_stop): Rename to ...
(windows_interrupt): ... this.
* target-delegates.c: Regenerate.
2015-08-07 01:22:58 +08:00
|
|
|
ops->to_interrupt = tdefault_interrupt;
|
remote: allow aborting long operations (e.g., file transfers)
Currently, when remote debugging, if you type Ctrl-C just while the
target stopped for an internal event, and GDB is busy doing something
that takes a while (e.g., fetching chunks of a shared library off of
the target, with vFile, to process ELF headers and debug info), the
Ctrl-C is lost.
The patch hooks up the QUIT macro to a new target method that lets the
target react to the double-Ctrl-C before the event loop is reached,
which allows reacting to a double-Ctrl-C even when GDB is busy doing
some long operation and not waiting for a stop reply. That end result
is:
(gdb) c
Continuing.
^C
^C
Interrupted while waiting for the program.
Give up waiting? (y or n) y
Quit
(gdb) info threads
Id Target Id Frame
* 1 Thread 11673 0x00007ffff7deb240 in _dl_debug_state () from target:/lib64/ld-linux-x86-64.so.2
(gdb)
If, however, GDB is waiting for a stop reply (because the target has
been resumed, with e.g., vCont;c), but the target isn't responding, we
now get:
(gdb) c
Continuing.
^C
^C
The target is not responding to interrupt requests.
Stop debugging it? (y or n) y
Disconnected from target.
(gdb) info threads
No threads.
This offers to disconnect, because when we're waiting for a stop
reply, there's nothing else we can send the target other than an
interrupt request. And if that doesn't work, there's nothing else we
can do.
The Ctrl-C is presently lost because until we get to a user-visible
stop, the SIGINT handler that is installed is the one that forwards
the interrupt to the remote side, with the \003 "packet" [1]. But,
gdbserver ignores an interrupt request if the program is stopped.
Still, even if it didn't, the server can only report back a
stop-because-of-SIGINT when the program is next resumed. And it may
take a while to actually re-resume the target.
[1] - In the old sync days, the remote target would react to a
double-Ctrl-C by asking users whether they wanted to give up waiting
and disconnect. The code is still there, but it it isn't reacheable
on most hosts, which support serial connections in async mode
(probably only DJGPP doesn't). Even then, in sync mode, remote.c's
SIGINT handler is only installed while the target is resumed, and is
removed as soon as the target sends back a stop reply. That means
that a Ctrl-C just while GDB is processing an internal event can end
up with an odd "Quit" at the prompt instead of "Program stopped by
SIGINT". In contrast, in async mode, remote.c's SIGINT handler is set
up as long as target_terminal_inferior or
target_terminal_ours_for_output are in effect (IOW, until we get a
user-visible stop and call target_terminal_ours), so the user
shouldn't get back a spurious Quit. However, it's still desirable to
be able to interrupt a long-running GDB operation, if GDB takes a
while to re-resume the target or get back to the event loop.
Tested on x86_64 Fedora 20.
gdb/ChangeLog:
2015-08-24 Pedro Alves <palves@redhat.com>
* defs.h (maybe_quit): Declare.
(QUIT): Now calls maybe_quit.
* event-loop.c (clear_async_signal_handler)
(async_signal_handler_is_marked): New functions.
* event-loop.h (async_signal_handler_is_marked)
(clear_async_signal_handler): New declarations.
* remote.c (remote_check_pending_interrupt): New function.
(interrupt_query): Use make_cleanup_restore_target_terminal. No
longer check whether the target is async. If waiting for a stop
reply, and a Ctrl-C as been sent to the target, offer to
disconnect, and throw TARGET_CLOSE_ERROR instead of a quit.
Otherwise do not disconnect and throw a quit.
(_initialize_remote): Install remote_check_pending_interrupt as
to_check_pending_interrupt.
* target.c (target_check_pending_interrupt): New function.
* target.h (struct target_ops) <to_check_pending_interrupt>: New
field.
(target_check_pending_interrupt): New declaration.
* utils.c (maybe_quit): New function.
* target-delegates.c: Regenerate.
2015-08-25 23:12:11 +08:00
|
|
|
ops->to_check_pending_interrupt = tdefault_check_pending_interrupt;
|
2013-12-19 00:35:21 +08:00
|
|
|
ops->to_rcmd = default_rcmd;
|
2013-12-19 01:51:10 +08:00
|
|
|
ops->to_pid_to_exec_file = tdefault_pid_to_exec_file;
|
2013-12-19 01:52:58 +08:00
|
|
|
ops->to_log_command = tdefault_log_command;
|
2013-12-19 05:47:06 +08:00
|
|
|
ops->to_get_section_table = tdefault_get_section_table;
|
fix regressions with target-async
A patch in the target cleanup series caused a regression when using
record with target-async. Version 4 of the patch is here:
https://sourceware.org/ml/gdb-patches/2014-03/msg00159.html
The immediate problem is that record supplies to_can_async_p and
to_is_async_p methods, but does not supply a to_async method. So,
when target-async is set, record claims to support async -- but if the
underlying target does not support async, then the to_async method
call will end up in that method's default implementation, namely
tcomplain.
This worked previously because the record target used to provide a
to_async method; one that (erroneously, only at push time) checked the
other members of the target stack, and then simply dropped to_async
calls in the "does not implement async" case.
My first thought was to simply drop tcomplain as the default for
to_async. This works, but Pedro pointed out that the only reason
record has to supply to_can_async_p and to_is_async_p is that these
default to using the find_default_run_target machinery -- and these
defaults are only needed by "run" and "attach".
So, a nicer solution presents itself: change run and attach to
explicitly call into the default run target when needed; and change
to_is_async_p and to_can_async_p to default to "return 0". This makes
the target stack simpler to use and lets us remove the method
implementations from record. This is also in harmony with other plans
for the target stack; namely trying to reduce the impact of
find_default_run_target. This approach makes it clear that
find_default_is_async_p is not needed -- it is asking whether a target
that may not even be pushed is actually async, which seems like a
nonsensical question.
While an improvement, this approach proved to introduce the same bug
when using the core target. Looking a bit deeper, the issue is that
code in "attach" and "run" may need to use either the current target
stack or the default run target -- but different calls into the target
API in those functions could wind up querying different targets.
This new patch makes the target to use more explicit in "run" and
"attach". Then these commands explicitly make the needed calls
against that target. This ensures that a single target is used for
all relevant operations. This lets us remove a couple find_default_*
functions from various targets, including the dummy target. I think
this is a decent understandability improvement.
One issue I see with this patch is that the new calls in "run" and
"attach" are not very much like the rest of the target API. I think
fundamentally this is due to bad factoring in the target API, which
may need to be fixed for multi-target. Tackling that seemed ambitious
for a regression fix.
While working on this I noticed that there don't seem to be any test
cases that involve both target-async and record, so this patch changes
break-precsave.exp to add some. It also changes corefile.exp to add
some target-async tests; these pass with current trunk and with this
patch applied, but fail with the v1 patch.
This patch differs from v4 in that it moves initialization of
to_can_async_p and to_supports_non_stop into inf-child, adds some
assertions to complete_target_initialization, and adds some comments
to target.h.
Built and regtested on x86-64 Fedora 20.
2014-03-12 Tom Tromey <tromey@redhat.com>
* inf-child.c (return_zero): New function.
(inf_child_target): Set to_can_async_p, to_supports_non_stop.
* aix-thread.c (aix_thread_inferior_created): New function.
(aix_thread_attach): Remove.
(init_aix_thread_ops): Don't set to_attach.
(_initialize_aix_thread): Register inferior_created observer.
* corelow.c (init_core_ops): Don't set to_attach or
to_create_inferior.
* exec.c (init_exec_ops): Don't set to_attach or
to_create_inferior.
* infcmd.c (run_command_1): Use find_run_target. Make direct
target calls.
(attach_command): Use find_attach_target. Make direct target
calls.
* record-btrace.c (init_record_btrace_ops): Don't set
to_create_inferior.
* record-full.c (record_full_can_async_p, record_full_is_async_p):
Remove.
(init_record_full_ops, init_record_full_core_ops): Update. Don't
set to_create_inferior.
* target.c (complete_target_initialization): Add assertion.
(target_create_inferior): Remove.
(find_default_attach, find_default_create_inferior): Remove.
(find_attach_target, find_run_target): New functions.
(find_default_is_async_p, find_default_can_async_p)
(target_supports_non_stop, target_attach): Remove.
(init_dummy_target): Don't set to_create_inferior or
to_supports_non_stop.
* target.h (struct target_ops) <to_attach>: Add comment. Remove
TARGET_DEFAULT_FUNC.
<to_create_inferior>: Add comment.
<to_can_async_p, to_is_async_p, to_supports_non_stop>: Use
TARGET_DEFAULT_RETURN.
<to_can_async_p, to_supports_non_stop, to_can_run>: Add comments.
(find_attach_target, find_run_target): Declare.
(target_create_inferior): Remove.
(target_has_execution_1): Update comment.
(target_supports_non_stop): Remove.
* target-delegates.c: Rebuild.
2014-03-12 Tom Tromey <tromey@redhat.com>
* gdb.base/corefile.exp (corefile_test_run, corefile_test_attach):
New procs. Add target-async tests.
* gdb.reverse/break-precsave.exp (precsave_tests): New proc.
Add target-async tests.
2014-03-01 00:47:34 +08:00
|
|
|
ops->to_can_async_p = tdefault_can_async_p;
|
|
|
|
ops->to_is_async_p = tdefault_is_async_p;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
ops->to_async = tdefault_async;
|
fix regressions with target-async
A patch in the target cleanup series caused a regression when using
record with target-async. Version 4 of the patch is here:
https://sourceware.org/ml/gdb-patches/2014-03/msg00159.html
The immediate problem is that record supplies to_can_async_p and
to_is_async_p methods, but does not supply a to_async method. So,
when target-async is set, record claims to support async -- but if the
underlying target does not support async, then the to_async method
call will end up in that method's default implementation, namely
tcomplain.
This worked previously because the record target used to provide a
to_async method; one that (erroneously, only at push time) checked the
other members of the target stack, and then simply dropped to_async
calls in the "does not implement async" case.
My first thought was to simply drop tcomplain as the default for
to_async. This works, but Pedro pointed out that the only reason
record has to supply to_can_async_p and to_is_async_p is that these
default to using the find_default_run_target machinery -- and these
defaults are only needed by "run" and "attach".
So, a nicer solution presents itself: change run and attach to
explicitly call into the default run target when needed; and change
to_is_async_p and to_can_async_p to default to "return 0". This makes
the target stack simpler to use and lets us remove the method
implementations from record. This is also in harmony with other plans
for the target stack; namely trying to reduce the impact of
find_default_run_target. This approach makes it clear that
find_default_is_async_p is not needed -- it is asking whether a target
that may not even be pushed is actually async, which seems like a
nonsensical question.
While an improvement, this approach proved to introduce the same bug
when using the core target. Looking a bit deeper, the issue is that
code in "attach" and "run" may need to use either the current target
stack or the default run target -- but different calls into the target
API in those functions could wind up querying different targets.
This new patch makes the target to use more explicit in "run" and
"attach". Then these commands explicitly make the needed calls
against that target. This ensures that a single target is used for
all relevant operations. This lets us remove a couple find_default_*
functions from various targets, including the dummy target. I think
this is a decent understandability improvement.
One issue I see with this patch is that the new calls in "run" and
"attach" are not very much like the rest of the target API. I think
fundamentally this is due to bad factoring in the target API, which
may need to be fixed for multi-target. Tackling that seemed ambitious
for a regression fix.
While working on this I noticed that there don't seem to be any test
cases that involve both target-async and record, so this patch changes
break-precsave.exp to add some. It also changes corefile.exp to add
some target-async tests; these pass with current trunk and with this
patch applied, but fail with the v1 patch.
This patch differs from v4 in that it moves initialization of
to_can_async_p and to_supports_non_stop into inf-child, adds some
assertions to complete_target_initialization, and adds some comments
to target.h.
Built and regtested on x86-64 Fedora 20.
2014-03-12 Tom Tromey <tromey@redhat.com>
* inf-child.c (return_zero): New function.
(inf_child_target): Set to_can_async_p, to_supports_non_stop.
* aix-thread.c (aix_thread_inferior_created): New function.
(aix_thread_attach): Remove.
(init_aix_thread_ops): Don't set to_attach.
(_initialize_aix_thread): Register inferior_created observer.
* corelow.c (init_core_ops): Don't set to_attach or
to_create_inferior.
* exec.c (init_exec_ops): Don't set to_attach or
to_create_inferior.
* infcmd.c (run_command_1): Use find_run_target. Make direct
target calls.
(attach_command): Use find_attach_target. Make direct target
calls.
* record-btrace.c (init_record_btrace_ops): Don't set
to_create_inferior.
* record-full.c (record_full_can_async_p, record_full_is_async_p):
Remove.
(init_record_full_ops, init_record_full_core_ops): Update. Don't
set to_create_inferior.
* target.c (complete_target_initialization): Add assertion.
(target_create_inferior): Remove.
(find_default_attach, find_default_create_inferior): Remove.
(find_attach_target, find_run_target): New functions.
(find_default_is_async_p, find_default_can_async_p)
(target_supports_non_stop, target_attach): Remove.
(init_dummy_target): Don't set to_create_inferior or
to_supports_non_stop.
* target.h (struct target_ops) <to_attach>: Add comment. Remove
TARGET_DEFAULT_FUNC.
<to_create_inferior>: Add comment.
<to_can_async_p, to_is_async_p, to_supports_non_stop>: Use
TARGET_DEFAULT_RETURN.
<to_can_async_p, to_supports_non_stop, to_can_run>: Add comments.
(find_attach_target, find_run_target): Declare.
(target_create_inferior): Remove.
(target_has_execution_1): Update comment.
(target_supports_non_stop): Remove.
* target-delegates.c: Rebuild.
2014-03-12 Tom Tromey <tromey@redhat.com>
* gdb.base/corefile.exp (corefile_test_run, corefile_test_attach):
New procs. Add target-async tests.
* gdb.reverse/break-precsave.exp (precsave_tests): New proc.
Add target-async tests.
2014-03-01 00:47:34 +08:00
|
|
|
ops->to_supports_non_stop = tdefault_supports_non_stop;
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-08 00:24:01 +08:00
|
|
|
ops->to_always_non_stop_p = tdefault_always_non_stop_p;
|
2013-12-19 01:55:34 +08:00
|
|
|
ops->to_find_memory_regions = dummy_find_memory_regions;
|
2013-12-19 01:57:18 +08:00
|
|
|
ops->to_make_corefile_notes = dummy_make_corefile_notes;
|
2013-12-19 02:10:32 +08:00
|
|
|
ops->to_get_bookmark = tdefault_get_bookmark;
|
2013-12-19 02:11:25 +08:00
|
|
|
ops->to_goto_bookmark = tdefault_goto_bookmark;
|
2014-06-26 00:16:55 +08:00
|
|
|
ops->to_get_thread_local_address = tdefault_get_thread_local_address;
|
add target method delegation
This patch replaces some code in the record targets with target method
delegation.
record-full.c stores pointers to many target methods when the record
target is pushed. Then it later delegates some calls via these. This
is wrong because it violates the target stack contract. In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.
This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.
2014-02-19 Tom Tromey <tromey@redhat.com>
* record-full.c (record_full_beneath_to_resume_ops)
(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
(record_full_beneath_to_wait)
(record_full_beneath_to_store_registers_ops)
(record_full_beneath_to_store_registers)
(record_full_beneath_to_xfer_partial_ops)
(record_full_beneath_to_xfer_partial)
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_stopped_data_address)
(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
(tmp_to_store_registers, tmp_to_xfer_partial_ops)
(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_stopped_data_address, tmp_to_async): Remove.
(record_full_open_1, record_full_open): Update. Use RECORD_IS_USED.
(record_full_resume, record_full_wait_1)
(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
(record_full_store_registers, record_full_xfer_partial)
(record_full_insert_breakpoint, record_full_remove_breakpoint)
(record_full_async, record_full_core_xfer_partial): Use target
delegation.
* target-delegates.c: Rebuild.
* target.c (current_xfer_partial): Remove.
(update_current_target): Do not INHERIT or de_fault
to_insert_breakpoint, to_remove_breakpoint,
to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async. Do not set to_xfer_partial field.
(default_xfer_partial): Simplify.
(current_xfer_partial): Remove.
(target_wait, target_resume): Simplify.
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
to_xfer_partial, to_stopped_by_watchpoint,
to_stopped_data_address.
(target_store_registers): Simplify.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
(target_remove_breakpoint, target_insert_breakpoint)
(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
* target.h (struct target_ops) <to_resume, to_wait,
to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
markup.
(forward_target_remove_breakpoint)
(forward_target_insert_breakpoint): Remove.
* record-btrace.c (record_btrace_remove_breakpoint): Delegate
directly.
(record_btrace_insert_breakpoint): Delegate directly.
2013-07-13 03:00:34 +08:00
|
|
|
ops->to_xfer_partial = tdefault_xfer_partial;
|
2013-12-19 22:47:11 +08:00
|
|
|
ops->to_memory_map = tdefault_memory_map;
|
2013-12-19 05:50:56 +08:00
|
|
|
ops->to_flash_erase = tdefault_flash_erase;
|
2013-12-19 05:52:02 +08:00
|
|
|
ops->to_flash_done = tdefault_flash_done;
|
2014-01-14 00:30:30 +08:00
|
|
|
ops->to_read_description = tdefault_read_description;
|
2013-12-19 04:53:09 +08:00
|
|
|
ops->to_get_ada_task_ptid = default_get_ada_task_ptid;
|
2013-12-19 22:56:20 +08:00
|
|
|
ops->to_auxv_parse = default_auxv_parse;
|
2013-12-19 23:12:26 +08:00
|
|
|
ops->to_search_memory = default_search_memory;
|
2013-12-19 02:12:28 +08:00
|
|
|
ops->to_can_execute_reverse = tdefault_can_execute_reverse;
|
2013-12-19 02:15:21 +08:00
|
|
|
ops->to_execution_direction = default_execution_direction;
|
2013-12-19 04:54:06 +08:00
|
|
|
ops->to_supports_multi_process = tdefault_supports_multi_process;
|
2013-12-19 04:54:59 +08:00
|
|
|
ops->to_supports_enable_disable_tracepoint = tdefault_supports_enable_disable_tracepoint;
|
2013-12-19 04:56:04 +08:00
|
|
|
ops->to_supports_string_tracing = tdefault_supports_string_tracing;
|
2013-12-19 05:20:06 +08:00
|
|
|
ops->to_supports_evaluation_of_breakpoint_conditions = tdefault_supports_evaluation_of_breakpoint_conditions;
|
2013-12-19 05:20:36 +08:00
|
|
|
ops->to_can_run_breakpoint_commands = tdefault_can_run_breakpoint_commands;
|
2013-12-19 02:16:31 +08:00
|
|
|
ops->to_thread_architecture = default_thread_architecture;
|
2014-02-22 01:33:42 +08:00
|
|
|
ops->to_thread_address_space = default_thread_address_space;
|
2015-04-02 20:38:28 +08:00
|
|
|
ops->to_filesystem_is_local = tdefault_filesystem_is_local;
|
2013-12-19 04:57:05 +08:00
|
|
|
ops->to_trace_init = tdefault_trace_init;
|
2013-12-19 04:57:41 +08:00
|
|
|
ops->to_download_tracepoint = tdefault_download_tracepoint;
|
2013-12-19 05:00:23 +08:00
|
|
|
ops->to_can_download_tracepoint = tdefault_can_download_tracepoint;
|
2013-12-19 05:01:07 +08:00
|
|
|
ops->to_download_trace_state_variable = tdefault_download_trace_state_variable;
|
2013-12-19 05:01:51 +08:00
|
|
|
ops->to_enable_tracepoint = tdefault_enable_tracepoint;
|
2013-12-19 05:02:30 +08:00
|
|
|
ops->to_disable_tracepoint = tdefault_disable_tracepoint;
|
2013-12-19 05:03:28 +08:00
|
|
|
ops->to_trace_set_readonly_regions = tdefault_trace_set_readonly_regions;
|
2013-12-19 05:04:27 +08:00
|
|
|
ops->to_trace_start = tdefault_trace_start;
|
2013-12-19 05:06:18 +08:00
|
|
|
ops->to_get_trace_status = tdefault_get_trace_status;
|
2013-12-19 05:06:52 +08:00
|
|
|
ops->to_get_tracepoint_status = tdefault_get_tracepoint_status;
|
2013-12-19 05:07:28 +08:00
|
|
|
ops->to_trace_stop = tdefault_trace_stop;
|
2013-12-19 05:08:14 +08:00
|
|
|
ops->to_trace_find = tdefault_trace_find;
|
2013-12-19 05:09:04 +08:00
|
|
|
ops->to_get_trace_state_variable_value = tdefault_get_trace_state_variable_value;
|
2013-12-19 05:09:37 +08:00
|
|
|
ops->to_save_trace_data = tdefault_save_trace_data;
|
2013-12-19 05:10:14 +08:00
|
|
|
ops->to_upload_tracepoints = tdefault_upload_tracepoints;
|
2013-12-19 05:10:40 +08:00
|
|
|
ops->to_upload_trace_state_variables = tdefault_upload_trace_state_variables;
|
2013-12-19 05:11:12 +08:00
|
|
|
ops->to_get_raw_trace_data = tdefault_get_raw_trace_data;
|
2013-12-19 05:11:53 +08:00
|
|
|
ops->to_get_min_fast_tracepoint_insn_len = tdefault_get_min_fast_tracepoint_insn_len;
|
2013-12-19 05:12:29 +08:00
|
|
|
ops->to_set_disconnected_tracing = tdefault_set_disconnected_tracing;
|
2013-12-19 05:13:09 +08:00
|
|
|
ops->to_set_circular_trace_buffer = tdefault_set_circular_trace_buffer;
|
2013-12-19 05:14:58 +08:00
|
|
|
ops->to_set_trace_buffer_size = tdefault_set_trace_buffer_size;
|
2013-12-19 05:15:23 +08:00
|
|
|
ops->to_set_trace_notes = tdefault_set_trace_notes;
|
2013-12-19 05:55:06 +08:00
|
|
|
ops->to_core_of_thread = tdefault_core_of_thread;
|
Make compare-sections work against all targets; add compare-sections [-r] tests.
This does two things:
1. Adds a test.
Recently compare-sections got a new "-r" switch, but given no test
existed for compare-sections, the patch was allowed in with no
testsuite addition. This now adds a test for both compare-sections
and compare-sections -r.
2. Makes the compare-sections command work against all targets.
Currently, compare-sections only works with remote targets, and only
those that support the qCRC packet. The patch makes it so that if the
target doesn't support accelerating memory verification, then GDB
falls back to comparing memory itself. This is of course slower, but
it's better than nothing, IMO. While testing against extended-remote
GDBserver I noticed that we send the qCRC request to the target if
we're connected, but not yet running a program. That can't work of
course -- the patch fixes that. This all also goes in the direction
of bridging the local/remote parity gap.
I didn't decouple 1. from 2., because that would mean that the test
would need to handle the case of the target not supporting the
command.
Tested on x86_64 Fedora 17, native, remote GDBserver, and
extended-remote GDBserver. I also hack-disabled qCRC support to make
sure the fallback paths in remote.c work.
gdb/doc/
2014-05-20 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Memory) <compare-sections>: Generalize comments to
not be remote specific. Add cross reference to the qCRC packet.
(Separate Debug Files): Update cross reference to the qCRC packet.
(General Query Packets) <qCRC packet>: Add anchor.
gdb/
2014-05-20 Pedro Alves <palves@redhat.com>
* NEWS: Mention that compare-sections now works with all targets.
* remote.c (PACKET_qCRC): New enum value.
(remote_verify_memory): Don't send qCRC if the target has no
execution. Use packet_support/packet_ok. If the target doesn't
support the qCRC packet, fallback to a deep memory copy.
(compare_sections_command): Say "target image" instead of "remote
executable".
(_initialize_remote): Add PACKET_qCRC to the list of config
packets that have no associated command. Extend comment.
* target.c (simple_verify_memory, default_verify_memory): New
function.
* target.h (struct target_ops) <to_verify_memory>: Default to
default_verify_memory.
(simple_verify_memory): New declaration.
* target-delegates.c: Regenerate.
gdb/testsuite/
2014-05-20 Pedro Alves <palves@redhat.com>
* gdb.base/compare-sections.c: New file.
* gdb.base/compare-sections.exp: New file.
2014-05-21 02:11:39 +08:00
|
|
|
ops->to_verify_memory = default_verify_memory;
|
2013-12-19 05:15:55 +08:00
|
|
|
ops->to_get_tib_address = tdefault_get_tib_address;
|
2013-12-19 05:16:24 +08:00
|
|
|
ops->to_set_permissions = tdefault_set_permissions;
|
2013-12-19 05:16:51 +08:00
|
|
|
ops->to_static_tracepoint_marker_at = tdefault_static_tracepoint_marker_at;
|
2013-12-19 05:17:35 +08:00
|
|
|
ops->to_static_tracepoint_markers_by_strid = tdefault_static_tracepoint_markers_by_strid;
|
2013-12-19 05:18:10 +08:00
|
|
|
ops->to_traceframe_info = tdefault_traceframe_info;
|
2013-12-19 05:18:35 +08:00
|
|
|
ops->to_use_agent = tdefault_use_agent;
|
2013-12-19 05:19:04 +08:00
|
|
|
ops->to_can_use_agent = tdefault_can_use_agent;
|
2013-12-14 04:26:04 +08:00
|
|
|
ops->to_supports_btrace = tdefault_supports_btrace;
|
2013-12-19 23:19:41 +08:00
|
|
|
ops->to_enable_btrace = tdefault_enable_btrace;
|
2013-12-19 23:17:16 +08:00
|
|
|
ops->to_disable_btrace = tdefault_disable_btrace;
|
2013-12-19 23:18:04 +08:00
|
|
|
ops->to_teardown_btrace = tdefault_teardown_btrace;
|
2013-12-19 23:19:02 +08:00
|
|
|
ops->to_read_btrace = tdefault_read_btrace;
|
2013-11-28 22:44:13 +08:00
|
|
|
ops->to_btrace_conf = tdefault_btrace_conf;
|
2013-12-19 23:21:20 +08:00
|
|
|
ops->to_stop_recording = tdefault_stop_recording;
|
2014-07-16 22:05:03 +08:00
|
|
|
ops->to_info_record = tdefault_info_record;
|
2013-12-19 11:26:34 +08:00
|
|
|
ops->to_save_record = tdefault_save_record;
|
2013-12-19 11:25:47 +08:00
|
|
|
ops->to_delete_record = tdefault_delete_record;
|
2013-12-19 11:25:01 +08:00
|
|
|
ops->to_record_is_replaying = tdefault_record_is_replaying;
|
2015-09-17 17:14:55 +08:00
|
|
|
ops->to_record_will_replay = tdefault_record_will_replay;
|
2015-09-08 15:42:20 +08:00
|
|
|
ops->to_record_stop_replaying = tdefault_record_stop_replaying;
|
2013-12-19 11:24:04 +08:00
|
|
|
ops->to_goto_record_begin = tdefault_goto_record_begin;
|
2013-12-19 11:23:23 +08:00
|
|
|
ops->to_goto_record_end = tdefault_goto_record_end;
|
2013-12-19 11:22:36 +08:00
|
|
|
ops->to_goto_record = tdefault_goto_record;
|
2013-12-19 11:18:49 +08:00
|
|
|
ops->to_insn_history = tdefault_insn_history;
|
2013-12-19 11:16:56 +08:00
|
|
|
ops->to_insn_history_from = tdefault_insn_history_from;
|
2013-12-19 11:15:44 +08:00
|
|
|
ops->to_insn_history_range = tdefault_insn_history_range;
|
2013-12-19 11:13:40 +08:00
|
|
|
ops->to_call_history = tdefault_call_history;
|
2013-12-19 11:11:49 +08:00
|
|
|
ops->to_call_history_from = tdefault_call_history_from;
|
2013-12-19 11:10:20 +08:00
|
|
|
ops->to_call_history_range = tdefault_call_history_range;
|
2013-12-19 05:19:33 +08:00
|
|
|
ops->to_augmented_libraries_svr4_read = tdefault_augmented_libraries_svr4_read;
|
2014-01-17 04:00:07 +08:00
|
|
|
ops->to_get_unwinder = tdefault_get_unwinder;
|
|
|
|
ops->to_get_tailcall_unwinder = tdefault_get_tailcall_unwinder;
|
2014-05-20 21:22:53 +08:00
|
|
|
ops->to_prepare_to_generate_core = tdefault_prepare_to_generate_core;
|
|
|
|
ops->to_done_generating_core = tdefault_done_generating_core;
|
2013-12-20 00:38:11 +08:00
|
|
|
}
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
init_debug_target (struct target_ops *ops)
|
|
|
|
{
|
|
|
|
ops->to_post_attach = debug_post_attach;
|
|
|
|
ops->to_detach = debug_detach;
|
|
|
|
ops->to_disconnect = debug_disconnect;
|
|
|
|
ops->to_resume = debug_resume;
|
|
|
|
ops->to_wait = debug_wait;
|
|
|
|
ops->to_fetch_registers = debug_fetch_registers;
|
|
|
|
ops->to_store_registers = debug_store_registers;
|
|
|
|
ops->to_prepare_to_store = debug_prepare_to_store;
|
|
|
|
ops->to_files_info = debug_files_info;
|
|
|
|
ops->to_insert_breakpoint = debug_insert_breakpoint;
|
|
|
|
ops->to_remove_breakpoint = debug_remove_breakpoint;
|
Teach GDB about targets that can tell whether a trap is a breakpoint event
The moribund locations heuristics are problematic. This patch teaches
GDB about targets that can reliably tell whether a trap was caused by
a software or hardware breakpoint, and thus don't need moribund
locations, thus bypassing all the problems that mechanism has.
The non-stop-fair-events.exp test is frequently failing currently.
E.g., see https://sourceware.org/ml/gdb-testers/2015-q1/msg03148.html.
The root cause is a fundamental problem with moribund locations. For
example, the stepped_breakpoint logic added by af48d08f breaks in this
case (which is what happens with that test):
- Step thread A, no breakpoint is set at PC.
- The kernel doesn't schedule thread A yet.
- Insert breakpoint at A's PC, for some reason (e.g., a step-resume
breakpoint for thread B).
- Kernel finally schedules thread A.
- thread A's stepped_breakpoint flag is not set, even though it now
stepped a breakpoint instruction.
- adjust_pc_after_break gets the PC wrong, because PC == PREV_PC, but
stepped_breakpoint is not set.
We needed the stepped_breakpoint logic to workaround moribund
locations, because otherwise adjust_pc_after_break could apply an
adjustment when it shouldn't just because there _used_ to be a
breakpoint at PC (a moribund breakpoint location). For example, on
x86, that's wrong if the thread really hasn't executed an int3, but
instead executed some other 1-byte long instruction. Getting the PC
adjustment wrong of course leads to the inferior executing the wrong
instruction.
Other problems with moribund locations are:
- if a true SIGTRAP happens to be raised when the program is
executing the PC that used to have a breakpoint, GDB will assume
that is a trap for a breakpoint that has recently been removed, and
thus we miss reporting the random signal to the user.
- to minimize that, we get rid of moribund location after a while.
That while is defined as just a certain number of events being
processed. That number of events sometimes passes by before a
delayed breakpoint is processed, and GDB confuses the trap for a
random signal, thus reporting the random trap. Once the user
resumes the thread, the program crashes because the PC was not
adjusted...
The fix for all this is to bite the bullet and get rid of heuristics
and instead rely on the target knowing accurately what caused the
SIGTRAP. The target/kernel/stub is in the best position to know what
that, because it can e.g. consult priviledged CPU flags GDB has no
access to, or by knowing which exception vector entry was called when
the instruction trapped, etc. Most debug APIs I've seen to date
report breakpoint hits as a distinct event in some fashion. For
example, on the Linux kernel, whether a breakpoint was executed is
exposed to userspace in the si_code field of the SIGTRAP's siginfo.
On Windows, the debug API reports a EXCEPTION_BREAKPOINT exception
code.
We needed to keep around deleted breakpoints in an on-the-side list
(the moribund locations) for two main reasons:
- Know that a SIGTRAP actually is a delayed event for a hit of a
breakpoint that was removed before the event was processed, and
thus should not be reported as a random signal.
- So we still do the decr_pc_after_break adjustment in that case, so
that the thread is resumed at the correct address.
In the new model, if GDB processes an event the target tells is a
breakpoint trap, and GDB doesn't find the corresponding breakpoint in
its breakpoint tables, it means that event is a delayed event for a
breakpoint that has since been removed, and thus the event should be
ignored.
For the decr_pc_after_after issue, it ends up being much simpler that
on targets that can reliably tell whether a breakpoint trapped, for
the breakpoint trap to present the PC already adjusted. Proper
multi-threading support already implies that targets needs to be doing
decr_pc_after_break adjustment themselves, otherwise for example, in
all-stop if two threads hit a breakpoint simultaneously, and the user
does "info threads", he'll see the non-event thread that hit the
breakpoint stopped at the wrong PC.
This way (target adjusts) also ends up eliminating the need for some
awkward re-incrementing of the PC in the record-full and Linux targets
that we do today, and the need for the target_decr_pc_after_break
hook.
If the target always adjusts, then there's a case where GDB needs to
re-increment the PC. Say, on x86, an "int3" instruction that was
explicitly written in the program traps. In this case, GDB should
report a random SIGTRAP signal to the user, with the PC pointing at
the instruction past the int3, just like if GDB was not debugging the
program. The user may well decide to pass the SIGTRAP to the program
because the program being debugged has a SIGTRAP handler that handles
its own breakpoints, and expects the PC to be unadjusted.
Tested on x86-64 Fedora 20.
gdb/ChangeLog:
2015-03-04 Pedro Alves <palves@redhat.com>
* breakpoint.c (need_moribund_for_location_type): New function.
(bpstat_stop_status): Don't skipping checking moribund locations
of breakpoint types which the target tell caused a stop.
(program_breakpoint_here_p): New function, factored out from ...
(bp_loc_is_permanent): ... this.
(update_global_location_list): Don't create a moribund location if
the target supports reporting stops of the type of the removed
breakpoint.
* breakpoint.h (program_breakpoint_here_p): New declaration.
* infrun.c (adjust_pc_after_break): Return early if the target has
already adjusted the PC. Add comments.
(handle_signal_stop): If nothing explains a signal, and the target
tells us the stop was caused by a software breakpoint, check if
there's a breakpoint instruction in the memory. If so, adjust the
PC before presenting the stop to the user. Otherwise, ignore the
trap. If nothing explains a signal, and the target tells us the
stop was caused by a hardware breakpoint, ignore the trap.
* target.h (struct target_ops) <to_stopped_by_sw_breakpoint,
to_supports_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint,
to_supports_stopped_by_hw_breakpoint>: New fields.
(target_stopped_by_sw_breakpoint)
(target_supports_stopped_by_sw_breakpoint)
(target_stopped_by_hw_breakpoint)
(target_supports_stopped_by_hw_breakpoint): Define.
* target-delegates.c: Regenerate.
2015-03-05 04:41:15 +08:00
|
|
|
ops->to_stopped_by_sw_breakpoint = debug_stopped_by_sw_breakpoint;
|
|
|
|
ops->to_supports_stopped_by_sw_breakpoint = debug_supports_stopped_by_sw_breakpoint;
|
|
|
|
ops->to_stopped_by_hw_breakpoint = debug_stopped_by_hw_breakpoint;
|
|
|
|
ops->to_supports_stopped_by_hw_breakpoint = debug_supports_stopped_by_hw_breakpoint;
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
ops->to_can_use_hw_breakpoint = debug_can_use_hw_breakpoint;
|
|
|
|
ops->to_ranged_break_num_registers = debug_ranged_break_num_registers;
|
|
|
|
ops->to_insert_hw_breakpoint = debug_insert_hw_breakpoint;
|
|
|
|
ops->to_remove_hw_breakpoint = debug_remove_hw_breakpoint;
|
|
|
|
ops->to_remove_watchpoint = debug_remove_watchpoint;
|
|
|
|
ops->to_insert_watchpoint = debug_insert_watchpoint;
|
|
|
|
ops->to_insert_mask_watchpoint = debug_insert_mask_watchpoint;
|
|
|
|
ops->to_remove_mask_watchpoint = debug_remove_mask_watchpoint;
|
|
|
|
ops->to_stopped_by_watchpoint = debug_stopped_by_watchpoint;
|
|
|
|
ops->to_stopped_data_address = debug_stopped_data_address;
|
|
|
|
ops->to_watchpoint_addr_within_range = debug_watchpoint_addr_within_range;
|
|
|
|
ops->to_region_ok_for_hw_watchpoint = debug_region_ok_for_hw_watchpoint;
|
|
|
|
ops->to_can_accel_watchpoint_condition = debug_can_accel_watchpoint_condition;
|
|
|
|
ops->to_masked_watch_num_registers = debug_masked_watch_num_registers;
|
Support single step by arch or target
Nowadays, GDB only knows whether architecture supports hardware single
step or software single step (through gdbarch hook software_single_step),
and for a given instruction or instruction sequence, GDB knows how to
do single step (hardware or software). However, GDB doesn't know whether
the target supports hardware single step. It is possible that the
architecture doesn't support hardware single step, such as arm, but
the target supports, such as simulator. This was discussed in this
thread https://www.sourceware.org/ml/gdb/2009-12/msg00033.html before.
I encounter this problem for aarch64 multi-arch support. When aarch64
debugs arm program, gdbarch is arm, so software single step is still
used. However, the underneath linux kernel does support hardware
single step, so IWBN to use it.
This patch is to add a new target_ops hook to_can_do_single_step, and
only use it in arm_linux_software_single_step to decide whether or not
to use hardware single step. On the native aarch64 linux target, 1 is
returned. On other targets, -1 is returned. On the remote target, if
the target supports s and S actions in the vCont? reply, then target
can do single step. However, old GDBserver will send s and S in the
reply to vCont?, which will confuse new GDB. For example, old GDBserver
on arm-linux will send s and S in the reply to vCont?, but it doesn't
support hardware single step. On the other hand, new GDBserver, on
arm-linux for example, will not send s and S in the reply to vCont?,
but old GDB thinks it doesn't support vCont packet at all. In order
to address this problem, I add a new qSupported feature vContSupported,
which indicates GDB wants to know the supported actions in the reply
to vCont?, and qSupported response contains vContSupported if the
stub is able tell supported vCont actions in the reply of vCont?.
If the patched GDB talks with patched GDBserver on x86, the RSP traffic
is like this:
-> $qSupported:...+;vContSupported+
<- ...+;vContSupported+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
then, GDB knows the stub can do single step, and may stop using software
single step even the architecture doesn't support hardware single step.
If the patched GDB talks with patched GDBserver on arm, the last vCont?
reply will become:
<- vCont;c;C;t
GDB thinks the target doesn't support single step, so it will use software
single step.
If the patched GDB talks with unpatched GDBserver, the RSP traffic is like
this:
-> $qSupported:...+;vContSupported+
<- ...+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
although GDBserver returns s and S, GDB still thinks GDBserver may not
support single step because it doesn't support vContSupported.
If the unpatched GDB talks with patched GDBserver on x86, the RSP traffic
is like:
-> $qSupported:...+;
<- ...+;vContSupported+
...
-> $vCont?
<- vCont;c;C;t;s;S;r
Since GDB doesn't sent vContSupported in the qSupported feature, GDBserver
sends s and S regardless of the support of hardware single step.
gdb:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-nat.c (aarch64_linux_can_do_single_step): New
function.
(_initialize_aarch64_linux_nat): Install it to to_can_do_single_step.
* arm-linux-tdep.c (arm_linux_software_single_step): Return 0
if target_can_do_single_step returns 1.
* remote.c (struct vCont_action_support) <s, S>: New fields.
(PACKET_vContSupported): New enum.
(remote_protocol_features): New element for vContSupported.
(remote_query_supported): Append "vContSupported+".
(remote_vcont_probe): Remove support_s and support_S, use
rs->supports_vCont.s and rs->supports_vCont.S instead. Disable
vCont packet if c and C actions are not supported.
(remote_can_do_single_step): New function.
(init_remote_ops): Install it to to_can_do_single_step.
(_initialize_remote): Call add_packet_config_cmd.
* target.h (struct target_ops) <to_can_do_single_step>: New field.
(target_can_do_single_step): New macro.
* target-delegates.c: Re-generated.
gdb/gdbserver:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* server.c (vCont_supported): New global variable.
(handle_query): Set vCont_supported to 1 if "vContSupported+"
matches. Append ";vContSupported+" to own_buf.
(handle_v_requests): Append ";s;S" to own_buf if target supports
hardware single step or vCont_supported is false.
(capture_main): Set vCont_supported to zero.
gdb/doc:
2015-09-15 Yao Qi <yao.qi@linaro.org>
* gdb.texinfo (General Query Packets): Add vContSupported to
tables of 'gdbfeatures' and 'stub features' supported in the
qSupported packet, as well as to the list containing stub
feature details.
2015-09-15 21:09:18 +08:00
|
|
|
ops->to_can_do_single_step = debug_can_do_single_step;
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
ops->to_terminal_init = debug_terminal_init;
|
|
|
|
ops->to_terminal_inferior = debug_terminal_inferior;
|
|
|
|
ops->to_terminal_ours_for_output = debug_terminal_ours_for_output;
|
|
|
|
ops->to_terminal_ours = debug_terminal_ours;
|
|
|
|
ops->to_terminal_info = debug_terminal_info;
|
|
|
|
ops->to_kill = debug_kill;
|
|
|
|
ops->to_load = debug_load;
|
|
|
|
ops->to_post_startup_inferior = debug_post_startup_inferior;
|
|
|
|
ops->to_insert_fork_catchpoint = debug_insert_fork_catchpoint;
|
|
|
|
ops->to_remove_fork_catchpoint = debug_remove_fork_catchpoint;
|
|
|
|
ops->to_insert_vfork_catchpoint = debug_insert_vfork_catchpoint;
|
|
|
|
ops->to_remove_vfork_catchpoint = debug_remove_vfork_catchpoint;
|
|
|
|
ops->to_follow_fork = debug_follow_fork;
|
|
|
|
ops->to_insert_exec_catchpoint = debug_insert_exec_catchpoint;
|
|
|
|
ops->to_remove_exec_catchpoint = debug_remove_exec_catchpoint;
|
Extended-remote follow-exec
This patch implements support for exec events on extended-remote Linux
targets. Follow-exec-mode and rerun behave as expected. Catchpoints and
test updates are implemented in subsequent patches.
This patch was derived from a patch posted last October:
https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html.
It was originally based on some work done by Luis Machado in 2013.
IMPLEMENTATION
----------------
Exec events are enabled via ptrace options.
When an exec event is detected by gdbserver, the existing process
data, along with all its associated lwp and thread data, is deleted
and replaced by data for a new single-threaded process. The new
process data is initialized with the appropriate parts of the state
of the execing process. This approach takes care of several potential
pitfalls, including:
* deleting the data for an execing non-leader thread before any
wait/sigsuspend occurs
* correctly initializing the architecture of the execed process
We then report the exec event using a new RSP stop reason, "exec".
When GDB receives an "exec" event, it saves the status in the event
structure's target_waitstatus field, like what is done for remote fork
events. Because the original and execed programs may have different
architectures, we skip parsing the section of the stop reply packet
that contains register data. The register data will be retrieved
later after the inferior's architecture has been set up by
infrun.c:follow_exec.
At that point the exec event is handled by the existing event handling
in GDB. However, a few changes were necessary so that
infrun.c:follow_exec could accommodate the remote target.
* Where follow-exec-mode "new" is handled, we now call
add_inferior_with_spaces instead of add_inferior with separate calls
to set up the program and address spaces. The motivation for this
is that add_inferior_with_spaces also sets up the initial architecture
for the inferior, which is needed later by target_find_description
when it calls target_gdbarch.
* We call a new target function, target_follow_exec. This function
allows us to store the execd_pathname in the inferior, instead of
using the static string remote_exec_file from remote.c. The static
string didn't work for follow-exec-mode "new", since once you switched
to the execed program, the original remote exec-file was lost. The
execd_pathname is now stored in the inferior's program space as a
REGISTRY field. All of the requisite mechanisms for this are
defined in remote.c.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_mourn): Static declaration.
(linux_arch_setup): Move in front of
handle_extended_wait.
(linux_arch_setup_thread): New function.
(handle_extended_wait): Handle exec events. Call
linux_arch_setup_thread. Make event_lwp argument a
pointer-to-a-pointer.
(check_zombie_leaders): Do not check stopped threads.
(linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC.
(linux_low_filter_event): Add lwp and thread for exec'ing
non-leader thread if leader thread has been deleted.
Refactor code into linux_arch_setup_thread and call it.
Pass child lwp pointer by reference to handle_extended_wait.
(linux_wait_for_event_filtered): Update comment.
(linux_wait_1): Prevent clobbering exec event status.
(linux_supports_exec_events): New function.
(linux_target_ops) <supports_exec_events>: Initialize new member.
* lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize
new member.
* remote-utils.c (prepare_resume_reply): New stop reason 'exec'.
* server.c (report_exec_events): New global variable.
(handle_query): Handle qSupported query for exec-events feature.
(captured_main): Initialize report_exec_events.
* server.h (report_exec_events): Declare new global variable.
* target.h (struct target_ops) <supports_exec_events>: New
member.
(target_supports_exec_events): New macro.
* win32-low.c (win32_target_ops) <supports_exec_events>:
Initialize new member.
gdb/ChangeLog:
* infrun.c (follow_exec): Use process-style ptid for
exec message. Call add_inferior_with_spaces and
target_follow_exec.
* nat/linux-ptrace.c (linux_supports_traceexec): New function.
* nat/linux-ptrace.h (linux_supports_traceexec): Declare.
* remote.c (remote_pspace_data): New static variable.
(remote_pspace_data_cleanup): New function.
(get_remote_exec_file): New function.
(set_remote_exec_file_1): New function.
(set_remote_exec_file): New function.
(show_remote_exec_file): New function.
(remote_exec_file): Delete static variable.
(anonymous enum) <PACKET_exec_event_feature> New
enumeration constant.
(remote_protocol_features): Add entry for exec-events feature.
(remote_query_supported): Add client side of qSupported query
for exec-events feature.
(remote_follow_exec): New function.
(remote_parse_stop_reply): Handle 'exec' stop reason.
(extended_remote_run, extended_remote_create_inferior): Call
get_remote_exec_file and set_remote_exec_file_1.
(init_extended_remote_ops) <to_follow_exec>: Initialize new
member.
(_initialize_remote): Call
register_program_space_data_with_cleanup. Call
add_packet_config_cmd for remote exec-events feature.
Modify call to add_setshow_string_noescape_cmd for exec-file
to use new functions set_remote_exec_file and
show_remote_exec_file.
* target-debug.h, target-delegates.c: Regenerated.
* target.c (target_follow_exec): New function.
* target.h (struct target_ops) <to_follow_exec>: New member.
(target_follow_exec): Declare new function.
2015-09-12 02:06:02 +08:00
|
|
|
ops->to_follow_exec = debug_follow_exec;
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
ops->to_set_syscall_catchpoint = debug_set_syscall_catchpoint;
|
|
|
|
ops->to_has_exited = debug_has_exited;
|
|
|
|
ops->to_mourn_inferior = debug_mourn_inferior;
|
|
|
|
ops->to_can_run = debug_can_run;
|
|
|
|
ops->to_pass_signals = debug_pass_signals;
|
|
|
|
ops->to_program_signals = debug_program_signals;
|
|
|
|
ops->to_thread_alive = debug_thread_alive;
|
Push pruning old threads down to the target
When GDB wants to sync the thread list with the target's (e.g., due to
"info threads"), it calls update_thread_list:
update_thread_list (void)
{
prune_threads ();
target_find_new_threads ();
update_threads_executing ();
}
And then prune_threads does:
prune_threads (void)
{
struct thread_info *tp, *next;
for (tp = thread_list; tp; tp = next)
{
next = tp->next;
if (!thread_alive (tp))
delete_thread (tp->ptid);
}
}
Calling thread_live on each thread one by one is expensive.
E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not
a big deal, but still a bunch of syscalls...
With the remote target, it's cumbersome. That thread_alive call ends
up generating one T packet per thread:
Sending packet: $Tp2141.2150#82...Packet received: OK
Sending packet: $Tp2141.214f#b7...Packet received: OK
Sending packet: $Tp2141.2141#82...Packet received: OK
Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n
That seems a bit silly when target_find_new_threads method
implementations will always fetch the whole current set of target
threads, and then add those that are not in GDB's thread list, to
GDB's thread list.
This patch thus pushes down the responsibility of pruning dead threads
to the target_find_new_threads method instead, so a target may
implement pruning dead threads however it wants.
Once we do that, target_find_new_threads becomes a misnomer, so the
patch renames it to target_update_thread_list.
The patch doesn't attempt to do any optimization to any target yet.
It simply exports prune_threads, and makes all implementations of
target_update_thread_list call that. It's meant to be a no-op.
gdb/
2014-10-15 Pedro Alves <palves@redhat.com>
* ada-tasks.c (print_ada_task_info, task_command_1): Adjust.
* bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ...
(bsd_uthread_update_thread_list): ... this. Call prune_threads.
(bsd_uthread_target): Adjust.
* corelow.c (core_open): Adjust.
* dec-thread.c (dec_thread_find_new_threads): Update comment.
(dec_thread_update_thread_list): New function.
(init_dec_thread_ops): Adjust.
* gdbthread.h (prune_threads): New declaration.
* linux-thread-db.c (thread_db_find_new_threads): Rename to ...
(thread_db_update_thread_list): ... this. Call prune_threads.
(init_thread_db_ops): Adjust.
* nto-procfs.c (procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
(procfs_attach, procfs_create_inferior, init_procfs_targets):
Adjust.
* obsd-nat.c (obsd_find_new_threads): Rename to ...
(obsd_update_thread_list): ... this. Call prune_threads.
(obsd_add_target): Adjust.
* procfs.c (procfs_target): Adjust.
(procfs_notice_thread): Update comment.
(procfs_find_new_threads): Rename to ...
(procfs_update_thread_list): ... this. Call prune_threads.
* ravenscar-thread.c (ravenscar_update_inferior_ptid): Update
comment.
(ravenscar_wait): Adjust.
(ravenscar_find_new_threads): Rename to ...
(ravenscar_update_thread_list): ... this. Call prune_threads.
(init_ravenscar_thread_ops): Adjust.
* record-btrace.c (record_btrace_find_new_threads): Rename to ...
(record_btrace_update_thread_list): ... this. Adjust comment.
(init_record_btrace_ops): Adjust.
* remote.c (remote_threads_info): Rename to ...
(remote_update_thread_list): ... this. Call prune_threads.
(remote_start_remote, extended_remote_attach_1, init_remote_ops):
Adjust.
* sol-thread.c (check_for_thread_db): Adjust.
(sol_find_new_threads_callback): Rename to ...
(sol_update_thread_list_callback): ... this.
(sol_find_new_threads): Rename to ...
(sol_update_thread_list): ... this. Call prune_threads. Adjust.
(sol_get_ada_task_ptid, init_sol_thread_ops): Adjust.
* target-delegates.c: Regenerate.
* target.c (target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* target.h (struct target_ops): Rename to_find_new_threads field
to to_update_thread_list.
(target_find_new_threads): Rename to ...
(target_update_thread_list): ... this.
* thread.c (prune_threads): Make extern.
(update_thread_list): Adjust.
2014-10-16 05:44:00 +08:00
|
|
|
ops->to_update_thread_list = debug_update_thread_list;
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
ops->to_pid_to_str = debug_pid_to_str;
|
|
|
|
ops->to_extra_thread_info = debug_extra_thread_info;
|
|
|
|
ops->to_thread_name = debug_thread_name;
|
|
|
|
ops->to_stop = debug_stop;
|
Fix interrupt-noterm.exp on targets always in non-stop
With "maint set target-non-stop on" we get:
@@ -66,13 +66,16 @@ Continuing.
interrupt
(gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt
-Program received signal SIGINT, Interrupt.
-PASS: gdb.base/interrupt-noterm.exp: inferior received SIGINT
-testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 0 seconds
+[process 12119] #1 stopped.
+0x0000003615ebc6d0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81
+81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
+FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT (timeout)
+testcase src/gdb/testsuite/gdb.base/interrupt-noterm.exp completed in 10 seconds
That is, we get "[$thread] #1 stopped" instead of SIGINT.
The issue is that we don't currently distinguish send
"interrupt/ctrl-c" to target terminal vs "stop/pause" thread well;
both cases go through "target_stop".
And then, the native Linux backend (linux-nat.c) implements
target_stop with SIGSTOP in non-stop mode, and SIGINT in all-stop
mode. Since "maint set target-non-stop on" forces the backend to be
always running in non-stop mode, even though the user-visible behavior
is "set non-stop" is "off", "interrupt" causes a SIGSTOP instead of
the SIGINT the test expects.
Fix this by introducing a target_interrupt method to use in the
"interrupt/ctrl-c" case, so "set non-stop off" can always work the
same irrespective of "maint set target-non-stop on/off". I'm
explictly considering changing the "set non-stop on" behavior as out
of scope here.
Most of the patch is an across-the-board rename of to_stop hook
implementations to to_interrupt. The only targets where something
more than a rename is being done are linux-nat.c and remote.c, which
are the only targets that support async, and thus are the only ones
the core side calls target_stop on.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_stop): Rename to ...
(darwin_interrupt): ... this.
(_initialize_darwin_inferior): Adjust.
* gnu-nat.c (gnu_stop): Delete.
(gnu_target): Don't install gnu_stop.
* inf-ptrace.c (inf_ptrace_stop): Rename to ...
(inf_ptrace_interrupt): ... this.
(inf_ptrace_target): Adjust.
* infcmd.c (interrupt_target_1): Use target_interrupt instead of
target_stop.
* linux-nat (linux_nat_stop): Rename to ...
(linux_nat_interrupt): ... this.
(linux_nat_stop): Reimplement.
(linux_nat_add_target): Install linux_nat_interrupt.
* nto-procfs.c (nto_interrupt_twice): Rename to ...
(nto_handle_sigint_twice): ... this.
(nto_interrupt): Rename to ...
(nto_handle_sigint): ... this. Call target_interrupt instead of
target_stop.
(procfs_wait): Adjust.
(procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(init_procfs_targets): Adjust.
* procfs.c (procfs_stop): Rename to ...
(procfs_interrupt): ... this.
(procfs_target): Adjust.
* remote-m32r-sdi.c (m32r_stop): Rename to ...
(m32r_interrupt): ... this.
(init_m32r_ops): Adjust.
* remote-sim.c (gdbsim_stop_inferior): Rename to ...
(gdbsim_interrupt_inferior): ... this.
(gdbsim_stop): Rename to ...
(gdbsim_interrupt): ... this.
(gdbsim_cntrl_c): Adjust.
(init_gdbsim_ops): Adjust.
* remote.c (sync_remote_interrupt): Adjust comments.
(remote_stop_as): Rename to ...
(remote_interrupt_as): ... this.
(remote_stop): Adjust comment.
(remote_interrupt): New function.
(init_remote_ops): Install remote_interrupt.
* target.c (target_interrupt): New function.
* target.h (struct target_ops) <to_interrupt>: New field.
(target_interrupt): New declaration.
* windows-nat.c (windows_stop): Rename to ...
(windows_interrupt): ... this.
* target-delegates.c: Regenerate.
2015-08-07 01:22:58 +08:00
|
|
|
ops->to_interrupt = debug_interrupt;
|
remote: allow aborting long operations (e.g., file transfers)
Currently, when remote debugging, if you type Ctrl-C just while the
target stopped for an internal event, and GDB is busy doing something
that takes a while (e.g., fetching chunks of a shared library off of
the target, with vFile, to process ELF headers and debug info), the
Ctrl-C is lost.
The patch hooks up the QUIT macro to a new target method that lets the
target react to the double-Ctrl-C before the event loop is reached,
which allows reacting to a double-Ctrl-C even when GDB is busy doing
some long operation and not waiting for a stop reply. That end result
is:
(gdb) c
Continuing.
^C
^C
Interrupted while waiting for the program.
Give up waiting? (y or n) y
Quit
(gdb) info threads
Id Target Id Frame
* 1 Thread 11673 0x00007ffff7deb240 in _dl_debug_state () from target:/lib64/ld-linux-x86-64.so.2
(gdb)
If, however, GDB is waiting for a stop reply (because the target has
been resumed, with e.g., vCont;c), but the target isn't responding, we
now get:
(gdb) c
Continuing.
^C
^C
The target is not responding to interrupt requests.
Stop debugging it? (y or n) y
Disconnected from target.
(gdb) info threads
No threads.
This offers to disconnect, because when we're waiting for a stop
reply, there's nothing else we can send the target other than an
interrupt request. And if that doesn't work, there's nothing else we
can do.
The Ctrl-C is presently lost because until we get to a user-visible
stop, the SIGINT handler that is installed is the one that forwards
the interrupt to the remote side, with the \003 "packet" [1]. But,
gdbserver ignores an interrupt request if the program is stopped.
Still, even if it didn't, the server can only report back a
stop-because-of-SIGINT when the program is next resumed. And it may
take a while to actually re-resume the target.
[1] - In the old sync days, the remote target would react to a
double-Ctrl-C by asking users whether they wanted to give up waiting
and disconnect. The code is still there, but it it isn't reacheable
on most hosts, which support serial connections in async mode
(probably only DJGPP doesn't). Even then, in sync mode, remote.c's
SIGINT handler is only installed while the target is resumed, and is
removed as soon as the target sends back a stop reply. That means
that a Ctrl-C just while GDB is processing an internal event can end
up with an odd "Quit" at the prompt instead of "Program stopped by
SIGINT". In contrast, in async mode, remote.c's SIGINT handler is set
up as long as target_terminal_inferior or
target_terminal_ours_for_output are in effect (IOW, until we get a
user-visible stop and call target_terminal_ours), so the user
shouldn't get back a spurious Quit. However, it's still desirable to
be able to interrupt a long-running GDB operation, if GDB takes a
while to re-resume the target or get back to the event loop.
Tested on x86_64 Fedora 20.
gdb/ChangeLog:
2015-08-24 Pedro Alves <palves@redhat.com>
* defs.h (maybe_quit): Declare.
(QUIT): Now calls maybe_quit.
* event-loop.c (clear_async_signal_handler)
(async_signal_handler_is_marked): New functions.
* event-loop.h (async_signal_handler_is_marked)
(clear_async_signal_handler): New declarations.
* remote.c (remote_check_pending_interrupt): New function.
(interrupt_query): Use make_cleanup_restore_target_terminal. No
longer check whether the target is async. If waiting for a stop
reply, and a Ctrl-C as been sent to the target, offer to
disconnect, and throw TARGET_CLOSE_ERROR instead of a quit.
Otherwise do not disconnect and throw a quit.
(_initialize_remote): Install remote_check_pending_interrupt as
to_check_pending_interrupt.
* target.c (target_check_pending_interrupt): New function.
* target.h (struct target_ops) <to_check_pending_interrupt>: New
field.
(target_check_pending_interrupt): New declaration.
* utils.c (maybe_quit): New function.
* target-delegates.c: Regenerate.
2015-08-25 23:12:11 +08:00
|
|
|
ops->to_check_pending_interrupt = debug_check_pending_interrupt;
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
ops->to_rcmd = debug_rcmd;
|
|
|
|
ops->to_pid_to_exec_file = debug_pid_to_exec_file;
|
|
|
|
ops->to_log_command = debug_log_command;
|
|
|
|
ops->to_get_section_table = debug_get_section_table;
|
|
|
|
ops->to_can_async_p = debug_can_async_p;
|
|
|
|
ops->to_is_async_p = debug_is_async_p;
|
|
|
|
ops->to_async = debug_async;
|
|
|
|
ops->to_supports_non_stop = debug_supports_non_stop;
|
Implement all-stop on top of a target running non-stop mode
This finally implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode. This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like thread groups, associating groups with breakpoints, etc.
From the user's perspective, all-stop mode is really just a special
case of being able to stop and resume specific sets of threads, so it
makes sense to do this step first.
With this, even in all-stop, the target is no longer in charge of
stopping all threads before reporting an event to the core -- the core
takes care of it when it sees fit. For example, when "next"- or
"step"-ing, we can avoid stopping and resuming all threads at each
internal single-step, and instead only stop all threads when we're
about to present the stop to the user.
The implementation is almost straight forward, as the heavy lifting
has been done already in previous patches. Basically, we replace
checks for "set non-stop on/off" (the non_stop global), with calls to
a new target_is_non_stop_p function. In a few places, if "set
non-stop off", we stop all threads explicitly, and in a few other
places we resume all threads explicitly, making use of existing
methods that were added for teaching non-stop to step over breakpoints
without displaced stepping.
This adds a new "maint set target-non-stop on/off/auto" knob that
allows both disabling the feature if we find problems, and
force-enable it for development (useful when teaching a target about
this. The default is "auto", which means the feature is enabled if a
new target method says it should be enabled. The patch implements the
method in linux-nat.c, just for illustration, because it still returns
false. We'll need a few follow up fixes before turning it on by
default. This is a separate target method from indicating regular
non-stop support, because e.g., while e.g., native linux-nat.c is
close to regression free with all-stop-non-stop (with following
patches will fixing the remaining regressions), remote.c+gdbserver
will still need more fixing, even though it supports "set non-stop
on".
Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* NEWS: Mention "maint set/show target-non-stop".
* breakpoint.c (update_global_location_list): Check
target_is_non_stop_p instead of non_stop.
* infcmd.c (attach_command_post_wait, attach_command): Likewise.
* infrun.c (show_can_use_displaced_stepping)
(can_use_displaced_stepping_p, start_step_over_inferior):
Likewise.
(internal_resume_ptid): New function.
(resume): Use it.
(proceed): Check target_is_non_stop_p instead of non_stop. If in
all-stop mode but the target is always in non-stop mode, start all
the other threads that are implicitly resumed too.
(for_each_just_stopped_thread, fetch_inferior_event)
(adjust_pc_after_break, stop_all_threads): Check
target_is_non_stop_p instead of non_stop.
(handle_inferior_event): Likewise. Handle detach-fork in all-stop
with the target always in non-stop mode.
(handle_signal_stop) <random signal>: Check target_is_non_stop_p
instead of non_stop.
(switch_back_to_stepped_thread): Check target_is_non_stop_p
instead of non_stop.
(keep_going_stepped_thread): Use internal_resume_ptid.
(stop_waiting): If in all-stop mode, and the target is in non-stop
mode, stop all threads.
(keep_going_pass): Likewise, when starting a new in-line step-over
sequence.
* linux-nat.c (get_pending_status, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
target_is_non_stop_p instead of non_stop.
(linux_nat_always_non_stop_p): New function.
(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
(linux_nat_add_target): Install linux_nat_always_non_stop_p.
* target-delegates.c: Regenerate.
* target.c (target_is_non_stop_p): New function.
(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
(maint_set_target_non_stop_command)
(maint_show_target_non_stop_command): New functions.
(_initilize_target): Install "maint set/show target-non-stop"
commands.
* target.h (struct target_ops) <to_always_non_stop_p>: New field.
(target_non_stop_enabled): New declaration.
(target_is_non_stop_p): New declaration.
gdb/doc/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Maintenance Commands): Document "maint set/show
target-non-stop".
2015-08-08 00:24:01 +08:00
|
|
|
ops->to_always_non_stop_p = debug_always_non_stop_p;
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
ops->to_find_memory_regions = debug_find_memory_regions;
|
|
|
|
ops->to_make_corefile_notes = debug_make_corefile_notes;
|
|
|
|
ops->to_get_bookmark = debug_get_bookmark;
|
|
|
|
ops->to_goto_bookmark = debug_goto_bookmark;
|
|
|
|
ops->to_get_thread_local_address = debug_get_thread_local_address;
|
|
|
|
ops->to_xfer_partial = debug_xfer_partial;
|
|
|
|
ops->to_memory_map = debug_memory_map;
|
|
|
|
ops->to_flash_erase = debug_flash_erase;
|
|
|
|
ops->to_flash_done = debug_flash_done;
|
|
|
|
ops->to_read_description = debug_read_description;
|
|
|
|
ops->to_get_ada_task_ptid = debug_get_ada_task_ptid;
|
|
|
|
ops->to_auxv_parse = debug_auxv_parse;
|
|
|
|
ops->to_search_memory = debug_search_memory;
|
|
|
|
ops->to_can_execute_reverse = debug_can_execute_reverse;
|
|
|
|
ops->to_execution_direction = debug_execution_direction;
|
|
|
|
ops->to_supports_multi_process = debug_supports_multi_process;
|
|
|
|
ops->to_supports_enable_disable_tracepoint = debug_supports_enable_disable_tracepoint;
|
|
|
|
ops->to_supports_string_tracing = debug_supports_string_tracing;
|
|
|
|
ops->to_supports_evaluation_of_breakpoint_conditions = debug_supports_evaluation_of_breakpoint_conditions;
|
|
|
|
ops->to_can_run_breakpoint_commands = debug_can_run_breakpoint_commands;
|
|
|
|
ops->to_thread_architecture = debug_thread_architecture;
|
|
|
|
ops->to_thread_address_space = debug_thread_address_space;
|
2015-04-02 20:38:28 +08:00
|
|
|
ops->to_filesystem_is_local = debug_filesystem_is_local;
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
ops->to_trace_init = debug_trace_init;
|
|
|
|
ops->to_download_tracepoint = debug_download_tracepoint;
|
|
|
|
ops->to_can_download_tracepoint = debug_can_download_tracepoint;
|
|
|
|
ops->to_download_trace_state_variable = debug_download_trace_state_variable;
|
|
|
|
ops->to_enable_tracepoint = debug_enable_tracepoint;
|
|
|
|
ops->to_disable_tracepoint = debug_disable_tracepoint;
|
|
|
|
ops->to_trace_set_readonly_regions = debug_trace_set_readonly_regions;
|
|
|
|
ops->to_trace_start = debug_trace_start;
|
|
|
|
ops->to_get_trace_status = debug_get_trace_status;
|
|
|
|
ops->to_get_tracepoint_status = debug_get_tracepoint_status;
|
|
|
|
ops->to_trace_stop = debug_trace_stop;
|
|
|
|
ops->to_trace_find = debug_trace_find;
|
|
|
|
ops->to_get_trace_state_variable_value = debug_get_trace_state_variable_value;
|
|
|
|
ops->to_save_trace_data = debug_save_trace_data;
|
|
|
|
ops->to_upload_tracepoints = debug_upload_tracepoints;
|
|
|
|
ops->to_upload_trace_state_variables = debug_upload_trace_state_variables;
|
|
|
|
ops->to_get_raw_trace_data = debug_get_raw_trace_data;
|
|
|
|
ops->to_get_min_fast_tracepoint_insn_len = debug_get_min_fast_tracepoint_insn_len;
|
|
|
|
ops->to_set_disconnected_tracing = debug_set_disconnected_tracing;
|
|
|
|
ops->to_set_circular_trace_buffer = debug_set_circular_trace_buffer;
|
|
|
|
ops->to_set_trace_buffer_size = debug_set_trace_buffer_size;
|
|
|
|
ops->to_set_trace_notes = debug_set_trace_notes;
|
|
|
|
ops->to_core_of_thread = debug_core_of_thread;
|
|
|
|
ops->to_verify_memory = debug_verify_memory;
|
|
|
|
ops->to_get_tib_address = debug_get_tib_address;
|
|
|
|
ops->to_set_permissions = debug_set_permissions;
|
|
|
|
ops->to_static_tracepoint_marker_at = debug_static_tracepoint_marker_at;
|
|
|
|
ops->to_static_tracepoint_markers_by_strid = debug_static_tracepoint_markers_by_strid;
|
|
|
|
ops->to_traceframe_info = debug_traceframe_info;
|
|
|
|
ops->to_use_agent = debug_use_agent;
|
|
|
|
ops->to_can_use_agent = debug_can_use_agent;
|
|
|
|
ops->to_supports_btrace = debug_supports_btrace;
|
|
|
|
ops->to_enable_btrace = debug_enable_btrace;
|
|
|
|
ops->to_disable_btrace = debug_disable_btrace;
|
|
|
|
ops->to_teardown_btrace = debug_teardown_btrace;
|
|
|
|
ops->to_read_btrace = debug_read_btrace;
|
2013-11-28 22:44:13 +08:00
|
|
|
ops->to_btrace_conf = debug_btrace_conf;
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
ops->to_stop_recording = debug_stop_recording;
|
|
|
|
ops->to_info_record = debug_info_record;
|
|
|
|
ops->to_save_record = debug_save_record;
|
|
|
|
ops->to_delete_record = debug_delete_record;
|
|
|
|
ops->to_record_is_replaying = debug_record_is_replaying;
|
2015-09-17 17:14:55 +08:00
|
|
|
ops->to_record_will_replay = debug_record_will_replay;
|
2015-09-08 15:42:20 +08:00
|
|
|
ops->to_record_stop_replaying = debug_record_stop_replaying;
|
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.
2014-06-16 11:28:57 +08:00
|
|
|
ops->to_goto_record_begin = debug_goto_record_begin;
|
|
|
|
ops->to_goto_record_end = debug_goto_record_end;
|
|
|
|
ops->to_goto_record = debug_goto_record;
|
|
|
|
ops->to_insn_history = debug_insn_history;
|
|
|
|
ops->to_insn_history_from = debug_insn_history_from;
|
|
|
|
ops->to_insn_history_range = debug_insn_history_range;
|
|
|
|
ops->to_call_history = debug_call_history;
|
|
|
|
ops->to_call_history_from = debug_call_history_from;
|
|
|
|
ops->to_call_history_range = debug_call_history_range;
|
|
|
|
ops->to_augmented_libraries_svr4_read = debug_augmented_libraries_svr4_read;
|
|
|
|
ops->to_get_unwinder = debug_get_unwinder;
|
|
|
|
ops->to_get_tailcall_unwinder = debug_get_tailcall_unwinder;
|
|
|
|
ops->to_prepare_to_generate_core = debug_prepare_to_generate_core;
|
|
|
|
ops->to_done_generating_core = debug_done_generating_core;
|
|
|
|
}
|