OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gdb-7.2/] [gdb-7.2-or32-1.0rc3/] [gdb/] [vaxobsd-tdep.c] - Diff between revs 330 and 513

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 330 Rev 513
/* Target-dependent code for OpenBSD/vax.
/* Target-dependent code for OpenBSD/vax.
 
 
   Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
   Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 
   This file is part of GDB.
   This file is part of GDB.
 
 
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
#include "defs.h"
#include "defs.h"
#include "arch-utils.h"
#include "arch-utils.h"
#include "frame.h"
#include "frame.h"
#include "frame-unwind.h"
#include "frame-unwind.h"
#include "osabi.h"
#include "osabi.h"
#include "symtab.h"
#include "symtab.h"
#include "trad-frame.h"
#include "trad-frame.h"
 
 
#include "vax-tdep.h"
#include "vax-tdep.h"
 
 
#include "gdb_string.h"
#include "gdb_string.h"
 
 
/* Signal trampolines.  */
/* Signal trampolines.  */
 
 
/* Since OpenBSD 3.2, the sigtramp routine is mapped at a random page
/* Since OpenBSD 3.2, the sigtramp routine is mapped at a random page
   in virtual memory.  The randomness makes it somewhat tricky to
   in virtual memory.  The randomness makes it somewhat tricky to
   detect it, but fortunately we can rely on the fact that the start
   detect it, but fortunately we can rely on the fact that the start
   of the sigtramp routine is page-aligned.  We recognize the
   of the sigtramp routine is page-aligned.  We recognize the
   trampoline by looking for the code that invokes the sigreturn
   trampoline by looking for the code that invokes the sigreturn
   system call.  The offset where we can find that code varies from
   system call.  The offset where we can find that code varies from
   release to release.
   release to release.
 
 
   By the way, the mapping mentioned above is read-only, so you cannot
   By the way, the mapping mentioned above is read-only, so you cannot
   place a breakpoint in the signal trampoline.  */
   place a breakpoint in the signal trampoline.  */
 
 
/* Default page size.  */
/* Default page size.  */
static const int vaxobsd_page_size = 4096;
static const int vaxobsd_page_size = 4096;
 
 
/* Offset for sigreturn(2).  */
/* Offset for sigreturn(2).  */
static const int vaxobsd_sigreturn_offset = 0x11;
static const int vaxobsd_sigreturn_offset = 0x11;
 
 
/* Instruction sequence for sigreturn(2).  VAX doesn't have
/* Instruction sequence for sigreturn(2).  VAX doesn't have
   fixed-length instructions so we include the ensuing exit(2) to
   fixed-length instructions so we include the ensuing exit(2) to
   reduce the chance of spurious matches.  */
   reduce the chance of spurious matches.  */
