From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway23.websitewelcome.com (gateway23.websitewelcome.com [192.185.49.180]) by sourceware.org (Postfix) with ESMTPS id 67D6A385E039 for ; Sun, 22 Mar 2020 18:45:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 67D6A385E039 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 1F6CE4430 for ; Sun, 22 Mar 2020 13:45:30 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id G5bGjQ11PVQh0G5bGjeUWL; Sun, 22 Mar 2020 13:45:30 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=eFrvDF8CdlyTblyCHlLmp/XTdRc+468k1YcaHj7sx8Q=; b=RlIcvTrOpdfSIZmgVNi34pRhr6 DT+AlLYqpALHyKJS2ySbcPdzsw4NnWN7dFyT8VWqRYF/vPEVQLpkJ0LeYCGKsHaL3gBMGKGNYpTRZ 8Y+KZfO3Nn8sAmuGiGFZpvwII; Received: from 97-118-117-21.hlrn.qwest.net ([97.118.117.21]:48304 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jG5bF-000LNS-TZ; Sun, 22 Mar 2020 12:45:29 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 21/22] Move DWARF-constant stringifying code to new file Date: Sun, 22 Mar 2020 12:45:22 -0600 Message-Id: <20200322184523.28959-22-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200322184523.28959-1-tom@tromey.com> References: <20200322184523.28959-1-tom@tromey.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.118.117.21 X-Source-L: No X-Exim-ID: 1jG5bF-000LNS-TZ X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-117-21.hlrn.qwest.net (bapiya.Home) [97.118.117.21]:48304 X-Source-Auth: tom+tromey.com X-Email-Count: 22 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-22.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, JMQ_SPF_NEUTRAL, KAM_SHORT, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, URIBL_CSS, URIBL_CSS_A autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Mar 2020 18:45:34 -0000 This moves the DWARF debugging functions that stringify various constants to a new file, dwarf2/stringify.c. gdb/ChangeLog 2020-03-22 Tom Tromey * dwarf2/read.c (dwarf_unit_type_name, dwarf_tag_name) (dwarf_attr_name, dwarf_form_name, dwarf_bool_name) (dwarf_type_encoding_name): Move to stringify.c. * Makefile.in (COMMON_SFILES): Add dwarf2/stringify.c. * dwarf2/stringify.c: New file. * dwarf2/stringify.h: New file. --- gdb/ChangeLog | 9 ++++ gdb/Makefile.in | 1 + gdb/dwarf2/read.c | 94 +-------------------------------- gdb/dwarf2/stringify.c | 114 +++++++++++++++++++++++++++++++++++++++++ gdb/dwarf2/stringify.h | 38 ++++++++++++++ 5 files changed, 163 insertions(+), 93 deletions(-) create mode 100644 gdb/dwarf2/stringify.c create mode 100644 gdb/dwarf2/stringify.h diff --git a/gdb/Makefile.in b/gdb/Makefile.in index f66affd3e5f..bc3ef695bbd 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1016,6 +1016,7 @@ COMMON_SFILES = \ dwarf2/macro.c \ dwarf2/read.c \ dwarf2/section.c \ + dwarf2/stringify.c \ eval.c \ event-loop.c \ event-top.c \ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 9e7152d03e6..87305ec3688 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -40,6 +40,7 @@ #include "dwarf2/dwz.h" #include "dwarf2/macro.h" #include "dwarf2/die.h" +#include "dwarf2/stringify.h" #include "bfd.h" #include "elf-bfd.h" #include "symtab.h" @@ -1406,16 +1407,6 @@ static const char *dwarf2_physname (const char *name, struct die_info *die, static struct die_info *dwarf2_extension (struct die_info *die, struct dwarf2_cu **); -static const char *dwarf_tag_name (unsigned int); - -static const char *dwarf_attr_name (unsigned int); - -static const char *dwarf_form_name (unsigned int); - -static const char *dwarf_bool_name (unsigned int); - -static const char *dwarf_type_encoding_name (unsigned int); - static void dump_die_shallow (struct ui_file *, int indent, struct die_info *); static void dump_die_for_error (struct die_info *); @@ -21336,89 +21327,6 @@ dwarf2_extension (struct die_info *die, struct dwarf2_cu **ext_cu) return follow_die_ref (die, attr, ext_cu); } -/* A convenience function that returns an "unknown" DWARF name, - including the value of V. STR is the name of the entity being - printed, e.g., "TAG". */ - -static const char * -dwarf_unknown (const char *str, unsigned v) -{ - char *cell = get_print_cell (); - xsnprintf (cell, PRINT_CELL_SIZE, "DW_%s_", str, v); - return cell; -} - -/* Convert a DIE tag into its string name. */ - -static const char * -dwarf_tag_name (unsigned tag) -{ - const char *name = get_DW_TAG_name (tag); - - if (name == NULL) - return dwarf_unknown ("TAG", tag); - - return name; -} - -/* Convert a DWARF attribute code into its string name. */ - -static const char * -dwarf_attr_name (unsigned attr) -{ - const char *name; - -#ifdef MIPS /* collides with DW_AT_HP_block_index */ - if (attr == DW_AT_MIPS_fde) - return "DW_AT_MIPS_fde"; -#else - if (attr == DW_AT_HP_block_index) - return "DW_AT_HP_block_index"; -#endif - - name = get_DW_AT_name (attr); - - if (name == NULL) - return dwarf_unknown ("AT", attr); - - return name; -} - -/* Convert a DWARF value form code into its string name. */ - -static const char * -dwarf_form_name (unsigned form) -{ - const char *name = get_DW_FORM_name (form); - - if (name == NULL) - return dwarf_unknown ("FORM", form); - - return name; -} - -static const char * -dwarf_bool_name (unsigned mybool) -{ - if (mybool) - return "TRUE"; - else - return "FALSE"; -} - -/* Convert a DWARF type code into its string name. */ - -static const char * -dwarf_type_encoding_name (unsigned enc) -{ - const char *name = get_DW_ATE_name (enc); - - if (name == NULL) - return dwarf_unknown ("ATE", enc); - - return name; -} - static void dump_die_shallow (struct ui_file *f, int indent, struct die_info *die) { diff --git a/gdb/dwarf2/stringify.c b/gdb/dwarf2/stringify.c new file mode 100644 index 00000000000..0cdefe81081 --- /dev/null +++ b/gdb/dwarf2/stringify.c @@ -0,0 +1,114 @@ +/* DWARF stringify code + + Copyright (C) 1994-2020 Free Software Foundation, Inc. + + Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology, + Inc. with support from Florida State University (under contract + with the Ada Joint Program Office), and Silicon Graphics, Inc. + Initial contribution by Brent Benson, Harris Computer Systems, Inc., + based on Fred Fish's (Cygnus Support) implementation of DWARF 1 + support. + + 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 "dwarf2.h" +#include "dwarf2/stringify.h" + +/* A convenience function that returns an "unknown" DWARF name, + including the value of V. STR is the name of the entity being + printed, e.g., "TAG". */ + +static const char * +dwarf_unknown (const char *str, unsigned v) +{ + char *cell = get_print_cell (); + xsnprintf (cell, PRINT_CELL_SIZE, "DW_%s_", str, v); + return cell; +} + +/* See stringify.h. */ + +const char * +dwarf_tag_name (unsigned tag) +{ + const char *name = get_DW_TAG_name (tag); + + if (name == NULL) + return dwarf_unknown ("TAG", tag); + + return name; +} + +/* See stringify.h. */ + +const char * +dwarf_attr_name (unsigned attr) +{ + const char *name; + +#ifdef MIPS /* collides with DW_AT_HP_block_index */ + if (attr == DW_AT_MIPS_fde) + return "DW_AT_MIPS_fde"; +#else + if (attr == DW_AT_HP_block_index) + return "DW_AT_HP_block_index"; +#endif + + name = get_DW_AT_name (attr); + + if (name == NULL) + return dwarf_unknown ("AT", attr); + + return name; +} + +/* See stringify.h. */ + +const char * +dwarf_form_name (unsigned form) +{ + const char *name = get_DW_FORM_name (form); + + if (name == NULL) + return dwarf_unknown ("FORM", form); + + return name; +} + +/* See stringify.h. */ + +const char * +dwarf_bool_name (unsigned mybool) +{ + if (mybool) + return "TRUE"; + else + return "FALSE"; +} + +/* See stringify.h. */ + +const char * +dwarf_type_encoding_name (unsigned enc) +{ + const char *name = get_DW_ATE_name (enc); + + if (name == NULL) + return dwarf_unknown ("ATE", enc); + + return name; +} diff --git a/gdb/dwarf2/stringify.h b/gdb/dwarf2/stringify.h new file mode 100644 index 00000000000..d3b3d2c191a --- /dev/null +++ b/gdb/dwarf2/stringify.h @@ -0,0 +1,38 @@ +/* DWARF stringify code + + Copyright (C) 2003-2020 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 . */ + +#ifndef GDB_DWARF2_STRINGIFY_H +#define GDB_DWARF2_STRINGIFY_H + +/* Convert a DIE tag into its string name. */ +extern const char *dwarf_tag_name (unsigned tag); + +/* Convert a DWARF attribute code into its string name. */ +extern const char *dwarf_attr_name (unsigned attr); + +/* Convert a DWARF value form code into its string name. */ +extern const char *dwarf_form_name (unsigned form); + +/* Convert a boolean to a string form. */ +extern const char *dwarf_bool_name (unsigned mybool); + +/* Convert a DWARF type code into its string name. */ +extern const char *dwarf_type_encoding_name (unsigned enc); + +#endif /* GDB_DWARF2_STRINGIFY_H */ -- 2.17.2