18dffb485Schristos /* Target operations for the remote server for GDB. 2*f1c2b495Schristos Copyright (C) 2002-2024 Free Software Foundation, Inc. 38dffb485Schristos 48dffb485Schristos Contributed by MontaVista Software. 58dffb485Schristos 68dffb485Schristos This file is part of GDB. 78dffb485Schristos 88dffb485Schristos This program is free software; you can redistribute it and/or modify 98dffb485Schristos it under the terms of the GNU General Public License as published by 108dffb485Schristos the Free Software Foundation; either version 3 of the License, or 118dffb485Schristos (at your option) any later version. 128dffb485Schristos 138dffb485Schristos This program is distributed in the hope that it will be useful, 148dffb485Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 158dffb485Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 168dffb485Schristos GNU General Public License for more details. 178dffb485Schristos 188dffb485Schristos You should have received a copy of the GNU General Public License 198dffb485Schristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 208dffb485Schristos 218dffb485Schristos #ifndef GDBSERVER_TARGET_H 228dffb485Schristos #define GDBSERVER_TARGET_H 238dffb485Schristos 24*f1c2b495Schristos #include <sys/types.h> 258dffb485Schristos #include "target/target.h" 268dffb485Schristos #include "target/resume.h" 278dffb485Schristos #include "target/wait.h" 288dffb485Schristos #include "target/waitstatus.h" 298dffb485Schristos #include "mem-break.h" 308dffb485Schristos #include "gdbsupport/array-view.h" 318dffb485Schristos #include "gdbsupport/btrace-common.h" 328dffb485Schristos #include <vector> 334b169a6bSchristos #include "gdbsupport/byte-vector.h" 348dffb485Schristos 358dffb485Schristos struct emit_ops; 368dffb485Schristos struct process_info; 378dffb485Schristos 388dffb485Schristos /* This structure describes how to resume a particular thread (or all 398dffb485Schristos threads) based on the client's request. If thread is -1, then this 408dffb485Schristos entry applies to all threads. These are passed around as an 418dffb485Schristos array. */ 428dffb485Schristos 438dffb485Schristos struct thread_resume 448dffb485Schristos { 458dffb485Schristos ptid_t thread; 468dffb485Schristos 478dffb485Schristos /* How to "resume". */ 488dffb485Schristos enum resume_kind kind; 498dffb485Schristos 508dffb485Schristos /* If non-zero, send this signal when we resume, or to stop the 518dffb485Schristos thread. If stopping a thread, and this is 0, the target should 528dffb485Schristos stop the thread however it best decides to (e.g., SIGSTOP on 538dffb485Schristos linux; SuspendThread on win32). This is a host signal value (not 548dffb485Schristos enum gdb_signal). */ 558dffb485Schristos int sig; 568dffb485Schristos 578dffb485Schristos /* Range to single step within. Valid only iff KIND is resume_step. 588dffb485Schristos 598dffb485Schristos Single-step once, and then continuing stepping as long as the 608dffb485Schristos thread stops in this range. (If the range is empty 618dffb485Schristos [STEP_RANGE_START == STEP_RANGE_END], then this is a single-step 628dffb485Schristos request.) */ 638dffb485Schristos CORE_ADDR step_range_start; /* Inclusive */ 648dffb485Schristos CORE_ADDR step_range_end; /* Exclusive */ 658dffb485Schristos }; 668dffb485Schristos 678dffb485Schristos /* GDBserver doesn't have a concept of strata like GDB, but we call 688dffb485Schristos its target vector "process_stratum" anyway for the benefit of 698dffb485Schristos shared code. */ 708dffb485Schristos 718dffb485Schristos class process_stratum_target 728dffb485Schristos { 738dffb485Schristos public: 748dffb485Schristos 758dffb485Schristos virtual ~process_stratum_target () = default; 768dffb485Schristos 778dffb485Schristos /* Start a new process. 788dffb485Schristos 798dffb485Schristos PROGRAM is a path to the program to execute. 808dffb485Schristos PROGRAM_ARGS is a standard NULL-terminated array of arguments, 818dffb485Schristos to be passed to the inferior as ``argv'' (along with PROGRAM). 828dffb485Schristos 838dffb485Schristos Returns the new PID on success, -1 on failure. Registers the new 848dffb485Schristos process with the process list. */ 858dffb485Schristos virtual int create_inferior (const char *program, 868dffb485Schristos const std::vector<char *> &program_args) = 0; 878dffb485Schristos 888dffb485Schristos /* Do additional setup after a new process is created, including 898dffb485Schristos exec-wrapper completion. */ 908dffb485Schristos virtual void post_create_inferior (); 918dffb485Schristos 928dffb485Schristos /* Attach to a running process. 938dffb485Schristos 948dffb485Schristos PID is the process ID to attach to, specified by the user 958dffb485Schristos or a higher layer. 968dffb485Schristos 978dffb485Schristos Returns -1 if attaching is unsupported, 0 on success, and calls 988dffb485Schristos error() otherwise. */ 998dffb485Schristos virtual int attach (unsigned long pid) = 0; 1008dffb485Schristos 1018dffb485Schristos /* Kill process PROC. Return -1 on failure, and 0 on success. */ 1028dffb485Schristos virtual int kill (process_info *proc) = 0; 1038dffb485Schristos 1048dffb485Schristos /* Detach from process PROC. Return -1 on failure, and 0 on 1058dffb485Schristos success. */ 1068dffb485Schristos virtual int detach (process_info *proc) = 0; 1078dffb485Schristos 1088dffb485Schristos /* The inferior process has died. Do what is right. */ 1098dffb485Schristos virtual void mourn (process_info *proc) = 0; 1108dffb485Schristos 1118dffb485Schristos /* Wait for process PID to exit. */ 1128dffb485Schristos virtual void join (int pid) = 0; 1138dffb485Schristos 1148dffb485Schristos /* Return true iff the thread with process ID PID is alive. */ 1158dffb485Schristos virtual bool thread_alive (ptid_t pid) = 0; 1168dffb485Schristos 1178dffb485Schristos /* Resume the inferior process. */ 1188dffb485Schristos virtual void resume (thread_resume *resume_info, size_t n) = 0; 1198dffb485Schristos 1208dffb485Schristos /* Wait for the inferior process or thread to change state. Store 1218dffb485Schristos status through argument pointer STATUS. 1228dffb485Schristos 1238dffb485Schristos PTID = -1 to wait for any pid to do something, PTID(pid,0,0) to 1248dffb485Schristos wait for any thread of process pid to do something. Return ptid 1258dffb485Schristos of child, or -1 in case of error; store status through argument 1268dffb485Schristos pointer STATUS. OPTIONS is a bit set of options defined as 1278dffb485Schristos TARGET_W* above. If options contains TARGET_WNOHANG and there's 1288dffb485Schristos no child stop to report, return is 1298dffb485Schristos null_ptid/TARGET_WAITKIND_IGNORE. */ 1308dffb485Schristos virtual ptid_t wait (ptid_t ptid, target_waitstatus *status, 1314b169a6bSchristos target_wait_flags options) = 0; 1328dffb485Schristos 1338dffb485Schristos /* Fetch registers from the inferior process. 1348dffb485Schristos 1358dffb485Schristos If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */ 1368dffb485Schristos virtual void fetch_registers (regcache *regcache, int regno) = 0; 1378dffb485Schristos 1388dffb485Schristos /* Store registers to the inferior process. 1398dffb485Schristos 1408dffb485Schristos If REGNO is -1, store all registers; otherwise, store at least REGNO. */ 1418dffb485Schristos virtual void store_registers (regcache *regcache, int regno) = 0; 1428dffb485Schristos 1438dffb485Schristos /* Read memory from the inferior process. This should generally be 1448dffb485Schristos called through read_inferior_memory, which handles breakpoint shadowing. 1458dffb485Schristos 1468dffb485Schristos Read LEN bytes at MEMADDR into a buffer at MYADDR. 1478dffb485Schristos 1488dffb485Schristos Returns 0 on success and errno on failure. */ 1498dffb485Schristos virtual int read_memory (CORE_ADDR memaddr, unsigned char *myaddr, 1508dffb485Schristos int len) = 0; 1518dffb485Schristos 1528dffb485Schristos /* Write memory to the inferior process. This should generally be 1538dffb485Schristos called through target_write_memory, which handles breakpoint shadowing. 1548dffb485Schristos 1558dffb485Schristos Write LEN bytes from the buffer at MYADDR to MEMADDR. 1568dffb485Schristos 1578dffb485Schristos Returns 0 on success and errno on failure. */ 1588dffb485Schristos virtual int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, 1598dffb485Schristos int len) = 0; 1608dffb485Schristos 1618dffb485Schristos /* Query GDB for the values of any symbols we're interested in. 1628dffb485Schristos This function is called whenever we receive a "qSymbols::" 1638dffb485Schristos query, which corresponds to every time more symbols (might) 1648dffb485Schristos become available. */ 1658dffb485Schristos virtual void look_up_symbols (); 1668dffb485Schristos 1678dffb485Schristos /* Send an interrupt request to the inferior process, 1688dffb485Schristos however is appropriate. */ 1698dffb485Schristos virtual void request_interrupt () = 0; 1708dffb485Schristos 1718dffb485Schristos /* Return true if the read_auxv target op is supported. */ 1728dffb485Schristos virtual bool supports_read_auxv (); 1738dffb485Schristos 174*f1c2b495Schristos /* Read auxiliary vector data from the process with pid PID. 1758dffb485Schristos 1768dffb485Schristos Read LEN bytes at OFFSET into a buffer at MYADDR. */ 177*f1c2b495Schristos virtual int read_auxv (int pid, CORE_ADDR offset, unsigned char *myaddr, 1788dffb485Schristos unsigned int len); 1798dffb485Schristos 1808dffb485Schristos /* Returns true if GDB Z breakpoint type TYPE is supported, false 1818dffb485Schristos otherwise. The type is coded as follows: 1828dffb485Schristos '0' - software-breakpoint 1838dffb485Schristos '1' - hardware-breakpoint 1848dffb485Schristos '2' - write watchpoint 1858dffb485Schristos '3' - read watchpoint 1868dffb485Schristos '4' - access watchpoint 1878dffb485Schristos */ 1888dffb485Schristos virtual bool supports_z_point_type (char z_type); 1898dffb485Schristos 1908dffb485Schristos /* Insert and remove a break or watchpoint. 1918dffb485Schristos Returns 0 on success, -1 on failure and 1 on unsupported. */ 1928dffb485Schristos virtual int insert_point (enum raw_bkpt_type type, CORE_ADDR addr, 1938dffb485Schristos int size, raw_breakpoint *bp); 1948dffb485Schristos 1958dffb485Schristos virtual int remove_point (enum raw_bkpt_type type, CORE_ADDR addr, 1968dffb485Schristos int size, raw_breakpoint *bp); 1978dffb485Schristos 1988dffb485Schristos /* Returns true if the target stopped because it executed a software 1998dffb485Schristos breakpoint instruction, false otherwise. */ 2008dffb485Schristos virtual bool stopped_by_sw_breakpoint (); 2018dffb485Schristos 2028dffb485Schristos /* Returns true if the target knows whether a trap was caused by a 2038dffb485Schristos SW breakpoint triggering. */ 2048dffb485Schristos virtual bool supports_stopped_by_sw_breakpoint (); 2058dffb485Schristos 2068dffb485Schristos /* Returns true if the target stopped for a hardware breakpoint. */ 2078dffb485Schristos virtual bool stopped_by_hw_breakpoint (); 2088dffb485Schristos 2098dffb485Schristos /* Returns true if the target knows whether a trap was caused by a 2108dffb485Schristos HW breakpoint triggering. */ 2118dffb485Schristos virtual bool supports_stopped_by_hw_breakpoint (); 2128dffb485Schristos 2138dffb485Schristos /* Returns true if the target can do hardware single step. */ 2148dffb485Schristos virtual bool supports_hardware_single_step (); 2158dffb485Schristos 2168dffb485Schristos /* Returns true if target was stopped due to a watchpoint hit, false 2178dffb485Schristos otherwise. */ 2188dffb485Schristos virtual bool stopped_by_watchpoint (); 2198dffb485Schristos 2208dffb485Schristos /* Returns the address associated with the watchpoint that hit, if any; 2218dffb485Schristos returns 0 otherwise. */ 2228dffb485Schristos virtual CORE_ADDR stopped_data_address (); 2238dffb485Schristos 2248dffb485Schristos /* Return true if the read_offsets target op is supported. */ 2258dffb485Schristos virtual bool supports_read_offsets (); 2268dffb485Schristos 2278dffb485Schristos /* Reports the text, data offsets of the executable. This is 2288dffb485Schristos needed for uclinux where the executable is relocated during load 2298dffb485Schristos time. */ 2308dffb485Schristos virtual int read_offsets (CORE_ADDR *text, CORE_ADDR *data); 2318dffb485Schristos 2328dffb485Schristos /* Return true if the get_tls_address target op is supported. */ 2338dffb485Schristos virtual bool supports_get_tls_address (); 2348dffb485Schristos 2358dffb485Schristos /* Fetch the address associated with a specific thread local storage 2368dffb485Schristos area, determined by the specified THREAD, OFFSET, and LOAD_MODULE. 2378dffb485Schristos Stores it in *ADDRESS and returns zero on success; otherwise returns 2388dffb485Schristos an error code. A return value of -1 means this system does not 2398dffb485Schristos support the operation. */ 2408dffb485Schristos virtual int get_tls_address (thread_info *thread, CORE_ADDR offset, 2418dffb485Schristos CORE_ADDR load_module, CORE_ADDR *address); 2428dffb485Schristos 2438dffb485Schristos /* Return true if the qxfer_osdata target op is supported. */ 2448dffb485Schristos virtual bool supports_qxfer_osdata (); 2458dffb485Schristos 2468dffb485Schristos /* Read/Write OS data using qXfer packets. */ 2478dffb485Schristos virtual int qxfer_osdata (const char *annex, unsigned char *readbuf, 2488dffb485Schristos unsigned const char *writebuf, 2498dffb485Schristos CORE_ADDR offset, int len); 2508dffb485Schristos 2518dffb485Schristos /* Return true if the qxfer_siginfo target op is supported. */ 2528dffb485Schristos virtual bool supports_qxfer_siginfo (); 2538dffb485Schristos 2548dffb485Schristos /* Read/Write extra signal info. */ 2558dffb485Schristos virtual int qxfer_siginfo (const char *annex, unsigned char *readbuf, 2568dffb485Schristos unsigned const char *writebuf, 2578dffb485Schristos CORE_ADDR offset, int len); 2588dffb485Schristos 2598dffb485Schristos /* Return true if non-stop mode is supported. */ 2608dffb485Schristos virtual bool supports_non_stop (); 2618dffb485Schristos 2628dffb485Schristos /* Enables async target events. Returns the previous enable 2638dffb485Schristos state. */ 2648dffb485Schristos virtual bool async (bool enable); 2658dffb485Schristos 2668dffb485Schristos /* Switch to non-stop (ENABLE == true) or all-stop (ENABLE == false) 2678dffb485Schristos mode. Return 0 on success, -1 otherwise. */ 2688dffb485Schristos virtual int start_non_stop (bool enable); 2698dffb485Schristos 2708dffb485Schristos /* Returns true if the target supports multi-process debugging. */ 2718dffb485Schristos virtual bool supports_multi_process (); 2728dffb485Schristos 2738dffb485Schristos /* Returns true if fork events are supported. */ 2748dffb485Schristos virtual bool supports_fork_events (); 2758dffb485Schristos 2768dffb485Schristos /* Returns true if vfork events are supported. */ 2778dffb485Schristos virtual bool supports_vfork_events (); 2788dffb485Schristos 279*f1c2b495Schristos /* Returns the set of supported thread options. */ 280*f1c2b495Schristos virtual gdb_thread_options supported_thread_options (); 281*f1c2b495Schristos 2828dffb485Schristos /* Returns true if exec events are supported. */ 2838dffb485Schristos virtual bool supports_exec_events (); 2848dffb485Schristos 2858dffb485Schristos /* Allows target to re-initialize connection-specific settings. */ 2868dffb485Schristos virtual void handle_new_gdb_connection (); 2878dffb485Schristos 2888dffb485Schristos /* The target-specific routine to process monitor command. 2898dffb485Schristos Returns 1 if handled, or 0 to perform default processing. */ 2908dffb485Schristos virtual int handle_monitor_command (char *mon); 2918dffb485Schristos 2928dffb485Schristos /* Returns the core given a thread, or -1 if not known. */ 2938dffb485Schristos virtual int core_of_thread (ptid_t ptid); 2948dffb485Schristos 2958dffb485Schristos /* Returns true if the read_loadmap target op is supported. */ 2968dffb485Schristos virtual bool supports_read_loadmap (); 2978dffb485Schristos 2988dffb485Schristos /* Read loadmaps. Read LEN bytes at OFFSET into a buffer at MYADDR. */ 2998dffb485Schristos virtual int read_loadmap (const char *annex, CORE_ADDR offset, 3008dffb485Schristos unsigned char *myaddr, unsigned int len); 3018dffb485Schristos 3028dffb485Schristos /* Target specific qSupported support. FEATURES is an array of 3038dffb485Schristos features unsupported by the core of GDBserver. */ 3048dffb485Schristos virtual void process_qsupported 3058dffb485Schristos (gdb::array_view<const char * const> features); 3068dffb485Schristos 3078dffb485Schristos /* Return true if the target supports tracepoints, false otherwise. */ 3088dffb485Schristos virtual bool supports_tracepoints (); 3098dffb485Schristos 3108dffb485Schristos /* Read PC from REGCACHE. */ 3118dffb485Schristos virtual CORE_ADDR read_pc (regcache *regcache); 3128dffb485Schristos 3138dffb485Schristos /* Write PC to REGCACHE. */ 3148dffb485Schristos virtual void write_pc (regcache *regcache, CORE_ADDR pc); 3158dffb485Schristos 3168dffb485Schristos /* Return true if the thread_stopped op is supported. */ 3178dffb485Schristos virtual bool supports_thread_stopped (); 3188dffb485Schristos 3198dffb485Schristos /* Return true if THREAD is known to be stopped now. */ 3208dffb485Schristos virtual bool thread_stopped (thread_info *thread); 3218dffb485Schristos 322*f1c2b495Schristos /* Return true if any thread is known to be resumed. */ 323*f1c2b495Schristos virtual bool any_resumed (); 324*f1c2b495Schristos 3258dffb485Schristos /* Return true if the get_tib_address op is supported. */ 3268dffb485Schristos virtual bool supports_get_tib_address (); 3278dffb485Schristos 3288dffb485Schristos /* Read Thread Information Block address. */ 3298dffb485Schristos virtual int get_tib_address (ptid_t ptid, CORE_ADDR *address); 3308dffb485Schristos 3318dffb485Schristos /* Pause all threads. If FREEZE, arrange for any resume attempt to 3328dffb485Schristos be ignored until an unpause_all call unfreezes threads again. 3338dffb485Schristos There can be nested calls to pause_all, so a freeze counter 3348dffb485Schristos should be maintained. */ 3358dffb485Schristos virtual void pause_all (bool freeze); 3368dffb485Schristos 3378dffb485Schristos /* Unpause all threads. Threads that hadn't been resumed by the 3388dffb485Schristos client should be left stopped. Basically a pause/unpause call 3398dffb485Schristos pair should not end up resuming threads that were stopped before 3408dffb485Schristos the pause call. */ 3418dffb485Schristos virtual void unpause_all (bool unfreeze); 3428dffb485Schristos 3438dffb485Schristos /* Stabilize all threads. That is, force them out of jump pads. */ 3448dffb485Schristos virtual void stabilize_threads (); 3458dffb485Schristos 3468dffb485Schristos /* Return true if the install_fast_tracepoint_jump_pad op is 3478dffb485Schristos supported. */ 3488dffb485Schristos virtual bool supports_fast_tracepoints (); 3498dffb485Schristos 3508dffb485Schristos /* Install a fast tracepoint jump pad. TPOINT is the address of the 3518dffb485Schristos tracepoint internal object as used by the IPA agent. TPADDR is 3528dffb485Schristos the address of tracepoint. COLLECTOR is address of the function 3538dffb485Schristos the jump pad redirects to. LOCKADDR is the address of the jump 3548dffb485Schristos pad lock object. ORIG_SIZE is the size in bytes of the 3558dffb485Schristos instruction at TPADDR. JUMP_ENTRY points to the address of the 3568dffb485Schristos jump pad entry, and on return holds the address past the end of 3578dffb485Schristos the created jump pad. If a trampoline is created by the function, 3588dffb485Schristos then TRAMPOLINE and TRAMPOLINE_SIZE return the address and size of 3598dffb485Schristos the trampoline, else they remain unchanged. JJUMP_PAD_INSN is a 3608dffb485Schristos buffer containing a copy of the instruction at TPADDR. 3618dffb485Schristos ADJUST_INSN_ADDR and ADJUST_INSN_ADDR_END are output parameters that 3628dffb485Schristos return the address range where the instruction at TPADDR was relocated 3638dffb485Schristos to. If an error occurs, the ERR may be used to pass on an error 3648dffb485Schristos message. */ 3658dffb485Schristos virtual int install_fast_tracepoint_jump_pad 3668dffb485Schristos (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector, 3678dffb485Schristos CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry, 3688dffb485Schristos CORE_ADDR *trampoline, ULONGEST *trampoline_size, 3698dffb485Schristos unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size, 3708dffb485Schristos CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end, 3718dffb485Schristos char *err); 3728dffb485Schristos 3738dffb485Schristos /* Return the minimum length of an instruction that can be safely 3748dffb485Schristos overwritten for use as a fast tracepoint. */ 3758dffb485Schristos virtual int get_min_fast_tracepoint_insn_len (); 3768dffb485Schristos 3778dffb485Schristos /* Return the bytecode operations vector for the current inferior. 3788dffb485Schristos Returns nullptr if bytecode compilation is not supported. */ 3798dffb485Schristos virtual struct emit_ops *emit_ops (); 3808dffb485Schristos 3818dffb485Schristos /* Returns true if the target supports disabling randomization. */ 3828dffb485Schristos virtual bool supports_disable_randomization (); 3838dffb485Schristos 3848dffb485Schristos /* Return true if the qxfer_libraries_svr4 op is supported. */ 3858dffb485Schristos virtual bool supports_qxfer_libraries_svr4 (); 3868dffb485Schristos 3878dffb485Schristos /* Read solib info on SVR4 platforms. */ 3888dffb485Schristos virtual int qxfer_libraries_svr4 (const char *annex, 3898dffb485Schristos unsigned char *readbuf, 3908dffb485Schristos unsigned const char *writebuf, 3918dffb485Schristos CORE_ADDR offset, int len); 3928dffb485Schristos 3938dffb485Schristos /* Return true if target supports debugging agent. */ 3948dffb485Schristos virtual bool supports_agent (); 3958dffb485Schristos 3964b169a6bSchristos /* Return true if target supports btrace. */ 3974b169a6bSchristos virtual bool supports_btrace (); 3984b169a6bSchristos 3994b169a6bSchristos /* Enable branch tracing for TP based on CONF and allocate a branch trace 4008dffb485Schristos target information struct for reading and for disabling branch trace. */ 4014b169a6bSchristos virtual btrace_target_info *enable_btrace (thread_info *tp, 4028dffb485Schristos const btrace_config *conf); 4038dffb485Schristos 4048dffb485Schristos /* Disable branch tracing. 4058dffb485Schristos Returns zero on success, non-zero otherwise. */ 4068dffb485Schristos virtual int disable_btrace (btrace_target_info *tinfo); 4078dffb485Schristos 4088dffb485Schristos /* Read branch trace data into buffer. 4098dffb485Schristos Return 0 on success; print an error message into BUFFER and return -1, 4108dffb485Schristos otherwise. */ 411*f1c2b495Schristos virtual int read_btrace (btrace_target_info *tinfo, std::string *buf, 4128dffb485Schristos enum btrace_read_type type); 4138dffb485Schristos 4148dffb485Schristos /* Read the branch trace configuration into BUFFER. 4158dffb485Schristos Return 0 on success; print an error message into BUFFER and return -1 4168dffb485Schristos otherwise. */ 4178dffb485Schristos virtual int read_btrace_conf (const btrace_target_info *tinfo, 418*f1c2b495Schristos std::string *buf); 4198dffb485Schristos 4208dffb485Schristos /* Return true if target supports range stepping. */ 4218dffb485Schristos virtual bool supports_range_stepping (); 4228dffb485Schristos 4238dffb485Schristos /* Return true if the pid_to_exec_file op is supported. */ 4248dffb485Schristos virtual bool supports_pid_to_exec_file (); 4258dffb485Schristos 4268dffb485Schristos /* Return the full absolute name of the executable file that was 4278dffb485Schristos run to create the process PID. If the executable file cannot 4288dffb485Schristos be determined, NULL is returned. Otherwise, a pointer to a 4298dffb485Schristos character string containing the pathname is returned. This 4308dffb485Schristos string should be copied into a buffer by the client if the string 4318dffb485Schristos will not be immediately used, or if it must persist. */ 4324b169a6bSchristos virtual const char *pid_to_exec_file (int pid); 4338dffb485Schristos 4348dffb485Schristos /* Return true if any of the multifs ops is supported. */ 4358dffb485Schristos virtual bool supports_multifs (); 4368dffb485Schristos 4378dffb485Schristos /* Multiple-filesystem-aware open. Like open(2), but operating in 4388dffb485Schristos the filesystem as it appears to process PID. Systems where all 4398dffb485Schristos processes share a common filesystem should not override this. 4408dffb485Schristos The default behavior is to use open(2). */ 4418dffb485Schristos virtual int multifs_open (int pid, const char *filename, 4428dffb485Schristos int flags, mode_t mode); 4438dffb485Schristos 4448dffb485Schristos /* Multiple-filesystem-aware unlink. Like unlink(2), but operates 4458dffb485Schristos in the filesystem as it appears to process PID. Systems where 4468dffb485Schristos all processes share a common filesystem should not override this. 4478dffb485Schristos The default behavior is to use unlink(2). */ 4488dffb485Schristos virtual int multifs_unlink (int pid, const char *filename); 4498dffb485Schristos 4508dffb485Schristos /* Multiple-filesystem-aware readlink. Like readlink(2), but 4518dffb485Schristos operating in the filesystem as it appears to process PID. 4528dffb485Schristos Systems where all processes share a common filesystem should 4538dffb485Schristos not override this. The default behavior is to use readlink(2). */ 4548dffb485Schristos virtual ssize_t multifs_readlink (int pid, const char *filename, 4558dffb485Schristos char *buf, size_t bufsiz); 4568dffb485Schristos 4578dffb485Schristos /* Return the breakpoint kind for this target based on PC. The 4588dffb485Schristos PCPTR is adjusted to the real memory location in case a flag 4598dffb485Schristos (e.g., the Thumb bit on ARM) was present in the PC. */ 4608dffb485Schristos virtual int breakpoint_kind_from_pc (CORE_ADDR *pcptr); 4618dffb485Schristos 4628dffb485Schristos /* Return the software breakpoint from KIND. KIND can have target 4638dffb485Schristos specific meaning like the Z0 kind parameter. 4648dffb485Schristos SIZE is set to the software breakpoint's length in memory. */ 4658dffb485Schristos virtual const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) = 0; 4668dffb485Schristos 4678dffb485Schristos /* Return the breakpoint kind for this target based on the current 4688dffb485Schristos processor state (e.g. the current instruction mode on ARM) and the 4698dffb485Schristos PC. The PCPTR is adjusted to the real memory location in case a 4708dffb485Schristos flag (e.g., the Thumb bit on ARM) is present in the PC. */ 4718dffb485Schristos virtual int breakpoint_kind_from_current_state (CORE_ADDR *pcptr); 4728dffb485Schristos 4738dffb485Schristos /* Return the thread's name, or NULL if the target is unable to 4748dffb485Schristos determine it. The returned value must not be freed by the 4758dffb485Schristos caller. */ 4768dffb485Schristos virtual const char *thread_name (ptid_t thread); 4778dffb485Schristos 4788dffb485Schristos /* Thread ID to (numeric) thread handle: Return true on success and 4798dffb485Schristos false for failure. Return pointer to thread handle via HANDLE 4808dffb485Schristos and the handle's length via HANDLE_LEN. */ 4818dffb485Schristos virtual bool thread_handle (ptid_t ptid, gdb_byte **handle, 4828dffb485Schristos int *handle_len); 4838dffb485Schristos 484*f1c2b495Schristos /* If THREAD is a fork/vfork/clone child that was not reported to 485*f1c2b495Schristos GDB, return its parent else nullptr. */ 4864b169a6bSchristos virtual thread_info *thread_pending_parent (thread_info *thread); 4874b169a6bSchristos 488*f1c2b495Schristos /* If THREAD is the parent of a fork/vfork/clone child that was not 489*f1c2b495Schristos reported to GDB, return this child and fill in KIND with the 490*f1c2b495Schristos matching waitkind, otherwise nullptr. */ 491*f1c2b495Schristos virtual thread_info *thread_pending_child (thread_info *thread, 492*f1c2b495Schristos target_waitkind *kind); 4934b169a6bSchristos 4948dffb485Schristos /* Returns true if the target can software single step. */ 4958dffb485Schristos virtual bool supports_software_single_step (); 4968dffb485Schristos 4978dffb485Schristos /* Return true if the target supports catch syscall. */ 4988dffb485Schristos virtual bool supports_catch_syscall (); 4998dffb485Schristos 5008dffb485Schristos /* Return tdesc index for IPA. */ 5018dffb485Schristos virtual int get_ipa_tdesc_idx (); 5024b169a6bSchristos 5034b169a6bSchristos /* Returns true if the target supports memory tagging facilities. */ 5044b169a6bSchristos virtual bool supports_memory_tagging (); 5054b169a6bSchristos 5064b169a6bSchristos /* Return the allocated memory tags of type TYPE associated with 5074b169a6bSchristos [ADDRESS, ADDRESS + LEN) in TAGS. 5084b169a6bSchristos 5094b169a6bSchristos Returns true if successful and false otherwise. */ 5104b169a6bSchristos virtual bool fetch_memtags (CORE_ADDR address, size_t len, 5114b169a6bSchristos gdb::byte_vector &tags, int type); 5124b169a6bSchristos 5134b169a6bSchristos /* Write the allocation tags of type TYPE contained in TAGS to the 5144b169a6bSchristos memory range [ADDRESS, ADDRESS + LEN). 5154b169a6bSchristos 5164b169a6bSchristos Returns true if successful and false otherwise. */ 5174b169a6bSchristos virtual bool store_memtags (CORE_ADDR address, size_t len, 5184b169a6bSchristos const gdb::byte_vector &tags, int type); 5198dffb485Schristos }; 5208dffb485Schristos 5218dffb485Schristos extern process_stratum_target *the_target; 5228dffb485Schristos 5238dffb485Schristos void set_target_ops (process_stratum_target *); 5248dffb485Schristos 5258dffb485Schristos #define target_create_inferior(program, program_args) \ 5268dffb485Schristos the_target->create_inferior (program, program_args) 5278dffb485Schristos 5288dffb485Schristos #define target_post_create_inferior() \ 5298dffb485Schristos the_target->post_create_inferior () 5308dffb485Schristos 5318dffb485Schristos #define myattach(pid) \ 5328dffb485Schristos the_target->attach (pid) 5338dffb485Schristos 5348dffb485Schristos int kill_inferior (process_info *proc); 5358dffb485Schristos 5368dffb485Schristos #define target_supports_fork_events() \ 5378dffb485Schristos the_target->supports_fork_events () 5388dffb485Schristos 5398dffb485Schristos #define target_supports_vfork_events() \ 5408dffb485Schristos the_target->supports_vfork_events () 5418dffb485Schristos 542*f1c2b495Schristos #define target_supported_thread_options(options) \ 543*f1c2b495Schristos the_target->supported_thread_options (options) 544*f1c2b495Schristos 5458dffb485Schristos #define target_supports_exec_events() \ 5468dffb485Schristos the_target->supports_exec_events () 5478dffb485Schristos 5484b169a6bSchristos #define target_supports_memory_tagging() \ 5494b169a6bSchristos the_target->supports_memory_tagging () 5504b169a6bSchristos 5518dffb485Schristos #define target_handle_new_gdb_connection() \ 5528dffb485Schristos the_target->handle_new_gdb_connection () 5538dffb485Schristos 5548dffb485Schristos #define detach_inferior(proc) \ 5558dffb485Schristos the_target->detach (proc) 5568dffb485Schristos 5578dffb485Schristos #define mythread_alive(pid) \ 5588dffb485Schristos the_target->thread_alive (pid) 5598dffb485Schristos 5608dffb485Schristos #define fetch_inferior_registers(regcache, regno) \ 5618dffb485Schristos the_target->fetch_registers (regcache, regno) 5628dffb485Schristos 5638dffb485Schristos #define store_inferior_registers(regcache, regno) \ 5648dffb485Schristos the_target->store_registers (regcache, regno) 5658dffb485Schristos 5668dffb485Schristos #define join_inferior(pid) \ 5678dffb485Schristos the_target->join (pid) 5688dffb485Schristos 5698dffb485Schristos #define target_supports_non_stop() \ 5708dffb485Schristos the_target->supports_non_stop () 5718dffb485Schristos 5728dffb485Schristos #define target_async(enable) \ 5738dffb485Schristos the_target->async (enable) 5748dffb485Schristos 5758dffb485Schristos #define target_process_qsupported(features) \ 5768dffb485Schristos the_target->process_qsupported (features) 5778dffb485Schristos 5788dffb485Schristos #define target_supports_catch_syscall() \ 5798dffb485Schristos the_target->supports_catch_syscall () 5808dffb485Schristos 5818dffb485Schristos #define target_get_ipa_tdesc_idx() \ 5828dffb485Schristos the_target->get_ipa_tdesc_idx () 5838dffb485Schristos 5848dffb485Schristos #define target_supports_tracepoints() \ 5858dffb485Schristos the_target->supports_tracepoints () 5868dffb485Schristos 5878dffb485Schristos #define target_supports_fast_tracepoints() \ 5888dffb485Schristos the_target->supports_fast_tracepoints () 5898dffb485Schristos 5908dffb485Schristos #define target_get_min_fast_tracepoint_insn_len() \ 5918dffb485Schristos the_target->get_min_fast_tracepoint_insn_len () 5928dffb485Schristos 5938dffb485Schristos #define target_thread_stopped(thread) \ 5948dffb485Schristos the_target->thread_stopped (thread) 5958dffb485Schristos 5968dffb485Schristos #define target_pause_all(freeze) \ 5978dffb485Schristos the_target->pause_all (freeze) 5988dffb485Schristos 5998dffb485Schristos #define target_unpause_all(unfreeze) \ 6008dffb485Schristos the_target->unpause_all (unfreeze) 6018dffb485Schristos 6028dffb485Schristos #define target_stabilize_threads() \ 6038dffb485Schristos the_target->stabilize_threads () 6048dffb485Schristos 6058dffb485Schristos #define target_install_fast_tracepoint_jump_pad(tpoint, tpaddr, \ 6068dffb485Schristos collector, lockaddr, \ 6078dffb485Schristos orig_size, \ 6088dffb485Schristos jump_entry, \ 6098dffb485Schristos trampoline, trampoline_size, \ 6108dffb485Schristos jjump_pad_insn, \ 6118dffb485Schristos jjump_pad_insn_size, \ 6128dffb485Schristos adjusted_insn_addr, \ 6138dffb485Schristos adjusted_insn_addr_end, \ 6148dffb485Schristos err) \ 6158dffb485Schristos the_target->install_fast_tracepoint_jump_pad (tpoint, tpaddr, \ 6168dffb485Schristos collector,lockaddr, \ 6178dffb485Schristos orig_size, jump_entry, \ 6188dffb485Schristos trampoline, \ 6198dffb485Schristos trampoline_size, \ 6208dffb485Schristos jjump_pad_insn, \ 6218dffb485Schristos jjump_pad_insn_size, \ 6228dffb485Schristos adjusted_insn_addr, \ 6238dffb485Schristos adjusted_insn_addr_end, \ 6248dffb485Schristos err) 6258dffb485Schristos 6268dffb485Schristos #define target_emit_ops() \ 6278dffb485Schristos the_target->emit_ops () 6288dffb485Schristos 6298dffb485Schristos #define target_supports_disable_randomization() \ 6308dffb485Schristos the_target->supports_disable_randomization () 6318dffb485Schristos 6328dffb485Schristos #define target_supports_agent() \ 6338dffb485Schristos the_target->supports_agent () 6348dffb485Schristos 6358dffb485Schristos static inline struct btrace_target_info * 6364b169a6bSchristos target_enable_btrace (thread_info *tp, const struct btrace_config *conf) 6378dffb485Schristos { 6384b169a6bSchristos return the_target->enable_btrace (tp, conf); 6398dffb485Schristos } 6408dffb485Schristos 6418dffb485Schristos static inline int 6428dffb485Schristos target_disable_btrace (struct btrace_target_info *tinfo) 6438dffb485Schristos { 6448dffb485Schristos return the_target->disable_btrace (tinfo); 6458dffb485Schristos } 6468dffb485Schristos 6478dffb485Schristos static inline int 6488dffb485Schristos target_read_btrace (struct btrace_target_info *tinfo, 649*f1c2b495Schristos std::string *buffer, 6508dffb485Schristos enum btrace_read_type type) 6518dffb485Schristos { 6528dffb485Schristos return the_target->read_btrace (tinfo, buffer, type); 6538dffb485Schristos } 6548dffb485Schristos 6558dffb485Schristos static inline int 6568dffb485Schristos target_read_btrace_conf (struct btrace_target_info *tinfo, 657*f1c2b495Schristos std::string *buffer) 6588dffb485Schristos { 6598dffb485Schristos return the_target->read_btrace_conf (tinfo, buffer); 6608dffb485Schristos } 6618dffb485Schristos 6628dffb485Schristos #define target_supports_range_stepping() \ 6638dffb485Schristos the_target->supports_range_stepping () 6648dffb485Schristos 6658dffb485Schristos #define target_supports_stopped_by_sw_breakpoint() \ 6668dffb485Schristos the_target->supports_stopped_by_sw_breakpoint () 6678dffb485Schristos 6688dffb485Schristos #define target_stopped_by_sw_breakpoint() \ 6698dffb485Schristos the_target->stopped_by_sw_breakpoint () 6708dffb485Schristos 6718dffb485Schristos #define target_supports_stopped_by_hw_breakpoint() \ 6728dffb485Schristos the_target->supports_stopped_by_hw_breakpoint () 6738dffb485Schristos 6748dffb485Schristos #define target_supports_hardware_single_step() \ 6758dffb485Schristos the_target->supports_hardware_single_step () 6768dffb485Schristos 6778dffb485Schristos #define target_stopped_by_hw_breakpoint() \ 6788dffb485Schristos the_target->stopped_by_hw_breakpoint () 6798dffb485Schristos 6808dffb485Schristos #define target_breakpoint_kind_from_pc(pcptr) \ 6818dffb485Schristos the_target->breakpoint_kind_from_pc (pcptr) 6828dffb485Schristos 6838dffb485Schristos #define target_breakpoint_kind_from_current_state(pcptr) \ 6848dffb485Schristos the_target->breakpoint_kind_from_current_state (pcptr) 6858dffb485Schristos 6868dffb485Schristos #define target_supports_software_single_step() \ 6878dffb485Schristos the_target->supports_software_single_step () 6888dffb485Schristos 689*f1c2b495Schristos #define target_any_resumed() \ 690*f1c2b495Schristos the_target->any_resumed () 691*f1c2b495Schristos 6924b169a6bSchristos ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, 6934b169a6bSchristos target_wait_flags options, int connected_wait); 6948dffb485Schristos 6958dffb485Schristos #define target_core_of_thread(ptid) \ 6968dffb485Schristos the_target->core_of_thread (ptid) 6978dffb485Schristos 6988dffb485Schristos #define target_thread_name(ptid) \ 6998dffb485Schristos the_target->thread_name (ptid) 7008dffb485Schristos 7018dffb485Schristos #define target_thread_handle(ptid, handle, handle_len) \ 7028dffb485Schristos the_target->thread_handle (ptid, handle, handle_len) 7038dffb485Schristos 7044b169a6bSchristos static inline thread_info * 7054b169a6bSchristos target_thread_pending_parent (thread_info *thread) 7064b169a6bSchristos { 7074b169a6bSchristos return the_target->thread_pending_parent (thread); 7084b169a6bSchristos } 7094b169a6bSchristos 7104b169a6bSchristos static inline thread_info * 711*f1c2b495Schristos target_thread_pending_child (thread_info *thread, target_waitkind *kind) 7124b169a6bSchristos { 713*f1c2b495Schristos return the_target->thread_pending_child (thread, kind); 7144b169a6bSchristos } 7154b169a6bSchristos 716*f1c2b495Schristos /* Read LEN bytes from MEMADDR in the buffer MYADDR. Return 0 if the read 717*f1c2b495Schristos is successful, otherwise, return a non-zero error code. */ 718*f1c2b495Schristos 7198dffb485Schristos int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len); 7208dffb485Schristos 7214b169a6bSchristos /* Set GDBserver's current thread to the thread the client requested 7224b169a6bSchristos via Hg. Also switches the current process to the requested 7234b169a6bSchristos process. If the requested thread is not found in the thread list, 7244b169a6bSchristos then the current thread is set to NULL. Likewise, if the requested 7254b169a6bSchristos process is not found in the process list, then the current process 7264b169a6bSchristos is set to NULL. Returns true if the requested thread was found, 7274b169a6bSchristos false otherwise. */ 7288dffb485Schristos 7294b169a6bSchristos bool set_desired_thread (); 7304b169a6bSchristos 7314b169a6bSchristos /* Set GDBserver's current process to the process the client requested 7324b169a6bSchristos via Hg. The current thread is set to NULL. */ 7334b169a6bSchristos 7344b169a6bSchristos bool set_desired_process (); 7354b169a6bSchristos 7364b169a6bSchristos std::string target_pid_to_str (ptid_t); 7378dffb485Schristos 7388dffb485Schristos #endif /* GDBSERVER_TARGET_H */ 739