1 /* Target-dependent code for Solaris.
3 Copyright (C) 2006-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
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 3 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #include "sol2-tdep.h"
27 /* The Solaris signal trampolines reside in libc. For normal signals,
28 the function `sigacthandler' is used. This signal trampoline will
29 call the signal handler using the System V calling convention,
30 where the third argument is a pointer to an instance of
31 `ucontext_t', which has a member `uc_mcontext' that contains the
32 saved registers. Incidentally, the kernel passes the `ucontext_t'
33 pointer as the third argument of the signal trampoline too, and
34 `sigacthandler' simply passes it on. However, if you link your
35 program with "-L/usr/ucblib -R/usr/ucblib -lucb", the function
36 `ucbsigvechandler' will be used, which invokes the using the BSD
37 convention, where the third argument is a pointer to an instance of
38 `struct sigcontext'. It is the `ucbsigvechandler' function that
39 converts the `ucontext_t' to a `sigcontext', and back. Unless the
40 signal handler modifies the `struct sigcontext' we can safely
44 sol2_pc_in_sigtramp (CORE_ADDR pc
, const char *name
)
46 return (name
&& (strcmp (name
, "sigacthandler") == 0
47 || strcmp (name
, "ucbsigvechandler") == 0
48 || strcmp (name
, "__sighndlr") == 0));
51 /* Return whether THIS_FRAME corresponds to a Solaris sigtramp routine. */
54 sol2_sigtramp_p (const frame_info_ptr
&this_frame
)
56 CORE_ADDR pc
= get_frame_pc (this_frame
);
59 find_pc_partial_function (pc
, &name
, NULL
, NULL
);
60 return sol2_pc_in_sigtramp (pc
, name
);
64 sol2_skip_solib_resolver (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
66 bound_minimal_symbol msym
67 = lookup_minimal_symbol (current_program_space
, "elf_bndr");
68 if (msym
.minsym
&& msym
.value_address () == pc
)
69 return frame_unwind_caller_pc (get_current_frame ());
74 /* This is how we want PTIDs from Solaris core files to be printed. */
77 sol2_core_pid_to_str (struct gdbarch
*gdbarch
, ptid_t ptid
)
82 /* Check whether we're printing an LWP (gdb thread) or a process. */
87 return string_printf ("LWP %ld", ptid
.lwp ());
90 /* GDB didn't use to put a NT_PSTATUS note in Solaris cores. If
91 that's missing, then we're dealing with a fake PID corelow.c made up. */
92 inf
= find_inferior_ptid (current_inferior ()->process_target (), ptid
);
93 if (inf
== NULL
|| inf
->fake_pid_p
)
96 /* Not fake; print as usual. */
97 return normal_pid_to_str (ptid
);
100 /* To be called from GDB_OSABI_SOLARIS handlers. */
103 sol2_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
105 /* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop, SunPRO)
106 compiler puts out 0 instead of the address in N_SO stabs. Starting with
107 SunPRO 3.0, the compiler does this for N_FUN stabs too. */
108 set_gdbarch_sofun_address_maybe_missing (gdbarch
, 1);
110 /* Solaris uses SVR4-style shared libraries. */
111 set_gdbarch_skip_solib_resolver (gdbarch
, sol2_skip_solib_resolver
);
113 /* How to print LWP PTIDs from core files. */
114 set_gdbarch_core_pid_to_str (gdbarch
, sol2_core_pid_to_str
);