From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23757 invoked by alias); 13 Jun 2005 02:40:34 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 23729 invoked by uid 22791); 13 Jun 2005 02:40:25 -0000 Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 13 Jun 2005 02:40:25 +0000 Received: from drow by nevyn.them.org with local (Exim 4.50) id 1DhesB-00066g-N0; Sun, 12 Jun 2005 22:40:23 -0400 Date: Mon, 13 Jun 2005 02:40:00 -0000 From: Daniel Jacobowitz To: Nick Roberts Cc: gdb-patches@sources.redhat.com Subject: Re: [PATCH] -data-list-changed-registers (Take 2) Message-ID: <20050613024022.GB9288@nevyn.them.org> Mail-Followup-To: Nick Roberts , gdb-patches@sources.redhat.com References: <17053.38913.487990.775198@farnswood.snap.net.nz> <20050603191326.GA538@nevyn.them.org> <17056.56149.181259.513462@farnswood.snap.net.nz> <20050603223652.GA8203@nevyn.them.org> <17057.37727.725621.254956@farnswood.snap.net.nz> <17060.46539.131335.71422@farnswood.snap.net.nz> <17066.35303.833870.612064@farnswood.snap.net.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <17066.35303.833870.612064@farnswood.snap.net.nz> User-Agent: Mutt/1.5.8i X-SW-Source: 2005-06/txt/msg00137.txt.bz2 On Sat, Jun 11, 2005 at 06:51:19PM +1200, Nick Roberts wrote: > > *stopped,changed-registers=3D[],reason=3D"breakpoint-hit",bkptno=3D"1"= ,thread-id=3D"0",frame=3D{addr=3D"0x080484d9",func=3D"main",args=3D[{name= =3D"argc",value=3D"1"},{name=3D"argv",value=3D"0xbffff794"}],file=3D"myprog= .c",fullname=3D"/home/nick/myprog.c",line=3D"55"} > Well it turms out that throw_exception calls do_cleanups, but clearly the > above output isn't acceptable. With CLI everything is output immediately. > With MI it's stored in memory to be output later. This can mixed with the > output of the next MI command and break the syntax, as above. >=20 > This patch addresses this problem and is not as lightweight as my earlier > patches. If its not the right fix then its pretty damn close. It's not the right fix, but we're moving in a good direction. I noticed this problem when working on some other patch, but never had time to dig... Here's my objection: There is nothing special about mi_cmd_data_list_changed_registers that means it should have to be aware of this problem. Can we put this cleanup somewhere that it will apply to all MI functions? Can we do it without assuming things about the internals of ui_files? They're opaque, you shouldn't be adding something that knows one is a mem_stream here. It looks like you're doing basically mi_out_rewind. There's already several of these in captured_mi_execute_command. They don't catch this because throw_exception takes us past them, all the way back to mi_execute_command. If we add an mi_out_rewind call right here: 1176 /* The command execution failed and error() was called 1177 somewhere */ Then the problem goes away. So, I've committed the attached patch instead. Let me know if you see any problems with it. The manual is not explicit that these two commands reflect the state of the selected frame, but by the explicit parallel to "info reg" it's the right choice, so get_selected_frame is OK here. If you feel like updating the manual for this, that would be appreciated... Note that I needed to correct some test cases! There's no longer any MI output giving the stop reason if we stop while inside a called function (since that's an error() case). But that's OK; the output was showing up with the next -stack-list-frames, where it has no intelligible meaning, so this is an improvement. Built and tested on i386-linux and committed. --=20 Daniel Jacobowitz CodeSourcery, LLC 2005-06-12 Daniel Jacobowitz Nick Roberts * mi/mi-main.c (register_changed_p, get_register): Use get_selected_frame. (mi_execute_command): Call mi_out_rewind after an error. 2005-06-12 Daniel Jacobowitz * gdb.mi/mi-syn-frame.exp, gdb.mi/mi2-syn-frame.exp: Don't expect excess MI output after an error. Index: mi/mi-main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/mi/mi-main.c,v retrieving revision 1.78 diff -u -p -r1.78 mi-main.c --- mi/mi-main.c 22 May 2005 14:53:35 -0000 1.78 +++ mi/mi-main.c 13 Jun 2005 02:22:19 -0000 @@ -388,7 +388,7 @@ register_changed_p (int regnum) { gdb_byte raw_buffer[MAX_REGISTER_SIZE]; =20 - if (! frame_register_read (deprecated_selected_frame, regnum, raw_buffer= )) + if (! frame_register_read (get_selected_frame (NULL), regnum, raw_buffer= )) return -1; =20 if (memcmp (&old_regs[DEPRECATED_REGISTER_BYTE (regnum)], raw_buffer, @@ -509,7 +509,7 @@ get_register (int regnum, int format) if (format =3D=3D 'N') format =3D 0; =20 - frame_register (deprecated_selected_frame, regnum, &optim, &lval, &addr, + frame_register (get_selected_frame (NULL), regnum, &optim, &lval, &addr, &realnum, buffer); =20 if (optim) @@ -1174,11 +1174,12 @@ mi_execute_command (char *cmd, int from_ if (result.reason < 0) { /* The command execution failed and error() was called - somewhere */ + somewhere. */ fputs_unfiltered (command->token, raw_stdout); fputs_unfiltered ("^error,msg=3D\"", raw_stdout); fputstr_unfiltered (result.message, '"', raw_stdout); fputs_unfiltered ("\"\n", raw_stdout); + mi_out_rewind (uiout); } mi_parse_free (command); } Index: testsuite/gdb.mi/mi-syn-frame.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-syn-frame.exp,v retrieving revision 1.3 diff -u -p -r1.3 mi-syn-frame.exp --- testsuite/gdb.mi/mi-syn-frame.exp 18 May 2005 03:41:59 -0000 1.3 +++ testsuite/gdb.mi/mi-syn-frame.exp 13 Jun 2005 02:37:16 -0000 @@ -53,7 +53,7 @@ mi_gdb_test "400-break-insert foo" "400\ =20 mi_gdb_test "401-data-evaluate-expression foo()" "\\&\"The program being d= ebugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"Wh= en the function \\(foo\\) is done executing, GDB will silently\\\\n\"\[\r\n= \]+\\&\"stop \\(instead of continuing to evaluate the expression containing= \\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+401\\^error,msg= =3D\"The program being debugged stopped while in a function called from GDB= .*\"" "call inferior's function with a breakpoint set in it" =20 -mi_gdb_test "402-stack-list-frames" "402\\^done,reason=3D\"breakpoint-hit\= ",bkptno=3D\"2\",thread-id=3D\"$decimal\",frame=3D\{addr=3D\"$hex\",func=3D= \"foo\",args=3D\\\[\\\],file=3D\".*mi-syn-frame.c\",line=3D\"$decimal\"\},s= tack=3D\\\[frame=3D\{level=3D\"0\",addr=3D\"$hex\",func=3D\"foo\",file=3D\"= .*mi-syn-frame.c\",line=3D\"$decimal\"\},frame=3D\{level=3D\"1\",addr=3D\"$= hex\",func=3D\"\"\},frame=3D\{level=3D\"2\",addr= =3D\"$hex\",func=3D\"main\",file=3D\".*mi-syn-frame.c\",line=3D\"$decimal\"= \}.*\\\]" "backtrace from inferior function stopped at bp, showing gdb dumm= y frame" +mi_gdb_test "402-stack-list-frames" "402\\^done,stack=3D\\\[frame=3D\{leve= l=3D\"0\",addr=3D\"$hex\",func=3D\"foo\",file=3D\".*mi-syn-frame.c\",line= =3D\"$decimal\"\},frame=3D\{level=3D\"1\",addr=3D\"$hex\",func=3D\"\"\},frame=3D\{level=3D\"2\",addr=3D\"$hex\",func=3D\"mai= n\",file=3D\".*mi-syn-frame.c\",line=3D\"$decimal\"\}.*\\\]" "backtrace fro= m inferior function stopped at bp, showing gdb dummy frame" =20 # # Continue back to main() @@ -83,7 +83,7 @@ mi_gdb_test "406-data-evaluate-expressio # We should have both a signal handler and a call dummy frame # in this next output. =20 -mi_gdb_test "407-stack-list-frames" "407\\^done,reason=3D\"breakpoint-hit\= ",bkptno=3D\"3\",thread-id=3D\"$decimal\",frame=3D\{addr=3D\"$hex\",func=3D= \"subroutine\",args=3D\\\[\{name=3D\"in\",value=3D\"$decimal\"\}\\\],file= =3D\".*mi-syn-frame.c\",fullname=3D\"${fullname_syntax}${srcfile}\",line=3D= \"$decimal\"\},stack=3D\\\[frame=3D\{level=3D\"0\",addr=3D\"$hex\",func=3D\= "subroutine\",file=3D\".*mi-syn-frame.c\",fullname=3D\"${fullname_syntax}${= srcfile}\",line=3D\"$decimal\"\},frame=3D\{level=3D\"1\",addr=3D\"$hex\",fu= nc=3D\"handler\",file=3D\".*mi-syn-frame.c\",fullname=3D\"${fullname_syntax= }${srcfile}\",line=3D\"$decimal\"\},frame=3D\{level=3D\"2\",addr=3D\"$hex\"= ,func=3D\"\"\},.*frame=3D\{level=3D\"$decimal\",addr= =3D\"$hex\",func=3D\"have_a_very_merry_interrupt\",file=3D\".*mi-syn-frame.= c\",fullname=3D\"${fullname_syntax}${srcfile}\",line=3D\"$decimal\"\},frame= =3D\{level=3D\"$decimal\",addr=3D\"$hex\",func=3D\"\"\},frame=3D\{level=3D\"$decimal\",addr=3D\"$hex\",func=3D\"main\",file= =3D\".*mi-syn-frame.c\",fullname=3D\"${fullname_syntax}${srcfile}\",line=3D= \"$decimal\"\}.*\\\]" +mi_gdb_test "407-stack-list-frames" "407\\^done,stack=3D\\\[frame=3D\{leve= l=3D\"0\",addr=3D\"$hex\",func=3D\"subroutine\",file=3D\".*mi-syn-frame.c\"= ,fullname=3D\"${fullname_syntax}${srcfile}\",line=3D\"$decimal\"\},frame=3D= \{level=3D\"1\",addr=3D\"$hex\",func=3D\"handler\",file=3D\".*mi-syn-frame.= c\",fullname=3D\"${fullname_syntax}${srcfile}\",line=3D\"$decimal\"\},frame= =3D\{level=3D\"2\",addr=3D\"$hex\",func=3D\"\"\},.*f= rame=3D\{level=3D\"$decimal\",addr=3D\"$hex\",func=3D\"have_a_very_merry_in= terrupt\",file=3D\".*mi-syn-frame.c\",fullname=3D\"${fullname_syntax}${srcf= ile}\",line=3D\"$decimal\"\},frame=3D\{level=3D\"$decimal\",addr=3D\"$hex\"= ,func=3D\"\"\},frame=3D\{level=3D\"$decimal\",add= r=3D\"$hex\",func=3D\"main\",file=3D\".*mi-syn-frame.c\",fullname=3D\"${ful= lname_syntax}${srcfile}\",line=3D\"$decimal\"\}.*\\\]" =20 =20 send_gdb "408-exec-continue\n" @@ -104,7 +104,7 @@ mi_gdb_test "409-stack-list-frames 0 0"=20 =20 mi_gdb_test "410-data-evaluate-expression bar()" "hi in bar\[\r\n\]+\\&\"T= he program being debugged was signaled while in a function called from GDB.= \\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received= .\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal = on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the fu= nction \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=3D\"The = program being debugged was signaled while in a function called from GDB.\\\= \nGDB remains in the frame where the signal was received.\\\\nTo change thi= s behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expr= ession containing the function \\(bar\\) will be abandoned.\"" "call inferi= or function which raises exception" =20 -mi_gdb_test "411-stack-list-frames" "411\\^done,reason=3D\"signal-received= \",signal-name=3D\".*\",signal-meaning=3D\".*\",thread-id=3D\"$decimal\",fr= ame=3D\{addr=3D\"$hex\",func=3D\"bar\",args=3D\\\[\\\],file=3D\".*mi-syn-fr= ame.c\",fullname=3D\"${fullname_syntax}${srcfile}\",line=3D\"$decimal\"\},s= tack=3D\\\[frame=3D\{level=3D\"0\",addr=3D\"$hex\",func=3D\"bar\",file=3D\"= .*mi-syn-frame.c\",fullname=3D\"${fullname_syntax}${srcfile}\",line=3D\"$de= cimal\"},frame=3D\{level=3D\"1\",addr=3D\"$hex\",func=3D\"\"\},frame=3D\{level=3D\"2\",addr=3D\"$hex\",func=3D\"main\",file= =3D\".*mi-syn-frame.c\",fullname=3D\"${fullname_syntax}${srcfile}\",line=3D= \"$decimal\"}.*\\\]" "backtrace from inferior function at exception" +mi_gdb_test "411-stack-list-frames" "411\\^done,stack=3D\\\[frame=3D\{leve= l=3D\"0\",addr=3D\"$hex\",func=3D\"bar\",file=3D\".*mi-syn-frame.c\",fullna= me=3D\"${fullname_syntax}${srcfile}\",line=3D\"$decimal\"},frame=3D\{level= =3D\"1\",addr=3D\"$hex\",func=3D\"\"\},frame=3D\{= level=3D\"2\",addr=3D\"$hex\",func=3D\"main\",file=3D\".*mi-syn-frame.c\",f= ullname=3D\"${fullname_syntax}${srcfile}\",line=3D\"$decimal\"}.*\\\]" "bac= ktrace from inferior function at exception" =20 mi_gdb_exit =20 Index: testsuite/gdb.mi/mi2-syn-frame.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-syn-frame.exp,v retrieving revision 1.2 diff -u -p -r1.2 mi2-syn-frame.exp --- testsuite/gdb.mi/mi2-syn-frame.exp 18 May 2005 03:41:59 -0000 1.2 +++ testsuite/gdb.mi/mi2-syn-frame.exp 13 Jun 2005 02:37:16 -0000 @@ -54,7 +54,7 @@ mi_gdb_test "400-break-insert foo" "400\ =20 mi_gdb_test "401-data-evaluate-expression foo()" "\\&\"The program being d= ebugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"Wh= en the function \\(foo\\) is done executing, GDB will silently\\\\n\"\[\r\n= \]+\\&\"stop \\(instead of continuing to evaluate the expression containing= \\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+401\\^error,msg= =3D\"The program being debugged stopped while in a function called from GDB= .*\"" "call inferior's function with a breakpoint set in it" =20 -mi_gdb_test "402-stack-list-frames" "402\\^done,reason=3D\"breakpoint-hit\= ",bkptno=3D\"2\",thread-id=3D\"$decimal\",frame=3D\{addr=3D\"$hex\",func=3D= \"foo\",args=3D\\\[\\\],file=3D\".*mi-syn-frame.c\",line=3D\"$decimal\"\},s= tack=3D\\\[frame=3D\{level=3D\"0\",addr=3D\"$hex\",func=3D\"foo\",file=3D\"= .*mi-syn-frame.c\",line=3D\"$decimal\"\},frame=3D\{level=3D\"1\",addr=3D\"$= hex\",func=3D\"\"\},frame=3D\{level=3D\"2\",addr= =3D\"$hex\",func=3D\"main\",file=3D\".*mi-syn-frame.c\",line=3D\"$decimal\"= \}.*\\\]" "backtrace from inferior function stopped at bp, showing gdb dumm= y frame" +mi_gdb_test "402-stack-list-frames" "402\\^done,stack=3D\\\[frame=3D\{leve= l=3D\"0\",addr=3D\"$hex\",func=3D\"foo\",file=3D\".*mi-syn-frame.c\",line= =3D\"$decimal\"\},frame=3D\{level=3D\"1\",addr=3D\"$hex\",func=3D\"\"\},frame=3D\{level=3D\"2\",addr=3D\"$hex\",func=3D\"mai= n\",file=3D\".*mi-syn-frame.c\",line=3D\"$decimal\"\}.*\\\]" "backtrace fro= m inferior function stopped at bp, showing gdb dummy frame" =20 # # Continue back to main() @@ -84,7 +84,7 @@ mi_gdb_test "406-data-evaluate-expressio # We should have both a signal handler and a call dummy frame # in this next output. =20 -mi_gdb_test "407-stack-list-frames" "407\\^done,reason=3D\"breakpoint-hit\= ",bkptno=3D\"3\",thread-id=3D\"$decimal\",frame=3D\{addr=3D\"$hex\",func=3D= \"subroutine\",args=3D\\\[\{name=3D\"in\",value=3D\"$decimal\"\}\\\],file= =3D\".*mi-syn-frame.c\",line=3D\"$decimal\"\},stack=3D\\\[frame=3D\{level= =3D\"0\",addr=3D\"$hex\",func=3D\"subroutine\",file=3D\".*mi-syn-frame.c\",= line=3D\"$decimal\"\},frame=3D\{level=3D\"1\",addr=3D\"$hex\",func=3D\"hand= ler\",file=3D\".*mi-syn-frame.c\",line=3D\"$decimal\"\},frame=3D\{level=3D\= "2\",addr=3D\"$hex\",func=3D\"\"\},.*frame=3D\{level= =3D\"$decimal\",addr=3D\"$hex\",func=3D\"have_a_very_merry_interrupt\",file= =3D\".*mi-syn-frame.c\",line=3D\"$decimal\"\},frame=3D\{level=3D\"$decimal\= ",addr=3D\"$hex\",func=3D\"\"\},frame=3D\{level= =3D\"$decimal\",addr=3D\"$hex\",func=3D\"main\",file=3D\".*mi-syn-frame.c\"= ,line=3D\"$decimal\"\}.*\\\]" +mi_gdb_test "407-stack-list-frames" "407\\^done,stack=3D\\\[frame=3D\{leve= l=3D\"0\",addr=3D\"$hex\",func=3D\"subroutine\",file=3D\".*mi-syn-frame.c\"= ,line=3D\"$decimal\"\},frame=3D\{level=3D\"1\",addr=3D\"$hex\",func=3D\"han= dler\",file=3D\".*mi-syn-frame.c\",line=3D\"$decimal\"\},frame=3D\{level=3D= \"2\",addr=3D\"$hex\",func=3D\"\"\},.*frame=3D\{leve= l=3D\"$decimal\",addr=3D\"$hex\",func=3D\"have_a_very_merry_interrupt\",fil= e=3D\".*mi-syn-frame.c\",line=3D\"$decimal\"\},frame=3D\{level=3D\"$decimal= \",addr=3D\"$hex\",func=3D\"\"\},frame=3D\{level= =3D\"$decimal\",addr=3D\"$hex\",func=3D\"main\",file=3D\".*mi-syn-frame.c\"= ,line=3D\"$decimal\"\}.*\\\]" =20 =20 send_gdb "408-exec-continue\n" @@ -105,7 +105,7 @@ mi_gdb_test "409-stack-list-frames 0 0"=20 =20 mi_gdb_test "410-data-evaluate-expression bar()" "hi in bar\[\r\n\]+\\&\"T= he program being debugged was signaled while in a function called from GDB.= \\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received= .\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal = on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the fu= nction \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=3D\"The = program being debugged was signaled while in a function called from GDB.\\\= \nGDB remains in the frame where the signal was received.\\\\nTo change thi= s behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expr= ession containing the function \\(bar\\) will be abandoned.\"" "call inferi= or function which raises exception" =20 -mi_gdb_test "411-stack-list-frames" "411\\^done,reason=3D\"signal-received= \",signal-name=3D\".*\",signal-meaning=3D\".*\",thread-id=3D\"$decimal\",fr= ame=3D\{addr=3D\"$hex\",func=3D\"bar\",args=3D\\\[\\\],file=3D\".*mi-syn-fr= ame.c\",fullname=3D\"${fullname_syntax}${srcfile}\",line=3D\"$decimal\"\},s= tack=3D\\\[frame=3D\{level=3D\"0\",addr=3D\"$hex\",func=3D\"bar\",file=3D\"= .*mi-syn-frame.c\",fullname=3D\"${fullname_syntax}${srcfile}\",line=3D\"$de= cimal\"},frame=3D\{level=3D\"1\",addr=3D\"$hex\",func=3D\"\"\},frame=3D\{level=3D\"2\",addr=3D\"$hex\",func=3D\"main\",file= =3D\".*mi-syn-frame.c\",fullname=3D\"${fullname_syntax}${srcfile}\",line=3D= \"$decimal\"}.*\\\]" "backtrace from inferior function at exception" +mi_gdb_test "411-stack-list-frames" "411\\^done,stack=3D\\\[frame=3D\{leve= l=3D\"0\",addr=3D\"$hex\",func=3D\"bar\",file=3D\".*mi-syn-frame.c\",fullna= me=3D\"${fullname_syntax}${srcfile}\",line=3D\"$decimal\"},frame=3D\{level= =3D\"1\",addr=3D\"$hex\",func=3D\"\"\},frame=3D\{= level=3D\"2\",addr=3D\"$hex\",func=3D\"main\",file=3D\".*mi-syn-frame.c\",f= ullname=3D\"${fullname_syntax}${srcfile}\",line=3D\"$decimal\"}.*\\\]" "bac= ktrace from inferior function at exception" =20 mi_gdb_exit =20