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