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