From patchwork Wed Aug 10 23:58:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 14479 Received: (qmail 38328 invoked by alias); 11 Aug 2016 00:00: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 29844 invoked by uid 89); 10 Aug 2016 23:58:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=gap, garbage, boundaries, 32, 6 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 10 Aug 2016 23:58:17 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 79F1C4E323; Wed, 10 Aug 2016 23:58:15 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7ANwDsq010656; Wed, 10 Aug 2016 19:58:14 -0400 Subject: Re: [PATCH v5] Add negative repeat count to 'x' command To: Thomas Preudhomme , Toshihito Kikuchi , gdb-patches@sourceware.org References: <1464857355-29883-1-git-send-email-k.toshihito@yahoo.de> <4e8feff5-935e-668e-6c68-87603173a953@foss.arm.com> Cc: Simon Marchi From: Pedro Alves Message-ID: <69169a01-7a25-1e72-810d-2971337ce002@redhat.com> Date: Thu, 11 Aug 2016 00:58:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <4e8feff5-935e-668e-6c68-87603173a953@foss.arm.com> On 08/08/2016 03:45 PM, Thomas Preudhomme wrote: > Sorry for the late reply but I noticed an issue in the tests added by > this patch for arm-none-eabi: > > > FAIL: gdb.base/examine-backward.exp: address zero boundary: examine 3 > bytes forward from 0x0 > NA->FAIL: gdb.base/examine-backward.exp char-width=1, print-max=20 take > 1 string backward (6/6) > NA->FAIL: gdb.base/examine-backward.exp char-width=1, print-max=20 take > 6 strings backward (pattern 1) > > > The first one is a testism: > > we match for: 0x\[0-9a-f\]+00.*:${byte}${byte}${byte} > but we get: 0x0: 0x7f 0x45 0x4c > > I'd thus suggest to match 0x\(\[0-9a-f\]+0\)?0 instead, with the right > amount of escaping (I don't know whether ? needs escaping and why + does > not need escaping in current pattern). We're examining at 0x0. Shouldn't we expect literally "0x0" instead then? > > > The other two seems like genuine errors. take 6 strings backward > (pattern 1) gives: > > gdb_expect_list pattern: /"ABCDEFGHIJKLMNOPQRST".../ > x/-6s^M > 0x9aff <_fini+2>: "\277\370\274\b\274\236FpGABCDEFGHIJK"...^M > 0x9b13 : "LMNOPQRSTUVWXYZ"^M > 0x9b23 : ""^M > 0x9b24 : ""^M > 0x9b25 : > "\343\201\273\343\201\222\343\201\273\343\201\222"^M > 0x9b32 : "01234567890123456789"...^M > (gdb) FAIL: gdb.base/examine-backward.exp: char-width=1, print-max=20: > take 6 strings backward (pattern 1) > > > take 1 string backward (6/6) gives: > > 0x9aff <_fini+2>: "\277\370\274\b\274\236FpGABCDEFGHIJK"... > > > Please let me know what I can do to help diagnose this error. The find-strings-backwards algorithm just looks back for '\0' to find string boundaries. Looks like it just happens that in your case, the TestStrings array is immediately preceded by the tail of _fini, with no gap in between. Try this. It's not strictly correct to assume that the linker places the objects consecutively, but it's probably safe in practice. diff --git c/gdb/testsuite/gdb.base/examine-backward.c w/gdb/testsuite/gdb.base/examine-backward.c index b338503..187fad1 100644 --- c/gdb/testsuite/gdb.base/examine-backward.c +++ w/gdb/testsuite/gdb.base/examine-backward.c @@ -32,6 +32,14 @@ literals. The content of each array is the same as followings: }; */ +/* This is here just to ensure we have a null character before + TestStrings, to avoid showing garbage when we look for strings + backwards from TestStrings. */ + +const char NullString[] = { + 0x00 +}; + const char TestStrings[] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,