2004-05-17 Randolph Chung <tausq@debian.org>
[deliverable/binutils-gdb.git] / gdb / hppa-tdep.c
1 /* Target-dependent code for the HP PA architecture, for GDB.
2
3 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
5 Foundation, Inc.
6
7 Contributed by the Center for Software Science at the
8 University of Utah (pa-gdb-bugs@cs.utah.edu).
9
10 This file is part of GDB.
11
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.
16
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.
21
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. */
26
27 #include "defs.h"
28 #include "frame.h"
29 #include "bfd.h"
30 #include "inferior.h"
31 #include "value.h"
32 #include "regcache.h"
33 #include "completer.h"
34 #include "language.h"
35 #include "osabi.h"
36 #include "gdb_assert.h"
37 #include "infttrace.h"
38 #include "arch-utils.h"
39 /* For argument passing to the inferior */
40 #include "symtab.h"
41 #include "infcall.h"
42 #include "dis-asm.h"
43 #include "trad-frame.h"
44 #include "frame-unwind.h"
45 #include "frame-base.h"
46
47 #include "gdb_stat.h"
48 #include "gdb_wait.h"
49
50 #include "gdbcore.h"
51 #include "gdbcmd.h"
52 #include "target.h"
53 #include "symfile.h"
54 #include "objfiles.h"
55 #include "hppa-tdep.h"
56
57 static int hppa_debug = 0;
58
59 /* Some local constants. */
60 static const int hppa32_num_regs = 128;
61 static const int hppa64_num_regs = 96;
62
63 /* hppa-specific object data -- unwind and solib info.
64 TODO/maybe: think about splitting this into two parts; the unwind data is
65 common to all hppa targets, but is only used in this file; we can register
66 that separately and make this static. The solib data is probably hpux-
67 specific, so we can create a separate extern objfile_data that is registered
68 by hppa-hpux-tdep.c and shared with pa64solib.c and somsolib.c. */
69 const struct objfile_data *hppa_objfile_priv_data = NULL;
70
71 /* Get at various relevent fields of an instruction word. */
72 #define MASK_5 0x1f
73 #define MASK_11 0x7ff
74 #define MASK_14 0x3fff
75 #define MASK_21 0x1fffff
76
77 /* Define offsets into the call dummy for the _sr4export address.
78 See comments related to CALL_DUMMY for more info. */
79 #define SR4EXPORT_LDIL_OFFSET (HPPA_INSTRUCTION_SIZE * 12)
80 #define SR4EXPORT_LDO_OFFSET (HPPA_INSTRUCTION_SIZE * 13)
81
82 /* Sizes (in bytes) of the native unwind entries. */
83 #define UNWIND_ENTRY_SIZE 16
84 #define STUB_UNWIND_ENTRY_SIZE 8
85
86 /* FIXME: brobecker 2002-11-07: We will likely be able to make the
87 following functions static, once we hppa is partially multiarched. */
88 int hppa_pc_requires_run_before_use (CORE_ADDR pc);
89 int hppa_instruction_nullified (void);
90
91 /* Handle 32/64-bit struct return conventions. */
92
93 static enum return_value_convention
94 hppa32_return_value (struct gdbarch *gdbarch,
95 struct type *type, struct regcache *regcache,
96 void *readbuf, const void *writebuf)
97 {
98 if (TYPE_LENGTH (type) <= 2 * 4)
99 {
100 /* The value always lives in the right hand end of the register
101 (or register pair)? */
102 int b;
103 int reg = TYPE_CODE (type) == TYPE_CODE_FLT ? HPPA_FP4_REGNUM : 28;
104 int part = TYPE_LENGTH (type) % 4;
105 /* The left hand register contains only part of the value,
106 transfer that first so that the rest can be xfered as entire
107 4-byte registers. */
108 if (part > 0)
109 {
110 if (readbuf != NULL)
111 regcache_cooked_read_part (regcache, reg, 4 - part,
112 part, readbuf);
113 if (writebuf != NULL)
114 regcache_cooked_write_part (regcache, reg, 4 - part,
115 part, writebuf);
116 reg++;
117 }
118 /* Now transfer the remaining register values. */
119 for (b = part; b < TYPE_LENGTH (type); b += 4)
120 {
121 if (readbuf != NULL)
122 regcache_cooked_read (regcache, reg, (char *) readbuf + b);
123 if (writebuf != NULL)
124 regcache_cooked_write (regcache, reg, (const char *) writebuf + b);
125 reg++;
126 }
127 return RETURN_VALUE_REGISTER_CONVENTION;
128 }
129 else
130 return RETURN_VALUE_STRUCT_CONVENTION;
131 }
132
133 static enum return_value_convention
134 hppa64_return_value (struct gdbarch *gdbarch,
135 struct type *type, struct regcache *regcache,
136 void *readbuf, const void *writebuf)
137 {
138 /* RM: Floats are returned in FR4R, doubles in FR4. Integral values
139 are in r28, padded on the left. Aggregates less that 65 bits are
140 in r28, right padded. Aggregates upto 128 bits are in r28 and
141 r29, right padded. */
142 if (TYPE_CODE (type) == TYPE_CODE_FLT
143 && TYPE_LENGTH (type) <= 8)
144 {
145 /* Floats are right aligned? */
146 int offset = register_size (gdbarch, HPPA_FP4_REGNUM) - TYPE_LENGTH (type);
147 if (readbuf != NULL)
148 regcache_cooked_read_part (regcache, HPPA_FP4_REGNUM, offset,
149 TYPE_LENGTH (type), readbuf);
150 if (writebuf != NULL)
151 regcache_cooked_write_part (regcache, HPPA_FP4_REGNUM, offset,
152 TYPE_LENGTH (type), writebuf);
153 return RETURN_VALUE_REGISTER_CONVENTION;
154 }
155 else if (TYPE_LENGTH (type) <= 8 && is_integral_type (type))
156 {
157 /* Integrals are right aligned. */
158 int offset = register_size (gdbarch, HPPA_FP4_REGNUM) - TYPE_LENGTH (type);
159 if (readbuf != NULL)
160 regcache_cooked_read_part (regcache, 28, offset,
161 TYPE_LENGTH (type), readbuf);
162 if (writebuf != NULL)
163 regcache_cooked_write_part (regcache, 28, offset,
164 TYPE_LENGTH (type), writebuf);
165 return RETURN_VALUE_REGISTER_CONVENTION;
166 }
167 else if (TYPE_LENGTH (type) <= 2 * 8)
168 {
169 /* Composite values are left aligned. */
170 int b;
171 for (b = 0; b < TYPE_LENGTH (type); b += 8)
172 {
173 int part = min (8, TYPE_LENGTH (type) - b);
174 if (readbuf != NULL)
175 regcache_cooked_read_part (regcache, 28 + b / 8, 0, part,
176 (char *) readbuf + b);
177 if (writebuf != NULL)
178 regcache_cooked_write_part (regcache, 28 + b / 8, 0, part,
179 (const char *) writebuf + b);
180 }
181 return RETURN_VALUE_REGISTER_CONVENTION;
182 }
183 else
184 return RETURN_VALUE_STRUCT_CONVENTION;
185 }
186
187 /* Routines to extract various sized constants out of hppa
188 instructions. */
189
190 /* This assumes that no garbage lies outside of the lower bits of
191 value. */
192
193 int
194 hppa_sign_extend (unsigned val, unsigned bits)
195 {
196 return (int) (val >> (bits - 1) ? (-1 << bits) | val : val);
197 }
198
199 /* For many immediate values the sign bit is the low bit! */
200
201 int
202 hppa_low_hppa_sign_extend (unsigned val, unsigned bits)
203 {
204 return (int) ((val & 0x1 ? (-1 << (bits - 1)) : 0) | val >> 1);
205 }
206
207 /* Extract the bits at positions between FROM and TO, using HP's numbering
208 (MSB = 0). */
209
210 int
211 hppa_get_field (unsigned word, int from, int to)
212 {
213 return ((word) >> (31 - (to)) & ((1 << ((to) - (from) + 1)) - 1));
214 }
215
216 /* extract the immediate field from a ld{bhw}s instruction */
217
218 int
219 hppa_extract_5_load (unsigned word)
220 {
221 return hppa_low_hppa_sign_extend (word >> 16 & MASK_5, 5);
222 }
223
224 /* extract the immediate field from a break instruction */
225
226 unsigned
227 hppa_extract_5r_store (unsigned word)
228 {
229 return (word & MASK_5);
230 }
231
232 /* extract the immediate field from a {sr}sm instruction */
233
234 unsigned
235 hppa_extract_5R_store (unsigned word)
236 {
237 return (word >> 16 & MASK_5);
238 }
239
240 /* extract a 14 bit immediate field */
241
242 int
243 hppa_extract_14 (unsigned word)
244 {
245 return hppa_low_hppa_sign_extend (word & MASK_14, 14);
246 }
247
248 /* extract a 21 bit constant */
249
250 int
251 hppa_extract_21 (unsigned word)
252 {
253 int val;
254
255 word &= MASK_21;
256 word <<= 11;
257 val = hppa_get_field (word, 20, 20);
258 val <<= 11;
259 val |= hppa_get_field (word, 9, 19);
260 val <<= 2;
261 val |= hppa_get_field (word, 5, 6);
262 val <<= 5;
263 val |= hppa_get_field (word, 0, 4);
264 val <<= 2;
265 val |= hppa_get_field (word, 7, 8);
266 return hppa_sign_extend (val, 21) << 11;
267 }
268
269 /* extract a 17 bit constant from branch instructions, returning the
270 19 bit signed value. */
271
272 int
273 hppa_extract_17 (unsigned word)
274 {
275 return hppa_sign_extend (hppa_get_field (word, 19, 28) |
276 hppa_get_field (word, 29, 29) << 10 |
277 hppa_get_field (word, 11, 15) << 11 |
278 (word & 0x1) << 16, 17) << 2;
279 }
280 \f
281
282 /* Compare the start address for two unwind entries returning 1 if
283 the first address is larger than the second, -1 if the second is
284 larger than the first, and zero if they are equal. */
285
286 static int
287 compare_unwind_entries (const void *arg1, const void *arg2)
288 {
289 const struct unwind_table_entry *a = arg1;
290 const struct unwind_table_entry *b = arg2;
291
292 if (a->region_start > b->region_start)
293 return 1;
294 else if (a->region_start < b->region_start)
295 return -1;
296 else
297 return 0;
298 }
299
300 static void
301 record_text_segment_lowaddr (bfd *abfd, asection *section, void *data)
302 {
303 if ((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
304 == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
305 {
306 bfd_vma value = section->vma - section->filepos;
307 CORE_ADDR *low_text_segment_address = (CORE_ADDR *)data;
308
309 if (value < *low_text_segment_address)
310 *low_text_segment_address = value;
311 }
312 }
313
314 static void
315 internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table,
316 asection *section, unsigned int entries, unsigned int size,
317 CORE_ADDR text_offset)
318 {
319 /* We will read the unwind entries into temporary memory, then
320 fill in the actual unwind table. */
321
322 if (size > 0)
323 {
324 unsigned long tmp;
325 unsigned i;
326 char *buf = alloca (size);
327 CORE_ADDR low_text_segment_address;
328
329 /* For ELF targets, then unwinds are supposed to
330 be segment relative offsets instead of absolute addresses.
331
332 Note that when loading a shared library (text_offset != 0) the
333 unwinds are already relative to the text_offset that will be
334 passed in. */
335 if (gdbarch_tdep (current_gdbarch)->is_elf && text_offset == 0)
336 {
337 low_text_segment_address = -1;
338
339 bfd_map_over_sections (objfile->obfd,
340 record_text_segment_lowaddr,
341 &low_text_segment_address);
342
343 text_offset = low_text_segment_address;
344 }
345
346 bfd_get_section_contents (objfile->obfd, section, buf, 0, size);
347
348 /* Now internalize the information being careful to handle host/target
349 endian issues. */
350 for (i = 0; i < entries; i++)
351 {
352 table[i].region_start = bfd_get_32 (objfile->obfd,
353 (bfd_byte *) buf);
354 table[i].region_start += text_offset;
355 buf += 4;
356 table[i].region_end = bfd_get_32 (objfile->obfd, (bfd_byte *) buf);
357 table[i].region_end += text_offset;
358 buf += 4;
359 tmp = bfd_get_32 (objfile->obfd, (bfd_byte *) buf);
360 buf += 4;
361 table[i].Cannot_unwind = (tmp >> 31) & 0x1;
362 table[i].Millicode = (tmp >> 30) & 0x1;
363 table[i].Millicode_save_sr0 = (tmp >> 29) & 0x1;
364 table[i].Region_description = (tmp >> 27) & 0x3;
365 table[i].reserved1 = (tmp >> 26) & 0x1;
366 table[i].Entry_SR = (tmp >> 25) & 0x1;
367 table[i].Entry_FR = (tmp >> 21) & 0xf;
368 table[i].Entry_GR = (tmp >> 16) & 0x1f;
369 table[i].Args_stored = (tmp >> 15) & 0x1;
370 table[i].Variable_Frame = (tmp >> 14) & 0x1;
371 table[i].Separate_Package_Body = (tmp >> 13) & 0x1;
372 table[i].Frame_Extension_Millicode = (tmp >> 12) & 0x1;
373 table[i].Stack_Overflow_Check = (tmp >> 11) & 0x1;
374 table[i].Two_Instruction_SP_Increment = (tmp >> 10) & 0x1;
375 table[i].Ada_Region = (tmp >> 9) & 0x1;
376 table[i].cxx_info = (tmp >> 8) & 0x1;
377 table[i].cxx_try_catch = (tmp >> 7) & 0x1;
378 table[i].sched_entry_seq = (tmp >> 6) & 0x1;
379 table[i].reserved2 = (tmp >> 5) & 0x1;
380 table[i].Save_SP = (tmp >> 4) & 0x1;
381 table[i].Save_RP = (tmp >> 3) & 0x1;
382 table[i].Save_MRP_in_frame = (tmp >> 2) & 0x1;
383 table[i].extn_ptr_defined = (tmp >> 1) & 0x1;
384 table[i].Cleanup_defined = tmp & 0x1;
385 tmp = bfd_get_32 (objfile->obfd, (bfd_byte *) buf);
386 buf += 4;
387 table[i].MPE_XL_interrupt_marker = (tmp >> 31) & 0x1;
388 table[i].HP_UX_interrupt_marker = (tmp >> 30) & 0x1;
389 table[i].Large_frame = (tmp >> 29) & 0x1;
390 table[i].Pseudo_SP_Set = (tmp >> 28) & 0x1;
391 table[i].reserved4 = (tmp >> 27) & 0x1;
392 table[i].Total_frame_size = tmp & 0x7ffffff;
393
394 /* Stub unwinds are handled elsewhere. */
395 table[i].stub_unwind.stub_type = 0;
396 table[i].stub_unwind.padding = 0;
397 }
398 }
399 }
400
401 /* Read in the backtrace information stored in the `$UNWIND_START$' section of
402 the object file. This info is used mainly by find_unwind_entry() to find
403 out the stack frame size and frame pointer used by procedures. We put
404 everything on the psymbol obstack in the objfile so that it automatically
405 gets freed when the objfile is destroyed. */
406
407 static void
408 read_unwind_info (struct objfile *objfile)
409 {
410 asection *unwind_sec, *stub_unwind_sec;
411 unsigned unwind_size, stub_unwind_size, total_size;
412 unsigned index, unwind_entries;
413 unsigned stub_entries, total_entries;
414 CORE_ADDR text_offset;
415 struct hppa_unwind_info *ui;
416 struct hppa_objfile_private *obj_private;
417
418 text_offset = ANOFFSET (objfile->section_offsets, 0);
419 ui = (struct hppa_unwind_info *) obstack_alloc (&objfile->objfile_obstack,
420 sizeof (struct hppa_unwind_info));
421
422 ui->table = NULL;
423 ui->cache = NULL;
424 ui->last = -1;
425
426 /* For reasons unknown the HP PA64 tools generate multiple unwinder
427 sections in a single executable. So we just iterate over every
428 section in the BFD looking for unwinder sections intead of trying
429 to do a lookup with bfd_get_section_by_name.
430
431 First determine the total size of the unwind tables so that we
432 can allocate memory in a nice big hunk. */
433 total_entries = 0;
434 for (unwind_sec = objfile->obfd->sections;
435 unwind_sec;
436 unwind_sec = unwind_sec->next)
437 {
438 if (strcmp (unwind_sec->name, "$UNWIND_START$") == 0
439 || strcmp (unwind_sec->name, ".PARISC.unwind") == 0)
440 {
441 unwind_size = bfd_section_size (objfile->obfd, unwind_sec);
442 unwind_entries = unwind_size / UNWIND_ENTRY_SIZE;
443
444 total_entries += unwind_entries;
445 }
446 }
447
448 /* Now compute the size of the stub unwinds. Note the ELF tools do not
449 use stub unwinds at the curren time. */
450 stub_unwind_sec = bfd_get_section_by_name (objfile->obfd, "$UNWIND_END$");
451
452 if (stub_unwind_sec)
453 {
454 stub_unwind_size = bfd_section_size (objfile->obfd, stub_unwind_sec);
455 stub_entries = stub_unwind_size / STUB_UNWIND_ENTRY_SIZE;
456 }
457 else
458 {
459 stub_unwind_size = 0;
460 stub_entries = 0;
461 }
462
463 /* Compute total number of unwind entries and their total size. */
464 total_entries += stub_entries;
465 total_size = total_entries * sizeof (struct unwind_table_entry);
466
467 /* Allocate memory for the unwind table. */
468 ui->table = (struct unwind_table_entry *)
469 obstack_alloc (&objfile->objfile_obstack, total_size);
470 ui->last = total_entries - 1;
471
472 /* Now read in each unwind section and internalize the standard unwind
473 entries. */
474 index = 0;
475 for (unwind_sec = objfile->obfd->sections;
476 unwind_sec;
477 unwind_sec = unwind_sec->next)
478 {
479 if (strcmp (unwind_sec->name, "$UNWIND_START$") == 0
480 || strcmp (unwind_sec->name, ".PARISC.unwind") == 0)
481 {
482 unwind_size = bfd_section_size (objfile->obfd, unwind_sec);
483 unwind_entries = unwind_size / UNWIND_ENTRY_SIZE;
484
485 internalize_unwinds (objfile, &ui->table[index], unwind_sec,
486 unwind_entries, unwind_size, text_offset);
487 index += unwind_entries;
488 }
489 }
490
491 /* Now read in and internalize the stub unwind entries. */
492 if (stub_unwind_size > 0)
493 {
494 unsigned int i;
495 char *buf = alloca (stub_unwind_size);
496
497 /* Read in the stub unwind entries. */
498 bfd_get_section_contents (objfile->obfd, stub_unwind_sec, buf,
499 0, stub_unwind_size);
500
501 /* Now convert them into regular unwind entries. */
502 for (i = 0; i < stub_entries; i++, index++)
503 {
504 /* Clear out the next unwind entry. */
505 memset (&ui->table[index], 0, sizeof (struct unwind_table_entry));
506
507 /* Convert offset & size into region_start and region_end.
508 Stuff away the stub type into "reserved" fields. */
509 ui->table[index].region_start = bfd_get_32 (objfile->obfd,
510 (bfd_byte *) buf);
511 ui->table[index].region_start += text_offset;
512 buf += 4;
513 ui->table[index].stub_unwind.stub_type = bfd_get_8 (objfile->obfd,
514 (bfd_byte *) buf);
515 buf += 2;
516 ui->table[index].region_end
517 = ui->table[index].region_start + 4 *
518 (bfd_get_16 (objfile->obfd, (bfd_byte *) buf) - 1);
519 buf += 2;
520 }
521
522 }
523
524 /* Unwind table needs to be kept sorted. */
525 qsort (ui->table, total_entries, sizeof (struct unwind_table_entry),
526 compare_unwind_entries);
527
528 /* Keep a pointer to the unwind information. */
529 obj_private = (struct hppa_objfile_private *)
530 objfile_data (objfile, hppa_objfile_priv_data);
531 if (obj_private == NULL)
532 {
533 obj_private = (struct hppa_objfile_private *)
534 obstack_alloc (&objfile->objfile_obstack,
535 sizeof (struct hppa_objfile_private));
536 set_objfile_data (objfile, hppa_objfile_priv_data, obj_private);
537 obj_private->unwind_info = NULL;
538 obj_private->so_info = NULL;
539 obj_private->dp = 0;
540 }
541 obj_private->unwind_info = ui;
542 }
543
544 /* Lookup the unwind (stack backtrace) info for the given PC. We search all
545 of the objfiles seeking the unwind table entry for this PC. Each objfile
546 contains a sorted list of struct unwind_table_entry. Since we do a binary
547 search of the unwind tables, we depend upon them to be sorted. */
548
549 struct unwind_table_entry *
550 find_unwind_entry (CORE_ADDR pc)
551 {
552 int first, middle, last;
553 struct objfile *objfile;
554 struct hppa_objfile_private *priv;
555
556 if (hppa_debug)
557 fprintf_unfiltered (gdb_stdlog, "{ find_unwind_entry 0x%s -> ",
558 paddr_nz (pc));
559
560 /* A function at address 0? Not in HP-UX! */
561 if (pc == (CORE_ADDR) 0)
562 {
563 if (hppa_debug)
564 fprintf_unfiltered (gdb_stdlog, "NULL }\n");
565 return NULL;
566 }
567
568 ALL_OBJFILES (objfile)
569 {
570 struct hppa_unwind_info *ui;
571 ui = NULL;
572 priv = objfile_data (objfile, hppa_objfile_priv_data);
573 if (priv)
574 ui = ((struct hppa_objfile_private *) priv)->unwind_info;
575
576 if (!ui)
577 {
578 read_unwind_info (objfile);
579 priv = objfile_data (objfile, hppa_objfile_priv_data);
580 if (priv == NULL)
581 error ("Internal error reading unwind information.");
582 ui = ((struct hppa_objfile_private *) priv)->unwind_info;
583 }
584
585 /* First, check the cache */
586
587 if (ui->cache
588 && pc >= ui->cache->region_start
589 && pc <= ui->cache->region_end)
590 {
591 if (hppa_debug)
592 fprintf_unfiltered (gdb_stdlog, "0x%s (cached) }\n",
593 paddr_nz ((CORE_ADDR) ui->cache));
594 return ui->cache;
595 }
596
597 /* Not in the cache, do a binary search */
598
599 first = 0;
600 last = ui->last;
601
602 while (first <= last)
603 {
604 middle = (first + last) / 2;
605 if (pc >= ui->table[middle].region_start
606 && pc <= ui->table[middle].region_end)
607 {
608 ui->cache = &ui->table[middle];
609 if (hppa_debug)
610 fprintf_unfiltered (gdb_stdlog, "0x%s }\n",
611 paddr_nz ((CORE_ADDR) ui->cache));
612 return &ui->table[middle];
613 }
614
615 if (pc < ui->table[middle].region_start)
616 last = middle - 1;
617 else
618 first = middle + 1;
619 }
620 } /* ALL_OBJFILES() */
621
622 if (hppa_debug)
623 fprintf_unfiltered (gdb_stdlog, "NULL (not found) }\n");
624
625 return NULL;
626 }
627
628 static const unsigned char *
629 hppa_breakpoint_from_pc (CORE_ADDR *pc, int *len)
630 {
631 static const unsigned char breakpoint[] = {0x00, 0x01, 0x00, 0x04};
632 (*len) = sizeof (breakpoint);
633 return breakpoint;
634 }
635
636 /* Return the name of a register. */
637
638 const char *
639 hppa32_register_name (int i)
640 {
641 static char *names[] = {
642 "flags", "r1", "rp", "r3",
643 "r4", "r5", "r6", "r7",
644 "r8", "r9", "r10", "r11",
645 "r12", "r13", "r14", "r15",
646 "r16", "r17", "r18", "r19",
647 "r20", "r21", "r22", "r23",
648 "r24", "r25", "r26", "dp",
649 "ret0", "ret1", "sp", "r31",
650 "sar", "pcoqh", "pcsqh", "pcoqt",
651 "pcsqt", "eiem", "iir", "isr",
652 "ior", "ipsw", "goto", "sr4",
653 "sr0", "sr1", "sr2", "sr3",
654 "sr5", "sr6", "sr7", "cr0",
655 "cr8", "cr9", "ccr", "cr12",
656 "cr13", "cr24", "cr25", "cr26",
657 "mpsfu_high","mpsfu_low","mpsfu_ovflo","pad",
658 "fpsr", "fpe1", "fpe2", "fpe3",
659 "fpe4", "fpe5", "fpe6", "fpe7",
660 "fr4", "fr4R", "fr5", "fr5R",
661 "fr6", "fr6R", "fr7", "fr7R",
662 "fr8", "fr8R", "fr9", "fr9R",
663 "fr10", "fr10R", "fr11", "fr11R",
664 "fr12", "fr12R", "fr13", "fr13R",
665 "fr14", "fr14R", "fr15", "fr15R",
666 "fr16", "fr16R", "fr17", "fr17R",
667 "fr18", "fr18R", "fr19", "fr19R",
668 "fr20", "fr20R", "fr21", "fr21R",
669 "fr22", "fr22R", "fr23", "fr23R",
670 "fr24", "fr24R", "fr25", "fr25R",
671 "fr26", "fr26R", "fr27", "fr27R",
672 "fr28", "fr28R", "fr29", "fr29R",
673 "fr30", "fr30R", "fr31", "fr31R"
674 };
675 if (i < 0 || i >= (sizeof (names) / sizeof (*names)))
676 return NULL;
677 else
678 return names[i];
679 }
680
681 const char *
682 hppa64_register_name (int i)
683 {
684 static char *names[] = {
685 "flags", "r1", "rp", "r3",
686 "r4", "r5", "r6", "r7",
687 "r8", "r9", "r10", "r11",
688 "r12", "r13", "r14", "r15",
689 "r16", "r17", "r18", "r19",
690 "r20", "r21", "r22", "r23",
691 "r24", "r25", "r26", "dp",
692 "ret0", "ret1", "sp", "r31",
693 "sar", "pcoqh", "pcsqh", "pcoqt",
694 "pcsqt", "eiem", "iir", "isr",
695 "ior", "ipsw", "goto", "sr4",
696 "sr0", "sr1", "sr2", "sr3",
697 "sr5", "sr6", "sr7", "cr0",
698 "cr8", "cr9", "ccr", "cr12",
699 "cr13", "cr24", "cr25", "cr26",
700 "mpsfu_high","mpsfu_low","mpsfu_ovflo","pad",
701 "fpsr", "fpe1", "fpe2", "fpe3",
702 "fr4", "fr5", "fr6", "fr7",
703 "fr8", "fr9", "fr10", "fr11",
704 "fr12", "fr13", "fr14", "fr15",
705 "fr16", "fr17", "fr18", "fr19",
706 "fr20", "fr21", "fr22", "fr23",
707 "fr24", "fr25", "fr26", "fr27",
708 "fr28", "fr29", "fr30", "fr31"
709 };
710 if (i < 0 || i >= (sizeof (names) / sizeof (*names)))
711 return NULL;
712 else
713 return names[i];
714 }
715
716 /* This function pushes a stack frame with arguments as part of the
717 inferior function calling mechanism.
718
719 This is the version of the function for the 32-bit PA machines, in
720 which later arguments appear at lower addresses. (The stack always
721 grows towards higher addresses.)
722
723 We simply allocate the appropriate amount of stack space and put
724 arguments into their proper slots. */
725
726 CORE_ADDR
727 hppa32_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
728 struct regcache *regcache, CORE_ADDR bp_addr,
729 int nargs, struct value **args, CORE_ADDR sp,
730 int struct_return, CORE_ADDR struct_addr)
731 {
732 /* Stack base address at which any pass-by-reference parameters are
733 stored. */
734 CORE_ADDR struct_end = 0;
735 /* Stack base address at which the first parameter is stored. */
736 CORE_ADDR param_end = 0;
737
738 /* The inner most end of the stack after all the parameters have
739 been pushed. */
740 CORE_ADDR new_sp = 0;
741
742 /* Two passes. First pass computes the location of everything,
743 second pass writes the bytes out. */
744 int write_pass;
745 for (write_pass = 0; write_pass < 2; write_pass++)
746 {
747 CORE_ADDR struct_ptr = 0;
748 /* The first parameter goes into sp-36, each stack slot is 4-bytes.
749 struct_ptr is adjusted for each argument below, so the first
750 argument will end up at sp-36. */
751 CORE_ADDR param_ptr = 32;
752 int i;
753 int small_struct = 0;
754
755 for (i = 0; i < nargs; i++)
756 {
757 struct value *arg = args[i];
758 struct type *type = check_typedef (VALUE_TYPE (arg));
759 /* The corresponding parameter that is pushed onto the
760 stack, and [possibly] passed in a register. */
761 char param_val[8];
762 int param_len;
763 memset (param_val, 0, sizeof param_val);
764 if (TYPE_LENGTH (type) > 8)
765 {
766 /* Large parameter, pass by reference. Store the value
767 in "struct" area and then pass its address. */
768 param_len = 4;
769 struct_ptr += align_up (TYPE_LENGTH (type), 8);
770 if (write_pass)
771 write_memory (struct_end - struct_ptr, VALUE_CONTENTS (arg),
772 TYPE_LENGTH (type));
773 store_unsigned_integer (param_val, 4, struct_end - struct_ptr);
774 }
775 else if (TYPE_CODE (type) == TYPE_CODE_INT
776 || TYPE_CODE (type) == TYPE_CODE_ENUM)
777 {
778 /* Integer value store, right aligned. "unpack_long"
779 takes care of any sign-extension problems. */
780 param_len = align_up (TYPE_LENGTH (type), 4);
781 store_unsigned_integer (param_val, param_len,
782 unpack_long (type,
783 VALUE_CONTENTS (arg)));
784 }
785 else if (TYPE_CODE (type) == TYPE_CODE_FLT)
786 {
787 /* Floating point value store, right aligned. */
788 param_len = align_up (TYPE_LENGTH (type), 4);
789 memcpy (param_val, VALUE_CONTENTS (arg), param_len);
790 }
791 else
792 {
793 param_len = align_up (TYPE_LENGTH (type), 4);
794
795 /* Small struct value are stored right-aligned. */
796 memcpy (param_val + param_len - TYPE_LENGTH (type),
797 VALUE_CONTENTS (arg), TYPE_LENGTH (type));
798
799 /* Structures of size 5, 6 and 7 bytes are special in that
800 the higher-ordered word is stored in the lower-ordered
801 argument, and even though it is a 8-byte quantity the
802 registers need not be 8-byte aligned. */
803 if (param_len > 4)
804 small_struct = 1;
805 }
806
807 param_ptr += param_len;
808 if (param_len == 8 && !small_struct)
809 param_ptr = align_up (param_ptr, 8);
810
811 /* First 4 non-FP arguments are passed in gr26-gr23.
812 First 4 32-bit FP arguments are passed in fr4L-fr7L.
813 First 2 64-bit FP arguments are passed in fr5 and fr7.
814
815 The rest go on the stack, starting at sp-36, towards lower
816 addresses. 8-byte arguments must be aligned to a 8-byte
817 stack boundary. */
818 if (write_pass)
819 {
820 write_memory (param_end - param_ptr, param_val, param_len);
821
822 /* There are some cases when we don't know the type
823 expected by the callee (e.g. for variadic functions), so
824 pass the parameters in both general and fp regs. */
825 if (param_ptr <= 48)
826 {
827 int grreg = 26 - (param_ptr - 36) / 4;
828 int fpLreg = 72 + (param_ptr - 36) / 4 * 2;
829 int fpreg = 74 + (param_ptr - 32) / 8 * 4;
830
831 regcache_cooked_write (regcache, grreg, param_val);
832 regcache_cooked_write (regcache, fpLreg, param_val);
833
834 if (param_len > 4)
835 {
836 regcache_cooked_write (regcache, grreg + 1,
837 param_val + 4);
838
839 regcache_cooked_write (regcache, fpreg, param_val);
840 regcache_cooked_write (regcache, fpreg + 1,
841 param_val + 4);
842 }
843 }
844 }
845 }
846
847 /* Update the various stack pointers. */
848 if (!write_pass)
849 {
850 struct_end = sp + align_up (struct_ptr, 64);
851 /* PARAM_PTR already accounts for all the arguments passed
852 by the user. However, the ABI mandates minimum stack
853 space allocations for outgoing arguments. The ABI also
854 mandates minimum stack alignments which we must
855 preserve. */
856 param_end = struct_end + align_up (param_ptr, 64);
857 }
858 }
859
860 /* If a structure has to be returned, set up register 28 to hold its
861 address */
862 if (struct_return)
863 write_register (28, struct_addr);
864
865 /* Set the return address. */
866 regcache_cooked_write_unsigned (regcache, HPPA_RP_REGNUM, bp_addr);
867
868 /* Update the Stack Pointer. */
869 regcache_cooked_write_unsigned (regcache, HPPA_SP_REGNUM, param_end);
870
871 return param_end;
872 }
873
874 /* This function pushes a stack frame with arguments as part of the
875 inferior function calling mechanism.
876
877 This is the version for the PA64, in which later arguments appear
878 at higher addresses. (The stack always grows towards higher
879 addresses.)
880
881 We simply allocate the appropriate amount of stack space and put
882 arguments into their proper slots.
883
884 This ABI also requires that the caller provide an argument pointer
885 to the callee, so we do that too. */
886
887 CORE_ADDR
888 hppa64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
889 struct regcache *regcache, CORE_ADDR bp_addr,
890 int nargs, struct value **args, CORE_ADDR sp,
891 int struct_return, CORE_ADDR struct_addr)
892 {
893 /* NOTE: cagney/2004-02-27: This is a guess - its implemented by
894 reverse engineering testsuite failures. */
895
896 /* Stack base address at which any pass-by-reference parameters are
897 stored. */
898 CORE_ADDR struct_end = 0;
899 /* Stack base address at which the first parameter is stored. */
900 CORE_ADDR param_end = 0;
901
902 /* The inner most end of the stack after all the parameters have
903 been pushed. */
904 CORE_ADDR new_sp = 0;
905
906 /* Two passes. First pass computes the location of everything,
907 second pass writes the bytes out. */
908 int write_pass;
909 for (write_pass = 0; write_pass < 2; write_pass++)
910 {
911 CORE_ADDR struct_ptr = 0;
912 CORE_ADDR param_ptr = 0;
913 int i;
914 for (i = 0; i < nargs; i++)
915 {
916 struct value *arg = args[i];
917 struct type *type = check_typedef (VALUE_TYPE (arg));
918 if ((TYPE_CODE (type) == TYPE_CODE_INT
919 || TYPE_CODE (type) == TYPE_CODE_ENUM)
920 && TYPE_LENGTH (type) <= 8)
921 {
922 /* Integer value store, right aligned. "unpack_long"
923 takes care of any sign-extension problems. */
924 param_ptr += 8;
925 if (write_pass)
926 {
927 ULONGEST val = unpack_long (type, VALUE_CONTENTS (arg));
928 int reg = 27 - param_ptr / 8;
929 write_memory_unsigned_integer (param_end - param_ptr,
930 val, 8);
931 if (reg >= 19)
932 regcache_cooked_write_unsigned (regcache, reg, val);
933 }
934 }
935 else
936 {
937 /* Small struct value, store left aligned? */
938 int reg;
939 if (TYPE_LENGTH (type) > 8)
940 {
941 param_ptr = align_up (param_ptr, 16);
942 reg = 26 - param_ptr / 8;
943 param_ptr += align_up (TYPE_LENGTH (type), 16);
944 }
945 else
946 {
947 param_ptr = align_up (param_ptr, 8);
948 reg = 26 - param_ptr / 8;
949 param_ptr += align_up (TYPE_LENGTH (type), 8);
950 }
951 if (write_pass)
952 {
953 int byte;
954 write_memory (param_end - param_ptr, VALUE_CONTENTS (arg),
955 TYPE_LENGTH (type));
956 for (byte = 0; byte < TYPE_LENGTH (type); byte += 8)
957 {
958 if (reg >= 19)
959 {
960 int len = min (8, TYPE_LENGTH (type) - byte);
961 regcache_cooked_write_part (regcache, reg, 0, len,
962 VALUE_CONTENTS (arg) + byte);
963 }
964 reg--;
965 }
966 }
967 }
968 }
969 /* Update the various stack pointers. */
970 if (!write_pass)
971 {
972 struct_end = sp + struct_ptr;
973 /* PARAM_PTR already accounts for all the arguments passed
974 by the user. However, the ABI mandates minimum stack
975 space allocations for outgoing arguments. The ABI also
976 mandates minimum stack alignments which we must
977 preserve. */
978 param_end = struct_end + max (align_up (param_ptr, 16), 64);
979 }
980 }
981
982 /* If a structure has to be returned, set up register 28 to hold its
983 address */
984 if (struct_return)
985 write_register (28, struct_addr);
986
987 /* Set the return address. */
988 regcache_cooked_write_unsigned (regcache, HPPA_RP_REGNUM, bp_addr);
989
990 /* Update the Stack Pointer. */
991 regcache_cooked_write_unsigned (regcache, HPPA_SP_REGNUM, param_end + 64);
992
993 /* The stack will have 32 bytes of additional space for a frame marker. */
994 return param_end + 64;
995 }
996
997 static CORE_ADDR
998 hppa32_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
999 {
1000 /* HP frames are 64-byte (or cache line) aligned (yes that's _byte_
1001 and not _bit_)! */
1002 return align_up (addr, 64);
1003 }
1004
1005 /* Force all frames to 16-byte alignment. Better safe than sorry. */
1006
1007 static CORE_ADDR
1008 hppa64_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
1009 {
1010 /* Just always 16-byte align. */
1011 return align_up (addr, 16);
1012 }
1013
1014
1015 /* Get the PC from %r31 if currently in a syscall. Also mask out privilege
1016 bits. */
1017
1018 static CORE_ADDR
1019 hppa_target_read_pc (ptid_t ptid)
1020 {
1021 int flags = read_register_pid (HPPA_FLAGS_REGNUM, ptid);
1022
1023 /* The following test does not belong here. It is OS-specific, and belongs
1024 in native code. */
1025 /* Test SS_INSYSCALL */
1026 if (flags & 2)
1027 return read_register_pid (31, ptid) & ~0x3;
1028
1029 return read_register_pid (HPPA_PCOQ_HEAD_REGNUM, ptid) & ~0x3;
1030 }
1031
1032 /* Write out the PC. If currently in a syscall, then also write the new
1033 PC value into %r31. */
1034
1035 static void
1036 hppa_target_write_pc (CORE_ADDR v, ptid_t ptid)
1037 {
1038 int flags = read_register_pid (HPPA_FLAGS_REGNUM, ptid);
1039
1040 /* The following test does not belong here. It is OS-specific, and belongs
1041 in native code. */
1042 /* If in a syscall, then set %r31. Also make sure to get the
1043 privilege bits set correctly. */
1044 /* Test SS_INSYSCALL */
1045 if (flags & 2)
1046 write_register_pid (31, v | 0x3, ptid);
1047
1048 write_register_pid (HPPA_PCOQ_HEAD_REGNUM, v, ptid);
1049 write_register_pid (HPPA_PCOQ_TAIL_REGNUM, v + 4, ptid);
1050 }
1051
1052 /* return the alignment of a type in bytes. Structures have the maximum
1053 alignment required by their fields. */
1054
1055 static int
1056 hppa_alignof (struct type *type)
1057 {
1058 int max_align, align, i;
1059 CHECK_TYPEDEF (type);
1060 switch (TYPE_CODE (type))
1061 {
1062 case TYPE_CODE_PTR:
1063 case TYPE_CODE_INT:
1064 case TYPE_CODE_FLT:
1065 return TYPE_LENGTH (type);
1066 case TYPE_CODE_ARRAY:
1067 return hppa_alignof (TYPE_FIELD_TYPE (type, 0));
1068 case TYPE_CODE_STRUCT:
1069 case TYPE_CODE_UNION:
1070 max_align = 1;
1071 for (i = 0; i < TYPE_NFIELDS (type); i++)
1072 {
1073 /* Bit fields have no real alignment. */
1074 /* if (!TYPE_FIELD_BITPOS (type, i)) */
1075 if (!TYPE_FIELD_BITSIZE (type, i)) /* elz: this should be bitsize */
1076 {
1077 align = hppa_alignof (TYPE_FIELD_TYPE (type, i));
1078 max_align = max (max_align, align);
1079 }
1080 }
1081 return max_align;
1082 default:
1083 return 4;
1084 }
1085 }
1086
1087 /* For the given instruction (INST), return any adjustment it makes
1088 to the stack pointer or zero for no adjustment.
1089
1090 This only handles instructions commonly found in prologues. */
1091
1092 static int
1093 prologue_inst_adjust_sp (unsigned long inst)
1094 {
1095 /* This must persist across calls. */
1096 static int save_high21;
1097
1098 /* The most common way to perform a stack adjustment ldo X(sp),sp */
1099 if ((inst & 0xffffc000) == 0x37de0000)
1100 return hppa_extract_14 (inst);
1101
1102 /* stwm X,D(sp) */
1103 if ((inst & 0xffe00000) == 0x6fc00000)
1104 return hppa_extract_14 (inst);
1105
1106 /* std,ma X,D(sp) */
1107 if ((inst & 0xffe00008) == 0x73c00008)
1108 return (inst & 0x1 ? -1 << 13 : 0) | (((inst >> 4) & 0x3ff) << 3);
1109
1110 /* addil high21,%r1; ldo low11,(%r1),%r30)
1111 save high bits in save_high21 for later use. */
1112 if ((inst & 0xffe00000) == 0x28200000)
1113 {
1114 save_high21 = hppa_extract_21 (inst);
1115 return 0;
1116 }
1117
1118 if ((inst & 0xffff0000) == 0x343e0000)
1119 return save_high21 + hppa_extract_14 (inst);
1120
1121 /* fstws as used by the HP compilers. */
1122 if ((inst & 0xffffffe0) == 0x2fd01220)
1123 return hppa_extract_5_load (inst);
1124
1125 /* No adjustment. */
1126 return 0;
1127 }
1128
1129 /* Return nonzero if INST is a branch of some kind, else return zero. */
1130
1131 static int
1132 is_branch (unsigned long inst)
1133 {
1134 switch (inst >> 26)
1135 {
1136 case 0x20:
1137 case 0x21:
1138 case 0x22:
1139 case 0x23:
1140 case 0x27:
1141 case 0x28:
1142 case 0x29:
1143 case 0x2a:
1144 case 0x2b:
1145 case 0x2f:
1146 case 0x30:
1147 case 0x31:
1148 case 0x32:
1149 case 0x33:
1150 case 0x38:
1151 case 0x39:
1152 case 0x3a:
1153 case 0x3b:
1154 return 1;
1155
1156 default:
1157 return 0;
1158 }
1159 }
1160
1161 /* Return the register number for a GR which is saved by INST or
1162 zero it INST does not save a GR. */
1163
1164 static int
1165 inst_saves_gr (unsigned long inst)
1166 {
1167 /* Does it look like a stw? */
1168 if ((inst >> 26) == 0x1a || (inst >> 26) == 0x1b
1169 || (inst >> 26) == 0x1f
1170 || ((inst >> 26) == 0x1f
1171 && ((inst >> 6) == 0xa)))
1172 return hppa_extract_5R_store (inst);
1173
1174 /* Does it look like a std? */
1175 if ((inst >> 26) == 0x1c
1176 || ((inst >> 26) == 0x03
1177 && ((inst >> 6) & 0xf) == 0xb))
1178 return hppa_extract_5R_store (inst);
1179
1180 /* Does it look like a stwm? GCC & HPC may use this in prologues. */
1181 if ((inst >> 26) == 0x1b)
1182 return hppa_extract_5R_store (inst);
1183
1184 /* Does it look like sth or stb? HPC versions 9.0 and later use these
1185 too. */
1186 if ((inst >> 26) == 0x19 || (inst >> 26) == 0x18
1187 || ((inst >> 26) == 0x3
1188 && (((inst >> 6) & 0xf) == 0x8
1189 || (inst >> 6) & 0xf) == 0x9))
1190 return hppa_extract_5R_store (inst);
1191
1192 return 0;
1193 }
1194
1195 /* Return the register number for a FR which is saved by INST or
1196 zero it INST does not save a FR.
1197
1198 Note we only care about full 64bit register stores (that's the only
1199 kind of stores the prologue will use).
1200
1201 FIXME: What about argument stores with the HP compiler in ANSI mode? */
1202
1203 static int
1204 inst_saves_fr (unsigned long inst)
1205 {
1206 /* is this an FSTD ? */
1207 if ((inst & 0xfc00dfc0) == 0x2c001200)
1208 return hppa_extract_5r_store (inst);
1209 if ((inst & 0xfc000002) == 0x70000002)
1210 return hppa_extract_5R_store (inst);
1211 /* is this an FSTW ? */
1212 if ((inst & 0xfc00df80) == 0x24001200)
1213 return hppa_extract_5r_store (inst);
1214 if ((inst & 0xfc000002) == 0x7c000000)
1215 return hppa_extract_5R_store (inst);
1216 return 0;
1217 }
1218
1219 /* Advance PC across any function entry prologue instructions
1220 to reach some "real" code.
1221
1222 Use information in the unwind table to determine what exactly should
1223 be in the prologue. */
1224
1225
1226 CORE_ADDR
1227 skip_prologue_hard_way (CORE_ADDR pc)
1228 {
1229 char buf[4];
1230 CORE_ADDR orig_pc = pc;
1231 unsigned long inst, stack_remaining, save_gr, save_fr, save_rp, save_sp;
1232 unsigned long args_stored, status, i, restart_gr, restart_fr;
1233 struct unwind_table_entry *u;
1234
1235 restart_gr = 0;
1236 restart_fr = 0;
1237
1238 restart:
1239 u = find_unwind_entry (pc);
1240 if (!u)
1241 return pc;
1242
1243 /* If we are not at the beginning of a function, then return now. */
1244 if ((pc & ~0x3) != u->region_start)
1245 return pc;
1246
1247 /* This is how much of a frame adjustment we need to account for. */
1248 stack_remaining = u->Total_frame_size << 3;
1249
1250 /* Magic register saves we want to know about. */
1251 save_rp = u->Save_RP;
1252 save_sp = u->Save_SP;
1253
1254 /* An indication that args may be stored into the stack. Unfortunately
1255 the HPUX compilers tend to set this in cases where no args were
1256 stored too!. */
1257 args_stored = 1;
1258
1259 /* Turn the Entry_GR field into a bitmask. */
1260 save_gr = 0;
1261 for (i = 3; i < u->Entry_GR + 3; i++)
1262 {
1263 /* Frame pointer gets saved into a special location. */
1264 if (u->Save_SP && i == HPPA_FP_REGNUM)
1265 continue;
1266
1267 save_gr |= (1 << i);
1268 }
1269 save_gr &= ~restart_gr;
1270
1271 /* Turn the Entry_FR field into a bitmask too. */
1272 save_fr = 0;
1273 for (i = 12; i < u->Entry_FR + 12; i++)
1274 save_fr |= (1 << i);
1275 save_fr &= ~restart_fr;
1276
1277 /* Loop until we find everything of interest or hit a branch.
1278
1279 For unoptimized GCC code and for any HP CC code this will never ever
1280 examine any user instructions.
1281
1282 For optimzied GCC code we're faced with problems. GCC will schedule
1283 its prologue and make prologue instructions available for delay slot
1284 filling. The end result is user code gets mixed in with the prologue
1285 and a prologue instruction may be in the delay slot of the first branch
1286 or call.
1287
1288 Some unexpected things are expected with debugging optimized code, so
1289 we allow this routine to walk past user instructions in optimized
1290 GCC code. */
1291 while (save_gr || save_fr || save_rp || save_sp || stack_remaining > 0
1292 || args_stored)
1293 {
1294 unsigned int reg_num;
1295 unsigned long old_stack_remaining, old_save_gr, old_save_fr;
1296 unsigned long old_save_rp, old_save_sp, next_inst;
1297
1298 /* Save copies of all the triggers so we can compare them later
1299 (only for HPC). */
1300 old_save_gr = save_gr;
1301 old_save_fr = save_fr;
1302 old_save_rp = save_rp;
1303 old_save_sp = save_sp;
1304 old_stack_remaining = stack_remaining;
1305
1306 status = read_memory_nobpt (pc, buf, 4);
1307 inst = extract_unsigned_integer (buf, 4);
1308
1309 /* Yow! */
1310 if (status != 0)
1311 return pc;
1312
1313 /* Note the interesting effects of this instruction. */
1314 stack_remaining -= prologue_inst_adjust_sp (inst);
1315
1316 /* There are limited ways to store the return pointer into the
1317 stack. */
1318 if (inst == 0x6bc23fd9 || inst == 0x0fc212c1)
1319 save_rp = 0;
1320
1321 /* These are the only ways we save SP into the stack. At this time
1322 the HP compilers never bother to save SP into the stack. */
1323 if ((inst & 0xffffc000) == 0x6fc10000
1324 || (inst & 0xffffc00c) == 0x73c10008)
1325 save_sp = 0;
1326
1327 /* Are we loading some register with an offset from the argument
1328 pointer? */
1329 if ((inst & 0xffe00000) == 0x37a00000
1330 || (inst & 0xffffffe0) == 0x081d0240)
1331 {
1332 pc += 4;
1333 continue;
1334 }
1335
1336 /* Account for general and floating-point register saves. */
1337 reg_num = inst_saves_gr (inst);
1338 save_gr &= ~(1 << reg_num);
1339
1340 /* Ugh. Also account for argument stores into the stack.
1341 Unfortunately args_stored only tells us that some arguments
1342 where stored into the stack. Not how many or what kind!
1343
1344 This is a kludge as on the HP compiler sets this bit and it
1345 never does prologue scheduling. So once we see one, skip past
1346 all of them. We have similar code for the fp arg stores below.
1347
1348 FIXME. Can still die if we have a mix of GR and FR argument
1349 stores! */
1350 if (reg_num >= (TARGET_PTR_BIT == 64 ? 19 : 23) && reg_num <= 26)
1351 {
1352 while (reg_num >= (TARGET_PTR_BIT == 64 ? 19 : 23) && reg_num <= 26)
1353 {
1354 pc += 4;
1355 status = read_memory_nobpt (pc, buf, 4);
1356 inst = extract_unsigned_integer (buf, 4);
1357 if (status != 0)
1358 return pc;
1359 reg_num = inst_saves_gr (inst);
1360 }
1361 args_stored = 0;
1362 continue;
1363 }
1364
1365 reg_num = inst_saves_fr (inst);
1366 save_fr &= ~(1 << reg_num);
1367
1368 status = read_memory_nobpt (pc + 4, buf, 4);
1369 next_inst = extract_unsigned_integer (buf, 4);
1370
1371 /* Yow! */
1372 if (status != 0)
1373 return pc;
1374
1375 /* We've got to be read to handle the ldo before the fp register
1376 save. */
1377 if ((inst & 0xfc000000) == 0x34000000
1378 && inst_saves_fr (next_inst) >= 4
1379 && inst_saves_fr (next_inst) <= (TARGET_PTR_BIT == 64 ? 11 : 7))
1380 {
1381 /* So we drop into the code below in a reasonable state. */
1382 reg_num = inst_saves_fr (next_inst);
1383 pc -= 4;
1384 }
1385
1386 /* Ugh. Also account for argument stores into the stack.
1387 This is a kludge as on the HP compiler sets this bit and it
1388 never does prologue scheduling. So once we see one, skip past
1389 all of them. */
1390 if (reg_num >= 4 && reg_num <= (TARGET_PTR_BIT == 64 ? 11 : 7))
1391 {
1392 while (reg_num >= 4 && reg_num <= (TARGET_PTR_BIT == 64 ? 11 : 7))
1393 {
1394 pc += 8;
1395 status = read_memory_nobpt (pc, buf, 4);
1396 inst = extract_unsigned_integer (buf, 4);
1397 if (status != 0)
1398 return pc;
1399 if ((inst & 0xfc000000) != 0x34000000)
1400 break;
1401 status = read_memory_nobpt (pc + 4, buf, 4);
1402 next_inst = extract_unsigned_integer (buf, 4);
1403 if (status != 0)
1404 return pc;
1405 reg_num = inst_saves_fr (next_inst);
1406 }
1407 args_stored = 0;
1408 continue;
1409 }
1410
1411 /* Quit if we hit any kind of branch. This can happen if a prologue
1412 instruction is in the delay slot of the first call/branch. */
1413 if (is_branch (inst))
1414 break;
1415
1416 /* What a crock. The HP compilers set args_stored even if no
1417 arguments were stored into the stack (boo hiss). This could
1418 cause this code to then skip a bunch of user insns (up to the
1419 first branch).
1420
1421 To combat this we try to identify when args_stored was bogusly
1422 set and clear it. We only do this when args_stored is nonzero,
1423 all other resources are accounted for, and nothing changed on
1424 this pass. */
1425 if (args_stored
1426 && !(save_gr || save_fr || save_rp || save_sp || stack_remaining > 0)
1427 && old_save_gr == save_gr && old_save_fr == save_fr
1428 && old_save_rp == save_rp && old_save_sp == save_sp
1429 && old_stack_remaining == stack_remaining)
1430 break;
1431
1432 /* Bump the PC. */
1433 pc += 4;
1434 }
1435
1436 /* We've got a tenative location for the end of the prologue. However
1437 because of limitations in the unwind descriptor mechanism we may
1438 have went too far into user code looking for the save of a register
1439 that does not exist. So, if there registers we expected to be saved
1440 but never were, mask them out and restart.
1441
1442 This should only happen in optimized code, and should be very rare. */
1443 if (save_gr || (save_fr && !(restart_fr || restart_gr)))
1444 {
1445 pc = orig_pc;
1446 restart_gr = save_gr;
1447 restart_fr = save_fr;
1448 goto restart;
1449 }
1450
1451 return pc;
1452 }
1453
1454
1455 /* Return the address of the PC after the last prologue instruction if
1456 we can determine it from the debug symbols. Else return zero. */
1457
1458 static CORE_ADDR
1459 after_prologue (CORE_ADDR pc)
1460 {
1461 struct symtab_and_line sal;
1462 CORE_ADDR func_addr, func_end;
1463 struct symbol *f;
1464
1465 /* If we can not find the symbol in the partial symbol table, then
1466 there is no hope we can determine the function's start address
1467 with this code. */
1468 if (!find_pc_partial_function (pc, NULL, &func_addr, &func_end))
1469 return 0;
1470
1471 /* Get the line associated with FUNC_ADDR. */
1472 sal = find_pc_line (func_addr, 0);
1473
1474 /* There are only two cases to consider. First, the end of the source line
1475 is within the function bounds. In that case we return the end of the
1476 source line. Second is the end of the source line extends beyond the
1477 bounds of the current function. We need to use the slow code to
1478 examine instructions in that case.
1479
1480 Anything else is simply a bug elsewhere. Fixing it here is absolutely
1481 the wrong thing to do. In fact, it should be entirely possible for this
1482 function to always return zero since the slow instruction scanning code
1483 is supposed to *always* work. If it does not, then it is a bug. */
1484 if (sal.end < func_end)
1485 return sal.end;
1486 else
1487 return 0;
1488 }
1489
1490 /* To skip prologues, I use this predicate. Returns either PC itself
1491 if the code at PC does not look like a function prologue; otherwise
1492 returns an address that (if we're lucky) follows the prologue. If
1493 LENIENT, then we must skip everything which is involved in setting
1494 up the frame (it's OK to skip more, just so long as we don't skip
1495 anything which might clobber the registers which are being saved.
1496 Currently we must not skip more on the alpha, but we might the lenient
1497 stuff some day. */
1498
1499 static CORE_ADDR
1500 hppa_skip_prologue (CORE_ADDR pc)
1501 {
1502 unsigned long inst;
1503 int offset;
1504 CORE_ADDR post_prologue_pc;
1505 char buf[4];
1506
1507 /* See if we can determine the end of the prologue via the symbol table.
1508 If so, then return either PC, or the PC after the prologue, whichever
1509 is greater. */
1510
1511 post_prologue_pc = after_prologue (pc);
1512
1513 /* If after_prologue returned a useful address, then use it. Else
1514 fall back on the instruction skipping code.
1515
1516 Some folks have claimed this causes problems because the breakpoint
1517 may be the first instruction of the prologue. If that happens, then
1518 the instruction skipping code has a bug that needs to be fixed. */
1519 if (post_prologue_pc != 0)
1520 return max (pc, post_prologue_pc);
1521 else
1522 return (skip_prologue_hard_way (pc));
1523 }
1524
1525 struct hppa_frame_cache
1526 {
1527 CORE_ADDR base;
1528 struct trad_frame_saved_reg *saved_regs;
1529 };
1530
1531 static struct hppa_frame_cache *
1532 hppa_frame_cache (struct frame_info *next_frame, void **this_cache)
1533 {
1534 struct hppa_frame_cache *cache;
1535 long saved_gr_mask;
1536 long saved_fr_mask;
1537 CORE_ADDR this_sp;
1538 long frame_size;
1539 struct unwind_table_entry *u;
1540 CORE_ADDR prologue_end;
1541 int i;
1542
1543 if (hppa_debug)
1544 fprintf_unfiltered (gdb_stdlog, "{ hppa_frame_cache (frame=%d) -> ",
1545 frame_relative_level(next_frame));
1546
1547 if ((*this_cache) != NULL)
1548 {
1549 if (hppa_debug)
1550 fprintf_unfiltered (gdb_stdlog, "base=0x%s (cached) }",
1551 paddr_nz (((struct hppa_frame_cache *)*this_cache)->base));
1552 return (*this_cache);
1553 }
1554 cache = FRAME_OBSTACK_ZALLOC (struct hppa_frame_cache);
1555 (*this_cache) = cache;
1556 cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
1557
1558 /* Yow! */
1559 u = find_unwind_entry (frame_func_unwind (next_frame));
1560 if (!u)
1561 {
1562 if (hppa_debug)
1563 fprintf_unfiltered (gdb_stdlog, "base=NULL (no unwind entry) }");
1564 return (*this_cache);
1565 }
1566
1567 /* Turn the Entry_GR field into a bitmask. */
1568 saved_gr_mask = 0;
1569 for (i = 3; i < u->Entry_GR + 3; i++)
1570 {
1571 /* Frame pointer gets saved into a special location. */
1572 if (u->Save_SP && i == HPPA_FP_REGNUM)
1573 continue;
1574
1575 saved_gr_mask |= (1 << i);
1576 }
1577
1578 /* Turn the Entry_FR field into a bitmask too. */
1579 saved_fr_mask = 0;
1580 for (i = 12; i < u->Entry_FR + 12; i++)
1581 saved_fr_mask |= (1 << i);
1582
1583 /* Loop until we find everything of interest or hit a branch.
1584
1585 For unoptimized GCC code and for any HP CC code this will never ever
1586 examine any user instructions.
1587
1588 For optimized GCC code we're faced with problems. GCC will schedule
1589 its prologue and make prologue instructions available for delay slot
1590 filling. The end result is user code gets mixed in with the prologue
1591 and a prologue instruction may be in the delay slot of the first branch
1592 or call.
1593
1594 Some unexpected things are expected with debugging optimized code, so
1595 we allow this routine to walk past user instructions in optimized
1596 GCC code. */
1597 {
1598 int final_iteration = 0;
1599 CORE_ADDR pc, end_pc;
1600 int looking_for_sp = u->Save_SP;
1601 int looking_for_rp = u->Save_RP;
1602 int fp_loc = -1;
1603
1604 /* We have to use hppa_skip_prologue instead of just
1605 skip_prologue_using_sal, in case we stepped into a function without
1606 symbol information. hppa_skip_prologue also bounds the returned
1607 pc by the passed in pc, so it will not return a pc in the next
1608 function. */
1609 prologue_end = hppa_skip_prologue (frame_func_unwind (next_frame));
1610 end_pc = frame_pc_unwind (next_frame);
1611
1612 if (prologue_end != 0 && end_pc > prologue_end)
1613 end_pc = prologue_end;
1614
1615 frame_size = 0;
1616
1617 for (pc = frame_func_unwind (next_frame);
1618 ((saved_gr_mask || saved_fr_mask
1619 || looking_for_sp || looking_for_rp
1620 || frame_size < (u->Total_frame_size << 3))
1621 && pc < end_pc);
1622 pc += 4)
1623 {
1624 int reg;
1625 char buf4[4];
1626 long status = read_memory_nobpt (pc, buf4, sizeof buf4);
1627 long inst = extract_unsigned_integer (buf4, sizeof buf4);
1628
1629 /* Note the interesting effects of this instruction. */
1630 frame_size += prologue_inst_adjust_sp (inst);
1631
1632 /* There are limited ways to store the return pointer into the
1633 stack. */
1634 if (inst == 0x6bc23fd9) /* stw rp,-0x14(sr0,sp) */
1635 {
1636 looking_for_rp = 0;
1637 cache->saved_regs[HPPA_RP_REGNUM].addr = -20;
1638 }
1639 else if (inst == 0x0fc212c1) /* std rp,-0x10(sr0,sp) */
1640 {
1641 looking_for_rp = 0;
1642 cache->saved_regs[HPPA_RP_REGNUM].addr = -16;
1643 }
1644
1645 /* Check to see if we saved SP into the stack. This also
1646 happens to indicate the location of the saved frame
1647 pointer. */
1648 if ((inst & 0xffffc000) == 0x6fc10000 /* stw,ma r1,N(sr0,sp) */
1649 || (inst & 0xffffc00c) == 0x73c10008) /* std,ma r1,N(sr0,sp) */
1650 {
1651 looking_for_sp = 0;
1652 cache->saved_regs[HPPA_FP_REGNUM].addr = 0;
1653 }
1654
1655 /* Account for general and floating-point register saves. */
1656 reg = inst_saves_gr (inst);
1657 if (reg >= 3 && reg <= 18
1658 && (!u->Save_SP || reg != HPPA_FP_REGNUM))
1659 {
1660 saved_gr_mask &= ~(1 << reg);
1661 if ((inst >> 26) == 0x1b && hppa_extract_14 (inst) >= 0)
1662 /* stwm with a positive displacement is a _post_
1663 _modify_. */
1664 cache->saved_regs[reg].addr = 0;
1665 else if ((inst & 0xfc00000c) == 0x70000008)
1666 /* A std has explicit post_modify forms. */
1667 cache->saved_regs[reg].addr = 0;
1668 else
1669 {
1670 CORE_ADDR offset;
1671
1672 if ((inst >> 26) == 0x1c)
1673 offset = (inst & 0x1 ? -1 << 13 : 0) | (((inst >> 4) & 0x3ff) << 3);
1674 else if ((inst >> 26) == 0x03)
1675 offset = hppa_low_hppa_sign_extend (inst & 0x1f, 5);
1676 else
1677 offset = hppa_extract_14 (inst);
1678
1679 /* Handle code with and without frame pointers. */
1680 if (u->Save_SP)
1681 cache->saved_regs[reg].addr = offset;
1682 else
1683 cache->saved_regs[reg].addr = (u->Total_frame_size << 3) + offset;
1684 }
1685 }
1686
1687 /* GCC handles callee saved FP regs a little differently.
1688
1689 It emits an instruction to put the value of the start of
1690 the FP store area into %r1. It then uses fstds,ma with a
1691 basereg of %r1 for the stores.
1692
1693 HP CC emits them at the current stack pointer modifying the
1694 stack pointer as it stores each register. */
1695
1696 /* ldo X(%r3),%r1 or ldo X(%r30),%r1. */
1697 if ((inst & 0xffffc000) == 0x34610000
1698 || (inst & 0xffffc000) == 0x37c10000)
1699 fp_loc = hppa_extract_14 (inst);
1700
1701 reg = inst_saves_fr (inst);
1702 if (reg >= 12 && reg <= 21)
1703 {
1704 /* Note +4 braindamage below is necessary because the FP
1705 status registers are internally 8 registers rather than
1706 the expected 4 registers. */
1707 saved_fr_mask &= ~(1 << reg);
1708 if (fp_loc == -1)
1709 {
1710 /* 1st HP CC FP register store. After this
1711 instruction we've set enough state that the GCC and
1712 HPCC code are both handled in the same manner. */
1713 cache->saved_regs[reg + HPPA_FP4_REGNUM + 4].addr = 0;
1714 fp_loc = 8;
1715 }
1716 else
1717 {
1718 cache->saved_regs[reg + HPPA_FP0_REGNUM + 4].addr = fp_loc;
1719 fp_loc += 8;
1720 }
1721 }
1722
1723 /* Quit if we hit any kind of branch the previous iteration. */
1724 if (final_iteration)
1725 break;
1726 /* We want to look precisely one instruction beyond the branch
1727 if we have not found everything yet. */
1728 if (is_branch (inst))
1729 final_iteration = 1;
1730 }
1731 }
1732
1733 {
1734 /* The frame base always represents the value of %sp at entry to
1735 the current function (and is thus equivalent to the "saved"
1736 stack pointer. */
1737 CORE_ADDR this_sp = frame_unwind_register_unsigned (next_frame, HPPA_SP_REGNUM);
1738
1739 if (hppa_debug)
1740 fprintf_unfiltered (gdb_stdlog, " (this_sp=0x%s, pc=0x%s, "
1741 "prologue_end=0x%s) ",
1742 paddr_nz (this_sp),
1743 paddr_nz (frame_pc_unwind (next_frame)),
1744 paddr_nz (prologue_end));
1745
1746 if (frame_pc_unwind (next_frame) >= prologue_end)
1747 {
1748 if (u->Save_SP && trad_frame_addr_p (cache->saved_regs, HPPA_SP_REGNUM))
1749 {
1750 /* Both we're expecting the SP to be saved and the SP has been
1751 saved. The entry SP value is saved at this frame's SP
1752 address. */
1753 cache->base = read_memory_integer (this_sp, TARGET_PTR_BIT / 8);
1754
1755 if (hppa_debug)
1756 fprintf_unfiltered (gdb_stdlog, " (base=0x%s) [saved] }",
1757 paddr_nz (cache->base));
1758 }
1759 else
1760 {
1761 /* The prologue has been slowly allocating stack space. Adjust
1762 the SP back. */
1763 cache->base = this_sp - frame_size;
1764 if (hppa_debug)
1765 fprintf_unfiltered (gdb_stdlog, " (base=0x%s) [unwind adjust] } ",
1766 paddr_nz (cache->base));
1767
1768 }
1769 }
1770 else
1771 {
1772 /* This frame has not yet been created. */
1773 cache->base = this_sp;
1774
1775 if (hppa_debug)
1776 fprintf_unfiltered (gdb_stdlog, " (base=0x%s) [before prologue] } ",
1777 paddr_nz (cache->base));
1778
1779 }
1780
1781 trad_frame_set_value (cache->saved_regs, HPPA_SP_REGNUM, cache->base);
1782 }
1783
1784 /* The PC is found in the "return register", "Millicode" uses "r31"
1785 as the return register while normal code uses "rp". */
1786 if (u->Millicode)
1787 {
1788 if (trad_frame_addr_p (cache->saved_regs, HPPA_RP_REGNUM))
1789 cache->saved_regs[HPPA_PCOQ_HEAD_REGNUM] = cache->saved_regs[31];
1790 else
1791 {
1792 ULONGEST r31 = frame_unwind_register_unsigned (next_frame, 31);
1793 trad_frame_set_value (cache->saved_regs, HPPA_PCOQ_HEAD_REGNUM, r31);
1794 }
1795 }
1796 else
1797 {
1798 if (trad_frame_addr_p (cache->saved_regs, HPPA_RP_REGNUM))
1799 cache->saved_regs[HPPA_PCOQ_HEAD_REGNUM] = cache->saved_regs[HPPA_RP_REGNUM];
1800 else
1801 {
1802 ULONGEST rp = frame_unwind_register_unsigned (next_frame, HPPA_RP_REGNUM);
1803 trad_frame_set_value (cache->saved_regs, HPPA_PCOQ_HEAD_REGNUM, rp);
1804 }
1805 }
1806
1807 {
1808 /* Convert all the offsets into addresses. */
1809 int reg;
1810 for (reg = 0; reg < NUM_REGS; reg++)
1811 {
1812 if (trad_frame_addr_p (cache->saved_regs, reg))
1813 cache->saved_regs[reg].addr += cache->base;
1814 }
1815 }
1816
1817 if (hppa_debug)
1818 fprintf_unfiltered (gdb_stdlog, "base=0x%s }",
1819 paddr_nz (((struct hppa_frame_cache *)*this_cache)->base));
1820 return (*this_cache);
1821 }
1822
1823 static void
1824 hppa_frame_this_id (struct frame_info *next_frame, void **this_cache,
1825 struct frame_id *this_id)
1826 {
1827 struct hppa_frame_cache *info = hppa_frame_cache (next_frame, this_cache);
1828 (*this_id) = frame_id_build (info->base, frame_func_unwind (next_frame));
1829 }
1830
1831 static void
1832 hppa_frame_prev_register (struct frame_info *next_frame,
1833 void **this_cache,
1834 int regnum, int *optimizedp,
1835 enum lval_type *lvalp, CORE_ADDR *addrp,
1836 int *realnump, void *valuep)
1837 {
1838 struct hppa_frame_cache *info = hppa_frame_cache (next_frame, this_cache);
1839 hppa_frame_prev_register_helper (next_frame, info->saved_regs, regnum,
1840 optimizedp, lvalp, addrp, realnump, valuep);
1841 }
1842
1843 static const struct frame_unwind hppa_frame_unwind =
1844 {
1845 NORMAL_FRAME,
1846 hppa_frame_this_id,
1847 hppa_frame_prev_register
1848 };
1849
1850 static const struct frame_unwind *
1851 hppa_frame_unwind_sniffer (struct frame_info *next_frame)
1852 {
1853 CORE_ADDR pc = frame_pc_unwind (next_frame);
1854
1855 if (find_unwind_entry (pc))
1856 return &hppa_frame_unwind;
1857
1858 return NULL;
1859 }
1860
1861 /* This is a generic fallback frame unwinder that kicks in if we fail all
1862 the other ones. Normally we would expect the stub and regular unwinder
1863 to work, but in some cases we might hit a function that just doesn't
1864 have any unwind information available. In this case we try to do
1865 unwinding solely based on code reading. This is obviously going to be
1866 slow, so only use this as a last resort. Currently this will only
1867 identify the stack and pc for the frame. */
1868
1869 static struct hppa_frame_cache *
1870 hppa_fallback_frame_cache (struct frame_info *next_frame, void **this_cache)
1871 {
1872 struct hppa_frame_cache *cache;
1873 CORE_ADDR pc, start_pc, end_pc, cur_pc;
1874
1875 cache = FRAME_OBSTACK_ZALLOC (struct hppa_frame_cache);
1876 (*this_cache) = cache;
1877 cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
1878
1879 pc = frame_func_unwind (next_frame);
1880 cur_pc = frame_pc_unwind (next_frame);
1881
1882 find_pc_partial_function (pc, NULL, &start_pc, &end_pc);
1883
1884 if (start_pc == 0 || end_pc == 0)
1885 {
1886 error ("Cannot find bounds of current function (@0x%s), unwinding will "
1887 "fail.", paddr_nz (pc));
1888 return cache;
1889 }
1890
1891 if (end_pc > cur_pc)
1892 end_pc = cur_pc;
1893
1894 for (pc = start_pc; pc < end_pc; pc += 4)
1895 {
1896 unsigned int insn;
1897
1898 insn = read_memory_unsigned_integer (pc, 4);
1899
1900 /* There are limited ways to store the return pointer into the
1901 stack. */
1902 if (insn == 0x6bc23fd9) /* stw rp,-0x14(sr0,sp) */
1903 {
1904 cache->saved_regs[HPPA_RP_REGNUM].addr = -20;
1905 break;
1906 }
1907 else if (insn == 0x0fc212c1) /* std rp,-0x10(sr0,sp) */
1908 {
1909 cache->saved_regs[HPPA_RP_REGNUM].addr = -16;
1910 break;
1911 }
1912 }
1913
1914 cache->base = frame_unwind_register_unsigned (next_frame, HPPA_SP_REGNUM);
1915
1916 if (trad_frame_addr_p (cache->saved_regs, HPPA_RP_REGNUM))
1917 {
1918 cache->saved_regs[HPPA_RP_REGNUM].addr += cache->base;
1919 cache->saved_regs[HPPA_PCOQ_HEAD_REGNUM] = cache->saved_regs[HPPA_RP_REGNUM];
1920 }
1921 else
1922 {
1923 ULONGEST rp = frame_unwind_register_unsigned (next_frame, HPPA_RP_REGNUM);
1924 trad_frame_set_value (cache->saved_regs, HPPA_PCOQ_HEAD_REGNUM, rp);
1925 }
1926
1927 return cache;
1928 }
1929
1930 static void
1931 hppa_fallback_frame_this_id (struct frame_info *next_frame, void **this_cache,
1932 struct frame_id *this_id)
1933 {
1934 struct hppa_frame_cache *info =
1935 hppa_fallback_frame_cache (next_frame, this_cache);
1936 (*this_id) = frame_id_build (info->base, frame_func_unwind (next_frame));
1937 }
1938
1939 static void
1940 hppa_fallback_frame_prev_register (struct frame_info *next_frame,
1941 void **this_cache,
1942 int regnum, int *optimizedp,
1943 enum lval_type *lvalp, CORE_ADDR *addrp,
1944 int *realnump, void *valuep)
1945 {
1946 struct hppa_frame_cache *info =
1947 hppa_fallback_frame_cache (next_frame, this_cache);
1948 hppa_frame_prev_register_helper (next_frame, info->saved_regs, regnum,
1949 optimizedp, lvalp, addrp, realnump, valuep);
1950 }
1951
1952 static const struct frame_unwind hppa_fallback_frame_unwind =
1953 {
1954 NORMAL_FRAME,
1955 hppa_fallback_frame_this_id,
1956 hppa_fallback_frame_prev_register
1957 };
1958
1959 static const struct frame_unwind *
1960 hppa_fallback_unwind_sniffer (struct frame_info *next_frame)
1961 {
1962 return &hppa_fallback_frame_unwind;
1963 }
1964
1965 static CORE_ADDR
1966 hppa_frame_base_address (struct frame_info *next_frame,
1967 void **this_cache)
1968 {
1969 struct hppa_frame_cache *info = hppa_frame_cache (next_frame,
1970 this_cache);
1971 return info->base;
1972 }
1973
1974 static const struct frame_base hppa_frame_base = {
1975 &hppa_frame_unwind,
1976 hppa_frame_base_address,
1977 hppa_frame_base_address,
1978 hppa_frame_base_address
1979 };
1980
1981 static const struct frame_base *
1982 hppa_frame_base_sniffer (struct frame_info *next_frame)
1983 {
1984 return &hppa_frame_base;
1985 }
1986
1987 /* Stub frames, used for all kinds of call stubs. */
1988 struct hppa_stub_unwind_cache
1989 {
1990 CORE_ADDR base;
1991 struct trad_frame_saved_reg *saved_regs;
1992 };
1993
1994 static struct hppa_stub_unwind_cache *
1995 hppa_stub_frame_unwind_cache (struct frame_info *next_frame,
1996 void **this_cache)
1997 {
1998 struct gdbarch *gdbarch = get_frame_arch (next_frame);
1999 struct hppa_stub_unwind_cache *info;
2000
2001 if (*this_cache)
2002 return *this_cache;
2003
2004 info = FRAME_OBSTACK_ZALLOC (struct hppa_stub_unwind_cache);
2005 *this_cache = info;
2006 info->saved_regs = trad_frame_alloc_saved_regs (next_frame);
2007
2008 info->saved_regs[HPPA_PCOQ_HEAD_REGNUM].realreg = HPPA_RP_REGNUM;
2009 info->base = frame_unwind_register_unsigned (next_frame, HPPA_SP_REGNUM);
2010
2011 return info;
2012 }
2013
2014 static void
2015 hppa_stub_frame_this_id (struct frame_info *next_frame,
2016 void **this_prologue_cache,
2017 struct frame_id *this_id)
2018 {
2019 struct hppa_stub_unwind_cache *info
2020 = hppa_stub_frame_unwind_cache (next_frame, this_prologue_cache);
2021 *this_id = frame_id_build (info->base, frame_pc_unwind (next_frame));
2022 }
2023
2024 static void
2025 hppa_stub_frame_prev_register (struct frame_info *next_frame,
2026 void **this_prologue_cache,
2027 int regnum, int *optimizedp,
2028 enum lval_type *lvalp, CORE_ADDR *addrp,
2029 int *realnump, void *valuep)
2030 {
2031 struct hppa_stub_unwind_cache *info
2032 = hppa_stub_frame_unwind_cache (next_frame, this_prologue_cache);
2033 hppa_frame_prev_register_helper (next_frame, info->saved_regs, regnum,
2034 optimizedp, lvalp, addrp, realnump, valuep);
2035 }
2036
2037 static const struct frame_unwind hppa_stub_frame_unwind = {
2038 NORMAL_FRAME,
2039 hppa_stub_frame_this_id,
2040 hppa_stub_frame_prev_register
2041 };
2042
2043 static const struct frame_unwind *
2044 hppa_stub_unwind_sniffer (struct frame_info *next_frame)
2045 {
2046 CORE_ADDR pc = frame_pc_unwind (next_frame);
2047
2048 if (IN_SOLIB_CALL_TRAMPOLINE (pc, NULL)
2049 || IN_SOLIB_RETURN_TRAMPOLINE (pc, NULL))
2050 return &hppa_stub_frame_unwind;
2051 return NULL;
2052 }
2053
2054 static struct frame_id
2055 hppa_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
2056 {
2057 return frame_id_build (frame_unwind_register_unsigned (next_frame,
2058 HPPA_SP_REGNUM),
2059 frame_pc_unwind (next_frame));
2060 }
2061
2062 static CORE_ADDR
2063 hppa_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
2064 {
2065 return frame_unwind_register_signed (next_frame, HPPA_PCOQ_HEAD_REGNUM) & ~3;
2066 }
2067
2068 /* Instead of this nasty cast, add a method pvoid() that prints out a
2069 host VOID data type (remember %p isn't portable). */
2070
2071 static CORE_ADDR
2072 hppa_pointer_to_address_hack (void *ptr)
2073 {
2074 gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
2075 return POINTER_TO_ADDRESS (builtin_type_void_data_ptr, &ptr);
2076 }
2077
2078 static void
2079 unwind_command (char *exp, int from_tty)
2080 {
2081 CORE_ADDR address;
2082 struct unwind_table_entry *u;
2083
2084 /* If we have an expression, evaluate it and use it as the address. */
2085
2086 if (exp != 0 && *exp != 0)
2087 address = parse_and_eval_address (exp);
2088 else
2089 return;
2090
2091 u = find_unwind_entry (address);
2092
2093 if (!u)
2094 {
2095 printf_unfiltered ("Can't find unwind table entry for %s\n", exp);
2096 return;
2097 }
2098
2099 printf_unfiltered ("unwind_table_entry (0x%s):\n",
2100 paddr_nz (hppa_pointer_to_address_hack (u)));
2101
2102 printf_unfiltered ("\tregion_start = ");
2103 print_address (u->region_start, gdb_stdout);
2104
2105 printf_unfiltered ("\n\tregion_end = ");
2106 print_address (u->region_end, gdb_stdout);
2107
2108 #define pif(FLD) if (u->FLD) printf_unfiltered (" "#FLD);
2109
2110 printf_unfiltered ("\n\tflags =");
2111 pif (Cannot_unwind);
2112 pif (Millicode);
2113 pif (Millicode_save_sr0);
2114 pif (Entry_SR);
2115 pif (Args_stored);
2116 pif (Variable_Frame);
2117 pif (Separate_Package_Body);
2118 pif (Frame_Extension_Millicode);
2119 pif (Stack_Overflow_Check);
2120 pif (Two_Instruction_SP_Increment);
2121 pif (Ada_Region);
2122 pif (Save_SP);
2123 pif (Save_RP);
2124 pif (Save_MRP_in_frame);
2125 pif (extn_ptr_defined);
2126 pif (Cleanup_defined);
2127 pif (MPE_XL_interrupt_marker);
2128 pif (HP_UX_interrupt_marker);
2129 pif (Large_frame);
2130
2131 putchar_unfiltered ('\n');
2132
2133 #define pin(FLD) printf_unfiltered ("\t"#FLD" = 0x%x\n", u->FLD);
2134
2135 pin (Region_description);
2136 pin (Entry_FR);
2137 pin (Entry_GR);
2138 pin (Total_frame_size);
2139 }
2140
2141 void
2142 hppa_skip_permanent_breakpoint (void)
2143 {
2144 /* To step over a breakpoint instruction on the PA takes some
2145 fiddling with the instruction address queue.
2146
2147 When we stop at a breakpoint, the IA queue front (the instruction
2148 we're executing now) points at the breakpoint instruction, and
2149 the IA queue back (the next instruction to execute) points to
2150 whatever instruction we would execute after the breakpoint, if it
2151 were an ordinary instruction. This is the case even if the
2152 breakpoint is in the delay slot of a branch instruction.
2153
2154 Clearly, to step past the breakpoint, we need to set the queue
2155 front to the back. But what do we put in the back? What
2156 instruction comes after that one? Because of the branch delay
2157 slot, the next insn is always at the back + 4. */
2158 write_register (HPPA_PCOQ_HEAD_REGNUM, read_register (HPPA_PCOQ_TAIL_REGNUM));
2159 write_register (HPPA_PCSQ_HEAD_REGNUM, read_register (HPPA_PCSQ_TAIL_REGNUM));
2160
2161 write_register (HPPA_PCOQ_TAIL_REGNUM, read_register (HPPA_PCOQ_TAIL_REGNUM) + 4);
2162 /* We can leave the tail's space the same, since there's no jump. */
2163 }
2164
2165 int
2166 hppa_pc_requires_run_before_use (CORE_ADDR pc)
2167 {
2168 /* Sometimes we may pluck out a minimal symbol that has a negative address.
2169
2170 An example of this occurs when an a.out is linked against a foo.sl.
2171 The foo.sl defines a global bar(), and the a.out declares a signature
2172 for bar(). However, the a.out doesn't directly call bar(), but passes
2173 its address in another call.
2174
2175 If you have this scenario and attempt to "break bar" before running,
2176 gdb will find a minimal symbol for bar() in the a.out. But that
2177 symbol's address will be negative. What this appears to denote is
2178 an index backwards from the base of the procedure linkage table (PLT)
2179 into the data linkage table (DLT), the end of which is contiguous
2180 with the start of the PLT. This is clearly not a valid address for
2181 us to set a breakpoint on.
2182
2183 Note that one must be careful in how one checks for a negative address.
2184 0xc0000000 is a legitimate address of something in a shared text
2185 segment, for example. Since I don't know what the possible range
2186 is of these "really, truly negative" addresses that come from the
2187 minimal symbols, I'm resorting to the gross hack of checking the
2188 top byte of the address for all 1's. Sigh. */
2189
2190 return (!target_has_stack && (pc & 0xFF000000));
2191 }
2192
2193 int
2194 hppa_instruction_nullified (void)
2195 {
2196 /* brobecker 2002/11/07: Couldn't we use a ULONGEST here? It would
2197 avoid the type cast. I'm leaving it as is for now as I'm doing
2198 semi-mechanical multiarching-related changes. */
2199 const int ipsw = (int) read_register (HPPA_IPSW_REGNUM);
2200 const int flags = (int) read_register (HPPA_FLAGS_REGNUM);
2201
2202 return ((ipsw & 0x00200000) && !(flags & 0x2));
2203 }
2204
2205 /* Return the GDB type object for the "standard" data type of data
2206 in register N. */
2207
2208 static struct type *
2209 hppa32_register_type (struct gdbarch *gdbarch, int reg_nr)
2210 {
2211 if (reg_nr < HPPA_FP4_REGNUM)
2212 return builtin_type_uint32;
2213 else
2214 return builtin_type_ieee_single_big;
2215 }
2216
2217 /* Return the GDB type object for the "standard" data type of data
2218 in register N. hppa64 version. */
2219
2220 static struct type *
2221 hppa64_register_type (struct gdbarch *gdbarch, int reg_nr)
2222 {
2223 if (reg_nr < HPPA_FP4_REGNUM)
2224 return builtin_type_uint64;
2225 else
2226 return builtin_type_ieee_double_big;
2227 }
2228
2229 /* Return True if REGNUM is not a register available to the user
2230 through ptrace(). */
2231
2232 static int
2233 hppa_cannot_store_register (int regnum)
2234 {
2235 return (regnum == 0
2236 || regnum == HPPA_PCSQ_HEAD_REGNUM
2237 || (regnum >= HPPA_PCSQ_TAIL_REGNUM && regnum < HPPA_IPSW_REGNUM)
2238 || (regnum > HPPA_IPSW_REGNUM && regnum < HPPA_FP4_REGNUM));
2239
2240 }
2241
2242 static CORE_ADDR
2243 hppa_smash_text_address (CORE_ADDR addr)
2244 {
2245 /* The low two bits of the PC on the PA contain the privilege level.
2246 Some genius implementing a (non-GCC) compiler apparently decided
2247 this means that "addresses" in a text section therefore include a
2248 privilege level, and thus symbol tables should contain these bits.
2249 This seems like a bonehead thing to do--anyway, it seems to work
2250 for our purposes to just ignore those bits. */
2251
2252 return (addr &= ~0x3);
2253 }
2254
2255 /* Get the ith function argument for the current function. */
2256 CORE_ADDR
2257 hppa_fetch_pointer_argument (struct frame_info *frame, int argi,
2258 struct type *type)
2259 {
2260 CORE_ADDR addr;
2261 get_frame_register (frame, HPPA_R0_REGNUM + 26 - argi, &addr);
2262 return addr;
2263 }
2264
2265 static void
2266 hppa_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
2267 int regnum, void *buf)
2268 {
2269 ULONGEST tmp;
2270
2271 regcache_raw_read_unsigned (regcache, regnum, &tmp);
2272 if (regnum == HPPA_PCOQ_HEAD_REGNUM || regnum == HPPA_PCOQ_TAIL_REGNUM)
2273 tmp &= ~0x3;
2274 store_unsigned_integer (buf, sizeof(tmp), tmp);
2275 }
2276
2277 void
2278 hppa_frame_prev_register_helper (struct frame_info *next_frame,
2279 struct trad_frame_saved_reg saved_regs[],
2280 int regnum, int *optimizedp,
2281 enum lval_type *lvalp, CORE_ADDR *addrp,
2282 int *realnump, void *valuep)
2283 {
2284 int pcoqt = (regnum == HPPA_PCOQ_TAIL_REGNUM);
2285 struct gdbarch *gdbarch = get_frame_arch (next_frame);
2286 int regsize = register_size (gdbarch, HPPA_PCOQ_HEAD_REGNUM);
2287
2288 if (pcoqt)
2289 regnum = HPPA_PCOQ_HEAD_REGNUM;
2290
2291 trad_frame_prev_register (next_frame, saved_regs, regnum,
2292 optimizedp, lvalp, addrp, realnump, valuep);
2293
2294 if (pcoqt)
2295 store_unsigned_integer (valuep, regsize,
2296 extract_unsigned_integer (valuep, regsize) + 4);
2297 }
2298
2299 /* Here is a table of C type sizes on hppa with various compiles
2300 and options. I measured this on PA 9000/800 with HP-UX 11.11
2301 and these compilers:
2302
2303 /usr/ccs/bin/cc HP92453-01 A.11.01.21
2304 /opt/ansic/bin/cc HP92453-01 B.11.11.28706.GP
2305 /opt/aCC/bin/aCC B3910B A.03.45
2306 gcc gcc 3.3.2 native hppa2.0w-hp-hpux11.11
2307
2308 cc : 1 2 4 4 8 : 4 8 -- : 4 4
2309 ansic +DA1.1 : 1 2 4 4 8 : 4 8 16 : 4 4
2310 ansic +DA2.0 : 1 2 4 4 8 : 4 8 16 : 4 4
2311 ansic +DA2.0W : 1 2 4 8 8 : 4 8 16 : 8 8
2312 acc +DA1.1 : 1 2 4 4 8 : 4 8 16 : 4 4
2313 acc +DA2.0 : 1 2 4 4 8 : 4 8 16 : 4 4
2314 acc +DA2.0W : 1 2 4 8 8 : 4 8 16 : 8 8
2315 gcc : 1 2 4 4 8 : 4 8 16 : 4 4
2316
2317 Each line is:
2318
2319 compiler and options
2320 char, short, int, long, long long
2321 float, double, long double
2322 char *, void (*)()
2323
2324 So all these compilers use either ILP32 or LP64 model.
2325 TODO: gcc has more options so it needs more investigation.
2326
2327 For floating point types, see:
2328
2329 http://docs.hp.com/hpux/pdf/B3906-90006.pdf
2330 HP-UX floating-point guide, hpux 11.00
2331
2332 -- chastain 2003-12-18 */
2333
2334 static struct gdbarch *
2335 hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
2336 {
2337 struct gdbarch_tdep *tdep;
2338 struct gdbarch *gdbarch;
2339
2340 /* Try to determine the ABI of the object we are loading. */
2341 if (info.abfd != NULL && info.osabi == GDB_OSABI_UNKNOWN)
2342 {
2343 /* If it's a SOM file, assume it's HP/UX SOM. */
2344 if (bfd_get_flavour (info.abfd) == bfd_target_som_flavour)
2345 info.osabi = GDB_OSABI_HPUX_SOM;
2346 }
2347
2348 /* find a candidate among the list of pre-declared architectures. */
2349 arches = gdbarch_list_lookup_by_info (arches, &info);
2350 if (arches != NULL)
2351 return (arches->gdbarch);
2352
2353 /* If none found, then allocate and initialize one. */
2354 tdep = XZALLOC (struct gdbarch_tdep);
2355 gdbarch = gdbarch_alloc (&info, tdep);
2356
2357 /* Determine from the bfd_arch_info structure if we are dealing with
2358 a 32 or 64 bits architecture. If the bfd_arch_info is not available,
2359 then default to a 32bit machine. */
2360 if (info.bfd_arch_info != NULL)
2361 tdep->bytes_per_address =
2362 info.bfd_arch_info->bits_per_address / info.bfd_arch_info->bits_per_byte;
2363 else
2364 tdep->bytes_per_address = 4;
2365
2366 /* Some parts of the gdbarch vector depend on whether we are running
2367 on a 32 bits or 64 bits target. */
2368 switch (tdep->bytes_per_address)
2369 {
2370 case 4:
2371 set_gdbarch_num_regs (gdbarch, hppa32_num_regs);
2372 set_gdbarch_register_name (gdbarch, hppa32_register_name);
2373 set_gdbarch_register_type (gdbarch, hppa32_register_type);
2374 break;
2375 case 8:
2376 set_gdbarch_num_regs (gdbarch, hppa64_num_regs);
2377 set_gdbarch_register_name (gdbarch, hppa64_register_name);
2378 set_gdbarch_register_type (gdbarch, hppa64_register_type);
2379 break;
2380 default:
2381 internal_error (__FILE__, __LINE__, "Unsupported address size: %d",
2382 tdep->bytes_per_address);
2383 }
2384
2385 set_gdbarch_long_bit (gdbarch, tdep->bytes_per_address * TARGET_CHAR_BIT);
2386 set_gdbarch_ptr_bit (gdbarch, tdep->bytes_per_address * TARGET_CHAR_BIT);
2387
2388 /* The following gdbarch vector elements are the same in both ILP32
2389 and LP64, but might show differences some day. */
2390 set_gdbarch_long_long_bit (gdbarch, 64);
2391 set_gdbarch_long_double_bit (gdbarch, 128);
2392 set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_big);
2393
2394 /* The following gdbarch vector elements do not depend on the address
2395 size, or in any other gdbarch element previously set. */
2396 set_gdbarch_skip_prologue (gdbarch, hppa_skip_prologue);
2397 set_gdbarch_inner_than (gdbarch, core_addr_greaterthan);
2398 set_gdbarch_sp_regnum (gdbarch, HPPA_SP_REGNUM);
2399 set_gdbarch_fp0_regnum (gdbarch, HPPA_FP0_REGNUM);
2400 set_gdbarch_cannot_store_register (gdbarch, hppa_cannot_store_register);
2401 set_gdbarch_cannot_fetch_register (gdbarch, hppa_cannot_store_register);
2402 set_gdbarch_addr_bits_remove (gdbarch, hppa_smash_text_address);
2403 set_gdbarch_smash_text_address (gdbarch, hppa_smash_text_address);
2404 set_gdbarch_believe_pcc_promotion (gdbarch, 1);
2405 set_gdbarch_read_pc (gdbarch, hppa_target_read_pc);
2406 set_gdbarch_write_pc (gdbarch, hppa_target_write_pc);
2407
2408 /* Helper for function argument information. */
2409 set_gdbarch_fetch_pointer_argument (gdbarch, hppa_fetch_pointer_argument);
2410
2411 set_gdbarch_print_insn (gdbarch, print_insn_hppa);
2412
2413 /* When a hardware watchpoint triggers, we'll move the inferior past
2414 it by removing all eventpoints; stepping past the instruction
2415 that caused the trigger; reinserting eventpoints; and checking
2416 whether any watched location changed. */
2417 set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);
2418
2419 /* Inferior function call methods. */
2420 switch (tdep->bytes_per_address)
2421 {
2422 case 4:
2423 set_gdbarch_push_dummy_call (gdbarch, hppa32_push_dummy_call);
2424 set_gdbarch_frame_align (gdbarch, hppa32_frame_align);
2425 break;
2426 case 8:
2427 set_gdbarch_push_dummy_call (gdbarch, hppa64_push_dummy_call);
2428 set_gdbarch_frame_align (gdbarch, hppa64_frame_align);
2429 break;
2430 default:
2431 internal_error (__FILE__, __LINE__, "bad switch");
2432 }
2433
2434 /* Struct return methods. */
2435 switch (tdep->bytes_per_address)
2436 {
2437 case 4:
2438 set_gdbarch_return_value (gdbarch, hppa32_return_value);
2439 break;
2440 case 8:
2441 set_gdbarch_return_value (gdbarch, hppa64_return_value);
2442 break;
2443 default:
2444 internal_error (__FILE__, __LINE__, "bad switch");
2445 }
2446
2447 set_gdbarch_breakpoint_from_pc (gdbarch, hppa_breakpoint_from_pc);
2448 set_gdbarch_pseudo_register_read (gdbarch, hppa_pseudo_register_read);
2449
2450 /* Frame unwind methods. */
2451 set_gdbarch_unwind_dummy_id (gdbarch, hppa_unwind_dummy_id);
2452 set_gdbarch_unwind_pc (gdbarch, hppa_unwind_pc);
2453
2454 /* Hook in ABI-specific overrides, if they have been registered. */
2455 gdbarch_init_osabi (info, gdbarch);
2456
2457 /* Hook in the default unwinders. */
2458 frame_unwind_append_sniffer (gdbarch, hppa_stub_unwind_sniffer);
2459 frame_unwind_append_sniffer (gdbarch, hppa_frame_unwind_sniffer);
2460 frame_unwind_append_sniffer (gdbarch, hppa_fallback_unwind_sniffer);
2461 frame_base_append_sniffer (gdbarch, hppa_frame_base_sniffer);
2462
2463 return gdbarch;
2464 }
2465
2466 static void
2467 hppa_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
2468 {
2469 struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
2470
2471 fprintf_unfiltered (file, "bytes_per_address = %d\n",
2472 tdep->bytes_per_address);
2473 fprintf_unfiltered (file, "elf = %s\n", tdep->is_elf ? "yes" : "no");
2474 }
2475
2476 void
2477 _initialize_hppa_tdep (void)
2478 {
2479 struct cmd_list_element *c;
2480 void break_at_finish_command (char *arg, int from_tty);
2481 void tbreak_at_finish_command (char *arg, int from_tty);
2482 void break_at_finish_at_depth_command (char *arg, int from_tty);
2483
2484 gdbarch_register (bfd_arch_hppa, hppa_gdbarch_init, hppa_dump_tdep);
2485
2486 hppa_objfile_priv_data = register_objfile_data ();
2487
2488 add_cmd ("unwind", class_maintenance, unwind_command,
2489 "Print unwind table entry at given address.",
2490 &maintenanceprintlist);
2491
2492 deprecate_cmd (add_com ("xbreak", class_breakpoint,
2493 break_at_finish_command,
2494 concat ("Set breakpoint at procedure exit. \n\
2495 Argument may be function name, or \"*\" and an address.\n\
2496 If function is specified, break at end of code for that function.\n\
2497 If an address is specified, break at the end of the function that contains \n\
2498 that exact address.\n",
2499 "With no arg, uses current execution address of selected stack frame.\n\
2500 This is useful for breaking on return to a stack frame.\n\
2501 \n\
2502 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
2503 \n\
2504 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL)), NULL);
2505 deprecate_cmd (add_com_alias ("xb", "xbreak", class_breakpoint, 1), NULL);
2506 deprecate_cmd (add_com_alias ("xbr", "xbreak", class_breakpoint, 1), NULL);
2507 deprecate_cmd (add_com_alias ("xbre", "xbreak", class_breakpoint, 1), NULL);
2508 deprecate_cmd (add_com_alias ("xbrea", "xbreak", class_breakpoint, 1), NULL);
2509
2510 deprecate_cmd (c = add_com ("txbreak", class_breakpoint,
2511 tbreak_at_finish_command,
2512 "Set temporary breakpoint at procedure exit. Either there should\n\
2513 be no argument or the argument must be a depth.\n"), NULL);
2514 set_cmd_completer (c, location_completer);
2515
2516 if (xdb_commands)
2517 deprecate_cmd (add_com ("bx", class_breakpoint,
2518 break_at_finish_at_depth_command,
2519 "Set breakpoint at procedure exit. Either there should\n\
2520 be no argument or the argument must be a depth.\n"), NULL);
2521
2522 /* Debug this files internals. */
2523 add_show_from_set (add_set_cmd ("hppa", class_maintenance, var_zinteger,
2524 &hppa_debug, "Set hppa debugging.\n\
2525 When non-zero, hppa specific debugging is enabled.", &setdebuglist), &showdebuglist);
2526 }
2527
This page took 0.081098 seconds and 5 git commands to generate.