]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/alpha-tdep.c
* defs.h (strlen_paddr, paddr, paddr_nz): Remove.
[thirdparty/binutils-gdb.git] / gdb / alpha-tdep.c
CommitLineData
c906108c 1/* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger.
0fd88904 2
6aba47ca 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
0fb0cc75 4 2003, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
c906108c 5
c5aa993b 6 This file is part of GDB.
c906108c 7
c5aa993b
JM
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
c5aa993b 11 (at your option) any later version.
c906108c 12
c5aa993b
JM
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
c906108c 17
c5aa993b 18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
20
21#include "defs.h"
615967cb 22#include "doublest.h"
c906108c 23#include "frame.h"
d2427a71
RH
24#include "frame-unwind.h"
25#include "frame-base.h"
baa490c4 26#include "dwarf2-frame.h"
c906108c
SS
27#include "inferior.h"
28#include "symtab.h"
29#include "value.h"
30#include "gdbcmd.h"
31#include "gdbcore.h"
32#include "dis-asm.h"
33#include "symfile.h"
34#include "objfiles.h"
35#include "gdb_string.h"
c5f0f3d0 36#include "linespec.h"
4e052eda 37#include "regcache.h"
615967cb 38#include "reggroups.h"
dc129d82 39#include "arch-utils.h"
4be87837 40#include "osabi.h"
fe898f56 41#include "block.h"
7d9b040b 42#include "infcall.h"
07ea644b 43#include "trad-frame.h"
dc129d82
JT
44
45#include "elf-bfd.h"
46
47#include "alpha-tdep.h"
48
c906108c 49\f
515921d7
JB
50/* Return the name of the REGNO register.
51
52 An empty name corresponds to a register number that used to
53 be used for a virtual register. That virtual register has
54 been removed, but the index is still reserved to maintain
55 compatibility with existing remote alpha targets. */
56
fa88f677 57static const char *
d93859e2 58alpha_register_name (struct gdbarch *gdbarch, int regno)
636a6dfc 59{
5ab84872 60 static const char * const register_names[] =
636a6dfc
JT
61 {
62 "v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
63 "t7", "s0", "s1", "s2", "s3", "s4", "s5", "fp",
64 "a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9",
65 "t10", "t11", "ra", "t12", "at", "gp", "sp", "zero",
66 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
67 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
68 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
69 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "fpcr",
44d88583 70 "pc", "", "unique"
636a6dfc
JT
71 };
72
73 if (regno < 0)
5ab84872 74 return NULL;
e8d2d628 75 if (regno >= ARRAY_SIZE(register_names))
5ab84872
RH
76 return NULL;
77 return register_names[regno];
636a6dfc 78}
d734c450 79
dc129d82 80static int
64a3914f 81alpha_cannot_fetch_register (struct gdbarch *gdbarch, int regno)
d734c450 82{
515921d7 83 return (regno == ALPHA_ZERO_REGNUM
64a3914f 84 || strlen (alpha_register_name (gdbarch, regno)) == 0);
d734c450
JT
85}
86
dc129d82 87static int
64a3914f 88alpha_cannot_store_register (struct gdbarch *gdbarch, int regno)
d734c450 89{
515921d7 90 return (regno == ALPHA_ZERO_REGNUM
64a3914f 91 || strlen (alpha_register_name (gdbarch, regno)) == 0);
d734c450
JT
92}
93
dc129d82 94static struct type *
c483c494 95alpha_register_type (struct gdbarch *gdbarch, int regno)
0d056799 96{
72667056 97 if (regno == ALPHA_SP_REGNUM || regno == ALPHA_GP_REGNUM)
0dfff4cb 98 return builtin_type (gdbarch)->builtin_data_ptr;
72667056 99 if (regno == ALPHA_PC_REGNUM)
0dfff4cb 100 return builtin_type (gdbarch)->builtin_func_ptr;
72667056
RH
101
102 /* Don't need to worry about little vs big endian until
103 some jerk tries to port to alpha-unicosmk. */
b38b6be2 104 if (regno >= ALPHA_FP0_REGNUM && regno < ALPHA_FP0_REGNUM + 31)
27067745 105 return builtin_type (gdbarch)->builtin_double;
72667056 106
df4df182 107 return builtin_type (gdbarch)->builtin_int64;
0d056799 108}
f8453e34 109
615967cb
RH
110/* Is REGNUM a member of REGGROUP? */
111
112static int
113alpha_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
114 struct reggroup *group)
115{
116 /* Filter out any registers eliminated, but whose regnum is
117 reserved for backward compatibility, e.g. the vfp. */
ec7cc0e8
UW
118 if (gdbarch_register_name (gdbarch, regnum) == NULL
119 || *gdbarch_register_name (gdbarch, regnum) == '\0')
615967cb
RH
120 return 0;
121
df4a182b
RH
122 if (group == all_reggroup)
123 return 1;
124
125 /* Zero should not be saved or restored. Technically it is a general
126 register (just as $f31 would be a float if we represented it), but
127 there's no point displaying it during "info regs", so leave it out
128 of all groups except for "all". */
129 if (regnum == ALPHA_ZERO_REGNUM)
130 return 0;
131
132 /* All other registers are saved and restored. */
133 if (group == save_reggroup || group == restore_reggroup)
615967cb
RH
134 return 1;
135
136 /* All other groups are non-overlapping. */
137
138 /* Since this is really a PALcode memory slot... */
139 if (regnum == ALPHA_UNIQUE_REGNUM)
140 return group == system_reggroup;
141
142 /* Force the FPCR to be considered part of the floating point state. */
143 if (regnum == ALPHA_FPCR_REGNUM)
144 return group == float_reggroup;
145
146 if (regnum >= ALPHA_FP0_REGNUM && regnum < ALPHA_FP0_REGNUM + 31)
147 return group == float_reggroup;
148 else
149 return group == general_reggroup;
150}
151
c483c494
RH
152/* The following represents exactly the conversion performed by
153 the LDS instruction. This applies to both single-precision
154 floating point and 32-bit integers. */
155
156static void
157alpha_lds (void *out, const void *in)
158{
159 ULONGEST mem = extract_unsigned_integer (in, 4);
160 ULONGEST frac = (mem >> 0) & 0x7fffff;
161 ULONGEST sign = (mem >> 31) & 1;
162 ULONGEST exp_msb = (mem >> 30) & 1;
163 ULONGEST exp_low = (mem >> 23) & 0x7f;
164 ULONGEST exp, reg;
165
166 exp = (exp_msb << 10) | exp_low;
167 if (exp_msb)
168 {
169 if (exp_low == 0x7f)
170 exp = 0x7ff;
171 }
172 else
173 {
174 if (exp_low != 0x00)
175 exp |= 0x380;
176 }
177
178 reg = (sign << 63) | (exp << 52) | (frac << 29);
179 store_unsigned_integer (out, 8, reg);
180}
181
182/* Similarly, this represents exactly the conversion performed by
183 the STS instruction. */
184
39efb398 185static void
c483c494
RH
186alpha_sts (void *out, const void *in)
187{
188 ULONGEST reg, mem;
189
190 reg = extract_unsigned_integer (in, 8);
191 mem = ((reg >> 32) & 0xc0000000) | ((reg >> 29) & 0x3fffffff);
192 store_unsigned_integer (out, 4, mem);
193}
194
d2427a71
RH
195/* The alpha needs a conversion between register and memory format if the
196 register is a floating point register and memory format is float, as the
197 register format must be double or memory format is an integer with 4
198 bytes or less, as the representation of integers in floating point
199 registers is different. */
200
c483c494 201static int
0abe36f5 202alpha_convert_register_p (struct gdbarch *gdbarch, int regno, struct type *type)
14696584 203{
83acabca
DJ
204 return (regno >= ALPHA_FP0_REGNUM && regno < ALPHA_FP0_REGNUM + 31
205 && TYPE_LENGTH (type) != 8);
14696584
RH
206}
207
d2427a71 208static void
ff2e87ac 209alpha_register_to_value (struct frame_info *frame, int regnum,
5b819568 210 struct type *valtype, gdb_byte *out)
5868c862 211{
2a1ce6ec
MK
212 gdb_byte in[MAX_REGISTER_SIZE];
213
ff2e87ac 214 frame_register_read (frame, regnum, in);
c483c494 215 switch (TYPE_LENGTH (valtype))
d2427a71 216 {
c483c494
RH
217 case 4:
218 alpha_sts (out, in);
219 break;
c483c494 220 default:
323e0a4a 221 error (_("Cannot retrieve value from floating point register"));
d2427a71 222 }
d2427a71 223}
5868c862 224
d2427a71 225static void
ff2e87ac 226alpha_value_to_register (struct frame_info *frame, int regnum,
5b819568 227 struct type *valtype, const gdb_byte *in)
d2427a71 228{
2a1ce6ec
MK
229 gdb_byte out[MAX_REGISTER_SIZE];
230
c483c494 231 switch (TYPE_LENGTH (valtype))
d2427a71 232 {
c483c494
RH
233 case 4:
234 alpha_lds (out, in);
235 break;
c483c494 236 default:
323e0a4a 237 error (_("Cannot store value in floating point register"));
d2427a71 238 }
ff2e87ac 239 put_frame_register (frame, regnum, out);
5868c862
JT
240}
241
d2427a71
RH
242\f
243/* The alpha passes the first six arguments in the registers, the rest on
c88e30c0
RH
244 the stack. The register arguments are stored in ARG_REG_BUFFER, and
245 then moved into the register file; this simplifies the passing of a
246 large struct which extends from the registers to the stack, plus avoids
247 three ptrace invocations per word.
248
249 We don't bother tracking which register values should go in integer
250 regs or fp regs; we load the same values into both.
251
d2427a71
RH
252 If the called function is returning a structure, the address of the
253 structure to be returned is passed as a hidden first argument. */
c906108c 254
d2427a71 255static CORE_ADDR
7d9b040b 256alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
c88e30c0
RH
257 struct regcache *regcache, CORE_ADDR bp_addr,
258 int nargs, struct value **args, CORE_ADDR sp,
259 int struct_return, CORE_ADDR struct_addr)
c906108c 260{
d2427a71
RH
261 int i;
262 int accumulate_size = struct_return ? 8 : 0;
d2427a71 263 struct alpha_arg
c906108c 264 {
2a1ce6ec 265 gdb_byte *contents;
d2427a71
RH
266 int len;
267 int offset;
268 };
c88e30c0
RH
269 struct alpha_arg *alpha_args
270 = (struct alpha_arg *) alloca (nargs * sizeof (struct alpha_arg));
52f0bd74 271 struct alpha_arg *m_arg;
2a1ce6ec 272 gdb_byte arg_reg_buffer[ALPHA_REGISTER_SIZE * ALPHA_NUM_ARG_REGS];
d2427a71 273 int required_arg_regs;
7d9b040b 274 CORE_ADDR func_addr = find_function_addr (function, NULL);
c906108c 275
c88e30c0
RH
276 /* The ABI places the address of the called function in T12. */
277 regcache_cooked_write_signed (regcache, ALPHA_T12_REGNUM, func_addr);
278
279 /* Set the return address register to point to the entry point
280 of the program, where a breakpoint lies in wait. */
281 regcache_cooked_write_signed (regcache, ALPHA_RA_REGNUM, bp_addr);
282
283 /* Lay out the arguments in memory. */
d2427a71
RH
284 for (i = 0, m_arg = alpha_args; i < nargs; i++, m_arg++)
285 {
286 struct value *arg = args[i];
4991999e 287 struct type *arg_type = check_typedef (value_type (arg));
c88e30c0 288
d2427a71
RH
289 /* Cast argument to long if necessary as the compiler does it too. */
290 switch (TYPE_CODE (arg_type))
c906108c 291 {
d2427a71
RH
292 case TYPE_CODE_INT:
293 case TYPE_CODE_BOOL:
294 case TYPE_CODE_CHAR:
295 case TYPE_CODE_RANGE:
296 case TYPE_CODE_ENUM:
0ede8eca 297 if (TYPE_LENGTH (arg_type) == 4)
d2427a71 298 {
0ede8eca
RH
299 /* 32-bit values must be sign-extended to 64 bits
300 even if the base data type is unsigned. */
df4df182 301 arg_type = builtin_type (gdbarch)->builtin_int32;
0ede8eca
RH
302 arg = value_cast (arg_type, arg);
303 }
304 if (TYPE_LENGTH (arg_type) < ALPHA_REGISTER_SIZE)
305 {
df4df182 306 arg_type = builtin_type (gdbarch)->builtin_int64;
d2427a71
RH
307 arg = value_cast (arg_type, arg);
308 }
309 break;
7b5e1cb3 310
c88e30c0
RH
311 case TYPE_CODE_FLT:
312 /* "float" arguments loaded in registers must be passed in
313 register format, aka "double". */
314 if (accumulate_size < sizeof (arg_reg_buffer)
315 && TYPE_LENGTH (arg_type) == 4)
316 {
27067745 317 arg_type = builtin_type (gdbarch)->builtin_double;
c88e30c0
RH
318 arg = value_cast (arg_type, arg);
319 }
320 /* Tru64 5.1 has a 128-bit long double, and passes this by
321 invisible reference. No one else uses this data type. */
322 else if (TYPE_LENGTH (arg_type) == 16)
323 {
324 /* Allocate aligned storage. */
325 sp = (sp & -16) - 16;
326
327 /* Write the real data into the stack. */
0fd88904 328 write_memory (sp, value_contents (arg), 16);
c88e30c0
RH
329
330 /* Construct the indirection. */
331 arg_type = lookup_pointer_type (arg_type);
332 arg = value_from_pointer (arg_type, sp);
333 }
334 break;
7b5e1cb3
RH
335
336 case TYPE_CODE_COMPLEX:
337 /* ??? The ABI says that complex values are passed as two
338 separate scalar values. This distinction only matters
339 for complex float. However, GCC does not implement this. */
340
341 /* Tru64 5.1 has a 128-bit long double, and passes this by
342 invisible reference. */
343 if (TYPE_LENGTH (arg_type) == 32)
344 {
345 /* Allocate aligned storage. */
346 sp = (sp & -16) - 16;
347
348 /* Write the real data into the stack. */
0fd88904 349 write_memory (sp, value_contents (arg), 32);
7b5e1cb3
RH
350
351 /* Construct the indirection. */
352 arg_type = lookup_pointer_type (arg_type);
353 arg = value_from_pointer (arg_type, sp);
354 }
355 break;
356
d2427a71
RH
357 default:
358 break;
c906108c 359 }
d2427a71
RH
360 m_arg->len = TYPE_LENGTH (arg_type);
361 m_arg->offset = accumulate_size;
362 accumulate_size = (accumulate_size + m_arg->len + 7) & ~7;
0fd88904 363 m_arg->contents = value_contents_writeable (arg);
c906108c
SS
364 }
365
d2427a71
RH
366 /* Determine required argument register loads, loading an argument register
367 is expensive as it uses three ptrace calls. */
368 required_arg_regs = accumulate_size / 8;
369 if (required_arg_regs > ALPHA_NUM_ARG_REGS)
370 required_arg_regs = ALPHA_NUM_ARG_REGS;
c906108c 371
d2427a71 372 /* Make room for the arguments on the stack. */
c88e30c0
RH
373 if (accumulate_size < sizeof(arg_reg_buffer))
374 accumulate_size = 0;
375 else
376 accumulate_size -= sizeof(arg_reg_buffer);
d2427a71 377 sp -= accumulate_size;
c906108c 378
c88e30c0 379 /* Keep sp aligned to a multiple of 16 as the ABI requires. */
d2427a71 380 sp &= ~15;
c906108c 381
d2427a71
RH
382 /* `Push' arguments on the stack. */
383 for (i = nargs; m_arg--, --i >= 0;)
c906108c 384 {
2a1ce6ec 385 gdb_byte *contents = m_arg->contents;
c88e30c0
RH
386 int offset = m_arg->offset;
387 int len = m_arg->len;
388
389 /* Copy the bytes destined for registers into arg_reg_buffer. */
390 if (offset < sizeof(arg_reg_buffer))
391 {
392 if (offset + len <= sizeof(arg_reg_buffer))
393 {
394 memcpy (arg_reg_buffer + offset, contents, len);
395 continue;
396 }
397 else
398 {
399 int tlen = sizeof(arg_reg_buffer) - offset;
400 memcpy (arg_reg_buffer + offset, contents, tlen);
401 offset += tlen;
402 contents += tlen;
403 len -= tlen;
404 }
405 }
406
407 /* Everything else goes to the stack. */
408 write_memory (sp + offset - sizeof(arg_reg_buffer), contents, len);
c906108c 409 }
c88e30c0
RH
410 if (struct_return)
411 store_unsigned_integer (arg_reg_buffer, ALPHA_REGISTER_SIZE, struct_addr);
c906108c 412
d2427a71
RH
413 /* Load the argument registers. */
414 for (i = 0; i < required_arg_regs; i++)
415 {
09cc52fd
RH
416 regcache_cooked_write (regcache, ALPHA_A0_REGNUM + i,
417 arg_reg_buffer + i*ALPHA_REGISTER_SIZE);
418 regcache_cooked_write (regcache, ALPHA_FPA0_REGNUM + i,
419 arg_reg_buffer + i*ALPHA_REGISTER_SIZE);
d2427a71 420 }
c906108c 421
09cc52fd
RH
422 /* Finally, update the stack pointer. */
423 regcache_cooked_write_signed (regcache, ALPHA_SP_REGNUM, sp);
424
c88e30c0 425 return sp;
c906108c
SS
426}
427
5ec2bb99
RH
428/* Extract from REGCACHE the value about to be returned from a function
429 and copy it into VALBUF. */
d2427a71 430
dc129d82 431static void
5ec2bb99 432alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
5b819568 433 gdb_byte *valbuf)
140f9984 434{
7b5e1cb3 435 int length = TYPE_LENGTH (valtype);
2a1ce6ec 436 gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
5ec2bb99
RH
437 ULONGEST l;
438
439 switch (TYPE_CODE (valtype))
440 {
441 case TYPE_CODE_FLT:
7b5e1cb3 442 switch (length)
5ec2bb99
RH
443 {
444 case 4:
445 regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, raw_buffer);
c483c494 446 alpha_sts (valbuf, raw_buffer);
5ec2bb99
RH
447 break;
448
449 case 8:
450 regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, valbuf);
451 break;
452
24064b5c
RH
453 case 16:
454 regcache_cooked_read_unsigned (regcache, ALPHA_V0_REGNUM, &l);
455 read_memory (l, valbuf, 16);
456 break;
457
5ec2bb99 458 default:
323e0a4a 459 internal_error (__FILE__, __LINE__, _("unknown floating point width"));
5ec2bb99
RH
460 }
461 break;
462
7b5e1cb3
RH
463 case TYPE_CODE_COMPLEX:
464 switch (length)
465 {
466 case 8:
467 /* ??? This isn't correct wrt the ABI, but it's what GCC does. */
468 regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, valbuf);
469 break;
470
471 case 16:
472 regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, valbuf);
2a1ce6ec 473 regcache_cooked_read (regcache, ALPHA_FP0_REGNUM + 1, valbuf + 8);
7b5e1cb3
RH
474 break;
475
476 case 32:
477 regcache_cooked_read_signed (regcache, ALPHA_V0_REGNUM, &l);
478 read_memory (l, valbuf, 32);
479 break;
480
481 default:
323e0a4a 482 internal_error (__FILE__, __LINE__, _("unknown floating point width"));
7b5e1cb3
RH
483 }
484 break;
485
5ec2bb99
RH
486 default:
487 /* Assume everything else degenerates to an integer. */
488 regcache_cooked_read_unsigned (regcache, ALPHA_V0_REGNUM, &l);
7b5e1cb3 489 store_unsigned_integer (valbuf, length, l);
5ec2bb99
RH
490 break;
491 }
140f9984
JT
492}
493
5ec2bb99
RH
494/* Insert the given value into REGCACHE as if it was being
495 returned by a function. */
0d056799 496
d2427a71 497static void
5ec2bb99 498alpha_store_return_value (struct type *valtype, struct regcache *regcache,
5b819568 499 const gdb_byte *valbuf)
c906108c 500{
df4df182 501 struct gdbarch *gdbarch = get_regcache_arch (regcache);
d2427a71 502 int length = TYPE_LENGTH (valtype);
2a1ce6ec 503 gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
5ec2bb99 504 ULONGEST l;
d2427a71 505
5ec2bb99 506 switch (TYPE_CODE (valtype))
c906108c 507 {
5ec2bb99
RH
508 case TYPE_CODE_FLT:
509 switch (length)
510 {
511 case 4:
c483c494 512 alpha_lds (raw_buffer, valbuf);
f75d70cc
RH
513 regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, raw_buffer);
514 break;
5ec2bb99
RH
515
516 case 8:
517 regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, valbuf);
518 break;
519
24064b5c
RH
520 case 16:
521 /* FIXME: 128-bit long doubles are returned like structures:
522 by writing into indirect storage provided by the caller
523 as the first argument. */
323e0a4a 524 error (_("Cannot set a 128-bit long double return value."));
24064b5c 525
5ec2bb99 526 default:
323e0a4a 527 internal_error (__FILE__, __LINE__, _("unknown floating point width"));
5ec2bb99
RH
528 }
529 break;
d2427a71 530
7b5e1cb3
RH
531 case TYPE_CODE_COMPLEX:
532 switch (length)
533 {
534 case 8:
535 /* ??? This isn't correct wrt the ABI, but it's what GCC does. */
536 regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, valbuf);
537 break;
538
539 case 16:
540 regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, valbuf);
2a1ce6ec 541 regcache_cooked_write (regcache, ALPHA_FP0_REGNUM + 1, valbuf + 8);
7b5e1cb3
RH
542 break;
543
544 case 32:
545 /* FIXME: 128-bit long doubles are returned like structures:
546 by writing into indirect storage provided by the caller
547 as the first argument. */
323e0a4a 548 error (_("Cannot set a 128-bit long double return value."));
7b5e1cb3
RH
549
550 default:
323e0a4a 551 internal_error (__FILE__, __LINE__, _("unknown floating point width"));
7b5e1cb3
RH
552 }
553 break;
554
5ec2bb99
RH
555 default:
556 /* Assume everything else degenerates to an integer. */
0ede8eca
RH
557 /* 32-bit values must be sign-extended to 64 bits
558 even if the base data type is unsigned. */
559 if (length == 4)
df4df182 560 valtype = builtin_type (gdbarch)->builtin_int32;
5ec2bb99
RH
561 l = unpack_long (valtype, valbuf);
562 regcache_cooked_write_unsigned (regcache, ALPHA_V0_REGNUM, l);
563 break;
564 }
c906108c
SS
565}
566
9823e921 567static enum return_value_convention
c055b101
CV
568alpha_return_value (struct gdbarch *gdbarch, struct type *func_type,
569 struct type *type, struct regcache *regcache,
570 gdb_byte *readbuf, const gdb_byte *writebuf)
9823e921
RH
571{
572 enum type_code code = TYPE_CODE (type);
573
574 if ((code == TYPE_CODE_STRUCT
575 || code == TYPE_CODE_UNION
576 || code == TYPE_CODE_ARRAY)
577 && gdbarch_tdep (gdbarch)->return_in_memory (type))
578 {
579 if (readbuf)
580 {
581 ULONGEST addr;
582 regcache_raw_read_unsigned (regcache, ALPHA_V0_REGNUM, &addr);
583 read_memory (addr, readbuf, TYPE_LENGTH (type));
584 }
585
586 return RETURN_VALUE_ABI_RETURNS_ADDRESS;
587 }
588
589 if (readbuf)
590 alpha_extract_return_value (type, regcache, readbuf);
591 if (writebuf)
592 alpha_store_return_value (type, regcache, writebuf);
593
594 return RETURN_VALUE_REGISTER_CONVENTION;
595}
596
597static int
598alpha_return_in_memory_always (struct type *type)
599{
600 return 1;
601}
d2427a71 602\f
2a1ce6ec 603static const gdb_byte *
67d57894 604alpha_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
c906108c 605{
2a1ce6ec 606 static const gdb_byte break_insn[] = { 0x80, 0, 0, 0 }; /* call_pal bpt */
c906108c 607
2a1ce6ec
MK
608 *len = sizeof(break_insn);
609 return break_insn;
d2427a71 610}
c906108c 611
d2427a71
RH
612\f
613/* This returns the PC of the first insn after the prologue.
614 If we can't find the prologue, then return 0. */
c906108c 615
d2427a71
RH
616CORE_ADDR
617alpha_after_prologue (CORE_ADDR pc)
c906108c 618{
d2427a71
RH
619 struct symtab_and_line sal;
620 CORE_ADDR func_addr, func_end;
c906108c 621
d2427a71 622 if (!find_pc_partial_function (pc, NULL, &func_addr, &func_end))
c5aa993b 623 return 0;
c906108c 624
d2427a71
RH
625 sal = find_pc_line (func_addr, 0);
626 if (sal.end < func_end)
627 return sal.end;
c5aa993b 628
d2427a71
RH
629 /* The line after the prologue is after the end of the function. In this
630 case, tell the caller to find the prologue the hard way. */
631 return 0;
c906108c
SS
632}
633
d2427a71
RH
634/* Read an instruction from memory at PC, looking through breakpoints. */
635
636unsigned int
637alpha_read_insn (CORE_ADDR pc)
c906108c 638{
e8d2d628 639 gdb_byte buf[ALPHA_INSN_SIZE];
d2427a71 640 int status;
c5aa993b 641
8defab1a 642 status = target_read_memory (pc, buf, sizeof (buf));
d2427a71
RH
643 if (status)
644 memory_error (status, pc);
e8d2d628 645 return extract_unsigned_integer (buf, sizeof (buf));
d2427a71 646}
c5aa993b 647
d2427a71
RH
648/* To skip prologues, I use this predicate. Returns either PC itself
649 if the code at PC does not look like a function prologue; otherwise
650 returns an address that (if we're lucky) follows the prologue. If
651 LENIENT, then we must skip everything which is involved in setting
652 up the frame (it's OK to skip more, just so long as we don't skip
653 anything which might clobber the registers which are being saved. */
c906108c 654
d2427a71 655static CORE_ADDR
6093d2eb 656alpha_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
d2427a71
RH
657{
658 unsigned long inst;
659 int offset;
660 CORE_ADDR post_prologue_pc;
e8d2d628 661 gdb_byte buf[ALPHA_INSN_SIZE];
c906108c 662
d2427a71
RH
663 /* Silently return the unaltered pc upon memory errors.
664 This could happen on OSF/1 if decode_line_1 tries to skip the
665 prologue for quickstarted shared library functions when the
666 shared library is not yet mapped in.
667 Reading target memory is slow over serial lines, so we perform
668 this check only if the target has shared libraries (which all
669 Alpha targets do). */
e8d2d628 670 if (target_read_memory (pc, buf, sizeof (buf)))
d2427a71 671 return pc;
c906108c 672
d2427a71
RH
673 /* See if we can determine the end of the prologue via the symbol table.
674 If so, then return either PC, or the PC after the prologue, whichever
675 is greater. */
c906108c 676
d2427a71
RH
677 post_prologue_pc = alpha_after_prologue (pc);
678 if (post_prologue_pc != 0)
679 return max (pc, post_prologue_pc);
c906108c 680
d2427a71
RH
681 /* Can't determine prologue from the symbol table, need to examine
682 instructions. */
dc1b0db2 683
d2427a71
RH
684 /* Skip the typical prologue instructions. These are the stack adjustment
685 instruction and the instructions that save registers on the stack
686 or in the gcc frame. */
e8d2d628 687 for (offset = 0; offset < 100; offset += ALPHA_INSN_SIZE)
d2427a71
RH
688 {
689 inst = alpha_read_insn (pc + offset);
c906108c 690
d2427a71
RH
691 if ((inst & 0xffff0000) == 0x27bb0000) /* ldah $gp,n($t12) */
692 continue;
693 if ((inst & 0xffff0000) == 0x23bd0000) /* lda $gp,n($gp) */
694 continue;
695 if ((inst & 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */
696 continue;
697 if ((inst & 0xffe01fff) == 0x43c0153e) /* subq $sp,n,$sp */
698 continue;
c906108c 699
d2427a71
RH
700 if (((inst & 0xfc1f0000) == 0xb41e0000 /* stq reg,n($sp) */
701 || (inst & 0xfc1f0000) == 0x9c1e0000) /* stt reg,n($sp) */
702 && (inst & 0x03e00000) != 0x03e00000) /* reg != $zero */
703 continue;
c906108c 704
d2427a71
RH
705 if (inst == 0x47de040f) /* bis sp,sp,fp */
706 continue;
707 if (inst == 0x47fe040f) /* bis zero,sp,fp */
708 continue;
c906108c 709
d2427a71 710 break;
c906108c 711 }
d2427a71
RH
712 return pc + offset;
713}
c906108c 714
d2427a71
RH
715\f
716/* Figure out where the longjmp will land.
717 We expect the first arg to be a pointer to the jmp_buf structure from
718 which we extract the PC (JB_PC) that we will land at. The PC is copied
719 into the "pc". This routine returns true on success. */
c906108c
SS
720
721static int
60ade65d 722alpha_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
c906108c 723{
60ade65d 724 struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
d2427a71 725 CORE_ADDR jb_addr;
2a1ce6ec 726 gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
c906108c 727
60ade65d 728 jb_addr = get_frame_register_unsigned (frame, ALPHA_A0_REGNUM);
c906108c 729
d2427a71
RH
730 if (target_read_memory (jb_addr + (tdep->jb_pc * tdep->jb_elt_size),
731 raw_buffer, tdep->jb_elt_size))
c906108c 732 return 0;
d2427a71 733
7c0b4a20 734 *pc = extract_unsigned_integer (raw_buffer, tdep->jb_elt_size);
d2427a71 735 return 1;
c906108c
SS
736}
737
d2427a71
RH
738\f
739/* Frame unwinder for signal trampolines. We use alpha tdep bits that
740 describe the location and shape of the sigcontext structure. After
741 that, all registers are in memory, so it's easy. */
742/* ??? Shouldn't we be able to do this generically, rather than with
743 OSABI data specific to Alpha? */
744
745struct alpha_sigtramp_unwind_cache
c906108c 746{
d2427a71
RH
747 CORE_ADDR sigcontext_addr;
748};
c906108c 749
d2427a71 750static struct alpha_sigtramp_unwind_cache *
6834c9bb 751alpha_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
d2427a71
RH
752 void **this_prologue_cache)
753{
754 struct alpha_sigtramp_unwind_cache *info;
755 struct gdbarch_tdep *tdep;
c906108c 756
d2427a71
RH
757 if (*this_prologue_cache)
758 return *this_prologue_cache;
c906108c 759
d2427a71
RH
760 info = FRAME_OBSTACK_ZALLOC (struct alpha_sigtramp_unwind_cache);
761 *this_prologue_cache = info;
c906108c 762
6834c9bb
JB
763 tdep = gdbarch_tdep (get_frame_arch (this_frame));
764 info->sigcontext_addr = tdep->sigcontext_addr (this_frame);
c906108c 765
d2427a71 766 return info;
c906108c
SS
767}
768
138e7be5
MK
769/* Return the address of REGNUM in a sigtramp frame. Since this is
770 all arithmetic, it doesn't seem worthwhile to cache it. */
c5aa993b 771
d2427a71 772static CORE_ADDR
be8626e0
MD
773alpha_sigtramp_register_address (struct gdbarch *gdbarch,
774 CORE_ADDR sigcontext_addr, int regnum)
d2427a71 775{
be8626e0 776 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
138e7be5
MK
777
778 if (regnum >= 0 && regnum < 32)
779 return sigcontext_addr + tdep->sc_regs_offset + regnum * 8;
780 else if (regnum >= ALPHA_FP0_REGNUM && regnum < ALPHA_FP0_REGNUM + 32)
781 return sigcontext_addr + tdep->sc_fpregs_offset + regnum * 8;
782 else if (regnum == ALPHA_PC_REGNUM)
783 return sigcontext_addr + tdep->sc_pc_offset;
c5aa993b 784
d2427a71 785 return 0;
c906108c
SS
786}
787
d2427a71
RH
788/* Given a GDB frame, determine the address of the calling function's
789 frame. This will be used to create a new GDB frame struct. */
140f9984 790
dc129d82 791static void
6834c9bb 792alpha_sigtramp_frame_this_id (struct frame_info *this_frame,
d2427a71
RH
793 void **this_prologue_cache,
794 struct frame_id *this_id)
c906108c 795{
6834c9bb 796 struct gdbarch *gdbarch = get_frame_arch (this_frame);
be8626e0 797 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
d2427a71 798 struct alpha_sigtramp_unwind_cache *info
6834c9bb 799 = alpha_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache);
d2427a71
RH
800 CORE_ADDR stack_addr, code_addr;
801
802 /* If the OSABI couldn't locate the sigcontext, give up. */
803 if (info->sigcontext_addr == 0)
804 return;
805
806 /* If we have dynamic signal trampolines, find their start.
807 If we do not, then we must assume there is a symbol record
808 that can provide the start address. */
d2427a71 809 if (tdep->dynamic_sigtramp_offset)
c906108c 810 {
d2427a71 811 int offset;
6834c9bb 812 code_addr = get_frame_pc (this_frame);
d2427a71
RH
813 offset = tdep->dynamic_sigtramp_offset (code_addr);
814 if (offset >= 0)
815 code_addr -= offset;
c906108c 816 else
d2427a71 817 code_addr = 0;
c906108c 818 }
d2427a71 819 else
6834c9bb 820 code_addr = get_frame_func (this_frame);
c906108c 821
d2427a71 822 /* The stack address is trivially read from the sigcontext. */
be8626e0 823 stack_addr = alpha_sigtramp_register_address (gdbarch, info->sigcontext_addr,
d2427a71 824 ALPHA_SP_REGNUM);
6834c9bb 825 stack_addr = get_frame_memory_unsigned (this_frame, stack_addr,
b21fd293 826 ALPHA_REGISTER_SIZE);
c906108c 827
d2427a71 828 *this_id = frame_id_build (stack_addr, code_addr);
c906108c
SS
829}
830
d2427a71 831/* Retrieve the value of REGNUM in FRAME. Don't give up! */
c906108c 832
6834c9bb
JB
833static struct value *
834alpha_sigtramp_frame_prev_register (struct frame_info *this_frame,
835 void **this_prologue_cache, int regnum)
c906108c 836{
d2427a71 837 struct alpha_sigtramp_unwind_cache *info
6834c9bb 838 = alpha_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache);
d2427a71 839 CORE_ADDR addr;
c906108c 840
d2427a71 841 if (info->sigcontext_addr != 0)
c906108c 842 {
d2427a71 843 /* All integer and fp registers are stored in memory. */
6834c9bb 844 addr = alpha_sigtramp_register_address (get_frame_arch (this_frame),
be8626e0 845 info->sigcontext_addr, regnum);
d2427a71 846 if (addr != 0)
6834c9bb 847 return frame_unwind_got_memory (this_frame, regnum, addr);
c906108c
SS
848 }
849
d2427a71
RH
850 /* This extra register may actually be in the sigcontext, but our
851 current description of it in alpha_sigtramp_frame_unwind_cache
852 doesn't include it. Too bad. Fall back on whatever's in the
853 outer frame. */
6834c9bb 854 return frame_unwind_got_register (this_frame, regnum, regnum);
d2427a71 855}
c906108c 856
6834c9bb
JB
857static int
858alpha_sigtramp_frame_sniffer (const struct frame_unwind *self,
859 struct frame_info *this_frame,
860 void **this_prologue_cache)
d2427a71 861{
6834c9bb
JB
862 struct gdbarch *gdbarch = get_frame_arch (this_frame);
863 CORE_ADDR pc = get_frame_pc (this_frame);
d2427a71 864 char *name;
c906108c 865
f2524b93
AC
866 /* NOTE: cagney/2004-04-30: Do not copy/clone this code. Instead
867 look at tramp-frame.h and other simplier per-architecture
868 sigtramp unwinders. */
869
870 /* We shouldn't even bother to try if the OSABI didn't register a
871 sigcontext_addr handler or pc_in_sigtramp hander. */
ec7cc0e8 872 if (gdbarch_tdep (gdbarch)->sigcontext_addr == NULL)
6834c9bb 873 return 0;
ec7cc0e8 874 if (gdbarch_tdep (gdbarch)->pc_in_sigtramp == NULL)
6834c9bb 875 return 0;
c906108c 876
d2427a71
RH
877 /* Otherwise we should be in a signal frame. */
878 find_pc_partial_function (pc, &name, NULL, NULL);
ec7cc0e8 879 if (gdbarch_tdep (gdbarch)->pc_in_sigtramp (pc, name))
6834c9bb 880 return 1;
c906108c 881
6834c9bb 882 return 0;
c906108c 883}
6834c9bb
JB
884
885static const struct frame_unwind alpha_sigtramp_frame_unwind = {
886 SIGTRAMP_FRAME,
887 alpha_sigtramp_frame_this_id,
888 alpha_sigtramp_frame_prev_register,
889 NULL,
890 alpha_sigtramp_frame_sniffer
891};
892
d2427a71 893\f
c906108c 894
d2427a71
RH
895/* Heuristic_proc_start may hunt through the text section for a long
896 time across a 2400 baud serial line. Allows the user to limit this
897 search. */
898static unsigned int heuristic_fence_post = 0;
c906108c 899
d2427a71
RH
900/* Attempt to locate the start of the function containing PC. We assume that
901 the previous function ends with an about_to_return insn. Not foolproof by
902 any means, since gcc is happy to put the epilogue in the middle of a
903 function. But we're guessing anyway... */
c906108c 904
d2427a71 905static CORE_ADDR
be8626e0 906alpha_heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
d2427a71 907{
be8626e0 908 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
d2427a71
RH
909 CORE_ADDR last_non_nop = pc;
910 CORE_ADDR fence = pc - heuristic_fence_post;
911 CORE_ADDR orig_pc = pc;
fbe586ae 912 CORE_ADDR func;
d6b48e9c 913 struct inferior *inf;
9e0b60a8 914
d2427a71
RH
915 if (pc == 0)
916 return 0;
9e0b60a8 917
fbe586ae
RH
918 /* First see if we can find the start of the function from minimal
919 symbol information. This can succeed with a binary that doesn't
920 have debug info, but hasn't been stripped. */
921 func = get_pc_function_start (pc);
922 if (func)
923 return func;
924
d2427a71
RH
925 if (heuristic_fence_post == UINT_MAX
926 || fence < tdep->vm_min_address)
927 fence = tdep->vm_min_address;
c906108c 928
d2427a71
RH
929 /* Search back for previous return; also stop at a 0, which might be
930 seen for instance before the start of a code section. Don't include
931 nops, since this usually indicates padding between functions. */
e8d2d628 932 for (pc -= ALPHA_INSN_SIZE; pc >= fence; pc -= ALPHA_INSN_SIZE)
c906108c 933 {
d2427a71
RH
934 unsigned int insn = alpha_read_insn (pc);
935 switch (insn)
c906108c 936 {
d2427a71
RH
937 case 0: /* invalid insn */
938 case 0x6bfa8001: /* ret $31,($26),1 */
939 return last_non_nop;
940
941 case 0x2ffe0000: /* unop: ldq_u $31,0($30) */
942 case 0x47ff041f: /* nop: bis $31,$31,$31 */
943 break;
944
945 default:
946 last_non_nop = pc;
947 break;
c906108c 948 }
d2427a71 949 }
c906108c 950
d6b48e9c
PA
951 inf = current_inferior ();
952
d2427a71
RH
953 /* It's not clear to me why we reach this point when stopping quietly,
954 but with this test, at least we don't print out warnings for every
955 child forked (eg, on decstation). 22apr93 rich@cygnus.com. */
d6b48e9c 956 if (inf->stop_soon == NO_STOP_QUIETLY)
d2427a71
RH
957 {
958 static int blurb_printed = 0;
c906108c 959
d2427a71 960 if (fence == tdep->vm_min_address)
323e0a4a 961 warning (_("Hit beginning of text section without finding \
5af949e3 962enclosing function for address %s"), paddress (gdbarch, orig_pc));
c906108c 963 else
323e0a4a 964 warning (_("Hit heuristic-fence-post without finding \
5af949e3 965enclosing function for address %s"), paddress (gdbarch, orig_pc));
c906108c 966
d2427a71
RH
967 if (!blurb_printed)
968 {
323e0a4a 969 printf_filtered (_("\
d2427a71
RH
970This warning occurs if you are debugging a function without any symbols\n\
971(for example, in a stripped executable). In that case, you may wish to\n\
972increase the size of the search with the `set heuristic-fence-post' command.\n\
973\n\
974Otherwise, you told GDB there was a function where there isn't one, or\n\
323e0a4a 975(more likely) you have encountered a bug in GDB.\n"));
d2427a71
RH
976 blurb_printed = 1;
977 }
978 }
c906108c 979
d2427a71
RH
980 return 0;
981}
c906108c 982
07ea644b
MD
983/* Fallback alpha frame unwinder. Uses instruction scanning and knows
984 something about the traditional layout of alpha stack frames. */
985
986struct alpha_heuristic_unwind_cache
987{
988 CORE_ADDR vfp;
989 CORE_ADDR start_pc;
990 struct trad_frame_saved_reg *saved_regs;
991 int return_reg;
992};
993
fbe586ae 994static struct alpha_heuristic_unwind_cache *
6834c9bb 995alpha_heuristic_frame_unwind_cache (struct frame_info *this_frame,
d2427a71
RH
996 void **this_prologue_cache,
997 CORE_ADDR start_pc)
998{
6834c9bb 999 struct gdbarch *gdbarch = get_frame_arch (this_frame);
d2427a71
RH
1000 struct alpha_heuristic_unwind_cache *info;
1001 ULONGEST val;
1002 CORE_ADDR limit_pc, cur_pc;
1003 int frame_reg, frame_size, return_reg, reg;
c906108c 1004
d2427a71
RH
1005 if (*this_prologue_cache)
1006 return *this_prologue_cache;
c906108c 1007
d2427a71
RH
1008 info = FRAME_OBSTACK_ZALLOC (struct alpha_heuristic_unwind_cache);
1009 *this_prologue_cache = info;
6834c9bb 1010 info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
c906108c 1011
6834c9bb 1012 limit_pc = get_frame_pc (this_frame);
d2427a71 1013 if (start_pc == 0)
be8626e0 1014 start_pc = alpha_heuristic_proc_start (gdbarch, limit_pc);
d2427a71 1015 info->start_pc = start_pc;
c906108c 1016
d2427a71
RH
1017 frame_reg = ALPHA_SP_REGNUM;
1018 frame_size = 0;
1019 return_reg = -1;
c906108c 1020
d2427a71
RH
1021 /* If we've identified a likely place to start, do code scanning. */
1022 if (start_pc != 0)
c5aa993b 1023 {
d2427a71
RH
1024 /* Limit the forward search to 50 instructions. */
1025 if (start_pc + 200 < limit_pc)
1026 limit_pc = start_pc + 200;
c5aa993b 1027
e8d2d628 1028 for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += ALPHA_INSN_SIZE)
d2427a71
RH
1029 {
1030 unsigned int word = alpha_read_insn (cur_pc);
c5aa993b 1031
d2427a71
RH
1032 if ((word & 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */
1033 {
1034 if (word & 0x8000)
1035 {
1036 /* Consider only the first stack allocation instruction
1037 to contain the static size of the frame. */
1038 if (frame_size == 0)
1039 frame_size = (-word) & 0xffff;
1040 }
1041 else
1042 {
1043 /* Exit loop if a positive stack adjustment is found, which
1044 usually means that the stack cleanup code in the function
1045 epilogue is reached. */
1046 break;
1047 }
1048 }
1049 else if ((word & 0xfc1f0000) == 0xb41e0000) /* stq reg,n($sp) */
1050 {
1051 reg = (word & 0x03e00000) >> 21;
1052
d15bfd3a
AC
1053 /* Ignore this instruction if we have already encountered
1054 an instruction saving the same register earlier in the
1055 function code. The current instruction does not tell
1056 us where the original value upon function entry is saved.
1057 All it says is that the function we are scanning reused
1058 that register for some computation of its own, and is now
1059 saving its result. */
07ea644b 1060 if (trad_frame_addr_p(info->saved_regs, reg))
d15bfd3a
AC
1061 continue;
1062
d2427a71
RH
1063 if (reg == 31)
1064 continue;
1065
1066 /* Do not compute the address where the register was saved yet,
1067 because we don't know yet if the offset will need to be
1068 relative to $sp or $fp (we can not compute the address
1069 relative to $sp if $sp is updated during the execution of
1070 the current subroutine, for instance when doing some alloca).
1071 So just store the offset for the moment, and compute the
1072 address later when we know whether this frame has a frame
1073 pointer or not. */
1074 /* Hack: temporarily add one, so that the offset is non-zero
1075 and we can tell which registers have save offsets below. */
07ea644b 1076 info->saved_regs[reg].addr = (word & 0xffff) + 1;
d2427a71
RH
1077
1078 /* Starting with OSF/1-3.2C, the system libraries are shipped
1079 without local symbols, but they still contain procedure
1080 descriptors without a symbol reference. GDB is currently
1081 unable to find these procedure descriptors and uses
1082 heuristic_proc_desc instead.
1083 As some low level compiler support routines (__div*, __add*)
1084 use a non-standard return address register, we have to
1085 add some heuristics to determine the return address register,
1086 or stepping over these routines will fail.
1087 Usually the return address register is the first register
1088 saved on the stack, but assembler optimization might
1089 rearrange the register saves.
1090 So we recognize only a few registers (t7, t9, ra) within
1091 the procedure prologue as valid return address registers.
1092 If we encounter a return instruction, we extract the
1093 the return address register from it.
1094
1095 FIXME: Rewriting GDB to access the procedure descriptors,
1096 e.g. via the minimal symbol table, might obviate this hack. */
1097 if (return_reg == -1
1098 && cur_pc < (start_pc + 80)
1099 && (reg == ALPHA_T7_REGNUM
1100 || reg == ALPHA_T9_REGNUM
1101 || reg == ALPHA_RA_REGNUM))
1102 return_reg = reg;
1103 }
1104 else if ((word & 0xffe0ffff) == 0x6be08001) /* ret zero,reg,1 */
1105 return_reg = (word >> 16) & 0x1f;
1106 else if (word == 0x47de040f) /* bis sp,sp,fp */
1107 frame_reg = ALPHA_GCC_FP_REGNUM;
1108 else if (word == 0x47fe040f) /* bis zero,sp,fp */
1109 frame_reg = ALPHA_GCC_FP_REGNUM;
1110 }
c5aa993b 1111
d2427a71
RH
1112 /* If we haven't found a valid return address register yet, keep
1113 searching in the procedure prologue. */
1114 if (return_reg == -1)
1115 {
1116 while (cur_pc < (limit_pc + 80) && cur_pc < (start_pc + 80))
1117 {
1118 unsigned int word = alpha_read_insn (cur_pc);
c5aa993b 1119
d2427a71
RH
1120 if ((word & 0xfc1f0000) == 0xb41e0000) /* stq reg,n($sp) */
1121 {
1122 reg = (word & 0x03e00000) >> 21;
1123 if (reg == ALPHA_T7_REGNUM
1124 || reg == ALPHA_T9_REGNUM
1125 || reg == ALPHA_RA_REGNUM)
1126 {
1127 return_reg = reg;
1128 break;
1129 }
1130 }
1131 else if ((word & 0xffe0ffff) == 0x6be08001) /* ret zero,reg,1 */
1132 {
1133 return_reg = (word >> 16) & 0x1f;
1134 break;
1135 }
85b32d22 1136
e8d2d628 1137 cur_pc += ALPHA_INSN_SIZE;
d2427a71
RH
1138 }
1139 }
c906108c 1140 }
c906108c 1141
d2427a71
RH
1142 /* Failing that, do default to the customary RA. */
1143 if (return_reg == -1)
1144 return_reg = ALPHA_RA_REGNUM;
1145 info->return_reg = return_reg;
f8453e34 1146
6834c9bb 1147 val = get_frame_register_unsigned (this_frame, frame_reg);
d2427a71 1148 info->vfp = val + frame_size;
c906108c 1149
d2427a71
RH
1150 /* Convert offsets to absolute addresses. See above about adding
1151 one to the offsets to make all detected offsets non-zero. */
1152 for (reg = 0; reg < ALPHA_NUM_REGS; ++reg)
07ea644b
MD
1153 if (trad_frame_addr_p(info->saved_regs, reg))
1154 info->saved_regs[reg].addr += val - 1;
d2427a71 1155
bfd66dd9
JB
1156 /* The stack pointer of the previous frame is computed by popping
1157 the current stack frame. */
1158 if (!trad_frame_addr_p (info->saved_regs, ALPHA_SP_REGNUM))
1159 trad_frame_set_value (info->saved_regs, ALPHA_SP_REGNUM, info->vfp);
1160
d2427a71 1161 return info;
c906108c 1162}
c906108c 1163
d2427a71
RH
1164/* Given a GDB frame, determine the address of the calling function's
1165 frame. This will be used to create a new GDB frame struct. */
1166
fbe586ae 1167static void
6834c9bb
JB
1168alpha_heuristic_frame_this_id (struct frame_info *this_frame,
1169 void **this_prologue_cache,
1170 struct frame_id *this_id)
c906108c 1171{
d2427a71 1172 struct alpha_heuristic_unwind_cache *info
6834c9bb 1173 = alpha_heuristic_frame_unwind_cache (this_frame, this_prologue_cache, 0);
c906108c 1174
d2427a71 1175 *this_id = frame_id_build (info->vfp, info->start_pc);
c906108c
SS
1176}
1177
d2427a71
RH
1178/* Retrieve the value of REGNUM in FRAME. Don't give up! */
1179
6834c9bb
JB
1180static struct value *
1181alpha_heuristic_frame_prev_register (struct frame_info *this_frame,
1182 void **this_prologue_cache, int regnum)
c906108c 1183{
d2427a71 1184 struct alpha_heuristic_unwind_cache *info
6834c9bb 1185 = alpha_heuristic_frame_unwind_cache (this_frame, this_prologue_cache, 0);
d2427a71
RH
1186
1187 /* The PC of the previous frame is stored in the link register of
1188 the current frame. Frob regnum so that we pull the value from
1189 the correct place. */
1190 if (regnum == ALPHA_PC_REGNUM)
1191 regnum = info->return_reg;
1192
6834c9bb 1193 return trad_frame_get_prev_register (this_frame, info->saved_regs, regnum);
95b80706
JT
1194}
1195
d2427a71
RH
1196static const struct frame_unwind alpha_heuristic_frame_unwind = {
1197 NORMAL_FRAME,
1198 alpha_heuristic_frame_this_id,
6834c9bb
JB
1199 alpha_heuristic_frame_prev_register,
1200 NULL,
1201 default_frame_sniffer
d2427a71 1202};
c906108c 1203
fbe586ae 1204static CORE_ADDR
6834c9bb 1205alpha_heuristic_frame_base_address (struct frame_info *this_frame,
d2427a71 1206 void **this_prologue_cache)
c906108c 1207{
d2427a71 1208 struct alpha_heuristic_unwind_cache *info
6834c9bb 1209 = alpha_heuristic_frame_unwind_cache (this_frame, this_prologue_cache, 0);
c906108c 1210
d2427a71 1211 return info->vfp;
c906108c
SS
1212}
1213
d2427a71
RH
1214static const struct frame_base alpha_heuristic_frame_base = {
1215 &alpha_heuristic_frame_unwind,
1216 alpha_heuristic_frame_base_address,
1217 alpha_heuristic_frame_base_address,
1218 alpha_heuristic_frame_base_address
1219};
1220
c906108c 1221/* Just like reinit_frame_cache, but with the right arguments to be
d2427a71 1222 callable as an sfunc. Used by the "set heuristic-fence-post" command. */
c906108c
SS
1223
1224static void
fba45db2 1225reinit_frame_cache_sfunc (char *args, int from_tty, struct cmd_list_element *c)
c906108c
SS
1226{
1227 reinit_frame_cache ();
1228}
1229
d2427a71 1230\f
d2427a71
RH
1231/* Assuming NEXT_FRAME->prev is a dummy, return the frame ID of that
1232 dummy frame. The frame ID's base needs to match the TOS value
1233 saved by save_dummy_frame_tos(), and the PC match the dummy frame's
1234 breakpoint. */
d734c450 1235
d2427a71 1236static struct frame_id
6834c9bb 1237alpha_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
0d056799 1238{
d2427a71 1239 ULONGEST base;
6834c9bb
JB
1240 base = get_frame_register_unsigned (this_frame, ALPHA_SP_REGNUM);
1241 return frame_id_build (base, get_frame_pc (this_frame));
0d056799
JT
1242}
1243
dc129d82 1244static CORE_ADDR
d2427a71 1245alpha_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
accc6d1f 1246{
d2427a71 1247 ULONGEST pc;
11411de3 1248 pc = frame_unwind_register_unsigned (next_frame, ALPHA_PC_REGNUM);
d2427a71 1249 return pc;
accc6d1f
JT
1250}
1251
98a8e1e5
RH
1252\f
1253/* Helper routines for alpha*-nat.c files to move register sets to and
1254 from core files. The UNIQUE pointer is allowed to be NULL, as most
1255 targets don't supply this value in their core files. */
1256
1257void
390c1522
UW
1258alpha_supply_int_regs (struct regcache *regcache, int regno,
1259 const void *r0_r30, const void *pc, const void *unique)
98a8e1e5 1260{
2a1ce6ec 1261 const gdb_byte *regs = r0_r30;
98a8e1e5
RH
1262 int i;
1263
1264 for (i = 0; i < 31; ++i)
1265 if (regno == i || regno == -1)
390c1522 1266 regcache_raw_supply (regcache, i, regs + i * 8);
98a8e1e5
RH
1267
1268 if (regno == ALPHA_ZERO_REGNUM || regno == -1)
390c1522 1269 regcache_raw_supply (regcache, ALPHA_ZERO_REGNUM, NULL);
98a8e1e5
RH
1270
1271 if (regno == ALPHA_PC_REGNUM || regno == -1)
390c1522 1272 regcache_raw_supply (regcache, ALPHA_PC_REGNUM, pc);
98a8e1e5
RH
1273
1274 if (regno == ALPHA_UNIQUE_REGNUM || regno == -1)
390c1522 1275 regcache_raw_supply (regcache, ALPHA_UNIQUE_REGNUM, unique);
98a8e1e5
RH
1276}
1277
1278void
390c1522
UW
1279alpha_fill_int_regs (const struct regcache *regcache,
1280 int regno, void *r0_r30, void *pc, void *unique)
98a8e1e5 1281{
2a1ce6ec 1282 gdb_byte *regs = r0_r30;
98a8e1e5
RH
1283 int i;
1284
1285 for (i = 0; i < 31; ++i)
1286 if (regno == i || regno == -1)
390c1522 1287 regcache_raw_collect (regcache, i, regs + i * 8);
98a8e1e5
RH
1288
1289 if (regno == ALPHA_PC_REGNUM || regno == -1)
390c1522 1290 regcache_raw_collect (regcache, ALPHA_PC_REGNUM, pc);
98a8e1e5
RH
1291
1292 if (unique && (regno == ALPHA_UNIQUE_REGNUM || regno == -1))
390c1522 1293 regcache_raw_collect (regcache, ALPHA_UNIQUE_REGNUM, unique);
98a8e1e5
RH
1294}
1295
1296void
390c1522
UW
1297alpha_supply_fp_regs (struct regcache *regcache, int regno,
1298 const void *f0_f30, const void *fpcr)
98a8e1e5 1299{
2a1ce6ec 1300 const gdb_byte *regs = f0_f30;
98a8e1e5
RH
1301 int i;
1302
1303 for (i = ALPHA_FP0_REGNUM; i < ALPHA_FP0_REGNUM + 31; ++i)
1304 if (regno == i || regno == -1)
390c1522 1305 regcache_raw_supply (regcache, i,
2a1ce6ec 1306 regs + (i - ALPHA_FP0_REGNUM) * 8);
98a8e1e5
RH
1307
1308 if (regno == ALPHA_FPCR_REGNUM || regno == -1)
390c1522 1309 regcache_raw_supply (regcache, ALPHA_FPCR_REGNUM, fpcr);
98a8e1e5
RH
1310}
1311
1312void
390c1522
UW
1313alpha_fill_fp_regs (const struct regcache *regcache,
1314 int regno, void *f0_f30, void *fpcr)
98a8e1e5 1315{
2a1ce6ec 1316 gdb_byte *regs = f0_f30;
98a8e1e5
RH
1317 int i;
1318
1319 for (i = ALPHA_FP0_REGNUM; i < ALPHA_FP0_REGNUM + 31; ++i)
1320 if (regno == i || regno == -1)
390c1522 1321 regcache_raw_collect (regcache, i,
2a1ce6ec 1322 regs + (i - ALPHA_FP0_REGNUM) * 8);
98a8e1e5
RH
1323
1324 if (regno == ALPHA_FPCR_REGNUM || regno == -1)
390c1522 1325 regcache_raw_collect (regcache, ALPHA_FPCR_REGNUM, fpcr);
98a8e1e5
RH
1326}
1327
d2427a71 1328\f
0de94d4b
JB
1329
1330/* Return nonzero if the G_floating register value in REG is equal to
1331 zero for FP control instructions. */
1332
1333static int
1334fp_register_zero_p (LONGEST reg)
1335{
1336 /* Check that all bits except the sign bit are zero. */
1337 const LONGEST zero_mask = ((LONGEST) 1 << 63) ^ -1;
1338
1339 return ((reg & zero_mask) == 0);
1340}
1341
1342/* Return the value of the sign bit for the G_floating register
1343 value held in REG. */
1344
1345static int
1346fp_register_sign_bit (LONGEST reg)
1347{
1348 const LONGEST sign_mask = (LONGEST) 1 << 63;
1349
1350 return ((reg & sign_mask) != 0);
1351}
1352
ec32e4be
JT
1353/* alpha_software_single_step() is called just before we want to resume
1354 the inferior, if we want to single-step it but there is no hardware
1355 or kernel single-step support (NetBSD on Alpha, for example). We find
e0cd558a 1356 the target of the coming instruction and breakpoint it. */
ec32e4be
JT
1357
1358static CORE_ADDR
0b1b3e42 1359alpha_next_pc (struct frame_info *frame, CORE_ADDR pc)
ec32e4be
JT
1360{
1361 unsigned int insn;
1362 unsigned int op;
551e4f2e 1363 int regno;
ec32e4be
JT
1364 int offset;
1365 LONGEST rav;
1366
b21fd293 1367 insn = alpha_read_insn (pc);
ec32e4be
JT
1368
1369 /* Opcode is top 6 bits. */
1370 op = (insn >> 26) & 0x3f;
1371
1372 if (op == 0x1a)
1373 {
1374 /* Jump format: target PC is:
1375 RB & ~3 */
0b1b3e42 1376 return (get_frame_register_unsigned (frame, (insn >> 16) & 0x1f) & ~3);
ec32e4be
JT
1377 }
1378
1379 if ((op & 0x30) == 0x30)
1380 {
1381 /* Branch format: target PC is:
1382 (new PC) + (4 * sext(displacement)) */
1383 if (op == 0x30 || /* BR */
1384 op == 0x34) /* BSR */
1385 {
1386 branch_taken:
1387 offset = (insn & 0x001fffff);
1388 if (offset & 0x00100000)
1389 offset |= 0xffe00000;
e8d2d628
MK
1390 offset *= ALPHA_INSN_SIZE;
1391 return (pc + ALPHA_INSN_SIZE + offset);
ec32e4be
JT
1392 }
1393
1394 /* Need to determine if branch is taken; read RA. */
551e4f2e
JB
1395 regno = (insn >> 21) & 0x1f;
1396 switch (op)
1397 {
1398 case 0x31: /* FBEQ */
1399 case 0x36: /* FBGE */
1400 case 0x37: /* FBGT */
1401 case 0x33: /* FBLE */
1402 case 0x32: /* FBLT */
1403 case 0x35: /* FBNE */
ec7cc0e8 1404 regno += gdbarch_fp0_regnum (get_frame_arch (frame));
551e4f2e
JB
1405 }
1406
0b1b3e42 1407 rav = get_frame_register_signed (frame, regno);
0de94d4b 1408
ec32e4be
JT
1409 switch (op)
1410 {
1411 case 0x38: /* BLBC */
1412 if ((rav & 1) == 0)
1413 goto branch_taken;
1414 break;
1415 case 0x3c: /* BLBS */
1416 if (rav & 1)
1417 goto branch_taken;
1418 break;
1419 case 0x39: /* BEQ */
1420 if (rav == 0)
1421 goto branch_taken;
1422 break;
1423 case 0x3d: /* BNE */
1424 if (rav != 0)
1425 goto branch_taken;
1426 break;
1427 case 0x3a: /* BLT */
1428 if (rav < 0)
1429 goto branch_taken;
1430 break;
1431 case 0x3b: /* BLE */
1432 if (rav <= 0)
1433 goto branch_taken;
1434 break;
1435 case 0x3f: /* BGT */
1436 if (rav > 0)
1437 goto branch_taken;
1438 break;
1439 case 0x3e: /* BGE */
1440 if (rav >= 0)
1441 goto branch_taken;
1442 break;
d2427a71 1443
0de94d4b
JB
1444 /* Floating point branches. */
1445
1446 case 0x31: /* FBEQ */
1447 if (fp_register_zero_p (rav))
1448 goto branch_taken;
1449 break;
1450 case 0x36: /* FBGE */
1451 if (fp_register_sign_bit (rav) == 0 || fp_register_zero_p (rav))
1452 goto branch_taken;
1453 break;
1454 case 0x37: /* FBGT */
1455 if (fp_register_sign_bit (rav) == 0 && ! fp_register_zero_p (rav))
1456 goto branch_taken;
1457 break;
1458 case 0x33: /* FBLE */
1459 if (fp_register_sign_bit (rav) == 1 || fp_register_zero_p (rav))
1460 goto branch_taken;
1461 break;
1462 case 0x32: /* FBLT */
1463 if (fp_register_sign_bit (rav) == 1 && ! fp_register_zero_p (rav))
1464 goto branch_taken;
1465 break;
1466 case 0x35: /* FBNE */
1467 if (! fp_register_zero_p (rav))
1468 goto branch_taken;
1469 break;
ec32e4be
JT
1470 }
1471 }
1472
1473 /* Not a branch or branch not taken; target PC is:
1474 pc + 4 */
e8d2d628 1475 return (pc + ALPHA_INSN_SIZE);
ec32e4be
JT
1476}
1477
e6590a1b 1478int
0b1b3e42 1479alpha_software_single_step (struct frame_info *frame)
ec32e4be 1480{
a6d9a66e 1481 struct gdbarch *gdbarch = get_frame_arch (frame);
e0cd558a 1482 CORE_ADDR pc, next_pc;
ec32e4be 1483
0b1b3e42
UW
1484 pc = get_frame_pc (frame);
1485 next_pc = alpha_next_pc (frame, pc);
ec32e4be 1486
a6d9a66e 1487 insert_single_step_breakpoint (gdbarch, next_pc);
e6590a1b 1488 return 1;
c906108c
SS
1489}
1490
dc129d82 1491\f
dc129d82
JT
1492/* Initialize the current architecture based on INFO. If possible, re-use an
1493 architecture from ARCHES, which is a list of architectures already created
1494 during this debugging session.
1495
1496 Called e.g. at program startup, when reading a core file, and when reading
1497 a binary file. */
1498
1499static struct gdbarch *
1500alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1501{
1502 struct gdbarch_tdep *tdep;
1503 struct gdbarch *gdbarch;
dc129d82
JT
1504
1505 /* Try to determine the ABI of the object we are loading. */
4be87837 1506 if (info.abfd != NULL && info.osabi == GDB_OSABI_UNKNOWN)
dc129d82 1507 {
4be87837
DJ
1508 /* If it's an ECOFF file, assume it's OSF/1. */
1509 if (bfd_get_flavour (info.abfd) == bfd_target_ecoff_flavour)
aff87235 1510 info.osabi = GDB_OSABI_OSF1;
dc129d82
JT
1511 }
1512
1513 /* Find a candidate among extant architectures. */
4be87837
DJ
1514 arches = gdbarch_list_lookup_by_info (arches, &info);
1515 if (arches != NULL)
1516 return arches->gdbarch;
dc129d82
JT
1517
1518 tdep = xmalloc (sizeof (struct gdbarch_tdep));
1519 gdbarch = gdbarch_alloc (&info, tdep);
1520
d2427a71
RH
1521 /* Lowest text address. This is used by heuristic_proc_start()
1522 to decide when to stop looking. */
594706e6 1523 tdep->vm_min_address = (CORE_ADDR) 0x120000000LL;
d9b023cc 1524
36a6271d 1525 tdep->dynamic_sigtramp_offset = NULL;
5868c862 1526 tdep->sigcontext_addr = NULL;
138e7be5
MK
1527 tdep->sc_pc_offset = 2 * 8;
1528 tdep->sc_regs_offset = 4 * 8;
1529 tdep->sc_fpregs_offset = tdep->sc_regs_offset + 32 * 8 + 8;
36a6271d 1530
accc6d1f
JT
1531 tdep->jb_pc = -1; /* longjmp support not enabled by default */
1532
9823e921
RH
1533 tdep->return_in_memory = alpha_return_in_memory_always;
1534
dc129d82
JT
1535 /* Type sizes */
1536 set_gdbarch_short_bit (gdbarch, 16);
1537 set_gdbarch_int_bit (gdbarch, 32);
1538 set_gdbarch_long_bit (gdbarch, 64);
1539 set_gdbarch_long_long_bit (gdbarch, 64);
1540 set_gdbarch_float_bit (gdbarch, 32);
1541 set_gdbarch_double_bit (gdbarch, 64);
1542 set_gdbarch_long_double_bit (gdbarch, 64);
1543 set_gdbarch_ptr_bit (gdbarch, 64);
1544
1545 /* Register info */
1546 set_gdbarch_num_regs (gdbarch, ALPHA_NUM_REGS);
1547 set_gdbarch_sp_regnum (gdbarch, ALPHA_SP_REGNUM);
dc129d82
JT
1548 set_gdbarch_pc_regnum (gdbarch, ALPHA_PC_REGNUM);
1549 set_gdbarch_fp0_regnum (gdbarch, ALPHA_FP0_REGNUM);
1550
1551 set_gdbarch_register_name (gdbarch, alpha_register_name);
c483c494 1552 set_gdbarch_register_type (gdbarch, alpha_register_type);
dc129d82
JT
1553
1554 set_gdbarch_cannot_fetch_register (gdbarch, alpha_cannot_fetch_register);
1555 set_gdbarch_cannot_store_register (gdbarch, alpha_cannot_store_register);
1556
c483c494
RH
1557 set_gdbarch_convert_register_p (gdbarch, alpha_convert_register_p);
1558 set_gdbarch_register_to_value (gdbarch, alpha_register_to_value);
1559 set_gdbarch_value_to_register (gdbarch, alpha_value_to_register);
dc129d82 1560
615967cb
RH
1561 set_gdbarch_register_reggroup_p (gdbarch, alpha_register_reggroup_p);
1562
d2427a71 1563 /* Prologue heuristics. */
dc129d82
JT
1564 set_gdbarch_skip_prologue (gdbarch, alpha_skip_prologue);
1565
5ef165c2
RH
1566 /* Disassembler. */
1567 set_gdbarch_print_insn (gdbarch, print_insn_alpha);
1568
d2427a71 1569 /* Call info. */
dc129d82 1570
9823e921 1571 set_gdbarch_return_value (gdbarch, alpha_return_value);
dc129d82
JT
1572
1573 /* Settings for calling functions in the inferior. */
c88e30c0 1574 set_gdbarch_push_dummy_call (gdbarch, alpha_push_dummy_call);
d2427a71
RH
1575
1576 /* Methods for saving / extracting a dummy frame's ID. */
6834c9bb 1577 set_gdbarch_dummy_id (gdbarch, alpha_dummy_id);
d2427a71
RH
1578
1579 /* Return the unwound PC value. */
1580 set_gdbarch_unwind_pc (gdbarch, alpha_unwind_pc);
dc129d82
JT
1581
1582 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
36a6271d 1583 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
dc129d82 1584
95b80706 1585 set_gdbarch_breakpoint_from_pc (gdbarch, alpha_breakpoint_from_pc);
e8d2d628 1586 set_gdbarch_decr_pc_after_break (gdbarch, ALPHA_INSN_SIZE);
9d519230 1587 set_gdbarch_cannot_step_breakpoint (gdbarch, 1);
95b80706 1588
44dffaac 1589 /* Hook in ABI-specific overrides, if they have been registered. */
4be87837 1590 gdbarch_init_osabi (info, gdbarch);
44dffaac 1591
accc6d1f
JT
1592 /* Now that we have tuned the configuration, set a few final things
1593 based on what the OS ABI has told us. */
1594
1595 if (tdep->jb_pc >= 0)
1596 set_gdbarch_get_longjmp_target (gdbarch, alpha_get_longjmp_target);
1597
6834c9bb
JB
1598 frame_unwind_append_unwinder (gdbarch, &alpha_sigtramp_frame_unwind);
1599 frame_unwind_append_unwinder (gdbarch, &alpha_heuristic_frame_unwind);
dc129d82 1600
d2427a71 1601 frame_base_set_default (gdbarch, &alpha_heuristic_frame_base);
accc6d1f 1602
d2427a71 1603 return gdbarch;
dc129d82
JT
1604}
1605
baa490c4
RH
1606void
1607alpha_dwarf2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1608{
6834c9bb 1609 dwarf2_append_unwinders (gdbarch);
336d1bba 1610 frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
baa490c4
RH
1611}
1612
a78f21af
AC
1613extern initialize_file_ftype _initialize_alpha_tdep; /* -Wmissing-prototypes */
1614
c906108c 1615void
fba45db2 1616_initialize_alpha_tdep (void)
c906108c
SS
1617{
1618 struct cmd_list_element *c;
1619
d2427a71 1620 gdbarch_register (bfd_arch_alpha, alpha_gdbarch_init, NULL);
c906108c
SS
1621
1622 /* Let the user set the fence post for heuristic_proc_start. */
1623
1624 /* We really would like to have both "0" and "unlimited" work, but
1625 command.c doesn't deal with that. So make it a var_zinteger
1626 because the user can always use "999999" or some such for unlimited. */
edefbb7c
AC
1627 /* We need to throw away the frame cache when we set this, since it
1628 might change our ability to get backtraces. */
1629 add_setshow_zinteger_cmd ("heuristic-fence-post", class_support,
7915a72c
AC
1630 &heuristic_fence_post, _("\
1631Set the distance searched for the start of a function."), _("\
1632Show the distance searched for the start of a function."), _("\
c906108c
SS
1633If you are debugging a stripped executable, GDB needs to search through the\n\
1634program for the start of a function. This command sets the distance of the\n\
323e0a4a 1635search. The only need to set it is when debugging a stripped executable."),
2c5b56ce 1636 reinit_frame_cache_sfunc,
7915a72c 1637 NULL, /* FIXME: i18n: The distance searched for the start of a function is \"%d\". */
edefbb7c 1638 &setlist, &showlist);
c906108c 1639}