OSDN Git Service

* hppa-hpux-tdep.c (_initialize_hppa_hpux_tdep): Use the correct
[pf3gnuchains/pf3gnuchains4x.git] / gdb / hppa-hpux-tdep.c
1 /* Target-dependent code for HPUX running on PA-RISC, for GDB.
2
3    Copyright 2002, 2003 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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, Boston, MA 02111-1307, USA.  */
20
21 #include "defs.h"
22 #include "arch-utils.h"
23 #include "gdbcore.h"
24 #include "osabi.h"
25 #include "gdb_string.h"
26 #include "frame.h"
27
28 /* Forward declarations.  */
29 extern void _initialize_hppa_hpux_tdep (void);
30 extern initialize_file_ftype _initialize_hppa_hpux_tdep;
31
32 /* FIXME: brobecker 2002-12-25.  The following functions will eventually
33    become static, after the multiarching conversion is done.  */
34 int hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name);
35 void hppa_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi,
36                                            CORE_ADDR *tmp);
37 void hppa_hpux_frame_base_before_sigtramp (struct frame_info *fi,
38                                            CORE_ADDR *tmp);
39 void hppa_hpux_frame_find_saved_regs_in_sigtramp
40       (struct frame_info *fi, CORE_ADDR *fsr);
41
42 int
43 hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name)
44 {
45   /* Actually, for a PA running HPUX the kernel calls the signal handler
46      without an intermediate trampoline.  Luckily the kernel always sets
47      the return pointer for the signal handler to point to _sigreturn.  */
48   return (name && (strcmp ("_sigreturn", name) == 0));
49 }
50
51 /* For hppa_hpux_frame_saved_pc_in_sigtramp, 
52    hppa_hpux_frame_base_before_sigtramp and
53    hppa_hpux_frame_find_saved_regs_in_sigtramp:
54
55    The signal context structure pointer is always saved at the base
56    of the frame which "calls" the signal handler.  We only want to find
57    the hardware save state structure, which lives 10 32bit words into
58    sigcontext structure.
59
60    Within the hardware save state structure, registers are found in the
61    same order as the register numbers in GDB.
62
63    At one time we peeked at %r31 rather than the PC queues to determine
64    what instruction took the fault.  This was done on purpose, but I don't
65    remember why.  Looking at the PC queues is really the right way, and
66    I don't remember why that didn't work when this code was originally
67    written.  */
68
69 void
70 hppa_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi, CORE_ADDR *tmp)
71 {
72   *tmp = read_memory_integer (get_frame_base (fi) + (43 * 4), 4);
73 }
74
75 void
76 hppa_hpux_frame_base_before_sigtramp (struct frame_info *fi,
77                                       CORE_ADDR *tmp)
78 {
79   *tmp = read_memory_integer (get_frame_base (fi) + (40 * 4), 4);
80 }
81
82 void
83 hppa_hpux_frame_find_saved_regs_in_sigtramp (struct frame_info *fi,
84                                              CORE_ADDR *fsr)
85 {
86   int i;
87   const CORE_ADDR tmp = get_frame_base (fi) + (10 * 4);
88
89   for (i = 0; i < NUM_REGS; i++)
90     {
91       if (i == SP_REGNUM)
92         fsr[SP_REGNUM] = read_memory_integer (tmp + SP_REGNUM * 4, 4);
93       else
94         fsr[i] = tmp + i * 4;
95     }
96 }
97
98 static void
99 hppa_hpux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
100 {
101   set_gdbarch_pc_in_sigtramp (gdbarch, hppa_hpux_pc_in_sigtramp);
102 }
103
104 static void
105 hppa_hpux_som_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
106 {
107   hppa_hpux_init_abi (info, gdbarch);
108 }
109
110 static void
111 hppa_hpux_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
112 {
113   hppa_hpux_init_abi (info, gdbarch);
114 }
115
116 void
117 _initialize_hppa_hpux_tdep (void)
118 {
119   gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_HPUX_SOM,
120                           hppa_hpux_som_init_abi);
121   /* FIXME brobecker 2003-08-13: The machine number 25 corresponds to
122      the hppa2.0w bfd arch_info. A #define should probably be defined
123      in bfd, instead of using this hard-coded number.  */
124   gdbarch_register_osabi (bfd_arch_hppa, 25, GDB_OSABI_HPUX_ELF,
125                           hppa_hpux_elf_init_abi);
126 }