GDB (API)
/home/stan/gdb/src/gdb/xtensa-linux-tdep.c
Go to the documentation of this file.
00001 /* Target-dependent code for GNU/Linux on Xtensa processors.
00002 
00003    Copyright (C) 2007-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #include "defs.h"
00021 #include "osabi.h"
00022 #include "linux-tdep.h"
00023 #include "solib-svr4.h"
00024 #include "symtab.h"
00025 
00026 /* This enum represents the signals' numbers on the Xtensa
00027    architecture.  It just contains the signal definitions which are
00028    different from the generic implementation.
00029 
00030    It is derived from the file <arch/xtensa/include/uapi/asm/signal.h>,
00031    from the Linux kernel tree.  */
00032 
00033 enum
00034   {
00035     XTENSA_LINUX_SIGRTMIN = 32,
00036     XTENSA_LINUX_SIGRTMAX = 63,
00037   };
00038 
00039 /* Implementation of `gdbarch_gdb_signal_from_target', as defined in
00040    gdbarch.h.  */
00041 
00042 static enum gdb_signal
00043 xtensa_linux_gdb_signal_from_target (struct gdbarch *gdbarch,
00044                                    int signal)
00045 {
00046   if (signal >= XTENSA_LINUX_SIGRTMIN && signal <= XTENSA_LINUX_SIGRTMAX)
00047     {
00048       int offset = signal - XTENSA_LINUX_SIGRTMIN;
00049 
00050       if (offset == 0)
00051         return GDB_SIGNAL_REALTIME_32;
00052       else
00053         return (enum gdb_signal) (offset - 1
00054                                   + (int) GDB_SIGNAL_REALTIME_33);
00055     }
00056   else if (signal > XTENSA_LINUX_SIGRTMAX)
00057     return GDB_SIGNAL_UNKNOWN;
00058 
00059   return linux_gdb_signal_from_target (gdbarch, signal);
00060 }
00061 
00062 /* Implementation of `gdbarch_gdb_signal_to_target', as defined in
00063    gdbarch.h.  */
00064 
00065 static int
00066 xtensa_linux_gdb_signal_to_target (struct gdbarch *gdbarch,
00067                                    enum gdb_signal signal)
00068 {
00069   switch (signal)
00070     {
00071     /* GDB_SIGNAL_REALTIME_32 is not continuous in <gdb/signals.def>,
00072        therefore we have to handle it here.  */
00073     case GDB_SIGNAL_REALTIME_32:
00074       return XTENSA_LINUX_SIGRTMIN;
00075 
00076     /* GDB_SIGNAL_REALTIME_64 is not valid on Xtensa.  */
00077     case GDB_SIGNAL_REALTIME_64:
00078       return -1;
00079     }
00080 
00081   /* GDB_SIGNAL_REALTIME_33 to _63 are continuous.
00082 
00083      Xtensa does not have _64.  */
00084   if (signal >= GDB_SIGNAL_REALTIME_33
00085       && signal <= GDB_SIGNAL_REALTIME_63)
00086     {
00087       int offset = signal - GDB_SIGNAL_REALTIME_33;
00088 
00089       return XTENSA_LINUX_SIGRTMIN + 1 + offset;
00090     }
00091 
00092   return linux_gdb_signal_to_target (gdbarch, signal);
00093 }
00094 
00095 /* OS specific initialization of gdbarch.  */
00096 
00097 static void
00098 xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
00099 {
00100   linux_init_abi (info, gdbarch);
00101 
00102   set_solib_svr4_fetch_link_map_offsets
00103     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
00104 
00105   set_gdbarch_gdb_signal_from_target (gdbarch,
00106                                       xtensa_linux_gdb_signal_from_target);
00107   set_gdbarch_gdb_signal_to_target (gdbarch,
00108                                     xtensa_linux_gdb_signal_to_target);
00109 }
00110 
00111 /* Provide a prototype to silence -Wmissing-prototypes.  */
00112 extern initialize_file_ftype _initialize_xtensa_linux_tdep;
00113 
00114 void
00115 _initialize_xtensa_linux_tdep (void)
00116 {
00117   gdbarch_register_osabi (bfd_arch_xtensa, bfd_mach_xtensa, GDB_OSABI_LINUX,
00118                           xtensa_linux_init_abi);
00119 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines