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 cli/7900] "printf" output last result


------- Additional Comments From naaaag at gmail dot com  2009-01-09 09:03 -------
( I am new to gdb development with some debugging + customized debugger dev
experience. Thought of entering this arena with some bug fixes to get to
understand the internals ). 

This problem seems to be present in 6.8 too. 

(gdb) printf "%x",(int *)main
40055a(gdb) printf "%x",(int *)main
(gdb) printf "%x",(int *)main
40055a(gdb) printf "%d", 9
40055a(gdb) printf "%d", 9
9(gdb) 

Problem since a 'wrap_here' present in command_line_handler. 

    658 
    659   /* Make sure that all output has been output.  Some machines may let
    660      you get away with leaving out some of the gdb_flush, but not all.  */
===>661   wrap_here("");
    662   gdb_flush (gdb_stdout);
    663   gdb_flush (gdb_stderr);

As per utils.c : 

   1536 /* Buffer and start column of buffered text, for doing smarter word-
   1537    wrapping.  When someone calls wrap_here(), we start buffering output
   1538    that comes through fputs_filtered().  If we see a newline, we just
   1539    spit it out and forget about the wrap_here().  If we see another
   1540    wrap_here(), we spit it out and remember the newer one.  If we see
   1541    the end of the line, we spit out a newline, the indent, and then
   1542    the buffered output.  */

Hence this "" is buffered and printing is disabled in fputs* functions due to
wrap_column is set. ( This is not the case , when a o/p ends with \n as
char_printed is 0 ). 

And when the next wrap here comes, this buffer is spit out ( hence out of order
printing ). 

This wrap_here doesn't seems to be required as it is in command line functions. 

(gdb) printf "%x",(int *)main
40055a(gdb) printf "%x",(int *)main
40055a(gdb) printf "%x",(int *)main
40055a(gdb) printf "%d", 9
9(gdb) printf "%d", 9
9(gdb) 

-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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