Bug 13170 - some error and warning messages are written to gdb/mi log stream
Summary: some error and warning messages are written to gdb/mi log stream
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: mi (show other bugs)
Version: 7.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-08 19:28 UTC by Xavier de Gaye
Modified: 2011-09-08 20:41 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xavier de Gaye 2011-09-08 19:28:11 UTC
How-To-Repeat
-------------

* build a plain executable:

$ echo "main(){}" | gcc -x c -g  -


* run the following test and confirm that the message "No source file
  named foo.c." is written to gdb/mi log stream instead of the console
  stream:

$ gdb --interpreter=mi -q -ex "set confirm off" a.out
=thread-group-added,id="i1"
~"Reading symbols from /home/xavier/tmp/a.out..."
~"done.\n"
(gdb)
-interpreter-exec console "break foo.c:1"
&"No source file named foo.c.\n"
^done
(gdb)
quit
&"quit\n"
Comment 1 Xavier de Gaye 2011-09-08 20:41:55 UTC
Warning message written to the log stream
-----------------------------------------
The following test case shows a warning message written to the log
stream instead of the console output stream.

Test with the following source code:
=======================================
class A {
    public:
        void test(void) {}
        void test(int a) {}
};

int main()
{
    A obj;
    obj.test();
    obj.test(0);
}
=======================================

xavier@maritorne:multiple_choice$ gdb -q --interpreter=mi a.out
=thread-group-added,id="i1"
~"Reading symbols from a.out..."
~"done.\n"
(gdb) 
-break-insert A::test
&"warning: Multiple breakpoints were set.\nUse the \"delete\" command to delete unwanted breakpoints."
&"\n"
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00000000004005a7",func="A::test(int)",file="overloaded.cc",fullname="/home/xavier/tmp/gdb_bugs/multiple_choice/overloaded.cc",line="4",times="0",original-location="A::test(int)"},bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x000000000040059a",func="A::test()",file="overloaded.cc",fullname="/home/xavier/tmp/gdb_bugs/multiple_choice/overloaded.cc",line="3",times="0",original-location="A::test()"}
(gdb) 



Message written twice: to the log stream and as an error result record
----------------------------------------------------------------------
The following test case shows that a same error message is written
twice, once to the log stream and once as an error result record.

This is annoying as frontends that choose to display all the log
stream messages in the same window together with the console output
stream messages and the error result records (as a workaround to these
error messages mis-routed to the log stream) will print twice the
message.

Test with the following source code:
=======================================
void foo() {}

int main()
{
    foo();
}
=======================================

$ gdb -q --interpreter=mi a.out
=thread-group-added,id="i1"
~"Reading symbols from a.out..."
~"done.\n"
(gdb) 
-break-insert foo
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400480",func="foo",file="foo.c",fullname="/home/xavier/tmp/gdb_bugs/print/foo.c",line="1",times="0",original-location="foo"}
(gdb) 
-exec-run
=thread-group-started,id="i1",pid="12432"
=thread-created,id="1",group-id="i1"

[1]+  Stopped                 gdb -q --interpreter=mi a.out
$ fg
gdb -q --interpreter=mi a.out
^running
*running,thread-id="all"
(gdb) 
=library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1"
=library-loaded,id="/lib/libc.so.6",target-name="/lib/libc.so.6",host-name="/lib/libc.so.6",symbols-loaded="0",thread-group="i1"
*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x0000000000400480",func="foo",args=[],file="foo.c",fullname="/home/xavier/tmp/gdb_bugs/print/foo.c",line="1"},thread-id="1",stopped-threads="all",core="1"
(gdb) 
-interpreter-exec console "print foo()"
~"\nBreakpoint "
~"1, foo () at foo.c:1\n"
~"1\tvoid foo() {}\n"
&"The program being debugged stopped while in a function called from GDB.\n"
&"Evaluation of the expression containing the function\n"
&"(foo) will be abandoned.\n"
&"When the function is done executing, GDB will silently stop.\n"
^error,msg="The program being debugged stopped while in a function called from GDB.\nEvaluation of the expression containing the function\n(foo) will be abandoned.\nWhen the function is done executing, GDB will silently stop."
(gdb)