amd64-sol2-tdep.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* Target-dependent code for AMD64 Solaris.
  2. Copyright (C) 2001-2022 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 "gdbsupport/x86-xstate.h"
  24. #include "solib-svr4.h"
  25. /* Mapping between the general-purpose registers in gregset_t format
  26. and GDB's register cache layout. */
  27. /* From <sys/regset.h>. */
  28. static int amd64_sol2_gregset_reg_offset[] = {
  29. 14 * 8, /* %rax */
  30. 11 * 8, /* %rbx */
  31. 13 * 8, /* %rcx */
  32. 12 * 8, /* %rdx */
  33. 9 * 8, /* %rsi */
  34. 8 * 8, /* %rdi */
  35. 10 * 8, /* %rbp */
  36. 20 * 8, /* %rsp */
  37. 7 * 8, /* %r8 ... */
  38. 6 * 8,
  39. 5 * 8,
  40. 4 * 8,
  41. 3 * 8,
  42. 2 * 8,
  43. 1 * 8,
  44. 0 * 8, /* ... %r15 */
  45. 17 * 8, /* %rip */
  46. 19 * 8, /* %eflags */
  47. 18 * 8, /* %cs */
  48. 21 * 8, /* %ss */
  49. 25 * 8, /* %ds */
  50. 24 * 8, /* %es */
  51. 22 * 8, /* %fs */
  52. 23 * 8 /* %gs */
  53. };
  54. /* Solaris doesn't have a 'struct sigcontext', but it does have a
  55. 'mcontext_t' that contains the saved set of machine registers. */
  56. static CORE_ADDR
  57. amd64_sol2_mcontext_addr (struct frame_info *this_frame)
  58. {
  59. CORE_ADDR sp, ucontext_addr;
  60. sp = get_frame_register_unsigned (this_frame, AMD64_RSP_REGNUM);
  61. ucontext_addr = get_frame_memory_unsigned (this_frame, sp + 8, 8);
  62. return ucontext_addr + 72;
  63. }
  64. static void
  65. amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
  66. {
  67. i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch);
  68. tdep->gregset_reg_offset = amd64_sol2_gregset_reg_offset;
  69. tdep->gregset_num_regs = ARRAY_SIZE (amd64_sol2_gregset_reg_offset);
  70. tdep->sizeof_gregset = 28 * 8;
  71. amd64_init_abi (info, gdbarch,
  72. amd64_target_description (X86_XSTATE_SSE_MASK, true));
  73. sol2_init_abi (info, gdbarch);
  74. tdep->sigtramp_p = sol2_sigtramp_p;
  75. tdep->sigcontext_addr = amd64_sol2_mcontext_addr;
  76. tdep->sc_reg_offset = tdep->gregset_reg_offset;
  77. tdep->sc_num_regs = tdep->gregset_num_regs;
  78. /* Solaris uses SVR4-style shared libraries. */
  79. set_solib_svr4_fetch_link_map_offsets
  80. (gdbarch, svr4_lp64_fetch_link_map_offsets);
  81. }
  82. void _initialize_amd64_sol2_tdep ();
  83. void
  84. _initialize_amd64_sol2_tdep ()
  85. {
  86. gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
  87. GDB_OSABI_SOLARIS, amd64_sol2_init_abi);
  88. }