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
|
|
|
/* GDB target debugging macros
|
|
|
|
|
2024-01-12 23:30:44 +08:00
|
|
|
Copyright (C) 2014-2024 Free Software Foundation, Inc.
|
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
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#ifndef TARGET_DEBUG_H
|
|
|
|
#define TARGET_DEBUG_H
|
|
|
|
|
|
|
|
/* Printers for the debug target. Each prints an object of a given
|
|
|
|
type to a string that needn't be freed. Most printers are macros,
|
|
|
|
for brevity, but a few are static functions where more complicated
|
|
|
|
behavior is needed.
|
|
|
|
|
|
|
|
References to these printers are automatically generated by
|
2024-08-05 23:24:36 +08:00
|
|
|
make-target-delegates. See the generated file target-delegates-gen.c.
|
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
|
|
|
|
|
|
|
In a couple cases, a special printing function is defined and then
|
|
|
|
used via the TARGET_DEBUG_PRINTER macro. See target.h.
|
|
|
|
|
|
|
|
A few methods still have some explicit targetdebug code in
|
|
|
|
target.c. In most cases this is because target delegation hasn't
|
|
|
|
been done for the method; but individual cases vary. For instance,
|
|
|
|
target_store_registers does some special register printing that is
|
|
|
|
more simply done there, and target_xfer_partial additionally
|
|
|
|
bypasses the debug target. */
|
|
|
|
|
2024-04-18 04:54:07 +08:00
|
|
|
#include "gdbarch.h"
|
2024-04-13 02:44:38 +08:00
|
|
|
#include "gdbsupport/x86-xstate.h"
|
2024-04-18 04:54:07 +08:00
|
|
|
#include "progspace.h"
|
2024-04-13 02:44:38 +08:00
|
|
|
#include "target.h"
|
|
|
|
#include "target/wait.h"
|
|
|
|
#include "target/waitstatus.h"
|
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
|
|
|
|
2024-04-18 04:54:07 +08:00
|
|
|
/* The functions defined in this header file are not marked "inline", such
|
2024-08-05 23:24:36 +08:00
|
|
|
that any function not used by target-delegates-gen.c (the only user of this
|
|
|
|
file) will be flagged as unused. */
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_target_object (target_object object)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (object); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_CORE_ADDR (CORE_ADDR addr)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return core_addr_to_string (addr); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_const_char_p (const char *s)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return s != nullptr ? s : "(null)"; }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_int (int v)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (v); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_bool (bool v)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return v ? "true" : "false"; }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_long (long v)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (v); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_target_xfer_status (target_xfer_status status)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (status); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_exec_direction_kind (exec_direction_kind kind)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (kind); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_trace_find_type (trace_find_type type)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (type); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_btrace_read_type (btrace_read_type type)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (type); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_btrace_error (btrace_error error)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (error); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_ptid_t (ptid_t ptid)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (ptid.pid ()); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_gdbarch_p (gdbarch *arch)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return gdbarch_bfd_arch_info (arch)->printable_name; }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_const_gdb_byte_p (const gdb_byte *p)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (p); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_gdb_byte_p (gdb_byte *p)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (p); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_const_gdb_byte_pp (const gdb_byte **p)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (*p); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_gdb_signal (gdb_signal sig)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return gdb_signal_to_name (sig); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_ULONGEST (ULONGEST v)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return hex_string (v); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_ULONGEST_p (ULONGEST *p)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return hex_string (*p); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_LONGEST (LONGEST v)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return phex (v, 0); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_LONGEST_p (LONGEST *p)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return phex (*p, 0); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_bp_target_info_p (bp_target_info *bp)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return core_addr_to_string (bp->placed_address); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_expression_p (expression *exp)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (exp); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_CORE_ADDR_p (CORE_ADDR *p)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return core_addr_to_string (*p); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_int_p (int *p)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (*p); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_regcache_p (regcache *regcache)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (regcache); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_thread_info_p (thread_info *thread)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (thread); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_ui_file_p (ui_file *file)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (file); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_const_std_vector_target_section_p
|
|
|
|
(const std::vector<target_section> *vec)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (vec->data ()); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_void_p (void *p)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (p); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_find_memory_region_ftype (find_memory_region_ftype func)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (func); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_bfd_p (bfd *bfd)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (bfd); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_std_vector_mem_region (const std::vector<mem_region> &vec)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (vec.data ()); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_std_vector_static_tracepoint_marker
|
|
|
|
(const std::vector<static_tracepoint_marker> &vec)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (vec.data ()); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_const_target_desc_p (const target_desc *tdesc)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (tdesc); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_bp_location_p (bp_location *loc)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (loc); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_const_trace_state_variable_r
|
|
|
|
(const trace_state_variable &tsv)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (&tsv); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_trace_status_p (trace_status *status)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (status); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_tracepoint_p (tracepoint *tp)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (tp); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_uploaded_tp_p (uploaded_tp *tp)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (tp); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_uploaded_tp_pp (uploaded_tp **v)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (*v); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_uploaded_tsv_pp (uploaded_tsv **tsv)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (tsv); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_static_tracepoint_marker_p (static_tracepoint_marker *marker)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (marker); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_btrace_target_info_p (btrace_target_info *info)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (info); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_const_frame_unwind_p (const frame_unwind *fu)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (fu); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_btrace_data_p (btrace_data *data)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (data); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_record_method (record_method method)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (method); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_const_btrace_config_p (const btrace_config *config)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (config); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_const_btrace_target_info_p (const btrace_target_info *info)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (info); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_target_hw_bp_type (target_hw_bp_type type)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (type); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_bptype (bptype type)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (type); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_inferior_p (inferior *inf)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (inf); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_remove_bp_reason (remove_bp_reason reason)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (reason); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_gdb_disassembly_flags (gdb_disassembly_flags flags)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (flags); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_traceframe_info_up (std::unique_ptr<traceframe_info> &info)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (info.get ()); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_gdb_array_view_const_int
|
|
|
|
(const gdb::array_view<const int> &view)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return host_address_to_string (view.data ()); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_record_print_flags (record_print_flags flags)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (flags); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_thread_control_capabilities (thread_control_capabilities cap)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return plongest (cap); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_std_string (const std::string &str)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return str.c_str (); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_gdb_unique_xmalloc_ptr_char
|
|
|
|
(const gdb::unique_xmalloc_ptr<char> &p)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return p.get (); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_target_waitkind (target_waitkind kind)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return pulongest (kind); }
|
2024-04-18 04:54:07 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_gdb_thread_options (gdb_thread_options options)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return to_string (options); }
|
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
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2023-09-20 01:02:27 +08:00
|
|
|
target_debug_print_target_waitstatus_p (struct target_waitstatus *status)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return status->to_string (); }
|
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
|
|
|
|
2024-04-18 04:54:07 +08:00
|
|
|
/* Functions that are used via TARGET_DEBUG_PRINTER. */
|
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
|
|
|
|
gdb: make debug_target use one-liners
Turn the debug prints in debug_target's method to be one liners. For
instance, change this:
gdb_printf (gdb_stdlog, "<- %s->wait (", this->beneath ()->shortname ());
gdb_puts (target_debug_print_ptid_t (arg0), gdb_stdlog);
gdb_puts (", ", gdb_stdlog);
gdb_puts (target_debug_print_target_waitstatus_p (arg1), gdb_stdlog);
gdb_puts (", ", gdb_stdlog);
gdb_puts (target_debug_print_target_wait_flags (arg2), gdb_stdlog);
gdb_puts (") = ", gdb_stdlog);
target_debug_print_ptid_t (result);
gdb_puts ("\n", gdb_stdlog);
into this:
gdb_printf (gdb_stdlog,
"<- %s->wait (%s, %s, %s) = %s\n",
this->beneath ()->shortname (),
target_debug_print_ptid_t (arg0).c_str (),
target_debug_print_target_waitstatus_p (arg1).c_str (),
target_debug_print_target_wait_flags (arg2).c_str (),
target_debug_print_ptid_t (result).c_str ());
This makes it possible for a subsequent patch to turn this gdb_printf
call into a `target_debug_printf` call.
Change-Id: I808202438972fac1bba2f8ccb63e66a4fcef20c9
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-20 03:46:52 +08:00
|
|
|
static std::string
|
2024-04-18 04:54:07 +08:00
|
|
|
target_debug_print_step (int step)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return step ? "step" : "continue"; }
|
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
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
Make target_wait options use enum flags
This changes TARGET_WNOHANG to be a member of an enum, rather than a
define, and also adds a DEF_ENUM_FLAGS_TYPE for this type. Then, it
changes target_wait and the various target wait methods to use this
type rather than "int".
This didn't catch any bugs, but it seems like a decent cleanup
nevertheless.
I did not change deprecated_target_wait_hook, since that's only used
out-of-tree (by Insight), and there didn't seem to be a need.
I can't build some of these targets, so I modified them on a
best-effort basis. I don't think this patch should go in before the
release branch is made.
gdb/ChangeLog
2020-09-18 Tom Tromey <tromey@adacore.com>
* windows-nat.c (struct windows_nat_target) <wait>: Update.
(windows_nat_target::wait): Update.
* target/wait.h (enum target_wait_flag): New. Use
DEF_ENUM_FLAGS_TYPE.
* target/target.h (target_wait): Change type of options.
* target.h (target_options_to_string, default_target_wait):
Update.
(struct target_ops) <wait>: Change type of options.
* target.c (target_wait, default_target_wait, do_option): Change
type of "options".
(target_options_to_string): Likewise.
* target-delegates.c: Rebuild.
* target-debug.h (target_debug_print_target_wait_flags): Rename
from target_debug_print_options.
* sol-thread.c (class sol_thread_target) <wait>: Update.
(sol_thread_target::wait): Update.
* rs6000-nat.c (class rs6000_nat_target) <wait>: Update.
(rs6000_nat_target::wait): Update.
* remote.c (class remote_target) <wait, wait_ns, wait_as>:
Update.
(remote_target::wait_ns, remote_target::wait_as): Change type of
"options".
(remote_target::wait): Update.
* remote-sim.c (struct gdbsim_target) <wait>: Update.
(gdbsim_target::wait): Update.
* record-full.c (class record_full_base_target) <wait>: Update.
(record_full_wait_1): Change type of "options".
(record_full_base_target::wait): Update.
* record-btrace.c (class record_btrace_target) <wait>: Update.
(record_btrace_target::wait): Update.
* ravenscar-thread.c (struct ravenscar_thread_target) <wait>:
Update.
(ravenscar_thread_target::wait): Update.
* procfs.c (class procfs_target) <wait>: Update.
(procfs_target::wait): Update.
* obsd-nat.h (class obsd_nat_target) <wait>: Update.
* obsd-nat.c (obsd_nat_target::wait): Update.
* nto-procfs.c (struct nto_procfs_target) <wait>: Update.
(nto_procfs_target::wait): Update.
* nbsd-nat.h (struct nbsd_nat_target) <wait>: Update.
* nbsd-nat.c (nbsd_wait): Change type of "options".
(nbsd_nat_target::wait): Update.
* linux-thread-db.c (class thread_db_target) <wait>: Update.
(thread_db_target::wait): Update.
* linux-nat.h (class linux_nat_target) <wait>: Update.
* linux-nat.c (linux_nat_target::wait): Update.
(linux_nat_wait_1): Update.
* infrun.c (do_target_wait_1, do_target_wait): Change type of
"options".
* inf-ptrace.h (struct inf_ptrace_target) <wait>: Update.
* inf-ptrace.c (inf_ptrace_target::wait): Update.
* go32-nat.c (struct go32_nat_target) <wait>: Update.
(go32_nat_target::wait): Update.
* gnu-nat.h (struct gnu_nat_target) <wait>: Update.
* gnu-nat.c (gnu_nat_target::wait): Update.
* fbsd-nat.h (class fbsd_nat_target) <wait>: Update.
* fbsd-nat.c (fbsd_nat_target::wait): Update.
* darwin-nat.h (class darwin_nat_target) <wait>: Update.
* darwin-nat.c (darwin_nat_target::wait): Update.
* bsd-uthread.c (struct bsd_uthread_target) <wait>: Update.
(bsd_uthread_target::wait): Update.
* aix-thread.c (class aix_thread_target) <wait>: Update.
(aix_thread_target::wait): Update.
gdbserver/ChangeLog
2020-09-18 Tom Tromey <tromey@adacore.com>
* netbsd-low.h (class netbsd_process_target) <wait>: Update.
* netbsd-low.cc (netbsd_waitpid, netbsd_wait)
(netbsd_process_target::wait): Change type of target_options.
* win32-low.h (class win32_process_target) <wait>: Update.
* win32-low.cc (win32_process_target::wait): Update.
* target.h (class process_stratum_target) <wait>: Update.
(mywait): Update.
* target.cc (mywait, target_wait): Change type of "options".
* linux-low.h (class linux_process_target) <wait, wait_1>:
Update.
* linux-low.cc (linux_process_target::wait)
(linux_process_target::wait_1): Update.
2020-09-19 04:20:44 +08:00
|
|
|
target_debug_print_target_wait_flags (target_wait_flags options)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return target_options_to_string (options); }
|
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
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
target_pass_signals/target_program_signals: Use gdb::array_view
This replaces the pointer and length parameters of target_pass_signals
and target_program_signals with a gdb::array_view parameter, and fixes
the fallout.
In infrun.c, the signal_stop, signal_print, signal_program,
signal_catch, signal_pass globals are currently pointers to
heap-allocated memory. I see no point in that, so I converted them to
arrays. This allows simplifying the calls to
target_pass_signals/target_program_signals, since we can pass the
array directly, which can implicitly convert to gdb::array_view.
gdb/ChangeLog:
2019-01-24 Pedro Alves <palves@redhat.com>
* infrun.c (signal_stop, signal_print, signal_program)
(signal_catch, signal_pass): Now arrays instead of pointers.
(update_signals_program_target, do_target_resume)
(signal_catch_update, handle_command, _initialize_infrun): Adjust.
* linux-nat.c (linux_nat_target::pass_signals)
(linux_nat_target::create_inferior, linux_nat_target::attach):
Adjust.
* linux-nat.h (linux_nat_target::pass_signals): Adjust.
* nto-procfs.c (nto_procfs_target::pass_signals): Adjust.
* procfs.c (procfs_target::pass_signals): Adjust.
* record-full.c (record_full_target::resume): Adjust.
* remote.c (remote_target::pass_signals)
(remote_target::program_signals): Adjust.
* target-debug.h (target_debug_print_signals): Now takes a
gdb::array_view as parameter. Adjust.
* target.h (target_ops) <pass_signals, program_signals>: Replace
pointer and length parameters with gdb::array_view.
(target_pass_signals, target_program_signals): Likewise.
* target-delegates.c: Regenerate.
2019-01-25 02:25:06 +08:00
|
|
|
target_debug_print_signals (gdb::array_view<const unsigned char> sigs)
|
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
|
|
|
{
|
2024-04-20 03:46:51 +08:00
|
|
|
std::string s = "{";
|
target_pass_signals/target_program_signals: Use gdb::array_view
This replaces the pointer and length parameters of target_pass_signals
and target_program_signals with a gdb::array_view parameter, and fixes
the fallout.
In infrun.c, the signal_stop, signal_print, signal_program,
signal_catch, signal_pass globals are currently pointers to
heap-allocated memory. I see no point in that, so I converted them to
arrays. This allows simplifying the calls to
target_pass_signals/target_program_signals, since we can pass the
array directly, which can implicitly convert to gdb::array_view.
gdb/ChangeLog:
2019-01-24 Pedro Alves <palves@redhat.com>
* infrun.c (signal_stop, signal_print, signal_program)
(signal_catch, signal_pass): Now arrays instead of pointers.
(update_signals_program_target, do_target_resume)
(signal_catch_update, handle_command, _initialize_infrun): Adjust.
* linux-nat.c (linux_nat_target::pass_signals)
(linux_nat_target::create_inferior, linux_nat_target::attach):
Adjust.
* linux-nat.h (linux_nat_target::pass_signals): Adjust.
* nto-procfs.c (nto_procfs_target::pass_signals): Adjust.
* procfs.c (procfs_target::pass_signals): Adjust.
* record-full.c (record_full_target::resume): Adjust.
* remote.c (remote_target::pass_signals)
(remote_target::program_signals): Adjust.
* target-debug.h (target_debug_print_signals): Now takes a
gdb::array_view as parameter. Adjust.
* target.h (target_ops) <pass_signals, program_signals>: Replace
pointer and length parameters with gdb::array_view.
(target_pass_signals, target_program_signals): Likewise.
* target-delegates.c: Regenerate.
2019-01-25 02:25:06 +08:00
|
|
|
|
|
|
|
for (size_t i = 0; i < sigs.size (); i++)
|
|
|
|
if (sigs[i] != 0)
|
2024-04-20 03:46:51 +08:00
|
|
|
string_appendf (s, " %s",
|
|
|
|
gdb_signal_to_name (static_cast<gdb_signal>(i)));
|
|
|
|
|
|
|
|
s += " }";
|
|
|
|
|
|
|
|
return s;
|
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
|
|
|
}
|
|
|
|
|
gdb: make debug_target use one-liners
Turn the debug prints in debug_target's method to be one liners. For
instance, change this:
gdb_printf (gdb_stdlog, "<- %s->wait (", this->beneath ()->shortname ());
gdb_puts (target_debug_print_ptid_t (arg0), gdb_stdlog);
gdb_puts (", ", gdb_stdlog);
gdb_puts (target_debug_print_target_waitstatus_p (arg1), gdb_stdlog);
gdb_puts (", ", gdb_stdlog);
gdb_puts (target_debug_print_target_wait_flags (arg2), gdb_stdlog);
gdb_puts (") = ", gdb_stdlog);
target_debug_print_ptid_t (result);
gdb_puts ("\n", gdb_stdlog);
into this:
gdb_printf (gdb_stdlog,
"<- %s->wait (%s, %s, %s) = %s\n",
this->beneath ()->shortname (),
target_debug_print_ptid_t (arg0).c_str (),
target_debug_print_target_waitstatus_p (arg1).c_str (),
target_debug_print_target_wait_flags (arg2).c_str (),
target_debug_print_ptid_t (result).c_str ());
This makes it possible for a subsequent patch to turn this gdb_printf
call into a `target_debug_printf` call.
Change-Id: I808202438972fac1bba2f8ccb63e66a4fcef20c9
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-20 03:46:52 +08:00
|
|
|
static std::string
|
2020-06-20 04:31:23 +08:00
|
|
|
target_debug_print_size_t (size_t size)
|
|
|
|
{
|
2024-04-20 03:46:51 +08:00
|
|
|
return pulongest (size);
|
2020-06-20 04:31:23 +08:00
|
|
|
}
|
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2023-08-24 19:40:38 +08:00
|
|
|
target_debug_print_gdb_array_view_const_gdb_byte (gdb::array_view<const gdb_byte> vector)
|
2020-06-20 04:31:23 +08:00
|
|
|
{
|
2024-04-20 03:46:51 +08:00
|
|
|
std::string s = "{";
|
|
|
|
|
|
|
|
for (const auto b : vector)
|
|
|
|
string_appendf (s, " %s", phex_nz (b, 1));
|
|
|
|
|
|
|
|
s += " }";
|
|
|
|
|
|
|
|
return s;
|
2020-06-20 04:31:23 +08:00
|
|
|
}
|
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2023-08-24 19:40:38 +08:00
|
|
|
target_debug_print_const_gdb_byte_vector_r (const gdb::byte_vector &vector)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return target_debug_print_gdb_array_view_const_gdb_byte (vector); }
|
2023-08-24 19:40:38 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2020-06-20 04:31:23 +08:00
|
|
|
target_debug_print_gdb_byte_vector_r (gdb::byte_vector &vector)
|
2024-04-20 03:46:51 +08:00
|
|
|
{ return target_debug_print_const_gdb_byte_vector_r (vector); }
|
2023-08-29 05:18:19 +08:00
|
|
|
|
2024-04-20 03:46:51 +08:00
|
|
|
static std::string
|
2023-08-29 05:18:19 +08:00
|
|
|
target_debug_print_x86_xsave_layout (const x86_xsave_layout &layout)
|
|
|
|
{
|
2024-04-20 03:46:51 +08:00
|
|
|
std::string s = string_printf ("{ sizeof_xsave=%d", layout.sizeof_xsave);
|
|
|
|
|
|
|
|
#define POFFS(region) \
|
|
|
|
if (layout.region##_offset != 0) \
|
|
|
|
string_appendf (s, ", " #region "_offset=%d", layout.region##_offset);
|
|
|
|
|
2023-08-29 05:18:19 +08:00
|
|
|
POFFS(avx);
|
|
|
|
POFFS(k);
|
|
|
|
POFFS(zmm_h);
|
|
|
|
POFFS(zmm);
|
|
|
|
POFFS(pkru);
|
2024-04-20 03:46:51 +08:00
|
|
|
|
2023-08-29 05:18:19 +08:00
|
|
|
#undef POFFS
|
2024-04-20 03:46:51 +08:00
|
|
|
|
|
|
|
s += " }";
|
|
|
|
|
|
|
|
return s;
|
2023-08-29 05:18:19 +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
|
|
|
#endif /* TARGET_DEBUG_H */
|