gdb/xtensa-linux-tdep.c - gdb

Functions defined

Source code

  1. /* Target-dependent code for GNU/Linux on Xtensa processors.

  2.    Copyright (C) 2007-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 "solib-svr4.h"
  18. #include "symtab.h"

  19. /* This enum represents the signals' numbers on the Xtensa
  20.    architecture.  It just contains the signal definitions which are
  21.    different from the generic implementation.

  22.    It is derived from the file <arch/xtensa/include/uapi/asm/signal.h>,
  23.    from the Linux kernel tree.  */

  24. enum
  25.   {
  26.     XTENSA_LINUX_SIGRTMIN = 32,
  27.     XTENSA_LINUX_SIGRTMAX = 63,
  28.   };

  29. /* Implementation of `gdbarch_gdb_signal_from_target', as defined in
  30.    gdbarch.h.  */

  31. static enum gdb_signal
  32. xtensa_linux_gdb_signal_from_target (struct gdbarch *gdbarch,
  33.                                    int signal)
  34. {
  35.   if (signal >= XTENSA_LINUX_SIGRTMIN && signal <= XTENSA_LINUX_SIGRTMAX)
  36.     {
  37.       int offset = signal - XTENSA_LINUX_SIGRTMIN;

  38.       if (offset == 0)
  39.         return GDB_SIGNAL_REALTIME_32;
  40.       else
  41.         return (enum gdb_signal) (offset - 1
  42.                                   + (int) GDB_SIGNAL_REALTIME_33);
  43.     }
  44.   else if (signal > XTENSA_LINUX_SIGRTMAX)
  45.     return GDB_SIGNAL_UNKNOWN;

  46.   return linux_gdb_signal_from_target (gdbarch, signal);
  47. }

  48. /* Implementation of `gdbarch_gdb_signal_to_target', as defined in
  49.    gdbarch.h.  */

  50. static int
  51. xtensa_linux_gdb_signal_to_target (struct gdbarch *gdbarch,
  52.                                    enum gdb_signal signal)
  53. {
  54.   switch (signal)
  55.     {
  56.     /* GDB_SIGNAL_REALTIME_32 is not continuous in <gdb/signals.def>,
  57.        therefore we have to handle it here.  */
  58.     case GDB_SIGNAL_REALTIME_32:
  59.       return XTENSA_LINUX_SIGRTMIN;

  60.     /* GDB_SIGNAL_REALTIME_64 is not valid on Xtensa.  */
  61.     case GDB_SIGNAL_REALTIME_64:
  62.       return -1;
  63.     }

  64.   /* GDB_SIGNAL_REALTIME_33 to _63 are continuous.

  65.      Xtensa does not have _64.  */
  66.   if (signal >= GDB_SIGNAL_REALTIME_33
  67.       && signal <= GDB_SIGNAL_REALTIME_63)
  68.     {
  69.       int offset = signal - GDB_SIGNAL_REALTIME_33;

  70.       return XTENSA_LINUX_SIGRTMIN + 1 + offset;
  71.     }

  72.   return linux_gdb_signal_to_target (gdbarch, signal);
  73. }

  74. /* OS specific initialization of gdbarch.  */

  75. static void
  76. xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
  77. {
  78.   linux_init_abi (info, gdbarch);

  79.   set_solib_svr4_fetch_link_map_offsets
  80.     (gdbarch, svr4_ilp32_fetch_link_map_offsets);

  81.   set_gdbarch_gdb_signal_from_target (gdbarch,
  82.                                       xtensa_linux_gdb_signal_from_target);
  83.   set_gdbarch_gdb_signal_to_target (gdbarch,
  84.                                     xtensa_linux_gdb_signal_to_target);
  85. }

  86. /* Provide a prototype to silence -Wmissing-prototypes.  */
  87. extern initialize_file_ftype _initialize_xtensa_linux_tdep;

  88. void
  89. _initialize_xtensa_linux_tdep (void)
  90. {
  91.   gdbarch_register_osabi (bfd_arch_xtensa, bfd_mach_xtensa, GDB_OSABI_LINUX,
  92.                           xtensa_linux_init_abi);
  93. }