* Makefile.in (objfiles.o, symfile.o): Update.
[deliverable/binutils-gdb.git] / gdb / alpha-linux-tdep.c
CommitLineData
3379287a 1/* Target-dependent code for GNU/Linux on Alpha.
197e01b6 2 Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3379287a
JT
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
197e01b6
EZ
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
3379287a
JT
20
21#include "defs.h"
5868c862 22#include "frame.h"
d2427a71 23#include "gdb_assert.h"
f1a559ae 24#include "osabi.h"
b2756930 25#include "solib-svr4.h"
3379287a
JT
26
27#include "alpha-tdep.h"
28
d2427a71
RH
29/* Under GNU/Linux, signal handler invocations can be identified by
30 the designated code sequence that is used to return from a signal
3379287a 31 handler. In particular, the return address of a signal handler
d2427a71
RH
32 points to a sequence that copies $sp to $16, loads $0 with the
33 appropriate syscall number, and finally enters the kernel.
34
35 This is somewhat complicated in that:
36 (1) the expansion of the "mov" assembler macro has changed over
37 time, from "bis src,src,dst" to "bis zero,src,dst",
38 (2) the kernel has changed from using "addq" to "lda" to load the
39 syscall number,
40 (3) there is a "normal" sigreturn and an "rt" sigreturn which
41 has a different stack layout.
42*/
43
44static long
45alpha_linux_sigtramp_offset_1 (CORE_ADDR pc)
3379287a 46{
d2427a71
RH
47 switch (alpha_read_insn (pc))
48 {
49 case 0x47de0410: /* bis $30,$30,$16 */
50 case 0x47fe0410: /* bis $31,$30,$16 */
51 return 0;
3379287a 52
d2427a71
RH
53 case 0x43ecf400: /* addq $31,103,$0 */
54 case 0x201f0067: /* lda $0,103($31) */
55 case 0x201f015f: /* lda $0,351($31) */
56 return 4;
57
58 case 0x00000083: /* call_pal callsys */
59 return 8;
3379287a 60
3379287a
JT
61 default:
62 return -1;
63 }
d2427a71
RH
64}
65
66static LONGEST
67alpha_linux_sigtramp_offset (CORE_ADDR pc)
68{
69 long i, off;
70
71 if (pc & 3)
72 return -1;
73
74 /* Guess where we might be in the sequence. */
75 off = alpha_linux_sigtramp_offset_1 (pc);
76 if (off < 0)
77 return -1;
78
79 /* Verify that the other two insns of the sequence are as we expect. */
3379287a 80 pc -= off;
d2427a71 81 for (i = 0; i < 12; i += 4)
3379287a 82 {
d2427a71
RH
83 if (i == off)
84 continue;
85 if (alpha_linux_sigtramp_offset_1 (pc + i) != i)
86 return -1;
3379287a 87 }
3379287a 88
d2427a71 89 return off;
3379287a
JT
90}
91
6c72f9f9
JT
92static int
93alpha_linux_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
94{
d2427a71 95 return alpha_linux_sigtramp_offset (pc) >= 0;
6c72f9f9
JT
96}
97
5868c862 98static CORE_ADDR
d2427a71 99alpha_linux_sigcontext_addr (struct frame_info *next_frame)
5868c862 100{
d2427a71
RH
101 CORE_ADDR pc;
102 ULONGEST sp;
103 long off;
104
105 pc = frame_pc_unwind (next_frame);
106 frame_unwind_unsigned_register (next_frame, ALPHA_SP_REGNUM, &sp);
107
108 off = alpha_linux_sigtramp_offset (pc);
109 gdb_assert (off >= 0);
110
111 /* __NR_rt_sigreturn has a couple of structures on the stack. This is:
112
113 struct rt_sigframe {
114 struct siginfo info;
115 struct ucontext uc;
116 };
117
118 offsetof (struct rt_sigframe, uc.uc_mcontext);
119 */
120 if (alpha_read_insn (pc - off + 4) == 0x201f015f)
121 return sp + 176;
122
123 /* __NR_sigreturn has the sigcontext structure at the top of the stack. */
124 return sp;
5868c862
JT
125}
126
3379287a 127static void
baa490c4 128alpha_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
3379287a 129{
d2427a71
RH
130 struct gdbarch_tdep *tdep;
131
f1a559ae 132 /* Hook into the DWARF CFI frame unwinder. */
baa490c4 133 alpha_dwarf2_init_abi (info, gdbarch);
f1a559ae
RH
134
135 /* Hook into the MDEBUG frame unwinder. */
d2427a71 136 alpha_mdebug_init_abi (info, gdbarch);
36a6271d 137
d2427a71 138 tdep = gdbarch_tdep (gdbarch);
36a6271d 139 tdep->dynamic_sigtramp_offset = alpha_linux_sigtramp_offset;
5868c862 140 tdep->sigcontext_addr = alpha_linux_sigcontext_addr;
f2524b93 141 tdep->pc_in_sigtramp = alpha_linux_pc_in_sigtramp;
accc6d1f
JT
142 tdep->jb_pc = 2;
143 tdep->jb_elt_size = 8;
b2756930
KB
144
145 /* Enable TLS support. */
146 set_gdbarch_fetch_tls_load_module_address (gdbarch,
147 svr4_fetch_objfile_link_map);
3379287a
JT
148}
149
150void
151_initialize_alpha_linux_tdep (void)
152{
05816f70 153 gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_LINUX,
70f80edf 154 alpha_linux_init_abi);
3379287a 155}
This page took 0.275528 seconds and 4 git commands to generate.