This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA/RFC] fix bug: TUI not print source after switch from source type to command type
- From: Hui Zhu <teawater at gmail dot com>
- To: gdb-patches ml <gdb-patches at sourceware dot org>
- Cc: Joel Brobecker <brobecker at adacore dot com>
- Date: Mon, 5 Jul 2010 00:08:53 +0800
- Subject: [RFA/RFC] fix bug: TUI not print source after switch from source type to command type
Hi guys,
I found this bug in a long time. I suggest this bug can be fixed
before 7.2 release.
gdb ./gdb
(top-gdb) start
Temporary breakpoint 3 at 0x409073: file ../../src/gdb/gdb.c, line 29.
Starting program: /home/teawater/gdb/bgdbnotk/gdb/gdb
[Thread debugging using libthread_db enabled]
Temporary breakpoint 3, main (argc=
During symbol reading, incomplete CFI data; unspecified registers
(e.g., rax) at 0x409068.
1, argv=0x7fffffffe298) at ../../src/gdb/gdb.c:29
29 memset (&args, 0, sizeof args);
(top-gdb)
Ctrl-x a
Switch to source mode.
Use up and down key to move the code.
Ctrl-x a
Switch back to command mode.
Temporary breakpoint 3, main (argc=
During symbol reading, incomplete CFI data; unspecified registers
(e.g., rax) at 0x409068.
1, argv=0x7fffffffe298) at ../../src/gdb/gdb.c:29
29 memset (&args, 0, sizeof args);
(top-gdb) n
31 in ../../src/gdb/gdb.c
(top-gdb) n
32 in ../../src/gdb/gdb.c
(top-gdb)
33 in ../../src/gdb/gdb.c
(top-gdb)
It cannot output the source code.
The cause of this bug is in print_source_lines_base:
When tui in source mode, Use up and down key to move the code. The
"tui_vertical_source_scroll" will call "print_source_lines_base".
In it:
if (ui_out_test_flags (uiout, ui_source_list))
{
/* Only prints "No such file or directory" once */
if ((s != last_source_visited) || (!last_source_error))
{
last_source_visited = s;
desc = open_source_file (s);
}
else
{
desc = last_source_error;
noerror = 1;
}
}
else
{
desc = -1;
noerror = 1;
}
if (desc < 0)
{
last_source_error = desc;
"ui_out_test_flags (uiout, ui_source_list)" will return false, then
last_source_error will be set to -1.
Then when we set back to command line mode. The last_source_error
will make this function cannot output the source code.
I have 2 ways to handle this issue:
1. Looks "print_source_lines_base" is useless for
"tui_vertical_source_scroll". Maybe we can remove it.
2. Add a special check for noprint. I make a patch for it.
Please give me comments about this issue. Thanks.
Best regards,
Hui
2010-07-05 Hui Zhu <teawater@gmail.com>
* source.c (print_source_lines_base): Add check for noprint.
---
source.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/source.c
+++ b/source.c
@@ -1293,6 +1293,7 @@ print_source_lines_base (struct symtab *
{
int c;
int desc;
+ int noprint = 0;
FILE *stream;
int nlines = stopline - line;
struct cleanup *cleanup;
@@ -1319,11 +1320,12 @@ print_source_lines_base (struct symtab *
}
else
{
- desc = -1;
+ desc = last_source_error;
noerror = 1;
+ noprint = 1;
}
- if (desc < 0)
+ if (desc < 0 || noprint)
{
last_source_error = desc;