/* Interface between GDB and target environments, including files and processes
- Copyright 1990-1994, 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ 2000, 2001 Free Software Foundation, Inc.
Contributed by Cygnus Support. Written by John Gilmore.
This file is part of GDB.
#include "bfd.h"
#include "symtab.h"
+#include "dcache.h"
+#include "memattr.h"
enum strata
{
TARGET_WAITKIND_IGNORE
};
-/* The numbering of these signals is chosen to match traditional unix
- signals (insofar as various unices use the same numbers, anyway).
- It is also the numbering of the GDB remote protocol. Other remote
- protocols, if they use a different numbering, should make sure to
- translate appropriately.
-
- Since these numbers have actually made it out into other software
- (stubs, etc.), you mustn't disturb the assigned numbering. If you
- need to add new signals here, add them to the end of the explicitly
- numbered signals.
-
- This is based strongly on Unix/POSIX signals for several reasons:
- (1) This set of signals represents a widely-accepted attempt to
- represent events of this sort in a portable fashion, (2) we want a
- signal to make it from wait to child_wait to the user intact, (3) many
- remote protocols use a similar encoding. However, it is
- recognized that this set of signals has limitations (such as not
- distinguishing between various kinds of SIGSEGV, or not
- distinguishing hitting a breakpoint from finishing a single step).
- So in the future we may get around this either by adding additional
- signals for breakpoint, single-step, etc., or by adding signal
- codes; the latter seems more in the spirit of what BSD, System V,
- etc. are doing to address these issues. */
-
-/* For an explanation of what each signal means, see
- target_signal_to_string. */
-
-enum target_signal
- {
- /* Used some places (e.g. stop_signal) to record the concept that
- there is no signal. */
- TARGET_SIGNAL_0 = 0,
- TARGET_SIGNAL_FIRST = 0,
- TARGET_SIGNAL_HUP = 1,
- TARGET_SIGNAL_INT = 2,
- TARGET_SIGNAL_QUIT = 3,
- TARGET_SIGNAL_ILL = 4,
- TARGET_SIGNAL_TRAP = 5,
- TARGET_SIGNAL_ABRT = 6,
- TARGET_SIGNAL_EMT = 7,
- TARGET_SIGNAL_FPE = 8,
- TARGET_SIGNAL_KILL = 9,
- TARGET_SIGNAL_BUS = 10,
- TARGET_SIGNAL_SEGV = 11,
- TARGET_SIGNAL_SYS = 12,
- TARGET_SIGNAL_PIPE = 13,
- TARGET_SIGNAL_ALRM = 14,
- TARGET_SIGNAL_TERM = 15,
- TARGET_SIGNAL_URG = 16,
- TARGET_SIGNAL_STOP = 17,
- TARGET_SIGNAL_TSTP = 18,
- TARGET_SIGNAL_CONT = 19,
- TARGET_SIGNAL_CHLD = 20,
- TARGET_SIGNAL_TTIN = 21,
- TARGET_SIGNAL_TTOU = 22,
- TARGET_SIGNAL_IO = 23,
- TARGET_SIGNAL_XCPU = 24,
- TARGET_SIGNAL_XFSZ = 25,
- TARGET_SIGNAL_VTALRM = 26,
- TARGET_SIGNAL_PROF = 27,
- TARGET_SIGNAL_WINCH = 28,
- TARGET_SIGNAL_LOST = 29,
- TARGET_SIGNAL_USR1 = 30,
- TARGET_SIGNAL_USR2 = 31,
- TARGET_SIGNAL_PWR = 32,
- /* Similar to SIGIO. Perhaps they should have the same number. */
- TARGET_SIGNAL_POLL = 33,
- TARGET_SIGNAL_WIND = 34,
- TARGET_SIGNAL_PHONE = 35,
- TARGET_SIGNAL_WAITING = 36,
- TARGET_SIGNAL_LWP = 37,
- TARGET_SIGNAL_DANGER = 38,
- TARGET_SIGNAL_GRANT = 39,
- TARGET_SIGNAL_RETRACT = 40,
- TARGET_SIGNAL_MSG = 41,
- TARGET_SIGNAL_SOUND = 42,
- TARGET_SIGNAL_SAK = 43,
- TARGET_SIGNAL_PRIO = 44,
- TARGET_SIGNAL_REALTIME_33 = 45,
- TARGET_SIGNAL_REALTIME_34 = 46,
- TARGET_SIGNAL_REALTIME_35 = 47,
- TARGET_SIGNAL_REALTIME_36 = 48,
- TARGET_SIGNAL_REALTIME_37 = 49,
- TARGET_SIGNAL_REALTIME_38 = 50,
- TARGET_SIGNAL_REALTIME_39 = 51,
- TARGET_SIGNAL_REALTIME_40 = 52,
- TARGET_SIGNAL_REALTIME_41 = 53,
- TARGET_SIGNAL_REALTIME_42 = 54,
- TARGET_SIGNAL_REALTIME_43 = 55,
- TARGET_SIGNAL_REALTIME_44 = 56,
- TARGET_SIGNAL_REALTIME_45 = 57,
- TARGET_SIGNAL_REALTIME_46 = 58,
- TARGET_SIGNAL_REALTIME_47 = 59,
- TARGET_SIGNAL_REALTIME_48 = 60,
- TARGET_SIGNAL_REALTIME_49 = 61,
- TARGET_SIGNAL_REALTIME_50 = 62,
- TARGET_SIGNAL_REALTIME_51 = 63,
- TARGET_SIGNAL_REALTIME_52 = 64,
- TARGET_SIGNAL_REALTIME_53 = 65,
- TARGET_SIGNAL_REALTIME_54 = 66,
- TARGET_SIGNAL_REALTIME_55 = 67,
- TARGET_SIGNAL_REALTIME_56 = 68,
- TARGET_SIGNAL_REALTIME_57 = 69,
- TARGET_SIGNAL_REALTIME_58 = 70,
- TARGET_SIGNAL_REALTIME_59 = 71,
- TARGET_SIGNAL_REALTIME_60 = 72,
- TARGET_SIGNAL_REALTIME_61 = 73,
- TARGET_SIGNAL_REALTIME_62 = 74,
- TARGET_SIGNAL_REALTIME_63 = 75,
-
- /* Used internally by Solaris threads. See signal(5) on Solaris. */
- TARGET_SIGNAL_CANCEL = 76,
-
- /* Yes, this pains me, too. But LynxOS didn't have SIG32, and now
- Linux does, and we can't disturb the numbering, since it's part
- of the protocol. Note that in some GDB's TARGET_SIGNAL_REALTIME_32
- is number 76. */
- TARGET_SIGNAL_REALTIME_32,
-
-#if defined(MACH) || defined(__MACH__)
- /* Mach exceptions */
- TARGET_EXC_BAD_ACCESS,
- TARGET_EXC_BAD_INSTRUCTION,
- TARGET_EXC_ARITHMETIC,
- TARGET_EXC_EMULATION,
- TARGET_EXC_SOFTWARE,
- TARGET_EXC_BREAKPOINT,
-#endif
- TARGET_SIGNAL_INFO,
-
- /* Some signal we don't know about. */
- TARGET_SIGNAL_UNKNOWN,
-
- /* Use whatever signal we use when one is not specifically specified
- (for passing to proceed and so on). */
- TARGET_SIGNAL_DEFAULT,
-
- /* Last and unused enum value, for sizing arrays, etc. */
- TARGET_SIGNAL_LAST
- };
-
struct target_waitstatus
{
enum target_waitkind kind;
on TARGET_ACTIVITY_FD. */
extern int target_activity_fd;
/* Returns zero to leave the inferior alone, one to interrupt it. */
-extern int (*target_activity_function) PARAMS ((void));
+extern int (*target_activity_function) (void);
\f
struct thread_info; /* fwd decl for parameter list below: */
char *to_doc; /* Documentation. Does not include trailing
newline, and starts with a one-line descrip-
tion (probably similar to to_longname). */
- void (*to_open) PARAMS ((char *, int));
- void (*to_close) PARAMS ((int));
- void (*to_attach) PARAMS ((char *, int));
- void (*to_post_attach) PARAMS ((int));
- void (*to_require_attach) PARAMS ((char *, int));
- void (*to_detach) PARAMS ((char *, int));
- void (*to_require_detach) PARAMS ((int, char *, int));
- void (*to_resume) PARAMS ((int, int, enum target_signal));
- int (*to_wait) PARAMS ((int, struct target_waitstatus *));
- void (*to_post_wait) PARAMS ((int, int));
- void (*to_fetch_registers) PARAMS ((int));
- void (*to_store_registers) PARAMS ((int));
- void (*to_prepare_to_store) PARAMS ((void));
+ void (*to_open) (char *, int);
+ void (*to_close) (int);
+ void (*to_attach) (char *, int);
+ void (*to_post_attach) (int);
+ void (*to_require_attach) (char *, int);
+ void (*to_detach) (char *, int);
+ void (*to_require_detach) (int, char *, int);
+ void (*to_resume) (ptid_t, int, enum target_signal);
+ ptid_t (*to_wait) (ptid_t, struct target_waitstatus *);
+ void (*to_post_wait) (ptid_t, int);
+ void (*to_fetch_registers) (int);
+ void (*to_store_registers) (int);
+ void (*to_prepare_to_store) (void);
/* Transfer LEN bytes of memory between GDB address MYADDR and
target address MEMADDR. If WRITE, transfer them to the target, else
transfer right at MEMADDR, but we could transfer at least
something at MEMADDR + N. */
- int (*to_xfer_memory) PARAMS ((CORE_ADDR memaddr, char *myaddr,
- int len, int write,
- struct target_ops * target));
+ int (*to_xfer_memory) (CORE_ADDR memaddr, char *myaddr,
+ int len, int write,
+ struct mem_attrib *attrib,
+ struct target_ops *target);
#if 0
/* Enable this after 4.12. */
If we don't find anything, set *ADDR_FOUND to (CORE_ADDR)0 and
return. */
- void (*to_search) PARAMS ((int len, char *data, char *mask,
- CORE_ADDR startaddr, int increment,
- CORE_ADDR lorange, CORE_ADDR hirange,
- CORE_ADDR * addr_found, char *data_found));
+ void (*to_search) (int len, char *data, char *mask,
+ CORE_ADDR startaddr, int increment,
+ CORE_ADDR lorange, CORE_ADDR hirange,
+ CORE_ADDR * addr_found, char *data_found);
#define target_search(len, data, mask, startaddr, increment, lorange, hirange, addr_found, data_found) \
(*current_target.to_search) (len, data, mask, startaddr, increment, \
lorange, hirange, addr_found, data_found)
#endif /* 0 */
- void (*to_files_info) PARAMS ((struct target_ops *));
- int (*to_insert_breakpoint) PARAMS ((CORE_ADDR, char *));
- int (*to_remove_breakpoint) PARAMS ((CORE_ADDR, char *));
- void (*to_terminal_init) PARAMS ((void));
- void (*to_terminal_inferior) PARAMS ((void));
- void (*to_terminal_ours_for_output) PARAMS ((void));
- void (*to_terminal_ours) PARAMS ((void));
- void (*to_terminal_info) PARAMS ((char *, int));
- void (*to_kill) PARAMS ((void));
- void (*to_load) PARAMS ((char *, int));
- int (*to_lookup_symbol) PARAMS ((char *, CORE_ADDR *));
- void (*to_create_inferior) PARAMS ((char *, char *, char **));
- void (*to_post_startup_inferior) PARAMS ((int));
- void (*to_acknowledge_created_inferior) PARAMS ((int));
- void (*to_clone_and_follow_inferior) PARAMS ((int, int *));
- void (*to_post_follow_inferior_by_clone) PARAMS ((void));
- int (*to_insert_fork_catchpoint) PARAMS ((int));
- int (*to_remove_fork_catchpoint) PARAMS ((int));
- int (*to_insert_vfork_catchpoint) PARAMS ((int));
- int (*to_remove_vfork_catchpoint) PARAMS ((int));
- int (*to_has_forked) PARAMS ((int, int *));
- int (*to_has_vforked) PARAMS ((int, int *));
- int (*to_can_follow_vfork_prior_to_exec) PARAMS ((void));
- void (*to_post_follow_vfork) PARAMS ((int, int, int, int));
- int (*to_insert_exec_catchpoint) PARAMS ((int));
- int (*to_remove_exec_catchpoint) PARAMS ((int));
- int (*to_has_execd) PARAMS ((int, char **));
- int (*to_reported_exec_events_per_exec_call) PARAMS ((void));
- int (*to_has_syscall_event) PARAMS ((int, enum target_waitkind *, int *));
- int (*to_has_exited) PARAMS ((int, int, int *));
- void (*to_mourn_inferior) PARAMS ((void));
- int (*to_can_run) PARAMS ((void));
- void (*to_notice_signals) PARAMS ((int pid));
- int (*to_thread_alive) PARAMS ((int pid));
- void (*to_find_new_threads) PARAMS ((void));
- char *(*to_pid_to_str) PARAMS ((int));
- char *(*to_extra_thread_info) PARAMS ((struct thread_info *));
- void (*to_stop) PARAMS ((void));
- int (*to_query) PARAMS ((int /*char */ , char *, char *, int *));
+ void (*to_files_info) (struct target_ops *);
+ int (*to_insert_breakpoint) (CORE_ADDR, char *);
+ int (*to_remove_breakpoint) (CORE_ADDR, char *);
+ void (*to_terminal_init) (void);
+ void (*to_terminal_inferior) (void);
+ void (*to_terminal_ours_for_output) (void);
+ void (*to_terminal_ours) (void);
+ void (*to_terminal_info) (char *, int);
+ void (*to_kill) (void);
+ void (*to_load) (char *, int);
+ int (*to_lookup_symbol) (char *, CORE_ADDR *);
+ void (*to_create_inferior) (char *, char *, char **);
+ void (*to_post_startup_inferior) (ptid_t);
+ void (*to_acknowledge_created_inferior) (int);
+ void (*to_clone_and_follow_inferior) (int, int *);
+ void (*to_post_follow_inferior_by_clone) (void);
+ int (*to_insert_fork_catchpoint) (int);
+ int (*to_remove_fork_catchpoint) (int);
+ int (*to_insert_vfork_catchpoint) (int);
+ int (*to_remove_vfork_catchpoint) (int);
+ int (*to_has_forked) (int, int *);
+ int (*to_has_vforked) (int, int *);
+ int (*to_can_follow_vfork_prior_to_exec) (void);
+ void (*to_post_follow_vfork) (int, int, int, int);
+ int (*to_insert_exec_catchpoint) (int);
+ int (*to_remove_exec_catchpoint) (int);
+ int (*to_has_execd) (int, char **);
+ int (*to_reported_exec_events_per_exec_call) (void);
+ int (*to_has_syscall_event) (int, enum target_waitkind *, int *);
+ int (*to_has_exited) (int, int, int *);
+ void (*to_mourn_inferior) (void);
+ int (*to_can_run) (void);
+ void (*to_notice_signals) (ptid_t ptid);
+ int (*to_thread_alive) (ptid_t ptid);
+ void (*to_find_new_threads) (void);
+ char *(*to_pid_to_str) (ptid_t);
+ char *(*to_extra_thread_info) (struct thread_info *);
+ void (*to_stop) (void);
+ int (*to_query) (int /*char */ , char *, char *, int *);
void (*to_rcmd) (char *command, struct ui_file *output);
- struct symtab_and_line *(*to_enable_exception_callback) PARAMS ((enum exception_event_kind, int));
- struct exception_event_record *(*to_get_current_exception_event) PARAMS ((void));
- char *(*to_pid_to_exec_file) PARAMS ((int pid));
- char *(*to_core_file_to_sym_file) PARAMS ((char *));
+ struct symtab_and_line *(*to_enable_exception_callback) (enum
+ exception_event_kind,
+ int);
+ struct exception_event_record *(*to_get_current_exception_event) (void);
+ char *(*to_pid_to_exec_file) (int pid);
enum strata to_stratum;
struct target_ops
*DONT_USE; /* formerly to_next */
and (if successful) pushes a new target onto the stack.
Targets should supply this routine, if only to provide an error message. */
-#define target_open(name, from_tty) \
- (*current_target.to_open) (name, from_tty)
+#define target_open(name, from_tty) \
+ do { \
+ dcache_invalidate (target_dcache); \
+ (*current_target.to_open) (name, from_tty); \
+ } while (0)
/* Does whatever cleanup is required for a target that we are no longer
going to be calling. Argument says whether we are quitting gdb and
#define target_require_detach(pid, args, from_tty) \
(*current_target.to_require_detach) (pid, args, from_tty)
-/* Resume execution of the target process PID. STEP says whether to
+/* Resume execution of the target process PTID. STEP says whether to
single-step or to run free; SIGGNAL is the signal to be given to
the target, or TARGET_SIGNAL_0 for no signal. The caller may not
pass TARGET_SIGNAL_DEFAULT. */
-#define target_resume(pid, step, siggnal) \
- (*current_target.to_resume) (pid, step, siggnal)
+#define target_resume(ptid, step, siggnal) \
+ do { \
+ dcache_invalidate(target_dcache); \
+ (*current_target.to_resume) (ptid, step, siggnal); \
+ } while (0)
-/* Wait for process pid to do something. Pid = -1 to wait for any pid
+/* Wait for process pid to do something. PTID = -1 to wait for any pid
to do something. Return pid of child, or -1 in case of error;
store status through argument pointer STATUS. Note that it is
*not* OK to return_to_top_level out of target_wait without popping
to the prompt with a debugging target but without the frame cache,
stop_pc, etc., set up. */
-#define target_wait(pid, status) \
- (*current_target.to_wait) (pid, status)
+#define target_wait(ptid, status) \
+ (*current_target.to_wait) (ptid, status)
/* The target_wait operation waits for a process event to occur, and
thereby stop the process.
This operation provides a target-specific hook that allows the
necessary bookkeeping to be performed to track such sequences. */
-#define target_post_wait(pid, status) \
- (*current_target.to_post_wait) (pid, status)
+#define target_post_wait(ptid, status) \
+ (*current_target.to_post_wait) (ptid, status)
-/* Fetch register REGNO, or all regs if regno == -1. No result. */
+/* Fetch at least register REGNO, or all regs if regno == -1. No result. */
#define target_fetch_registers(regno) \
(*current_target.to_fetch_registers) (regno)
#define target_prepare_to_store() \
(*current_target.to_prepare_to_store) ()
+extern DCACHE *target_dcache;
+
+extern int do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct mem_attrib *attrib);
+
extern int target_read_string (CORE_ADDR, char **, int, int *);
extern int target_read_memory (CORE_ADDR memaddr, char *myaddr, int len);
-extern int target_write_memory (CORE_ADDR, char *, int);
+extern int target_write_memory (CORE_ADDR memaddr, char *myaddr, int len);
-extern int xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);
+extern int xfer_memory (CORE_ADDR, char *, int, int,
+ struct mem_attrib *, struct target_ops *);
-extern int
-child_xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);
+extern int child_xfer_memory (CORE_ADDR, char *, int, int,
+ struct mem_attrib *, struct target_ops *);
/* Make a single attempt at transfering LEN bytes. On a successful
transfer, the number of bytes actually transfered is returned and
extern void child_post_attach (int);
#endif
-extern void child_post_wait (int, int);
+extern void child_post_wait (ptid_t, int);
-extern void child_post_startup_inferior (int);
+extern void child_post_startup_inferior (ptid_t);
extern void child_acknowledge_created_inferior (int);
extern int child_has_exited (int, int, int *);
-extern int child_thread_alive (int);
+extern int child_thread_alive (ptid_t);
/* From exec.c */
#define target_lookup_symbol(name, addrp) \
(*current_target.to_lookup_symbol) (name, addrp)
-/* Start an inferior process and set inferior_pid to its pid.
+/* Start an inferior process and set inferior_ptid to its pid.
EXEC_FILE is the file to run.
ALLARGS is a string containing the arguments to the program.
ENV is the environment vector to pass. Errors reported with error().
Such targets will supply an appropriate definition for this function. */
-#define target_post_startup_inferior(pid) \
- (*current_target.to_post_startup_inferior) (pid)
+#define target_post_startup_inferior(ptid) \
+ (*current_target.to_post_startup_inferior) (ptid)
/* On some targets, the sequence of starting up an inferior requires
some synchronization between gdb and the new inferior process, PID. */
/* post process changes to signal handling in the inferior. */
-#define target_notice_signals(pid) \
- (*current_target.to_notice_signals) (pid)
+#define target_notice_signals(ptid) \
+ (*current_target.to_notice_signals) (ptid)
/* Check to see if a thread is still alive. */
-#define target_thread_alive(pid) \
- (*current_target.to_thread_alive) (pid)
+#define target_thread_alive(ptid) \
+ (*current_target.to_thread_alive) (ptid)
/* Query for new threads and add them to the thread list. */
#ifndef target_tid_to_str
#define target_tid_to_str(PID) \
target_pid_to_str (PID)
-extern char *normal_pid_to_str (int pid);
+extern char *normal_pid_to_str (ptid_t ptid);
#endif
/* Return a short string describing extra information about PID,
* can receive this notification (something like with signal handlers).
*/
-extern void (*target_new_objfile_hook) PARAMS ((struct objfile *));
+extern void (*target_new_objfile_hook) (struct objfile *);
#ifndef target_pid_or_tid_to_str
#define target_pid_or_tid_to_str(ID) \
#define target_pid_to_exec_file(pid) \
(current_target.to_pid_to_exec_file) (pid)
-/* Hook to call target-dependant code after reading in a new symbol table. */
+/* Hook to call target-dependent code after reading in a new symbol table. */
#ifndef TARGET_SYMFILE_POSTREAD
#define TARGET_SYMFILE_POSTREAD(OBJFILE)
#endif
-/* Hook to call target dependant code just after inferior target process has
+/* Hook to call target dependent code just after inferior target process has
started. */
#ifndef TARGET_CREATE_INFERIOR_HOOK
#if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
#define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(byte_count) \
- (LONGEST)(byte_count) <= REGISTER_SIZE
+ ((LONGEST)(byte_count) <= REGISTER_SIZE)
#endif
/* However, some addresses may not be profitable to use hardware to watch,
\f
/* Imported from machine dependent code */
-#ifndef SOFTWARE_SINGLE_STEP_P
-#define SOFTWARE_SINGLE_STEP_P 0
-#define SOFTWARE_SINGLE_STEP(sig,bp_p) \
- (internal_error ("SOFTWARE_SINGLE_STEP"), 0)
-#endif /* SOFTWARE_SINGLE_STEP_P */
-
/* Blank target vector entries are initialized to target_ignore. */
void target_ignore (void);