From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 286743894415 for ; Thu, 22 Apr 2021 09:31:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 286743894415 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-wr1-x430.google.com with SMTP id c4so5160400wrt.8 for ; Thu, 22 Apr 2021 02:31:03 -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=FAW+Xzr87ordbjsCn2N3QbVReBcSjP4xuXpHeOQjqK0=; b=WDKaQbIXmchHk7Bp5pMVKLlOw8UZkV7CLPUbTWJNNWaoGiV7hyE56VrOptQvJC5SdY cTLv197DxH8GPd2OzDmcY5WOkXyNCuzYc1jlItQQbCL/5TUFyY/Q96TrBr9wXD0dxybU xBY1OuG9UIC34e2cTCSafo0LQGxXlE6Qd1htjERyVRz/1jmSQhl3Sx1cvmQelvwi7u7k fiaAA3AixzColMm60GP9yC7dG3joL7qkGqd2CiemS/ZAQCsPEa7p6GI7khshEUxMOia2 U+zf0HZbaXSevJZYKF0IXfi80Wn2U5DDKoapLHrcos7JTmzApQhwWYRYLfsRGJegyAOD ghOQ== 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=FAW+Xzr87ordbjsCn2N3QbVReBcSjP4xuXpHeOQjqK0=; b=SkC2hLz+U0BxIujHZPee9KuUGk8h+YfvB26dj4rTJQIS7nKq6WUsxwzmFctFy183/R kwiVooqkDbInjH2x5fr8cM5CdLdhwWVRPM/o/mdZJU3Hf+R44MQMLkEexUcmw7pCRB3A +xOr4NYFElOL9QTcN+izSIZBr7RkL3tZsY/Qh4nqt9G7+e+8UkqN4AUmBTFdW3Z0CL1V do6IkVg19tQi+TsS01ybGUgr38M6o52rZ58UYv93u15RtTam8SSAO1sgIBc5ANAe3yyu A30JXrIG0oCqFir6kzpy9w1ldBR0ckAzusdh6V5NiGdUatxCYqgWlzgA8fKJFA1H/0Ck doGw== X-Gm-Message-State: AOAM532FBbJeUqt7g90yUuqHHbCPzKl+ayQF+opnItF11fmsU3KfgRzf d21R/K/4gNhx/mMzHoLOMP4YtkpDRsEK7A== X-Google-Smtp-Source: ABdhPJxAre+hN+Dly9uZ2RO4l7e0cn7ogGrzTF87mDAg18jwfj2ptH5PyLz5SgHTz5lR8wyjuLbs5g== X-Received: by 2002:a5d:508d:: with SMTP id a13mr2928312wrt.182.1619083862028; Thu, 22 Apr 2021 02:31:02 -0700 (PDT) Received: from localhost (host109-151-46-70.range109-151.btcentralplus.com. [109.151.46.70]) by smtp.gmail.com with ESMTPSA id n9sm2242291wmo.27.2021.04.22.02.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 02:31:01 -0700 (PDT) Date: Thu, 22 Apr 2021 10:31:00 +0100 From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Fix ptype/o bug with "" Message-ID: <20210422093100.GM2610@embecosm.com> References: <20210422014904.3521301-1-tom@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210422014904.3521301-1-tom@tromey.com> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 10:30:36 up 11 days, 20:17, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: Thu, 22 Apr 2021 09:31:04 -0000 * Tom Tromey [2021-04-21 19:49:04 -0600]: > I noticed that when using ptype/o, the "" text that > may be emitted is indented incorrectly. This patch fixes the bug and > adds a new test case. > > I also removed a stray backslash from ptype-offsets.exp that I noticed > while writing the test. This seemed too trivial to warrant a separate > patch. > > gdb/ChangeLog > 2021-04-21 Tom Tromey > > * c-typeprint.c (c_type_print_base_struct_union): Use > print_spaces_filtered_with_print_options. > > gdb/testsuite/ChangeLog > 2021-04-21 Tom Tromey > > * gdb.base/ptype-offsets.cc (struct empty_member): New. > (main): Use empty_member. > * gdb.base/ptype-offsets.exp: Add new test. LGTM. Thanks, Andrew > --- > gdb/ChangeLog | 5 +++++ > gdb/c-typeprint.c | 7 +++---- > gdb/testsuite/ChangeLog | 6 ++++++ > gdb/testsuite/gdb.base/ptype-offsets.cc | 7 +++++++ > gdb/testsuite/gdb.base/ptype-offsets.exp | 17 ++++++++++++++++- > 5 files changed, 37 insertions(+), 5 deletions(-) > > diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c > index f81f1c2c113..72616a59af0 100644 > --- a/gdb/c-typeprint.c > +++ b/gdb/c-typeprint.c > @@ -1121,13 +1121,12 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, > if (type->num_fields () == 0 && TYPE_NFN_FIELDS (type) == 0 > && TYPE_TYPEDEF_FIELD_COUNT (type) == 0) > { > + print_spaces_filtered_with_print_options (level + 4, stream, flags); > if (type->is_stub ()) > - fprintf_filtered (stream, _("%*s%p[%p]\n"), > - level + 4, "", > + fprintf_filtered (stream, _("%p[%p]\n"), > metadata_style.style ().ptr (), nullptr); > else > - fprintf_filtered (stream, _("%*s%p[%p]\n"), > - level + 4, "", > + fprintf_filtered (stream, _("%p[%p]\n"), > metadata_style.style ().ptr (), nullptr); > } > > diff --git a/gdb/testsuite/gdb.base/ptype-offsets.cc b/gdb/testsuite/gdb.base/ptype-offsets.cc > index 4582af48cef..dc21e34752f 100644 > --- a/gdb/testsuite/gdb.base/ptype-offsets.cc > +++ b/gdb/testsuite/gdb.base/ptype-offsets.cc > @@ -185,6 +185,12 @@ struct static_member > int abc; > }; > > +struct empty_member > +{ > + struct { } empty; > + int an_int; > +}; > + > int > main (int argc, char *argv[]) > { > @@ -196,6 +202,7 @@ main (int argc, char *argv[]) > struct asd f; > uint8_t i; > static_member stmember; > + empty_member emember; > > return 0; > } > diff --git a/gdb/testsuite/gdb.base/ptype-offsets.exp b/gdb/testsuite/gdb.base/ptype-offsets.exp > index f466db9a7f2..0a0bbc87062 100644 > --- a/gdb/testsuite/gdb.base/ptype-offsets.exp > +++ b/gdb/testsuite/gdb.base/ptype-offsets.exp > @@ -336,7 +336,22 @@ gdb_test "ptype/o static_member" \ > [string_to_regexp [multi_line \ > "/* offset | size */ type = struct static_member \{" \ > " static static_member Empty;" \ > -"\/* 0 | 4 */ int abc;" \ > +"/* 0 | 4 */ int abc;" \ > "" \ > " /* total size (bytes): 4 */" \ > " \}"]] > + > +# Test that the "no data fields" text is indented properly. > +gdb_test "ptype/o empty_member" \ > + [string_to_regexp [multi_line \ > +"/* offset | size */ type = struct empty_member \{" \ > +"/* 0 | 1 */ struct {" \ > +" " \ > +"" \ > +" /* total size (bytes): 1 */" \ > +" } empty;" \ > +"/* XXX 3-byte hole */" \ > +"/* 4 | 4 */ int an_int;" \ > +"" \ > +" /* total size (bytes): 8 */" \ > +" \}"]] > -- > 2.26.2 >