public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug cli/25808] New: Correct line number, incorrect line with python colorize
@ 2020-04-09 23:12 vries at gcc dot gnu.org
2020-04-09 23:13 ` [Bug cli/25808] " vries at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-04-09 23:12 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25808
Bug ID: 25808
Summary: Correct line number, incorrect line with python
colorize
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: cli
Assignee: unassigned at sourceware dot org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
Consider the test-case gdb.base/async.exp.
Using the executable, I run to main, and land on line 26:
...
$ gdb outputs/gdb.base/async/async -ex "set confirm off" -ex start -ex quit
Reading symbols from outputs/gdb.base/async/async...
Temporary breakpoint 1 at 0x4004e4: file gdb.base/async.c, line 26.
Starting program: outputs/gdb.base/async/async
Temporary breakpoint 1, main () at gdb.base/async.c:26
26 y = foo ();
...
Which actually, turns out not to be line 26, but line 28:
...
$ cat -n gdb.base/async.c 1
21 int
22 main (void)
23 {
24 int y, z;
25
26 y = 2;
27 z = 9;
28 y = foo ();
29 z = y;
30 y = y + 2; /* jump here */
31 y = baz ();
32 return 0; /* until here */
33 }
...
By switching "style sources" off, I get the expected line:
...
$ gdb outputs/gdb.base/async/async -ex "set style sources off" -ex "set confirm
off" -ex start -ex quit
Reading symbols from outputs/gdb.base/async/async...
Temporary breakpoint 1 at 0x4004e4: file gdb.base/async.c, line 26.
Starting program: outputs/gdb.base/async/async
Temporary breakpoint 1, main () at gdb.base/async.c:26
26 y = 2;
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug cli/25808] Correct line number, incorrect line with python colorize
2020-04-09 23:12 [Bug cli/25808] New: Correct line number, incorrect line with python colorize vries at gcc dot gnu.org
@ 2020-04-09 23:13 ` vries at gcc dot gnu.org
2020-04-10 7:29 ` cvs-commit at gcc dot gnu.org
2020-04-10 7:32 ` vries at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-04-09 23:13 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25808
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Tentative fix:
...
diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
index a1aac00792..3dfb51b2af 100644
--- a/gdb/python/lib/gdb/__init__.py
+++ b/gdb/python/lib/gdb/__init__.py
@@ -216,7 +216,7 @@ try:
def colorize(filename, contents):
# Don't want any errors.
try:
- lexer = lexers.get_lexer_for_filename(filename)
+ lexer = lexers.get_lexer_for_filename(filename, stripnl=False)
formatter = formatters.TerminalFormatter()
return highlight(contents, lexer, formatter)
except:
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug cli/25808] Correct line number, incorrect line with python colorize
2020-04-09 23:12 [Bug cli/25808] New: Correct line number, incorrect line with python colorize vries at gcc dot gnu.org
2020-04-09 23:13 ` [Bug cli/25808] " vries at gcc dot gnu.org
@ 2020-04-10 7:29 ` cvs-commit at gcc dot gnu.org
2020-04-10 7:32 ` vries at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-10 7:29 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25808
--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bdfc1e8a0b176257bfc700de755463d3aaf69849
commit bdfc1e8a0b176257bfc700de755463d3aaf69849
Author: Tom de Vries <tdevries@suse.de>
Date: Fri Apr 10 09:29:52 2020 +0200
[gdb/cli] Don't let python colorize strip leading newlines
Consider the test-case gdb.base/async.exp. Using the executable, I run to
main, and land on a line advertised as line 26:
...
$ gdb outputs/gdb.base/async/async -ex start
Reading symbols from outputs/gdb.base/async/async...
Temporary breakpoint 1 at 0x4004e4: file gdb.base/async.c, line 26.
Starting program: outputs/gdb.base/async/async
Temporary breakpoint 1, main () at gdb.base/async.c:26
26 y = foo ();
...
But actually, the line turns out to be line 28:
...
$ cat -n gdb.base/async.c
...
26 y = 2;
27 z = 9;
28 y = foo ();
...
This is caused by the following: the python colorizer initializes the lexer
with default options (no second argument to get_lexer_for_filename):
...
def colorize(filename, contents):
# Don't want any errors.
try:
lexer = lexers.get_lexer_for_filename(filename)
formatter = formatters.TerminalFormatter()
return highlight(contents, lexer, formatter)
...
which include option stripnl=True, which strips leading and trailing
newlines.
This causes the python colorizer to strip the two leading newlines of
async.c.
Fix this by initializing the lexer with stripnl=False.
Build and reg-tested on x86_64-linux.
gdb/ChangeLog:
2020-04-10 Tom de Vries <tdevries@suse.de>
PR cli/25808
* python/lib/gdb/__init__.py: Initialize lexer with stripnl=False.
gdb/testsuite/ChangeLog:
2020-04-10 Tom de Vries <tdevries@suse.de>
PR cli/25808
* gdb.base/style.c: Add leading newlines.
* gdb.base/style.exp: Use gdb_get_line_number to get specific
lines.
Check listing of main's one-line body.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug cli/25808] Correct line number, incorrect line with python colorize
2020-04-09 23:12 [Bug cli/25808] New: Correct line number, incorrect line with python colorize vries at gcc dot gnu.org
2020-04-09 23:13 ` [Bug cli/25808] " vries at gcc dot gnu.org
2020-04-10 7:29 ` cvs-commit at gcc dot gnu.org
@ 2020-04-10 7:32 ` vries at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-04-10 7:32 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25808
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Patch with test-case committed, marking resolved-fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-10 7:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-09 23:12 [Bug cli/25808] New: Correct line number, incorrect line with python colorize vries at gcc dot gnu.org
2020-04-09 23:13 ` [Bug cli/25808] " vries at gcc dot gnu.org
2020-04-10 7:29 ` cvs-commit at gcc dot gnu.org
2020-04-10 7:32 ` vries at gcc dot gnu.org
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).