Home | History | Annotate | Line # | Download | only in gdbserver
      1 /* Copyright (C) 2020-2024 Free Software Foundation, Inc.
      2 
      3    This file is part of GDB.
      4 
      5    This program is free software; you can redistribute it and/or modify
      6    it under the terms of the GNU General Public License as published by
      7    the Free Software Foundation; either version 3 of the License, or
      8    (at your option) any later version.
      9 
     10    This program is distributed in the hope that it will be useful,
     11    but WITHOUT ANY WARRANTY; without even the implied warranty of
     12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13    GNU General Public License for more details.
     14 
     15    You should have received a copy of the GNU General Public License
     16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     17 
     18 #ifndef GDBSERVER_NETBSD_LOW_H
     19 #define GDBSERVER_NETBSD_LOW_H
     20 
     21 struct regcache;
     22 struct target_desc;
     23 
     24 /*  Some information relative to a given register set.   */
     25 
     26 struct netbsd_regset_info
     27 {
     28   /* The ptrace request needed to get/set registers of this set.  */
     29   int get_request, set_request;
     30   /* The size of the register set.  */
     31   int size;
     32   /* Fill the buffer BUF from the contents of the given REGCACHE.  */
     33   void (*fill_function) (struct regcache *regcache, char *buf);
     34   /* Store the register value in BUF in the given REGCACHE.  */
     35   void (*store_function) (struct regcache *regcache, const char *buf);
     36 };
     37 
     38 /* Target ops definitions for a NetBSD target.  */
     39 
     40 class netbsd_process_target : public process_stratum_target
     41 {
     42 public:
     43 
     44   int create_inferior (const char *program,
     45 		       const std::vector<char *> &program_args) override;
     46 
     47   void post_create_inferior () override;
     48 
     49   int attach (unsigned long pid) override;
     50 
     51   int kill (process_info *proc) override;
     52 
     53   int detach (process_info *proc) override;
     54 
     55   void mourn (process_info *proc) override;
     56 
     57   void join (int pid) override;
     58 
     59   bool thread_alive (ptid_t pid) override;
     60 
     61   void resume (thread_resume *resume_info, size_t n) override;
     62 
     63   ptid_t wait (ptid_t ptid, target_waitstatus *status,
     64 	       target_wait_flags options) override;
     65 
     66   void fetch_registers (regcache *regcache, int regno) override;
     67 
     68   void store_registers (regcache *regcache, int regno) override;
     69 
     70   int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
     71 		   int len) override;
     72 
     73   int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
     74 		    int len) override;
     75 
     76   void request_interrupt () override;
     77 
     78   bool supports_read_auxv () override;
     79 
     80   int read_auxv (int pid, CORE_ADDR offset, unsigned char *myaddr,
     81 		 unsigned int len) override;
     82 
     83   bool supports_hardware_single_step () override;
     84 
     85   const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
     86 
     87   bool supports_z_point_type (char z_type) override;
     88 
     89   int insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
     90 		    int size, struct raw_breakpoint *bp) override;
     91 
     92   int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
     93 		    int size, struct raw_breakpoint *bp) override;
     94 
     95   bool stopped_by_sw_breakpoint () override;
     96 
     97   bool supports_qxfer_siginfo () override;
     98 
     99   int qxfer_siginfo (const char *annex, unsigned char *readbuf,
    100 		     unsigned const char *writebuf, CORE_ADDR offset,
    101 		     int len) override;
    102 
    103   bool supports_stopped_by_sw_breakpoint () override;
    104 
    105   bool supports_non_stop () override;
    106 
    107   bool supports_multi_process () override;
    108 
    109   bool supports_fork_events () override;
    110 
    111   bool supports_vfork_events () override;
    112 
    113   bool supports_exec_events () override;
    114 
    115   bool supports_disable_randomization () override;
    116 
    117   bool supports_qxfer_libraries_svr4 () override;
    118 
    119   int qxfer_libraries_svr4 (const char*, unsigned char*, const unsigned char*,
    120 			    CORE_ADDR, int) override;
    121 
    122   bool supports_pid_to_exec_file () override;
    123 
    124   const char *pid_to_exec_file (int pid) override;
    125 
    126   const char *thread_name (ptid_t thread) override;
    127 
    128   bool supports_catch_syscall () override;
    129 
    130 protected:
    131   /* The architecture-specific "low" methods are listed below.  */
    132 
    133   /* Return the information to access registers.  */
    134   virtual const netbsd_regset_info *get_regs_info () = 0;
    135 
    136   /* Architecture-specific setup for the current process.  */
    137   virtual void low_arch_setup () = 0;
    138 };
    139 
    140 extern netbsd_process_target *the_netbsd_target;
    141 
    142 #endif /* GDBSERVER_NETBSD_LOW_H */
    143