2003-09-17 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / config / pa / nm-hppah.h
CommitLineData
c906108c 1/* Native support for HPPA-RISC machine running HPUX, for GDB.
710686b3 2 Copyright 1991, 1992, 1994, 1996, 1998, 1999, 2000, 2002
b6ba6518 3 Free Software Foundation, Inc.
c906108c 4
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
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.
c906108c 11
c5aa993b
JM
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.
c906108c 16
c5aa993b
JM
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. */
c906108c
SS
21
22#define U_REGS_OFFSET 0
23
24#define KERNEL_U_ADDR 0
25
26/* What a coincidence! */
27#define REGISTER_U_ADDR(addr, blockend, regno) \
62700349 28{ addr = (int)(blockend) + DEPRECATED_REGISTER_BYTE (regno);}
c906108c 29
a0b3c4fd
JM
30/* This isn't really correct, because ptrace is actually a 32-bit
31 interface. However, the modern HP-UX targets all really use
32 ttrace, which is a 64-bit interface --- a debugger running in
33 either 32- or 64-bit mode can debug a 64-bit process. BUT, the
34 code doesn't use ttrace directly --- it calls call_ptrace instead,
35 which is supposed to be drop-in substitute for ptrace. In other
36 words, they access a 64-bit system call (ttrace) through a
37 compatibility layer which is allegedly a 32-bit interface.
38
39 So I don't feel the least bit guilty about this. */
40#define PTRACE_ARG3_TYPE CORE_ADDR
41
c906108c
SS
42/* HPUX 8.0, in its infinite wisdom, has chosen to prototype ptrace
43 with five arguments, so programs written for normal ptrace lose. */
44#define FIVE_ARG_PTRACE
45
46/* We need to figure out where the text region is so that we use the
47 appropriate ptrace operator to manipulate text. Simply reading/writing
48 user space will crap out HPUX. */
49#define NEED_TEXT_START_END 1
50
c906108c
SS
51/* In hppah-nat.c: */
52#define FETCH_INFERIOR_REGISTERS
53#define CHILD_XFER_MEMORY
6604731b 54#define CHILD_FOLLOW_FORK
c906108c 55
c906108c
SS
56/* In infptrace.c or infttrace.c: */
57#define CHILD_PID_TO_EXEC_FILE
58#define CHILD_POST_STARTUP_INFERIOR
59#define CHILD_ACKNOWLEDGE_CREATED_INFERIOR
60#define CHILD_INSERT_FORK_CATCHPOINT
61#define CHILD_REMOVE_FORK_CATCHPOINT
62#define CHILD_INSERT_VFORK_CATCHPOINT
63#define CHILD_REMOVE_VFORK_CATCHPOINT
c906108c
SS
64#define CHILD_INSERT_EXEC_CATCHPOINT
65#define CHILD_REMOVE_EXEC_CATCHPOINT
c906108c 66#define CHILD_REPORTED_EXEC_EVENTS_PER_EXEC_CALL
c906108c
SS
67#define CHILD_POST_ATTACH
68#define CHILD_THREAD_ALIVE
ed9a39eb 69#define CHILD_PID_TO_STR
47932f85 70#define CHILD_WAIT
8a1f4c4c 71struct target_waitstatus;
47932f85 72extern ptid_t child_wait (ptid_t, struct target_waitstatus *);
c906108c 73
a14ed312 74extern int hppa_require_attach (int);
a14ed312 75extern int hppa_require_detach (int, int);
c906108c
SS
76
77/* So we can cleanly use code in infptrace.c. */
78#define PT_KILL PT_EXIT
79#define PT_STEP PT_SINGLE
80#define PT_CONTINUE PT_CONTIN
81
82/* FIXME HP MERGE : Previously, PT_RDUAREA. this is actually fixed
83 in gdb-hp-snapshot-980509 */
84#define PT_READ_U PT_RUAREA
85#define PT_WRITE_U PT_WUAREA
86#define PT_READ_I PT_RIUSER
87#define PT_READ_D PT_RDUSER
88#define PT_WRITE_I PT_WIUSER
89#define PT_WRITE_D PT_WDUSER
90
91/* attach/detach works to some extent under BSD and HPUX. So long
92 as the process you're attaching to isn't blocked waiting on io,
93 blocked waiting on a signal, or in a system call things work
94 fine. (The problems in those cases are related to the fact that
95 the kernel can't provide complete register information for the
96 target process... Which really pisses off GDB.) */
97
98#define ATTACH_DETACH
99
100/* In infptrace or infttrace.c: */
101
102/* Starting with HP-UX 10.30, support is provided (in the form of
103 ttrace requests) for memory-protection-based hardware watchpoints.
104
105 The 10.30 implementation of these functions reside in infttrace.c.
106
107 Stubs of these functions will be provided in infptrace.c, so that
108 10.20 will at least link. However, the "can I use a fast watchpoint?"
109 query will always return "No" for 10.20. */
110
111#define TARGET_HAS_HARDWARE_WATCHPOINTS
112
113/* The PA can watch any number of locations (generic routines already check
114 that all intermediates are in watchable memory locations). */
65e82032 115extern int hppa_can_use_hw_watchpoint (int type, int cnt, int ot);
c906108c
SS
116#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(type, cnt, ot) \
117 hppa_can_use_hw_watchpoint(type, cnt, ot)
118
b1e29e33
AC
119/* The PA can also watch memory regions of arbitrary size, since we're
120 using a page-protection scheme. (On some targets, apparently watch
121 registers are used, which can only accomodate regions of
122 DEPRECATED_REGISTER_SIZE.) */
c906108c
SS
123#define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(byte_count) \
124 (1)
125
126/* However, some addresses may not be profitable to use hardware to watch,
127 or may be difficult to understand when the addressed object is out of
128 scope, and hence should be unwatched. On some targets, this may have
129 severe performance penalties, such that we might as well use regular
130 watchpoints, and save (possibly precious) hardware watchpoints for other
131 locations.
132
133 On HP-UX, we choose not to watch stack-based addresses, because
134
135 [1] Our implementation relies on page protection traps. The granularity
136 of these is large and so can generate many false hits, which are expensive
137 to respond to.
138
139 [2] Watches of "*p" where we may not know the symbol that p points to,
140 make it difficult to know when the addressed object is out of scope, and
141 hence shouldn't be watched. Page protection that isn't removed when the
142 addressed object is out of scope will either degrade execution speed
143 (false hits) or give false triggers (when the address is recycled by
144 other calls).
145
146 Since either of these points results in a slow-running inferior, we might
147 as well use normal watchpoints, aka single-step & test. */
148#define TARGET_RANGE_PROFITABLE_FOR_HW_WATCHPOINT(pid,start,len) \
149 hppa_range_profitable_for_hw_watchpoint(pid, start, (LONGEST)(len))
150
151/* On HP-UX, we're using page-protection to implement hardware watchpoints.
152 When an instruction attempts to write to a write-protected memory page,
153 a SIGBUS is raised. At that point, the write has not actually occurred.
154
155 We must therefore remove page-protections; single-step the inferior (to
156 allow the write to happen); restore page-protections; and check whether
157 any watchpoint triggered.
158
159 If none did, then the write was to a "nearby" location that just happens
160 to fall on the same page as a watched location, and so can be ignored.
161
162 The only intended client of this macro is wait_for_inferior(), in infrun.c.
163 When HAVE_NONSTEPPABLE_WATCHPOINT is true, that function will take care
164 of the stepping & etc. */
165
166#define STOPPED_BY_WATCHPOINT(W) \
167 ((W.kind == TARGET_WAITKIND_STOPPED) && \
168 (stop_signal == TARGET_SIGNAL_BUS) && \
169 ! stepped_after_stopped_by_watchpoint && \
170 bpstat_have_active_hw_watchpoints ())
171
c906108c
SS
172/* Our implementation of "hardware" watchpoints uses memory page-protection
173 faults. However, HP-UX has unfortunate interactions between these and
174 system calls; basically, it's unsafe to have page protections on when a
175 syscall is running. Therefore, we also ask for notification of syscall
176 entries and returns. When the inferior enters a syscall, we disable
177 h/w watchpoints. When the inferior returns from a syscall, we reenable
178 h/w watchpoints.
179
180 infptrace.c supplies dummy versions of these; infttrace.c is where the
181 meaningful implementations are.
c5aa993b 182 */
c906108c
SS
183#define TARGET_ENABLE_HW_WATCHPOINTS(pid) \
184 hppa_enable_page_protection_events (pid)
a14ed312 185extern void hppa_enable_page_protection_events (int);
c906108c
SS
186
187#define TARGET_DISABLE_HW_WATCHPOINTS(pid) \
188 hppa_disable_page_protection_events (pid)
a14ed312 189extern void hppa_disable_page_protection_events (int);
c906108c
SS
190
191/* Use these macros for watchpoint insertion/deletion. */
65e82032
AC
192extern int hppa_insert_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len,
193 int type);
c906108c 194#define target_insert_watchpoint(addr, len, type) \
39f77062 195 hppa_insert_hw_watchpoint (PIDGET (inferior_ptid), addr, (LONGEST)(len), type)
c906108c 196
65e82032
AC
197extern int hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len,
198 int type);
c906108c 199#define target_remove_watchpoint(addr, len, type) \
39f77062 200 hppa_remove_hw_watchpoint (PIDGET (inferior_ptid), addr, (LONGEST)(len), type)
c906108c
SS
201
202/* We call our k-thread processes "threads", rather
203 * than processes. So we need a new way to print
204 * the string. Code is in hppah-nat.c.
205 */
ed9a39eb 206
39f77062 207extern char *child_pid_to_str (ptid_t);
c906108c 208
39f77062
KB
209#define target_tid_to_str( ptid ) \
210 hppa_tid_to_str( ptid )
211extern char *hppa_tid_to_str (ptid_t);
c906108c
SS
212
213/* For this, ID can be either a process or thread ID, and the function
214 will describe it appropriately, returning the description as a printable
215 string.
216
217 The function that implements this macro is defined in infptrace.c and
218 infttrace.c.
c5aa993b 219 */
c906108c
SS
220#define target_pid_or_tid_to_str(ID) \
221 hppa_pid_or_tid_to_str (ID)
39f77062 222extern char *hppa_pid_or_tid_to_str (ptid_t);
c906108c
SS
223
224/* This is used when handling events caused by a call to vfork(). On ptrace-
225 based HP-UXs, when you resume the vforked child, the parent automagically
226 begins running again. To prevent this runaway, this function is used.
227
228 Note that for vfork on HP-UX, we receive three events of interest:
229
230 1. the vfork event for the new child process
231 2. the exit or exec event of the new child process (actually, you get
c5aa993b 232 two exec events on ptrace-based HP-UXs)
c906108c
SS
233 3. the vfork event for the original parent process
234
235 The first is always received first. The other two may be received in any
236 order; HP-UX doesn't guarantee an order.
c5aa993b 237 */
c906108c
SS
238#define ENSURE_VFORKING_PARENT_REMAINS_STOPPED(PID) \
239 hppa_ensure_vforking_parent_remains_stopped (PID)
a14ed312 240extern void hppa_ensure_vforking_parent_remains_stopped (int);
c906108c
SS
241
242/* This is used when handling events caused by a call to vfork().
243
244 On ttrace-based HP-UXs, the parent vfork and child exec arrive more or less
245 together. That is, you could do two wait()s without resuming either parent
246 or child, and get both events.
247
248 On ptrace-based HP-UXs, you must resume the child after its exec event is
249 delivered or you won't get the parent's vfork. I.e., you can't just wait()
250 and get the parent vfork, after receiving the child exec.
c5aa993b 251 */
c906108c
SS
252#define RESUME_EXECD_VFORKING_CHILD_TO_GET_PARENT_VFORK() \
253 hppa_resume_execd_vforking_child_to_get_parent_vfork ()
a14ed312 254extern int hppa_resume_execd_vforking_child_to_get_parent_vfork (void);
c906108c 255
c906108c 256#define HPUXHPPA
7a292a7a
SS
257
258#define MAY_SWITCH_FROM_INFERIOR_PID (1)
259
260#define MAY_FOLLOW_EXEC (1)
261
262#define USE_THREAD_STEP_NEEDED (1)
65e82032
AC
263
264#include "infttrace.h" /* For parent_attach_all. */
This page took 0.264492 seconds and 4 git commands to generate.