Commit | Line | Data |
---|---|---|
081bf9da MK |
1 | /* Target-dependent code for Solaris. |
2 | ||
3666a048 | 3 | Copyright (C) 2006-2021 Free Software Foundation, Inc. |
081bf9da MK |
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 | |
a9762ec7 | 9 | the Free Software Foundation; either version 3 of the License, or |
081bf9da MK |
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 | |
a9762ec7 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
081bf9da MK |
19 | |
20 | #include "defs.h" | |
21 | #include "frame.h" | |
22 | #include "symtab.h" | |
28439f5e | 23 | #include "inferior.h" |
77e371c0 | 24 | #include "objfiles.h" |
081bf9da MK |
25 | |
26 | #include "sol2-tdep.h" | |
27 | ||
d412e696 RO |
28 | /* The Solaris signal trampolines reside in libc. For normal signals, |
29 | the function `sigacthandler' is used. This signal trampoline will | |
30 | call the signal handler using the System V calling convention, | |
31 | where the third argument is a pointer to an instance of | |
32 | `ucontext_t', which has a member `uc_mcontext' that contains the | |
33 | saved registers. Incidentally, the kernel passes the `ucontext_t' | |
34 | pointer as the third argument of the signal trampoline too, and | |
35 | `sigacthandler' simply passes it on. However, if you link your | |
36 | program with "-L/usr/ucblib -R/usr/ucblib -lucb", the function | |
37 | `ucbsigvechandler' will be used, which invokes the using the BSD | |
38 | convention, where the third argument is a pointer to an instance of | |
39 | `struct sigcontext'. It is the `ucbsigvechandler' function that | |
40 | converts the `ucontext_t' to a `sigcontext', and back. Unless the | |
41 | signal handler modifies the `struct sigcontext' we can safely | |
42 | ignore this. */ | |
43 | ||
44 | static int | |
45 | sol2_pc_in_sigtramp (CORE_ADDR pc, const char *name) | |
46 | { | |
47 | return (name && (strcmp (name, "sigacthandler") == 0 | |
48 | || strcmp (name, "ucbsigvechandler") == 0 | |
49 | || strcmp (name, "__sighndlr") == 0)); | |
50 | } | |
51 | ||
52 | /* Return whether THIS_FRAME corresponds to a Solaris sigtramp routine. */ | |
53 | ||
54 | int | |
55 | sol2_sigtramp_p (struct frame_info *this_frame) | |
56 | { | |
57 | CORE_ADDR pc = get_frame_pc (this_frame); | |
58 | const char *name; | |
59 | ||
60 | find_pc_partial_function (pc, &name, NULL, NULL); | |
61 | return sol2_pc_in_sigtramp (pc, name); | |
62 | } | |
63 | ||
d412e696 | 64 | static CORE_ADDR |
081bf9da MK |
65 | sol2_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) |
66 | { | |
3b7344d5 | 67 | struct bound_minimal_symbol msym; |
081bf9da MK |
68 | |
69 | msym = lookup_minimal_symbol("elf_bndr", NULL, NULL); | |
77e371c0 | 70 | if (msym.minsym && BMSYMBOL_VALUE_ADDRESS (msym) == pc) |
c7ce8faa | 71 | return frame_unwind_caller_pc (get_current_frame ()); |
081bf9da MK |
72 | |
73 | return 0; | |
74 | } | |
28439f5e | 75 | |
d412e696 | 76 | /* This is how we want PTIDs from Solaris core files to be printed. */ |
28439f5e | 77 | |
d412e696 | 78 | static std::string |
28439f5e PA |
79 | sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) |
80 | { | |
3e3420f6 PA |
81 | struct inferior *inf; |
82 | int pid; | |
28439f5e | 83 | |
d412e696 | 84 | /* Check whether we're printing an LWP (gdb thread) or a process. */ |
e38504b3 | 85 | pid = ptid.lwp (); |
3e3420f6 PA |
86 | if (pid != 0) |
87 | { | |
88 | /* A thread. */ | |
a068643d | 89 | return string_printf ("LWP %ld", ptid.lwp ()); |
3e3420f6 PA |
90 | } |
91 | ||
92 | /* GDB didn't use to put a NT_PSTATUS note in Solaris cores. If | |
d412e696 | 93 | that's missing, then we're dealing with a fake PID corelow.c made up. */ |
5b6d1e4f | 94 | inf = find_inferior_ptid (current_inferior ()->process_target (), ptid); |
3e3420f6 | 95 | if (inf == NULL || inf->fake_pid_p) |
a068643d | 96 | return "<core>"; |
3e3420f6 PA |
97 | |
98 | /* Not fake; print as usual. */ | |
99 | return normal_pid_to_str (ptid); | |
28439f5e | 100 | } |
d412e696 RO |
101 | |
102 | /* To be called from GDB_OSABI_SOLARIS handlers. */ | |
103 | ||
104 | void | |
105 | sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | |
106 | { | |
107 | /* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop, SunPRO) | |
108 | compiler puts out 0 instead of the address in N_SO stabs. Starting with | |
109 | SunPRO 3.0, the compiler does this for N_FUN stabs too. */ | |
110 | set_gdbarch_sofun_address_maybe_missing (gdbarch, 1); | |
111 | ||
d412e696 RO |
112 | /* Solaris uses SVR4-style shared libraries. */ |
113 | set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver); | |
114 | ||
115 | /* How to print LWP PTIDs from core files. */ | |
116 | set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str); | |
117 | } |