static const gdb_byte vaxobsd_sigreturn[] = {
static const gdb_byte vaxobsd_sigreturn[] = {
  0xbc, 0x8f, 0x67, 0x00,       /* chmk $SYS_sigreturn */
  0xbc, 0x8f, 0x67, 0x00,       /* chmk $SYS_sigreturn */
  0xbc, 0x01                    /* chmk $SYS_exit */
  0xbc, 0x01                    /* chmk $SYS_exit */
};
};
 
 
static int
static int
vaxobsd_sigtramp_sniffer (const struct frame_unwind *self,
vaxobsd_sigtramp_sniffer (const struct frame_unwind *self,
                          struct frame_info *this_frame,
                          struct frame_info *this_frame,
                          void **this_cache)
                          void **this_cache)
{
{
  CORE_ADDR pc = get_frame_pc (this_frame);
  CORE_ADDR pc = get_frame_pc (this_frame);
  CORE_ADDR start_pc = (pc & ~(vaxobsd_page_size - 1));
  CORE_ADDR start_pc = (pc & ~(vaxobsd_page_size - 1));
  CORE_ADDR sigreturn_addr = start_pc + vaxobsd_sigreturn_offset;
  CORE_ADDR sigreturn_addr = start_pc + vaxobsd_sigreturn_offset;
  gdb_byte *buf;
  gdb_byte *buf;
  char *name;
  char *name;
 
 
  find_pc_partial_function (pc, &name, NULL, NULL);
  find_pc_partial_function (pc, &name, NULL, NULL);
  if (name)
  if (name)
    return 0;
    return 0;
 
 
  buf = alloca(sizeof vaxobsd_sigreturn);
  buf = alloca(sizeof vaxobsd_sigreturn);
  if (!safe_frame_unwind_memory (this_frame, sigreturn_addr,
  if (!safe_frame_unwind_memory (this_frame, sigreturn_addr,
                                 buf, sizeof vaxobsd_sigreturn))
                                 buf, sizeof vaxobsd_sigreturn))
    return 0;
    return 0;
 
 
  if (memcmp(buf, vaxobsd_sigreturn, sizeof vaxobsd_sigreturn) == 0)
  if (memcmp(buf, vaxobsd_sigreturn, sizeof vaxobsd_sigreturn) == 0)
    return 1;
    return 1;
 
 
  return 0;
  return 0;
}
}
 
 
static struct trad_frame_cache *
static struct trad_frame_cache *
vaxobsd_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
vaxobsd_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
{
{
  struct trad_frame_cache *cache;
  struct trad_frame_cache *cache;
  CORE_ADDR addr, base, func;
  CORE_ADDR addr, base, func;
 
 
  if (*this_cache)
  if (*this_cache)
    return *this_cache;
    return *this_cache;
 
 
  cache = trad_frame_cache_zalloc (this_frame);
  cache = trad_frame_cache_zalloc (this_frame);
  *this_cache = cache;
  *this_cache = cache;
 
 
  func = get_frame_pc (this_frame);
  func = get_frame_pc (this_frame);
  func &= ~(vaxobsd_page_size - 1);
  func &= ~(vaxobsd_page_size - 1);
 
 
  base = get_frame_register_unsigned (this_frame, VAX_SP_REGNUM);
  base = get_frame_register_unsigned (this_frame, VAX_SP_REGNUM);
  addr = get_frame_memory_unsigned (this_frame, base - 4, 4);
  addr = get_frame_memory_unsigned (this_frame, base - 4, 4);
 
 
  trad_frame_set_reg_addr (cache, VAX_SP_REGNUM, addr + 8);
  trad_frame_set_reg_addr (cache, VAX_SP_REGNUM, addr + 8);
  trad_frame_set_reg_addr (cache, VAX_FP_REGNUM, addr + 12);
  trad_frame_set_reg_addr (cache, VAX_FP_REGNUM, addr + 12);
  trad_frame_set_reg_addr (cache, VAX_AP_REGNUM, addr + 16);
  trad_frame_set_reg_addr (cache, VAX_AP_REGNUM, addr + 16);
  trad_frame_set_reg_addr (cache, VAX_PC_REGNUM, addr + 20);
  trad_frame_set_reg_addr (cache, VAX_PC_REGNUM, addr + 20);
  trad_frame_set_reg_addr (cache, VAX_PS_REGNUM, addr + 24);
  trad_frame_set_reg_addr (cache, VAX_PS_REGNUM, addr + 24);
 
 
  /* Construct the frame ID using the function start.  */
  /* Construct the frame ID using the function start.  */
  trad_frame_set_id (cache, frame_id_build (base, func));
  trad_frame_set_id (cache, frame_id_build (base, func));
 
 
  return cache;
  return cache;
}
}
 
 
static void
static void
vaxobsd_sigtramp_frame_this_id (struct frame_info *this_frame,
vaxobsd_sigtramp_frame_this_id (struct frame_info *this_frame,
                                void **this_cache, struct frame_id *this_id)
                                void **this_cache, struct frame_id *this_id)
{
{
  struct trad_frame_cache *cache =
  struct trad_frame_cache *cache =
    vaxobsd_sigtramp_frame_cache (this_frame, this_cache);
    vaxobsd_sigtramp_frame_cache (this_frame, this_cache);
 
 
  trad_frame_get_id (cache, this_id);
  trad_frame_get_id (cache, this_id);
}
}
 
 
static struct value *
static struct value *
vaxobsd_sigtramp_frame_prev_register (struct frame_info *this_frame,
vaxobsd_sigtramp_frame_prev_register (struct frame_info *this_frame,
                                      void **this_cache, int regnum)
                                      void **this_cache, int regnum)
{
{
  struct trad_frame_cache *cache =
  struct trad_frame_cache *cache =
    vaxobsd_sigtramp_frame_cache (this_frame, this_cache);
    vaxobsd_sigtramp_frame_cache (this_frame, this_cache);
 
 
  return trad_frame_get_register (cache, this_frame, regnum);
  return trad_frame_get_register (cache, this_frame, regnum);
}
}
 
 
static const struct frame_unwind vaxobsd_sigtramp_frame_unwind = {
static const struct frame_unwind vaxobsd_sigtramp_frame_unwind = {
  SIGTRAMP_FRAME,
  SIGTRAMP_FRAME,
  vaxobsd_sigtramp_frame_this_id,
  vaxobsd_sigtramp_frame_this_id,
  vaxobsd_sigtramp_frame_prev_register,
  vaxobsd_sigtramp_frame_prev_register,
  NULL,
  NULL,
  vaxobsd_sigtramp_sniffer
  vaxobsd_sigtramp_sniffer
};
};


 
 
