5f37239f93061a95c674aec1d97b0b3125b4d88b
[deliverable/binutils-gdb.git] / gdb / config / pa / nm-hppah.h
1 /* Native support for HPPA-RISC machine running HPUX, for GDB.
2 Copyright 1991, 1992, 1994, 1996, 1998, 1999, 2000, 2002
3 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 struct target_ops;
23
24 #define U_REGS_OFFSET 0
25
26 #define KERNEL_U_ADDR 0
27
28 /* What a coincidence! */
29 #define REGISTER_U_ADDR(addr, blockend, regno) \
30 { addr = (int)(blockend) + DEPRECATED_REGISTER_BYTE (regno);}
31
32 /* This isn't really correct, because ptrace is actually a 32-bit
33 interface. However, the modern HP-UX targets all really use
34 ttrace, which is a 64-bit interface --- a debugger running in
35 either 32- or 64-bit mode can debug a 64-bit process. BUT, the
36 code doesn't use ttrace directly --- it calls call_ptrace instead,
37 which is supposed to be drop-in substitute for ptrace. In other
38 words, they access a 64-bit system call (ttrace) through a
39 compatibility layer which is allegedly a 32-bit interface.
40
41 So I don't feel the least bit guilty about this. */
42 #define PTRACE_ARG3_TYPE CORE_ADDR
43
44 /* We need to figure out where the text region is so that we use the
45 appropriate ptrace operator to manipulate text. Simply
46 reading/writing user space will crap out HPUX. */
47 #define DEPRECATED_HPUX_TEXT_END deprecated_hpux_text_end
48 extern void deprecated_hpux_text_end (struct target_ops *exec_ops);
49
50 /* In hppah-nat.c: */
51 #define FETCH_INFERIOR_REGISTERS
52 #define CHILD_XFER_MEMORY
53 #define CHILD_FOLLOW_FORK
54
55 /* In infptrace.c or infttrace.c: */
56 #define CHILD_PID_TO_EXEC_FILE
57 #define CHILD_POST_STARTUP_INFERIOR
58 #define CHILD_ACKNOWLEDGE_CREATED_INFERIOR
59 #define CHILD_INSERT_FORK_CATCHPOINT
60 #define CHILD_REMOVE_FORK_CATCHPOINT
61 #define CHILD_INSERT_VFORK_CATCHPOINT
62 #define CHILD_REMOVE_VFORK_CATCHPOINT
63 #define CHILD_INSERT_EXEC_CATCHPOINT
64 #define CHILD_REMOVE_EXEC_CATCHPOINT
65 #define CHILD_REPORTED_EXEC_EVENTS_PER_EXEC_CALL
66 #define CHILD_POST_ATTACH
67 #define CHILD_THREAD_ALIVE
68 #define CHILD_PID_TO_STR
69 #define CHILD_WAIT
70 struct target_waitstatus;
71 extern ptid_t child_wait (ptid_t, struct target_waitstatus *);
72
73 extern int hppa_require_attach (int);
74 extern int hppa_require_detach (int, int);
75
76 /* So we can cleanly use code in infptrace.c. */
77 #define PT_KILL PT_EXIT
78 #define PT_STEP PT_SINGLE
79 #define PT_CONTINUE PT_CONTIN
80
81 /* FIXME HP MERGE : Previously, PT_RDUAREA. this is actually fixed
82 in gdb-hp-snapshot-980509 */
83 #define PT_READ_U PT_RUAREA
84 #define PT_WRITE_U PT_WUAREA
85 #define PT_READ_I PT_RIUSER
86 #define PT_READ_D PT_RDUSER
87 #define PT_WRITE_I PT_WIUSER
88 #define PT_WRITE_D PT_WDUSER
89
90 /* In infptrace or infttrace.c: */
91
92 /* Starting with HP-UX 10.30, support is provided (in the form of
93 ttrace requests) for memory-protection-based hardware watchpoints.
94
95 The 10.30 implementation of these functions reside in infttrace.c.
96
97 Stubs of these functions will be provided in infptrace.c, so that
98 10.20 will at least link. However, the "can I use a fast watchpoint?"
99 query will always return "No" for 10.20. */
100
101 #define TARGET_HAS_HARDWARE_WATCHPOINTS
102
103 /* The PA can watch any number of locations (generic routines already check
104 that all intermediates are in watchable memory locations). */
105 extern int hppa_can_use_hw_watchpoint (int type, int cnt, int ot);
106 #define TARGET_CAN_USE_HARDWARE_WATCHPOINT(type, cnt, ot) \
107 hppa_can_use_hw_watchpoint(type, cnt, ot)
108
109 /* The PA can also watch memory regions of arbitrary size, since we're
110 using a page-protection scheme. (On some targets, apparently watch
111 registers are used, which can only accomodate regions of
112 DEPRECATED_REGISTER_SIZE.) */
113 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(byte_count) \
114 (1)
115
116 /* On HP-UX, we're using page-protection to implement hardware watchpoints.
117 When an instruction attempts to write to a write-protected memory page,
118 a SIGBUS is raised. At that point, the write has not actually occurred.
119
120 We must therefore remove page-protections; single-step the inferior (to
121 allow the write to happen); restore page-protections; and check whether
122 any watchpoint triggered.
123
124 If none did, then the write was to a "nearby" location that just happens
125 to fall on the same page as a watched location, and so can be ignored.
126
127 The only intended client of this macro is wait_for_inferior(), in infrun.c.
128 When HAVE_NONSTEPPABLE_WATCHPOINT is true, that function will take care
129 of the stepping & etc. */
130
131 #define STOPPED_BY_WATCHPOINT(W) \
132 ((W.kind == TARGET_WAITKIND_STOPPED) && \
133 (stop_signal == TARGET_SIGNAL_BUS) && \
134 ! stepped_after_stopped_by_watchpoint && \
135 bpstat_have_active_hw_watchpoints ())
136
137 /* Our implementation of "hardware" watchpoints uses memory page-protection
138 faults. However, HP-UX has unfortunate interactions between these and
139 system calls; basically, it's unsafe to have page protections on when a
140 syscall is running. Therefore, we also ask for notification of syscall
141 entries and returns. When the inferior enters a syscall, we disable
142 h/w watchpoints. When the inferior returns from a syscall, we reenable
143 h/w watchpoints.
144
145 infptrace.c supplies dummy versions of these; infttrace.c is where the
146 meaningful implementations are.
147 */
148 #define TARGET_ENABLE_HW_WATCHPOINTS(pid) \
149 hppa_enable_page_protection_events (pid)
150 extern void hppa_enable_page_protection_events (int);
151
152 #define TARGET_DISABLE_HW_WATCHPOINTS(pid) \
153 hppa_disable_page_protection_events (pid)
154 extern void hppa_disable_page_protection_events (int);
155
156 /* Use these macros for watchpoint insertion/deletion. */
157 extern int hppa_insert_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len,
158 int type);
159 #define target_insert_watchpoint(addr, len, type) \
160 hppa_insert_hw_watchpoint (PIDGET (inferior_ptid), addr, (LONGEST)(len), type)
161
162 extern int hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len,
163 int type);
164 #define target_remove_watchpoint(addr, len, type) \
165 hppa_remove_hw_watchpoint (PIDGET (inferior_ptid), addr, (LONGEST)(len), type)
166
167 /* We call our k-thread processes "threads", rather
168 * than processes. So we need a new way to print
169 * the string. Code is in hppah-nat.c.
170 */
171
172 extern char *child_pid_to_str (ptid_t);
173
174 #define target_tid_to_str( ptid ) \
175 hppa_tid_to_str( ptid )
176 extern char *hppa_tid_to_str (ptid_t);
177
178 /* For this, ID can be either a process or thread ID, and the function
179 will describe it appropriately, returning the description as a printable
180 string.
181
182 The function that implements this macro is defined in infptrace.c and
183 infttrace.c.
184 */
185 #define target_pid_or_tid_to_str(ID) \
186 hppa_pid_or_tid_to_str (ID)
187 extern char *hppa_pid_or_tid_to_str (ptid_t);
188
189 /* This is used when handling events caused by a call to vfork(). On ptrace-
190 based HP-UXs, when you resume the vforked child, the parent automagically
191 begins running again. To prevent this runaway, this function is used.
192
193 Note that for vfork on HP-UX, we receive three events of interest:
194
195 1. the vfork event for the new child process
196 2. the exit or exec event of the new child process (actually, you get
197 two exec events on ptrace-based HP-UXs)
198 3. the vfork event for the original parent process
199
200 The first is always received first. The other two may be received in any
201 order; HP-UX doesn't guarantee an order.
202 */
203 #define ENSURE_VFORKING_PARENT_REMAINS_STOPPED(PID) \
204 hppa_ensure_vforking_parent_remains_stopped (PID)
205 extern void hppa_ensure_vforking_parent_remains_stopped (int);
206
207 /* This is used when handling events caused by a call to vfork().
208
209 On ttrace-based HP-UXs, the parent vfork and child exec arrive more or less
210 together. That is, you could do two wait()s without resuming either parent
211 or child, and get both events.
212
213 On ptrace-based HP-UXs, you must resume the child after its exec event is
214 delivered or you won't get the parent's vfork. I.e., you can't just wait()
215 and get the parent vfork, after receiving the child exec.
216 */
217 #define RESUME_EXECD_VFORKING_CHILD_TO_GET_PARENT_VFORK() \
218 hppa_resume_execd_vforking_child_to_get_parent_vfork ()
219 extern int hppa_resume_execd_vforking_child_to_get_parent_vfork (void);
220
221 #define HPUXHPPA
222
223 #define MAY_FOLLOW_EXEC (1)
224
225 #include "infttrace.h" /* For parent_attach_all. */
This page took 0.03362 seconds and 3 git commands to generate.