From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8250 invoked by alias); 9 Jan 2009 09:03:38 -0000 Received: (qmail 8236 invoked by uid 48); 9 Jan 2009 09:03:38 -0000 Date: Fri, 09 Jan 2009 09:03:00 -0000 Message-ID: <20090109090338.8235.qmail@sourceware.org> From: "naaaag at gmail dot com" To: gdb-prs@sourceware.org In-Reply-To: <20021010045802.7900.chuajun@sina.com> References: <20021010045802.7900.chuajun@sina.com> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug cli/7900] "printf" output last result X-Bugzilla-Reason: CC Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org X-SW-Source: 2009-q1/txt/msg00032.txt.bz2 ------- 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.