]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix "list" when control characters are seen
authorTom Tromey <tromey@adacore.com>
Tue, 9 Apr 2019 18:52:46 +0000 (12:52 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 19 Apr 2019 19:01:54 +0000 (13:01 -0600)
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-19  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-19  Tom Tromey  <tromey@adacore.com>

PR symtab/24423:
* gdb.base/list0.h (foo): Add a control-l character.

gdb/ChangeLog
gdb/source.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/list0.h

index ab65671ca8b3ff2947c20f667602e280ba943190..22f22b963e849410dc19e1d6abbf39c4c6cbd163 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-19  Ilya Yu. Malakhov  <malakhov@mcst.ru>
+
+       PR symtab/24423:
+       * source.c (print_source_lines_base): Advance "iter" when a
+       control character is seen.
+
 2019-04-19  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
        * cli/cli-cmds.c (_initialize_cli_cmds): Move "shell" "!" alias
index f99215f98103d8ed42fb19251479057b25897a8f..b61880ab503c6f957de9120d0bc77c3f06a1ad2c 100644 (file)
@@ -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");
     }
index 297e2d48c635042308c07ecb6f8ab0c43043cfe3..89058f41a1b6b914af19634ee561e4c132584a5e 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-19  Tom Tromey  <tromey@adacore.com>
+
+       PR symtab/24423:
+       * gdb.base/list0.h (foo): Add a control-l character.
+
 2019-04-18  Tom de Vries  <tdevries@suse.de>
 
        PR gdb/24433
index 42a4fe0f03a3ca28c3892e58bb103b7524c00053..6f2809355093eb8890929a274d8cb7de1b5b9e9f 100644 (file)
@@ -3,7 +3,7 @@
 extern void bar(int);
 static void foo (int x)
 /* !
-   !
+\f
    ! */
 {
     bar (x++);