1 /* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger.
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
32 #include "gdb_string.h"
36 #include "arch-utils.h"
40 #include "alpha-tdep.h"
42 static gdbarch_init_ftype alpha_gdbarch_init
;
44 static gdbarch_register_name_ftype alpha_register_name
;
45 static gdbarch_register_raw_size_ftype alpha_register_raw_size
;
46 static gdbarch_register_virtual_size_ftype alpha_register_virtual_size
;
47 static gdbarch_register_virtual_type_ftype alpha_register_virtual_type
;
48 static gdbarch_register_byte_ftype alpha_register_byte
;
49 static gdbarch_cannot_fetch_register_ftype alpha_cannot_fetch_register
;
50 static gdbarch_cannot_store_register_ftype alpha_cannot_store_register
;
51 static gdbarch_register_convertible_ftype alpha_register_convertible
;
52 static gdbarch_register_convert_to_virtual_ftype
53 alpha_register_convert_to_virtual
;
54 static gdbarch_register_convert_to_raw_ftype alpha_register_convert_to_raw
;
55 static gdbarch_store_struct_return_ftype alpha_store_struct_return
;
56 static gdbarch_extract_return_value_ftype alpha_extract_return_value
;
57 static gdbarch_store_return_value_ftype alpha_store_return_value
;
58 static gdbarch_extract_struct_value_address_ftype
59 alpha_extract_struct_value_address
;
60 static gdbarch_use_struct_convention_ftype alpha_use_struct_convention
;
62 static gdbarch_breakpoint_from_pc_ftype alpha_breakpoint_from_pc
;
64 static gdbarch_frame_args_address_ftype alpha_frame_args_address
;
65 static gdbarch_frame_locals_address_ftype alpha_frame_locals_address
;
67 static gdbarch_skip_prologue_ftype alpha_skip_prologue
;
68 static gdbarch_get_saved_register_ftype alpha_get_saved_register
;
69 static gdbarch_saved_pc_after_call_ftype alpha_saved_pc_after_call
;
70 static gdbarch_frame_chain_ftype alpha_frame_chain
;
71 static gdbarch_frame_saved_pc_ftype alpha_frame_saved_pc
;
72 static gdbarch_frame_init_saved_regs_ftype alpha_frame_init_saved_regs
;
74 static gdbarch_push_arguments_ftype alpha_push_arguments
;
75 static gdbarch_push_dummy_frame_ftype alpha_push_dummy_frame
;
76 static gdbarch_pop_frame_ftype alpha_pop_frame
;
77 static gdbarch_fix_call_dummy_ftype alpha_fix_call_dummy
;
78 static gdbarch_init_frame_pc_first_ftype alpha_init_frame_pc_first
;
79 static gdbarch_init_extra_frame_info_ftype alpha_init_extra_frame_info
;
81 static gdbarch_get_longjmp_target_ftype alpha_get_longjmp_target
;
83 struct frame_extra_info
85 alpha_extra_func_info_t proc_desc
;
90 /* FIXME: Some of this code should perhaps be merged with mips-tdep.c. */
92 /* Prototypes for local functions. */
94 static void alpha_find_saved_regs (struct frame_info
*);
96 static alpha_extra_func_info_t
push_sigtramp_desc (CORE_ADDR low_addr
);
98 static CORE_ADDR
read_next_frame_reg (struct frame_info
*, int);
100 static CORE_ADDR
heuristic_proc_start (CORE_ADDR
);
102 static alpha_extra_func_info_t
heuristic_proc_desc (CORE_ADDR
,
104 struct frame_info
*);
106 static alpha_extra_func_info_t
find_proc_desc (CORE_ADDR
,
107 struct frame_info
*);
110 static int alpha_in_lenient_prologue (CORE_ADDR
, CORE_ADDR
);
113 static void reinit_frame_cache_sfunc (char *, int, struct cmd_list_element
*);
115 static CORE_ADDR
after_prologue (CORE_ADDR pc
,
116 alpha_extra_func_info_t proc_desc
);
118 static int alpha_in_prologue (CORE_ADDR pc
,
119 alpha_extra_func_info_t proc_desc
);
121 static int alpha_about_to_return (CORE_ADDR pc
);
123 void _initialize_alpha_tdep (void);
125 /* Heuristic_proc_start may hunt through the text section for a long
126 time across a 2400 baud serial line. Allows the user to limit this
128 static unsigned int heuristic_fence_post
= 0;
130 /* Layout of a stack frame on the alpha:
133 pdr members: | 7th ... nth arg, |
134 | `pushed' by caller. |
136 ----------------|-------------------------------|<-- old_sp == vfp
139 | |localoff | Copies of 1st .. 6th |
140 | | | | | argument if necessary. |
142 | | | --- |-------------------------------|<-- FRAME_LOCALS_ADDRESS
144 | | | | Locals and temporaries. |
146 | | | |-------------------------------|
148 |-fregoffset | Saved float registers. |
154 | | -------|-------------------------------|
156 | | | Saved registers. |
163 | ----------|-------------------------------|
165 frameoffset | Argument build area, gets |
166 | | 7th ... nth arg for any |
167 | | called procedure. |
169 -------------|-------------------------------|<-- sp
174 #define PROC_LOW_ADDR(proc) ((proc)->pdr.adr) /* least address */
175 /* These next two fields are kind of being hijacked. I wonder if
176 iline is too small for the values it needs to hold, if GDB is
177 running on a 32-bit host. */
178 #define PROC_HIGH_ADDR(proc) ((proc)->pdr.iline) /* upper address bound */
179 #define PROC_DUMMY_FRAME(proc) ((proc)->pdr.cbLineOffset) /*CALL_DUMMY frame */
180 #define PROC_FRAME_OFFSET(proc) ((proc)->pdr.frameoffset)
181 #define PROC_FRAME_REG(proc) ((proc)->pdr.framereg)
182 #define PROC_REG_MASK(proc) ((proc)->pdr.regmask)
183 #define PROC_FREG_MASK(proc) ((proc)->pdr.fregmask)
184 #define PROC_REG_OFFSET(proc) ((proc)->pdr.regoffset)
185 #define PROC_FREG_OFFSET(proc) ((proc)->pdr.fregoffset)
186 #define PROC_PC_REG(proc) ((proc)->pdr.pcreg)
187 #define PROC_LOCALOFF(proc) ((proc)->pdr.localoff)
188 #define PROC_SYMBOL(proc) (*(struct symbol**)&(proc)->pdr.isym)
189 #define _PROC_MAGIC_ 0x0F0F0F0F
190 #define PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym == _PROC_MAGIC_)
191 #define SET_PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym = _PROC_MAGIC_)
193 struct linked_proc_info
195 struct alpha_extra_func_info info
;
196 struct linked_proc_info
*next
;
198 *linked_proc_desc_table
= NULL
;
201 alpha_frame_past_sigtramp_frame (struct frame_info
*frame
, CORE_ADDR pc
)
203 struct gdbarch_tdep
*tdep
= gdbarch_tdep (current_gdbarch
);
205 if (tdep
->skip_sigtramp_frame
!= NULL
)
206 return (tdep
->skip_sigtramp_frame (frame
, pc
));
212 alpha_dynamic_sigtramp_offset (CORE_ADDR pc
)
214 struct gdbarch_tdep
*tdep
= gdbarch_tdep (current_gdbarch
);
216 /* Must be provided by OS/ABI variant code if supported. */
217 if (tdep
->dynamic_sigtramp_offset
!= NULL
)
218 return (tdep
->dynamic_sigtramp_offset (pc
));
223 #define ALPHA_PROC_SIGTRAMP_MAGIC 0x0e0f0f0f
225 /* Return TRUE if the procedure descriptor PROC is a procedure
226 descriptor that refers to a dynamically generated signal
227 trampoline routine. */
229 alpha_proc_desc_is_dyn_sigtramp (struct alpha_extra_func_info
*proc
)
231 struct gdbarch_tdep
*tdep
= gdbarch_tdep (current_gdbarch
);
233 if (tdep
->dynamic_sigtramp_offset
!= NULL
)
234 return (proc
->pdr
.isym
== ALPHA_PROC_SIGTRAMP_MAGIC
);
240 alpha_set_proc_desc_is_dyn_sigtramp (struct alpha_extra_func_info
*proc
)
242 struct gdbarch_tdep
*tdep
= gdbarch_tdep (current_gdbarch
);
244 if (tdep
->dynamic_sigtramp_offset
!= NULL
)
245 proc
->pdr
.isym
= ALPHA_PROC_SIGTRAMP_MAGIC
;
248 /* Dynamically create a signal-handler caller procedure descriptor for
249 the signal-handler return code starting at address LOW_ADDR. The
250 descriptor is added to the linked_proc_desc_table. */
252 static alpha_extra_func_info_t
253 push_sigtramp_desc (CORE_ADDR low_addr
)
255 struct linked_proc_info
*link
;
256 alpha_extra_func_info_t proc_desc
;
258 link
= (struct linked_proc_info
*)
259 xmalloc (sizeof (struct linked_proc_info
));
260 link
->next
= linked_proc_desc_table
;
261 linked_proc_desc_table
= link
;
263 proc_desc
= &link
->info
;
265 proc_desc
->numargs
= 0;
266 PROC_LOW_ADDR (proc_desc
) = low_addr
;
267 PROC_HIGH_ADDR (proc_desc
) = low_addr
+ 3 * 4;
268 PROC_DUMMY_FRAME (proc_desc
) = 0;
269 PROC_FRAME_OFFSET (proc_desc
) = 0x298; /* sizeof(struct sigcontext_struct) */
270 PROC_FRAME_REG (proc_desc
) = SP_REGNUM
;
271 PROC_REG_MASK (proc_desc
) = 0xffff;
272 PROC_FREG_MASK (proc_desc
) = 0xffff;
273 PROC_PC_REG (proc_desc
) = 26;
274 PROC_LOCALOFF (proc_desc
) = 0;
275 alpha_set_proc_desc_is_dyn_sigtramp (proc_desc
);
281 alpha_register_name (int regno
)
283 static char *register_names
[] =
285 "v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
286 "t7", "s0", "s1", "s2", "s3", "s4", "s5", "fp",
287 "a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9",
288 "t10", "t11", "ra", "t12", "at", "gp", "sp", "zero",
289 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
290 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
291 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
292 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "fpcr",
298 if (regno
>= (sizeof(register_names
) / sizeof(*register_names
)))
300 return (register_names
[regno
]);
304 alpha_cannot_fetch_register (int regno
)
306 return (regno
== FP_REGNUM
|| regno
== ALPHA_ZERO_REGNUM
);
310 alpha_cannot_store_register (int regno
)
312 return (regno
== FP_REGNUM
|| regno
== ALPHA_ZERO_REGNUM
);
316 alpha_register_convertible (int regno
)
318 return (regno
>= FP0_REGNUM
&& regno
<= FP0_REGNUM
+ 31);
322 alpha_register_virtual_type (int regno
)
324 return ((regno
>= FP0_REGNUM
&& regno
< (FP0_REGNUM
+31))
325 ? builtin_type_double
: builtin_type_long
);
329 alpha_register_byte (int regno
)
335 alpha_register_raw_size (int regno
)
341 alpha_register_virtual_size (int regno
)
347 /* Guaranteed to set frame->saved_regs to some values (it never leaves it
351 alpha_find_saved_regs (struct frame_info
*frame
)
354 CORE_ADDR reg_position
;
356 alpha_extra_func_info_t proc_desc
;
359 frame_saved_regs_zalloc (frame
);
361 /* If it is the frame for __sigtramp, the saved registers are located
362 in a sigcontext structure somewhere on the stack. __sigtramp
363 passes a pointer to the sigcontext structure on the stack.
364 If the stack layout for __sigtramp changes, or if sigcontext offsets
365 change, we might have to update this code. */
366 #ifndef SIGFRAME_PC_OFF
367 #define SIGFRAME_PC_OFF (2 * 8)
368 #define SIGFRAME_REGSAVE_OFF (4 * 8)
369 #define SIGFRAME_FPREGSAVE_OFF (SIGFRAME_REGSAVE_OFF + 32 * 8 + 8)
371 if (frame
->signal_handler_caller
)
373 CORE_ADDR sigcontext_addr
;
375 sigcontext_addr
= SIGCONTEXT_ADDR (frame
);
376 for (ireg
= 0; ireg
< 32; ireg
++)
378 reg_position
= sigcontext_addr
+ SIGFRAME_REGSAVE_OFF
+ ireg
* 8;
379 frame
->saved_regs
[ireg
] = reg_position
;
381 for (ireg
= 0; ireg
< 32; ireg
++)
383 reg_position
= sigcontext_addr
+ SIGFRAME_FPREGSAVE_OFF
+ ireg
* 8;
384 frame
->saved_regs
[FP0_REGNUM
+ ireg
] = reg_position
;
386 frame
->saved_regs
[PC_REGNUM
] = sigcontext_addr
+ SIGFRAME_PC_OFF
;
390 proc_desc
= frame
->extra_info
->proc_desc
;
391 if (proc_desc
== NULL
)
392 /* I'm not sure how/whether this can happen. Normally when we can't
393 find a proc_desc, we "synthesize" one using heuristic_proc_desc
394 and set the saved_regs right away. */
397 /* Fill in the offsets for the registers which gen_mask says
400 reg_position
= frame
->frame
+ PROC_REG_OFFSET (proc_desc
);
401 mask
= PROC_REG_MASK (proc_desc
);
403 returnreg
= PROC_PC_REG (proc_desc
);
405 /* Note that RA is always saved first, regardless of its actual
407 if (mask
& (1 << returnreg
))
409 frame
->saved_regs
[returnreg
] = reg_position
;
411 mask
&= ~(1 << returnreg
); /* Clear bit for RA so we
412 don't save again later. */
415 for (ireg
= 0; ireg
<= 31; ++ireg
)
416 if (mask
& (1 << ireg
))
418 frame
->saved_regs
[ireg
] = reg_position
;
422 /* Fill in the offsets for the registers which float_mask says
425 reg_position
= frame
->frame
+ PROC_FREG_OFFSET (proc_desc
);
426 mask
= PROC_FREG_MASK (proc_desc
);
428 for (ireg
= 0; ireg
<= 31; ++ireg
)
429 if (mask
& (1 << ireg
))
431 frame
->saved_regs
[FP0_REGNUM
+ ireg
] = reg_position
;
435 frame
->saved_regs
[PC_REGNUM
] = frame
->saved_regs
[returnreg
];
439 alpha_frame_init_saved_regs (struct frame_info
*fi
)
441 if (fi
->saved_regs
== NULL
)
442 alpha_find_saved_regs (fi
);
443 fi
->saved_regs
[SP_REGNUM
] = fi
->frame
;
447 alpha_init_frame_pc_first (int fromleaf
, struct frame_info
*prev
)
449 prev
->pc
= (fromleaf
? SAVED_PC_AFTER_CALL (prev
->next
) :
450 prev
->next
? FRAME_SAVED_PC (prev
->next
) : read_pc ());
454 read_next_frame_reg (struct frame_info
*fi
, int regno
)
456 for (; fi
; fi
= fi
->next
)
458 /* We have to get the saved sp from the sigcontext
459 if it is a signal handler frame. */
460 if (regno
== SP_REGNUM
&& !fi
->signal_handler_caller
)
464 if (fi
->saved_regs
== NULL
)
465 alpha_find_saved_regs (fi
);
466 if (fi
->saved_regs
[regno
])
467 return read_memory_integer (fi
->saved_regs
[regno
], 8);
470 return read_register (regno
);
474 alpha_frame_saved_pc (struct frame_info
*frame
)
476 alpha_extra_func_info_t proc_desc
= frame
->extra_info
->proc_desc
;
477 /* We have to get the saved pc from the sigcontext
478 if it is a signal handler frame. */
479 int pcreg
= frame
->signal_handler_caller
? PC_REGNUM
480 : frame
->extra_info
->pc_reg
;
482 if (proc_desc
&& PROC_DESC_IS_DUMMY (proc_desc
))
483 return read_memory_integer (frame
->frame
- 8, 8);
485 return read_next_frame_reg (frame
, pcreg
);
489 alpha_get_saved_register (char *raw_buffer
,
492 struct frame_info
*frame
,
494 enum lval_type
*lval
)
498 if (!target_has_registers
)
499 error ("No registers.");
501 /* Normal systems don't optimize out things with register numbers. */
502 if (optimized
!= NULL
)
504 addr
= find_saved_register (frame
, regnum
);
509 if (regnum
== SP_REGNUM
)
511 if (raw_buffer
!= NULL
)
513 /* Put it back in target format. */
514 store_address (raw_buffer
, REGISTER_RAW_SIZE (regnum
),
521 if (raw_buffer
!= NULL
)
522 target_read_memory (addr
, raw_buffer
, REGISTER_RAW_SIZE (regnum
));
527 *lval
= lval_register
;
528 addr
= REGISTER_BYTE (regnum
);
529 if (raw_buffer
!= NULL
)
530 read_register_gen (regnum
, raw_buffer
);
537 alpha_saved_pc_after_call (struct frame_info
*frame
)
539 CORE_ADDR pc
= frame
->pc
;
541 alpha_extra_func_info_t proc_desc
;
544 /* Skip over shared library trampoline if necessary. */
545 tmp
= SKIP_TRAMPOLINE_CODE (pc
);
549 proc_desc
= find_proc_desc (pc
, frame
->next
);
550 pcreg
= proc_desc
? PROC_PC_REG (proc_desc
) : ALPHA_RA_REGNUM
;
552 if (frame
->signal_handler_caller
)
553 return alpha_frame_saved_pc (frame
);
555 return read_register (pcreg
);
559 static struct alpha_extra_func_info temp_proc_desc
;
560 static CORE_ADDR temp_saved_regs
[ALPHA_NUM_REGS
];
562 /* Nonzero if instruction at PC is a return instruction. "ret
563 $zero,($ra),1" on alpha. */
566 alpha_about_to_return (CORE_ADDR pc
)
568 return read_memory_integer (pc
, 4) == 0x6bfa8001;
573 /* This fencepost looks highly suspicious to me. Removing it also
574 seems suspicious as it could affect remote debugging across serial
578 heuristic_proc_start (CORE_ADDR pc
)
580 struct gdbarch_tdep
*tdep
= gdbarch_tdep (current_gdbarch
);
581 CORE_ADDR start_pc
= pc
;
582 CORE_ADDR fence
= start_pc
- heuristic_fence_post
;
587 if (heuristic_fence_post
== UINT_MAX
588 || fence
< tdep
->vm_min_address
)
589 fence
= tdep
->vm_min_address
;
591 /* search back for previous return */
592 for (start_pc
-= 4;; start_pc
-= 4)
593 if (start_pc
< fence
)
595 /* It's not clear to me why we reach this point when
596 stop_soon_quietly, but with this test, at least we
597 don't print out warnings for every child forked (eg, on
598 decstation). 22apr93 rich@cygnus.com. */
599 if (!stop_soon_quietly
)
601 static int blurb_printed
= 0;
603 if (fence
== tdep
->vm_min_address
)
604 warning ("Hit beginning of text section without finding");
606 warning ("Hit heuristic-fence-post without finding");
608 warning ("enclosing function for address 0x%s", paddr_nz (pc
));
612 This warning occurs if you are debugging a function without any symbols\n\
613 (for example, in a stripped executable). In that case, you may wish to\n\
614 increase the size of the search with the `set heuristic-fence-post' command.\n\
616 Otherwise, you told GDB there was a function where there isn't one, or\n\
617 (more likely) you have encountered a bug in GDB.\n");
624 else if (alpha_about_to_return (start_pc
))
627 start_pc
+= 4; /* skip return */
631 static alpha_extra_func_info_t
632 heuristic_proc_desc (CORE_ADDR start_pc
, CORE_ADDR limit_pc
,
633 struct frame_info
*next_frame
)
635 CORE_ADDR sp
= read_next_frame_reg (next_frame
, SP_REGNUM
);
638 int has_frame_reg
= 0;
639 unsigned long reg_mask
= 0;
644 memset (&temp_proc_desc
, '\0', sizeof (temp_proc_desc
));
645 memset (&temp_saved_regs
, '\0', SIZEOF_FRAME_SAVED_REGS
);
646 PROC_LOW_ADDR (&temp_proc_desc
) = start_pc
;
648 if (start_pc
+ 200 < limit_pc
)
649 limit_pc
= start_pc
+ 200;
651 for (cur_pc
= start_pc
; cur_pc
< limit_pc
; cur_pc
+= 4)
657 status
= read_memory_nobpt (cur_pc
, buf
, 4);
659 memory_error (status
, cur_pc
);
660 word
= extract_unsigned_integer (buf
, 4);
662 if ((word
& 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */
665 frame_size
+= (-word
) & 0xffff;
667 /* Exit loop if a positive stack adjustment is found, which
668 usually means that the stack cleanup code in the function
669 epilogue is reached. */
672 else if ((word
& 0xfc1f0000) == 0xb41e0000 /* stq reg,n($sp) */
673 && (word
& 0xffff0000) != 0xb7fe0000) /* reg != $zero */
675 int reg
= (word
& 0x03e00000) >> 21;
676 reg_mask
|= 1 << reg
;
677 temp_saved_regs
[reg
] = sp
+ (short) word
;
679 /* Starting with OSF/1-3.2C, the system libraries are shipped
680 without local symbols, but they still contain procedure
681 descriptors without a symbol reference. GDB is currently
682 unable to find these procedure descriptors and uses
683 heuristic_proc_desc instead.
684 As some low level compiler support routines (__div*, __add*)
685 use a non-standard return address register, we have to
686 add some heuristics to determine the return address register,
687 or stepping over these routines will fail.
688 Usually the return address register is the first register
689 saved on the stack, but assembler optimization might
690 rearrange the register saves.
691 So we recognize only a few registers (t7, t9, ra) within
692 the procedure prologue as valid return address registers.
693 If we encounter a return instruction, we extract the
694 the return address register from it.
696 FIXME: Rewriting GDB to access the procedure descriptors,
697 e.g. via the minimal symbol table, might obviate this hack. */
699 && cur_pc
< (start_pc
+ 80)
700 && (reg
== ALPHA_T7_REGNUM
|| reg
== ALPHA_T9_REGNUM
701 || reg
== ALPHA_RA_REGNUM
))
704 else if ((word
& 0xffe0ffff) == 0x6be08001) /* ret zero,reg,1 */
705 pcreg
= (word
>> 16) & 0x1f;
706 else if (word
== 0x47de040f) /* bis sp,sp fp */
711 /* If we haven't found a valid return address register yet,
712 keep searching in the procedure prologue. */
713 while (cur_pc
< (limit_pc
+ 80) && cur_pc
< (start_pc
+ 80))
718 if (read_memory_nobpt (cur_pc
, buf
, 4))
721 word
= extract_unsigned_integer (buf
, 4);
723 if ((word
& 0xfc1f0000) == 0xb41e0000 /* stq reg,n($sp) */
724 && (word
& 0xffff0000) != 0xb7fe0000) /* reg != $zero */
726 int reg
= (word
& 0x03e00000) >> 21;
727 if (reg
== ALPHA_T7_REGNUM
|| reg
== ALPHA_T9_REGNUM
728 || reg
== ALPHA_RA_REGNUM
)
734 else if ((word
& 0xffe0ffff) == 0x6be08001) /* ret zero,reg,1 */
736 pcreg
= (word
>> 16) & 0x1f;
743 PROC_FRAME_REG (&temp_proc_desc
) = ALPHA_GCC_FP_REGNUM
;
745 PROC_FRAME_REG (&temp_proc_desc
) = SP_REGNUM
;
746 PROC_FRAME_OFFSET (&temp_proc_desc
) = frame_size
;
747 PROC_REG_MASK (&temp_proc_desc
) = reg_mask
;
748 PROC_PC_REG (&temp_proc_desc
) = (pcreg
== -1) ? ALPHA_RA_REGNUM
: pcreg
;
749 PROC_LOCALOFF (&temp_proc_desc
) = 0; /* XXX - bogus */
750 return &temp_proc_desc
;
753 /* This returns the PC of the first inst after the prologue. If we can't
754 find the prologue, then return 0. */
757 after_prologue (CORE_ADDR pc
, alpha_extra_func_info_t proc_desc
)
759 struct symtab_and_line sal
;
760 CORE_ADDR func_addr
, func_end
;
763 proc_desc
= find_proc_desc (pc
, NULL
);
767 if (alpha_proc_desc_is_dyn_sigtramp (proc_desc
))
768 return PROC_LOW_ADDR (proc_desc
); /* "prologue" is in kernel */
770 /* If function is frameless, then we need to do it the hard way. I
771 strongly suspect that frameless always means prologueless... */
772 if (PROC_FRAME_REG (proc_desc
) == SP_REGNUM
773 && PROC_FRAME_OFFSET (proc_desc
) == 0)
777 if (!find_pc_partial_function (pc
, NULL
, &func_addr
, &func_end
))
778 return 0; /* Unknown */
780 sal
= find_pc_line (func_addr
, 0);
782 if (sal
.end
< func_end
)
785 /* The line after the prologue is after the end of the function. In this
786 case, tell the caller to find the prologue the hard way. */
791 /* Return non-zero if we *might* be in a function prologue. Return zero if we
792 are definitively *not* in a function prologue. */
795 alpha_in_prologue (CORE_ADDR pc
, alpha_extra_func_info_t proc_desc
)
797 CORE_ADDR after_prologue_pc
;
799 after_prologue_pc
= after_prologue (pc
, proc_desc
);
801 if (after_prologue_pc
== 0
802 || pc
< after_prologue_pc
)
808 static alpha_extra_func_info_t
809 find_proc_desc (CORE_ADDR pc
, struct frame_info
*next_frame
)
811 alpha_extra_func_info_t proc_desc
;
816 /* Try to get the proc_desc from the linked call dummy proc_descs
817 if the pc is in the call dummy.
818 This is hairy. In the case of nested dummy calls we have to find the
819 right proc_desc, but we might not yet know the frame for the dummy
820 as it will be contained in the proc_desc we are searching for.
821 So we have to find the proc_desc whose frame is closest to the current
824 if (PC_IN_CALL_DUMMY (pc
, 0, 0))
826 struct linked_proc_info
*link
;
827 CORE_ADDR sp
= read_next_frame_reg (next_frame
, SP_REGNUM
);
828 alpha_extra_func_info_t found_proc_desc
= NULL
;
829 long min_distance
= LONG_MAX
;
831 for (link
= linked_proc_desc_table
; link
; link
= link
->next
)
833 long distance
= (CORE_ADDR
) PROC_DUMMY_FRAME (&link
->info
) - sp
;
834 if (distance
> 0 && distance
< min_distance
)
836 min_distance
= distance
;
837 found_proc_desc
= &link
->info
;
840 if (found_proc_desc
!= NULL
)
841 return found_proc_desc
;
844 b
= block_for_pc (pc
);
846 find_pc_partial_function (pc
, NULL
, &startaddr
, NULL
);
851 if (startaddr
> BLOCK_START (b
))
852 /* This is the "pathological" case referred to in a comment in
853 print_frame_info. It might be better to move this check into
857 sym
= lookup_symbol (MIPS_EFI_SYMBOL_NAME
, b
, LABEL_NAMESPACE
,
861 /* If we never found a PDR for this function in symbol reading, then
862 examine prologues to find the information. */
863 if (sym
&& ((mips_extra_func_info_t
) SYMBOL_VALUE (sym
))->pdr
.framereg
== -1)
868 /* IF this is the topmost frame AND
869 * (this proc does not have debugging information OR
870 * the PC is in the procedure prologue)
871 * THEN create a "heuristic" proc_desc (by analyzing
872 * the actual code) to replace the "official" proc_desc.
874 proc_desc
= (alpha_extra_func_info_t
) SYMBOL_VALUE (sym
);
875 if (next_frame
== NULL
)
877 if (PROC_DESC_IS_DUMMY (proc_desc
) || alpha_in_prologue (pc
, proc_desc
))
879 alpha_extra_func_info_t found_heuristic
=
880 heuristic_proc_desc (PROC_LOW_ADDR (proc_desc
),
884 PROC_LOCALOFF (found_heuristic
) =
885 PROC_LOCALOFF (proc_desc
);
886 PROC_PC_REG (found_heuristic
) = PROC_PC_REG (proc_desc
);
887 proc_desc
= found_heuristic
;
896 /* Is linked_proc_desc_table really necessary? It only seems to be used
897 by procedure call dummys. However, the procedures being called ought
898 to have their own proc_descs, and even if they don't,
899 heuristic_proc_desc knows how to create them! */
901 register struct linked_proc_info
*link
;
902 for (link
= linked_proc_desc_table
; link
; link
= link
->next
)
903 if (PROC_LOW_ADDR (&link
->info
) <= pc
904 && PROC_HIGH_ADDR (&link
->info
) > pc
)
907 /* If PC is inside a dynamically generated sigtramp handler,
908 create and push a procedure descriptor for that code: */
909 offset
= alpha_dynamic_sigtramp_offset (pc
);
911 return push_sigtramp_desc (pc
- offset
);
913 /* If heuristic_fence_post is non-zero, determine the procedure
914 start address by examining the instructions.
915 This allows us to find the start address of static functions which
916 have no symbolic information, as startaddr would have been set to
917 the preceding global function start address by the
918 find_pc_partial_function call above. */
919 if (startaddr
== 0 || heuristic_fence_post
!= 0)
920 startaddr
= heuristic_proc_start (pc
);
923 heuristic_proc_desc (startaddr
, pc
, next_frame
);
928 alpha_extra_func_info_t cached_proc_desc
;
931 alpha_frame_chain (struct frame_info
*frame
)
933 alpha_extra_func_info_t proc_desc
;
934 CORE_ADDR saved_pc
= FRAME_SAVED_PC (frame
);
936 if (saved_pc
== 0 || inside_entry_file (saved_pc
))
939 proc_desc
= find_proc_desc (saved_pc
, frame
);
943 cached_proc_desc
= proc_desc
;
945 /* Fetch the frame pointer for a dummy frame from the procedure
947 if (PROC_DESC_IS_DUMMY (proc_desc
))
948 return (CORE_ADDR
) PROC_DUMMY_FRAME (proc_desc
);
950 /* If no frame pointer and frame size is zero, we must be at end
951 of stack (or otherwise hosed). If we don't check frame size,
952 we loop forever if we see a zero size frame. */
953 if (PROC_FRAME_REG (proc_desc
) == SP_REGNUM
954 && PROC_FRAME_OFFSET (proc_desc
) == 0
955 /* The previous frame from a sigtramp frame might be frameless
956 and have frame size zero. */
957 && !frame
->signal_handler_caller
)
958 return alpha_frame_past_sigtramp_frame (frame
, saved_pc
);
960 return read_next_frame_reg (frame
, PROC_FRAME_REG (proc_desc
))
961 + PROC_FRAME_OFFSET (proc_desc
);
965 alpha_print_extra_frame_info (struct frame_info
*fi
)
969 && fi
->extra_info
->proc_desc
970 && fi
->extra_info
->proc_desc
->pdr
.framereg
< NUM_REGS
)
971 printf_filtered (" frame pointer is at %s+%s\n",
972 REGISTER_NAME (fi
->extra_info
->proc_desc
->pdr
.framereg
),
973 paddr_d (fi
->extra_info
->proc_desc
->pdr
.frameoffset
));
977 alpha_init_extra_frame_info (int fromleaf
, struct frame_info
*frame
)
979 /* Use proc_desc calculated in frame_chain */
980 alpha_extra_func_info_t proc_desc
=
981 frame
->next
? cached_proc_desc
: find_proc_desc (frame
->pc
, frame
->next
);
983 frame
->extra_info
= (struct frame_extra_info
*)
984 frame_obstack_alloc (sizeof (struct frame_extra_info
));
986 frame
->saved_regs
= NULL
;
987 frame
->extra_info
->localoff
= 0;
988 frame
->extra_info
->pc_reg
= ALPHA_RA_REGNUM
;
989 frame
->extra_info
->proc_desc
= proc_desc
== &temp_proc_desc
? 0 : proc_desc
;
992 /* Get the locals offset and the saved pc register from the
993 procedure descriptor, they are valid even if we are in the
994 middle of the prologue. */
995 frame
->extra_info
->localoff
= PROC_LOCALOFF (proc_desc
);
996 frame
->extra_info
->pc_reg
= PROC_PC_REG (proc_desc
);
998 /* Fixup frame-pointer - only needed for top frame */
1000 /* Fetch the frame pointer for a dummy frame from the procedure
1002 if (PROC_DESC_IS_DUMMY (proc_desc
))
1003 frame
->frame
= (CORE_ADDR
) PROC_DUMMY_FRAME (proc_desc
);
1005 /* This may not be quite right, if proc has a real frame register.
1006 Get the value of the frame relative sp, procedure might have been
1007 interrupted by a signal at it's very start. */
1008 else if (frame
->pc
== PROC_LOW_ADDR (proc_desc
)
1009 && !alpha_proc_desc_is_dyn_sigtramp (proc_desc
))
1010 frame
->frame
= read_next_frame_reg (frame
->next
, SP_REGNUM
);
1012 frame
->frame
= read_next_frame_reg (frame
->next
, PROC_FRAME_REG (proc_desc
))
1013 + PROC_FRAME_OFFSET (proc_desc
);
1015 if (proc_desc
== &temp_proc_desc
)
1019 /* Do not set the saved registers for a sigtramp frame,
1020 alpha_find_saved_registers will do that for us.
1021 We can't use frame->signal_handler_caller, it is not yet set. */
1022 find_pc_partial_function (frame
->pc
, &name
,
1023 (CORE_ADDR
*) NULL
, (CORE_ADDR
*) NULL
);
1024 if (!PC_IN_SIGTRAMP (frame
->pc
, name
))
1026 frame
->saved_regs
= (CORE_ADDR
*)
1027 frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS
);
1028 memcpy (frame
->saved_regs
, temp_saved_regs
,
1029 SIZEOF_FRAME_SAVED_REGS
);
1030 frame
->saved_regs
[PC_REGNUM
]
1031 = frame
->saved_regs
[ALPHA_RA_REGNUM
];
1038 alpha_frame_locals_address (struct frame_info
*fi
)
1040 return (fi
->frame
- fi
->extra_info
->localoff
);
1044 alpha_frame_args_address (struct frame_info
*fi
)
1046 return (fi
->frame
- (ALPHA_NUM_ARG_REGS
* 8));
1049 /* ALPHA stack frames are almost impenetrable. When execution stops,
1050 we basically have to look at symbol information for the function
1051 that we stopped in, which tells us *which* register (if any) is
1052 the base of the frame pointer, and what offset from that register
1053 the frame itself is at.
1055 This presents a problem when trying to examine a stack in memory
1056 (that isn't executing at the moment), using the "frame" command. We
1057 don't have a PC, nor do we have any registers except SP.
1059 This routine takes two arguments, SP and PC, and tries to make the
1060 cached frames look as if these two arguments defined a frame on the
1061 cache. This allows the rest of info frame to extract the important
1062 arguments without difficulty. */
1065 alpha_setup_arbitrary_frame (int argc
, CORE_ADDR
*argv
)
1068 error ("ALPHA frame specifications require two arguments: sp and pc");
1070 return create_new_frame (argv
[0], argv
[1]);
1073 /* The alpha passes the first six arguments in the registers, the rest on
1074 the stack. The register arguments are eventually transferred to the
1075 argument transfer area immediately below the stack by the called function
1076 anyway. So we `push' at least six arguments on the stack, `reload' the
1077 argument registers and then adjust the stack pointer to point past the
1078 sixth argument. This algorithm simplifies the passing of a large struct
1079 which extends from the registers to the stack.
1080 If the called function is returning a structure, the address of the
1081 structure to be returned is passed as a hidden first argument. */
1084 alpha_push_arguments (int nargs
, struct value
**args
, CORE_ADDR sp
,
1085 int struct_return
, CORE_ADDR struct_addr
)
1088 int accumulate_size
= struct_return
? 8 : 0;
1089 int arg_regs_size
= ALPHA_NUM_ARG_REGS
* 8;
1096 struct alpha_arg
*alpha_args
=
1097 (struct alpha_arg
*) alloca (nargs
* sizeof (struct alpha_arg
));
1098 register struct alpha_arg
*m_arg
;
1099 char raw_buffer
[sizeof (CORE_ADDR
)];
1100 int required_arg_regs
;
1102 for (i
= 0, m_arg
= alpha_args
; i
< nargs
; i
++, m_arg
++)
1104 struct value
*arg
= args
[i
];
1105 struct type
*arg_type
= check_typedef (VALUE_TYPE (arg
));
1106 /* Cast argument to long if necessary as the compiler does it too. */
1107 switch (TYPE_CODE (arg_type
))
1110 case TYPE_CODE_BOOL
:
1111 case TYPE_CODE_CHAR
:
1112 case TYPE_CODE_RANGE
:
1113 case TYPE_CODE_ENUM
:
1114 if (TYPE_LENGTH (arg_type
) < TYPE_LENGTH (builtin_type_long
))
1116 arg_type
= builtin_type_long
;
1117 arg
= value_cast (arg_type
, arg
);
1123 m_arg
->len
= TYPE_LENGTH (arg_type
);
1124 m_arg
->offset
= accumulate_size
;
1125 accumulate_size
= (accumulate_size
+ m_arg
->len
+ 7) & ~7;
1126 m_arg
->contents
= VALUE_CONTENTS (arg
);
1129 /* Determine required argument register loads, loading an argument register
1130 is expensive as it uses three ptrace calls. */
1131 required_arg_regs
= accumulate_size
/ 8;
1132 if (required_arg_regs
> ALPHA_NUM_ARG_REGS
)
1133 required_arg_regs
= ALPHA_NUM_ARG_REGS
;
1135 /* Make room for the arguments on the stack. */
1136 if (accumulate_size
< arg_regs_size
)
1137 accumulate_size
= arg_regs_size
;
1138 sp
-= accumulate_size
;
1140 /* Keep sp aligned to a multiple of 16 as the compiler does it too. */
1143 /* `Push' arguments on the stack. */
1144 for (i
= nargs
; m_arg
--, --i
>= 0;)
1145 write_memory (sp
+ m_arg
->offset
, m_arg
->contents
, m_arg
->len
);
1148 store_address (raw_buffer
, sizeof (CORE_ADDR
), struct_addr
);
1149 write_memory (sp
, raw_buffer
, sizeof (CORE_ADDR
));
1152 /* Load the argument registers. */
1153 for (i
= 0; i
< required_arg_regs
; i
++)
1157 val
= read_memory_integer (sp
+ i
* 8, 8);
1158 write_register (ALPHA_A0_REGNUM
+ i
, val
);
1159 write_register (ALPHA_FPA0_REGNUM
+ i
, val
);
1162 return sp
+ arg_regs_size
;
1166 alpha_push_dummy_frame (void)
1169 struct linked_proc_info
*link
;
1170 alpha_extra_func_info_t proc_desc
;
1171 CORE_ADDR sp
= read_register (SP_REGNUM
);
1172 CORE_ADDR save_address
;
1173 char raw_buffer
[ALPHA_MAX_REGISTER_RAW_SIZE
];
1176 link
= (struct linked_proc_info
*) xmalloc (sizeof (struct linked_proc_info
));
1177 link
->next
= linked_proc_desc_table
;
1178 linked_proc_desc_table
= link
;
1180 proc_desc
= &link
->info
;
1183 * The registers we must save are all those not preserved across
1185 * In addition, we must save the PC and RA.
1187 * Dummy frame layout:
1197 * Parameter build area
1201 /* MASK(i,j) == (1<<i) + (1<<(i+1)) + ... + (1<<j)). Assume i<=j<31. */
1202 #define MASK(i,j) ((((LONGEST)1 << ((j)+1)) - 1) ^ (((LONGEST)1 << (i)) - 1))
1203 #define GEN_REG_SAVE_MASK (MASK(0,8) | MASK(16,29))
1204 #define GEN_REG_SAVE_COUNT 24
1205 #define FLOAT_REG_SAVE_MASK (MASK(0,1) | MASK(10,30))
1206 #define FLOAT_REG_SAVE_COUNT 23
1207 /* The special register is the PC as we have no bit for it in the save masks.
1208 alpha_frame_saved_pc knows where the pc is saved in a dummy frame. */
1209 #define SPECIAL_REG_SAVE_COUNT 1
1211 PROC_REG_MASK (proc_desc
) = GEN_REG_SAVE_MASK
;
1212 PROC_FREG_MASK (proc_desc
) = FLOAT_REG_SAVE_MASK
;
1213 /* PROC_REG_OFFSET is the offset from the dummy frame to the saved RA,
1214 but keep SP aligned to a multiple of 16. */
1215 PROC_REG_OFFSET (proc_desc
) =
1216 -((8 * (SPECIAL_REG_SAVE_COUNT
1217 + GEN_REG_SAVE_COUNT
1218 + FLOAT_REG_SAVE_COUNT
)
1220 PROC_FREG_OFFSET (proc_desc
) =
1221 PROC_REG_OFFSET (proc_desc
) + 8 * GEN_REG_SAVE_COUNT
;
1223 /* Save general registers.
1224 The return address register is the first saved register, all other
1225 registers follow in ascending order.
1226 The PC is saved immediately below the SP. */
1227 save_address
= sp
+ PROC_REG_OFFSET (proc_desc
);
1228 store_address (raw_buffer
, 8, read_register (ALPHA_RA_REGNUM
));
1229 write_memory (save_address
, raw_buffer
, 8);
1231 mask
= PROC_REG_MASK (proc_desc
) & 0xffffffffL
;
1232 for (ireg
= 0; mask
; ireg
++, mask
>>= 1)
1235 if (ireg
== ALPHA_RA_REGNUM
)
1237 store_address (raw_buffer
, 8, read_register (ireg
));
1238 write_memory (save_address
, raw_buffer
, 8);
1242 store_address (raw_buffer
, 8, read_register (PC_REGNUM
));
1243 write_memory (sp
- 8, raw_buffer
, 8);
1245 /* Save floating point registers. */
1246 save_address
= sp
+ PROC_FREG_OFFSET (proc_desc
);
1247 mask
= PROC_FREG_MASK (proc_desc
) & 0xffffffffL
;
1248 for (ireg
= 0; mask
; ireg
++, mask
>>= 1)
1251 store_address (raw_buffer
, 8, read_register (ireg
+ FP0_REGNUM
));
1252 write_memory (save_address
, raw_buffer
, 8);
1256 /* Set and save the frame address for the dummy.
1257 This is tricky. The only registers that are suitable for a frame save
1258 are those that are preserved across procedure calls (s0-s6). But if
1259 a read system call is interrupted and then a dummy call is made
1260 (see testsuite/gdb.t17/interrupt.exp) the dummy call hangs till the read
1261 is satisfied. Then it returns with the s0-s6 registers set to the values
1262 on entry to the read system call and our dummy frame pointer would be
1263 destroyed. So we save the dummy frame in the proc_desc and handle the
1264 retrieval of the frame pointer of a dummy specifically. The frame register
1265 is set to the virtual frame (pseudo) register, it's value will always
1266 be read as zero and will help us to catch any errors in the dummy frame
1268 PROC_DUMMY_FRAME (proc_desc
) = sp
;
1269 PROC_FRAME_REG (proc_desc
) = FP_REGNUM
;
1270 PROC_FRAME_OFFSET (proc_desc
) = 0;
1271 sp
+= PROC_REG_OFFSET (proc_desc
);
1272 write_register (SP_REGNUM
, sp
);
1274 PROC_LOW_ADDR (proc_desc
) = CALL_DUMMY_ADDRESS ();
1275 PROC_HIGH_ADDR (proc_desc
) = PROC_LOW_ADDR (proc_desc
) + 4;
1277 SET_PROC_DESC_IS_DUMMY (proc_desc
);
1278 PROC_PC_REG (proc_desc
) = ALPHA_RA_REGNUM
;
1282 alpha_pop_frame (void)
1284 register int regnum
;
1285 struct frame_info
*frame
= get_current_frame ();
1286 CORE_ADDR new_sp
= frame
->frame
;
1288 alpha_extra_func_info_t proc_desc
= frame
->extra_info
->proc_desc
;
1290 /* we need proc_desc to know how to restore the registers;
1291 if it is NULL, construct (a temporary) one */
1292 if (proc_desc
== NULL
)
1293 proc_desc
= find_proc_desc (frame
->pc
, frame
->next
);
1295 /* Question: should we copy this proc_desc and save it in
1296 frame->proc_desc? If we do, who will free it?
1297 For now, we don't save a copy... */
1299 write_register (PC_REGNUM
, FRAME_SAVED_PC (frame
));
1300 if (frame
->saved_regs
== NULL
)
1301 alpha_find_saved_regs (frame
);
1304 for (regnum
= 32; --regnum
>= 0;)
1305 if (PROC_REG_MASK (proc_desc
) & (1 << regnum
))
1306 write_register (regnum
,
1307 read_memory_integer (frame
->saved_regs
[regnum
],
1309 for (regnum
= 32; --regnum
>= 0;)
1310 if (PROC_FREG_MASK (proc_desc
) & (1 << regnum
))
1311 write_register (regnum
+ FP0_REGNUM
,
1312 read_memory_integer (frame
->saved_regs
[regnum
+ FP0_REGNUM
], 8));
1314 write_register (SP_REGNUM
, new_sp
);
1315 flush_cached_frames ();
1317 if (proc_desc
&& (PROC_DESC_IS_DUMMY (proc_desc
)
1318 || alpha_proc_desc_is_dyn_sigtramp (proc_desc
)))
1320 struct linked_proc_info
*pi_ptr
, *prev_ptr
;
1322 for (pi_ptr
= linked_proc_desc_table
, prev_ptr
= NULL
;
1324 prev_ptr
= pi_ptr
, pi_ptr
= pi_ptr
->next
)
1326 if (&pi_ptr
->info
== proc_desc
)
1331 error ("Can't locate dummy extra frame info\n");
1333 if (prev_ptr
!= NULL
)
1334 prev_ptr
->next
= pi_ptr
->next
;
1336 linked_proc_desc_table
= pi_ptr
->next
;
1342 /* To skip prologues, I use this predicate. Returns either PC itself
1343 if the code at PC does not look like a function prologue; otherwise
1344 returns an address that (if we're lucky) follows the prologue. If
1345 LENIENT, then we must skip everything which is involved in setting
1346 up the frame (it's OK to skip more, just so long as we don't skip
1347 anything which might clobber the registers which are being saved.
1348 Currently we must not skip more on the alpha, but we might need the
1349 lenient stuff some day. */
1352 alpha_skip_prologue_internal (CORE_ADDR pc
, int lenient
)
1356 CORE_ADDR post_prologue_pc
;
1359 /* Silently return the unaltered pc upon memory errors.
1360 This could happen on OSF/1 if decode_line_1 tries to skip the
1361 prologue for quickstarted shared library functions when the
1362 shared library is not yet mapped in.
1363 Reading target memory is slow over serial lines, so we perform
1364 this check only if the target has shared libraries (which all
1365 Alpha targets do). */
1366 if (target_read_memory (pc
, buf
, 4))
1369 /* See if we can determine the end of the prologue via the symbol table.
1370 If so, then return either PC, or the PC after the prologue, whichever
1373 post_prologue_pc
= after_prologue (pc
, NULL
);
1375 if (post_prologue_pc
!= 0)
1376 return max (pc
, post_prologue_pc
);
1378 /* Can't determine prologue from the symbol table, need to examine
1381 /* Skip the typical prologue instructions. These are the stack adjustment
1382 instruction and the instructions that save registers on the stack
1383 or in the gcc frame. */
1384 for (offset
= 0; offset
< 100; offset
+= 4)
1388 status
= read_memory_nobpt (pc
+ offset
, buf
, 4);
1390 memory_error (status
, pc
+ offset
);
1391 inst
= extract_unsigned_integer (buf
, 4);
1393 /* The alpha has no delay slots. But let's keep the lenient stuff,
1394 we might need it for something else in the future. */
1398 if ((inst
& 0xffff0000) == 0x27bb0000) /* ldah $gp,n($t12) */
1400 if ((inst
& 0xffff0000) == 0x23bd0000) /* lda $gp,n($gp) */
1402 if ((inst
& 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */
1404 if ((inst
& 0xffe01fff) == 0x43c0153e) /* subq $sp,n,$sp */
1407 if ((inst
& 0xfc1f0000) == 0xb41e0000
1408 && (inst
& 0xffff0000) != 0xb7fe0000)
1409 continue; /* stq reg,n($sp) */
1411 if ((inst
& 0xfc1f0000) == 0x9c1e0000
1412 && (inst
& 0xffff0000) != 0x9ffe0000)
1413 continue; /* stt reg,n($sp) */
1415 if (inst
== 0x47de040f) /* bis sp,sp,fp */
1424 alpha_skip_prologue (CORE_ADDR addr
)
1426 return (alpha_skip_prologue_internal (addr
, 0));
1430 /* Is address PC in the prologue (loosely defined) for function at
1434 alpha_in_lenient_prologue (CORE_ADDR startaddr
, CORE_ADDR pc
)
1436 CORE_ADDR end_prologue
= alpha_skip_prologue_internal (startaddr
, 1);
1437 return pc
>= startaddr
&& pc
< end_prologue
;
1441 /* The alpha needs a conversion between register and memory format if
1442 the register is a floating point register and
1443 memory format is float, as the register format must be double
1445 memory format is an integer with 4 bytes or less, as the representation
1446 of integers in floating point registers is different. */
1448 alpha_register_convert_to_virtual (int regnum
, struct type
*valtype
,
1449 char *raw_buffer
, char *virtual_buffer
)
1451 if (TYPE_LENGTH (valtype
) >= REGISTER_RAW_SIZE (regnum
))
1453 memcpy (virtual_buffer
, raw_buffer
, REGISTER_VIRTUAL_SIZE (regnum
));
1457 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
)
1459 double d
= extract_floating (raw_buffer
, REGISTER_RAW_SIZE (regnum
));
1460 store_floating (virtual_buffer
, TYPE_LENGTH (valtype
), d
);
1462 else if (TYPE_CODE (valtype
) == TYPE_CODE_INT
&& TYPE_LENGTH (valtype
) <= 4)
1465 l
= extract_unsigned_integer (raw_buffer
, REGISTER_RAW_SIZE (regnum
));
1466 l
= ((l
>> 32) & 0xc0000000) | ((l
>> 29) & 0x3fffffff);
1467 store_unsigned_integer (virtual_buffer
, TYPE_LENGTH (valtype
), l
);
1470 error ("Cannot retrieve value from floating point register");
1474 alpha_register_convert_to_raw (struct type
*valtype
, int regnum
,
1475 char *virtual_buffer
, char *raw_buffer
)
1477 if (TYPE_LENGTH (valtype
) >= REGISTER_RAW_SIZE (regnum
))
1479 memcpy (raw_buffer
, virtual_buffer
, REGISTER_RAW_SIZE (regnum
));
1483 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
)
1485 double d
= extract_floating (virtual_buffer
, TYPE_LENGTH (valtype
));
1486 store_floating (raw_buffer
, REGISTER_RAW_SIZE (regnum
), d
);
1488 else if (TYPE_CODE (valtype
) == TYPE_CODE_INT
&& TYPE_LENGTH (valtype
) <= 4)
1491 if (TYPE_UNSIGNED (valtype
))
1492 l
= extract_unsigned_integer (virtual_buffer
, TYPE_LENGTH (valtype
));
1494 l
= extract_signed_integer (virtual_buffer
, TYPE_LENGTH (valtype
));
1495 l
= ((l
& 0xc0000000) << 32) | ((l
& 0x3fffffff) << 29);
1496 store_unsigned_integer (raw_buffer
, REGISTER_RAW_SIZE (regnum
), l
);
1499 error ("Cannot store value in floating point register");
1502 static const unsigned char *
1503 alpha_breakpoint_from_pc (CORE_ADDR
*pcptr
, int *lenptr
)
1505 static const unsigned char alpha_breakpoint
[] =
1506 { 0x80, 0, 0, 0 }; /* call_pal bpt */
1508 *lenptr
= sizeof(alpha_breakpoint
);
1509 return (alpha_breakpoint
);
1512 /* Given a return value in `regbuf' with a type `valtype',
1513 extract and copy its value into `valbuf'. */
1516 alpha_extract_return_value (struct type
*valtype
,
1517 char regbuf
[REGISTER_BYTES
], char *valbuf
)
1519 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
)
1520 alpha_register_convert_to_virtual (FP0_REGNUM
, valtype
,
1521 regbuf
+ REGISTER_BYTE (FP0_REGNUM
),
1524 memcpy (valbuf
, regbuf
+ REGISTER_BYTE (ALPHA_V0_REGNUM
),
1525 TYPE_LENGTH (valtype
));
1528 /* Given a return value in `regbuf' with a type `valtype',
1529 write its value into the appropriate register. */
1532 alpha_store_return_value (struct type
*valtype
, char *valbuf
)
1534 char raw_buffer
[ALPHA_MAX_REGISTER_RAW_SIZE
];
1535 int regnum
= ALPHA_V0_REGNUM
;
1536 int length
= TYPE_LENGTH (valtype
);
1538 if (TYPE_CODE (valtype
) == TYPE_CODE_FLT
)
1540 regnum
= FP0_REGNUM
;
1541 length
= REGISTER_RAW_SIZE (regnum
);
1542 alpha_register_convert_to_raw (valtype
, regnum
, valbuf
, raw_buffer
);
1545 memcpy (raw_buffer
, valbuf
, length
);
1547 write_register_bytes (REGISTER_BYTE (regnum
), raw_buffer
, length
);
1550 /* Just like reinit_frame_cache, but with the right arguments to be
1551 callable as an sfunc. */
1554 reinit_frame_cache_sfunc (char *args
, int from_tty
, struct cmd_list_element
*c
)
1556 reinit_frame_cache ();
1559 /* This is the definition of CALL_DUMMY_ADDRESS. It's a heuristic that is used
1560 to find a convenient place in the text segment to stick a breakpoint to
1561 detect the completion of a target function call (ala call_function_by_hand).
1565 alpha_call_dummy_address (void)
1568 struct minimal_symbol
*sym
;
1570 entry
= entry_point_address ();
1575 sym
= lookup_minimal_symbol ("_Prelude", NULL
, symfile_objfile
);
1577 if (!sym
|| MSYMBOL_TYPE (sym
) != mst_text
)
1580 return SYMBOL_VALUE_ADDRESS (sym
) + 4;
1584 alpha_fix_call_dummy (char *dummy
, CORE_ADDR pc
, CORE_ADDR fun
, int nargs
,
1585 struct value
**args
, struct type
*type
, int gcc_p
)
1587 CORE_ADDR bp_address
= CALL_DUMMY_ADDRESS ();
1589 if (bp_address
== 0)
1590 error ("no place to put call");
1591 write_register (ALPHA_RA_REGNUM
, bp_address
);
1592 write_register (ALPHA_T12_REGNUM
, fun
);
1595 /* On the Alpha, the call dummy code is nevery copied to user space
1596 (see alpha_fix_call_dummy() above). The contents of this do not
1598 LONGEST alpha_call_dummy_words
[] = { 0 };
1601 alpha_use_struct_convention (int gcc_p
, struct type
*type
)
1603 /* Structures are returned by ref in extra arg0. */
1608 alpha_store_struct_return (CORE_ADDR addr
, CORE_ADDR sp
)
1610 /* Store the address of the place in which to copy the structure the
1611 subroutine will return. Handled by alpha_push_arguments. */
1615 alpha_extract_struct_value_address (char *regbuf
)
1617 return (extract_address (regbuf
+ REGISTER_BYTE (ALPHA_V0_REGNUM
),
1618 REGISTER_RAW_SIZE (ALPHA_V0_REGNUM
)));
1621 /* Figure out where the longjmp will land.
1622 We expect the first arg to be a pointer to the jmp_buf structure from
1623 which we extract the PC (JB_PC) that we will land at. The PC is copied
1624 into the "pc". This routine returns true on success. */
1627 alpha_get_longjmp_target (CORE_ADDR
*pc
)
1629 struct gdbarch_tdep
*tdep
= gdbarch_tdep (current_gdbarch
);
1631 char raw_buffer
[ALPHA_MAX_REGISTER_RAW_SIZE
];
1633 jb_addr
= read_register (ALPHA_A0_REGNUM
);
1635 if (target_read_memory (jb_addr
+ (tdep
->jb_pc
* tdep
->jb_elt_size
),
1636 raw_buffer
, tdep
->jb_elt_size
))
1639 *pc
= extract_address (raw_buffer
, tdep
->jb_elt_size
);
1643 /* alpha_software_single_step() is called just before we want to resume
1644 the inferior, if we want to single-step it but there is no hardware
1645 or kernel single-step support (NetBSD on Alpha, for example). We find
1646 the target of the coming instruction and breakpoint it.
1648 single_step is also called just after the inferior stops. If we had
1649 set up a simulated single-step, we undo our damage. */
1652 alpha_next_pc (CORE_ADDR pc
)
1659 insn
= read_memory_unsigned_integer (pc
, sizeof (insn
));
1661 /* Opcode is top 6 bits. */
1662 op
= (insn
>> 26) & 0x3f;
1666 /* Jump format: target PC is:
1668 return (read_register ((insn
>> 16) & 0x1f) & ~3);
1671 if ((op
& 0x30) == 0x30)
1673 /* Branch format: target PC is:
1674 (new PC) + (4 * sext(displacement)) */
1675 if (op
== 0x30 || /* BR */
1676 op
== 0x34) /* BSR */
1679 offset
= (insn
& 0x001fffff);
1680 if (offset
& 0x00100000)
1681 offset
|= 0xffe00000;
1683 return (pc
+ 4 + offset
);
1686 /* Need to determine if branch is taken; read RA. */
1687 rav
= (LONGEST
) read_register ((insn
>> 21) & 0x1f);
1690 case 0x38: /* BLBC */
1694 case 0x3c: /* BLBS */
1698 case 0x39: /* BEQ */
1702 case 0x3d: /* BNE */
1706 case 0x3a: /* BLT */
1710 case 0x3b: /* BLE */
1714 case 0x3f: /* BGT */
1718 case 0x3e: /* BGE */
1725 /* Not a branch or branch not taken; target PC is:
1731 alpha_software_single_step (enum target_signal sig
, int insert_breakpoints_p
)
1733 static CORE_ADDR next_pc
;
1734 typedef char binsn_quantum
[BREAKPOINT_MAX
];
1735 static binsn_quantum break_mem
;
1738 if (insert_breakpoints_p
)
1741 next_pc
= alpha_next_pc (pc
);
1743 target_insert_breakpoint (next_pc
, break_mem
);
1747 target_remove_breakpoint (next_pc
, break_mem
);
1753 /* This table matches the indices assigned to enum alpha_abi. Keep
1755 static const char * const alpha_abi_names
[] =
1766 process_note_abi_tag_sections (bfd
*abfd
, asection
*sect
, void *obj
)
1768 enum alpha_abi
*os_ident_ptr
= obj
;
1770 unsigned int sectsize
;
1772 name
= bfd_get_section_name (abfd
, sect
);
1773 sectsize
= bfd_section_size (abfd
, sect
);
1775 if (strcmp (name
, ".note.ABI-tag") == 0 && sectsize
> 0)
1777 unsigned int name_length
, data_length
, note_type
;
1780 /* If the section is larger than this, it's probably not what we are
1785 note
= alloca (sectsize
);
1787 bfd_get_section_contents (abfd
, sect
, note
,
1788 (file_ptr
) 0, (bfd_size_type
) sectsize
);
1790 name_length
= bfd_h_get_32 (abfd
, note
);
1791 data_length
= bfd_h_get_32 (abfd
, note
+ 4);
1792 note_type
= bfd_h_get_32 (abfd
, note
+ 8);
1794 if (name_length
== 4 && data_length
== 16 && note_type
== 1
1795 && strcmp (note
+ 12, "GNU") == 0)
1797 int os_number
= bfd_h_get_32 (abfd
, note
+ 16);
1799 /* The case numbers are from abi-tags in glibc. */
1803 *os_ident_ptr
= ALPHA_ABI_LINUX
;
1808 (__FILE__
, __LINE__
,
1809 "process_note_abi_sections: Hurd objects not supported");
1814 (__FILE__
, __LINE__
,
1815 "process_note_abi_sections: Solaris objects not supported");
1820 (__FILE__
, __LINE__
,
1821 "process_note_abi_sections: unknown OS number %d",
1827 /* NetBSD uses a similar trick. */
1828 else if (strcmp (name
, ".note.netbsd.ident") == 0 && sectsize
> 0)
1830 unsigned int name_length
, desc_length
, note_type
;
1833 /* If the section is larger than this, it's probably not what we are
1838 note
= alloca (sectsize
);
1840 bfd_get_section_contents (abfd
, sect
, note
,
1841 (file_ptr
) 0, (bfd_size_type
) sectsize
);
1843 name_length
= bfd_h_get_32 (abfd
, note
);
1844 desc_length
= bfd_h_get_32 (abfd
, note
+ 4);
1845 note_type
= bfd_h_get_32 (abfd
, note
+ 8);
1847 if (name_length
== 7 && desc_length
== 4 && note_type
== 1
1848 && strcmp (note
+ 12, "NetBSD") == 0)
1849 /* XXX Should we check the version here?
1850 Probably not necessary yet. */
1851 *os_ident_ptr
= ALPHA_ABI_NETBSD
;
1856 get_elfosabi (bfd
*abfd
)
1859 enum alpha_abi alpha_abi
= ALPHA_ABI_UNKNOWN
;
1861 elfosabi
= elf_elfheader (abfd
)->e_ident
[EI_OSABI
];
1863 /* When elfosabi is 0 (ELFOSABI_NONE), this is supposed to indicate
1864 what we're on a SYSV system. However, GNU/Linux uses a note section
1865 to record OS/ABI info, but leaves e_ident[EI_OSABI] zero. So we
1866 have to check the note sections too. */
1869 bfd_map_over_sections (abfd
,
1870 process_note_abi_tag_sections
,
1874 if (alpha_abi
!= ALPHA_ABI_UNKNOWN
)
1880 /* Leave it as unknown. */
1883 case ELFOSABI_NETBSD
:
1884 return ALPHA_ABI_NETBSD
;
1886 case ELFOSABI_FREEBSD
:
1887 return ALPHA_ABI_FREEBSD
;
1889 case ELFOSABI_LINUX
:
1890 return ALPHA_ABI_LINUX
;
1893 return ALPHA_ABI_UNKNOWN
;
1896 struct alpha_abi_handler
1898 struct alpha_abi_handler
*next
;
1900 void (*init_abi
)(struct gdbarch_info
, struct gdbarch
*);
1903 struct alpha_abi_handler
*alpha_abi_handler_list
= NULL
;
1906 alpha_gdbarch_register_os_abi (enum alpha_abi abi
,
1907 void (*init_abi
)(struct gdbarch_info
,
1910 struct alpha_abi_handler
**handler_p
;
1912 for (handler_p
= &alpha_abi_handler_list
; *handler_p
!= NULL
;
1913 handler_p
= &(*handler_p
)->next
)
1915 if ((*handler_p
)->abi
== abi
)
1918 (__FILE__
, __LINE__
,
1919 "alpha_gdbarch_register_os_abi: A handler for this ABI variant "
1920 "(%d) has already been registered", (int) abi
);
1921 /* If user wants to continue, override previous definition. */
1922 (*handler_p
)->init_abi
= init_abi
;
1928 = (struct alpha_abi_handler
*) xmalloc (sizeof (struct alpha_abi_handler
));
1929 (*handler_p
)->next
= NULL
;
1930 (*handler_p
)->abi
= abi
;
1931 (*handler_p
)->init_abi
= init_abi
;
1934 /* Initialize the current architecture based on INFO. If possible, re-use an
1935 architecture from ARCHES, which is a list of architectures already created
1936 during this debugging session.
1938 Called e.g. at program startup, when reading a core file, and when reading
1941 static struct gdbarch
*
1942 alpha_gdbarch_init (struct gdbarch_info info
, struct gdbarch_list
*arches
)
1944 struct gdbarch_tdep
*tdep
;
1945 struct gdbarch
*gdbarch
;
1946 enum alpha_abi alpha_abi
= ALPHA_ABI_UNKNOWN
;
1947 struct alpha_abi_handler
*abi_handler
;
1949 /* Try to determine the ABI of the object we are loading. */
1951 if (info
.abfd
!= NULL
)
1953 switch (bfd_get_flavour (info
.abfd
))
1955 case bfd_target_elf_flavour
:
1956 alpha_abi
= get_elfosabi (info
.abfd
);
1959 case bfd_target_ecoff_flavour
:
1960 /* Assume it's OSF/1. */
1961 alpha_abi
= ALPHA_ABI_OSF1
;
1965 /* Not sure what to do here, leave the ABI as unknown. */
1970 /* Find a candidate among extant architectures. */
1971 for (arches
= gdbarch_list_lookup_by_info (arches
, &info
);
1973 arches
= gdbarch_list_lookup_by_info (arches
->next
, &info
))
1975 /* Make sure the ABI selection matches. */
1976 tdep
= gdbarch_tdep (arches
->gdbarch
);
1977 if (tdep
&& tdep
->alpha_abi
== alpha_abi
)
1978 return arches
->gdbarch
;
1981 tdep
= xmalloc (sizeof (struct gdbarch_tdep
));
1982 gdbarch
= gdbarch_alloc (&info
, tdep
);
1984 tdep
->alpha_abi
= alpha_abi
;
1985 if (alpha_abi
< ALPHA_ABI_INVALID
)
1986 tdep
->abi_name
= alpha_abi_names
[alpha_abi
];
1989 internal_error (__FILE__
, __LINE__
, "Invalid setting of alpha_abi %d",
1991 tdep
->abi_name
= "<invalid>";
1994 /* Lowest text address. This is used by heuristic_proc_start() to
1995 decide when to stop looking. */
1996 tdep
->vm_min_address
= (CORE_ADDR
) 0x120000000;
1998 tdep
->dynamic_sigtramp_offset
= NULL
;
1999 tdep
->skip_sigtramp_frame
= NULL
;
2001 tdep
->jb_pc
= -1; /* longjmp support not enabled by default */
2004 set_gdbarch_short_bit (gdbarch
, 16);
2005 set_gdbarch_int_bit (gdbarch
, 32);
2006 set_gdbarch_long_bit (gdbarch
, 64);
2007 set_gdbarch_long_long_bit (gdbarch
, 64);
2008 set_gdbarch_float_bit (gdbarch
, 32);
2009 set_gdbarch_double_bit (gdbarch
, 64);
2010 set_gdbarch_long_double_bit (gdbarch
, 64);
2011 set_gdbarch_ptr_bit (gdbarch
, 64);
2014 set_gdbarch_num_regs (gdbarch
, ALPHA_NUM_REGS
);
2015 set_gdbarch_sp_regnum (gdbarch
, ALPHA_SP_REGNUM
);
2016 set_gdbarch_fp_regnum (gdbarch
, ALPHA_FP_REGNUM
);
2017 set_gdbarch_pc_regnum (gdbarch
, ALPHA_PC_REGNUM
);
2018 set_gdbarch_fp0_regnum (gdbarch
, ALPHA_FP0_REGNUM
);
2020 set_gdbarch_register_name (gdbarch
, alpha_register_name
);
2021 set_gdbarch_register_size (gdbarch
, ALPHA_REGISTER_SIZE
);
2022 set_gdbarch_register_bytes (gdbarch
, ALPHA_REGISTER_BYTES
);
2023 set_gdbarch_register_byte (gdbarch
, alpha_register_byte
);
2024 set_gdbarch_register_raw_size (gdbarch
, alpha_register_raw_size
);
2025 set_gdbarch_max_register_raw_size (gdbarch
, ALPHA_MAX_REGISTER_RAW_SIZE
);
2026 set_gdbarch_register_virtual_size (gdbarch
, alpha_register_virtual_size
);
2027 set_gdbarch_max_register_virtual_size (gdbarch
,
2028 ALPHA_MAX_REGISTER_VIRTUAL_SIZE
);
2029 set_gdbarch_register_virtual_type (gdbarch
, alpha_register_virtual_type
);
2031 set_gdbarch_cannot_fetch_register (gdbarch
, alpha_cannot_fetch_register
);
2032 set_gdbarch_cannot_store_register (gdbarch
, alpha_cannot_store_register
);
2034 set_gdbarch_register_convertible (gdbarch
, alpha_register_convertible
);
2035 set_gdbarch_register_convert_to_virtual (gdbarch
,
2036 alpha_register_convert_to_virtual
);
2037 set_gdbarch_register_convert_to_raw (gdbarch
, alpha_register_convert_to_raw
);
2039 set_gdbarch_skip_prologue (gdbarch
, alpha_skip_prologue
);
2041 set_gdbarch_frame_num_args (gdbarch
, frame_num_args_unknown
);
2042 set_gdbarch_frameless_function_invocation (gdbarch
,
2043 generic_frameless_function_invocation_not
);
2045 set_gdbarch_saved_pc_after_call (gdbarch
, alpha_saved_pc_after_call
);
2047 set_gdbarch_frame_chain (gdbarch
, alpha_frame_chain
);
2048 set_gdbarch_frame_chain_valid (gdbarch
, func_frame_chain_valid
);
2049 set_gdbarch_frame_saved_pc (gdbarch
, alpha_frame_saved_pc
);
2051 set_gdbarch_frame_init_saved_regs (gdbarch
, alpha_frame_init_saved_regs
);
2052 set_gdbarch_get_saved_register (gdbarch
, alpha_get_saved_register
);
2054 set_gdbarch_use_struct_convention (gdbarch
, alpha_use_struct_convention
);
2055 set_gdbarch_extract_return_value (gdbarch
, alpha_extract_return_value
);
2057 set_gdbarch_store_struct_return (gdbarch
, alpha_store_struct_return
);
2058 set_gdbarch_store_return_value (gdbarch
, alpha_store_return_value
);
2059 set_gdbarch_extract_struct_value_address (gdbarch
,
2060 alpha_extract_struct_value_address
);
2062 /* Settings for calling functions in the inferior. */
2063 set_gdbarch_use_generic_dummy_frames (gdbarch
, 0);
2064 set_gdbarch_call_dummy_length (gdbarch
, 0);
2065 set_gdbarch_push_arguments (gdbarch
, alpha_push_arguments
);
2066 set_gdbarch_pop_frame (gdbarch
, alpha_pop_frame
);
2068 /* On the Alpha, the call dummy code is never copied to user space,
2069 stopping the user call is achieved via a bp_call_dummy breakpoint.
2070 But we need a fake CALL_DUMMY definition to enable the proper
2071 call_function_by_hand and to avoid zero length array warnings. */
2072 set_gdbarch_call_dummy_p (gdbarch
, 1);
2073 set_gdbarch_call_dummy_words (gdbarch
, alpha_call_dummy_words
);
2074 set_gdbarch_sizeof_call_dummy_words (gdbarch
, 0);
2075 set_gdbarch_frame_args_address (gdbarch
, alpha_frame_args_address
);
2076 set_gdbarch_frame_locals_address (gdbarch
, alpha_frame_locals_address
);
2077 set_gdbarch_init_extra_frame_info (gdbarch
, alpha_init_extra_frame_info
);
2079 /* Alpha OSF/1 inhibits execution of code on the stack. But there is
2080 no need for a dummy on the Alpha. PUSH_ARGUMENTS takes care of all
2081 argument handling and bp_call_dummy takes care of stopping the dummy. */
2082 set_gdbarch_call_dummy_location (gdbarch
, AT_ENTRY_POINT
);
2083 set_gdbarch_call_dummy_address (gdbarch
, alpha_call_dummy_address
);
2084 set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch
, 1);
2085 set_gdbarch_call_dummy_breakpoint_offset (gdbarch
, 0);
2086 set_gdbarch_call_dummy_start_offset (gdbarch
, 0);
2087 set_gdbarch_pc_in_call_dummy (gdbarch
, pc_in_call_dummy_at_entry_point
);
2088 set_gdbarch_call_dummy_stack_adjust_p (gdbarch
, 0);
2089 set_gdbarch_push_dummy_frame (gdbarch
, alpha_push_dummy_frame
);
2090 set_gdbarch_fix_call_dummy (gdbarch
, alpha_fix_call_dummy
);
2091 set_gdbarch_init_frame_pc (gdbarch
, init_frame_pc_noop
);
2092 set_gdbarch_init_frame_pc_first (gdbarch
, alpha_init_frame_pc_first
);
2094 set_gdbarch_inner_than (gdbarch
, core_addr_lessthan
);
2095 set_gdbarch_skip_trampoline_code (gdbarch
, find_solib_trampoline_target
);
2097 /* Floats are always passed as doubles. */
2098 set_gdbarch_coerce_float_to_double (gdbarch
,
2099 standard_coerce_float_to_double
);
2101 set_gdbarch_breakpoint_from_pc (gdbarch
, alpha_breakpoint_from_pc
);
2102 set_gdbarch_decr_pc_after_break (gdbarch
, 4);
2104 set_gdbarch_function_start_offset (gdbarch
, 0);
2105 set_gdbarch_frame_args_skip (gdbarch
, 0);
2107 /* Hook in ABI-specific overrides, if they have been registered. */
2108 if (alpha_abi
== ALPHA_ABI_UNKNOWN
)
2110 /* Don't complain about not knowing the ABI variant if we don't
2111 have an inferior. */
2114 (gdb_stderr
, "GDB doesn't recognize the ABI of the inferior. "
2115 "Attempting to continue with the default Alpha settings");
2119 for (abi_handler
= alpha_abi_handler_list
; abi_handler
!= NULL
;
2120 abi_handler
= abi_handler
->next
)
2121 if (abi_handler
->abi
== alpha_abi
)
2125 abi_handler
->init_abi (info
, gdbarch
);
2128 /* We assume that if GDB_MULTI_ARCH is less than
2129 GDB_MULTI_ARCH_TM that an ABI variant can be supported by
2130 overriding definitions in this file. */
2131 if (GDB_MULTI_ARCH
> GDB_MULTI_ARCH_PARTIAL
)
2134 "A handler for the ABI variant \"%s\" is not built into this "
2135 "configuration of GDB. "
2136 "Attempting to continue with the default Alpha settings",
2137 alpha_abi_names
[alpha_abi
]);
2141 /* Now that we have tuned the configuration, set a few final things
2142 based on what the OS ABI has told us. */
2144 if (tdep
->jb_pc
>= 0)
2145 set_gdbarch_get_longjmp_target (gdbarch
, alpha_get_longjmp_target
);
2151 alpha_dump_tdep (struct gdbarch
*current_gdbarch
, struct ui_file
*file
)
2153 struct gdbarch_tdep
*tdep
= gdbarch_tdep (current_gdbarch
);
2158 if (tdep
->abi_name
!= NULL
)
2159 fprintf_unfiltered (file
, "alpha_dump_tdep: ABI = %s\n", tdep
->abi_name
);
2161 internal_error (__FILE__
, __LINE__
,
2162 "alpha_dump_tdep: illegal setting of tdep->alpha_abi (%d)",
2163 (int) tdep
->alpha_abi
);
2165 fprintf_unfiltered (file
,
2166 "alpha_dump_tdep: vm_min_address = 0x%lx\n",
2167 (long) tdep
->vm_min_address
);
2169 fprintf_unfiltered (file
,
2170 "alpha_dump_tdep: jb_pc = %d\n",
2172 fprintf_unfiltered (file
,
2173 "alpha_dump_tdep: jb_elt_size = %ld\n",
2174 (long) tdep
->jb_elt_size
);
2178 _initialize_alpha_tdep (void)
2180 struct cmd_list_element
*c
;
2182 gdbarch_register (bfd_arch_alpha
, alpha_gdbarch_init
, alpha_dump_tdep
);
2184 tm_print_insn
= print_insn_alpha
;
2186 /* Let the user set the fence post for heuristic_proc_start. */
2188 /* We really would like to have both "0" and "unlimited" work, but
2189 command.c doesn't deal with that. So make it a var_zinteger
2190 because the user can always use "999999" or some such for unlimited. */
2191 c
= add_set_cmd ("heuristic-fence-post", class_support
, var_zinteger
,
2192 (char *) &heuristic_fence_post
,
2194 Set the distance searched for the start of a function.\n\
2195 If you are debugging a stripped executable, GDB needs to search through the\n\
2196 program for the start of a function. This command sets the distance of the\n\
2197 search. The only need to set it is when debugging a stripped executable.",
2199 /* We need to throw away the frame cache when we set this, since it
2200 might change our ability to get backtraces. */
2201 set_cmd_sfunc (c
, reinit_frame_cache_sfunc
);
2202 add_show_from_set (c
, &showlist
);