GDB (API)
/home/stan/gdb/src/gdb/amd64-sol2-tdep.c
Go to the documentation of this file.
00001 /* Target-dependent code for AMD64 Solaris.
00002 
00003    Copyright (C) 2001-2013 Free Software Foundation, Inc.
00004 
00005    Contributed by Joseph Myers, CodeSourcery, LLC.
00006 
00007    This file is part of GDB.
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; either version 3 of the License, or
00012    (at your option) any later version.
00013 
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018 
00019    You should have received a copy of the GNU General Public License
00020    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00021 
00022 #include "defs.h"
00023 #include "frame.h"
00024 #include "gdbcore.h"
00025 #include "regcache.h"
00026 #include "osabi.h"
00027 #include "symtab.h"
00028 
00029 #include "gdb_string.h"
00030 
00031 #include "sol2-tdep.h"
00032 #include "amd64-tdep.h"
00033 #include "solib-svr4.h"
00034 
00035 /* Mapping between the general-purpose registers in gregset_t format
00036    and GDB's register cache layout.  */
00037 
00038 /* From <sys/regset.h>.  */
00039 static int amd64_sol2_gregset_reg_offset[] = {
00040   14 * 8,                       /* %rax */
00041   11 * 8,                       /* %rbx */
00042   13 * 8,                       /* %rcx */
00043   12 * 8,                       /* %rdx */
00044   9 * 8,                        /* %rsi */
00045   8 * 8,                        /* %rdi */
00046   10 * 8,                       /* %rbp */
00047   20 * 8,                       /* %rsp */
00048   7 * 8,                        /* %r8 ...  */
00049   6 * 8,
00050   5 * 8,
00051   4 * 8,
00052   3 * 8,
00053   2 * 8,
00054   1 * 8,
00055   0 * 8,                        /* ... %r15 */
00056   17 * 8,                       /* %rip */
00057   19 * 8,                       /* %eflags */
00058   18 * 8,                       /* %cs */
00059   21 * 8,                       /* %ss */
00060   25 * 8,                       /* %ds */
00061   24 * 8,                       /* %es */
00062   22 * 8,                       /* %fs */
00063   23 * 8                        /* %gs */
00064 };
00065 
00066 
00067 /* Return whether THIS_FRAME corresponds to a Solaris sigtramp
00068    routine.  */
00069 
00070 static int
00071 amd64_sol2_sigtramp_p (struct frame_info *this_frame)
00072 {
00073   CORE_ADDR pc = get_frame_pc (this_frame);
00074   const char *name;
00075 
00076   find_pc_partial_function (pc, &name, NULL, NULL);
00077   return (name && (strcmp ("sigacthandler", name) == 0
00078                    || strcmp (name, "ucbsigvechandler") == 0));
00079 }
00080 
00081 /* Solaris doesn't have a 'struct sigcontext', but it does have a
00082    'mcontext_t' that contains the saved set of machine registers.  */
00083 
00084 static CORE_ADDR
00085 amd64_sol2_mcontext_addr (struct frame_info *this_frame)
00086 {
00087   CORE_ADDR sp, ucontext_addr;
00088 
00089   sp = get_frame_register_unsigned (this_frame, AMD64_RSP_REGNUM);
00090   ucontext_addr = get_frame_memory_unsigned (this_frame, sp + 8, 8);
00091 
00092   return ucontext_addr + 72;
00093 }
00094 
00095 static void
00096 amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
00097 {
00098   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
00099 
00100   tdep->gregset_reg_offset = amd64_sol2_gregset_reg_offset;
00101   tdep->gregset_num_regs = ARRAY_SIZE (amd64_sol2_gregset_reg_offset);
00102   tdep->sizeof_gregset = 28 * 8;
00103 
00104   amd64_init_abi (info, gdbarch);
00105 
00106   tdep->sigtramp_p = amd64_sol2_sigtramp_p;
00107   tdep->sigcontext_addr = amd64_sol2_mcontext_addr;
00108   tdep->sc_reg_offset = tdep->gregset_reg_offset;
00109   tdep->sc_num_regs = tdep->gregset_num_regs;
00110 
00111   /* Solaris uses SVR4-style shared libraries.  */
00112   set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver);
00113   set_solib_svr4_fetch_link_map_offsets
00114     (gdbarch, svr4_lp64_fetch_link_map_offsets);
00115 
00116   /* How to print LWP PTIDs from core files.  */
00117   set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
00118 }
00119 
00120 
00121 /* Provide a prototype to silence -Wmissing-prototypes.  */
00122 extern void _initialize_amd64_sol2_tdep (void);
00123 
00124 void
00125 _initialize_amd64_sol2_tdep (void)
00126 {
00127   gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
00128                           GDB_OSABI_SOLARIS, amd64_sol2_init_abi);
00129 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines