target.h revision 267654
155505Sshin/* Target operations for the remote server for GDB. 255505Sshin Copyright 2002, 2003, 2004 355505Sshin Free Software Foundation, Inc. 455505Sshin 555505Sshin Contributed by MontaVista Software. 655505Sshin 755505Sshin This file is part of GDB. 855505Sshin 955505Sshin This program is free software; you can redistribute it and/or modify 1055505Sshin it under the terms of the GNU General Public License as published by 1155505Sshin the Free Software Foundation; either version 2 of the License, or 1255505Sshin (at your option) any later version. 1355505Sshin 1455505Sshin This program is distributed in the hope that it will be useful, 1555505Sshin but WITHOUT ANY WARRANTY; without even the implied warranty of 1655505Sshin MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1755505Sshin GNU General Public License for more details. 1855505Sshin 1955505Sshin You should have received a copy of the GNU General Public License 2055505Sshin along with this program; if not, write to the Free Software 2155505Sshin Foundation, Inc., 59 Temple Place - Suite 330, 2255505Sshin Boston, MA 02111-1307, USA. */ 2355505Sshin 2455505Sshin#ifndef TARGET_H 2555505Sshin#define TARGET_H 2655505Sshin 2755505Sshin/* This structure describes how to resume a particular thread (or 2855505Sshin all threads) based on the client's request. If thread is -1, then 2955505Sshin this entry applies to all threads. These are generally passed around 3055505Sshin as an array, and terminated by a thread == -1 entry. */ 3155505Sshin 3255505Sshinstruct thread_resume 3355505Sshin{ 3455505Sshin int thread; 3555505Sshin 3655505Sshin /* If non-zero, leave this thread stopped. */ 3755505Sshin int leave_stopped; 3855505Sshin 3955505Sshin /* If non-zero, we want to single-step. */ 4055505Sshin int step; 4155505Sshin 4255505Sshin /* If non-zero, send this signal when we resume. */ 4355505Sshin int sig; 4455505Sshin}; 4555505Sshin 4655505Sshinstruct target_ops 4755505Sshin{ 4855505Sshin /* Start a new process. 4955505Sshin 5055505Sshin PROGRAM is a path to the program to execute. 5155505Sshin ARGS is a standard NULL-terminated array of arguments, 5255505Sshin to be passed to the inferior as ``argv''. 5355505Sshin 5455505Sshin Returns the new PID on success, -1 on failure. Registers the new 5555505Sshin process with the process list. */ 5655505Sshin 5755505Sshin int (*create_inferior) (char *program, char **args); 5855505Sshin 5955505Sshin /* Attach to a running process. 6055505Sshin 6155505Sshin PID is the process ID to attach to, specified by the user 6255505Sshin or a higher layer. */ 6355505Sshin 6455505Sshin int (*attach) (int pid); 6555505Sshin 6655505Sshin /* Kill all inferiors. */ 6755505Sshin 6855505Sshin void (*kill) (void); 6955505Sshin 7055505Sshin /* Detach from all inferiors. */ 7155505Sshin 7255505Sshin void (*detach) (void); 7355505Sshin 7455505Sshin /* Return 1 iff the thread with process ID PID is alive. */ 7555505Sshin 7655505Sshin int (*thread_alive) (int pid); 7755505Sshin 7855505Sshin /* Resume the inferior process. */ 7955505Sshin 8055505Sshin void (*resume) (struct thread_resume *resume_info); 8155505Sshin 8255505Sshin /* Wait for the inferior process to change state. 8355505Sshin 8455505Sshin STATUSP will be filled in with a response code to send to GDB. 8555505Sshin 8655505Sshin Returns the signal which caused the process to stop. */ 8755505Sshin 88 unsigned char (*wait) (char *status); 89 90 /* Fetch registers from the inferior process. 91 92 If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */ 93 94 void (*fetch_registers) (int regno); 95 96 /* Store registers to the inferior process. 97 98 If REGNO is -1, store all registers; otherwise, store at least REGNO. */ 99 100 void (*store_registers) (int regno); 101 102 /* Read memory from the inferior process. This should generally be 103 called through read_inferior_memory, which handles breakpoint shadowing. 104 105 Read LEN bytes at MEMADDR into a buffer at MYADDR. 106 107 Returns 0 on success and errno on failure. */ 108 109 int (*read_memory) (CORE_ADDR memaddr, char *myaddr, int len); 110 111 /* Write memory to the inferior process. This should generally be 112 called through write_inferior_memory, which handles breakpoint shadowing. 113 114 Write LEN bytes from the buffer at MYADDR to MEMADDR. 115 116 Returns 0 on success and errno on failure. */ 117 118 int (*write_memory) (CORE_ADDR memaddr, const char *myaddr, int len); 119 120 /* Query GDB for the values of any symbols we're interested in. 121 This function is called whenever we receive a "qSymbols::" 122 query, which corresponds to every time more symbols (might) 123 become available. NULL if we aren't interested in any 124 symbols. */ 125 126 void (*look_up_symbols) (void); 127 128 /* Send a signal to the inferior process, however is appropriate. */ 129 void (*send_signal) (int); 130 131 /* Read auxiliary vector data from the inferior process. 132 133 Read LEN bytes at OFFSET into a buffer at MYADDR. */ 134 135 int (*read_auxv) (CORE_ADDR offset, char *myaddr, unsigned int len); 136}; 137 138extern struct target_ops *the_target; 139 140void set_target_ops (struct target_ops *); 141 142#define create_inferior(program, args) \ 143 (*the_target->create_inferior) (program, args) 144 145#define myattach(pid) \ 146 (*the_target->attach) (pid) 147 148#define kill_inferior() \ 149 (*the_target->kill) () 150 151#define detach_inferior() \ 152 (*the_target->detach) () 153 154#define mythread_alive(pid) \ 155 (*the_target->thread_alive) (pid) 156 157#define fetch_inferior_registers(regno) \ 158 (*the_target->fetch_registers) (regno) 159 160#define store_inferior_registers(regno) \ 161 (*the_target->store_registers) (regno) 162 163unsigned char mywait (char *statusp, int connected_wait); 164 165int read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len); 166 167int write_inferior_memory (CORE_ADDR memaddr, const char *myaddr, int len); 168 169void set_desired_inferior (int id); 170 171#endif /* TARGET_H */ 172