2003-05-31 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / hppa-hpux-tdep.c
CommitLineData
273f8429 1/* Target-dependent code for HPUX running on PA-RISC, for GDB.
ef6e7e13
AC
2
3 Copyright 2002, 2003 Free Software Foundation, Inc.
273f8429
JB
4
5This file is part of GDB.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21#include "defs.h"
22#include "arch-utils.h"
60e1ff27 23#include "gdbcore.h"
273f8429 24#include "osabi.h"
65e82032 25#include "gdb_string.h"
273f8429
JB
26
27/* Forward declarations. */
28extern void _initialize_hppa_hpux_tdep (void);
29extern initialize_file_ftype _initialize_hppa_hpux_tdep;
30
60e1ff27
JB
31/* FIXME: brobecker 2002-12-25. The following functions will eventually
32 become static, after the multiarching conversion is done. */
33int hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name);
34void hppa_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi,
35 CORE_ADDR *tmp);
36void hppa_hpux_frame_base_before_sigtramp (struct frame_info *fi,
37 CORE_ADDR *tmp);
38void hppa_hpux_frame_find_saved_regs_in_sigtramp
43bd9a9e 39 (struct frame_info *fi, CORE_ADDR *fsr);
60e1ff27
JB
40
41int
42hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name)
43{
44 /* Actually, for a PA running HPUX the kernel calls the signal handler
45 without an intermediate trampoline. Luckily the kernel always sets
46 the return pointer for the signal handler to point to _sigreturn. */
47 return (name && (strcmp ("_sigreturn", name) == 0));
48}
49
50/* For hppa_hpux_frame_saved_pc_in_sigtramp,
51 hppa_hpux_frame_base_before_sigtramp and
52 hppa_hpux_frame_find_saved_regs_in_sigtramp:
53
54 The signal context structure pointer is always saved at the base
55 of the frame which "calls" the signal handler. We only want to find
56 the hardware save state structure, which lives 10 32bit words into
57 sigcontext structure.
58
59 Within the hardware save state structure, registers are found in the
60 same order as the register numbers in GDB.
61
62 At one time we peeked at %r31 rather than the PC queues to determine
63 what instruction took the fault. This was done on purpose, but I don't
64 remember why. Looking at the PC queues is really the right way, and
65 I don't remember why that didn't work when this code was originally
66 written. */
67
68void
69hppa_hpux_frame_saved_pc_in_sigtramp (struct frame_info *fi, CORE_ADDR *tmp)
70{
ef6e7e13 71 *tmp = read_memory_integer (get_frame_base (fi) + (43 * 4), 4);
60e1ff27
JB
72}
73
74void
75hppa_hpux_frame_base_before_sigtramp (struct frame_info *fi,
76 CORE_ADDR *tmp)
77{
ef6e7e13 78 *tmp = read_memory_integer (get_frame_base (fi) + (40 * 4), 4);
60e1ff27
JB
79}
80
81void
82hppa_hpux_frame_find_saved_regs_in_sigtramp (struct frame_info *fi,
43bd9a9e 83 CORE_ADDR *fsr)
60e1ff27
JB
84{
85 int i;
ef6e7e13 86 const CORE_ADDR tmp = get_frame_base (fi) + (10 * 4);
60e1ff27
JB
87
88 for (i = 0; i < NUM_REGS; i++)
89 {
90 if (i == SP_REGNUM)
43bd9a9e 91 fsr[SP_REGNUM] = read_memory_integer (tmp + SP_REGNUM * 4, 4);
60e1ff27 92 else
43bd9a9e 93 fsr[i] = tmp + i * 4;
60e1ff27
JB
94 }
95}
96
97
273f8429
JB
98static void
99hppa_hpux_som_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
100{
101}
102
103static void
104hppa_hpux_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
105{
106}
107
108void
109_initialize_hppa_hpux_tdep (void)
110{
05816f70 111 gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_HPUX_SOM,
273f8429 112 hppa_hpux_som_init_abi);
05816f70 113 gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_HPUX_ELF,
273f8429
JB
114 hppa_hpux_elf_init_abi);
115}
This page took 0.067229 seconds and 4 git commands to generate.