GDB (API)
/home/stan/gdb/src/gdb/alphafbsd-tdep.c
Go to the documentation of this file.
00001 /* Target-dependent code for FreeBSD/alpha.
00002 
00003    Copyright (C) 2001-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 "value.h"
00022 #include "osabi.h"
00023 
00024 #include "alpha-tdep.h"
00025 #include "solib-svr4.h"
00026 
00027 static int
00028 alphafbsd_return_in_memory (struct type *type)
00029 {
00030   enum type_code code;
00031   int i;
00032 
00033   /* All aggregate types that won't fit in a register must be returned
00034      in memory.  */
00035   if (TYPE_LENGTH (type) > ALPHA_REGISTER_SIZE)
00036     return 1;
00037 
00038   /* The only aggregate types that can be returned in a register are
00039      structs and unions.  Arrays must be returned in memory.  */
00040   code = TYPE_CODE (type);
00041   if (code != TYPE_CODE_STRUCT && code != TYPE_CODE_UNION)
00042     return 1;
00043 
00044   /* We need to check if this struct/union is "integer" like.  For
00045      this to be true, the offset of each adressable subfield must be
00046      zero.  Note that bit fields are not addressable.  */
00047   for (i = 0; i < TYPE_NFIELDS (type); i++)
00048     {
00049       /* If the field bitsize is non-zero, it isn't adressable.  */
00050       if (TYPE_FIELD_BITPOS (type, i) != 0
00051           && TYPE_FIELD_BITSIZE (type, i) == 0)
00052         return 1;
00053     }
00054 
00055   return 0;
00056 }
00057 
00058 
00059 /* Support for signal handlers.  */
00060 
00061 /* Return whether PC is in a BSD sigtramp routine.  */
00062 
00063 CORE_ADDR alphafbsd_sigtramp_start = 0x11ffff68;
00064 CORE_ADDR alphafbsd_sigtramp_end = 0x11ffffe0;
00065 
00066 static int
00067 alphafbsd_pc_in_sigtramp (struct gdbarch *gdbarch,
00068                           CORE_ADDR pc, const char *func_name)
00069 {
00070   return (pc >= alphafbsd_sigtramp_start && pc < alphafbsd_sigtramp_end);
00071 }
00072 
00073 static LONGEST
00074 alphafbsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
00075 {
00076   return pc - alphafbsd_sigtramp_start;
00077 }
00078 
00079 /* Assuming THIS_FRAME is the frame of a BSD sigtramp routine,
00080    return the address of the associated sigcontext structure.  */
00081 
00082 static CORE_ADDR
00083 alphafbsd_sigcontext_addr (struct frame_info *this_frame)
00084 {
00085   return get_frame_register_unsigned (this_frame, ALPHA_SP_REGNUM) + 24;
00086 }
00087 
00088 /* FreeBSD 5.0-RELEASE or later.  */
00089 
00090 static void
00091 alphafbsd_init_abi (struct gdbarch_info info,
00092                     struct gdbarch *gdbarch)
00093 {
00094   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
00095 
00096   /* Hook into the DWARF CFI frame unwinder.  */
00097   alpha_dwarf2_init_abi (info, gdbarch);
00098 
00099   /* Hook into the MDEBUG frame unwinder.  */
00100   alpha_mdebug_init_abi (info, gdbarch);
00101 
00102   /* FreeBSD/alpha has SVR4-style shared libraries.  */
00103   set_solib_svr4_fetch_link_map_offsets
00104     (gdbarch, svr4_lp64_fetch_link_map_offsets);
00105 
00106   tdep->dynamic_sigtramp_offset = alphafbsd_sigtramp_offset;
00107   tdep->sigcontext_addr = alphafbsd_sigcontext_addr;
00108   tdep->pc_in_sigtramp = alphafbsd_pc_in_sigtramp;
00109   tdep->return_in_memory = alphafbsd_return_in_memory;
00110   tdep->sc_pc_offset = 288;
00111   tdep->sc_regs_offset = 24;
00112   tdep->sc_fpregs_offset = 320;
00113 
00114   tdep->jb_pc = 2;
00115   tdep->jb_elt_size = 8;
00116 }
00117 
00118 
00119 /* Provide a prototype to silence -Wmissing-prototypes.  */
00120 void _initialize_alphafbsd_tdep (void);
00121 
00122 void
00123 _initialize_alphafbsd_tdep (void)
00124 {
00125   gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_FREEBSD_ELF,
00126                           alphafbsd_init_abi);
00127 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines