2003-02-06 Andrew Cagney <ac131313@redhat.com>
[deliverable/binutils-gdb.git] / gdb / alpha-linux-tdep.c
CommitLineData
3379287a 1/* Target-dependent code for GNU/Linux on Alpha.
4be87837 2 Copyright 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
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21#include "defs.h"
5868c862 22#include "frame.h"
36a6271d 23#include "gdbcore.h"
3379287a 24#include "value.h"
4be87837 25#include "osabi.h"
3379287a
JT
26
27#include "alpha-tdep.h"
28
29/* Under GNU/Linux, signal handler invocations can be identified by the
30 designated code sequence that is used to return from a signal
31 handler. In particular, the return address of a signal handler
32 points to the following sequence (the first instruction is quadword
33 aligned):
34
35 bis $30,$30,$16
36 addq $31,0x67,$0
37 call_pal callsys
38
39 Each instruction has a unique encoding, so we simply attempt to
40 match the instruction the pc is pointing to with any of the above
41 instructions. If there is a hit, we know the offset to the start
42 of the designated sequence and can then check whether we really are
43 executing in a designated sequence. If not, -1 is returned,
44 otherwise the offset from the start of the desingated sequence is
45 returned.
46
47 There is a slight chance of false hits: code could jump into the
48 middle of the designated sequence, in which case there is no
49 guarantee that we are in the middle of a sigreturn syscall. Don't
50 think this will be a problem in praxis, though. */
36a6271d 51LONGEST
3379287a
JT
52alpha_linux_sigtramp_offset (CORE_ADDR pc)
53{
54 unsigned int i[3], w;
55 long off;
56
57 if (read_memory_nobpt (pc, (char *) &w, 4) != 0)
58 return -1;
59
60 off = -1;
61 switch (w)
62 {
63 case 0x47de0410:
64 off = 0;
65 break; /* bis $30,$30,$16 */
66 case 0x43ecf400:
67 off = 4;
68 break; /* addq $31,0x67,$0 */
69 case 0x00000083:
70 off = 8;
71 break; /* call_pal callsys */
72 default:
73 return -1;
74 }
75 pc -= off;
76 if (pc & 0x7)
77 {
78 /* designated sequence is not quadword aligned */
79 return -1;
80 }
81 if (read_memory_nobpt (pc, (char *) i, sizeof (i)) != 0)
82 return -1;
83
84 if (i[0] == 0x47de0410 && i[1] == 0x43ecf400 && i[2] == 0x00000083)
85 return off;
86
87 return -1;
88}
89
6c72f9f9
JT
90static int
91alpha_linux_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
92{
93 return (alpha_linux_sigtramp_offset (pc) >= 0);
94}
95
5868c862
JT
96static CORE_ADDR
97alpha_linux_sigcontext_addr (struct frame_info *frame)
98{
1c615f7a 99 return (get_frame_base (frame) - 0x298); /* sizeof(struct sigcontext) */
5868c862
JT
100}
101
3379287a
JT
102static void
103alpha_linux_init_abi (struct gdbarch_info info,
104 struct gdbarch *gdbarch)
105{
36a6271d
JT
106 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
107
6c72f9f9
JT
108 set_gdbarch_pc_in_sigtramp (gdbarch, alpha_linux_pc_in_sigtramp);
109
36a6271d 110 tdep->dynamic_sigtramp_offset = alpha_linux_sigtramp_offset;
5868c862 111 tdep->sigcontext_addr = alpha_linux_sigcontext_addr;
accc6d1f
JT
112
113 tdep->jb_pc = 2;
114 tdep->jb_elt_size = 8;
3379287a
JT
115}
116
117void
118_initialize_alpha_linux_tdep (void)
119{
05816f70 120 gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_LINUX,
70f80edf 121 alpha_linux_init_abi);
3379287a 122}
This page took 0.085871 seconds and 4 git commands to generate.