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