[PATCH] Incorrect output in error case

Andrew Burgess
2011-11-28T17:34:23Z

Hi,

If I try this,

$ cat woof.c
#include <stdio.h>

int
main ()
{
printf ("Woof!\n");

return 0;
}
$ gcc -g -o woof.x woof.c
$ mv woof.c woof.c.bak
$ cat cmds.gdb
list main
quit
$ gdb -q -x cmds.gdb woof.x
Reading symbols from /home/andrew/tmp/woof.x...done.
1 woof.c: No such file or directory.
in woof.c

I believe the "in woof.c" output from gdb is a mistake caused by missing
braces in an else clause.

Patch/Changelog below for review. I think this is an "obvious" fix, so
I'll commit this in a week unless someones says not to.

Thanks,

Andrew

gdb/ChangeLog

2011-11-28 Andrew Burgess <aburgess@broadcom.com>

* source.c (print_source_lines_base): Fix missing braces on else
clause leading to additional output.

diff --git a/gdb/source.c b/gdb/source.c
index 77df541..e456ac0 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1322,10 +1322,12 @@ print_source_lines_base (struct symtab *s, int
line, int
print_sys_errmsg (name, errno);
}
else
- ui_out_field_int (uiout, "line", line);
- ui_out_text (uiout, "\tin ");
- ui_out_field_string (uiout, "file", s->filename);
- ui_out_text (uiout, "\n");
+ {
+ ui_out_field_int (uiout, "line", line);
+ ui_out_text (uiout, "\tin ");
+ ui_out_field_string (uiout, "file", s->filename);
+ ui_out_text (uiout, "\n");
+ }

return;
}