/* OpenBSD a.out.  */
/* OpenBSD a.out.  */
 
 
static void
static void
vaxobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
vaxobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
{
  frame_unwind_append_unwinder (gdbarch, &vaxobsd_sigtramp_frame_unwind);
  frame_unwind_append_unwinder (gdbarch, &vaxobsd_sigtramp_frame_unwind);
}
}
 
 
/* FIXME: kettenis/20050821: Since OpenBSD/vax binaries are
/* FIXME: kettenis/20050821: Since OpenBSD/vax binaries are
   indistingushable from NetBSD/vax a.out binaries, building a GDB
   indistingushable from NetBSD/vax a.out binaries, building a GDB
   that should support both these targets will probably not work as
   that should support both these targets will probably not work as
   expected.  */
   expected.  */
#define GDB_OSABI_OPENBSD_AOUT GDB_OSABI_NETBSD_AOUT
#define GDB_OSABI_OPENBSD_AOUT GDB_OSABI_NETBSD_AOUT
 
 
static enum gdb_osabi
static enum gdb_osabi
vaxobsd_aout_osabi_sniffer (bfd *abfd)
vaxobsd_aout_osabi_sniffer (bfd *abfd)
{
{
  if (strcmp (bfd_get_target (abfd), "a.out-vax-netbsd") == 0)
  if (strcmp (bfd_get_target (abfd), "a.out-vax-netbsd") == 0)
    return GDB_OSABI_OPENBSD_AOUT;
    return GDB_OSABI_OPENBSD_AOUT;
 
 
  return GDB_OSABI_UNKNOWN;
  return GDB_OSABI_UNKNOWN;
}
}


 
 
/* Provide a prototype to silence -Wmissing-prototypes.  */
/* Provide a prototype to silence -Wmissing-prototypes.  */
void _initialize_vaxobsd_tdep (void);
void _initialize_vaxobsd_tdep (void);
 
 
void
void
_initialize_vaxobsd_tdep (void)
_initialize_vaxobsd_tdep (void)
{
{
  gdbarch_register_osabi_sniffer (bfd_arch_vax, bfd_target_aout_flavour,
  gdbarch_register_osabi_sniffer (bfd_arch_vax, bfd_target_aout_flavour,
                                  vaxobsd_aout_osabi_sniffer);
                                  vaxobsd_aout_osabi_sniffer);
 
 
  gdbarch_register_osabi (bfd_arch_vax, 0, GDB_OSABI_OPENBSD_AOUT,
  gdbarch_register_osabi (bfd_arch_vax, 0, GDB_OSABI_OPENBSD_AOUT,
                          vaxobsd_init_abi);
                          vaxobsd_init_abi);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.