tilegx-linux-tdep.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* Target-dependent code for GNU/Linux on Tilera TILE-Gx processors.
  2. Copyright (C) 2012-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #include "defs.h"
  15. #include "osabi.h"
  16. #include "linux-tdep.h"
  17. #include "glibc-tdep.h"
  18. #include "solib-svr4.h"
  19. #include "symtab.h"
  20. #include "regcache.h"
  21. #include "regset.h"
  22. #include "tramp-frame.h"
  23. #include "trad-frame.h"
  24. #include "tilegx-tdep.h"
  25. #include "gdbarch.h"
  26. /* Signal trampoline support. */
  27. static void
  28. tilegx_linux_sigframe_init (const struct tramp_frame *self,
  29. struct frame_info *this_frame,
  30. struct trad_frame_cache *this_cache,
  31. CORE_ADDR func)
  32. {
  33. CORE_ADDR sp = get_frame_register_unsigned (this_frame, 54);
  34. /* Base address of register save area. */
  35. CORE_ADDR base = sp
  36. + 16 /* Skip ABI_SAVE_AREA. */
  37. + 128 /* Skip SIGINFO. */
  38. + 40; /* Skip UCONTEXT. */
  39. /* Address of saved LR register (R56) which holds previous PC. */
  40. CORE_ADDR prev_pc = base + 56 * 8;
  41. int i;
  42. for (i = 0; i < 56; i++)
  43. trad_frame_set_reg_addr (this_cache, i, base + i * 8);
  44. trad_frame_set_reg_value (this_cache, 64,
  45. get_frame_memory_unsigned (this_frame, prev_pc, 8));
  46. /* Save a frame ID. */
  47. trad_frame_set_id (this_cache, frame_id_build (base, func));
  48. }
  49. static const struct tramp_frame tilegx_linux_rt_sigframe =
  50. {
  51. SIGTRAMP_FRAME,
  52. 8,
  53. {
  54. { 0x00045fe551483000ULL, ULONGEST_MAX }, /* { moveli r10, 139 } */
  55. { 0x286b180051485000ULL, ULONGEST_MAX }, /* { swint1 } */
  56. { TRAMP_SENTINEL_INSN, ULONGEST_MAX }
  57. },
  58. tilegx_linux_sigframe_init
  59. };
  60. /* Register map; must match struct pt_regs in "ptrace.h". */
  61. static const struct regcache_map_entry tilegx_linux_regmap[] =
  62. {
  63. { TILEGX_NUM_EASY_REGS, TILEGX_FIRST_EASY_REGNUM, 8 },
  64. { 1, TILEGX_PC_REGNUM, 8 },
  65. { 1, TILEGX_FAULTNUM_REGNUM, 8 },
  66. { 0 }
  67. };
  68. #define TILEGX_LINUX_SIZEOF_GREGSET (64 * 8)
  69. /* TILE-Gx Linux kernel register set. */
  70. static const struct regset tilegx_linux_regset =
  71. {
  72. tilegx_linux_regmap,
  73. regcache_supply_regset, regcache_collect_regset
  74. };
  75. static void
  76. tilegx_iterate_over_regset_sections (struct gdbarch *gdbarch,
  77. iterate_over_regset_sections_cb *cb,
  78. void *cb_data,
  79. const struct regcache *regcache)
  80. {
  81. cb (".reg", TILEGX_LINUX_SIZEOF_GREGSET, TILEGX_LINUX_SIZEOF_GREGSET,
  82. &tilegx_linux_regset, NULL, cb_data);
  83. }
  84. /* OS specific initialization of gdbarch. */
  85. static void
  86. tilegx_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
  87. {
  88. int arch_size = gdbarch_addr_bit (gdbarch);
  89. linux_init_abi (info, gdbarch, 0);
  90. tramp_frame_prepend_unwinder (gdbarch, &tilegx_linux_rt_sigframe);
  91. set_gdbarch_iterate_over_regset_sections
  92. (gdbarch, tilegx_iterate_over_regset_sections);
  93. /* GNU/Linux uses SVR4-style shared libraries. */
  94. if (arch_size == 32)
  95. set_solib_svr4_fetch_link_map_offsets (gdbarch,
  96. linux_ilp32_fetch_link_map_offsets);
  97. else
  98. set_solib_svr4_fetch_link_map_offsets (gdbarch,
  99. linux_lp64_fetch_link_map_offsets);
  100. /* Enable TLS support. */
  101. set_gdbarch_fetch_tls_load_module_address (gdbarch,
  102. svr4_fetch_objfile_link_map);
  103. /* Shared library handling. */
  104. set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
  105. set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
  106. }
  107. void _initialize_tilegx_linux_tdep ();
  108. void
  109. _initialize_tilegx_linux_tdep ()
  110. {
  111. gdbarch_register_osabi (bfd_arch_tilegx, bfd_mach_tilegx, GDB_OSABI_LINUX,
  112. tilegx_linux_init_abi);
  113. }