This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug breakpoints/15186] New: Agent style dprintf does not bufferoutput properly


http://sourceware.org/bugzilla/show_bug.cgi?id=15186

             Bug #: 15186
           Summary: Agent style dprintf does not buffer output properly
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
        AssignedTo: unassigned@sourceware.org
        ReportedBy: marc.khouzam@ericsson.com
    Classification: Unclassified


Output buffering for "agent" style is not behaving as a real printf.  For
example, if my program does
     printf("hello");
     printf("friend\n");
and I put a dprintf " my " on the second line, I would expect to see
   "hello my friend"
but instead I see the " my " gets buffered until the program terminates.

Note two sessions below, one no using a new line and one with a new line:

> gdb.7.6 ~/loopfirst
GNU gdb (GDB) 7.5.50.20130223-cvs
(gdb) l
1       #include <unistd.h>
2       #include <stdio.h>
3
4       int main() {
5           for (int i=0;i<5;i++) {
6               printf("hello");
7               printf("friend\n");
8               printf("home\n");
9               sleep(1);
10          }
(gdb) target remote :9999
Remote debugging using :9999
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
0x00110850 in ?? () from /lib/ld-linux.so.2
(gdb) dprintf 7," my "
Dprintf 1 at 0x8048553: file loopfirst.cc, line 7.
(gdb) set dprintf-style agent
(gdb) info b
Num     Type           Disp Enb Address    What
1       dprintf        keep y   0x08048553 in main() at loopfirst.cc:7
        agent-printf " my "
(gdb) c

gdbserver output:
Remote debugging from host 127.0.0.1
hellofriend
home
hellofriend
home
hellofriend
home
hellofriend
home
hellofriend
home

Child exited with status 0
GDBserver exiting
 my  my  my  my  my >


Even with a new-line in the dprintf, things don't behave right:

> gdb.7.6 ~/loopfirst
GNU gdb (GDB) 7.5.50.20130223-cvs
(gdb) target remote :9999
Remote debugging using :9999
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
0x00110850 in ?? () from /lib/ld-linux.so.2
(gdb) l
1       #include <unistd.h>
2       #include <stdio.h>
3
4       int main() {
5           for (int i=0;i<5;i++) {
6               printf("hello");
7               printf("friend\n");
8               printf("home\n");
9               sleep(1);
10          }
(gdb) dprintf 7," my\n"
Dprintf 1 at 0x8048553: file loopfirst.cc, line 7.
(gdb) set dprintf-style agent
(gdb) info b
Num     Type           Disp Enb Address    What
1       dprintf        keep y   0x08048553 in main() at loopfirst.cc:7
        agent-printf " my\n"
(gdb) c

gdbserver output:
Remote debugging from host 127.0.0.1
 my
hellofriend
home
 my
hellofriend
home
 my
hellofriend
home
 my
hellofriend
home
 my
hellofriend
home

Child exited with status 0
GDBserver exiting
> 

Note how the "my" is flushed first and not after the "hello", although the
dprintf was put after the "hello".

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]