Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Target-dependent code for the HP PA architecture, for GDB. |
cda5a58a AC |
2 | |
3 | Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, | |
adc11376 AC |
4 | 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software |
5 | Foundation, Inc. | |
c906108c SS |
6 | |
7 | Contributed by the Center for Software Science at the | |
8 | University of Utah (pa-gdb-bugs@cs.utah.edu). | |
9 | ||
c5aa993b | 10 | This file is part of GDB. |
c906108c | 11 | |
c5aa993b JM |
12 | This program is free software; you can redistribute it and/or modify |
13 | it under the terms of the GNU General Public License as published by | |
14 | the Free Software Foundation; either version 2 of the License, or | |
15 | (at your option) any later version. | |
c906108c | 16 | |
c5aa993b JM |
17 | This program is distributed in the hope that it will be useful, |
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | GNU General Public License for more details. | |
c906108c | 21 | |
c5aa993b JM |
22 | You should have received a copy of the GNU General Public License |
23 | along with this program; if not, write to the Free Software | |
24 | Foundation, Inc., 59 Temple Place - Suite 330, | |
25 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
26 | |
27 | #include "defs.h" | |
28 | #include "frame.h" | |
29 | #include "bfd.h" | |
30 | #include "inferior.h" | |
31 | #include "value.h" | |
4e052eda | 32 | #include "regcache.h" |
e5d66720 | 33 | #include "completer.h" |
d709c020 | 34 | #include "language.h" |
59623e27 | 35 | #include "osabi.h" |
a7ff40e7 | 36 | #include "gdb_assert.h" |
65e82032 | 37 | #include "infttrace.h" |
343af405 | 38 | #include "arch-utils.h" |
c906108c SS |
39 | /* For argument passing to the inferior */ |
40 | #include "symtab.h" | |
04714b91 | 41 | #include "infcall.h" |
fde2cceb | 42 | #include "dis-asm.h" |
26d08f08 AC |
43 | #include "trad-frame.h" |
44 | #include "frame-unwind.h" | |
45 | #include "frame-base.h" | |
c906108c SS |
46 | |
47 | #ifdef USG | |
48 | #include <sys/types.h> | |
49 | #endif | |
50 | ||
51 | #include <dl.h> | |
52 | #include <sys/param.h> | |
53 | #include <signal.h> | |
54 | ||
55 | #include <sys/ptrace.h> | |
56 | #include <machine/save_state.h> | |
57 | ||
58 | #ifdef COFF_ENCAPSULATE | |
59 | #include "a.out.encap.h" | |
60 | #else | |
61 | #endif | |
62 | ||
c5aa993b | 63 | /*#include <sys/user.h> After a.out.h */ |
c906108c SS |
64 | #include <sys/file.h> |
65 | #include "gdb_stat.h" | |
03f2053f | 66 | #include "gdb_wait.h" |
c906108c SS |
67 | |
68 | #include "gdbcore.h" | |
69 | #include "gdbcmd.h" | |
70 | #include "target.h" | |
71 | #include "symfile.h" | |
72 | #include "objfiles.h" | |
3ff7cf9e | 73 | #include "hppa-tdep.h" |
c906108c | 74 | |
60383d10 | 75 | /* Some local constants. */ |
3ff7cf9e JB |
76 | static const int hppa32_num_regs = 128; |
77 | static const int hppa64_num_regs = 96; | |
78 | ||
e2ac8128 JB |
79 | /* Get at various relevent fields of an instruction word. */ |
80 | #define MASK_5 0x1f | |
81 | #define MASK_11 0x7ff | |
82 | #define MASK_14 0x3fff | |
83 | #define MASK_21 0x1fffff | |
84 | ||
e2ac8128 JB |
85 | /* Define offsets into the call dummy for the _sr4export address. |
86 | See comments related to CALL_DUMMY for more info. */ | |
87 | #define SR4EXPORT_LDIL_OFFSET (INSTRUCTION_SIZE * 12) | |
88 | #define SR4EXPORT_LDO_OFFSET (INSTRUCTION_SIZE * 13) | |
89 | ||
c906108c SS |
90 | /* To support detection of the pseudo-initial frame |
91 | that threads have. */ | |
92 | #define THREAD_INITIAL_FRAME_SYMBOL "__pthread_exit" | |
93 | #define THREAD_INITIAL_FRAME_SYM_LEN sizeof(THREAD_INITIAL_FRAME_SYMBOL) | |
c5aa993b | 94 | |
e2ac8128 JB |
95 | /* Sizes (in bytes) of the native unwind entries. */ |
96 | #define UNWIND_ENTRY_SIZE 16 | |
97 | #define STUB_UNWIND_ENTRY_SIZE 8 | |
98 | ||
99 | static int get_field (unsigned word, int from, int to); | |
100 | ||
a14ed312 | 101 | static int extract_5_load (unsigned int); |
c906108c | 102 | |
a14ed312 | 103 | static unsigned extract_5R_store (unsigned int); |
c906108c | 104 | |
a14ed312 | 105 | static unsigned extract_5r_store (unsigned int); |
c906108c | 106 | |
a14ed312 | 107 | struct unwind_table_entry *find_unwind_entry (CORE_ADDR); |
c906108c | 108 | |
a14ed312 | 109 | static int extract_17 (unsigned int); |
c906108c | 110 | |
a14ed312 | 111 | static int extract_21 (unsigned); |
c906108c | 112 | |
a14ed312 | 113 | static int extract_14 (unsigned); |
c906108c | 114 | |
a14ed312 | 115 | static void unwind_command (char *, int); |
c906108c | 116 | |
a14ed312 | 117 | static int low_sign_extend (unsigned int, unsigned int); |
c906108c | 118 | |
a14ed312 | 119 | static int sign_extend (unsigned int, unsigned int); |
c906108c | 120 | |
a14ed312 | 121 | static int hppa_alignof (struct type *); |
c906108c | 122 | |
a14ed312 | 123 | static int prologue_inst_adjust_sp (unsigned long); |
c906108c | 124 | |
a14ed312 | 125 | static int is_branch (unsigned long); |
c906108c | 126 | |
a14ed312 | 127 | static int inst_saves_gr (unsigned long); |
c906108c | 128 | |
a14ed312 | 129 | static int inst_saves_fr (unsigned long); |
c906108c | 130 | |
a14ed312 | 131 | static int compare_unwind_entries (const void *, const void *); |
c906108c | 132 | |
a14ed312 | 133 | static void read_unwind_info (struct objfile *); |
c906108c | 134 | |
a14ed312 KB |
135 | static void internalize_unwinds (struct objfile *, |
136 | struct unwind_table_entry *, | |
137 | asection *, unsigned int, | |
138 | unsigned int, CORE_ADDR); | |
a14ed312 | 139 | static void record_text_segment_lowaddr (bfd *, asection *, void *); |
d709c020 JB |
140 | /* FIXME: brobecker 2002-11-07: We will likely be able to make the |
141 | following functions static, once we hppa is partially multiarched. */ | |
142 | int hppa_reg_struct_has_addr (int gcc_p, struct type *type); | |
60383d10 JB |
143 | CORE_ADDR hppa_skip_prologue (CORE_ADDR pc); |
144 | CORE_ADDR hppa_skip_trampoline_code (CORE_ADDR pc); | |
145 | int hppa_in_solib_call_trampoline (CORE_ADDR pc, char *name); | |
146 | int hppa_in_solib_return_trampoline (CORE_ADDR pc, char *name); | |
d709c020 | 147 | int hppa_inner_than (CORE_ADDR lhs, CORE_ADDR rhs); |
d709c020 JB |
148 | int hppa_pc_requires_run_before_use (CORE_ADDR pc); |
149 | int hppa_instruction_nullified (void); | |
d709c020 | 150 | int hppa_cannot_store_register (int regnum); |
d709c020 | 151 | CORE_ADDR hppa_smash_text_address (CORE_ADDR addr); |
60383d10 JB |
152 | CORE_ADDR hppa_target_read_pc (ptid_t ptid); |
153 | void hppa_target_write_pc (CORE_ADDR v, ptid_t ptid); | |
c906108c | 154 | |
c5aa993b JM |
155 | typedef struct |
156 | { | |
157 | struct minimal_symbol *msym; | |
158 | CORE_ADDR solib_handle; | |
a0b3c4fd | 159 | CORE_ADDR return_val; |
c5aa993b JM |
160 | } |
161 | args_for_find_stub; | |
c906108c | 162 | |
4efb68b1 | 163 | static int cover_find_stub_with_shl_get (void *); |
c906108c | 164 | |
c5aa993b | 165 | static int is_pa_2 = 0; /* False */ |
c906108c | 166 | |
c5aa993b | 167 | /* This is declared in symtab.c; set to 1 in hp-symtab-read.c */ |
c906108c SS |
168 | extern int hp_som_som_object_present; |
169 | ||
170 | /* In breakpoint.c */ | |
171 | extern int exception_catchpoints_are_fragile; | |
172 | ||
537987fc AC |
173 | /* Handle 32/64-bit struct return conventions. */ |
174 | ||
175 | static enum return_value_convention | |
176 | hppa32_return_value (struct gdbarch *gdbarch, | |
177 | struct type *type, struct regcache *regcache, | |
178 | void *readbuf, const void *writebuf) | |
179 | { | |
180 | if (TYPE_CODE (type) == TYPE_CODE_FLT) | |
181 | { | |
182 | if (readbuf != NULL) | |
183 | regcache_cooked_read_part (regcache, FP4_REGNUM, 0, | |
184 | TYPE_LENGTH (type), readbuf); | |
185 | if (writebuf != NULL) | |
186 | regcache_cooked_write_part (regcache, FP4_REGNUM, 0, | |
187 | TYPE_LENGTH (type), writebuf); | |
188 | return RETURN_VALUE_REGISTER_CONVENTION; | |
189 | } | |
190 | if (TYPE_LENGTH (type) <= 2 * 4) | |
191 | { | |
192 | /* The value always lives in the right hand end of the register | |
193 | (or register pair)? */ | |
194 | int b; | |
195 | int reg = 28; | |
196 | int part = TYPE_LENGTH (type) % 4; | |
197 | /* The left hand register contains only part of the value, | |
198 | transfer that first so that the rest can be xfered as entire | |
199 | 4-byte registers. */ | |
200 | if (part > 0) | |
201 | { | |
202 | if (readbuf != NULL) | |
203 | regcache_cooked_read_part (regcache, reg, 4 - part, | |
204 | part, readbuf); | |
205 | if (writebuf != NULL) | |
206 | regcache_cooked_write_part (regcache, reg, 4 - part, | |
207 | part, writebuf); | |
208 | reg++; | |
209 | } | |
210 | /* Now transfer the remaining register values. */ | |
211 | for (b = part; b < TYPE_LENGTH (type); b += 4) | |
212 | { | |
213 | if (readbuf != NULL) | |
214 | regcache_cooked_read (regcache, reg, (char *) readbuf + b); | |
215 | if (writebuf != NULL) | |
216 | regcache_cooked_write (regcache, reg, (const char *) writebuf + b); | |
217 | reg++; | |
218 | } | |
219 | return RETURN_VALUE_REGISTER_CONVENTION; | |
220 | } | |
221 | else | |
222 | return RETURN_VALUE_STRUCT_CONVENTION; | |
223 | } | |
224 | ||
225 | static enum return_value_convention | |
226 | hppa64_return_value (struct gdbarch *gdbarch, | |
227 | struct type *type, struct regcache *regcache, | |
228 | void *readbuf, const void *writebuf) | |
229 | { | |
230 | /* RM: Floats are returned in FR4R, doubles in FR4. Integral values | |
231 | are in r28, padded on the left. Aggregates less that 65 bits are | |
232 | in r28, right padded. Aggregates upto 128 bits are in r28 and | |
233 | r29, right padded. */ | |
449e1137 AC |
234 | if (TYPE_CODE (type) == TYPE_CODE_FLT |
235 | && TYPE_LENGTH (type) <= 8) | |
537987fc AC |
236 | { |
237 | /* Floats are right aligned? */ | |
238 | int offset = register_size (gdbarch, FP4_REGNUM) - TYPE_LENGTH (type); | |
239 | if (readbuf != NULL) | |
240 | regcache_cooked_read_part (regcache, FP4_REGNUM, offset, | |
241 | TYPE_LENGTH (type), readbuf); | |
242 | if (writebuf != NULL) | |
243 | regcache_cooked_write_part (regcache, FP4_REGNUM, offset, | |
244 | TYPE_LENGTH (type), writebuf); | |
245 | return RETURN_VALUE_REGISTER_CONVENTION; | |
246 | } | |
247 | else if (TYPE_LENGTH (type) <= 8 && is_integral_type (type)) | |
248 | { | |
249 | /* Integrals are right aligned. */ | |
250 | int offset = register_size (gdbarch, FP4_REGNUM) - TYPE_LENGTH (type); | |
251 | if (readbuf != NULL) | |
252 | regcache_cooked_read_part (regcache, 28, offset, | |
253 | TYPE_LENGTH (type), readbuf); | |
254 | if (writebuf != NULL) | |
255 | regcache_cooked_write_part (regcache, 28, offset, | |
256 | TYPE_LENGTH (type), writebuf); | |
257 | return RETURN_VALUE_REGISTER_CONVENTION; | |
258 | } | |
259 | else if (TYPE_LENGTH (type) <= 2 * 8) | |
260 | { | |
261 | /* Composite values are left aligned. */ | |
262 | int b; | |
263 | for (b = 0; b < TYPE_LENGTH (type); b += 8) | |
264 | { | |
449e1137 | 265 | int part = min (8, TYPE_LENGTH (type) - b); |
537987fc | 266 | if (readbuf != NULL) |
449e1137 | 267 | regcache_cooked_read_part (regcache, 28 + b / 8, 0, part, |
537987fc AC |
268 | (char *) readbuf + b); |
269 | if (writebuf != NULL) | |
449e1137 | 270 | regcache_cooked_write_part (regcache, 28 + b / 8, 0, part, |
537987fc AC |
271 | (const char *) writebuf + b); |
272 | } | |
449e1137 | 273 | return RETURN_VALUE_REGISTER_CONVENTION; |
537987fc AC |
274 | } |
275 | else | |
276 | return RETURN_VALUE_STRUCT_CONVENTION; | |
277 | } | |
278 | ||
c906108c SS |
279 | /* Routines to extract various sized constants out of hppa |
280 | instructions. */ | |
281 | ||
282 | /* This assumes that no garbage lies outside of the lower bits of | |
283 | value. */ | |
284 | ||
285 | static int | |
fba45db2 | 286 | sign_extend (unsigned val, unsigned bits) |
c906108c | 287 | { |
c5aa993b | 288 | return (int) (val >> (bits - 1) ? (-1 << bits) | val : val); |
c906108c SS |
289 | } |
290 | ||
291 | /* For many immediate values the sign bit is the low bit! */ | |
292 | ||
293 | static int | |
fba45db2 | 294 | low_sign_extend (unsigned val, unsigned bits) |
c906108c | 295 | { |
c5aa993b | 296 | return (int) ((val & 0x1 ? (-1 << (bits - 1)) : 0) | val >> 1); |
c906108c SS |
297 | } |
298 | ||
e2ac8128 JB |
299 | /* Extract the bits at positions between FROM and TO, using HP's numbering |
300 | (MSB = 0). */ | |
301 | ||
302 | static int | |
303 | get_field (unsigned word, int from, int to) | |
304 | { | |
305 | return ((word) >> (31 - (to)) & ((1 << ((to) - (from) + 1)) - 1)); | |
306 | } | |
307 | ||
c906108c SS |
308 | /* extract the immediate field from a ld{bhw}s instruction */ |
309 | ||
c906108c | 310 | static int |
fba45db2 | 311 | extract_5_load (unsigned word) |
c906108c SS |
312 | { |
313 | return low_sign_extend (word >> 16 & MASK_5, 5); | |
314 | } | |
315 | ||
c906108c SS |
316 | /* extract the immediate field from a break instruction */ |
317 | ||
318 | static unsigned | |
fba45db2 | 319 | extract_5r_store (unsigned word) |
c906108c SS |
320 | { |
321 | return (word & MASK_5); | |
322 | } | |
323 | ||
324 | /* extract the immediate field from a {sr}sm instruction */ | |
325 | ||
326 | static unsigned | |
fba45db2 | 327 | extract_5R_store (unsigned word) |
c906108c SS |
328 | { |
329 | return (word >> 16 & MASK_5); | |
330 | } | |
331 | ||
c906108c SS |
332 | /* extract a 14 bit immediate field */ |
333 | ||
334 | static int | |
fba45db2 | 335 | extract_14 (unsigned word) |
c906108c SS |
336 | { |
337 | return low_sign_extend (word & MASK_14, 14); | |
338 | } | |
339 | ||
c906108c SS |
340 | /* extract a 21 bit constant */ |
341 | ||
342 | static int | |
fba45db2 | 343 | extract_21 (unsigned word) |
c906108c SS |
344 | { |
345 | int val; | |
346 | ||
347 | word &= MASK_21; | |
348 | word <<= 11; | |
e2ac8128 | 349 | val = get_field (word, 20, 20); |
c906108c | 350 | val <<= 11; |
e2ac8128 | 351 | val |= get_field (word, 9, 19); |
c906108c | 352 | val <<= 2; |
e2ac8128 | 353 | val |= get_field (word, 5, 6); |
c906108c | 354 | val <<= 5; |
e2ac8128 | 355 | val |= get_field (word, 0, 4); |
c906108c | 356 | val <<= 2; |
e2ac8128 | 357 | val |= get_field (word, 7, 8); |
c906108c SS |
358 | return sign_extend (val, 21) << 11; |
359 | } | |
360 | ||
c906108c SS |
361 | /* extract a 17 bit constant from branch instructions, returning the |
362 | 19 bit signed value. */ | |
363 | ||
364 | static int | |
fba45db2 | 365 | extract_17 (unsigned word) |
c906108c | 366 | { |
e2ac8128 JB |
367 | return sign_extend (get_field (word, 19, 28) | |
368 | get_field (word, 29, 29) << 10 | | |
369 | get_field (word, 11, 15) << 11 | | |
c906108c SS |
370 | (word & 0x1) << 16, 17) << 2; |
371 | } | |
372 | \f | |
373 | ||
374 | /* Compare the start address for two unwind entries returning 1 if | |
375 | the first address is larger than the second, -1 if the second is | |
376 | larger than the first, and zero if they are equal. */ | |
377 | ||
378 | static int | |
fba45db2 | 379 | compare_unwind_entries (const void *arg1, const void *arg2) |
c906108c SS |
380 | { |
381 | const struct unwind_table_entry *a = arg1; | |
382 | const struct unwind_table_entry *b = arg2; | |
383 | ||
384 | if (a->region_start > b->region_start) | |
385 | return 1; | |
386 | else if (a->region_start < b->region_start) | |
387 | return -1; | |
388 | else | |
389 | return 0; | |
390 | } | |
391 | ||
53a5351d JM |
392 | static CORE_ADDR low_text_segment_address; |
393 | ||
394 | static void | |
8fef05cc | 395 | record_text_segment_lowaddr (bfd *abfd, asection *section, void *ignored) |
53a5351d | 396 | { |
bf9c25dc | 397 | if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY)) |
53a5351d JM |
398 | == (SEC_ALLOC | SEC_LOAD | SEC_READONLY)) |
399 | && section->vma < low_text_segment_address) | |
400 | low_text_segment_address = section->vma; | |
401 | } | |
402 | ||
c906108c | 403 | static void |
fba45db2 KB |
404 | internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table, |
405 | asection *section, unsigned int entries, unsigned int size, | |
406 | CORE_ADDR text_offset) | |
c906108c SS |
407 | { |
408 | /* We will read the unwind entries into temporary memory, then | |
409 | fill in the actual unwind table. */ | |
410 | if (size > 0) | |
411 | { | |
412 | unsigned long tmp; | |
413 | unsigned i; | |
414 | char *buf = alloca (size); | |
415 | ||
53a5351d JM |
416 | low_text_segment_address = -1; |
417 | ||
418 | /* If addresses are 64 bits wide, then unwinds are supposed to | |
c2c6d25f JM |
419 | be segment relative offsets instead of absolute addresses. |
420 | ||
421 | Note that when loading a shared library (text_offset != 0) the | |
422 | unwinds are already relative to the text_offset that will be | |
423 | passed in. */ | |
424 | if (TARGET_PTR_BIT == 64 && text_offset == 0) | |
53a5351d JM |
425 | { |
426 | bfd_map_over_sections (objfile->obfd, | |
4efb68b1 | 427 | record_text_segment_lowaddr, NULL); |
53a5351d JM |
428 | |
429 | /* ?!? Mask off some low bits. Should this instead subtract | |
430 | out the lowest section's filepos or something like that? | |
431 | This looks very hokey to me. */ | |
432 | low_text_segment_address &= ~0xfff; | |
433 | text_offset += low_text_segment_address; | |
434 | } | |
435 | ||
c906108c SS |
436 | bfd_get_section_contents (objfile->obfd, section, buf, 0, size); |
437 | ||
438 | /* Now internalize the information being careful to handle host/target | |
c5aa993b | 439 | endian issues. */ |
c906108c SS |
440 | for (i = 0; i < entries; i++) |
441 | { | |
442 | table[i].region_start = bfd_get_32 (objfile->obfd, | |
c5aa993b | 443 | (bfd_byte *) buf); |
c906108c SS |
444 | table[i].region_start += text_offset; |
445 | buf += 4; | |
c5aa993b | 446 | table[i].region_end = bfd_get_32 (objfile->obfd, (bfd_byte *) buf); |
c906108c SS |
447 | table[i].region_end += text_offset; |
448 | buf += 4; | |
c5aa993b | 449 | tmp = bfd_get_32 (objfile->obfd, (bfd_byte *) buf); |
c906108c SS |
450 | buf += 4; |
451 | table[i].Cannot_unwind = (tmp >> 31) & 0x1; | |
452 | table[i].Millicode = (tmp >> 30) & 0x1; | |
453 | table[i].Millicode_save_sr0 = (tmp >> 29) & 0x1; | |
454 | table[i].Region_description = (tmp >> 27) & 0x3; | |
455 | table[i].reserved1 = (tmp >> 26) & 0x1; | |
456 | table[i].Entry_SR = (tmp >> 25) & 0x1; | |
457 | table[i].Entry_FR = (tmp >> 21) & 0xf; | |
458 | table[i].Entry_GR = (tmp >> 16) & 0x1f; | |
459 | table[i].Args_stored = (tmp >> 15) & 0x1; | |
460 | table[i].Variable_Frame = (tmp >> 14) & 0x1; | |
461 | table[i].Separate_Package_Body = (tmp >> 13) & 0x1; | |
462 | table[i].Frame_Extension_Millicode = (tmp >> 12) & 0x1; | |
463 | table[i].Stack_Overflow_Check = (tmp >> 11) & 0x1; | |
464 | table[i].Two_Instruction_SP_Increment = (tmp >> 10) & 0x1; | |
465 | table[i].Ada_Region = (tmp >> 9) & 0x1; | |
466 | table[i].cxx_info = (tmp >> 8) & 0x1; | |
467 | table[i].cxx_try_catch = (tmp >> 7) & 0x1; | |
468 | table[i].sched_entry_seq = (tmp >> 6) & 0x1; | |
469 | table[i].reserved2 = (tmp >> 5) & 0x1; | |
470 | table[i].Save_SP = (tmp >> 4) & 0x1; | |
471 | table[i].Save_RP = (tmp >> 3) & 0x1; | |
472 | table[i].Save_MRP_in_frame = (tmp >> 2) & 0x1; | |
473 | table[i].extn_ptr_defined = (tmp >> 1) & 0x1; | |
474 | table[i].Cleanup_defined = tmp & 0x1; | |
c5aa993b | 475 | tmp = bfd_get_32 (objfile->obfd, (bfd_byte *) buf); |
c906108c SS |
476 | buf += 4; |
477 | table[i].MPE_XL_interrupt_marker = (tmp >> 31) & 0x1; | |
478 | table[i].HP_UX_interrupt_marker = (tmp >> 30) & 0x1; | |
479 | table[i].Large_frame = (tmp >> 29) & 0x1; | |
480 | table[i].Pseudo_SP_Set = (tmp >> 28) & 0x1; | |
481 | table[i].reserved4 = (tmp >> 27) & 0x1; | |
482 | table[i].Total_frame_size = tmp & 0x7ffffff; | |
483 | ||
c5aa993b | 484 | /* Stub unwinds are handled elsewhere. */ |
c906108c SS |
485 | table[i].stub_unwind.stub_type = 0; |
486 | table[i].stub_unwind.padding = 0; | |
487 | } | |
488 | } | |
489 | } | |
490 | ||
491 | /* Read in the backtrace information stored in the `$UNWIND_START$' section of | |
492 | the object file. This info is used mainly by find_unwind_entry() to find | |
493 | out the stack frame size and frame pointer used by procedures. We put | |
494 | everything on the psymbol obstack in the objfile so that it automatically | |
495 | gets freed when the objfile is destroyed. */ | |
496 | ||
497 | static void | |
fba45db2 | 498 | read_unwind_info (struct objfile *objfile) |
c906108c | 499 | { |
d4f3574e SS |
500 | asection *unwind_sec, *stub_unwind_sec; |
501 | unsigned unwind_size, stub_unwind_size, total_size; | |
502 | unsigned index, unwind_entries; | |
c906108c SS |
503 | unsigned stub_entries, total_entries; |
504 | CORE_ADDR text_offset; | |
505 | struct obj_unwind_info *ui; | |
506 | obj_private_data_t *obj_private; | |
507 | ||
508 | text_offset = ANOFFSET (objfile->section_offsets, 0); | |
8b92e4d5 | 509 | ui = (struct obj_unwind_info *) obstack_alloc (&objfile->objfile_obstack, |
c5aa993b | 510 | sizeof (struct obj_unwind_info)); |
c906108c SS |
511 | |
512 | ui->table = NULL; | |
513 | ui->cache = NULL; | |
514 | ui->last = -1; | |
515 | ||
d4f3574e SS |
516 | /* For reasons unknown the HP PA64 tools generate multiple unwinder |
517 | sections in a single executable. So we just iterate over every | |
518 | section in the BFD looking for unwinder sections intead of trying | |
519 | to do a lookup with bfd_get_section_by_name. | |
c906108c | 520 | |
d4f3574e SS |
521 | First determine the total size of the unwind tables so that we |
522 | can allocate memory in a nice big hunk. */ | |
523 | total_entries = 0; | |
524 | for (unwind_sec = objfile->obfd->sections; | |
525 | unwind_sec; | |
526 | unwind_sec = unwind_sec->next) | |
c906108c | 527 | { |
d4f3574e SS |
528 | if (strcmp (unwind_sec->name, "$UNWIND_START$") == 0 |
529 | || strcmp (unwind_sec->name, ".PARISC.unwind") == 0) | |
530 | { | |
531 | unwind_size = bfd_section_size (objfile->obfd, unwind_sec); | |
532 | unwind_entries = unwind_size / UNWIND_ENTRY_SIZE; | |
c906108c | 533 | |
d4f3574e SS |
534 | total_entries += unwind_entries; |
535 | } | |
c906108c SS |
536 | } |
537 | ||
d4f3574e SS |
538 | /* Now compute the size of the stub unwinds. Note the ELF tools do not |
539 | use stub unwinds at the curren time. */ | |
540 | stub_unwind_sec = bfd_get_section_by_name (objfile->obfd, "$UNWIND_END$"); | |
541 | ||
c906108c SS |
542 | if (stub_unwind_sec) |
543 | { | |
544 | stub_unwind_size = bfd_section_size (objfile->obfd, stub_unwind_sec); | |
545 | stub_entries = stub_unwind_size / STUB_UNWIND_ENTRY_SIZE; | |
546 | } | |
547 | else | |
548 | { | |
549 | stub_unwind_size = 0; | |
550 | stub_entries = 0; | |
551 | } | |
552 | ||
553 | /* Compute total number of unwind entries and their total size. */ | |
d4f3574e | 554 | total_entries += stub_entries; |
c906108c SS |
555 | total_size = total_entries * sizeof (struct unwind_table_entry); |
556 | ||
557 | /* Allocate memory for the unwind table. */ | |
558 | ui->table = (struct unwind_table_entry *) | |
8b92e4d5 | 559 | obstack_alloc (&objfile->objfile_obstack, total_size); |
c5aa993b | 560 | ui->last = total_entries - 1; |
c906108c | 561 | |
d4f3574e SS |
562 | /* Now read in each unwind section and internalize the standard unwind |
563 | entries. */ | |
c906108c | 564 | index = 0; |
d4f3574e SS |
565 | for (unwind_sec = objfile->obfd->sections; |
566 | unwind_sec; | |
567 | unwind_sec = unwind_sec->next) | |
568 | { | |
569 | if (strcmp (unwind_sec->name, "$UNWIND_START$") == 0 | |
570 | || strcmp (unwind_sec->name, ".PARISC.unwind") == 0) | |
571 | { | |
572 | unwind_size = bfd_section_size (objfile->obfd, unwind_sec); | |
573 | unwind_entries = unwind_size / UNWIND_ENTRY_SIZE; | |
574 | ||
575 | internalize_unwinds (objfile, &ui->table[index], unwind_sec, | |
576 | unwind_entries, unwind_size, text_offset); | |
577 | index += unwind_entries; | |
578 | } | |
579 | } | |
580 | ||
581 | /* Now read in and internalize the stub unwind entries. */ | |
c906108c SS |
582 | if (stub_unwind_size > 0) |
583 | { | |
584 | unsigned int i; | |
585 | char *buf = alloca (stub_unwind_size); | |
586 | ||
587 | /* Read in the stub unwind entries. */ | |
588 | bfd_get_section_contents (objfile->obfd, stub_unwind_sec, buf, | |
589 | 0, stub_unwind_size); | |
590 | ||
591 | /* Now convert them into regular unwind entries. */ | |
592 | for (i = 0; i < stub_entries; i++, index++) | |
593 | { | |
594 | /* Clear out the next unwind entry. */ | |
595 | memset (&ui->table[index], 0, sizeof (struct unwind_table_entry)); | |
596 | ||
597 | /* Convert offset & size into region_start and region_end. | |
598 | Stuff away the stub type into "reserved" fields. */ | |
599 | ui->table[index].region_start = bfd_get_32 (objfile->obfd, | |
600 | (bfd_byte *) buf); | |
601 | ui->table[index].region_start += text_offset; | |
602 | buf += 4; | |
603 | ui->table[index].stub_unwind.stub_type = bfd_get_8 (objfile->obfd, | |
c5aa993b | 604 | (bfd_byte *) buf); |
c906108c SS |
605 | buf += 2; |
606 | ui->table[index].region_end | |
c5aa993b JM |
607 | = ui->table[index].region_start + 4 * |
608 | (bfd_get_16 (objfile->obfd, (bfd_byte *) buf) - 1); | |
c906108c SS |
609 | buf += 2; |
610 | } | |
611 | ||
612 | } | |
613 | ||
614 | /* Unwind table needs to be kept sorted. */ | |
615 | qsort (ui->table, total_entries, sizeof (struct unwind_table_entry), | |
616 | compare_unwind_entries); | |
617 | ||
618 | /* Keep a pointer to the unwind information. */ | |
c5aa993b | 619 | if (objfile->obj_private == NULL) |
c906108c SS |
620 | { |
621 | obj_private = (obj_private_data_t *) | |
8b92e4d5 | 622 | obstack_alloc (&objfile->objfile_obstack, |
c5aa993b | 623 | sizeof (obj_private_data_t)); |
c906108c | 624 | obj_private->unwind_info = NULL; |
c5aa993b | 625 | obj_private->so_info = NULL; |
53a5351d | 626 | obj_private->dp = 0; |
c5aa993b | 627 | |
4efb68b1 | 628 | objfile->obj_private = obj_private; |
c906108c | 629 | } |
c5aa993b | 630 | obj_private = (obj_private_data_t *) objfile->obj_private; |
c906108c SS |
631 | obj_private->unwind_info = ui; |
632 | } | |
633 | ||
634 | /* Lookup the unwind (stack backtrace) info for the given PC. We search all | |
635 | of the objfiles seeking the unwind table entry for this PC. Each objfile | |
636 | contains a sorted list of struct unwind_table_entry. Since we do a binary | |
637 | search of the unwind tables, we depend upon them to be sorted. */ | |
638 | ||
639 | struct unwind_table_entry * | |
fba45db2 | 640 | find_unwind_entry (CORE_ADDR pc) |
c906108c SS |
641 | { |
642 | int first, middle, last; | |
643 | struct objfile *objfile; | |
644 | ||
645 | /* A function at address 0? Not in HP-UX! */ | |
646 | if (pc == (CORE_ADDR) 0) | |
647 | return NULL; | |
648 | ||
649 | ALL_OBJFILES (objfile) | |
c5aa993b JM |
650 | { |
651 | struct obj_unwind_info *ui; | |
652 | ui = NULL; | |
653 | if (objfile->obj_private) | |
654 | ui = ((obj_private_data_t *) (objfile->obj_private))->unwind_info; | |
c906108c | 655 | |
c5aa993b JM |
656 | if (!ui) |
657 | { | |
658 | read_unwind_info (objfile); | |
659 | if (objfile->obj_private == NULL) | |
104c1213 | 660 | error ("Internal error reading unwind information."); |
c5aa993b JM |
661 | ui = ((obj_private_data_t *) (objfile->obj_private))->unwind_info; |
662 | } | |
c906108c | 663 | |
c5aa993b | 664 | /* First, check the cache */ |
c906108c | 665 | |
c5aa993b JM |
666 | if (ui->cache |
667 | && pc >= ui->cache->region_start | |
668 | && pc <= ui->cache->region_end) | |
669 | return ui->cache; | |
c906108c | 670 | |
c5aa993b | 671 | /* Not in the cache, do a binary search */ |
c906108c | 672 | |
c5aa993b JM |
673 | first = 0; |
674 | last = ui->last; | |
c906108c | 675 | |
c5aa993b JM |
676 | while (first <= last) |
677 | { | |
678 | middle = (first + last) / 2; | |
679 | if (pc >= ui->table[middle].region_start | |
680 | && pc <= ui->table[middle].region_end) | |
681 | { | |
682 | ui->cache = &ui->table[middle]; | |
683 | return &ui->table[middle]; | |
684 | } | |
c906108c | 685 | |
c5aa993b JM |
686 | if (pc < ui->table[middle].region_start) |
687 | last = middle - 1; | |
688 | else | |
689 | first = middle + 1; | |
690 | } | |
691 | } /* ALL_OBJFILES() */ | |
c906108c SS |
692 | return NULL; |
693 | } | |
694 | ||
aaab4dba AC |
695 | const unsigned char * |
696 | hppa_breakpoint_from_pc (CORE_ADDR *pc, int *len) | |
697 | { | |
56132691 | 698 | static const unsigned char breakpoint[] = {0x00, 0x01, 0x00, 0x04}; |
aaab4dba AC |
699 | (*len) = sizeof (breakpoint); |
700 | return breakpoint; | |
701 | } | |
702 | ||
e23457df AC |
703 | /* Return the name of a register. */ |
704 | ||
705 | const char * | |
3ff7cf9e | 706 | hppa32_register_name (int i) |
e23457df AC |
707 | { |
708 | static char *names[] = { | |
709 | "flags", "r1", "rp", "r3", | |
710 | "r4", "r5", "r6", "r7", | |
711 | "r8", "r9", "r10", "r11", | |
712 | "r12", "r13", "r14", "r15", | |
713 | "r16", "r17", "r18", "r19", | |
714 | "r20", "r21", "r22", "r23", | |
715 | "r24", "r25", "r26", "dp", | |
716 | "ret0", "ret1", "sp", "r31", | |
717 | "sar", "pcoqh", "pcsqh", "pcoqt", | |
718 | "pcsqt", "eiem", "iir", "isr", | |
719 | "ior", "ipsw", "goto", "sr4", | |
720 | "sr0", "sr1", "sr2", "sr3", | |
721 | "sr5", "sr6", "sr7", "cr0", | |
722 | "cr8", "cr9", "ccr", "cr12", | |
723 | "cr13", "cr24", "cr25", "cr26", | |
724 | "mpsfu_high","mpsfu_low","mpsfu_ovflo","pad", | |
725 | "fpsr", "fpe1", "fpe2", "fpe3", | |
726 | "fpe4", "fpe5", "fpe6", "fpe7", | |
727 | "fr4", "fr4R", "fr5", "fr5R", | |
728 | "fr6", "fr6R", "fr7", "fr7R", | |
729 | "fr8", "fr8R", "fr9", "fr9R", | |
730 | "fr10", "fr10R", "fr11", "fr11R", | |
731 | "fr12", "fr12R", "fr13", "fr13R", | |
732 | "fr14", "fr14R", "fr15", "fr15R", | |
733 | "fr16", "fr16R", "fr17", "fr17R", | |
734 | "fr18", "fr18R", "fr19", "fr19R", | |
735 | "fr20", "fr20R", "fr21", "fr21R", | |
736 | "fr22", "fr22R", "fr23", "fr23R", | |
737 | "fr24", "fr24R", "fr25", "fr25R", | |
738 | "fr26", "fr26R", "fr27", "fr27R", | |
739 | "fr28", "fr28R", "fr29", "fr29R", | |
740 | "fr30", "fr30R", "fr31", "fr31R" | |
741 | }; | |
742 | if (i < 0 || i >= (sizeof (names) / sizeof (*names))) | |
743 | return NULL; | |
744 | else | |
745 | return names[i]; | |
746 | } | |
747 | ||
748 | const char * | |
749 | hppa64_register_name (int i) | |
750 | { | |
751 | static char *names[] = { | |
752 | "flags", "r1", "rp", "r3", | |
753 | "r4", "r5", "r6", "r7", | |
754 | "r8", "r9", "r10", "r11", | |
755 | "r12", "r13", "r14", "r15", | |
756 | "r16", "r17", "r18", "r19", | |
757 | "r20", "r21", "r22", "r23", | |
758 | "r24", "r25", "r26", "dp", | |
759 | "ret0", "ret1", "sp", "r31", | |
760 | "sar", "pcoqh", "pcsqh", "pcoqt", | |
761 | "pcsqt", "eiem", "iir", "isr", | |
762 | "ior", "ipsw", "goto", "sr4", | |
763 | "sr0", "sr1", "sr2", "sr3", | |
764 | "sr5", "sr6", "sr7", "cr0", | |
765 | "cr8", "cr9", "ccr", "cr12", | |
766 | "cr13", "cr24", "cr25", "cr26", | |
767 | "mpsfu_high","mpsfu_low","mpsfu_ovflo","pad", | |
768 | "fpsr", "fpe1", "fpe2", "fpe3", | |
769 | "fr4", "fr5", "fr6", "fr7", | |
770 | "fr8", "fr9", "fr10", "fr11", | |
771 | "fr12", "fr13", "fr14", "fr15", | |
772 | "fr16", "fr17", "fr18", "fr19", | |
773 | "fr20", "fr21", "fr22", "fr23", | |
774 | "fr24", "fr25", "fr26", "fr27", | |
775 | "fr28", "fr29", "fr30", "fr31" | |
776 | }; | |
777 | if (i < 0 || i >= (sizeof (names) / sizeof (*names))) | |
778 | return NULL; | |
779 | else | |
780 | return names[i]; | |
781 | } | |
782 | ||
783 | ||
784 | ||
c906108c SS |
785 | /* Return the adjustment necessary to make for addresses on the stack |
786 | as presented by hpread.c. | |
787 | ||
788 | This is necessary because of the stack direction on the PA and the | |
78161e48 AC |
789 | bizarre way in which someone (?) decided they wanted to handle |
790 | frame pointerless code in GDB. */ | |
791 | int | |
792 | hpread_adjust_stack_address (CORE_ADDR func_addr) | |
793 | { | |
794 | struct unwind_table_entry *u; | |
c906108c | 795 | |
78161e48 AC |
796 | u = find_unwind_entry (func_addr); |
797 | if (!u) | |
798 | return 0; | |
799 | else | |
800 | return u->Total_frame_size << 3; | |
c906108c SS |
801 | } |
802 | ||
79508e1e AC |
803 | /* This function pushes a stack frame with arguments as part of the |
804 | inferior function calling mechanism. | |
805 | ||
806 | This is the version of the function for the 32-bit PA machines, in | |
807 | which later arguments appear at lower addresses. (The stack always | |
808 | grows towards higher addresses.) | |
809 | ||
810 | We simply allocate the appropriate amount of stack space and put | |
811 | arguments into their proper slots. */ | |
812 | ||
813 | CORE_ADDR | |
814 | hppa32_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr, | |
815 | struct regcache *regcache, CORE_ADDR bp_addr, | |
816 | int nargs, struct value **args, CORE_ADDR sp, | |
817 | int struct_return, CORE_ADDR struct_addr) | |
818 | { | |
819 | /* NOTE: cagney/2004-02-27: This is a guess - its implemented by | |
820 | reverse engineering testsuite failures. */ | |
821 | ||
822 | /* Stack base address at which any pass-by-reference parameters are | |
823 | stored. */ | |
824 | CORE_ADDR struct_end = 0; | |
825 | /* Stack base address at which the first parameter is stored. */ | |
826 | CORE_ADDR param_end = 0; | |
827 | ||
828 | /* The inner most end of the stack after all the parameters have | |
829 | been pushed. */ | |
830 | CORE_ADDR new_sp = 0; | |
831 | ||
832 | /* Two passes. First pass computes the location of everything, | |
833 | second pass writes the bytes out. */ | |
834 | int write_pass; | |
835 | for (write_pass = 0; write_pass < 2; write_pass++) | |
836 | { | |
1797a8f6 AC |
837 | CORE_ADDR struct_ptr = 0; |
838 | CORE_ADDR param_ptr = 0; | |
79508e1e AC |
839 | int reg = 27; /* NOTE: Registers go down. */ |
840 | int i; | |
841 | for (i = 0; i < nargs; i++) | |
842 | { | |
843 | struct value *arg = args[i]; | |
844 | struct type *type = check_typedef (VALUE_TYPE (arg)); | |
845 | /* The corresponding parameter that is pushed onto the | |
846 | stack, and [possibly] passed in a register. */ | |
847 | char param_val[8]; | |
848 | int param_len; | |
849 | memset (param_val, 0, sizeof param_val); | |
850 | if (TYPE_LENGTH (type) > 8) | |
851 | { | |
852 | /* Large parameter, pass by reference. Store the value | |
853 | in "struct" area and then pass its address. */ | |
854 | param_len = 4; | |
1797a8f6 | 855 | struct_ptr += align_up (TYPE_LENGTH (type), 8); |
79508e1e | 856 | if (write_pass) |
1797a8f6 | 857 | write_memory (struct_end - struct_ptr, VALUE_CONTENTS (arg), |
79508e1e | 858 | TYPE_LENGTH (type)); |
1797a8f6 | 859 | store_unsigned_integer (param_val, 4, struct_end - struct_ptr); |
79508e1e AC |
860 | } |
861 | else if (TYPE_CODE (type) == TYPE_CODE_INT | |
862 | || TYPE_CODE (type) == TYPE_CODE_ENUM) | |
863 | { | |
864 | /* Integer value store, right aligned. "unpack_long" | |
865 | takes care of any sign-extension problems. */ | |
866 | param_len = align_up (TYPE_LENGTH (type), 4); | |
867 | store_unsigned_integer (param_val, param_len, | |
868 | unpack_long (type, | |
869 | VALUE_CONTENTS (arg))); | |
870 | } | |
871 | else | |
872 | { | |
873 | /* Small struct value, store right aligned? */ | |
874 | param_len = align_up (TYPE_LENGTH (type), 4); | |
875 | memcpy (param_val + param_len - TYPE_LENGTH (type), | |
876 | VALUE_CONTENTS (arg), TYPE_LENGTH (type)); | |
877 | } | |
1797a8f6 | 878 | param_ptr += param_len; |
79508e1e AC |
879 | reg -= param_len / 4; |
880 | if (write_pass) | |
881 | { | |
1797a8f6 | 882 | write_memory (param_end - param_ptr, param_val, param_len); |
79508e1e AC |
883 | if (reg >= 23) |
884 | { | |
885 | regcache_cooked_write (regcache, reg, param_val); | |
886 | if (param_len > 4) | |
887 | regcache_cooked_write (regcache, reg + 1, param_val + 4); | |
888 | } | |
889 | } | |
890 | } | |
891 | ||
892 | /* Update the various stack pointers. */ | |
893 | if (!write_pass) | |
894 | { | |
895 | struct_end = sp + struct_ptr; | |
896 | /* PARAM_PTR already accounts for all the arguments passed | |
897 | by the user. However, the ABI mandates minimum stack | |
898 | space allocations for outgoing arguments. The ABI also | |
899 | mandates minimum stack alignments which we must | |
900 | preserve. */ | |
d0bd2d18 | 901 | param_end = struct_end + max (align_up (param_ptr, 8), 16); |
79508e1e AC |
902 | } |
903 | } | |
904 | ||
905 | /* If a structure has to be returned, set up register 28 to hold its | |
906 | address */ | |
907 | if (struct_return) | |
908 | write_register (28, struct_addr); | |
909 | ||
910 | /* Set the return address. */ | |
911 | regcache_cooked_write_unsigned (regcache, RP_REGNUM, bp_addr); | |
912 | ||
c4557624 JB |
913 | /* Update the Stack Pointer. */ |
914 | regcache_cooked_write_unsigned (regcache, SP_REGNUM, param_end + 32); | |
915 | ||
79508e1e AC |
916 | /* The stack will have 32 bytes of additional space for a frame marker. */ |
917 | return param_end + 32; | |
918 | } | |
919 | ||
2f690297 AC |
920 | /* This function pushes a stack frame with arguments as part of the |
921 | inferior function calling mechanism. | |
922 | ||
923 | This is the version for the PA64, in which later arguments appear | |
924 | at higher addresses. (The stack always grows towards higher | |
925 | addresses.) | |
926 | ||
927 | We simply allocate the appropriate amount of stack space and put | |
928 | arguments into their proper slots. | |
929 | ||
930 | This ABI also requires that the caller provide an argument pointer | |
931 | to the callee, so we do that too. */ | |
932 | ||
933 | CORE_ADDR | |
934 | hppa64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr, | |
935 | struct regcache *regcache, CORE_ADDR bp_addr, | |
936 | int nargs, struct value **args, CORE_ADDR sp, | |
937 | int struct_return, CORE_ADDR struct_addr) | |
938 | { | |
449e1137 AC |
939 | /* NOTE: cagney/2004-02-27: This is a guess - its implemented by |
940 | reverse engineering testsuite failures. */ | |
2f690297 | 941 | |
449e1137 AC |
942 | /* Stack base address at which any pass-by-reference parameters are |
943 | stored. */ | |
944 | CORE_ADDR struct_end = 0; | |
945 | /* Stack base address at which the first parameter is stored. */ | |
946 | CORE_ADDR param_end = 0; | |
2f690297 | 947 | |
449e1137 AC |
948 | /* The inner most end of the stack after all the parameters have |
949 | been pushed. */ | |
950 | CORE_ADDR new_sp = 0; | |
2f690297 | 951 | |
449e1137 AC |
952 | /* Two passes. First pass computes the location of everything, |
953 | second pass writes the bytes out. */ | |
954 | int write_pass; | |
955 | for (write_pass = 0; write_pass < 2; write_pass++) | |
2f690297 | 956 | { |
449e1137 AC |
957 | CORE_ADDR struct_ptr = 0; |
958 | CORE_ADDR param_ptr = 0; | |
959 | int i; | |
960 | for (i = 0; i < nargs; i++) | |
2f690297 | 961 | { |
449e1137 AC |
962 | struct value *arg = args[i]; |
963 | struct type *type = check_typedef (VALUE_TYPE (arg)); | |
964 | if ((TYPE_CODE (type) == TYPE_CODE_INT | |
965 | || TYPE_CODE (type) == TYPE_CODE_ENUM) | |
966 | && TYPE_LENGTH (type) <= 8) | |
967 | { | |
968 | /* Integer value store, right aligned. "unpack_long" | |
969 | takes care of any sign-extension problems. */ | |
970 | param_ptr += 8; | |
971 | if (write_pass) | |
972 | { | |
973 | ULONGEST val = unpack_long (type, VALUE_CONTENTS (arg)); | |
974 | int reg = 27 - param_ptr / 8; | |
975 | write_memory_unsigned_integer (param_end - param_ptr, | |
976 | val, 8); | |
977 | if (reg >= 19) | |
978 | regcache_cooked_write_unsigned (regcache, reg, val); | |
979 | } | |
980 | } | |
981 | else | |
982 | { | |
983 | /* Small struct value, store left aligned? */ | |
984 | int reg; | |
985 | if (TYPE_LENGTH (type) > 8) | |
986 | { | |
987 | param_ptr = align_up (param_ptr, 16); | |
988 | reg = 26 - param_ptr / 8; | |
989 | param_ptr += align_up (TYPE_LENGTH (type), 16); | |
990 | } | |
991 | else | |
992 | { | |
993 | param_ptr = align_up (param_ptr, 8); | |
994 | reg = 26 - param_ptr / 8; | |
995 | param_ptr += align_up (TYPE_LENGTH (type), 8); | |
996 | } | |
997 | if (write_pass) | |
998 | { | |
999 | int byte; | |
1000 | write_memory (param_end - param_ptr, VALUE_CONTENTS (arg), | |
1001 | TYPE_LENGTH (type)); | |
1002 | for (byte = 0; byte < TYPE_LENGTH (type); byte += 8) | |
1003 | { | |
1004 | if (reg >= 19) | |
1005 | { | |
1006 | int len = min (8, TYPE_LENGTH (type) - byte); | |
1007 | regcache_cooked_write_part (regcache, reg, 0, len, | |
1008 | VALUE_CONTENTS (arg) + byte); | |
1009 | } | |
1010 | reg--; | |
1011 | } | |
1012 | } | |
1013 | } | |
2f690297 | 1014 | } |
449e1137 AC |
1015 | /* Update the various stack pointers. */ |
1016 | if (!write_pass) | |
2f690297 | 1017 | { |
449e1137 AC |
1018 | struct_end = sp + struct_ptr; |
1019 | /* PARAM_PTR already accounts for all the arguments passed | |
1020 | by the user. However, the ABI mandates minimum stack | |
1021 | space allocations for outgoing arguments. The ABI also | |
1022 | mandates minimum stack alignments which we must | |
1023 | preserve. */ | |
d0bd2d18 | 1024 | param_end = struct_end + max (align_up (param_ptr, 16), 64); |
2f690297 | 1025 | } |
2f690297 AC |
1026 | } |
1027 | ||
2f690297 AC |
1028 | /* If a structure has to be returned, set up register 28 to hold its |
1029 | address */ | |
1030 | if (struct_return) | |
1031 | write_register (28, struct_addr); | |
1032 | ||
2f690297 AC |
1033 | /* Set the return address. */ |
1034 | regcache_cooked_write_unsigned (regcache, RP_REGNUM, bp_addr); | |
1035 | ||
c4557624 JB |
1036 | /* Update the Stack Pointer. */ |
1037 | regcache_cooked_write_unsigned (regcache, SP_REGNUM, param_end + 64); | |
1038 | ||
449e1137 AC |
1039 | /* The stack will have 32 bytes of additional space for a frame marker. */ |
1040 | return param_end + 64; | |
2f690297 AC |
1041 | } |
1042 | ||
1797a8f6 AC |
1043 | static CORE_ADDR |
1044 | hppa32_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr) | |
1045 | { | |
1046 | /* HP frames are 64-byte (or cache line) aligned (yes that's _byte_ | |
1047 | and not _bit_)! */ | |
1048 | return align_up (addr, 64); | |
1049 | } | |
1050 | ||
2f690297 AC |
1051 | /* Force all frames to 16-byte alignment. Better safe than sorry. */ |
1052 | ||
1053 | static CORE_ADDR | |
1797a8f6 | 1054 | hppa64_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr) |
2f690297 AC |
1055 | { |
1056 | /* Just always 16-byte align. */ | |
1057 | return align_up (addr, 16); | |
1058 | } | |
1059 | ||
1060 | ||
c906108c | 1061 | /* elz: Used to lookup a symbol in the shared libraries. |
c5aa993b JM |
1062 | This function calls shl_findsym, indirectly through a |
1063 | call to __d_shl_get. __d_shl_get is in end.c, which is always | |
1064 | linked in by the hp compilers/linkers. | |
1065 | The call to shl_findsym cannot be made directly because it needs | |
1066 | to be active in target address space. | |
1067 | inputs: - minimal symbol pointer for the function we want to look up | |
1068 | - address in target space of the descriptor for the library | |
1069 | where we want to look the symbol up. | |
1070 | This address is retrieved using the | |
1071 | som_solib_get_solib_by_pc function (somsolib.c). | |
1072 | output: - real address in the library of the function. | |
1073 | note: the handle can be null, in which case shl_findsym will look for | |
1074 | the symbol in all the loaded shared libraries. | |
1075 | files to look at if you need reference on this stuff: | |
1076 | dld.c, dld_shl_findsym.c | |
1077 | end.c | |
1078 | man entry for shl_findsym */ | |
c906108c SS |
1079 | |
1080 | CORE_ADDR | |
fba45db2 | 1081 | find_stub_with_shl_get (struct minimal_symbol *function, CORE_ADDR handle) |
c906108c | 1082 | { |
c5aa993b JM |
1083 | struct symbol *get_sym, *symbol2; |
1084 | struct minimal_symbol *buff_minsym, *msymbol; | |
1085 | struct type *ftype; | |
ea7c478f AC |
1086 | struct value **args; |
1087 | struct value *funcval; | |
1088 | struct value *val; | |
c5aa993b JM |
1089 | |
1090 | int x, namelen, err_value, tmp = -1; | |
1091 | CORE_ADDR endo_buff_addr, value_return_addr, errno_return_addr; | |
1092 | CORE_ADDR stub_addr; | |
1093 | ||
1094 | ||
ea7c478f | 1095 | args = alloca (sizeof (struct value *) * 8); /* 6 for the arguments and one null one??? */ |
c5aa993b | 1096 | funcval = find_function_in_inferior ("__d_shl_get"); |
176620f1 | 1097 | get_sym = lookup_symbol ("__d_shl_get", NULL, VAR_DOMAIN, NULL, NULL); |
c5aa993b JM |
1098 | buff_minsym = lookup_minimal_symbol ("__buffer", NULL, NULL); |
1099 | msymbol = lookup_minimal_symbol ("__shldp", NULL, NULL); | |
176620f1 | 1100 | symbol2 = lookup_symbol ("__shldp", NULL, VAR_DOMAIN, NULL, NULL); |
c5aa993b | 1101 | endo_buff_addr = SYMBOL_VALUE_ADDRESS (buff_minsym); |
22abf04a | 1102 | namelen = strlen (DEPRECATED_SYMBOL_NAME (function)); |
c5aa993b JM |
1103 | value_return_addr = endo_buff_addr + namelen; |
1104 | ftype = check_typedef (SYMBOL_TYPE (get_sym)); | |
1105 | ||
1106 | /* do alignment */ | |
1107 | if ((x = value_return_addr % 64) != 0) | |
1108 | value_return_addr = value_return_addr + 64 - x; | |
1109 | ||
1110 | errno_return_addr = value_return_addr + 64; | |
1111 | ||
1112 | ||
1113 | /* set up stuff needed by __d_shl_get in buffer in end.o */ | |
1114 | ||
22abf04a | 1115 | target_write_memory (endo_buff_addr, DEPRECATED_SYMBOL_NAME (function), namelen); |
c5aa993b JM |
1116 | |
1117 | target_write_memory (value_return_addr, (char *) &tmp, 4); | |
1118 | ||
1119 | target_write_memory (errno_return_addr, (char *) &tmp, 4); | |
1120 | ||
1121 | target_write_memory (SYMBOL_VALUE_ADDRESS (msymbol), | |
1122 | (char *) &handle, 4); | |
1123 | ||
1124 | /* now prepare the arguments for the call */ | |
1125 | ||
1126 | args[0] = value_from_longest (TYPE_FIELD_TYPE (ftype, 0), 12); | |
4478b372 JB |
1127 | args[1] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 1), SYMBOL_VALUE_ADDRESS (msymbol)); |
1128 | args[2] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 2), endo_buff_addr); | |
c5aa993b | 1129 | args[3] = value_from_longest (TYPE_FIELD_TYPE (ftype, 3), TYPE_PROCEDURE); |
4478b372 JB |
1130 | args[4] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 4), value_return_addr); |
1131 | args[5] = value_from_pointer (TYPE_FIELD_TYPE (ftype, 5), errno_return_addr); | |
c5aa993b JM |
1132 | |
1133 | /* now call the function */ | |
1134 | ||
1135 | val = call_function_by_hand (funcval, 6, args); | |
1136 | ||
1137 | /* now get the results */ | |
1138 | ||
1139 | target_read_memory (errno_return_addr, (char *) &err_value, sizeof (err_value)); | |
1140 | ||
1141 | target_read_memory (value_return_addr, (char *) &stub_addr, sizeof (stub_addr)); | |
1142 | if (stub_addr <= 0) | |
104c1213 | 1143 | error ("call to __d_shl_get failed, error code is %d", err_value); |
c5aa993b JM |
1144 | |
1145 | return (stub_addr); | |
c906108c SS |
1146 | } |
1147 | ||
c5aa993b | 1148 | /* Cover routine for find_stub_with_shl_get to pass to catch_errors */ |
a0b3c4fd | 1149 | static int |
4efb68b1 | 1150 | cover_find_stub_with_shl_get (void *args_untyped) |
c906108c | 1151 | { |
a0b3c4fd JM |
1152 | args_for_find_stub *args = args_untyped; |
1153 | args->return_val = find_stub_with_shl_get (args->msym, args->solib_handle); | |
1154 | return 0; | |
c906108c SS |
1155 | } |
1156 | ||
c906108c SS |
1157 | /* Get the PC from %r31 if currently in a syscall. Also mask out privilege |
1158 | bits. */ | |
1159 | ||
1160 | CORE_ADDR | |
60383d10 | 1161 | hppa_target_read_pc (ptid_t ptid) |
c906108c | 1162 | { |
39f77062 | 1163 | int flags = read_register_pid (FLAGS_REGNUM, ptid); |
c906108c SS |
1164 | |
1165 | /* The following test does not belong here. It is OS-specific, and belongs | |
1166 | in native code. */ | |
1167 | /* Test SS_INSYSCALL */ | |
1168 | if (flags & 2) | |
39f77062 | 1169 | return read_register_pid (31, ptid) & ~0x3; |
c906108c | 1170 | |
449e1137 | 1171 | return read_register_pid (PCOQ_HEAD_REGNUM, ptid) & ~0x3; |
c906108c SS |
1172 | } |
1173 | ||
1174 | /* Write out the PC. If currently in a syscall, then also write the new | |
1175 | PC value into %r31. */ | |
1176 | ||
1177 | void | |
60383d10 | 1178 | hppa_target_write_pc (CORE_ADDR v, ptid_t ptid) |
c906108c | 1179 | { |
39f77062 | 1180 | int flags = read_register_pid (FLAGS_REGNUM, ptid); |
c906108c SS |
1181 | |
1182 | /* The following test does not belong here. It is OS-specific, and belongs | |
1183 | in native code. */ | |
1184 | /* If in a syscall, then set %r31. Also make sure to get the | |
1185 | privilege bits set correctly. */ | |
1186 | /* Test SS_INSYSCALL */ | |
1187 | if (flags & 2) | |
39f77062 | 1188 | write_register_pid (31, v | 0x3, ptid); |
c906108c | 1189 | |
449e1137 | 1190 | write_register_pid (PCOQ_HEAD_REGNUM, v, ptid); |
adc11376 | 1191 | write_register_pid (PCOQ_TAIL_REGNUM, v + 4, ptid); |
c906108c SS |
1192 | } |
1193 | ||
1194 | /* return the alignment of a type in bytes. Structures have the maximum | |
1195 | alignment required by their fields. */ | |
1196 | ||
1197 | static int | |
fba45db2 | 1198 | hppa_alignof (struct type *type) |
c906108c SS |
1199 | { |
1200 | int max_align, align, i; | |
1201 | CHECK_TYPEDEF (type); | |
1202 | switch (TYPE_CODE (type)) | |
1203 | { | |
1204 | case TYPE_CODE_PTR: | |
1205 | case TYPE_CODE_INT: | |
1206 | case TYPE_CODE_FLT: | |
1207 | return TYPE_LENGTH (type); | |
1208 | case TYPE_CODE_ARRAY: | |
1209 | return hppa_alignof (TYPE_FIELD_TYPE (type, 0)); | |
1210 | case TYPE_CODE_STRUCT: | |
1211 | case TYPE_CODE_UNION: | |
1212 | max_align = 1; | |
1213 | for (i = 0; i < TYPE_NFIELDS (type); i++) | |
1214 | { | |
1215 | /* Bit fields have no real alignment. */ | |
1216 | /* if (!TYPE_FIELD_BITPOS (type, i)) */ | |
c5aa993b | 1217 | if (!TYPE_FIELD_BITSIZE (type, i)) /* elz: this should be bitsize */ |
c906108c SS |
1218 | { |
1219 | align = hppa_alignof (TYPE_FIELD_TYPE (type, i)); | |
1220 | max_align = max (max_align, align); | |
1221 | } | |
1222 | } | |
1223 | return max_align; | |
1224 | default: | |
1225 | return 4; | |
1226 | } | |
1227 | } | |
1228 | ||
c906108c SS |
1229 | /* Return one if PC is in the call path of a trampoline, else return zero. |
1230 | ||
1231 | Note we return one for *any* call trampoline (long-call, arg-reloc), not | |
1232 | just shared library trampolines (import, export). */ | |
1233 | ||
1234 | int | |
60383d10 | 1235 | hppa_in_solib_call_trampoline (CORE_ADDR pc, char *name) |
c906108c SS |
1236 | { |
1237 | struct minimal_symbol *minsym; | |
1238 | struct unwind_table_entry *u; | |
1239 | static CORE_ADDR dyncall = 0; | |
1240 | static CORE_ADDR sr4export = 0; | |
1241 | ||
c2c6d25f JM |
1242 | #ifdef GDB_TARGET_IS_HPPA_20W |
1243 | /* PA64 has a completely different stub/trampoline scheme. Is it | |
1244 | better? Maybe. It's certainly harder to determine with any | |
1245 | certainty that we are in a stub because we can not refer to the | |
1246 | unwinders to help. | |
1247 | ||
1248 | The heuristic is simple. Try to lookup the current PC value in th | |
1249 | minimal symbol table. If that fails, then assume we are not in a | |
1250 | stub and return. | |
1251 | ||
1252 | Then see if the PC value falls within the section bounds for the | |
1253 | section containing the minimal symbol we found in the first | |
1254 | step. If it does, then assume we are not in a stub and return. | |
1255 | ||
1256 | Finally peek at the instructions to see if they look like a stub. */ | |
1257 | { | |
1258 | struct minimal_symbol *minsym; | |
1259 | asection *sec; | |
1260 | CORE_ADDR addr; | |
1261 | int insn, i; | |
1262 | ||
1263 | minsym = lookup_minimal_symbol_by_pc (pc); | |
1264 | if (! minsym) | |
1265 | return 0; | |
1266 | ||
1267 | sec = SYMBOL_BFD_SECTION (minsym); | |
1268 | ||
b98ed7be AM |
1269 | if (bfd_get_section_vma (sec->owner, sec) <= pc |
1270 | && pc < (bfd_get_section_vma (sec->owner, sec) | |
1271 | + bfd_section_size (sec->owner, sec))) | |
c2c6d25f JM |
1272 | return 0; |
1273 | ||
1274 | /* We might be in a stub. Peek at the instructions. Stubs are 3 | |
1275 | instructions long. */ | |
1276 | insn = read_memory_integer (pc, 4); | |
1277 | ||
b84a8afe | 1278 | /* Find out where we think we are within the stub. */ |
c2c6d25f JM |
1279 | if ((insn & 0xffffc00e) == 0x53610000) |
1280 | addr = pc; | |
1281 | else if ((insn & 0xffffffff) == 0xe820d000) | |
1282 | addr = pc - 4; | |
1283 | else if ((insn & 0xffffc00e) == 0x537b0000) | |
1284 | addr = pc - 8; | |
1285 | else | |
1286 | return 0; | |
1287 | ||
1288 | /* Now verify each insn in the range looks like a stub instruction. */ | |
1289 | insn = read_memory_integer (addr, 4); | |
1290 | if ((insn & 0xffffc00e) != 0x53610000) | |
1291 | return 0; | |
1292 | ||
1293 | /* Now verify each insn in the range looks like a stub instruction. */ | |
1294 | insn = read_memory_integer (addr + 4, 4); | |
1295 | if ((insn & 0xffffffff) != 0xe820d000) | |
1296 | return 0; | |
1297 | ||
1298 | /* Now verify each insn in the range looks like a stub instruction. */ | |
1299 | insn = read_memory_integer (addr + 8, 4); | |
1300 | if ((insn & 0xffffc00e) != 0x537b0000) | |
1301 | return 0; | |
1302 | ||
1303 | /* Looks like a stub. */ | |
1304 | return 1; | |
1305 | } | |
1306 | #endif | |
1307 | ||
1308 | /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a | |
1309 | new exec file */ | |
c906108c SS |
1310 | |
1311 | /* First see if PC is in one of the two C-library trampolines. */ | |
1312 | if (!dyncall) | |
1313 | { | |
1314 | minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); | |
1315 | if (minsym) | |
1316 | dyncall = SYMBOL_VALUE_ADDRESS (minsym); | |
1317 | else | |
1318 | dyncall = -1; | |
1319 | } | |
1320 | ||
1321 | if (!sr4export) | |
1322 | { | |
1323 | minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL); | |
1324 | if (minsym) | |
1325 | sr4export = SYMBOL_VALUE_ADDRESS (minsym); | |
1326 | else | |
1327 | sr4export = -1; | |
1328 | } | |
1329 | ||
1330 | if (pc == dyncall || pc == sr4export) | |
1331 | return 1; | |
1332 | ||
104c1213 | 1333 | minsym = lookup_minimal_symbol_by_pc (pc); |
22abf04a | 1334 | if (minsym && strcmp (DEPRECATED_SYMBOL_NAME (minsym), ".stub") == 0) |
104c1213 JM |
1335 | return 1; |
1336 | ||
c906108c SS |
1337 | /* Get the unwind descriptor corresponding to PC, return zero |
1338 | if no unwind was found. */ | |
1339 | u = find_unwind_entry (pc); | |
1340 | if (!u) | |
1341 | return 0; | |
1342 | ||
1343 | /* If this isn't a linker stub, then return now. */ | |
1344 | if (u->stub_unwind.stub_type == 0) | |
1345 | return 0; | |
1346 | ||
1347 | /* By definition a long-branch stub is a call stub. */ | |
1348 | if (u->stub_unwind.stub_type == LONG_BRANCH) | |
1349 | return 1; | |
1350 | ||
1351 | /* The call and return path execute the same instructions within | |
1352 | an IMPORT stub! So an IMPORT stub is both a call and return | |
1353 | trampoline. */ | |
1354 | if (u->stub_unwind.stub_type == IMPORT) | |
1355 | return 1; | |
1356 | ||
1357 | /* Parameter relocation stubs always have a call path and may have a | |
1358 | return path. */ | |
1359 | if (u->stub_unwind.stub_type == PARAMETER_RELOCATION | |
1360 | || u->stub_unwind.stub_type == EXPORT) | |
1361 | { | |
1362 | CORE_ADDR addr; | |
1363 | ||
1364 | /* Search forward from the current PC until we hit a branch | |
c5aa993b | 1365 | or the end of the stub. */ |
c906108c SS |
1366 | for (addr = pc; addr <= u->region_end; addr += 4) |
1367 | { | |
1368 | unsigned long insn; | |
1369 | ||
1370 | insn = read_memory_integer (addr, 4); | |
1371 | ||
1372 | /* Does it look like a bl? If so then it's the call path, if | |
1373 | we find a bv or be first, then we're on the return path. */ | |
1374 | if ((insn & 0xfc00e000) == 0xe8000000) | |
1375 | return 1; | |
1376 | else if ((insn & 0xfc00e001) == 0xe800c000 | |
1377 | || (insn & 0xfc000000) == 0xe0000000) | |
1378 | return 0; | |
1379 | } | |
1380 | ||
1381 | /* Should never happen. */ | |
104c1213 JM |
1382 | warning ("Unable to find branch in parameter relocation stub.\n"); |
1383 | return 0; | |
c906108c SS |
1384 | } |
1385 | ||
1386 | /* Unknown stub type. For now, just return zero. */ | |
104c1213 | 1387 | return 0; |
c906108c SS |
1388 | } |
1389 | ||
1390 | /* Return one if PC is in the return path of a trampoline, else return zero. | |
1391 | ||
1392 | Note we return one for *any* call trampoline (long-call, arg-reloc), not | |
1393 | just shared library trampolines (import, export). */ | |
1394 | ||
1395 | int | |
60383d10 | 1396 | hppa_in_solib_return_trampoline (CORE_ADDR pc, char *name) |
c906108c SS |
1397 | { |
1398 | struct unwind_table_entry *u; | |
1399 | ||
1400 | /* Get the unwind descriptor corresponding to PC, return zero | |
1401 | if no unwind was found. */ | |
1402 | u = find_unwind_entry (pc); | |
1403 | if (!u) | |
1404 | return 0; | |
1405 | ||
1406 | /* If this isn't a linker stub or it's just a long branch stub, then | |
1407 | return zero. */ | |
1408 | if (u->stub_unwind.stub_type == 0 || u->stub_unwind.stub_type == LONG_BRANCH) | |
1409 | return 0; | |
1410 | ||
1411 | /* The call and return path execute the same instructions within | |
1412 | an IMPORT stub! So an IMPORT stub is both a call and return | |
1413 | trampoline. */ | |
1414 | if (u->stub_unwind.stub_type == IMPORT) | |
1415 | return 1; | |
1416 | ||
1417 | /* Parameter relocation stubs always have a call path and may have a | |
1418 | return path. */ | |
1419 | if (u->stub_unwind.stub_type == PARAMETER_RELOCATION | |
1420 | || u->stub_unwind.stub_type == EXPORT) | |
1421 | { | |
1422 | CORE_ADDR addr; | |
1423 | ||
1424 | /* Search forward from the current PC until we hit a branch | |
c5aa993b | 1425 | or the end of the stub. */ |
c906108c SS |
1426 | for (addr = pc; addr <= u->region_end; addr += 4) |
1427 | { | |
1428 | unsigned long insn; | |
1429 | ||
1430 | insn = read_memory_integer (addr, 4); | |
1431 | ||
1432 | /* Does it look like a bl? If so then it's the call path, if | |
1433 | we find a bv or be first, then we're on the return path. */ | |
1434 | if ((insn & 0xfc00e000) == 0xe8000000) | |
1435 | return 0; | |
1436 | else if ((insn & 0xfc00e001) == 0xe800c000 | |
1437 | || (insn & 0xfc000000) == 0xe0000000) | |
1438 | return 1; | |
1439 | } | |
1440 | ||
1441 | /* Should never happen. */ | |
104c1213 JM |
1442 | warning ("Unable to find branch in parameter relocation stub.\n"); |
1443 | return 0; | |
c906108c SS |
1444 | } |
1445 | ||
1446 | /* Unknown stub type. For now, just return zero. */ | |
104c1213 | 1447 | return 0; |
c906108c SS |
1448 | |
1449 | } | |
1450 | ||
1451 | /* Figure out if PC is in a trampoline, and if so find out where | |
1452 | the trampoline will jump to. If not in a trampoline, return zero. | |
1453 | ||
1454 | Simple code examination probably is not a good idea since the code | |
1455 | sequences in trampolines can also appear in user code. | |
1456 | ||
1457 | We use unwinds and information from the minimal symbol table to | |
1458 | determine when we're in a trampoline. This won't work for ELF | |
1459 | (yet) since it doesn't create stub unwind entries. Whether or | |
1460 | not ELF will create stub unwinds or normal unwinds for linker | |
1461 | stubs is still being debated. | |
1462 | ||
1463 | This should handle simple calls through dyncall or sr4export, | |
1464 | long calls, argument relocation stubs, and dyncall/sr4export | |
1465 | calling an argument relocation stub. It even handles some stubs | |
1466 | used in dynamic executables. */ | |
1467 | ||
c906108c | 1468 | CORE_ADDR |
60383d10 | 1469 | hppa_skip_trampoline_code (CORE_ADDR pc) |
c906108c SS |
1470 | { |
1471 | long orig_pc = pc; | |
1472 | long prev_inst, curr_inst, loc; | |
1473 | static CORE_ADDR dyncall = 0; | |
1474 | static CORE_ADDR dyncall_external = 0; | |
1475 | static CORE_ADDR sr4export = 0; | |
1476 | struct minimal_symbol *msym; | |
1477 | struct unwind_table_entry *u; | |
1478 | ||
c2c6d25f JM |
1479 | /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a |
1480 | new exec file */ | |
c906108c SS |
1481 | |
1482 | if (!dyncall) | |
1483 | { | |
1484 | msym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); | |
1485 | if (msym) | |
1486 | dyncall = SYMBOL_VALUE_ADDRESS (msym); | |
1487 | else | |
1488 | dyncall = -1; | |
1489 | } | |
1490 | ||
1491 | if (!dyncall_external) | |
1492 | { | |
1493 | msym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL); | |
1494 | if (msym) | |
1495 | dyncall_external = SYMBOL_VALUE_ADDRESS (msym); | |
1496 | else | |
1497 | dyncall_external = -1; | |
1498 | } | |
1499 | ||
1500 | if (!sr4export) | |
1501 | { | |
1502 | msym = lookup_minimal_symbol ("_sr4export", NULL, NULL); | |
1503 | if (msym) | |
1504 | sr4export = SYMBOL_VALUE_ADDRESS (msym); | |
1505 | else | |
1506 | sr4export = -1; | |
1507 | } | |
1508 | ||
1509 | /* Addresses passed to dyncall may *NOT* be the actual address | |
1510 | of the function. So we may have to do something special. */ | |
1511 | if (pc == dyncall) | |
1512 | { | |
1513 | pc = (CORE_ADDR) read_register (22); | |
1514 | ||
1515 | /* If bit 30 (counting from the left) is on, then pc is the address of | |
c5aa993b JM |
1516 | the PLT entry for this function, not the address of the function |
1517 | itself. Bit 31 has meaning too, but only for MPE. */ | |
c906108c | 1518 | if (pc & 0x2) |
53a5351d | 1519 | pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8); |
c906108c SS |
1520 | } |
1521 | if (pc == dyncall_external) | |
1522 | { | |
1523 | pc = (CORE_ADDR) read_register (22); | |
53a5351d | 1524 | pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8); |
c906108c SS |
1525 | } |
1526 | else if (pc == sr4export) | |
1527 | pc = (CORE_ADDR) (read_register (22)); | |
1528 | ||
1529 | /* Get the unwind descriptor corresponding to PC, return zero | |
1530 | if no unwind was found. */ | |
1531 | u = find_unwind_entry (pc); | |
1532 | if (!u) | |
1533 | return 0; | |
1534 | ||
1535 | /* If this isn't a linker stub, then return now. */ | |
1536 | /* elz: attention here! (FIXME) because of a compiler/linker | |
1537 | error, some stubs which should have a non zero stub_unwind.stub_type | |
1538 | have unfortunately a value of zero. So this function would return here | |
1539 | as if we were not in a trampoline. To fix this, we go look at the partial | |
1540 | symbol information, which reports this guy as a stub. | |
1541 | (FIXME): Unfortunately, we are not that lucky: it turns out that the | |
1542 | partial symbol information is also wrong sometimes. This is because | |
1543 | when it is entered (somread.c::som_symtab_read()) it can happen that | |
1544 | if the type of the symbol (from the som) is Entry, and the symbol is | |
1545 | in a shared library, then it can also be a trampoline. This would | |
1546 | be OK, except that I believe the way they decide if we are ina shared library | |
1547 | does not work. SOOOO..., even if we have a regular function w/o trampolines | |
1548 | its minimal symbol can be assigned type mst_solib_trampoline. | |
1549 | Also, if we find that the symbol is a real stub, then we fix the unwind | |
1550 | descriptor, and define the stub type to be EXPORT. | |
c5aa993b | 1551 | Hopefully this is correct most of the times. */ |
c906108c | 1552 | if (u->stub_unwind.stub_type == 0) |
c5aa993b | 1553 | { |
c906108c SS |
1554 | |
1555 | /* elz: NOTE (FIXME!) once the problem with the unwind information is fixed | |
1556 | we can delete all the code which appears between the lines */ | |
1557 | /*--------------------------------------------------------------------------*/ | |
c5aa993b | 1558 | msym = lookup_minimal_symbol_by_pc (pc); |
c906108c | 1559 | |
c5aa993b JM |
1560 | if (msym == NULL || MSYMBOL_TYPE (msym) != mst_solib_trampoline) |
1561 | return orig_pc == pc ? 0 : pc & ~0x3; | |
1562 | ||
1563 | else if (msym != NULL && MSYMBOL_TYPE (msym) == mst_solib_trampoline) | |
1564 | { | |
1565 | struct objfile *objfile; | |
1566 | struct minimal_symbol *msymbol; | |
1567 | int function_found = 0; | |
1568 | ||
1569 | /* go look if there is another minimal symbol with the same name as | |
1570 | this one, but with type mst_text. This would happen if the msym | |
1571 | is an actual trampoline, in which case there would be another | |
1572 | symbol with the same name corresponding to the real function */ | |
1573 | ||
1574 | ALL_MSYMBOLS (objfile, msymbol) | |
1575 | { | |
1576 | if (MSYMBOL_TYPE (msymbol) == mst_text | |
cb137aa5 | 1577 | && DEPRECATED_STREQ (DEPRECATED_SYMBOL_NAME (msymbol), DEPRECATED_SYMBOL_NAME (msym))) |
c5aa993b JM |
1578 | { |
1579 | function_found = 1; | |
1580 | break; | |
1581 | } | |
1582 | } | |
1583 | ||
1584 | if (function_found) | |
1585 | /* the type of msym is correct (mst_solib_trampoline), but | |
1586 | the unwind info is wrong, so set it to the correct value */ | |
1587 | u->stub_unwind.stub_type = EXPORT; | |
1588 | else | |
1589 | /* the stub type info in the unwind is correct (this is not a | |
1590 | trampoline), but the msym type information is wrong, it | |
1591 | should be mst_text. So we need to fix the msym, and also | |
1592 | get out of this function */ | |
1593 | { | |
1594 | MSYMBOL_TYPE (msym) = mst_text; | |
1595 | return orig_pc == pc ? 0 : pc & ~0x3; | |
1596 | } | |
1597 | } | |
c906108c | 1598 | |
c906108c | 1599 | /*--------------------------------------------------------------------------*/ |
c5aa993b | 1600 | } |
c906108c SS |
1601 | |
1602 | /* It's a stub. Search for a branch and figure out where it goes. | |
1603 | Note we have to handle multi insn branch sequences like ldil;ble. | |
1604 | Most (all?) other branches can be determined by examining the contents | |
1605 | of certain registers and the stack. */ | |
1606 | ||
1607 | loc = pc; | |
1608 | curr_inst = 0; | |
1609 | prev_inst = 0; | |
1610 | while (1) | |
1611 | { | |
1612 | /* Make sure we haven't walked outside the range of this stub. */ | |
1613 | if (u != find_unwind_entry (loc)) | |
1614 | { | |
1615 | warning ("Unable to find branch in linker stub"); | |
1616 | return orig_pc == pc ? 0 : pc & ~0x3; | |
1617 | } | |
1618 | ||
1619 | prev_inst = curr_inst; | |
1620 | curr_inst = read_memory_integer (loc, 4); | |
1621 | ||
1622 | /* Does it look like a branch external using %r1? Then it's the | |
c5aa993b | 1623 | branch from the stub to the actual function. */ |
c906108c SS |
1624 | if ((curr_inst & 0xffe0e000) == 0xe0202000) |
1625 | { | |
1626 | /* Yup. See if the previous instruction loaded | |
1627 | a value into %r1. If so compute and return the jump address. */ | |
1628 | if ((prev_inst & 0xffe00000) == 0x20200000) | |
1629 | return (extract_21 (prev_inst) + extract_17 (curr_inst)) & ~0x3; | |
1630 | else | |
1631 | { | |
1632 | warning ("Unable to find ldil X,%%r1 before ble Y(%%sr4,%%r1)."); | |
1633 | return orig_pc == pc ? 0 : pc & ~0x3; | |
1634 | } | |
1635 | } | |
1636 | ||
1637 | /* Does it look like a be 0(sr0,%r21)? OR | |
1638 | Does it look like a be, n 0(sr0,%r21)? OR | |
1639 | Does it look like a bve (r21)? (this is on PA2.0) | |
1640 | Does it look like a bve, n(r21)? (this is also on PA2.0) | |
1641 | That's the branch from an | |
c5aa993b | 1642 | import stub to an export stub. |
c906108c | 1643 | |
c5aa993b JM |
1644 | It is impossible to determine the target of the branch via |
1645 | simple examination of instructions and/or data (consider | |
1646 | that the address in the plabel may be the address of the | |
1647 | bind-on-reference routine in the dynamic loader). | |
c906108c | 1648 | |
c5aa993b | 1649 | So we have try an alternative approach. |
c906108c | 1650 | |
c5aa993b JM |
1651 | Get the name of the symbol at our current location; it should |
1652 | be a stub symbol with the same name as the symbol in the | |
1653 | shared library. | |
c906108c | 1654 | |
c5aa993b JM |
1655 | Then lookup a minimal symbol with the same name; we should |
1656 | get the minimal symbol for the target routine in the shared | |
1657 | library as those take precedence of import/export stubs. */ | |
c906108c | 1658 | if ((curr_inst == 0xe2a00000) || |
c5aa993b JM |
1659 | (curr_inst == 0xe2a00002) || |
1660 | (curr_inst == 0xeaa0d000) || | |
1661 | (curr_inst == 0xeaa0d002)) | |
c906108c SS |
1662 | { |
1663 | struct minimal_symbol *stubsym, *libsym; | |
1664 | ||
1665 | stubsym = lookup_minimal_symbol_by_pc (loc); | |
1666 | if (stubsym == NULL) | |
1667 | { | |
ce414844 | 1668 | warning ("Unable to find symbol for 0x%lx", loc); |
c906108c SS |
1669 | return orig_pc == pc ? 0 : pc & ~0x3; |
1670 | } | |
1671 | ||
22abf04a | 1672 | libsym = lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (stubsym), NULL, NULL); |
c906108c SS |
1673 | if (libsym == NULL) |
1674 | { | |
1675 | warning ("Unable to find library symbol for %s\n", | |
22abf04a | 1676 | DEPRECATED_SYMBOL_NAME (stubsym)); |
c906108c SS |
1677 | return orig_pc == pc ? 0 : pc & ~0x3; |
1678 | } | |
1679 | ||
1680 | return SYMBOL_VALUE (libsym); | |
1681 | } | |
1682 | ||
1683 | /* Does it look like bl X,%rp or bl X,%r0? Another way to do a | |
c5aa993b JM |
1684 | branch from the stub to the actual function. */ |
1685 | /*elz */ | |
c906108c SS |
1686 | else if ((curr_inst & 0xffe0e000) == 0xe8400000 |
1687 | || (curr_inst & 0xffe0e000) == 0xe8000000 | |
c5aa993b | 1688 | || (curr_inst & 0xffe0e000) == 0xe800A000) |
c906108c SS |
1689 | return (loc + extract_17 (curr_inst) + 8) & ~0x3; |
1690 | ||
1691 | /* Does it look like bv (rp)? Note this depends on the | |
c5aa993b JM |
1692 | current stack pointer being the same as the stack |
1693 | pointer in the stub itself! This is a branch on from the | |
1694 | stub back to the original caller. */ | |
1695 | /*else if ((curr_inst & 0xffe0e000) == 0xe840c000) */ | |
c906108c SS |
1696 | else if ((curr_inst & 0xffe0f000) == 0xe840c000) |
1697 | { | |
1698 | /* Yup. See if the previous instruction loaded | |
1699 | rp from sp - 8. */ | |
1700 | if (prev_inst == 0x4bc23ff1) | |
1701 | return (read_memory_integer | |
eded0a31 | 1702 | (read_register (HPPA_SP_REGNUM) - 8, 4)) & ~0x3; |
c906108c SS |
1703 | else |
1704 | { | |
1705 | warning ("Unable to find restore of %%rp before bv (%%rp)."); | |
1706 | return orig_pc == pc ? 0 : pc & ~0x3; | |
1707 | } | |
1708 | } | |
1709 | ||
1710 | /* elz: added this case to capture the new instruction | |
1711 | at the end of the return part of an export stub used by | |
1712 | the PA2.0: BVE, n (rp) */ | |
1713 | else if ((curr_inst & 0xffe0f000) == 0xe840d000) | |
1714 | { | |
c5aa993b | 1715 | return (read_memory_integer |
eded0a31 | 1716 | (read_register (HPPA_SP_REGNUM) - 24, TARGET_PTR_BIT / 8)) & ~0x3; |
c906108c SS |
1717 | } |
1718 | ||
1719 | /* What about be,n 0(sr0,%rp)? It's just another way we return to | |
c5aa993b | 1720 | the original caller from the stub. Used in dynamic executables. */ |
c906108c SS |
1721 | else if (curr_inst == 0xe0400002) |
1722 | { | |
1723 | /* The value we jump to is sitting in sp - 24. But that's | |
1724 | loaded several instructions before the be instruction. | |
1725 | I guess we could check for the previous instruction being | |
1726 | mtsp %r1,%sr0 if we want to do sanity checking. */ | |
c5aa993b | 1727 | return (read_memory_integer |
eded0a31 | 1728 | (read_register (HPPA_SP_REGNUM) - 24, TARGET_PTR_BIT / 8)) & ~0x3; |
c906108c SS |
1729 | } |
1730 | ||
1731 | /* Haven't found the branch yet, but we're still in the stub. | |
c5aa993b | 1732 | Keep looking. */ |
c906108c SS |
1733 | loc += 4; |
1734 | } | |
1735 | } | |
1736 | ||
1737 | ||
1738 | /* For the given instruction (INST), return any adjustment it makes | |
1739 | to the stack pointer or zero for no adjustment. | |
1740 | ||
1741 | This only handles instructions commonly found in prologues. */ | |
1742 | ||
1743 | static int | |
fba45db2 | 1744 | prologue_inst_adjust_sp (unsigned long inst) |
c906108c SS |
1745 | { |
1746 | /* This must persist across calls. */ | |
1747 | static int save_high21; | |
1748 | ||
1749 | /* The most common way to perform a stack adjustment ldo X(sp),sp */ | |
1750 | if ((inst & 0xffffc000) == 0x37de0000) | |
1751 | return extract_14 (inst); | |
1752 | ||
1753 | /* stwm X,D(sp) */ | |
1754 | if ((inst & 0xffe00000) == 0x6fc00000) | |
1755 | return extract_14 (inst); | |
1756 | ||
104c1213 JM |
1757 | /* std,ma X,D(sp) */ |
1758 | if ((inst & 0xffe00008) == 0x73c00008) | |
d4f3574e | 1759 | return (inst & 0x1 ? -1 << 13 : 0) | (((inst >> 4) & 0x3ff) << 3); |
104c1213 | 1760 | |
c906108c SS |
1761 | /* addil high21,%r1; ldo low11,(%r1),%r30) |
1762 | save high bits in save_high21 for later use. */ | |
1763 | if ((inst & 0xffe00000) == 0x28200000) | |
1764 | { | |
1765 | save_high21 = extract_21 (inst); | |
1766 | return 0; | |
1767 | } | |
1768 | ||
1769 | if ((inst & 0xffff0000) == 0x343e0000) | |
1770 | return save_high21 + extract_14 (inst); | |
1771 | ||
1772 | /* fstws as used by the HP compilers. */ | |
1773 | if ((inst & 0xffffffe0) == 0x2fd01220) | |
1774 | return extract_5_load (inst); | |
1775 | ||
1776 | /* No adjustment. */ | |
1777 | return 0; | |
1778 | } | |
1779 | ||
1780 | /* Return nonzero if INST is a branch of some kind, else return zero. */ | |
1781 | ||
1782 | static int | |
fba45db2 | 1783 | is_branch (unsigned long inst) |
c906108c SS |
1784 | { |
1785 | switch (inst >> 26) | |
1786 | { | |
1787 | case 0x20: | |
1788 | case 0x21: | |
1789 | case 0x22: | |
1790 | case 0x23: | |
7be570e7 | 1791 | case 0x27: |
c906108c SS |
1792 | case 0x28: |
1793 | case 0x29: | |
1794 | case 0x2a: | |
1795 | case 0x2b: | |
7be570e7 | 1796 | case 0x2f: |
c906108c SS |
1797 | case 0x30: |
1798 | case 0x31: | |
1799 | case 0x32: | |
1800 | case 0x33: | |
1801 | case 0x38: | |
1802 | case 0x39: | |
1803 | case 0x3a: | |
7be570e7 | 1804 | case 0x3b: |
c906108c SS |
1805 | return 1; |
1806 | ||
1807 | default: | |
1808 | return 0; | |
1809 | } | |
1810 | } | |
1811 | ||
1812 | /* Return the register number for a GR which is saved by INST or | |
1813 | zero it INST does not save a GR. */ | |
1814 | ||
1815 | static int | |
fba45db2 | 1816 | inst_saves_gr (unsigned long inst) |
c906108c SS |
1817 | { |
1818 | /* Does it look like a stw? */ | |
7be570e7 JM |
1819 | if ((inst >> 26) == 0x1a || (inst >> 26) == 0x1b |
1820 | || (inst >> 26) == 0x1f | |
1821 | || ((inst >> 26) == 0x1f | |
1822 | && ((inst >> 6) == 0xa))) | |
1823 | return extract_5R_store (inst); | |
1824 | ||
1825 | /* Does it look like a std? */ | |
1826 | if ((inst >> 26) == 0x1c | |
1827 | || ((inst >> 26) == 0x03 | |
1828 | && ((inst >> 6) & 0xf) == 0xb)) | |
c906108c SS |
1829 | return extract_5R_store (inst); |
1830 | ||
1831 | /* Does it look like a stwm? GCC & HPC may use this in prologues. */ | |
1832 | if ((inst >> 26) == 0x1b) | |
1833 | return extract_5R_store (inst); | |
1834 | ||
1835 | /* Does it look like sth or stb? HPC versions 9.0 and later use these | |
1836 | too. */ | |
7be570e7 JM |
1837 | if ((inst >> 26) == 0x19 || (inst >> 26) == 0x18 |
1838 | || ((inst >> 26) == 0x3 | |
1839 | && (((inst >> 6) & 0xf) == 0x8 | |
1840 | || (inst >> 6) & 0xf) == 0x9)) | |
c906108c | 1841 | return extract_5R_store (inst); |
c5aa993b | 1842 | |
c906108c SS |
1843 | return 0; |
1844 | } | |
1845 | ||
1846 | /* Return the register number for a FR which is saved by INST or | |
1847 | zero it INST does not save a FR. | |
1848 | ||
1849 | Note we only care about full 64bit register stores (that's the only | |
1850 | kind of stores the prologue will use). | |
1851 | ||
1852 | FIXME: What about argument stores with the HP compiler in ANSI mode? */ | |
1853 | ||
1854 | static int | |
fba45db2 | 1855 | inst_saves_fr (unsigned long inst) |
c906108c | 1856 | { |
7be570e7 | 1857 | /* is this an FSTD ? */ |
c906108c SS |
1858 | if ((inst & 0xfc00dfc0) == 0x2c001200) |
1859 | return extract_5r_store (inst); | |
7be570e7 JM |
1860 | if ((inst & 0xfc000002) == 0x70000002) |
1861 | return extract_5R_store (inst); | |
1862 | /* is this an FSTW ? */ | |
c906108c SS |
1863 | if ((inst & 0xfc00df80) == 0x24001200) |
1864 | return extract_5r_store (inst); | |
7be570e7 JM |
1865 | if ((inst & 0xfc000002) == 0x7c000000) |
1866 | return extract_5R_store (inst); | |
c906108c SS |
1867 | return 0; |
1868 | } | |
1869 | ||
1870 | /* Advance PC across any function entry prologue instructions | |
1871 | to reach some "real" code. | |
1872 | ||
1873 | Use information in the unwind table to determine what exactly should | |
1874 | be in the prologue. */ | |
1875 | ||
1876 | ||
1877 | CORE_ADDR | |
fba45db2 | 1878 | skip_prologue_hard_way (CORE_ADDR pc) |
c906108c SS |
1879 | { |
1880 | char buf[4]; | |
1881 | CORE_ADDR orig_pc = pc; | |
1882 | unsigned long inst, stack_remaining, save_gr, save_fr, save_rp, save_sp; | |
1883 | unsigned long args_stored, status, i, restart_gr, restart_fr; | |
1884 | struct unwind_table_entry *u; | |
1885 | ||
1886 | restart_gr = 0; | |
1887 | restart_fr = 0; | |
1888 | ||
1889 | restart: | |
1890 | u = find_unwind_entry (pc); | |
1891 | if (!u) | |
1892 | return pc; | |
1893 | ||
c5aa993b | 1894 | /* If we are not at the beginning of a function, then return now. */ |
c906108c SS |
1895 | if ((pc & ~0x3) != u->region_start) |
1896 | return pc; | |
1897 | ||
1898 | /* This is how much of a frame adjustment we need to account for. */ | |
1899 | stack_remaining = u->Total_frame_size << 3; | |
1900 | ||
1901 | /* Magic register saves we want to know about. */ | |
1902 | save_rp = u->Save_RP; | |
1903 | save_sp = u->Save_SP; | |
1904 | ||
1905 | /* An indication that args may be stored into the stack. Unfortunately | |
1906 | the HPUX compilers tend to set this in cases where no args were | |
1907 | stored too!. */ | |
1908 | args_stored = 1; | |
1909 | ||
1910 | /* Turn the Entry_GR field into a bitmask. */ | |
1911 | save_gr = 0; | |
1912 | for (i = 3; i < u->Entry_GR + 3; i++) | |
1913 | { | |
1914 | /* Frame pointer gets saved into a special location. */ | |
eded0a31 | 1915 | if (u->Save_SP && i == HPPA_FP_REGNUM) |
c906108c SS |
1916 | continue; |
1917 | ||
1918 | save_gr |= (1 << i); | |
1919 | } | |
1920 | save_gr &= ~restart_gr; | |
1921 | ||
1922 | /* Turn the Entry_FR field into a bitmask too. */ | |
1923 | save_fr = 0; | |
1924 | for (i = 12; i < u->Entry_FR + 12; i++) | |
1925 | save_fr |= (1 << i); | |
1926 | save_fr &= ~restart_fr; | |
1927 | ||
1928 | /* Loop until we find everything of interest or hit a branch. | |
1929 | ||
1930 | For unoptimized GCC code and for any HP CC code this will never ever | |
1931 | examine any user instructions. | |
1932 | ||
1933 | For optimzied GCC code we're faced with problems. GCC will schedule | |
1934 | its prologue and make prologue instructions available for delay slot | |
1935 | filling. The end result is user code gets mixed in with the prologue | |
1936 | and a prologue instruction may be in the delay slot of the first branch | |
1937 | or call. | |
1938 | ||
1939 | Some unexpected things are expected with debugging optimized code, so | |
1940 | we allow this routine to walk past user instructions in optimized | |
1941 | GCC code. */ | |
1942 | while (save_gr || save_fr || save_rp || save_sp || stack_remaining > 0 | |
1943 | || args_stored) | |
1944 | { | |
1945 | unsigned int reg_num; | |
1946 | unsigned long old_stack_remaining, old_save_gr, old_save_fr; | |
1947 | unsigned long old_save_rp, old_save_sp, next_inst; | |
1948 | ||
1949 | /* Save copies of all the triggers so we can compare them later | |
c5aa993b | 1950 | (only for HPC). */ |
c906108c SS |
1951 | old_save_gr = save_gr; |
1952 | old_save_fr = save_fr; | |
1953 | old_save_rp = save_rp; | |
1954 | old_save_sp = save_sp; | |
1955 | old_stack_remaining = stack_remaining; | |
1956 | ||
1957 | status = target_read_memory (pc, buf, 4); | |
1958 | inst = extract_unsigned_integer (buf, 4); | |
c5aa993b | 1959 | |
c906108c SS |
1960 | /* Yow! */ |
1961 | if (status != 0) | |
1962 | return pc; | |
1963 | ||
1964 | /* Note the interesting effects of this instruction. */ | |
1965 | stack_remaining -= prologue_inst_adjust_sp (inst); | |
1966 | ||
7be570e7 JM |
1967 | /* There are limited ways to store the return pointer into the |
1968 | stack. */ | |
1969 | if (inst == 0x6bc23fd9 || inst == 0x0fc212c1) | |
c906108c SS |
1970 | save_rp = 0; |
1971 | ||
104c1213 | 1972 | /* These are the only ways we save SP into the stack. At this time |
c5aa993b | 1973 | the HP compilers never bother to save SP into the stack. */ |
104c1213 JM |
1974 | if ((inst & 0xffffc000) == 0x6fc10000 |
1975 | || (inst & 0xffffc00c) == 0x73c10008) | |
c906108c SS |
1976 | save_sp = 0; |
1977 | ||
6426a772 JM |
1978 | /* Are we loading some register with an offset from the argument |
1979 | pointer? */ | |
1980 | if ((inst & 0xffe00000) == 0x37a00000 | |
1981 | || (inst & 0xffffffe0) == 0x081d0240) | |
1982 | { | |
1983 | pc += 4; | |
1984 | continue; | |
1985 | } | |
1986 | ||
c906108c SS |
1987 | /* Account for general and floating-point register saves. */ |
1988 | reg_num = inst_saves_gr (inst); | |
1989 | save_gr &= ~(1 << reg_num); | |
1990 | ||
1991 | /* Ugh. Also account for argument stores into the stack. | |
c5aa993b JM |
1992 | Unfortunately args_stored only tells us that some arguments |
1993 | where stored into the stack. Not how many or what kind! | |
c906108c | 1994 | |
c5aa993b JM |
1995 | This is a kludge as on the HP compiler sets this bit and it |
1996 | never does prologue scheduling. So once we see one, skip past | |
1997 | all of them. We have similar code for the fp arg stores below. | |
c906108c | 1998 | |
c5aa993b JM |
1999 | FIXME. Can still die if we have a mix of GR and FR argument |
2000 | stores! */ | |
6426a772 | 2001 | if (reg_num >= (TARGET_PTR_BIT == 64 ? 19 : 23) && reg_num <= 26) |
c906108c | 2002 | { |
6426a772 | 2003 | while (reg_num >= (TARGET_PTR_BIT == 64 ? 19 : 23) && reg_num <= 26) |
c906108c SS |
2004 | { |
2005 | pc += 4; | |
2006 | status = target_read_memory (pc, buf, 4); | |
2007 | inst = extract_unsigned_integer (buf, 4); | |
2008 | if (status != 0) | |
2009 | return pc; | |
2010 | reg_num = inst_saves_gr (inst); | |
2011 | } | |
2012 | args_stored = 0; | |
2013 | continue; | |
2014 | } | |
2015 | ||
2016 | reg_num = inst_saves_fr (inst); | |
2017 | save_fr &= ~(1 << reg_num); | |
2018 | ||
2019 | status = target_read_memory (pc + 4, buf, 4); | |
2020 | next_inst = extract_unsigned_integer (buf, 4); | |
c5aa993b | 2021 | |
c906108c SS |
2022 | /* Yow! */ |
2023 | if (status != 0) | |
2024 | return pc; | |
2025 | ||
2026 | /* We've got to be read to handle the ldo before the fp register | |
c5aa993b | 2027 | save. */ |
c906108c SS |
2028 | if ((inst & 0xfc000000) == 0x34000000 |
2029 | && inst_saves_fr (next_inst) >= 4 | |
6426a772 | 2030 | && inst_saves_fr (next_inst) <= (TARGET_PTR_BIT == 64 ? 11 : 7)) |
c906108c SS |
2031 | { |
2032 | /* So we drop into the code below in a reasonable state. */ | |
2033 | reg_num = inst_saves_fr (next_inst); | |
2034 | pc -= 4; | |
2035 | } | |
2036 | ||
2037 | /* Ugh. Also account for argument stores into the stack. | |
c5aa993b JM |
2038 | This is a kludge as on the HP compiler sets this bit and it |
2039 | never does prologue scheduling. So once we see one, skip past | |
2040 | all of them. */ | |
6426a772 | 2041 | if (reg_num >= 4 && reg_num <= (TARGET_PTR_BIT == 64 ? 11 : 7)) |
c906108c | 2042 | { |
6426a772 | 2043 | while (reg_num >= 4 && reg_num <= (TARGET_PTR_BIT == 64 ? 11 : 7)) |
c906108c SS |
2044 | { |
2045 | pc += 8; | |
2046 | status = target_read_memory (pc, buf, 4); | |
2047 | inst = extract_unsigned_integer (buf, 4); | |
2048 | if (status != 0) | |
2049 | return pc; | |
2050 | if ((inst & 0xfc000000) != 0x34000000) | |
2051 | break; | |
2052 | status = target_read_memory (pc + 4, buf, 4); | |
2053 | next_inst = extract_unsigned_integer (buf, 4); | |
2054 | if (status != 0) | |
2055 | return pc; | |
2056 | reg_num = inst_saves_fr (next_inst); | |
2057 | } | |
2058 | args_stored = 0; | |
2059 | continue; | |
2060 | } | |
2061 | ||
2062 | /* Quit if we hit any kind of branch. This can happen if a prologue | |
c5aa993b | 2063 | instruction is in the delay slot of the first call/branch. */ |
c906108c SS |
2064 | if (is_branch (inst)) |
2065 | break; | |
2066 | ||
2067 | /* What a crock. The HP compilers set args_stored even if no | |
c5aa993b JM |
2068 | arguments were stored into the stack (boo hiss). This could |
2069 | cause this code to then skip a bunch of user insns (up to the | |
2070 | first branch). | |
2071 | ||
2072 | To combat this we try to identify when args_stored was bogusly | |
2073 | set and clear it. We only do this when args_stored is nonzero, | |
2074 | all other resources are accounted for, and nothing changed on | |
2075 | this pass. */ | |
c906108c | 2076 | if (args_stored |
c5aa993b | 2077 | && !(save_gr || save_fr || save_rp || save_sp || stack_remaining > 0) |
c906108c SS |
2078 | && old_save_gr == save_gr && old_save_fr == save_fr |
2079 | && old_save_rp == save_rp && old_save_sp == save_sp | |
2080 | && old_stack_remaining == stack_remaining) | |
2081 | break; | |
c5aa993b | 2082 | |
c906108c SS |
2083 | /* Bump the PC. */ |
2084 | pc += 4; | |
2085 | } | |
2086 | ||
2087 | /* We've got a tenative location for the end of the prologue. However | |
2088 | because of limitations in the unwind descriptor mechanism we may | |
2089 | have went too far into user code looking for the save of a register | |
2090 | that does not exist. So, if there registers we expected to be saved | |
2091 | but never were, mask them out and restart. | |
2092 | ||
2093 | This should only happen in optimized code, and should be very rare. */ | |
c5aa993b | 2094 | if (save_gr || (save_fr && !(restart_fr || restart_gr))) |
c906108c SS |
2095 | { |
2096 | pc = orig_pc; | |
2097 | restart_gr = save_gr; | |
2098 | restart_fr = save_fr; | |
2099 | goto restart; | |
2100 | } | |
2101 | ||
2102 | return pc; | |
2103 | } | |
2104 | ||
2105 | ||
7be570e7 JM |
2106 | /* Return the address of the PC after the last prologue instruction if |
2107 | we can determine it from the debug symbols. Else return zero. */ | |
c906108c SS |
2108 | |
2109 | static CORE_ADDR | |
fba45db2 | 2110 | after_prologue (CORE_ADDR pc) |
c906108c SS |
2111 | { |
2112 | struct symtab_and_line sal; | |
2113 | CORE_ADDR func_addr, func_end; | |
2114 | struct symbol *f; | |
2115 | ||
7be570e7 JM |
2116 | /* If we can not find the symbol in the partial symbol table, then |
2117 | there is no hope we can determine the function's start address | |
2118 | with this code. */ | |
c906108c | 2119 | if (!find_pc_partial_function (pc, NULL, &func_addr, &func_end)) |
7be570e7 | 2120 | return 0; |
c906108c | 2121 | |
7be570e7 | 2122 | /* Get the line associated with FUNC_ADDR. */ |
c906108c SS |
2123 | sal = find_pc_line (func_addr, 0); |
2124 | ||
7be570e7 JM |
2125 | /* There are only two cases to consider. First, the end of the source line |
2126 | is within the function bounds. In that case we return the end of the | |
2127 | source line. Second is the end of the source line extends beyond the | |
2128 | bounds of the current function. We need to use the slow code to | |
2129 | examine instructions in that case. | |
c906108c | 2130 | |
7be570e7 JM |
2131 | Anything else is simply a bug elsewhere. Fixing it here is absolutely |
2132 | the wrong thing to do. In fact, it should be entirely possible for this | |
2133 | function to always return zero since the slow instruction scanning code | |
2134 | is supposed to *always* work. If it does not, then it is a bug. */ | |
2135 | if (sal.end < func_end) | |
2136 | return sal.end; | |
c5aa993b | 2137 | else |
7be570e7 | 2138 | return 0; |
c906108c SS |
2139 | } |
2140 | ||
2141 | /* To skip prologues, I use this predicate. Returns either PC itself | |
2142 | if the code at PC does not look like a function prologue; otherwise | |
2143 | returns an address that (if we're lucky) follows the prologue. If | |
2144 | LENIENT, then we must skip everything which is involved in setting | |
2145 | up the frame (it's OK to skip more, just so long as we don't skip | |
2146 | anything which might clobber the registers which are being saved. | |
2147 | Currently we must not skip more on the alpha, but we might the lenient | |
2148 | stuff some day. */ | |
2149 | ||
2150 | CORE_ADDR | |
fba45db2 | 2151 | hppa_skip_prologue (CORE_ADDR pc) |
c906108c | 2152 | { |
c5aa993b JM |
2153 | unsigned long inst; |
2154 | int offset; | |
2155 | CORE_ADDR post_prologue_pc; | |
2156 | char buf[4]; | |
c906108c | 2157 | |
c5aa993b JM |
2158 | /* See if we can determine the end of the prologue via the symbol table. |
2159 | If so, then return either PC, or the PC after the prologue, whichever | |
2160 | is greater. */ | |
c906108c | 2161 | |
c5aa993b | 2162 | post_prologue_pc = after_prologue (pc); |
c906108c | 2163 | |
7be570e7 JM |
2164 | /* If after_prologue returned a useful address, then use it. Else |
2165 | fall back on the instruction skipping code. | |
2166 | ||
2167 | Some folks have claimed this causes problems because the breakpoint | |
2168 | may be the first instruction of the prologue. If that happens, then | |
2169 | the instruction skipping code has a bug that needs to be fixed. */ | |
c5aa993b JM |
2170 | if (post_prologue_pc != 0) |
2171 | return max (pc, post_prologue_pc); | |
c5aa993b JM |
2172 | else |
2173 | return (skip_prologue_hard_way (pc)); | |
c906108c SS |
2174 | } |
2175 | ||
26d08f08 AC |
2176 | struct hppa_frame_cache |
2177 | { | |
2178 | CORE_ADDR base; | |
2179 | struct trad_frame_saved_reg *saved_regs; | |
2180 | }; | |
2181 | ||
2182 | static struct hppa_frame_cache * | |
2183 | hppa_frame_cache (struct frame_info *next_frame, void **this_cache) | |
2184 | { | |
2185 | struct hppa_frame_cache *cache; | |
2186 | long saved_gr_mask; | |
2187 | long saved_fr_mask; | |
2188 | CORE_ADDR this_sp; | |
2189 | long frame_size; | |
2190 | struct unwind_table_entry *u; | |
2191 | int i; | |
2192 | ||
2193 | if ((*this_cache) != NULL) | |
2194 | return (*this_cache); | |
2195 | cache = FRAME_OBSTACK_ZALLOC (struct hppa_frame_cache); | |
2196 | (*this_cache) = cache; | |
2197 | cache->saved_regs = trad_frame_alloc_saved_regs (next_frame); | |
2198 | ||
2199 | /* Yow! */ | |
2200 | u = find_unwind_entry (frame_func_unwind (next_frame)); | |
2201 | if (!u) | |
52b5e991 | 2202 | return (*this_cache); |
26d08f08 AC |
2203 | |
2204 | /* Turn the Entry_GR field into a bitmask. */ | |
2205 | saved_gr_mask = 0; | |
2206 | for (i = 3; i < u->Entry_GR + 3; i++) | |
2207 | { | |
2208 | /* Frame pointer gets saved into a special location. */ | |
eded0a31 | 2209 | if (u->Save_SP && i == HPPA_FP_REGNUM) |
26d08f08 AC |
2210 | continue; |
2211 | ||
2212 | saved_gr_mask |= (1 << i); | |
2213 | } | |
2214 | ||
2215 | /* Turn the Entry_FR field into a bitmask too. */ | |
2216 | saved_fr_mask = 0; | |
2217 | for (i = 12; i < u->Entry_FR + 12; i++) | |
2218 | saved_fr_mask |= (1 << i); | |
2219 | ||
2220 | /* Loop until we find everything of interest or hit a branch. | |
2221 | ||
2222 | For unoptimized GCC code and for any HP CC code this will never ever | |
2223 | examine any user instructions. | |
2224 | ||
2225 | For optimized GCC code we're faced with problems. GCC will schedule | |
2226 | its prologue and make prologue instructions available for delay slot | |
2227 | filling. The end result is user code gets mixed in with the prologue | |
2228 | and a prologue instruction may be in the delay slot of the first branch | |
2229 | or call. | |
2230 | ||
2231 | Some unexpected things are expected with debugging optimized code, so | |
2232 | we allow this routine to walk past user instructions in optimized | |
2233 | GCC code. */ | |
2234 | { | |
2235 | int final_iteration = 0; | |
2236 | CORE_ADDR pc; | |
3a515653 | 2237 | CORE_ADDR end_pc; |
26d08f08 AC |
2238 | int looking_for_sp = u->Save_SP; |
2239 | int looking_for_rp = u->Save_RP; | |
2240 | int fp_loc = -1; | |
3a515653 | 2241 | end_pc = skip_prologue_using_sal (frame_func_unwind (next_frame)); |
26d08f08 AC |
2242 | if (end_pc == 0) |
2243 | end_pc = frame_pc_unwind (next_frame); | |
2244 | frame_size = 0; | |
2245 | for (pc = frame_func_unwind (next_frame); | |
2246 | ((saved_gr_mask || saved_fr_mask | |
2247 | || looking_for_sp || looking_for_rp | |
2248 | || frame_size < (u->Total_frame_size << 3)) | |
2249 | && pc <= end_pc); | |
2250 | pc += 4) | |
2251 | { | |
2252 | int reg; | |
2253 | char buf4[4]; | |
2254 | long status = target_read_memory (pc, buf4, sizeof buf4); | |
2255 | long inst = extract_unsigned_integer (buf4, sizeof buf4); | |
2256 | ||
2257 | /* Note the interesting effects of this instruction. */ | |
2258 | frame_size += prologue_inst_adjust_sp (inst); | |
2259 | ||
2260 | /* There are limited ways to store the return pointer into the | |
2261 | stack. */ | |
2262 | if (inst == 0x6bc23fd9) /* stw rp,-0x14(sr0,sp) */ | |
2263 | { | |
2264 | looking_for_rp = 0; | |
2265 | cache->saved_regs[RP_REGNUM].addr = -20; | |
2266 | } | |
2267 | else if (inst == 0x0fc212c1) /* std rp,-0x10(sr0,sp) */ | |
2268 | { | |
2269 | looking_for_rp = 0; | |
2270 | cache->saved_regs[RP_REGNUM].addr = -16; | |
2271 | } | |
2272 | ||
2273 | /* Check to see if we saved SP into the stack. This also | |
2274 | happens to indicate the location of the saved frame | |
2275 | pointer. */ | |
2276 | if ((inst & 0xffffc000) == 0x6fc10000 /* stw,ma r1,N(sr0,sp) */ | |
2277 | || (inst & 0xffffc00c) == 0x73c10008) /* std,ma r1,N(sr0,sp) */ | |
2278 | { | |
2279 | looking_for_sp = 0; | |
eded0a31 | 2280 | cache->saved_regs[HPPA_FP_REGNUM].addr = 0; |
26d08f08 AC |
2281 | } |
2282 | ||
2283 | /* Account for general and floating-point register saves. */ | |
2284 | reg = inst_saves_gr (inst); | |
2285 | if (reg >= 3 && reg <= 18 | |
eded0a31 | 2286 | && (!u->Save_SP || reg != HPPA_FP_REGNUM)) |
26d08f08 AC |
2287 | { |
2288 | saved_gr_mask &= ~(1 << reg); | |
2289 | if ((inst >> 26) == 0x1b && extract_14 (inst) >= 0) | |
2290 | /* stwm with a positive displacement is a _post_ | |
2291 | _modify_. */ | |
2292 | cache->saved_regs[reg].addr = 0; | |
2293 | else if ((inst & 0xfc00000c) == 0x70000008) | |
2294 | /* A std has explicit post_modify forms. */ | |
2295 | cache->saved_regs[reg].addr = 0; | |
2296 | else | |
2297 | { | |
2298 | CORE_ADDR offset; | |
2299 | ||
2300 | if ((inst >> 26) == 0x1c) | |
2301 | offset = (inst & 0x1 ? -1 << 13 : 0) | (((inst >> 4) & 0x3ff) << 3); | |
2302 | else if ((inst >> 26) == 0x03) | |
2303 | offset = low_sign_extend (inst & 0x1f, 5); | |
2304 | else | |
2305 | offset = extract_14 (inst); | |
2306 | ||
2307 | /* Handle code with and without frame pointers. */ | |
2308 | if (u->Save_SP) | |
2309 | cache->saved_regs[reg].addr = offset; | |
2310 | else | |
2311 | cache->saved_regs[reg].addr = (u->Total_frame_size << 3) + offset; | |
2312 | } | |
2313 | } | |
2314 | ||
2315 | /* GCC handles callee saved FP regs a little differently. | |
2316 | ||
2317 | It emits an instruction to put the value of the start of | |
2318 | the FP store area into %r1. It then uses fstds,ma with a | |
2319 | basereg of %r1 for the stores. | |
2320 | ||
2321 | HP CC emits them at the current stack pointer modifying the | |
2322 | stack pointer as it stores each register. */ | |
2323 | ||
2324 | /* ldo X(%r3),%r1 or ldo X(%r30),%r1. */ | |
2325 | if ((inst & 0xffffc000) == 0x34610000 | |
2326 | || (inst & 0xffffc000) == 0x37c10000) | |
2327 | fp_loc = extract_14 (inst); | |
2328 | ||
2329 | reg = inst_saves_fr (inst); | |
2330 | if (reg >= 12 && reg <= 21) | |
2331 | { | |
2332 | /* Note +4 braindamage below is necessary because the FP | |
2333 | status registers are internally 8 registers rather than | |
2334 | the expected 4 registers. */ | |
2335 | saved_fr_mask &= ~(1 << reg); | |
2336 | if (fp_loc == -1) | |
2337 | { | |
2338 | /* 1st HP CC FP register store. After this | |
2339 | instruction we've set enough state that the GCC and | |
2340 | HPCC code are both handled in the same manner. */ | |
2341 | cache->saved_regs[reg + FP4_REGNUM + 4].addr = 0; | |
2342 | fp_loc = 8; | |
2343 | } | |
2344 | else | |
2345 | { | |
eded0a31 | 2346 | cache->saved_regs[reg + HPPA_FP0_REGNUM + 4].addr = fp_loc; |
26d08f08 AC |
2347 | fp_loc += 8; |
2348 | } | |
2349 | } | |
2350 | ||
2351 | /* Quit if we hit any kind of branch the previous iteration. */ | |
2352 | if (final_iteration) | |
2353 | break; | |
2354 | /* We want to look precisely one instruction beyond the branch | |
2355 | if we have not found everything yet. */ | |
2356 | if (is_branch (inst)) | |
2357 | final_iteration = 1; | |
2358 | } | |
2359 | } | |
2360 | ||
2361 | { | |
2362 | /* The frame base always represents the value of %sp at entry to | |
2363 | the current function (and is thus equivalent to the "saved" | |
2364 | stack pointer. */ | |
eded0a31 | 2365 | CORE_ADDR this_sp = frame_unwind_register_unsigned (next_frame, HPPA_SP_REGNUM); |
26d08f08 AC |
2366 | /* FIXME: cagney/2004-02-22: This assumes that the frame has been |
2367 | created. If it hasn't everything will be out-of-wack. */ | |
eded0a31 | 2368 | if (u->Save_SP && trad_frame_addr_p (cache->saved_regs, HPPA_SP_REGNUM)) |
26d08f08 AC |
2369 | /* Both we're expecting the SP to be saved and the SP has been |
2370 | saved. The entry SP value is saved at this frame's SP | |
2371 | address. */ | |
2372 | cache->base = read_memory_integer (this_sp, TARGET_PTR_BIT / 8); | |
2373 | else | |
2374 | /* The prologue has been slowly allocating stack space. Adjust | |
2375 | the SP back. */ | |
2376 | cache->base = this_sp - frame_size; | |
eded0a31 | 2377 | trad_frame_set_value (cache->saved_regs, HPPA_SP_REGNUM, cache->base); |
26d08f08 AC |
2378 | } |
2379 | ||
412275d5 AC |
2380 | /* The PC is found in the "return register", "Millicode" uses "r31" |
2381 | as the return register while normal code uses "rp". */ | |
26d08f08 | 2382 | if (u->Millicode) |
412275d5 | 2383 | cache->saved_regs[PCOQ_HEAD_REGNUM] = cache->saved_regs[31]; |
26d08f08 | 2384 | else |
412275d5 | 2385 | cache->saved_regs[PCOQ_HEAD_REGNUM] = cache->saved_regs[RP_REGNUM]; |
26d08f08 AC |
2386 | |
2387 | { | |
2388 | /* Convert all the offsets into addresses. */ | |
2389 | int reg; | |
2390 | for (reg = 0; reg < NUM_REGS; reg++) | |
2391 | { | |
2392 | if (trad_frame_addr_p (cache->saved_regs, reg)) | |
2393 | cache->saved_regs[reg].addr += cache->base; | |
2394 | } | |
2395 | } | |
2396 | ||
2397 | return (*this_cache); | |
2398 | } | |
2399 | ||
2400 | static void | |
2401 | hppa_frame_this_id (struct frame_info *next_frame, void **this_cache, | |
2402 | struct frame_id *this_id) | |
2403 | { | |
2404 | struct hppa_frame_cache *info = hppa_frame_cache (next_frame, this_cache); | |
2405 | (*this_id) = frame_id_build (info->base, frame_func_unwind (next_frame)); | |
2406 | } | |
2407 | ||
2408 | static void | |
2409 | hppa_frame_prev_register (struct frame_info *next_frame, | |
2410 | void **this_cache, | |
2411 | int regnum, int *optimizedp, | |
2412 | enum lval_type *lvalp, CORE_ADDR *addrp, | |
2413 | int *realnump, void *valuep) | |
2414 | { | |
2415 | struct hppa_frame_cache *info = hppa_frame_cache (next_frame, this_cache); | |
412275d5 AC |
2416 | struct gdbarch *gdbarch = get_frame_arch (next_frame); |
2417 | if (regnum == PCOQ_TAIL_REGNUM) | |
2418 | { | |
2419 | /* The PCOQ TAIL, or NPC, needs to be computed from the unwound | |
2420 | PC register. */ | |
2421 | *optimizedp = 0; | |
2422 | *lvalp = not_lval; | |
2423 | *addrp = 0; | |
2424 | *realnump = 0; | |
2425 | if (valuep) | |
2426 | { | |
2427 | int regsize = register_size (gdbarch, PCOQ_HEAD_REGNUM); | |
2428 | CORE_ADDR pc; | |
2429 | int optimized; | |
2430 | enum lval_type lval; | |
2431 | CORE_ADDR addr; | |
2432 | int realnum; | |
2433 | bfd_byte value[MAX_REGISTER_SIZE]; | |
2434 | trad_frame_prev_register (next_frame, info->saved_regs, | |
2435 | PCOQ_HEAD_REGNUM, &optimized, &lval, &addr, | |
2436 | &realnum, &value); | |
2437 | pc = extract_unsigned_integer (&value, regsize); | |
2438 | store_unsigned_integer (valuep, regsize, pc + 4); | |
2439 | } | |
2440 | } | |
2441 | else | |
2442 | { | |
2443 | trad_frame_prev_register (next_frame, info->saved_regs, regnum, | |
2444 | optimizedp, lvalp, addrp, realnump, valuep); | |
2445 | } | |
26d08f08 AC |
2446 | } |
2447 | ||
2448 | static const struct frame_unwind hppa_frame_unwind = | |
2449 | { | |
2450 | NORMAL_FRAME, | |
2451 | hppa_frame_this_id, | |
2452 | hppa_frame_prev_register | |
2453 | }; | |
2454 | ||
2455 | static const struct frame_unwind * | |
2456 | hppa_frame_unwind_sniffer (struct frame_info *next_frame) | |
2457 | { | |
2458 | return &hppa_frame_unwind; | |
2459 | } | |
2460 | ||
2461 | static CORE_ADDR | |
2462 | hppa_frame_base_address (struct frame_info *next_frame, | |
2463 | void **this_cache) | |
2464 | { | |
2465 | struct hppa_frame_cache *info = hppa_frame_cache (next_frame, | |
2466 | this_cache); | |
2467 | return info->base; | |
2468 | } | |
2469 | ||
2470 | static const struct frame_base hppa_frame_base = { | |
2471 | &hppa_frame_unwind, | |
2472 | hppa_frame_base_address, | |
2473 | hppa_frame_base_address, | |
2474 | hppa_frame_base_address | |
2475 | }; | |
2476 | ||
2477 | static const struct frame_base * | |
2478 | hppa_frame_base_sniffer (struct frame_info *next_frame) | |
2479 | { | |
2480 | return &hppa_frame_base; | |
2481 | } | |
2482 | ||
2483 | static struct frame_id | |
2484 | hppa_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame) | |
2485 | { | |
2486 | return frame_id_build (frame_unwind_register_unsigned (next_frame, | |
eded0a31 | 2487 | HPPA_SP_REGNUM), |
26d08f08 AC |
2488 | frame_pc_unwind (next_frame)); |
2489 | } | |
2490 | ||
2491 | static CORE_ADDR | |
2492 | hppa_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) | |
2493 | { | |
449e1137 | 2494 | return frame_unwind_register_signed (next_frame, PCOQ_HEAD_REGNUM) & ~3; |
26d08f08 AC |
2495 | } |
2496 | ||
c906108c SS |
2497 | /* Exception handling support for the HP-UX ANSI C++ compiler. |
2498 | The compiler (aCC) provides a callback for exception events; | |
2499 | GDB can set a breakpoint on this callback and find out what | |
2500 | exception event has occurred. */ | |
2501 | ||
2502 | /* The name of the hook to be set to point to the callback function */ | |
c5aa993b JM |
2503 | static char HP_ACC_EH_notify_hook[] = "__eh_notify_hook"; |
2504 | /* The name of the function to be used to set the hook value */ | |
2505 | static char HP_ACC_EH_set_hook_value[] = "__eh_set_hook_value"; | |
2506 | /* The name of the callback function in end.o */ | |
c906108c | 2507 | static char HP_ACC_EH_notify_callback[] = "__d_eh_notify_callback"; |
c5aa993b JM |
2508 | /* Name of function in end.o on which a break is set (called by above) */ |
2509 | static char HP_ACC_EH_break[] = "__d_eh_break"; | |
2510 | /* Name of flag (in end.o) that enables catching throws */ | |
2511 | static char HP_ACC_EH_catch_throw[] = "__d_eh_catch_throw"; | |
2512 | /* Name of flag (in end.o) that enables catching catching */ | |
2513 | static char HP_ACC_EH_catch_catch[] = "__d_eh_catch_catch"; | |
2514 | /* The enum used by aCC */ | |
2515 | typedef enum | |
2516 | { | |
2517 | __EH_NOTIFY_THROW, | |
2518 | __EH_NOTIFY_CATCH | |
2519 | } | |
2520 | __eh_notification; | |
c906108c SS |
2521 | |
2522 | /* Is exception-handling support available with this executable? */ | |
2523 | static int hp_cxx_exception_support = 0; | |
2524 | /* Has the initialize function been run? */ | |
2525 | int hp_cxx_exception_support_initialized = 0; | |
2526 | /* Similar to above, but imported from breakpoint.c -- non-target-specific */ | |
2527 | extern int exception_support_initialized; | |
2528 | /* Address of __eh_notify_hook */ | |
a0b3c4fd | 2529 | static CORE_ADDR eh_notify_hook_addr = 0; |
c906108c | 2530 | /* Address of __d_eh_notify_callback */ |
a0b3c4fd | 2531 | static CORE_ADDR eh_notify_callback_addr = 0; |
c906108c | 2532 | /* Address of __d_eh_break */ |
a0b3c4fd | 2533 | static CORE_ADDR eh_break_addr = 0; |
c906108c | 2534 | /* Address of __d_eh_catch_catch */ |
a0b3c4fd | 2535 | static CORE_ADDR eh_catch_catch_addr = 0; |
c906108c | 2536 | /* Address of __d_eh_catch_throw */ |
a0b3c4fd | 2537 | static CORE_ADDR eh_catch_throw_addr = 0; |
c906108c | 2538 | /* Sal for __d_eh_break */ |
a0b3c4fd | 2539 | static struct symtab_and_line *break_callback_sal = 0; |
c906108c SS |
2540 | |
2541 | /* Code in end.c expects __d_pid to be set in the inferior, | |
2542 | otherwise __d_eh_notify_callback doesn't bother to call | |
2543 | __d_eh_break! So we poke the pid into this symbol | |
2544 | ourselves. | |
2545 | 0 => success | |
c5aa993b | 2546 | 1 => failure */ |
c906108c | 2547 | int |
fba45db2 | 2548 | setup_d_pid_in_inferior (void) |
c906108c SS |
2549 | { |
2550 | CORE_ADDR anaddr; | |
c5aa993b JM |
2551 | struct minimal_symbol *msymbol; |
2552 | char buf[4]; /* FIXME 32x64? */ | |
2553 | ||
c906108c SS |
2554 | /* Slam the pid of the process into __d_pid; failing is only a warning! */ |
2555 | msymbol = lookup_minimal_symbol ("__d_pid", NULL, symfile_objfile); | |
2556 | if (msymbol == NULL) | |
2557 | { | |
2558 | warning ("Unable to find __d_pid symbol in object file."); | |
2559 | warning ("Suggest linking executable with -g (links in /opt/langtools/lib/end.o)."); | |
2560 | return 1; | |
2561 | } | |
2562 | ||
2563 | anaddr = SYMBOL_VALUE_ADDRESS (msymbol); | |
39f77062 | 2564 | store_unsigned_integer (buf, 4, PIDGET (inferior_ptid)); /* FIXME 32x64? */ |
c5aa993b | 2565 | if (target_write_memory (anaddr, buf, 4)) /* FIXME 32x64? */ |
c906108c SS |
2566 | { |
2567 | warning ("Unable to write __d_pid"); | |
2568 | warning ("Suggest linking executable with -g (links in /opt/langtools/lib/end.o)."); | |
2569 | return 1; | |
2570 | } | |
2571 | return 0; | |
2572 | } | |
2573 | ||
2574 | /* Initialize exception catchpoint support by looking for the | |
2575 | necessary hooks/callbacks in end.o, etc., and set the hook value to | |
2576 | point to the required debug function | |
2577 | ||
2578 | Return 0 => failure | |
c5aa993b | 2579 | 1 => success */ |
c906108c SS |
2580 | |
2581 | static int | |
fba45db2 | 2582 | initialize_hp_cxx_exception_support (void) |
c906108c SS |
2583 | { |
2584 | struct symtabs_and_lines sals; | |
c5aa993b JM |
2585 | struct cleanup *old_chain; |
2586 | struct cleanup *canonical_strings_chain = NULL; | |
c906108c | 2587 | int i; |
c5aa993b JM |
2588 | char *addr_start; |
2589 | char *addr_end = NULL; | |
2590 | char **canonical = (char **) NULL; | |
c906108c | 2591 | int thread = -1; |
c5aa993b JM |
2592 | struct symbol *sym = NULL; |
2593 | struct minimal_symbol *msym = NULL; | |
2594 | struct objfile *objfile; | |
c906108c SS |
2595 | asection *shlib_info; |
2596 | ||
2597 | /* Detect and disallow recursion. On HP-UX with aCC, infinite | |
2598 | recursion is a possibility because finding the hook for exception | |
2599 | callbacks involves making a call in the inferior, which means | |
2600 | re-inserting breakpoints which can re-invoke this code */ | |
2601 | ||
c5aa993b JM |
2602 | static int recurse = 0; |
2603 | if (recurse > 0) | |
c906108c SS |
2604 | { |
2605 | hp_cxx_exception_support_initialized = 0; | |
2606 | exception_support_initialized = 0; | |
2607 | return 0; | |
2608 | } | |
2609 | ||
2610 | hp_cxx_exception_support = 0; | |
2611 | ||
2612 | /* First check if we have seen any HP compiled objects; if not, | |
2613 | it is very unlikely that HP's idiosyncratic callback mechanism | |
2614 | for exception handling debug support will be available! | |
2615 | This will percolate back up to breakpoint.c, where our callers | |
2616 | will decide to try the g++ exception-handling support instead. */ | |
2617 | if (!hp_som_som_object_present) | |
2618 | return 0; | |
c5aa993b | 2619 | |
c906108c SS |
2620 | /* We have a SOM executable with SOM debug info; find the hooks */ |
2621 | ||
2622 | /* First look for the notify hook provided by aCC runtime libs */ | |
2623 | /* If we find this symbol, we conclude that the executable must | |
2624 | have HP aCC exception support built in. If this symbol is not | |
2625 | found, even though we're a HP SOM-SOM file, we may have been | |
2626 | built with some other compiler (not aCC). This results percolates | |
2627 | back up to our callers in breakpoint.c which can decide to | |
2628 | try the g++ style of exception support instead. | |
2629 | If this symbol is found but the other symbols we require are | |
2630 | not found, there is something weird going on, and g++ support | |
2631 | should *not* be tried as an alternative. | |
c5aa993b | 2632 | |
c906108c SS |
2633 | ASSUMPTION: Only HP aCC code will have __eh_notify_hook defined. |
2634 | ASSUMPTION: HP aCC and g++ modules cannot be linked together. */ | |
c5aa993b | 2635 | |
c906108c SS |
2636 | /* libCsup has this hook; it'll usually be non-debuggable */ |
2637 | msym = lookup_minimal_symbol (HP_ACC_EH_notify_hook, NULL, NULL); | |
2638 | if (msym) | |
2639 | { | |
2640 | eh_notify_hook_addr = SYMBOL_VALUE_ADDRESS (msym); | |
2641 | hp_cxx_exception_support = 1; | |
c5aa993b | 2642 | } |
c906108c SS |
2643 | else |
2644 | { | |
2645 | warning ("Unable to find exception callback hook (%s).", HP_ACC_EH_notify_hook); | |
2646 | warning ("Executable may not have been compiled debuggable with HP aCC."); | |
2647 | warning ("GDB will be unable to intercept exception events."); | |
2648 | eh_notify_hook_addr = 0; | |
2649 | hp_cxx_exception_support = 0; | |
2650 | return 0; | |
2651 | } | |
2652 | ||
c906108c | 2653 | /* Next look for the notify callback routine in end.o */ |
c5aa993b | 2654 | /* This is always available in the SOM symbol dictionary if end.o is linked in */ |
c906108c SS |
2655 | msym = lookup_minimal_symbol (HP_ACC_EH_notify_callback, NULL, NULL); |
2656 | if (msym) | |
2657 | { | |
2658 | eh_notify_callback_addr = SYMBOL_VALUE_ADDRESS (msym); | |
2659 | hp_cxx_exception_support = 1; | |
c5aa993b JM |
2660 | } |
2661 | else | |
c906108c SS |
2662 | { |
2663 | warning ("Unable to find exception callback routine (%s).", HP_ACC_EH_notify_callback); | |
2664 | warning ("Suggest linking executable with -g (links in /opt/langtools/lib/end.o)."); | |
2665 | warning ("GDB will be unable to intercept exception events."); | |
2666 | eh_notify_callback_addr = 0; | |
2667 | return 0; | |
2668 | } | |
2669 | ||
53a5351d | 2670 | #ifndef GDB_TARGET_IS_HPPA_20W |
c906108c SS |
2671 | /* Check whether the executable is dynamically linked or archive bound */ |
2672 | /* With an archive-bound executable we can use the raw addresses we find | |
2673 | for the callback function, etc. without modification. For an executable | |
2674 | with shared libraries, we have to do more work to find the plabel, which | |
2675 | can be the target of a call through $$dyncall from the aCC runtime support | |
2676 | library (libCsup) which is linked shared by default by aCC. */ | |
2677 | /* This test below was copied from somsolib.c/somread.c. It may not be a very | |
c5aa993b | 2678 | reliable one to test that an executable is linked shared. pai/1997-07-18 */ |
c906108c SS |
2679 | shlib_info = bfd_get_section_by_name (symfile_objfile->obfd, "$SHLIB_INFO$"); |
2680 | if (shlib_info && (bfd_section_size (symfile_objfile->obfd, shlib_info) != 0)) | |
2681 | { | |
2682 | /* The minsym we have has the local code address, but that's not the | |
2683 | plabel that can be used by an inter-load-module call. */ | |
2684 | /* Find solib handle for main image (which has end.o), and use that | |
2685 | and the min sym as arguments to __d_shl_get() (which does the equivalent | |
c5aa993b | 2686 | of shl_findsym()) to find the plabel. */ |
c906108c SS |
2687 | |
2688 | args_for_find_stub args; | |
2689 | static char message[] = "Error while finding exception callback hook:\n"; | |
c5aa993b | 2690 | |
c906108c SS |
2691 | args.solib_handle = som_solib_get_solib_by_pc (eh_notify_callback_addr); |
2692 | args.msym = msym; | |
a0b3c4fd | 2693 | args.return_val = 0; |
c5aa993b | 2694 | |
c906108c | 2695 | recurse++; |
4efb68b1 | 2696 | catch_errors (cover_find_stub_with_shl_get, &args, message, |
a0b3c4fd JM |
2697 | RETURN_MASK_ALL); |
2698 | eh_notify_callback_addr = args.return_val; | |
c906108c | 2699 | recurse--; |
c5aa993b | 2700 | |
c906108c | 2701 | exception_catchpoints_are_fragile = 1; |
c5aa993b | 2702 | |
c906108c | 2703 | if (!eh_notify_callback_addr) |
c5aa993b JM |
2704 | { |
2705 | /* We can get here either if there is no plabel in the export list | |
1faa59a8 | 2706 | for the main image, or if something strange happened (?) */ |
c5aa993b JM |
2707 | warning ("Couldn't find a plabel (indirect function label) for the exception callback."); |
2708 | warning ("GDB will not be able to intercept exception events."); | |
2709 | return 0; | |
2710 | } | |
c906108c SS |
2711 | } |
2712 | else | |
2713 | exception_catchpoints_are_fragile = 0; | |
53a5351d | 2714 | #endif |
c906108c | 2715 | |
c906108c | 2716 | /* Now, look for the breakpointable routine in end.o */ |
c5aa993b | 2717 | /* This should also be available in the SOM symbol dict. if end.o linked in */ |
c906108c SS |
2718 | msym = lookup_minimal_symbol (HP_ACC_EH_break, NULL, NULL); |
2719 | if (msym) | |
2720 | { | |
2721 | eh_break_addr = SYMBOL_VALUE_ADDRESS (msym); | |
2722 | hp_cxx_exception_support = 1; | |
c5aa993b | 2723 | } |
c906108c SS |
2724 | else |
2725 | { | |
2726 | warning ("Unable to find exception callback routine to set breakpoint (%s).", HP_ACC_EH_break); | |
2727 | warning ("Suggest linking executable with -g (link in /opt/langtools/lib/end.o)."); | |
2728 | warning ("GDB will be unable to intercept exception events."); | |
2729 | eh_break_addr = 0; | |
2730 | return 0; | |
2731 | } | |
2732 | ||
c906108c SS |
2733 | /* Next look for the catch enable flag provided in end.o */ |
2734 | sym = lookup_symbol (HP_ACC_EH_catch_catch, (struct block *) NULL, | |
176620f1 | 2735 | VAR_DOMAIN, 0, (struct symtab **) NULL); |
c5aa993b | 2736 | if (sym) /* sometimes present in debug info */ |
c906108c SS |
2737 | { |
2738 | eh_catch_catch_addr = SYMBOL_VALUE_ADDRESS (sym); | |
2739 | hp_cxx_exception_support = 1; | |
2740 | } | |
c5aa993b JM |
2741 | else |
2742 | /* otherwise look in SOM symbol dict. */ | |
c906108c SS |
2743 | { |
2744 | msym = lookup_minimal_symbol (HP_ACC_EH_catch_catch, NULL, NULL); | |
2745 | if (msym) | |
c5aa993b JM |
2746 | { |
2747 | eh_catch_catch_addr = SYMBOL_VALUE_ADDRESS (msym); | |
2748 | hp_cxx_exception_support = 1; | |
2749 | } | |
c906108c | 2750 | else |
c5aa993b JM |
2751 | { |
2752 | warning ("Unable to enable interception of exception catches."); | |
2753 | warning ("Executable may not have been compiled debuggable with HP aCC."); | |
2754 | warning ("Suggest linking executable with -g (link in /opt/langtools/lib/end.o)."); | |
2755 | return 0; | |
2756 | } | |
c906108c SS |
2757 | } |
2758 | ||
c906108c SS |
2759 | /* Next look for the catch enable flag provided end.o */ |
2760 | sym = lookup_symbol (HP_ACC_EH_catch_catch, (struct block *) NULL, | |
176620f1 | 2761 | VAR_DOMAIN, 0, (struct symtab **) NULL); |
c5aa993b | 2762 | if (sym) /* sometimes present in debug info */ |
c906108c SS |
2763 | { |
2764 | eh_catch_throw_addr = SYMBOL_VALUE_ADDRESS (sym); | |
2765 | hp_cxx_exception_support = 1; | |
2766 | } | |
c5aa993b JM |
2767 | else |
2768 | /* otherwise look in SOM symbol dict. */ | |
c906108c SS |
2769 | { |
2770 | msym = lookup_minimal_symbol (HP_ACC_EH_catch_throw, NULL, NULL); | |
2771 | if (msym) | |
c5aa993b JM |
2772 | { |
2773 | eh_catch_throw_addr = SYMBOL_VALUE_ADDRESS (msym); | |
2774 | hp_cxx_exception_support = 1; | |
2775 | } | |
c906108c | 2776 | else |
c5aa993b JM |
2777 | { |
2778 | warning ("Unable to enable interception of exception throws."); | |
2779 | warning ("Executable may not have been compiled debuggable with HP aCC."); | |
2780 | warning ("Suggest linking executable with -g (link in /opt/langtools/lib/end.o)."); | |
2781 | return 0; | |
2782 | } | |
c906108c SS |
2783 | } |
2784 | ||
c5aa993b JM |
2785 | /* Set the flags */ |
2786 | hp_cxx_exception_support = 2; /* everything worked so far */ | |
c906108c SS |
2787 | hp_cxx_exception_support_initialized = 1; |
2788 | exception_support_initialized = 1; | |
2789 | ||
2790 | return 1; | |
2791 | } | |
2792 | ||
2793 | /* Target operation for enabling or disabling interception of | |
2794 | exception events. | |
2795 | KIND is either EX_EVENT_THROW or EX_EVENT_CATCH | |
2796 | ENABLE is either 0 (disable) or 1 (enable). | |
2797 | Return value is NULL if no support found; | |
2798 | -1 if something went wrong, | |
2799 | or a pointer to a symtab/line struct if the breakpointable | |
c5aa993b | 2800 | address was found. */ |
c906108c | 2801 | |
c5aa993b | 2802 | struct symtab_and_line * |
fba45db2 | 2803 | child_enable_exception_callback (enum exception_event_kind kind, int enable) |
c906108c SS |
2804 | { |
2805 | char buf[4]; | |
2806 | ||
2807 | if (!exception_support_initialized || !hp_cxx_exception_support_initialized) | |
2808 | if (!initialize_hp_cxx_exception_support ()) | |
2809 | return NULL; | |
2810 | ||
2811 | switch (hp_cxx_exception_support) | |
2812 | { | |
c5aa993b JM |
2813 | case 0: |
2814 | /* Assuming no HP support at all */ | |
2815 | return NULL; | |
2816 | case 1: | |
2817 | /* HP support should be present, but something went wrong */ | |
2818 | return (struct symtab_and_line *) -1; /* yuck! */ | |
2819 | /* there may be other cases in the future */ | |
c906108c | 2820 | } |
c5aa993b | 2821 | |
c906108c | 2822 | /* Set the EH hook to point to the callback routine */ |
c5aa993b | 2823 | store_unsigned_integer (buf, 4, enable ? eh_notify_callback_addr : 0); /* FIXME 32x64 problem */ |
c906108c | 2824 | /* pai: (temp) FIXME should there be a pack operation first? */ |
c5aa993b | 2825 | if (target_write_memory (eh_notify_hook_addr, buf, 4)) /* FIXME 32x64 problem */ |
c906108c SS |
2826 | { |
2827 | warning ("Could not write to target memory for exception event callback."); | |
2828 | warning ("Interception of exception events may not work."); | |
c5aa993b | 2829 | return (struct symtab_and_line *) -1; |
c906108c SS |
2830 | } |
2831 | if (enable) | |
2832 | { | |
c5aa993b | 2833 | /* Ensure that __d_pid is set up correctly -- end.c code checks this. :-( */ |
39f77062 | 2834 | if (PIDGET (inferior_ptid) > 0) |
c5aa993b JM |
2835 | { |
2836 | if (setup_d_pid_in_inferior ()) | |
2837 | return (struct symtab_and_line *) -1; | |
2838 | } | |
c906108c | 2839 | else |
c5aa993b | 2840 | { |
104c1213 JM |
2841 | warning ("Internal error: Invalid inferior pid? Cannot intercept exception events."); |
2842 | return (struct symtab_and_line *) -1; | |
c5aa993b | 2843 | } |
c906108c | 2844 | } |
c5aa993b | 2845 | |
c906108c SS |
2846 | switch (kind) |
2847 | { | |
c5aa993b JM |
2848 | case EX_EVENT_THROW: |
2849 | store_unsigned_integer (buf, 4, enable ? 1 : 0); | |
2850 | if (target_write_memory (eh_catch_throw_addr, buf, 4)) /* FIXME 32x64? */ | |
2851 | { | |
2852 | warning ("Couldn't enable exception throw interception."); | |
2853 | return (struct symtab_and_line *) -1; | |
2854 | } | |
2855 | break; | |
2856 | case EX_EVENT_CATCH: | |
2857 | store_unsigned_integer (buf, 4, enable ? 1 : 0); | |
2858 | if (target_write_memory (eh_catch_catch_addr, buf, 4)) /* FIXME 32x64? */ | |
2859 | { | |
2860 | warning ("Couldn't enable exception catch interception."); | |
2861 | return (struct symtab_and_line *) -1; | |
2862 | } | |
2863 | break; | |
104c1213 JM |
2864 | default: |
2865 | error ("Request to enable unknown or unsupported exception event."); | |
c906108c | 2866 | } |
c5aa993b | 2867 | |
c906108c SS |
2868 | /* Copy break address into new sal struct, malloc'ing if needed. */ |
2869 | if (!break_callback_sal) | |
2870 | { | |
2871 | break_callback_sal = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line)); | |
2872 | } | |
fe39c653 | 2873 | init_sal (break_callback_sal); |
c906108c SS |
2874 | break_callback_sal->symtab = NULL; |
2875 | break_callback_sal->pc = eh_break_addr; | |
2876 | break_callback_sal->line = 0; | |
2877 | break_callback_sal->end = eh_break_addr; | |
c5aa993b | 2878 | |
c906108c SS |
2879 | return break_callback_sal; |
2880 | } | |
2881 | ||
c5aa993b | 2882 | /* Record some information about the current exception event */ |
c906108c | 2883 | static struct exception_event_record current_ex_event; |
c5aa993b JM |
2884 | /* Convenience struct */ |
2885 | static struct symtab_and_line null_symtab_and_line = | |
2886 | {NULL, 0, 0, 0}; | |
c906108c SS |
2887 | |
2888 | /* Report current exception event. Returns a pointer to a record | |
2889 | that describes the kind of the event, where it was thrown from, | |
2890 | and where it will be caught. More information may be reported | |
c5aa993b | 2891 | in the future */ |
c906108c | 2892 | struct exception_event_record * |
fba45db2 | 2893 | child_get_current_exception_event (void) |
c906108c | 2894 | { |
c5aa993b JM |
2895 | CORE_ADDR event_kind; |
2896 | CORE_ADDR throw_addr; | |
2897 | CORE_ADDR catch_addr; | |
c906108c SS |
2898 | struct frame_info *fi, *curr_frame; |
2899 | int level = 1; | |
2900 | ||
c5aa993b | 2901 | curr_frame = get_current_frame (); |
c906108c SS |
2902 | if (!curr_frame) |
2903 | return (struct exception_event_record *) NULL; | |
2904 | ||
2905 | /* Go up one frame to __d_eh_notify_callback, because at the | |
2906 | point when this code is executed, there's garbage in the | |
2907 | arguments of __d_eh_break. */ | |
2908 | fi = find_relative_frame (curr_frame, &level); | |
2909 | if (level != 0) | |
2910 | return (struct exception_event_record *) NULL; | |
2911 | ||
0f7d239c | 2912 | select_frame (fi); |
c906108c SS |
2913 | |
2914 | /* Read in the arguments */ | |
2915 | /* __d_eh_notify_callback() is called with 3 arguments: | |
c5aa993b JM |
2916 | 1. event kind catch or throw |
2917 | 2. the target address if known | |
2918 | 3. a flag -- not sure what this is. pai/1997-07-17 */ | |
2919 | event_kind = read_register (ARG0_REGNUM); | |
c906108c SS |
2920 | catch_addr = read_register (ARG1_REGNUM); |
2921 | ||
2922 | /* Now go down to a user frame */ | |
2923 | /* For a throw, __d_eh_break is called by | |
c5aa993b JM |
2924 | __d_eh_notify_callback which is called by |
2925 | __notify_throw which is called | |
2926 | from user code. | |
c906108c | 2927 | For a catch, __d_eh_break is called by |
c5aa993b JM |
2928 | __d_eh_notify_callback which is called by |
2929 | <stackwalking stuff> which is called by | |
2930 | __throw__<stuff> or __rethrow_<stuff> which is called | |
2931 | from user code. */ | |
2932 | /* FIXME: Don't use such magic numbers; search for the frames */ | |
c906108c SS |
2933 | level = (event_kind == EX_EVENT_THROW) ? 3 : 4; |
2934 | fi = find_relative_frame (curr_frame, &level); | |
2935 | if (level != 0) | |
2936 | return (struct exception_event_record *) NULL; | |
2937 | ||
0f7d239c | 2938 | select_frame (fi); |
ef6e7e13 | 2939 | throw_addr = get_frame_pc (fi); |
c906108c SS |
2940 | |
2941 | /* Go back to original (top) frame */ | |
0f7d239c | 2942 | select_frame (curr_frame); |
c906108c SS |
2943 | |
2944 | current_ex_event.kind = (enum exception_event_kind) event_kind; | |
2945 | current_ex_event.throw_sal = find_pc_line (throw_addr, 1); | |
2946 | current_ex_event.catch_sal = find_pc_line (catch_addr, 1); | |
2947 | ||
2948 | return ¤t_ex_event; | |
2949 | } | |
2950 | ||
9a043c1d AC |
2951 | /* Instead of this nasty cast, add a method pvoid() that prints out a |
2952 | host VOID data type (remember %p isn't portable). */ | |
2953 | ||
2954 | static CORE_ADDR | |
2955 | hppa_pointer_to_address_hack (void *ptr) | |
2956 | { | |
2957 | gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr)); | |
2958 | return POINTER_TO_ADDRESS (builtin_type_void_data_ptr, &ptr); | |
2959 | } | |
2960 | ||
c906108c | 2961 | static void |
fba45db2 | 2962 | unwind_command (char *exp, int from_tty) |
c906108c SS |
2963 | { |
2964 | CORE_ADDR address; | |
2965 | struct unwind_table_entry *u; | |
2966 | ||
2967 | /* If we have an expression, evaluate it and use it as the address. */ | |
2968 | ||
2969 | if (exp != 0 && *exp != 0) | |
2970 | address = parse_and_eval_address (exp); | |
2971 | else | |
2972 | return; | |
2973 | ||
2974 | u = find_unwind_entry (address); | |
2975 | ||
2976 | if (!u) | |
2977 | { | |
2978 | printf_unfiltered ("Can't find unwind table entry for %s\n", exp); | |
2979 | return; | |
2980 | } | |
2981 | ||
ce414844 | 2982 | printf_unfiltered ("unwind_table_entry (0x%s):\n", |
9a043c1d | 2983 | paddr_nz (hppa_pointer_to_address_hack (u))); |
c906108c SS |
2984 | |
2985 | printf_unfiltered ("\tregion_start = "); | |
2986 | print_address (u->region_start, gdb_stdout); | |
2987 | ||
2988 | printf_unfiltered ("\n\tregion_end = "); | |
2989 | print_address (u->region_end, gdb_stdout); | |
2990 | ||
c906108c | 2991 | #define pif(FLD) if (u->FLD) printf_unfiltered (" "#FLD); |
c906108c SS |
2992 | |
2993 | printf_unfiltered ("\n\tflags ="); | |
2994 | pif (Cannot_unwind); | |
2995 | pif (Millicode); | |
2996 | pif (Millicode_save_sr0); | |
2997 | pif (Entry_SR); | |
2998 | pif (Args_stored); | |
2999 | pif (Variable_Frame); | |
3000 | pif (Separate_Package_Body); | |
3001 | pif (Frame_Extension_Millicode); | |
3002 | pif (Stack_Overflow_Check); | |
3003 | pif (Two_Instruction_SP_Increment); | |
3004 | pif (Ada_Region); | |
3005 | pif (Save_SP); | |
3006 | pif (Save_RP); | |
3007 | pif (Save_MRP_in_frame); | |
3008 | pif (extn_ptr_defined); | |
3009 | pif (Cleanup_defined); | |
3010 | pif (MPE_XL_interrupt_marker); | |
3011 | pif (HP_UX_interrupt_marker); | |
3012 | pif (Large_frame); | |
3013 | ||
3014 | putchar_unfiltered ('\n'); | |
3015 | ||
c906108c | 3016 | #define pin(FLD) printf_unfiltered ("\t"#FLD" = 0x%x\n", u->FLD); |
c906108c SS |
3017 | |
3018 | pin (Region_description); | |
3019 | pin (Entry_FR); | |
3020 | pin (Entry_GR); | |
3021 | pin (Total_frame_size); | |
3022 | } | |
c906108c | 3023 | |
c2c6d25f | 3024 | void |
fba45db2 | 3025 | hppa_skip_permanent_breakpoint (void) |
c2c6d25f JM |
3026 | { |
3027 | /* To step over a breakpoint instruction on the PA takes some | |
3028 | fiddling with the instruction address queue. | |
3029 | ||
3030 | When we stop at a breakpoint, the IA queue front (the instruction | |
3031 | we're executing now) points at the breakpoint instruction, and | |
3032 | the IA queue back (the next instruction to execute) points to | |
3033 | whatever instruction we would execute after the breakpoint, if it | |
3034 | were an ordinary instruction. This is the case even if the | |
3035 | breakpoint is in the delay slot of a branch instruction. | |
3036 | ||
3037 | Clearly, to step past the breakpoint, we need to set the queue | |
3038 | front to the back. But what do we put in the back? What | |
3039 | instruction comes after that one? Because of the branch delay | |
3040 | slot, the next insn is always at the back + 4. */ | |
3041 | write_register (PCOQ_HEAD_REGNUM, read_register (PCOQ_TAIL_REGNUM)); | |
3042 | write_register (PCSQ_HEAD_REGNUM, read_register (PCSQ_TAIL_REGNUM)); | |
3043 | ||
3044 | write_register (PCOQ_TAIL_REGNUM, read_register (PCOQ_TAIL_REGNUM) + 4); | |
3045 | /* We can leave the tail's space the same, since there's no jump. */ | |
3046 | } | |
3047 | ||
d709c020 JB |
3048 | int |
3049 | hppa_reg_struct_has_addr (int gcc_p, struct type *type) | |
3050 | { | |
3051 | /* On the PA, any pass-by-value structure > 8 bytes is actually passed | |
3052 | via a pointer regardless of its type or the compiler used. */ | |
3053 | return (TYPE_LENGTH (type) > 8); | |
3054 | } | |
3055 | ||
3056 | int | |
3057 | hppa_inner_than (CORE_ADDR lhs, CORE_ADDR rhs) | |
3058 | { | |
3059 | /* Stack grows upward */ | |
3060 | return (lhs > rhs); | |
3061 | } | |
3062 | ||
d709c020 JB |
3063 | int |
3064 | hppa_pc_requires_run_before_use (CORE_ADDR pc) | |
3065 | { | |
3066 | /* Sometimes we may pluck out a minimal symbol that has a negative address. | |
3067 | ||
3068 | An example of this occurs when an a.out is linked against a foo.sl. | |
3069 | The foo.sl defines a global bar(), and the a.out declares a signature | |
3070 | for bar(). However, the a.out doesn't directly call bar(), but passes | |
3071 | its address in another call. | |
3072 | ||
3073 | If you have this scenario and attempt to "break bar" before running, | |
3074 | gdb will find a minimal symbol for bar() in the a.out. But that | |
3075 | symbol's address will be negative. What this appears to denote is | |
3076 | an index backwards from the base of the procedure linkage table (PLT) | |
3077 | into the data linkage table (DLT), the end of which is contiguous | |
3078 | with the start of the PLT. This is clearly not a valid address for | |
3079 | us to set a breakpoint on. | |
3080 | ||
3081 | Note that one must be careful in how one checks for a negative address. | |
3082 | 0xc0000000 is a legitimate address of something in a shared text | |
3083 | segment, for example. Since I don't know what the possible range | |
3084 | is of these "really, truly negative" addresses that come from the | |
3085 | minimal symbols, I'm resorting to the gross hack of checking the | |
3086 | top byte of the address for all 1's. Sigh. */ | |
3087 | ||
3088 | return (!target_has_stack && (pc & 0xFF000000)); | |
3089 | } | |
3090 | ||
3091 | int | |
3092 | hppa_instruction_nullified (void) | |
3093 | { | |
3094 | /* brobecker 2002/11/07: Couldn't we use a ULONGEST here? It would | |
3095 | avoid the type cast. I'm leaving it as is for now as I'm doing | |
3096 | semi-mechanical multiarching-related changes. */ | |
3097 | const int ipsw = (int) read_register (IPSW_REGNUM); | |
3098 | const int flags = (int) read_register (FLAGS_REGNUM); | |
3099 | ||
3100 | return ((ipsw & 0x00200000) && !(flags & 0x2)); | |
3101 | } | |
3102 | ||
d709c020 JB |
3103 | /* Return the GDB type object for the "standard" data type of data |
3104 | in register N. */ | |
3105 | ||
eded0a31 AC |
3106 | static struct type * |
3107 | hppa32_register_type (struct gdbarch *gdbarch, int reg_nr) | |
d709c020 JB |
3108 | { |
3109 | if (reg_nr < FP4_REGNUM) | |
eded0a31 | 3110 | return builtin_type_uint32; |
d709c020 | 3111 | else |
eded0a31 | 3112 | return builtin_type_ieee_single_big; |
d709c020 JB |
3113 | } |
3114 | ||
3ff7cf9e JB |
3115 | /* Return the GDB type object for the "standard" data type of data |
3116 | in register N. hppa64 version. */ | |
3117 | ||
eded0a31 AC |
3118 | static struct type * |
3119 | hppa64_register_type (struct gdbarch *gdbarch, int reg_nr) | |
3ff7cf9e JB |
3120 | { |
3121 | if (reg_nr < FP4_REGNUM) | |
eded0a31 | 3122 | return builtin_type_uint64; |
3ff7cf9e | 3123 | else |
eded0a31 | 3124 | return builtin_type_ieee_double_big; |
3ff7cf9e JB |
3125 | } |
3126 | ||
d709c020 JB |
3127 | /* Return True if REGNUM is not a register available to the user |
3128 | through ptrace(). */ | |
3129 | ||
3130 | int | |
3131 | hppa_cannot_store_register (int regnum) | |
3132 | { | |
3133 | return (regnum == 0 | |
3134 | || regnum == PCSQ_HEAD_REGNUM | |
3135 | || (regnum >= PCSQ_TAIL_REGNUM && regnum < IPSW_REGNUM) | |
3136 | || (regnum > IPSW_REGNUM && regnum < FP4_REGNUM)); | |
3137 | ||
3138 | } | |
3139 | ||
d709c020 JB |
3140 | CORE_ADDR |
3141 | hppa_smash_text_address (CORE_ADDR addr) | |
3142 | { | |
3143 | /* The low two bits of the PC on the PA contain the privilege level. | |
3144 | Some genius implementing a (non-GCC) compiler apparently decided | |
3145 | this means that "addresses" in a text section therefore include a | |
3146 | privilege level, and thus symbol tables should contain these bits. | |
3147 | This seems like a bonehead thing to do--anyway, it seems to work | |
3148 | for our purposes to just ignore those bits. */ | |
3149 | ||
3150 | return (addr &= ~0x3); | |
3151 | } | |
3152 | ||
143985b7 AF |
3153 | /* Get the ith function argument for the current function. */ |
3154 | CORE_ADDR | |
3155 | hppa_fetch_pointer_argument (struct frame_info *frame, int argi, | |
3156 | struct type *type) | |
3157 | { | |
3158 | CORE_ADDR addr; | |
7f5f525d | 3159 | get_frame_register (frame, R0_REGNUM + 26 - argi, &addr); |
143985b7 AF |
3160 | return addr; |
3161 | } | |
3162 | ||
8e8b2dba MC |
3163 | /* Here is a table of C type sizes on hppa with various compiles |
3164 | and options. I measured this on PA 9000/800 with HP-UX 11.11 | |
3165 | and these compilers: | |
3166 | ||
3167 | /usr/ccs/bin/cc HP92453-01 A.11.01.21 | |
3168 | /opt/ansic/bin/cc HP92453-01 B.11.11.28706.GP | |
3169 | /opt/aCC/bin/aCC B3910B A.03.45 | |
3170 | gcc gcc 3.3.2 native hppa2.0w-hp-hpux11.11 | |
3171 | ||
3172 | cc : 1 2 4 4 8 : 4 8 -- : 4 4 | |
3173 | ansic +DA1.1 : 1 2 4 4 8 : 4 8 16 : 4 4 | |
3174 | ansic +DA2.0 : 1 2 4 4 8 : 4 8 16 : 4 4 | |
3175 | ansic +DA2.0W : 1 2 4 8 8 : 4 8 16 : 8 8 | |
3176 | acc +DA1.1 : 1 2 4 4 8 : 4 8 16 : 4 4 | |
3177 | acc +DA2.0 : 1 2 4 4 8 : 4 8 16 : 4 4 | |
3178 | acc +DA2.0W : 1 2 4 8 8 : 4 8 16 : 8 8 | |
3179 | gcc : 1 2 4 4 8 : 4 8 16 : 4 4 | |
3180 | ||
3181 | Each line is: | |
3182 | ||
3183 | compiler and options | |
3184 | char, short, int, long, long long | |
3185 | float, double, long double | |
3186 | char *, void (*)() | |
3187 | ||
3188 | So all these compilers use either ILP32 or LP64 model. | |
3189 | TODO: gcc has more options so it needs more investigation. | |
3190 | ||
a2379359 MC |
3191 | For floating point types, see: |
3192 | ||
3193 | http://docs.hp.com/hpux/pdf/B3906-90006.pdf | |
3194 | HP-UX floating-point guide, hpux 11.00 | |
3195 | ||
8e8b2dba MC |
3196 | -- chastain 2003-12-18 */ |
3197 | ||
e6e68f1f JB |
3198 | static struct gdbarch * |
3199 | hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | |
3200 | { | |
3ff7cf9e | 3201 | struct gdbarch_tdep *tdep; |
e6e68f1f | 3202 | struct gdbarch *gdbarch; |
59623e27 JB |
3203 | |
3204 | /* Try to determine the ABI of the object we are loading. */ | |
4be87837 | 3205 | if (info.abfd != NULL && info.osabi == GDB_OSABI_UNKNOWN) |
59623e27 | 3206 | { |
4be87837 DJ |
3207 | /* If it's a SOM file, assume it's HP/UX SOM. */ |
3208 | if (bfd_get_flavour (info.abfd) == bfd_target_som_flavour) | |
3209 | info.osabi = GDB_OSABI_HPUX_SOM; | |
59623e27 | 3210 | } |
e6e68f1f JB |
3211 | |
3212 | /* find a candidate among the list of pre-declared architectures. */ | |
3213 | arches = gdbarch_list_lookup_by_info (arches, &info); | |
3214 | if (arches != NULL) | |
3215 | return (arches->gdbarch); | |
3216 | ||
3217 | /* If none found, then allocate and initialize one. */ | |
3ff7cf9e JB |
3218 | tdep = XMALLOC (struct gdbarch_tdep); |
3219 | gdbarch = gdbarch_alloc (&info, tdep); | |
3220 | ||
3221 | /* Determine from the bfd_arch_info structure if we are dealing with | |
3222 | a 32 or 64 bits architecture. If the bfd_arch_info is not available, | |
3223 | then default to a 32bit machine. */ | |
3224 | if (info.bfd_arch_info != NULL) | |
3225 | tdep->bytes_per_address = | |
3226 | info.bfd_arch_info->bits_per_address / info.bfd_arch_info->bits_per_byte; | |
3227 | else | |
3228 | tdep->bytes_per_address = 4; | |
3229 | ||
3230 | /* Some parts of the gdbarch vector depend on whether we are running | |
3231 | on a 32 bits or 64 bits target. */ | |
3232 | switch (tdep->bytes_per_address) | |
3233 | { | |
3234 | case 4: | |
3235 | set_gdbarch_num_regs (gdbarch, hppa32_num_regs); | |
3236 | set_gdbarch_register_name (gdbarch, hppa32_register_name); | |
eded0a31 | 3237 | set_gdbarch_register_type (gdbarch, hppa32_register_type); |
3ff7cf9e JB |
3238 | break; |
3239 | case 8: | |
3240 | set_gdbarch_num_regs (gdbarch, hppa64_num_regs); | |
3241 | set_gdbarch_register_name (gdbarch, hppa64_register_name); | |
eded0a31 | 3242 | set_gdbarch_register_type (gdbarch, hppa64_register_type); |
3ff7cf9e JB |
3243 | break; |
3244 | default: | |
3245 | internal_error (__FILE__, __LINE__, "Unsupported address size: %d", | |
3246 | tdep->bytes_per_address); | |
3247 | } | |
3248 | ||
3ff7cf9e | 3249 | set_gdbarch_long_bit (gdbarch, tdep->bytes_per_address * TARGET_CHAR_BIT); |
3ff7cf9e | 3250 | set_gdbarch_ptr_bit (gdbarch, tdep->bytes_per_address * TARGET_CHAR_BIT); |
e6e68f1f | 3251 | |
8e8b2dba MC |
3252 | /* The following gdbarch vector elements are the same in both ILP32 |
3253 | and LP64, but might show differences some day. */ | |
3254 | set_gdbarch_long_long_bit (gdbarch, 64); | |
3255 | set_gdbarch_long_double_bit (gdbarch, 128); | |
a2379359 | 3256 | set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_big); |
8e8b2dba | 3257 | |
3ff7cf9e JB |
3258 | /* The following gdbarch vector elements do not depend on the address |
3259 | size, or in any other gdbarch element previously set. */ | |
60383d10 JB |
3260 | set_gdbarch_skip_prologue (gdbarch, hppa_skip_prologue); |
3261 | set_gdbarch_skip_trampoline_code (gdbarch, hppa_skip_trampoline_code); | |
3262 | set_gdbarch_in_solib_call_trampoline (gdbarch, hppa_in_solib_call_trampoline); | |
3263 | set_gdbarch_in_solib_return_trampoline (gdbarch, | |
3264 | hppa_in_solib_return_trampoline); | |
60383d10 | 3265 | set_gdbarch_inner_than (gdbarch, hppa_inner_than); |
eded0a31 AC |
3266 | set_gdbarch_sp_regnum (gdbarch, HPPA_SP_REGNUM); |
3267 | set_gdbarch_fp0_regnum (gdbarch, HPPA_FP0_REGNUM); | |
60383d10 | 3268 | set_gdbarch_cannot_store_register (gdbarch, hppa_cannot_store_register); |
b6fbdd1d | 3269 | set_gdbarch_addr_bits_remove (gdbarch, hppa_smash_text_address); |
60383d10 JB |
3270 | set_gdbarch_smash_text_address (gdbarch, hppa_smash_text_address); |
3271 | set_gdbarch_believe_pcc_promotion (gdbarch, 1); | |
3272 | set_gdbarch_read_pc (gdbarch, hppa_target_read_pc); | |
3273 | set_gdbarch_write_pc (gdbarch, hppa_target_write_pc); | |
60383d10 | 3274 | |
143985b7 AF |
3275 | /* Helper for function argument information. */ |
3276 | set_gdbarch_fetch_pointer_argument (gdbarch, hppa_fetch_pointer_argument); | |
3277 | ||
36482093 AC |
3278 | set_gdbarch_print_insn (gdbarch, print_insn_hppa); |
3279 | ||
3a3bc038 AC |
3280 | /* When a hardware watchpoint triggers, we'll move the inferior past |
3281 | it by removing all eventpoints; stepping past the instruction | |
3282 | that caused the trigger; reinserting eventpoints; and checking | |
3283 | whether any watched location changed. */ | |
3284 | set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1); | |
3285 | ||
5979bc46 | 3286 | /* Inferior function call methods. */ |
fca7aa43 | 3287 | switch (tdep->bytes_per_address) |
5979bc46 | 3288 | { |
fca7aa43 AC |
3289 | case 4: |
3290 | set_gdbarch_push_dummy_call (gdbarch, hppa32_push_dummy_call); | |
3291 | set_gdbarch_frame_align (gdbarch, hppa32_frame_align); | |
3292 | break; | |
3293 | case 8: | |
782eae8b AC |
3294 | set_gdbarch_push_dummy_call (gdbarch, hppa64_push_dummy_call); |
3295 | set_gdbarch_frame_align (gdbarch, hppa64_frame_align); | |
fca7aa43 | 3296 | break; |
782eae8b AC |
3297 | default: |
3298 | internal_error (__FILE__, __LINE__, "bad switch"); | |
fad850b2 AC |
3299 | } |
3300 | ||
3301 | /* Struct return methods. */ | |
fca7aa43 | 3302 | switch (tdep->bytes_per_address) |
fad850b2 | 3303 | { |
fca7aa43 AC |
3304 | case 4: |
3305 | set_gdbarch_return_value (gdbarch, hppa32_return_value); | |
3306 | break; | |
3307 | case 8: | |
782eae8b | 3308 | set_gdbarch_return_value (gdbarch, hppa64_return_value); |
f5f907e2 | 3309 | break; |
fca7aa43 AC |
3310 | default: |
3311 | internal_error (__FILE__, __LINE__, "bad switch"); | |
e963316f AC |
3312 | } |
3313 | ||
5979bc46 | 3314 | /* Frame unwind methods. */ |
782eae8b AC |
3315 | set_gdbarch_unwind_dummy_id (gdbarch, hppa_unwind_dummy_id); |
3316 | set_gdbarch_unwind_pc (gdbarch, hppa_unwind_pc); | |
3317 | frame_unwind_append_sniffer (gdbarch, hppa_frame_unwind_sniffer); | |
3318 | frame_base_append_sniffer (gdbarch, hppa_frame_base_sniffer); | |
5979bc46 | 3319 | |
752d4ac1 JB |
3320 | /* Hook in ABI-specific overrides, if they have been registered. */ |
3321 | gdbarch_init_osabi (info, gdbarch); | |
3322 | ||
e6e68f1f JB |
3323 | return gdbarch; |
3324 | } | |
3325 | ||
3326 | static void | |
3327 | hppa_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file) | |
3328 | { | |
3329 | /* Nothing to print for the moment. */ | |
3330 | } | |
3331 | ||
4facf7e8 JB |
3332 | void |
3333 | _initialize_hppa_tdep (void) | |
3334 | { | |
3335 | struct cmd_list_element *c; | |
3336 | void break_at_finish_command (char *arg, int from_tty); | |
3337 | void tbreak_at_finish_command (char *arg, int from_tty); | |
3338 | void break_at_finish_at_depth_command (char *arg, int from_tty); | |
3339 | ||
e6e68f1f | 3340 | gdbarch_register (bfd_arch_hppa, hppa_gdbarch_init, hppa_dump_tdep); |
4facf7e8 JB |
3341 | |
3342 | add_cmd ("unwind", class_maintenance, unwind_command, | |
3343 | "Print unwind table entry at given address.", | |
3344 | &maintenanceprintlist); | |
3345 | ||
3346 | deprecate_cmd (add_com ("xbreak", class_breakpoint, | |
3347 | break_at_finish_command, | |
3348 | concat ("Set breakpoint at procedure exit. \n\ | |
3349 | Argument may be function name, or \"*\" and an address.\n\ | |
3350 | If function is specified, break at end of code for that function.\n\ | |
3351 | If an address is specified, break at the end of the function that contains \n\ | |
3352 | that exact address.\n", | |
3353 | "With no arg, uses current execution address of selected stack frame.\n\ | |
3354 | This is useful for breaking on return to a stack frame.\n\ | |
3355 | \n\ | |
3356 | Multiple breakpoints at one place are permitted, and useful if conditional.\n\ | |
3357 | \n\ | |
3358 | Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL)), NULL); | |
3359 | deprecate_cmd (add_com_alias ("xb", "xbreak", class_breakpoint, 1), NULL); | |
3360 | deprecate_cmd (add_com_alias ("xbr", "xbreak", class_breakpoint, 1), NULL); | |
3361 | deprecate_cmd (add_com_alias ("xbre", "xbreak", class_breakpoint, 1), NULL); | |
3362 | deprecate_cmd (add_com_alias ("xbrea", "xbreak", class_breakpoint, 1), NULL); | |
3363 | ||
3364 | deprecate_cmd (c = add_com ("txbreak", class_breakpoint, | |
3365 | tbreak_at_finish_command, | |
3366 | "Set temporary breakpoint at procedure exit. Either there should\n\ | |
3367 | be no argument or the argument must be a depth.\n"), NULL); | |
3368 | set_cmd_completer (c, location_completer); | |
3369 | ||
3370 | if (xdb_commands) | |
3371 | deprecate_cmd (add_com ("bx", class_breakpoint, | |
3372 | break_at_finish_at_depth_command, | |
3373 | "Set breakpoint at procedure exit. Either there should\n\ | |
3374 | be no argument or the argument must be a depth.\n"), NULL); | |
3375 | } | |
3376 |