52405d85ec
Now that 'process_stratum_target' has a single field left, namely 'pt' of type 'process_target', and that all the requests to a 'process_stratum_target' are forwarded to 'pt', meld the 'process_target' class into 'process_stratum_target'. This essentially means 1. All the references of the form 'the_target->pt' become 'the_target'. 2. All the uses of the name 'process_target' become 'process_stratum_target'. 3. The platform-specific target op vectors (e.g. linux_target_ops) are removed and instances of their "process target" classes are used instead. gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * target.h (struct process_stratum_target): Remove. (class process_target): Rename to ... (class process_stratum_target): ... this. * linux-low.h (class linux_process_target): Derive from 'process_stratum_target'. * linux-low.cc (linux_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of linux_process_target. * lynx-low.h (class lynx_process_target): Derive from 'process_stratum_target'. * lynx-low.cc (lynx_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of lynx_process_target. * nto-low.h (class nto_process_target): Derive from 'process_stratum_target'. * nto-low.cc (nto_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of nto_process_target. * win32-low.h (class win32_process_target): Derive from 'process_stratum_target'. * win32-low.cc (win32_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of win32_process_target. Replace 'the_target->pt' with 'the_target' in the uses below. * hostio.cc (hostio_error) (handle_setfs) (handle_open) (handle_unlink) (handle_readlink) * linux-aarch32-low.cc (arm_breakpoint_at) * linux-aarch64-low.cc (aarch64_breakpoint_at) * linux-arm-low.cc (arm_sigreturn_next_pc) (arm_get_hwcap) (arm_get_syscall_trapinfo) * linux-cris-low.cc (cris_breakpoint_at) * linux-crisv32-low.cc (cris_breakpoint_at) * linux-low.cc (handle_extended_wait) (linux_wait_1) (linux_read_memory) (linux_process_target::breakpoint_kind_from_pc) (linux_get_auxv) * linux-m32r-low.cc (m32r_breakpoint_at) * linux-mips-low.cc (mips_breakpoint_at) * linux-nios2-low.cc (nios2_breakpoint_at) * linux-ppc-low.cc (ppc_breakpoint_at) * linux-s390-low.cc (s390_get_hwcap) * linux-sh-low.cc (sh_breakpoint_at) * linux-sparc-low.cc (sparc_fill_gregset_to_stack) (sparc_store_gregset_from_stack) (sparc_breakpoint_at) * linux-tic6x-low.cc (tic6x_breakpoint_at) * linux-tile-low.cc (tile_breakpoint_at) * linux-x86-low.cc (x86_breakpoint_at) * linux-xtensa-low.cc (xtensa_breakpoint_at) * mem-break.cc (bp_size) (bp_opcode) (insert_memory_breakpoint) (set_raw_breakpoint_at) (delete_raw_breakpoint) (z_type_supported) (uninsert_raw_breakpoint) (reinsert_raw_breakpoint) (validate_inserted_breakpoint) * regcache.cc (regcache_read_pc) (regcache_write_pc) * remote-utils.cc (putpkt_binary_1) (input_interrupt) (getpkt) (prepare_resume_reply) * server.cc (handle_general_set) (handle_detach) (handle_qxfer_auxv) (handle_qxfer_exec_file) (handle_qxfer_libraries_svr4) (handle_qxfer_osdata) (handle_qxfer_siginfo) (handle_qxfer_fdpic) (handle_query) (resume) (handle_v_requests) (queue_stop_reply_callback) (captured_main) * target.cc (prepare_to_access_memory) (done_accessing_memory) (read_inferior_memory) (target_write_memory) (target_stop_and_wait) (target_wait) (target_mourn_inferior) (target_continue_no_signal) (target_continue) (target_supports_multi_process) (kill_inferior) * target.h (target_create_inferior) (target_post_create_inferior) (myattach) (target_supports_fork_events) (target_supports_vfork_events) (target_supports_exec_events) (target_handle_new_gdb_connection) (detach_inferior) (mythread_alive) (fetch_inferior_registers) (store_inferior_registers) (join_inferior) (target_supports_non_stop) (target_async) (target_process_qsupported) (target_supports_catch_syscall) (target_get_ipa_tdesc_idx) (target_supports_tracepoints) (target_supports_fast_tracepoints) (target_get_min_fast_tracepoint_insn_len) (target_thread_stopped) (target_pause_all) (target_unpause_all) (target_stabilize_threads) (target_install_fast_tracepoint_jump_pad) (target_emit_ops) (target_supports_disable_randomization) (target_supports_agent) (target_enable_btrace) (target_disable_btrace) (target_read_btrace) (target_read_btrace_conf) (target_supports_range_stepping) (target_supports_stopped_by_sw_breakpoint) (target_stopped_by_sw_breakpoint) (target_supports_stopped_by_hw_breakpoint) (target_supports_hardware_single_step) (target_stopped_by_hw_breakpoint) (target_breakpoint_kind_from_pc) (target_breakpoint_kind_from_current_state) (target_supports_software_single_step) (target_core_of_thread) (target_thread_name) (target_thread_handle) * win32-low.cc (do_initial_child_stuff) Rename target op default definitions listed below. * target.cc (process_target::post_create_inferior): Rename as ... (process_stratum_target::post_create_inferior): ... this. (process_target::prepare_to_access_memory): Rename as ... (process_stratum_target::prepare_to_access_memory): ... this. (process_target::done_accessing_memory): Rename as ... (process_stratum_target::done_accessing_memory): ... this. (process_target::look_up_symbols): Rename as ... (process_stratum_target::look_up_symbols): ... this. (process_target::supports_read_auxv): Rename as ... (process_stratum_target::supports_read_auxv): ... this. (process_target::read_auxv): Rename as ... (process_stratum_target::read_auxv): ... this. (process_target::supports_z_point_type): Rename as ... (process_stratum_target::supports_z_point_type): ... this. (process_target::insert_point): Rename as ... (process_stratum_target::insert_point): ... this. (process_target::remove_point): Rename as ... (process_stratum_target::remove_point): ... this. (process_target::stopped_by_sw_breakpoint): Rename as ... (process_stratum_target::stopped_by_sw_breakpoint): ... this. (process_target::supports_stopped_by_sw_breakpoint): Rename as ... (process_stratum_target::supports_stopped_by_sw_breakpoint): ... this. (process_target::stopped_by_hw_breakpoint): Rename as ... (process_stratum_target::stopped_by_hw_breakpoint): ... this. (process_target::supports_stopped_by_hw_breakpoint): Rename as ... (process_stratum_target::supports_stopped_by_hw_breakpoint): ... this. (process_target::supports_hardware_single_step): Rename as ... (process_stratum_target::supports_hardware_single_step): ... this. (process_target::stopped_by_watchpoint): Rename as ... (process_stratum_target::stopped_by_watchpoint): ... this. (process_target::stopped_data_address): Rename as ... (process_stratum_target::stopped_data_address): ... this. (process_target::supports_read_offsets): Rename as ... (process_stratum_target::supports_read_offsets): ... this. (process_target::read_offsets): Rename as ... (process_stratum_target::read_offsets): ... this. (process_target::supports_get_tls_address): Rename as ... (process_stratum_target::supports_get_tls_address): ... this. (process_target::get_tls_address): Rename as ... (process_stratum_target::get_tls_address): ... this. (process_target::hostio_last_error): Rename as ... (process_stratum_target::hostio_last_error): ... this. (process_target::supports_qxfer_osdata): Rename as ... (process_stratum_target::supports_qxfer_osdata): ... this. (process_target::qxfer_osdata): Rename as ... (process_stratum_target::qxfer_osdata): ... this. (process_target::supports_qxfer_siginfo): Rename as ... (process_stratum_target::supports_qxfer_siginfo): ... this. (process_target::qxfer_siginfo): Rename as ... (process_stratum_target::qxfer_siginfo): ... this. (process_target::supports_non_stop): Rename as ... (process_stratum_target::supports_non_stop): ... this. (process_target::async): Rename as ... (process_stratum_target::async): ... this. (process_target::start_non_stop): Rename as ... (process_stratum_target::start_non_stop): ... this. (process_target::supports_multi_process): Rename as ... (process_stratum_target::supports_multi_process): ... this. (process_target::supports_fork_events): Rename as ... (process_stratum_target::supports_fork_events): ... this. (process_target::supports_vfork_events): Rename as ... (process_stratum_target::supports_vfork_events): ... this. (process_target::supports_exec_events): Rename as ... (process_stratum_target::supports_exec_events): ... this. (process_target::handle_new_gdb_connection): Rename as ... (process_stratum_target::handle_new_gdb_connection): ... this. (process_target::handle_monitor_command): Rename as ... (process_stratum_target::handle_monitor_command): ... this. (process_target::core_of_thread): Rename as ... (process_stratum_target::core_of_thread): ... this. (process_target::supports_read_loadmap): Rename as ... (process_stratum_target::supports_read_loadmap): ... this. (process_target::read_loadmap): Rename as ... (process_stratum_target::read_loadmap): ... this. (process_target::process_qsupported): Rename as ... (process_stratum_target::process_qsupported): ... this. (process_target::supports_tracepoints): Rename as ... (process_stratum_target::supports_tracepoints): ... this. (process_target::read_pc): Rename as ... (process_stratum_target::read_pc): ... this. (process_target::write_pc): Rename as ... (process_stratum_target::write_pc): ... this. (process_target::supports_thread_stopped): Rename as ... (process_stratum_target::supports_thread_stopped): ... this. (process_target::thread_stopped): Rename as ... (process_stratum_target::thread_stopped): ... this. (process_target::supports_get_tib_address): Rename as ... (process_stratum_target::supports_get_tib_address): ... this. (process_target::get_tib_address): Rename as ... (process_stratum_target::get_tib_address): ... this. (process_target::pause_all): Rename as ... (process_stratum_target::pause_all): ... this. (process_target::unpause_all): Rename as ... (process_stratum_target::unpause_all): ... this. (process_target::stabilize_threads): Rename as ... (process_stratum_target::stabilize_threads): ... this. (process_target::supports_fast_tracepoints): Rename as ... (process_stratum_target::supports_fast_tracepoints): ... this. (process_target::get_min_fast_tracepoint_insn_len): Rename as ... (process_stratum_target::get_min_fast_tracepoint_insn_len): ... this. (process_target::emit_ops): Rename as ... (process_stratum_target::emit_ops): ... this. (process_target::supports_disable_randomization): Rename as ... (process_stratum_target::supports_disable_randomization): ... this. (process_target::supports_qxfer_libraries_svr4): Rename as ... (process_stratum_target::supports_qxfer_libraries_svr4): ... this. (process_target::qxfer_libraries_svr4): Rename as ... (process_stratum_target::qxfer_libraries_svr4): ... this. (process_target::supports_agent): Rename as ... (process_stratum_target::supports_agent): ... this. (process_target::enable_btrace): Rename as ... (process_stratum_target::enable_btrace): ... this. (process_target::disable_btrace): Rename as ... (process_stratum_target::disable_btrace): ... this. (process_target::read_btrace): Rename as ... (process_stratum_target::read_btrace): ... this. (process_target::read_btrace_conf): Rename as ... (process_stratum_target::read_btrace_conf): ... this. (process_target::supports_range_stepping): Rename as ... (process_stratum_target::supports_range_stepping): ... this. (process_target::supports_pid_to_exec_file): Rename as ... (process_stratum_target::supports_pid_to_exec_file): ... this. (process_target::pid_to_exec_file): Rename as ... (process_stratum_target::pid_to_exec_file): ... this. (process_target::supports_multifs): Rename as ... (process_stratum_target::supports_multifs): ... this. (process_target::multifs_open): Rename as ... (process_stratum_target::multifs_open): ... this. (process_target::multifs_unlink): Rename as ... (process_stratum_target::multifs_unlink): ... this. (process_target::multifs_readlink): Rename as ... (process_stratum_target::multifs_readlink): ... this. (process_target::breakpoint_kind_from_pc): Rename as ... (process_stratum_target::breakpoint_kind_from_pc): ... this. (process_target::breakpoint_kind_from_current_state): Rename as ... (process_stratum_target::breakpoint_kind_from_current_state): ... this. (process_target::thread_name): Rename as ... (process_stratum_target::thread_name): ... this. (process_target::thread_handle): Rename as ... (process_stratum_target::thread_handle): ... this. (process_target::supports_software_single_step): Rename as ... (process_stratum_target::supports_software_single_step): ... this. (process_target::supports_catch_syscall): Rename as ... (process_stratum_target::supports_catch_syscall): ... this. (process_target::get_ipa_tdesc_idx): Rename as ... (process_stratum_target::get_ipa_tdesc_idx): ... this.
676 lines
22 KiB
C++
676 lines
22 KiB
C++
/* Internal interfaces for the GNU/Linux specific target code for gdbserver.
|
|
Copyright (C) 2002-2020 Free Software Foundation, Inc.
|
|
|
|
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 GDBSERVER_LINUX_LOW_H
|
|
#define GDBSERVER_LINUX_LOW_H
|
|
|
|
#include "nat/linux-nat.h"
|
|
#include "nat/gdb_thread_db.h"
|
|
#include <signal.h>
|
|
|
|
#include "gdbthread.h"
|
|
#include "gdb_proc_service.h"
|
|
|
|
/* Included for ptrace type definitions. */
|
|
#include "nat/linux-ptrace.h"
|
|
#include "target/waitstatus.h" /* For enum target_stop_reason. */
|
|
#include "tracepoint.h"
|
|
|
|
#define PTRACE_XFER_TYPE long
|
|
|
|
#ifdef HAVE_LINUX_REGSETS
|
|
typedef void (*regset_fill_func) (struct regcache *, void *);
|
|
typedef void (*regset_store_func) (struct regcache *, const void *);
|
|
enum regset_type {
|
|
GENERAL_REGS,
|
|
FP_REGS,
|
|
EXTENDED_REGS,
|
|
OPTIONAL_REGS, /* Do not error if the regset cannot be accessed. */
|
|
};
|
|
|
|
/* The arch's regsets array initializer must be terminated with a NULL
|
|
regset. */
|
|
#define NULL_REGSET \
|
|
{ 0, 0, 0, -1, (enum regset_type) -1, NULL, NULL }
|
|
|
|
struct regset_info
|
|
{
|
|
int get_request, set_request;
|
|
/* If NT_TYPE isn't 0, it will be passed to ptrace as the 3rd
|
|
argument and the 4th argument should be "const struct iovec *". */
|
|
int nt_type;
|
|
int size;
|
|
enum regset_type type;
|
|
regset_fill_func fill_function;
|
|
regset_store_func store_function;
|
|
};
|
|
|
|
/* Aggregation of all the supported regsets of a given
|
|
architecture/mode. */
|
|
|
|
struct regsets_info
|
|
{
|
|
/* The regsets array. */
|
|
struct regset_info *regsets;
|
|
|
|
/* The number of regsets in the REGSETS array. */
|
|
int num_regsets;
|
|
|
|
/* If we get EIO on a regset, do not try it again. Note the set of
|
|
supported regsets may depend on processor mode on biarch
|
|
machines. This is a (lazily allocated) array holding one boolean
|
|
byte (0/1) per regset, with each element corresponding to the
|
|
regset in the REGSETS array above at the same offset. */
|
|
char *disabled_regsets;
|
|
};
|
|
|
|
#endif
|
|
|
|
/* Mapping between the general-purpose registers in `struct user'
|
|
format and GDB's register array layout. */
|
|
|
|
struct usrregs_info
|
|
{
|
|
/* The number of registers accessible. */
|
|
int num_regs;
|
|
|
|
/* The registers map. */
|
|
int *regmap;
|
|
};
|
|
|
|
/* All info needed to access an architecture/mode's registers. */
|
|
|
|
struct regs_info
|
|
{
|
|
/* Regset support bitmap: 1 for registers that are transferred as a part
|
|
of a regset, 0 for ones that need to be handled individually. This
|
|
can be NULL if all registers are transferred with regsets or regsets
|
|
are not supported. */
|
|
unsigned char *regset_bitmap;
|
|
|
|
/* Info used when accessing registers with PTRACE_PEEKUSER /
|
|
PTRACE_POKEUSER. This can be NULL if all registers are
|
|
transferred with regsets .*/
|
|
struct usrregs_info *usrregs;
|
|
|
|
#ifdef HAVE_LINUX_REGSETS
|
|
/* Info used when accessing registers with regsets. */
|
|
struct regsets_info *regsets_info;
|
|
#endif
|
|
};
|
|
|
|
struct process_info_private
|
|
{
|
|
/* Arch-specific additions. */
|
|
struct arch_process_info *arch_private;
|
|
|
|
/* libthread_db-specific additions. Not NULL if this process has loaded
|
|
thread_db, and it is active. */
|
|
struct thread_db *thread_db;
|
|
|
|
/* &_r_debug. 0 if not yet determined. -1 if no PT_DYNAMIC in Phdrs. */
|
|
CORE_ADDR r_debug;
|
|
};
|
|
|
|
struct lwp_info;
|
|
|
|
struct linux_target_ops
|
|
{
|
|
/* Architecture-specific setup. */
|
|
void (*arch_setup) (void);
|
|
|
|
const struct regs_info *(*regs_info) (void);
|
|
int (*cannot_fetch_register) (int);
|
|
|
|
/* Returns 0 if we can store the register, 1 if we can not
|
|
store the register, and 2 if failure to store the register
|
|
is acceptable. */
|
|
int (*cannot_store_register) (int);
|
|
|
|
/* Hook to fetch a register in some non-standard way. Used for
|
|
example by backends that have read-only registers with hardcoded
|
|
values (e.g., IA64's gr0/fr0/fr1). Returns true if register
|
|
REGNO was supplied, false if not, and we should fallback to the
|
|
standard ptrace methods. */
|
|
int (*fetch_register) (struct regcache *regcache, int regno);
|
|
|
|
CORE_ADDR (*get_pc) (struct regcache *regcache);
|
|
void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc);
|
|
|
|
/* See target.h for details. */
|
|
int (*breakpoint_kind_from_pc) (CORE_ADDR *pcptr);
|
|
|
|
/* See target.h for details. */
|
|
const gdb_byte *(*sw_breakpoint_from_kind) (int kind, int *size);
|
|
|
|
/* Find the next possible PCs after the current instruction executes. */
|
|
std::vector<CORE_ADDR> (*get_next_pcs) (struct regcache *regcache);
|
|
|
|
int decr_pc_after_break;
|
|
int (*breakpoint_at) (CORE_ADDR pc);
|
|
|
|
/* Breakpoint and watchpoint related functions. See target.h for
|
|
comments. */
|
|
int (*supports_z_point_type) (char z_type);
|
|
int (*insert_point) (enum raw_bkpt_type type, CORE_ADDR addr,
|
|
int size, struct raw_breakpoint *bp);
|
|
int (*remove_point) (enum raw_bkpt_type type, CORE_ADDR addr,
|
|
int size, struct raw_breakpoint *bp);
|
|
|
|
int (*stopped_by_watchpoint) (void);
|
|
CORE_ADDR (*stopped_data_address) (void);
|
|
|
|
/* Hooks to reformat register data for PEEKUSR/POKEUSR (in particular
|
|
for registers smaller than an xfer unit). */
|
|
void (*collect_ptrace_register) (struct regcache *regcache,
|
|
int regno, char *buf);
|
|
void (*supply_ptrace_register) (struct regcache *regcache,
|
|
int regno, const char *buf);
|
|
|
|
/* Hook to convert from target format to ptrace format and back.
|
|
Returns true if any conversion was done; false otherwise.
|
|
If DIRECTION is 1, then copy from INF to NATIVE.
|
|
If DIRECTION is 0, copy from NATIVE to INF. */
|
|
int (*siginfo_fixup) (siginfo_t *native, gdb_byte *inf, int direction);
|
|
|
|
/* Hook to call when a new process is created or attached to.
|
|
If extra per-process architecture-specific data is needed,
|
|
allocate it here. */
|
|
struct arch_process_info * (*new_process) (void);
|
|
|
|
/* Hook to call when a process is being deleted. If extra per-process
|
|
architecture-specific data is needed, delete it here. */
|
|
void (*delete_process) (struct arch_process_info *info);
|
|
|
|
/* Hook to call when a new thread is detected.
|
|
If extra per-thread architecture-specific data is needed,
|
|
allocate it here. */
|
|
void (*new_thread) (struct lwp_info *);
|
|
|
|
/* Hook to call when a thread is being deleted. If extra per-thread
|
|
architecture-specific data is needed, delete it here. */
|
|
void (*delete_thread) (struct arch_lwp_info *);
|
|
|
|
/* Hook to call, if any, when a new fork is attached. */
|
|
void (*new_fork) (struct process_info *parent, struct process_info *child);
|
|
|
|
/* Hook to call prior to resuming a thread. */
|
|
void (*prepare_to_resume) (struct lwp_info *);
|
|
|
|
/* Hook to support target specific qSupported. */
|
|
void (*process_qsupported) (char **, int count);
|
|
|
|
/* Returns true if the low target supports tracepoints. */
|
|
int (*supports_tracepoints) (void);
|
|
|
|
/* Fill ADDRP with the thread area address of LWPID. Returns 0 on
|
|
success, -1 on failure. */
|
|
int (*get_thread_area) (int lwpid, CORE_ADDR *addrp);
|
|
|
|
/* Install a fast tracepoint jump pad. See target.h for
|
|
comments. */
|
|
int (*install_fast_tracepoint_jump_pad) (CORE_ADDR tpoint, CORE_ADDR tpaddr,
|
|
CORE_ADDR collector,
|
|
CORE_ADDR lockaddr,
|
|
ULONGEST orig_size,
|
|
CORE_ADDR *jump_entry,
|
|
CORE_ADDR *trampoline,
|
|
ULONGEST *trampoline_size,
|
|
unsigned char *jjump_pad_insn,
|
|
ULONGEST *jjump_pad_insn_size,
|
|
CORE_ADDR *adjusted_insn_addr,
|
|
CORE_ADDR *adjusted_insn_addr_end,
|
|
char *err);
|
|
|
|
/* Return the bytecode operations vector for the current inferior.
|
|
Returns NULL if bytecode compilation is not supported. */
|
|
struct emit_ops *(*emit_ops) (void);
|
|
|
|
/* Return the minimum length of an instruction that can be safely overwritten
|
|
for use as a fast tracepoint. */
|
|
int (*get_min_fast_tracepoint_insn_len) (void);
|
|
|
|
/* Returns true if the low target supports range stepping. */
|
|
int (*supports_range_stepping) (void);
|
|
|
|
/* See target.h. */
|
|
int (*breakpoint_kind_from_current_state) (CORE_ADDR *pcptr);
|
|
|
|
/* See target.h. */
|
|
int (*supports_hardware_single_step) (void);
|
|
|
|
/* Fill *SYSNO with the syscall nr trapped. Only to be called when
|
|
inferior is stopped due to SYSCALL_SIGTRAP. */
|
|
void (*get_syscall_trapinfo) (struct regcache *regcache, int *sysno);
|
|
|
|
/* See target.h. */
|
|
int (*get_ipa_tdesc_idx) (void);
|
|
};
|
|
|
|
extern struct linux_target_ops the_low_target;
|
|
|
|
/* Target ops definitions for a Linux target. */
|
|
|
|
class linux_process_target : public process_stratum_target
|
|
{
|
|
public:
|
|
|
|
int create_inferior (const char *program,
|
|
const std::vector<char *> &program_args) override;
|
|
|
|
void post_create_inferior () override;
|
|
|
|
int attach (unsigned long pid) override;
|
|
|
|
int kill (process_info *proc) override;
|
|
|
|
int detach (process_info *proc) override;
|
|
|
|
void mourn (process_info *proc) override;
|
|
|
|
void join (int pid) override;
|
|
|
|
bool thread_alive (ptid_t pid) override;
|
|
|
|
void resume (thread_resume *resume_info, size_t n) override;
|
|
|
|
ptid_t wait (ptid_t ptid, target_waitstatus *status,
|
|
int options) override;
|
|
|
|
void fetch_registers (regcache *regcache, int regno) override;
|
|
|
|
void store_registers (regcache *regcache, int regno) override;
|
|
|
|
int prepare_to_access_memory () override;
|
|
|
|
void done_accessing_memory () override;
|
|
|
|
int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
|
|
int len) override;
|
|
|
|
int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
|
|
int len) override;
|
|
|
|
void look_up_symbols () override;
|
|
|
|
void request_interrupt () override;
|
|
|
|
bool supports_read_auxv () override;
|
|
|
|
int read_auxv (CORE_ADDR offset, unsigned char *myaddr,
|
|
unsigned int len) override;
|
|
|
|
bool supports_z_point_type (char z_type) override;
|
|
|
|
int insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
|
|
int size, raw_breakpoint *bp) override;
|
|
|
|
int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
|
|
int size, raw_breakpoint *bp) override;
|
|
|
|
bool stopped_by_sw_breakpoint () override;
|
|
|
|
bool supports_stopped_by_sw_breakpoint () override;
|
|
|
|
bool stopped_by_hw_breakpoint () override;
|
|
|
|
bool supports_stopped_by_hw_breakpoint () override;
|
|
|
|
bool supports_hardware_single_step () override;
|
|
|
|
bool stopped_by_watchpoint () override;
|
|
|
|
CORE_ADDR stopped_data_address () override;
|
|
|
|
bool supports_read_offsets () override;
|
|
|
|
int read_offsets (CORE_ADDR *text, CORE_ADDR *data) override;
|
|
|
|
bool supports_get_tls_address () override;
|
|
|
|
int get_tls_address (thread_info *thread, CORE_ADDR offset,
|
|
CORE_ADDR load_module, CORE_ADDR *address) override;
|
|
|
|
bool supports_qxfer_osdata () override;
|
|
|
|
int qxfer_osdata (const char *annex, unsigned char *readbuf,
|
|
unsigned const char *writebuf,
|
|
CORE_ADDR offset, int len) override;
|
|
|
|
bool supports_qxfer_siginfo () override;
|
|
|
|
int qxfer_siginfo (const char *annex, unsigned char *readbuf,
|
|
unsigned const char *writebuf,
|
|
CORE_ADDR offset, int len) override;
|
|
|
|
bool supports_non_stop () override;
|
|
|
|
bool async (bool enable) override;
|
|
|
|
int start_non_stop (bool enable) override;
|
|
|
|
bool supports_multi_process () override;
|
|
|
|
bool supports_fork_events () override;
|
|
|
|
bool supports_vfork_events () override;
|
|
|
|
bool supports_exec_events () override;
|
|
|
|
void handle_new_gdb_connection () override;
|
|
|
|
int handle_monitor_command (char *mon) override;
|
|
|
|
int core_of_thread (ptid_t ptid) override;
|
|
|
|
#if defined PT_GETDSBT || defined PTRACE_GETFDPIC
|
|
bool supports_read_loadmap () override;
|
|
|
|
int read_loadmap (const char *annex, CORE_ADDR offset,
|
|
unsigned char *myaddr, unsigned int len) override;
|
|
#endif
|
|
|
|
void process_qsupported (char **features, int count) override;
|
|
|
|
bool supports_tracepoints () override;
|
|
|
|
CORE_ADDR read_pc (regcache *regcache) override;
|
|
|
|
void write_pc (regcache *regcache, CORE_ADDR pc) override;
|
|
|
|
bool supports_thread_stopped () override;
|
|
|
|
bool thread_stopped (thread_info *thread) override;
|
|
|
|
void pause_all (bool freeze) override;
|
|
|
|
void unpause_all (bool unfreeze) override;
|
|
|
|
void stabilize_threads () override;
|
|
|
|
bool supports_fast_tracepoints () override;
|
|
|
|
int install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
|
|
CORE_ADDR tpaddr,
|
|
CORE_ADDR collector,
|
|
CORE_ADDR lockaddr,
|
|
ULONGEST orig_size,
|
|
CORE_ADDR *jump_entry,
|
|
CORE_ADDR *trampoline,
|
|
ULONGEST *trampoline_size,
|
|
unsigned char *jjump_pad_insn,
|
|
ULONGEST *jjump_pad_insn_size,
|
|
CORE_ADDR *adjusted_insn_addr,
|
|
CORE_ADDR *adjusted_insn_addr_end,
|
|
char *err) override;
|
|
|
|
int get_min_fast_tracepoint_insn_len () override;
|
|
|
|
struct emit_ops *emit_ops () override;
|
|
|
|
bool supports_disable_randomization () override;
|
|
|
|
bool supports_qxfer_libraries_svr4 () override;
|
|
|
|
int qxfer_libraries_svr4 (const char *annex,
|
|
unsigned char *readbuf,
|
|
unsigned const char *writebuf,
|
|
CORE_ADDR offset, int len) override;
|
|
|
|
bool supports_agent () override;
|
|
|
|
#ifdef HAVE_LINUX_BTRACE
|
|
btrace_target_info *enable_btrace (ptid_t ptid,
|
|
const btrace_config *conf) override;
|
|
|
|
int disable_btrace (btrace_target_info *tinfo) override;
|
|
|
|
int read_btrace (btrace_target_info *tinfo, buffer *buf,
|
|
enum btrace_read_type type) override;
|
|
|
|
int read_btrace_conf (const btrace_target_info *tinfo,
|
|
buffer *buf) override;
|
|
#endif
|
|
|
|
bool supports_range_stepping () override;
|
|
|
|
bool supports_pid_to_exec_file () override;
|
|
|
|
char *pid_to_exec_file (int pid) override;
|
|
|
|
bool supports_multifs () override;
|
|
|
|
int multifs_open (int pid, const char *filename, int flags,
|
|
mode_t mode) override;
|
|
|
|
int multifs_unlink (int pid, const char *filename) override;
|
|
|
|
ssize_t multifs_readlink (int pid, const char *filename, char *buf,
|
|
size_t bufsiz) override;
|
|
|
|
int breakpoint_kind_from_pc (CORE_ADDR *pcptr) override;
|
|
|
|
const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
|
|
|
|
int breakpoint_kind_from_current_state (CORE_ADDR *pcptr) override;
|
|
|
|
const char *thread_name (ptid_t thread) override;
|
|
|
|
#if USE_THREAD_DB
|
|
bool thread_handle (ptid_t ptid, gdb_byte **handle,
|
|
int *handle_len) override;
|
|
#endif
|
|
|
|
bool supports_software_single_step () override;
|
|
|
|
bool supports_catch_syscall () override;
|
|
|
|
int get_ipa_tdesc_idx () override;
|
|
};
|
|
|
|
#define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
|
|
#define get_lwp_thread(lwp) ((lwp)->thread)
|
|
|
|
/* This struct is recorded in the target_data field of struct thread_info.
|
|
|
|
On linux ``all_threads'' is keyed by the LWP ID, which we use as the
|
|
GDB protocol representation of the thread ID. Threads also have
|
|
a "process ID" (poorly named) which is (presently) the same as the
|
|
LWP ID.
|
|
|
|
There is also ``all_processes'' is keyed by the "overall process ID",
|
|
which GNU/Linux calls tgid, "thread group ID". */
|
|
|
|
struct lwp_info
|
|
{
|
|
/* Backlink to the parent object. */
|
|
struct thread_info *thread;
|
|
|
|
/* If this flag is set, the next SIGSTOP will be ignored (the
|
|
process will be immediately resumed). This means that either we
|
|
sent the SIGSTOP to it ourselves and got some other pending event
|
|
(so the SIGSTOP is still pending), or that we stopped the
|
|
inferior implicitly via PTRACE_ATTACH and have not waited for it
|
|
yet. */
|
|
int stop_expected;
|
|
|
|
/* When this is true, we shall not try to resume this thread, even
|
|
if last_resume_kind isn't resume_stop. */
|
|
int suspended;
|
|
|
|
/* If this flag is set, the lwp is known to be stopped right now (stop
|
|
event already received in a wait()). */
|
|
int stopped;
|
|
|
|
/* Signal whether we are in a SYSCALL_ENTRY or
|
|
in a SYSCALL_RETURN event.
|
|
Values:
|
|
- TARGET_WAITKIND_SYSCALL_ENTRY
|
|
- TARGET_WAITKIND_SYSCALL_RETURN */
|
|
enum target_waitkind syscall_state;
|
|
|
|
/* When stopped is set, the last wait status recorded for this lwp. */
|
|
int last_status;
|
|
|
|
/* If WAITSTATUS->KIND != TARGET_WAITKIND_IGNORE, the waitstatus for
|
|
this LWP's last event, to pass to GDB without any further
|
|
processing. This is used to store extended ptrace event
|
|
information or exit status until it can be reported to GDB. */
|
|
struct target_waitstatus waitstatus;
|
|
|
|
/* A pointer to the fork child/parent relative. Valid only while
|
|
the parent fork event is not reported to higher layers. Used to
|
|
avoid wildcard vCont actions resuming a fork child before GDB is
|
|
notified about the parent's fork event. */
|
|
struct lwp_info *fork_relative;
|
|
|
|
/* When stopped is set, this is where the lwp last stopped, with
|
|
decr_pc_after_break already accounted for. If the LWP is
|
|
running, this is the address at which the lwp was resumed. */
|
|
CORE_ADDR stop_pc;
|
|
|
|
/* If this flag is set, STATUS_PENDING is a waitstatus that has not yet
|
|
been reported. */
|
|
int status_pending_p;
|
|
int status_pending;
|
|
|
|
/* The reason the LWP last stopped, if we need to track it
|
|
(breakpoint, watchpoint, etc.) */
|
|
enum target_stop_reason stop_reason;
|
|
|
|
/* On architectures where it is possible to know the data address of
|
|
a triggered watchpoint, STOPPED_DATA_ADDRESS is non-zero, and
|
|
contains such data address. Only valid if STOPPED_BY_WATCHPOINT
|
|
is true. */
|
|
CORE_ADDR stopped_data_address;
|
|
|
|
/* If this is non-zero, it is a breakpoint to be reinserted at our next
|
|
stop (SIGTRAP stops only). */
|
|
CORE_ADDR bp_reinsert;
|
|
|
|
/* If this flag is set, the last continue operation at the ptrace
|
|
level on this process was a single-step. */
|
|
int stepping;
|
|
|
|
/* Range to single step within. This is a copy of the step range
|
|
passed along the last resume request. See 'struct
|
|
thread_resume'. */
|
|
CORE_ADDR step_range_start; /* Inclusive */
|
|
CORE_ADDR step_range_end; /* Exclusive */
|
|
|
|
/* If this flag is set, we need to set the event request flags the
|
|
next time we see this LWP stop. */
|
|
int must_set_ptrace_flags;
|
|
|
|
/* If this is non-zero, it points to a chain of signals which need to
|
|
be delivered to this process. */
|
|
struct pending_signals *pending_signals;
|
|
|
|
/* A link used when resuming. It is initialized from the resume request,
|
|
and then processed and cleared in linux_resume_one_lwp. */
|
|
struct thread_resume *resume;
|
|
|
|
/* Information bout this lwp's fast tracepoint collection status (is it
|
|
currently stopped in the jump pad, and if so, before or at/after the
|
|
relocated instruction). Normally, we won't care about this, but we will
|
|
if a signal arrives to this lwp while it is collecting. */
|
|
fast_tpoint_collect_result collecting_fast_tracepoint;
|
|
|
|
/* If this is non-zero, it points to a chain of signals which need
|
|
to be reported to GDB. These were deferred because the thread
|
|
was doing a fast tracepoint collect when they arrived. */
|
|
struct pending_signals *pending_signals_to_report;
|
|
|
|
/* When collecting_fast_tracepoint is first found to be 1, we insert
|
|
a exit-jump-pad-quickly breakpoint. This is it. */
|
|
struct breakpoint *exit_jump_pad_bkpt;
|
|
|
|
#ifdef USE_THREAD_DB
|
|
int thread_known;
|
|
/* The thread handle, used for e.g. TLS access. Only valid if
|
|
THREAD_KNOWN is set. */
|
|
td_thrhandle_t th;
|
|
|
|
/* The pthread_t handle. */
|
|
thread_t thread_handle;
|
|
#endif
|
|
|
|
/* Arch-specific additions. */
|
|
struct arch_lwp_info *arch_private;
|
|
};
|
|
|
|
int linux_pid_exe_is_elf_64_file (int pid, unsigned int *machine);
|
|
|
|
/* Attach to PTID. Returns 0 on success, non-zero otherwise (an
|
|
errno). */
|
|
int linux_attach_lwp (ptid_t ptid);
|
|
|
|
struct lwp_info *find_lwp_pid (ptid_t ptid);
|
|
/* For linux_stop_lwp see nat/linux-nat.h. */
|
|
|
|
#ifdef HAVE_LINUX_REGSETS
|
|
void initialize_regsets_info (struct regsets_info *regsets_info);
|
|
#endif
|
|
|
|
void initialize_low_arch (void);
|
|
|
|
void linux_set_pc_32bit (struct regcache *regcache, CORE_ADDR pc);
|
|
CORE_ADDR linux_get_pc_32bit (struct regcache *regcache);
|
|
|
|
void linux_set_pc_64bit (struct regcache *regcache, CORE_ADDR pc);
|
|
CORE_ADDR linux_get_pc_64bit (struct regcache *regcache);
|
|
|
|
/* From thread-db.c */
|
|
int thread_db_init (void);
|
|
void thread_db_detach (struct process_info *);
|
|
void thread_db_mourn (struct process_info *);
|
|
int thread_db_handle_monitor_command (char *);
|
|
int thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
|
|
CORE_ADDR load_module, CORE_ADDR *address);
|
|
int thread_db_look_up_one_symbol (const char *name, CORE_ADDR *addrp);
|
|
|
|
/* Called from linux-low.c when a clone event is detected. Upon entry,
|
|
both the clone and the parent should be stopped. This function does
|
|
whatever is required have the clone under thread_db's control. */
|
|
|
|
void thread_db_notice_clone (struct thread_info *parent_thr, ptid_t child_ptid);
|
|
|
|
bool thread_db_thread_handle (ptid_t ptid, gdb_byte **handle, int *handle_len);
|
|
|
|
extern int have_ptrace_getregset;
|
|
|
|
/* Search for the value with type MATCH in the auxv vector with
|
|
entries of length WORDSIZE bytes. If found, store the value in
|
|
*VALP and return 1. If not found or if there is an error, return
|
|
0. */
|
|
|
|
int linux_get_auxv (int wordsize, CORE_ADDR match,
|
|
CORE_ADDR *valp);
|
|
|
|
/* Fetch the AT_HWCAP entry from the auxv vector, where entries are length
|
|
WORDSIZE. If no entry was found, return zero. */
|
|
|
|
CORE_ADDR linux_get_hwcap (int wordsize);
|
|
|
|
/* Fetch the AT_HWCAP2 entry from the auxv vector, where entries are length
|
|
WORDSIZE. If no entry was found, return zero. */
|
|
|
|
CORE_ADDR linux_get_hwcap2 (int wordsize);
|
|
|
|
#endif /* GDBSERVER_LINUX_LOW_H */
|