]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/config/pa/nm-hppab.h
Initial creation of sourceware repository
[thirdparty/binutils-gdb.git] / gdb / config / pa / nm-hppab.h
1 /* HPPA PA-RISC machine native support for BSD, for GDB.
2 Copyright 1991, 1992 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20 #include "somsolib.h"
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) \
28 { addr = (int)(blockend) + REGISTER_BYTE (regno);}
29
30 /* 3rd argument to ptrace is supposed to be a caddr_t. */
31
32 #define PTRACE_ARG3_TYPE caddr_t
33
34 /* HPUX 8.0, in its infinite wisdom, has chosen to prototype ptrace
35 with five arguments, so programs written for normal ptrace lose. */
36 #define FIVE_ARG_PTRACE
37
38
39 /* This macro defines the register numbers (from REGISTER_NAMES) that
40 are effectively unavailable to the user through ptrace(). It allows
41 us to include the whole register set in REGISTER_NAMES (inorder to
42 better support remote debugging). If it is used in
43 fetch/store_inferior_registers() gdb will not complain about I/O errors
44 on fetching these registers. If all registers in REGISTER_NAMES
45 are available, then return false (0). */
46
47 #define CANNOT_STORE_REGISTER(regno) \
48 ((regno) == 0) || \
49 ((regno) == PCSQ_HEAD_REGNUM) || \
50 ((regno) >= PCSQ_TAIL_REGNUM && (regno) < IPSW_REGNUM) || \
51 ((regno) > IPSW_REGNUM && (regno) < FP4_REGNUM)
52
53 /* fetch_inferior_registers is in hppab-nat.c. */
54 #define FETCH_INFERIOR_REGISTERS
55
56 /* attach/detach works to some extent under BSD and HPUX. So long
57 as the process you're attaching to isn't blocked waiting on io,
58 blocked waiting on a signal, or in a system call things work
59 fine. (The problems in those cases are related to the fact that
60 the kernel can't provide complete register information for the
61 target process... Which really pisses off GDB.) */
62
63 #define ATTACH_DETACH
64
65 /* The PA-BSD kernel has support for using the data memory break bit
66 to implement fast watchpoints.
67
68 Watchpoints on the PA act much like traditional page protection
69 schemes, but with some notable differences.
70
71 First, a special bit in the page table entry is used to cause
72 a trap when a specific page is written to. This avoids having
73 to overload watchpoints on the page protection bits. This makes
74 it possible for the kernel to easily decide if a trap was caused
75 by a watchpoint or by the user writing to protected memory and can
76 signal the user program differently in each case.
77
78 Second, the PA has a bit in the processor status word which causes
79 data memory breakpoints (aka watchpoints) to be disabled for a single
80 instruction. This bit can be used to avoid the overhead of unprotecting
81 and reprotecting pages when it becomes necessary to step over a watchpoint.
82
83
84 When the kernel receives a trap indicating a write to a page which
85 is being watched, the kernel performs a couple of simple actions. First
86 is sets the magic "disable memory breakpoint" bit in the processor
87 status word, it then sends a SIGTRAP to the process which caused the
88 trap.
89
90 GDB will take control and catch the signal for the inferior. GDB then
91 examines the PSW-X bit to determine if the SIGTRAP was caused by a
92 watchpoint firing. If so GDB single steps the inferior over the
93 instruction which caused the watchpoint to trigger (note because the
94 kernel disabled the data memory break bit for one instruction no trap
95 will be taken!). GDB will then determines the appropriate action to
96 take. (this may include restarting the inferior if the watchpoint
97 fired because of a write to an address on the same page as a watchpoint,
98 but no write to the watched address occured). */
99
100 #define TARGET_HAS_HARDWARE_WATCHPOINTS /* Enable the code in procfs.c */
101
102 /* The PA can watch any number of locations, there's no need for it to reject
103 anything (generic routines already check that all intermediates are
104 in memory). */
105 #define TARGET_CAN_USE_HARDWARE_WATCHPOINT(type, cnt, ot) \
106 ((type) == bp_hardware_watchpoint)
107
108 /* When a hardware watchpoint fires off the PC will be left at the
109 instruction which caused the watchpoint. It will be necessary for
110 GDB to step over the watchpoint.
111
112 On a PA running BSD, it is trivial to identify when it will be
113 necessary to step over a hardware watchpoint as we can examine
114 the PSW-X bit. If the bit is on, then we trapped because of a
115 watchpoint, else we trapped for some other reason. */
116 #define STOPPED_BY_WATCHPOINT(W) \
117 ((W).kind == TARGET_WAITKIND_STOPPED \
118 && (W).value.sig == TARGET_SIGNAL_TRAP \
119 && ((int) read_register (IPSW_REGNUM) & 0x00100000))
120
121 /* The PA can single step over a watchpoint if the kernel has set the
122 "X" bit in the processor status word (disable data memory breakpoint
123 for one instruction).
124
125 The kernel will always set this bit before notifying the inferior
126 that it hit a watchpoint. Thus, the inferior can single step over
127 the instruction which caused the watchpoint to fire. This avoids
128 the traditional need to disable the watchpoint, step the inferior,
129 then enable the watchpoint again. */
130 #define HAVE_STEPPABLE_WATCHPOINT
131
132 /* Use these macros for watchpoint insertion/deletion. */
133 /* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */
134 #define target_insert_watchpoint(addr, len, type) hppa_set_watchpoint (addr, len, 1)
135 #define target_remove_watchpoint(addr, len, type) hppa_set_watchpoint (addr, len, 0)