* [PATCH] Fix "list" when control characters are seen
@ 2019-04-09 18:54 Tom Tromey
2019-04-09 19:24 ` Andreas Schwab
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Tom Tromey @ 2019-04-09 18:54 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
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 <malakhov@mcst.ru>
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 <tromey@adacore.com>
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)
/* !
- !
+\f
! */
{
bar (x++);
--
2.20.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix "list" when control characters are seen
2019-04-09 18:54 [PATCH] Fix "list" when control characters are seen Tom Tromey
@ 2019-04-09 19:24 ` Andreas Schwab
2019-04-10 16:53 ` Tom Tromey
2019-04-19 19:03 ` Tom Tromey
2019-06-18 13:24 ` Pedro Alves
2 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2019-04-09 19:24 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Apr 09 2019, Tom Tromey <tromey@adacore.com> wrote:
> 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')
Does this give a warning when char is unsigned?
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix "list" when control characters are seen
2019-04-09 18:54 [PATCH] Fix "list" when control characters are seen Tom Tromey
2019-04-09 19:24 ` Andreas Schwab
@ 2019-04-19 19:03 ` Tom Tromey
2019-06-18 13:24 ` Pedro Alves
2 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2019-04-19 19:03 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:
Tom> PR symtab/24423 points out that control characters in a source file
Tom> cause a hang in the "list" command, a regression introduced by the
Tom> styling changes.
Tom> This patch, from the PR, fixes the bug. I've included a minimal
Tom> change to the "list" test that exercises this code.
Tom> I recall that this bug was discussed on gdb-patches, and I thought
Tom> there was a patch there as well, but I was unable to find it.
I'm going to check this in to master and the 8.3 branch now.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix "list" when control characters are seen
2019-04-09 18:54 [PATCH] Fix "list" when control characters are seen Tom Tromey
2019-04-09 19:24 ` Andreas Schwab
2019-04-19 19:03 ` Tom Tromey
@ 2019-06-18 13:24 ` Pedro Alves
2019-06-18 15:29 ` Tom Tromey
2 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2019-06-18 13:24 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 4/9/19 7:54 PM, Tom Tromey wrote:
> --- 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)
> /* !
> - !
> +
This seems pretty obscure without the context of the patch around.
Should we add a comment here?
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix "list" when control characters are seen
2019-06-18 13:24 ` Pedro Alves
@ 2019-06-18 15:29 ` Tom Tromey
2019-06-18 15:33 ` Pedro Alves
0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2019-06-18 15:29 UTC (permalink / raw)
To: Pedro Alves; +Cc: Tom Tromey, gdb-patches
>> static void foo (int x)
>> /* !
>> - !
>> +
Pedro> This seems pretty obscure without the context of the patch around.
Pedro> Should we add a comment here?
Good idea, how's this?
Tom
commit d20ed5fd574ce1b72543c2963fa53946eb2225de
Author: Tom Tromey <tromey@adacore.com>
Date: Tue Jun 18 09:27:45 2019 -0600
Add comment to list0.h
Pedro suggested adding a comment to list0.h to explain the control
character.
Tested on x86-64 Fedora 29.
gdb/testsuite/ChangeLog
2019-06-18 Tom Tromey <tromey@adacore.com>
* gdb.base/list0.h: Add comment explaining control character.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index b6fcf58c7dd..75adad35f48 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2019-06-18 Tom Tromey <tromey@adacore.com>
+
+ * gdb.base/list0.h: Add comment explaining control character.
+
2019-06-18 Tom de Vries <tdevries@suse.de>
* boards/fission.exp: Break up long debug_flags line.
diff --git a/gdb/testsuite/gdb.base/list0.h b/gdb/testsuite/gdb.base/list0.h
index 6f280935509..ba18e29268e 100644
--- a/gdb/testsuite/gdb.base/list0.h
+++ b/gdb/testsuite/gdb.base/list0.h
@@ -2,7 +2,7 @@
extern void bar(int);
static void foo (int x)
-/* !
+/* ! the next line has a control character, see PR symtab/24423.
\f
! */
{
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix "list" when control characters are seen
2019-06-18 15:29 ` Tom Tromey
@ 2019-06-18 15:33 ` Pedro Alves
0 siblings, 0 replies; 7+ messages in thread
From: Pedro Alves @ 2019-06-18 15:33 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 6/18/19 4:29 PM, Tom Tromey wrote:
>>> static void foo (int x)
>>> /* !
>>> - !
>>> +
>
> Pedro> This seems pretty obscure without the context of the patch around.
>
> Pedro> Should we add a comment here?
>
> Good idea, how's this?
Looks great, thanks.
Pedro Alves
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-06-18 15:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-09 18:54 [PATCH] Fix "list" when control characters are seen Tom Tromey
2019-04-09 19:24 ` Andreas Schwab
2019-04-10 16:53 ` Tom Tromey
2019-04-19 19:03 ` Tom Tromey
2019-06-18 13:24 ` Pedro Alves
2019-06-18 15:29 ` Tom Tromey
2019-06-18 15:33 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).