From patchwork Thu Jun 16 06:02:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 13126 Received: (qmail 125785 invoked by alias); 16 Jun 2016 06:02:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 125642 invoked by uid 89); 16 Jun 2016 06:02:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=dec, Hx-languages-length:2751, 3235, sk:freebsd X-Spam-User: qpsmtpd, 2 recipients X-HELO: bigwig.baldwin.cx Received: from bigwig.baldwin.cx (HELO bigwig.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 16 Jun 2016 06:02:24 +0000 Received: from ralph.baldwin.cx.net (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 3CCADB9C2; Thu, 16 Jun 2016 02:02:20 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org, binutils@sourceware.org Subject: [PATCH 6/6] Add a gdbarch 'print_auxv' method for FreeBSD ABIs. Date: Wed, 15 Jun 2016 23:02:02 -0700 Message-Id: <20160616060202.63470-7-jhb@FreeBSD.org> In-Reply-To: <20160616060202.63470-1-jhb@FreeBSD.org> References: <20160616060202.63470-1-jhb@FreeBSD.org> X-IsSubscribed: yes Add a 'print_auxv' method for FreeBSD ABIs that parses FreeBSD-specific auxiliary vector entries and outputs a suitable description using fprint_single_auxv. gdb/ChangeLog: * fbsd-tdep.c: Include "auxv.h". (fbsd_print_auxv): New function. (fbsd_init_abi): Install gdbarch "print_auxv" method. --- gdb/ChangeLog | 6 ++++++ gdb/fbsd-tdep.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2426a2f..27d4620 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2016-06-15 John Baldwin + * fbsd-tdep.c: Include "auxv.h". + (fbsd_print_auxv): New function. + (fbsd_init_abi): Install gdbarch "print_auxv" method. + +2016-06-15 John Baldwin + * auxv.c (fprint_single_auxv): New function. (default_print_auxv): New function. (fprint_target_auxv): Use gdbarch_print_auxv and default_print_auxv. diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 7310ea0..8aca570 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include "defs.h" +#include "auxv.h" #include "gdbcore.h" #include "inferior.h" #include "regcache.h" @@ -283,6 +284,37 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) return note_data; } +static int +fbsd_print_auxv (struct gdbarch *gdbarch, struct ui_file *file, CORE_ADDR type, + CORE_ADDR val) +{ + const char *name; + const char *description; + enum auxv_format flavor; + + switch (type) + { +#define _TAGNAME(tag) #tag +#define TAGNAME(tag) _TAGNAME(AT_##tag) +#define TAG(tag, text, kind) \ + case AT_FREEBSD_##tag: name = TAGNAME(tag); description = text; flavor = kind; break + TAG (EXECPATH, _("Executable path"), str); + TAG (CANARY, _("Canary for SSP"), hex); + TAG (CANARYLEN, ("Length of the SSP canary"), dec); + TAG (OSRELDATE, _("OSRELDATE"), dec); + TAG (NCPUS, _("Number of CPUs"), dec); + TAG (PAGESIZES, _("Pagesizes"), hex); + TAG (PAGESIZESLEN, _("Number of pagesizes"), dec); + TAG (TIMEKEEP, _("Pointer to timehands"), hex); + TAG (STACKPROT, _("Initial stack protection"), hex); + default: + return (0); + } + + fprint_single_auxv (file, name, description, flavor, type, val); + return (1); +} + /* To be called from GDB_OSABI_FREEBSD_ELF handlers. */ void @@ -291,4 +323,5 @@ fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_core_pid_to_str (gdbarch, fbsd_core_pid_to_str); set_gdbarch_core_thread_name (gdbarch, fbsd_core_thread_name); set_gdbarch_make_corefile_notes (gdbarch, fbsd_make_corefile_notes); + set_gdbarch_print_auxv (gdbarch, fbsd_print_auxv); }