From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24665 invoked by alias); 21 Feb 2012 16:08:02 -0000 Received: (qmail 24612 invoked by uid 22791); 21 Feb 2012 16:08:00 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,TW_EG,TW_NV,TW_YM X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Feb 2012 16:07:44 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id B12C7290088; Tue, 21 Feb 2012 17:07:43 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ydRZfWM7uE+R; Tue, 21 Feb 2012 17:07:43 +0100 (CET) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 9E29C290081; Tue, 21 Feb 2012 17:07:43 +0100 (CET) Subject: Re: RFA: New port: ia64-hp-openvms (3/3) - ia64-vms-tdep.c Mime-Version: 1.0 (Apple Message framework v1257) Content-Type: text/plain; charset=windows-1252 From: Tristan Gingold In-Reply-To: <4F3BA24E.8070009@redhat.com> Date: Tue, 21 Feb 2012 16:23:00 -0000 Cc: "gdb-patches@sourceware.org ml" , Rupp Douglas Content-Transfer-Encoding: quoted-printable Message-Id: <5ED28A1C-018A-4060-9D16-CABBB23EB860@adacore.com> References: <6AD2487F-8409-4F4E-93A6-9DB7FD195E71@adacore.com> <190A7167-B038-4EC0-82FD-815B306B4975@adacore.com> <4D8B23BF-A8D1-4698-8539-DF953219948B@adacore.com> <4F3A9ED3.7090408@redhat.com> <3F9413FC-FB03-4970-B9FB-C628E5663826@adacore.com> <4F3BA24E.8070009@redhat.com> To: Pedro Alves X-IsSubscribed: yes 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: 2012-02/txt/msg00435.txt.bz2 On Feb 15, 2012, at 1:17 PM, Pedro Alves wrote: > On 02/15/2012 08:05 AM, Tristan Gingold wrote: >>=20 >> On Feb 14, 2012, at 6:50 PM, Pedro Alves wrote: >=20 >>>> + info_len =3D extract_unsigned_integer (buf + 0, 4, byte_order); >>>> + pi->unwind_info_size =3D 8 * info_len; >>>> + >>>> + /* Read info. */ >>>> + pi->unwind_info =3D malloc (pi->unwind_info_size); >>>=20 >>> xmalloc >>=20 >> Humm, do we want to exit abruptly in case of memory error ? Note that w= e test the return status. Hi, this is the new version. > Ah, missed that. Fine with me to stay with malloc. What does > libunwind do when one returns -UNW_ENOMEM? My understanding is that libunwind properly propagate the error, and =85 > Does GDB end up recovering correctly, > or do we end up busted anyway? =85 gdb recovers. But because it is so likely that gdb will fail later, I have switched to xm= alloc/xfree. >> (OTOH, if malloc fails here, it is likely that the next xmalloc will too= ). >=20 > Right=85 Tristan. 2012-02-10 Tristan Gingold * ia64-tdep.h: Include libunwind-frame.h and libunwind-ia64.h. (ia64_unw_accessors, ia64_unw_rse_accessors) (ia64_libunwind_descr): Declare. * ia64-vms-tdep.c: New file. * ia64-tdep.c (ia64_unw_accessors, ia64_unw_rse_accessors) (ia64_libunwind_descr): Make them public. * configure.tgt: Add ia64-*-*vms*. * Makefile.in (ALL_64_TARGET_OBS): Add ia64-vms-tdep.o (ALLDEPFILES): Add ia64-vms-tdep.c diff --git a/configure.ac b/configure.ac index 9d48e90..c24fff4 100644 --- a/configure.ac +++ b/configure.ac @@ -929,8 +929,8 @@ case "${target}" in noconfigdirs=3D"$noconfigdirs libgui itcl ld" ;; ia64*-*-*vms*) - # No gdb or ld support yet. - noconfigdirs=3D"$noconfigdirs readline libgui itcl gdb ld" + # No ld support yet. + noconfigdirs=3D"$noconfigdirs libgui itcl ld" ;; i[[3456789]]86-w64-mingw*) ;; diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 3e1b93c..357a6db 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -516,7 +516,7 @@ ALL_64_TARGET_OBS =3D \ amd64fbsd-tdep.o amd64-darwin-tdep.o amd64-dicos-tdep.o \ amd64-linux-tdep.o amd64nbsd-tdep.o \ amd64obsd-tdep.o amd64-sol2-tdep.o amd64-tdep.o amd64-windows-tdep.o \ - ia64-hpux-tdep.o ia64-linux-tdep.o ia64-tdep.o \ + ia64-hpux-tdep.o ia64-linux-tdep.o ia64-vms-tdep.o ia64-tdep.o \ mips64obsd-tdep.o \ sparc64fbsd-tdep.o sparc64-linux-tdep.o sparc64nbsd-tdep.o \ sparc64obsd-tdep.o sparc64-sol2-tdep.o sparc64-tdep.o @@ -1458,7 +1458,7 @@ ALLDEPFILES =3D \ i386-sol2-nat.c i386-sol2-tdep.c \ i386gnu-nat.c i386gnu-tdep.c \ ia64-hpux-nat.c ia64-hpux-tdep.c \ - ia64-linux-nat.c ia64-linux-tdep.c ia64-tdep.c \ + ia64-linux-nat.c ia64-linux-tdep.c ia64-tdep.c ia64-vms-tdep.c \ inf-ptrace.c inf-ttrace.c \ irix5-nat.c \ libunwind-frame.c \ diff --git a/gdb/configure.tgt b/gdb/configure.tgt index 5e97ab4..6b4a504 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt @@ -246,6 +246,10 @@ ia64-*-linux*) solib-svr4.o symfile-mem.o" build_gdbserver=3Dyes ;; +ia64-*-*vms*) + # Target: Intel IA-64 running OpenVMS + gdb_target_obs=3D"ia64-tdep.o ia64-vms-tdep.o" + ;; ia64*-*-*) # Target: Intel IA-64 gdb_target_obs=3D"ia64-tdep.o" diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index a36dc22..1c4fa8f 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -3148,7 +3148,7 @@ static const struct frame_unwind ia64_libunwind_sigtr= amp_frame_unwind =3D }; =20 /* Set of libunwind callback acccessor functions. */ -static unw_accessors_t ia64_unw_accessors =3D +unw_accessors_t ia64_unw_accessors =3D { ia64_find_proc_info_x, ia64_put_unwind_info, @@ -3164,7 +3164,7 @@ static unw_accessors_t ia64_unw_accessors =3D the rse registers. At the top of the stack, we want libunwind to figur= e out how to read r32 - r127. Though usually they are found sequentially in memory starting from $bof, this is not always true. */ -static unw_accessors_t ia64_unw_rse_accessors =3D +unw_accessors_t ia64_unw_rse_accessors =3D { ia64_find_proc_info_x, ia64_put_unwind_info, @@ -3178,7 +3178,7 @@ static unw_accessors_t ia64_unw_rse_accessors =3D =20 /* Set of ia64 gdb libunwind-frame callbacks and data for generic libunwind-frame code to use. */ -static struct libunwind_descr ia64_libunwind_descr =3D +struct libunwind_descr ia64_libunwind_descr =3D { ia64_gdb2uw_regnum,=20 ia64_uw2gdb_regnum,=20 diff --git a/gdb/ia64-tdep.h b/gdb/ia64-tdep.h index 48cc3e0..7501eb4 100644 --- a/gdb/ia64-tdep.h +++ b/gdb/ia64-tdep.h @@ -20,6 +20,11 @@ #ifndef IA64_TDEP_H #define IA64_TDEP_H =20 +#ifdef HAVE_LIBUNWIND_IA64_H +#include "libunwind-ia64.h" +#include "libunwind-frame.h" +#endif + /* Register numbers of various important registers. */ =20 /* General registers; there are 128 of these 64 bit wide registers. @@ -250,4 +255,10 @@ struct gdbarch_tdep =20 extern void ia64_write_pc (struct regcache *, CORE_ADDR); =20 +#ifdef HAVE_LIBUNWIND_IA64_H +extern unw_accessors_t ia64_unw_accessors; +extern unw_accessors_t ia64_unw_rse_accessors; +extern struct libunwind_descr ia64_libunwind_descr; +#endif + #endif /* ia64-tdep.h */ diff --git a/gdb/ia64-vms-tdep.c b/gdb/ia64-vms-tdep.c new file mode 100644 index 0000000..dec66e1 --- /dev/null +++ b/gdb/ia64-vms-tdep.c @@ -0,0 +1,168 @@ +/* Target-dependent code for OpenVMS IA-64. + + Copyright (C) 2012 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 "frame-unwind.h" +#include "ia64-tdep.h" +#include "osabi.h" +#include "gdbtypes.h" +#include "solib.h" +#include "target.h" +#include "frame.h" +#include "regcache.h" +#include "gdbcore.h" +#include "inferior.h" + +#ifdef HAVE_LIBUNWIND_IA64_H + +/* Libunwind callback accessor function to acquire procedure unwind-info. = */ + +static int +ia64_vms_find_proc_info_x (unw_addr_space_t as, unw_word_t ip, + unw_proc_info_t *pi, + int need_unwind_info, void *arg) +{ + enum bfd_endian byte_order =3D gdbarch_byte_order (target_gdbarch); + unw_dyn_info_t di; + int ret; + gdb_byte buf[32]; + const char *annex =3D core_addr_to_string (ip); + LONGEST res; + CORE_ADDR table_addr; + unsigned int info_len; + + res =3D target_read (¤t_target, TARGET_OBJECT_OPENVMS_UIB, + annex + 2, buf, 0, sizeof (buf)); + + if (res !=3D sizeof (buf)) + return -UNW_ENOINFO; + + pi->format =3D UNW_INFO_FORMAT_REMOTE_TABLE; + pi->start_ip =3D extract_unsigned_integer (buf + 0, 8, byte_order); + pi->end_ip =3D extract_unsigned_integer (buf + 8, 8, byte_order); + pi->gp =3D extract_unsigned_integer (buf + 24, 8, byte_order); + table_addr =3D extract_unsigned_integer (buf + 16, 8, byte_order); + + if (table_addr =3D=3D 0) + { + /* No unwind data. */ + pi->unwind_info =3D NULL; + pi->unwind_info_size =3D 0; + return 0; + } + + res =3D target_read_memory (table_addr, buf, 8); + if (res !=3D 0) + return -UNW_ENOINFO; + + /* Check version. */ + if (extract_unsigned_integer (buf + 6, 2, byte_order) !=3D 1) + return -UNW_EBADVERSION; + info_len =3D extract_unsigned_integer (buf + 0, 4, byte_order); + pi->unwind_info_size =3D 8 * info_len; + + /* Read info. */ + pi->unwind_info =3D xmalloc (pi->unwind_info_size); + + res =3D target_read_memory (table_addr + 8, + pi->unwind_info, pi->unwind_info_size); + if (res !=3D 0) + { + xfree (pi->unwind_info); + pi->unwind_info =3D NULL; + return -UNW_ENOINFO; + } + + /* FIXME: Handle OSSD (OS Specific Data). This extension to ia64 unwind + information by OpenVMS is currently not handled by libunwind, but + looks to be used only in very specific context, and is not generated = by + GCC. */ + + pi->lsda =3D table_addr + 8 + pi->unwind_info_size; + if (extract_unsigned_integer (buf + 4, 2, byte_order) & 3) + { + pi->lsda +=3D 8; + /* There might be an handler, but this is not used for unwinding. */ + pi->handler =3D 0; + } + + return 0; +} + +/* Libunwind callback accessor function for cleanup. */ +static void +ia64_vms_put_unwind_info (unw_addr_space_t as, + unw_proc_info_t *pip, void *arg) +{ + /* Nothing required for now. */ +} + +/* Libunwind callback accessor function to get head of the dynamic + unwind-info registration list. */ +static int +ia64_vms_get_dyn_info_list (unw_addr_space_t as, + unw_word_t *dilap, void *arg) +{ + return -UNW_ENOINFO; +} + +/* Set of libunwind callback acccessor functions. */ +static unw_accessors_t ia64_vms_unw_accessors; +static unw_accessors_t ia64_vms_unw_rse_accessors; + +/* Set of ia64 gdb libunwind-frame callbacks and data for generic + libunwind-frame code to use. */ +static struct libunwind_descr ia64_vms_libunwind_descr; + +#endif /* HAVE_LIBUNWIND_IA64_H */ + +static void +ia64_openvms_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad); + +#ifdef HAVE_LIBUNWIND_IA64_H + /* Override the default descriptor. */ + ia64_vms_unw_accessors =3D ia64_unw_accessors; + ia64_vms_unw_accessors.find_proc_info =3D ia64_vms_find_proc_info_x; + ia64_vms_unw_accessors.put_unwind_info =3D ia64_vms_put_unwind_info; + ia64_vms_unw_accessors.get_dyn_info_list_addr =3D ia64_vms_get_dyn_info_= list; + + ia64_vms_unw_rse_accessors =3D ia64_unw_rse_accessors; + ia64_vms_unw_rse_accessors.find_proc_info =3D ia64_vms_find_proc_info_x; + ia64_vms_unw_rse_accessors.put_unwind_info =3D ia64_vms_put_unwind_info; + ia64_vms_unw_rse_accessors.get_dyn_info_list_addr =3D ia64_vms_get_dyn_i= nfo_list; + + ia64_vms_libunwind_descr =3D ia64_libunwind_descr; + ia64_vms_libunwind_descr.accessors =3D &ia64_vms_unw_accessors; + ia64_vms_libunwind_descr.special_accessors =3D &ia64_vms_unw_rse_accesso= rs; + + libunwind_frame_set_descr (gdbarch, &ia64_vms_libunwind_descr); +#endif +} + +/* Provide a prototype to silence -Wmissing-prototypes. */ +extern initialize_file_ftype _initialize_ia64_hpux_tdep; + +void +_initialize_ia64_hpux_tdep (void) +{ + gdbarch_register_osabi (bfd_arch_ia64, 0, GDB_OSABI_OPENVMS, + ia64_openvms_init_abi); +}