gdb/amd64-sol2-tdep.c - gdb

Global variables defined

Functions defined

Source code

  1. /* Target-dependent code for AMD64 Solaris.

  2.    Copyright (C) 2001-2015 Free Software Foundation, Inc.

  3.    Contributed by Joseph Myers, CodeSourcery, LLC.

  4.    This file is part of GDB.

  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 3 of the License, or
  8.    (at your option) any later version.

  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.

  13.    You should have received a copy of the GNU General Public License
  14.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  15. #include "defs.h"
  16. #include "frame.h"
  17. #include "gdbcore.h"
  18. #include "regcache.h"
  19. #include "osabi.h"
  20. #include "symtab.h"

  21. #include "sol2-tdep.h"
  22. #include "amd64-tdep.h"
  23. #include "solib-svr4.h"

  24. /* Mapping between the general-purpose registers in gregset_t format
  25.    and GDB's register cache layout.  */

  26. /* From <sys/regset.h>.  */
  27. static int amd64_sol2_gregset_reg_offset[] = {
  28.   14 * 8,                        /* %rax */
  29.   11 * 8,                        /* %rbx */
  30.   13 * 8,                        /* %rcx */
  31.   12 * 8,                        /* %rdx */
  32.   9 * 8,                        /* %rsi */
  33.   8 * 8,                        /* %rdi */
  34.   10 * 8,                        /* %rbp */
  35.   20 * 8,                        /* %rsp */
  36.   7 * 8,                        /* %r8 ...  */
  37.   6 * 8,
  38.   5 * 8,
  39.   4 * 8,
  40.   3 * 8,
  41.   2 * 8,
  42.   1 * 8,
  43.   0 * 8,                        /* ... %r15 */
  44.   17 * 8,                        /* %rip */
  45.   19 * 8,                        /* %eflags */
  46.   18 * 8,                        /* %cs */
  47.   21 * 8,                        /* %ss */
  48.   25 * 8,                        /* %ds */
  49.   24 * 8,                        /* %es */
  50.   22 * 8,                        /* %fs */
  51.   23 * 8                        /* %gs */
  52. };


  53. /* Return whether THIS_FRAME corresponds to a Solaris sigtramp
  54.    routine.  */

  55. static int
  56. amd64_sol2_sigtramp_p (struct frame_info *this_frame)
  57. {
  58.   CORE_ADDR pc = get_frame_pc (this_frame);
  59.   const char *name;

  60.   find_pc_partial_function (pc, &name, NULL, NULL);
  61.   return (name && (strcmp ("sigacthandler", name) == 0
  62.                    || strcmp (name, "ucbsigvechandler") == 0));
  63. }

  64. /* Solaris doesn't have a 'struct sigcontext', but it does have a
  65.    'mcontext_t' that contains the saved set of machine registers.  */

  66. static CORE_ADDR
  67. amd64_sol2_mcontext_addr (struct frame_info *this_frame)
  68. {
  69.   CORE_ADDR sp, ucontext_addr;

  70.   sp = get_frame_register_unsigned (this_frame, AMD64_RSP_REGNUM);
  71.   ucontext_addr = get_frame_memory_unsigned (this_frame, sp + 8, 8);

  72.   return ucontext_addr + 72;
  73. }

  74. static void
  75. amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
  76. {
  77.   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

  78.   tdep->gregset_reg_offset = amd64_sol2_gregset_reg_offset;
  79.   tdep->gregset_num_regs = ARRAY_SIZE (amd64_sol2_gregset_reg_offset);
  80.   tdep->sizeof_gregset = 28 * 8;

  81.   amd64_init_abi (info, gdbarch);

  82.   tdep->sigtramp_p = amd64_sol2_sigtramp_p;
  83.   tdep->sigcontext_addr = amd64_sol2_mcontext_addr;
  84.   tdep->sc_reg_offset = tdep->gregset_reg_offset;
  85.   tdep->sc_num_regs = tdep->gregset_num_regs;

  86.   /* Solaris uses SVR4-style shared libraries.  */
  87.   set_gdbarch_skip_solib_resolver (gdbarch, sol2_skip_solib_resolver);
  88.   set_solib_svr4_fetch_link_map_offsets
  89.     (gdbarch, svr4_lp64_fetch_link_map_offsets);

  90.   /* How to print LWP PTIDs from core files.  */
  91.   set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
  92. }


  93. /* Provide a prototype to silence -Wmissing-prototypes.  */
  94. extern void _initialize_amd64_sol2_tdep (void);

  95. void
  96. _initialize_amd64_sol2_tdep (void)
  97. {
  98.   gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
  99.                           GDB_OSABI_SOLARIS, amd64_sol2_init_abi);
  100. }