From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SM4nKyQfbGALRgAAWB0awg (envelope-from ) for ; Tue, 06 Apr 2021 04:43:16 -0400 Received: by simark.ca (Postfix, from userid 112) id A9D731E939; Tue, 6 Apr 2021 04:43:16 -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.6 required=5.0 tests=MAILING_LIST_MULTI, RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [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 7AF021E590 for ; Tue, 6 Apr 2021 04:43:15 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 417D9384A029; Tue, 6 Apr 2021 08:43:15 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 8F21A3858034 for ; Tue, 6 Apr 2021 08:43:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8F21A3858034 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A9C69AE06; Tue, 6 Apr 2021 08:43:09 +0000 (UTC) Date: Tue, 6 Apr 2021 10:43:08 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [committed][gdb/tui] Fix len_without_escapes in tui-disasm.c Message-ID: <20210406084306.GA14812@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi, On openSUSE Tumbleweed I run into: ... FAIL: gdb.tui/basic.exp: asm window shows main ERROR: invalid command name "_csi_L" ... Using a minimal example, we get: ... $ gdb -q outputs/gdb.tui/basic/basic -ex "tui enable" -ex "layout asm" src/gdb/ui-style.c:243: internal-error: bool \ ui_file_style::parse(const char*, size_t*): Assertion `match == 0' failed. ... The problem is in len_without_escapes, where we detect the start of an escape sequence, but then pass ptr to style.parse while ptr no longer points to the escape due to the ptr++ in the while condition: ... while ((c = *ptr++) != '\0') { if (c == '\033') { ui_file_style style; size_t n_read; if (style.parse (ptr, &n_read)) ... Fix this by removing the ++ in the while condition, and adding ptr++ in the loop body where appropriate. Tested on x86_64-linux. Committed to trunk. Thanks, - Tom [gdb/tui] Fix len_without_escapes in tui-disasm.c gdb/ChangeLog: 2021-04-06 Tom de Vries PR tui/27680 * tui/tui-disasm.c (len_without_escapes): Pass ptr pointing at escape to style.parse. --- gdb/tui/tui-disasm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index 65b300cb008..163552aede4 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -61,7 +61,7 @@ len_without_escapes (const std::string &str) const char *ptr = str.c_str (); char c; - while ((c = *ptr++) != '\0') + while ((c = *ptr) != '\0') { if (c == '\033') { @@ -77,7 +77,10 @@ len_without_escapes (const std::string &str) } } else - ++len; + { + ++len; + ++ptr; + } } return len; }