From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14186 invoked by alias); 25 Apr 2010 15:48:26 -0000 Received: (qmail 13899 invoked by uid 22791); 25 Apr 2010 15:48:20 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=BAYES_00,TW_EG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 25 Apr 2010 15:48:09 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 022D42BACA0 for ; Sun, 25 Apr 2010 11:47:52 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 5A-R0LUdatSz for ; Sun, 25 Apr 2010 11:47:51 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id CD8472BAC98 for ; Sun, 25 Apr 2010 11:47:51 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 76710F5896; Sun, 25 Apr 2010 11:47:51 -0400 (EDT) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [vxworks 13/14] Add tdep files for x86 and powerpc. Date: Sun, 25 Apr 2010 15:48:00 -0000 Message-Id: <1272210447-13895-14-git-send-email-brobecker@adacore.com> In-Reply-To: <1272210447-13895-1-git-send-email-brobecker@adacore.com> References: <1272210447-13895-1-git-send-email-brobecker@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00845.txt.bz2 This patch adds a new GDB_OSABI_VXWORKS for VxWorks targets, and introduces new VxWorks tdep files for x86 and powerpc. They will be included in the build by the next patch. 2010-04-24 Joel Brobecker * defs.h (enum gdb_osabi): Add GDB_OSABI_VXWORKS. * osabi.c (gdb_osabi_names): Add entry for GDB_OSABI_VXWORKS. * i386-vxworks-tdep.c, rs6000-vxworks-tdep.c: New files. --- gdb/defs.h | 1 + gdb/i386-vxworks-tdep.c | 53 +++++++++++++++++++++++ gdb/osabi.c | 1 + gdb/rs6000-vxworks-tdep.c | 105 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+), 0 deletions(-) create mode 100644 gdb/i386-vxworks-tdep.c create mode 100644 gdb/rs6000-vxworks-tdep.c diff --git a/gdb/defs.h b/gdb/defs.h index e8a1dd4..a7f69ae 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -986,6 +986,7 @@ enum gdb_osabi GDB_OSABI_QNXNTO, GDB_OSABI_CYGWIN, GDB_OSABI_AIX, + GDB_OSABI_VXWORKS, GDB_OSABI_DICOS, GDB_OSABI_DARWIN, GDB_OSABI_SYMBIAN, diff --git a/gdb/i386-vxworks-tdep.c b/gdb/i386-vxworks-tdep.c new file mode 100644 index 0000000..a2248c8 --- /dev/null +++ b/gdb/i386-vxworks-tdep.c @@ -0,0 +1,53 @@ +/* Copyright (C) 2007, 2010 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "inferior.h" +#include "osabi.h" +#include "i386-tdep.h" + +static void +i386_vxworks_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + /* The AT_ENTRY_POINT method is not practical on VxWorks systems, + because there is no concept of "the" executable. Furthermore, + memory space is shared by all processes (and thus someone + spawning a new task using the same entry point might interfere + with our function call). So we rely on the ON_STACK method + instead. */ + set_gdbarch_call_dummy_location (gdbarch, ON_STACK); +} + +static enum gdb_osabi +i386_vxworks_osabi_sniffer (bfd * abfd) +{ + char *target_name = bfd_get_target (abfd); + + if (strstr (target_name, "vxworks") != NULL) + return GDB_OSABI_VXWORKS; + + return GDB_OSABI_UNKNOWN; +} +void +_initialize_vxworks_tdep (void) +{ + gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour, + i386_vxworks_osabi_sniffer); + gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_VXWORKS, + i386_vxworks_init_abi); +} + diff --git a/gdb/osabi.c b/gdb/osabi.c index 84590cd..60171e1 100644 --- a/gdb/osabi.c +++ b/gdb/osabi.c @@ -70,6 +70,7 @@ static const char * const gdb_osabi_names[] = "QNX Neutrino", "Cygwin", "AIX", + "VxWorks", "DICOS", "Darwin", "Symbian", diff --git a/gdb/rs6000-vxworks-tdep.c b/gdb/rs6000-vxworks-tdep.c new file mode 100644 index 0000000..2f10bfd --- /dev/null +++ b/gdb/rs6000-vxworks-tdep.c @@ -0,0 +1,105 @@ +/* Target-dependent code for GDB, the GNU debugger. + + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "gdbarch.h" +#include "osabi.h" +#include "ppc-tdep.h" +#include "gdb_assert.h" +#include "inferior.h" +#include "gdb_string.h" + +static CORE_ADDR +rs6000_vxworks_push_dummy_code (struct gdbarch *gdbarch, + CORE_ADDR sp, CORE_ADDR funaddr, + struct value **args, int nargs, + struct type *value_type, + CORE_ADDR *real_pc, CORE_ADDR *bp_addr, + struct regcache *regcache) +{ + /* Something here to findout the size of a breakpoint and then + allocate space for it on the stack. */ + int bplen; + /* This code assumes frame align. */ + gdb_assert (gdbarch_frame_align_p (gdbarch)); + /* Force the stack's alignment. The intent is to ensure that the SP + is aligned to at least a breakpoint instruction's boundary. */ + sp = gdbarch_frame_align (gdbarch, sp); + /* Allocate space for, and then position the breakpoint on the stack. */ + if (gdbarch_inner_than (gdbarch, 1, 2)) + { + CORE_ADDR bppc = sp; + gdbarch_breakpoint_from_pc (gdbarch, &bppc, &bplen); + sp = gdbarch_frame_align (gdbarch, sp - bplen); + (*bp_addr) = sp; + /* Should the breakpoint size/location be re-computed here? */ + } + else + { + (*bp_addr) = sp; + gdbarch_breakpoint_from_pc (gdbarch, bp_addr, &bplen); + sp = gdbarch_frame_align (gdbarch, sp + bplen); + } + /* Inferior resumes at the function entry point. */ + (*real_pc) = funaddr; + return sp; +} + +static void +rs6000_vxworks_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + /* Certain versions of VxWorks do not provide support for Altivec + registers. For now, disable support for these registers on all + versions of GDB. */ + tdep->ppc_vr0_regnum = -1; + tdep->ppc_vrsave_regnum = -1; + + /* The AT_ENTRY_POINT method is not practical on VxWorks systems, + because there is no concept of "the" executable. Furthermore, + memory space is shared by all processes (and thus someone + spawning a new task using the same entry point might interfere + with our function call). So we rely on the ON_STACK method + instead. */ + set_gdbarch_call_dummy_location (gdbarch, ON_STACK); + set_gdbarch_push_dummy_code (gdbarch, rs6000_vxworks_push_dummy_code); +} + +static enum gdb_osabi +rs6000_vxworks_osabi_sniffer (bfd * abfd) +{ + char *target_name = bfd_get_target (abfd); + + if (strstr (target_name, "vxworks") != NULL) + return GDB_OSABI_VXWORKS; + + return GDB_OSABI_UNKNOWN; +} + +void +_initialize_rs6000_vxworks_tdep (void) +{ + /* Register the sniffer for the VxWorks targets. */ + gdbarch_register_osabi_sniffer (bfd_arch_powerpc, bfd_target_elf_flavour, + rs6000_vxworks_osabi_sniffer); + gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_VXWORKS, + rs6000_vxworks_init_abi); +} + -- 1.6.3.3