From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id pdDDCHF2U2AdJAAAWB0awg (envelope-from ) for ; Thu, 18 Mar 2021 11:49:05 -0400 Received: by simark.ca (Postfix, from userid 112) id 198101EF78; Thu, 18 Mar 2021 11:49:05 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6EC4F1E789 for ; Thu, 18 Mar 2021 11:49:04 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C93013858002; Thu, 18 Mar 2021 15:49:03 +0000 (GMT) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 089AF385781F for ; Thu, 18 Mar 2021 15:49:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 089AF385781F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-ej1-x633.google.com with SMTP id ce10so4707935ejb.6 for ; Thu, 18 Mar 2021 08:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=J4sm5ODZBceESHJR/MJsUKrq34Q0AV3p4ptXzEr5Xsc=; b=eirM4gcQNl38zLxvniM5vthqjpf4ihGjEov9t3r344q9TahgkQcO4LPfcl9V3mhZ/M lhfiNO9p5i06fFbyVo1UoVwCjp9Mm9GwcCmYK+LxSjhAYgNUFnv7pWBECP/c56zvREof 8CdQpYiu/piOh3Nsxzvv0yZpexT1++2VdH1uHIrygTV9i6eiMyteSBOKvi0Y/NXgbP6L h4WYhi73uxEAT6ikd8V47HR63W+LSZLILhAGln/zTKEUA0y4tp4MEm6Xbges0Vh6Z+S4 qEDeGfMOa59naLHd22x93ocxytUsTdsyIecte0g7roYuZZNxMHKpUFlCs193IEW1hzlD vzbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J4sm5ODZBceESHJR/MJsUKrq34Q0AV3p4ptXzEr5Xsc=; b=RcdVZOSYgUhsB1XXm1tO9NUXC+FShnqlOdlrxgXVsIEvp+Veml1C1AzR7GZdZRUEz4 1BhzJB3VfuOyZvfUoU86TMopnR9BbodmfW8WADYT4kuUb+V0mRSHlBRLCQ8RmBblAask g+dxMhbK/1FiKhEx4D45TyCWiXhJxVZ4W2TUzcyN8W2ed9NTvqsSpweBColDXmu2AZp6 /0jmEbPrTz3WfPrsTqtTU849sXKyaL4Z92MVhzn3pKkLE+1rhtz6g9wLUSGf+BQ8pnWH 5Yx7GJksq18x5AJMQrEHQRlztcV4JdL0i63RVdFDiNVQt1DARcfq+StWttdQn757UJay 6xpQ== X-Gm-Message-State: AOAM5326j0lThP0EEPXK4zKCqEm0gi1h9SNwPdDQX3mn1WqsqcXrwfaB RwSlirYPvaPDyqu5NTdkrJzHhA== X-Google-Smtp-Source: ABdhPJyvIadTUs3bNQYuoa/4VOLjo9oRjj++FTi0/WiexaiHqX3H7X4/EB4ESzQAZ8o3qsz68bXhJA== X-Received: by 2002:a17:907:d15:: with SMTP id gn21mr40544694ejc.337.1616082540129; Thu, 18 Mar 2021 08:49:00 -0700 (PDT) Received: from localhost (host165-120-118-227.range165-120.btcentralplus.com. [165.120.118.227]) by smtp.gmail.com with ESMTPSA id u15sm2535021eds.6.2021.03.18.08.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 08:48:59 -0700 (PDT) Date: Thu, 18 Mar 2021 15:48:58 +0000 From: Andrew Burgess To: Tom Tromey Subject: Re: [PATCH] Reimplement dwarf_unit_type_name Message-ID: <20210318154858.GE5520@embecosm.com> References: <20210318150524.3677886-1-tromey@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210318150524.3677886-1-tromey@adacore.com> X-Operating-System: Linux/5.8.13-100.fc31.x86_64 (x86_64) X-Uptime: 15:48:48 up 6 days, 23:00, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] 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: , Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" * Tom Tromey [2021-03-18 09:05:24 -0600]: > I noticed that dwarf_unit_type_name is nearly identical to > get_DW_UT_name from libiberty; but rather than simply replacing it, it > seemed better to have it work like the other DWARF constant > stringification functions -- return a string showing unrecognized > numeric forms rather than nullptr. (The previous code did include > numeric values for the recognized constants, but this seems to be not > that useful to me.) > > gdb/ChangeLog > 2021-03-18 Tom Tromey > > * dwarf2/stringify.c (dwarf_unit_type_name): New function. Use > get_DW_UT_name. > * dwarf2/stringify.h (dwarf_unit_type_name): Declare. > * dwarf2/comp-unit.c (dwarf_unit_type_name): Remove. LGTM. Thanks, Andrew > --- > gdb/ChangeLog | 7 +++++++ > gdb/dwarf2/comp-unit.c | 29 +---------------------------- > gdb/dwarf2/stringify.c | 13 +++++++++++++ > gdb/dwarf2/stringify.h | 3 +++ > 4 files changed, 24 insertions(+), 28 deletions(-) > > diff --git a/gdb/dwarf2/comp-unit.c b/gdb/dwarf2/comp-unit.c > index 72b4e80d808..ce3b55778f4 100644 > --- a/gdb/dwarf2/comp-unit.c > +++ b/gdb/dwarf2/comp-unit.c > @@ -29,34 +29,7 @@ > #include "dwarf2/leb.h" > #include "dwarf2/read.h" > #include "dwarf2/section.h" > - > -/* Convert a unit type to corresponding DW_UT name. */ > - > -static const char * > -dwarf_unit_type_name (int unit_type) > -{ > - switch (unit_type) > - { > - case 0x01: > - return "DW_UT_compile (0x01)"; > - case 0x02: > - return "DW_UT_type (0x02)"; > - case 0x03: > - return "DW_UT_partial (0x03)"; > - case 0x04: > - return "DW_UT_skeleton (0x04)"; > - case 0x05: > - return "DW_UT_split_compile (0x05)"; > - case 0x06: > - return "DW_UT_split_type (0x06)"; > - case 0x80: > - return "DW_UT_lo_user (0x80)"; > - case 0xff: > - return "DW_UT_hi_user (0xff)"; > - default: > - return nullptr; > - } > -} > +#include "dwarf2/stringify.h" > > /* See comp-unit.h. */ > > diff --git a/gdb/dwarf2/stringify.c b/gdb/dwarf2/stringify.c > index 43e88f9043f..b292f9fccc8 100644 > --- a/gdb/dwarf2/stringify.c > +++ b/gdb/dwarf2/stringify.c > @@ -112,3 +112,16 @@ dwarf_type_encoding_name (unsigned enc) > > return name; > } > + > +/* See stringify.h. */ > + > +const char * > +dwarf_unit_type_name (int unit_type) > +{ > + const char *name = get_DW_UT_name (unit_type); > + > + if (name == nullptr) > + return dwarf_unknown ("UT", unit_type); > + > + return name; > +} > diff --git a/gdb/dwarf2/stringify.h b/gdb/dwarf2/stringify.h > index ada4c1e77e7..d2139d91db9 100644 > --- a/gdb/dwarf2/stringify.h > +++ b/gdb/dwarf2/stringify.h > @@ -35,4 +35,7 @@ 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); > > +/* Convert a DWARF unit type into is string name. */ > +extern const char *dwarf_unit_type_name (int unit_type); > + > #endif /* GDB_DWARF2_STRINGIFY_H */ > -- > 2.26.2 >