gdb/tilegx-linux-tdep.c - gdb

Global variables defined

Functions defined

Macros defined

Source code

  1. /* Target-dependent code for GNU/Linux on Tilera TILE-Gx processors.

  2.    Copyright (C) 2012-2015 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. /* Signal trampoline support.  */

  26. static void
  27. tilegx_linux_sigframe_init (const struct tramp_frame *self,
  28.                             struct frame_info *this_frame,
  29.                             struct trad_frame_cache *this_cache,
  30.                             CORE_ADDR func)
  31. {
  32.   CORE_ADDR pc = get_frame_register_unsigned (this_frame, 64);
  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, -1 }, /* { moveli r10, 139 } */
  55.     { 0x286b180051485000ULL, -1 }, /* { swint1 } */
  56.     { TRAMP_SENTINEL_INSN, -1 }
  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_regset,
  82.       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);

  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.                                            svr4_ilp32_fetch_link_map_offsets);
  97.   else
  98.     set_solib_svr4_fetch_link_map_offsets (gdbarch,
  99.                                            svr4_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.   set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type);
  107. }

  108. /* Provide a prototype to silence -Wmissing-prototypes.  */
  109. extern initialize_file_ftype _initialize_tilegx_linux_tdep;

  110. void
  111. _initialize_tilegx_linux_tdep (void)
  112. {
  113.   gdbarch_register_osabi (bfd_arch_tilegx, bfd_mach_tilegx, GDB_OSABI_LINUX,
  114.                           tilegx_linux_init_abi);
  115. }