From patchwork Tue Apr 9 18:54:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32228 Received: (qmail 65989 invoked by alias); 9 Apr 2019 18:54:38 -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 65980 invoked by uid 89); 9 Apr 2019 18:54:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Apr 2019 18:54:36 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 9A807561DA; Tue, 9 Apr 2019 14:54:34 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 3+puWJM0UIlw; Tue, 9 Apr 2019 14:54:34 -0400 (EDT) Received: from murgatroyd.Home (174-29-37-56.hlrn.qwest.net [174.29.37.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 45841561D7; Tue, 9 Apr 2019 14:54:34 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Fix "list" when control characters are seen Date: Tue, 9 Apr 2019 12:54:32 -0600 Message-Id: <20190409185432.16985-1-tromey@adacore.com> MIME-Version: 1.0 PR symtab/24423 points out that control characters in a source file cause a hang in the "list" command, a regression introduced by the styling changes. This patch, from the PR, fixes the bug. I've included a minimal change to the "list" test that exercises this code. I recall that this bug was discussed on gdb-patches, and I thought there was a patch there as well, but I was unable to find it. gdb/ChangeLog 2019-04-09 Ilya Yu. Malakhov PR symtab/24423: * source.c (print_source_lines_base): Advance "iter" when a control character is seen. gdb/testsuite/ChangeLog 2019-04-09 Tom Tromey PR symtab/24423: * gdb.base/list0.h (foo): Add a control-l character. --- gdb/ChangeLog | 6 ++++++ gdb/source.c | 8 ++++++-- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/list0.h | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gdb/source.c b/gdb/source.c index f99215f9810..b61880ab503 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1368,7 +1368,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline, char c = *iter; if (c == '\033' && skip_ansi_escape (iter, &skip_bytes)) iter += skip_bytes; - else if (c < 040 && c != '\t') + else if (c >= 0 && c < 040 && c != '\t') break; else if (c == 0177) break; @@ -1397,9 +1397,13 @@ print_source_lines_base (struct symtab *s, int line, int stopline, { xsnprintf (buf, sizeof (buf), "^%c", *iter + 0100); uiout->text (buf); + ++iter; } else if (*iter == 0177) - uiout->text ("^?"); + { + uiout->text ("^?"); + ++iter; + } } uiout->text ("\n"); } diff --git a/gdb/testsuite/gdb.base/list0.h b/gdb/testsuite/gdb.base/list0.h index 42a4fe0f03a..6f280935509 100644 --- a/gdb/testsuite/gdb.base/list0.h +++ b/gdb/testsuite/gdb.base/list0.h @@ -3,7 +3,7 @@ extern void bar(int); static void foo (int x) /* ! - ! + ! */ { bar (x++);