From patchwork Thu Jun 23 20:34:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 13346 Received: (qmail 16712 invoked by alias); 23 Jun 2016 20:39:32 -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 16158 invoked by uid 89); 23 Jun 2016 20:39:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=Install, sk:gdbarch, auxv_format, AUXV 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, 23 Jun 2016 20:39:22 +0000 Received: from ralph.com (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 9C34FB9C2 for ; Thu, 23 Jun 2016 16:39:05 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v2 6/6] Add a gdbarch 'print_auxv_entry' method for FreeBSD ABIs. Date: Thu, 23 Jun 2016 13:34:15 -0700 Message-Id: <20160623203415.62681-7-jhb@FreeBSD.org> In-Reply-To: <20160623203415.62681-1-jhb@FreeBSD.org> References: <20160623203415.62681-1-jhb@FreeBSD.org> X-IsSubscribed: yes Add a 'print_auxv_entry' method for FreeBSD ABIs that parses FreeBSD-specific auxiliary vector entries and outputs a suitable description using fprint_auxv_entry. gdb/ChangeLog: * fbsd-tdep.c: Include "auxv.h". (fbsd_print_auxv_entry): New function. (fbsd_init_abi): Install gdbarch "print_auxv_entry" method. --- gdb/ChangeLog | 6 ++++++ gdb/fbsd-tdep.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4db74fb..95a5375 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2016-06-23 John Baldwin + * fbsd-tdep.c: Include "auxv.h". + (fbsd_print_auxv_entry): New function. + (fbsd_init_abi): Install gdbarch "print_auxv_entry" method. + +2016-06-23 John Baldwin + * auxv.c (fprint_auxv_entry): New function. (default_print_auxv_entry): New function. (fprint_target_auxv): Use gdbarch_print_auxv_entry. diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 7310ea0..e8f8605 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,39 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) return note_data; } +/* Print descriptions of FreeBSD-specific AUXV entries to FILE. */ + +static void +fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file, + CORE_ADDR type, CORE_ADDR val) +{ + const char *name; + const char *description; + enum auxv_format format; + + 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; format = kind; break + TAG (EXECPATH, _("Executable path"), AUXV_FORMAT_STR); + TAG (CANARY, _("Canary for SSP"), AUXV_FORMAT_HEX); + TAG (CANARYLEN, ("Length of the SSP canary"), AUXV_FORMAT_DEC); + TAG (OSRELDATE, _("OSRELDATE"), AUXV_FORMAT_DEC); + TAG (NCPUS, _("Number of CPUs"), AUXV_FORMAT_DEC); + TAG (PAGESIZES, _("Pagesizes"), AUXV_FORMAT_HEX); + TAG (PAGESIZESLEN, _("Number of pagesizes"), AUXV_FORMAT_DEC); + TAG (TIMEKEEP, _("Pointer to timehands"), AUXV_FORMAT_HEX); + TAG (STACKPROT, _("Initial stack protection"), AUXV_FORMAT_HEX); + default: + default_print_auxv_entry (gdbarch, file, type, val); + return; + } + + fprint_auxv_entry (file, name, description, format, type, val); +} + /* To be called from GDB_OSABI_FREEBSD_ELF handlers. */ void @@ -291,4 +325,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_entry (gdbarch, fbsd_print_auxv_entry); }