This is the mail archive of the 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]

[PATCH] waiting_for_stop_reply around remote_fileio_request

I see this error when GDB works with qemu,

(gdb) n
Sending packet: $vCont;c#a8...Ack
Packet received: Ffstat,00000001,f6fff038
Cannot execute this command while the target is running.
Use the "interrupt" command to stop the target
and then try again.

looks we don't set rs->waiting_for_stop_reply to zero
before handle fileio request,

 #10 0x00000000005edb64 in target_write (len=64, offset=4143968312, buf=0x7fffffffd570 "\375\377\377\377", annex=0x0, object=TARGET_OBJECT_MEMORY,
    ops=<optimised out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/target.c:1922
 #11 target_write_memory (memaddr=memaddr@entry=4143968312, myaddr=myaddr@entry=0x7fffffffd6a0 "", len=len@entry=64)
    at /home/yao/SourceCode/gnu/gdb/git/gdb/target.c:1500
 #12 0x00000000004b2b41 in remote_fileio_func_fstat (buf=0x127b258 "") at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:1037
 #13 0x00000000004b1878 in do_remote_fileio_request (uiout=<optimised out>, buf_arg=buf_arg@entry=0x127b240)
    at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:1204
 #14 0x00000000005b8c7c in catch_exceptions_with_msg (func_uiout=<optimised out>, func=func@entry=0x4b1800 <do_remote_fileio_request>,
    func_args=func_args@entry=0x127b240, gdberrmsg=gdberrmsg@entry=0x0, mask=mask@entry=RETURN_MASK_ALL)
    at /home/yao/SourceCode/gnu/gdb/git/gdb/exceptions.c:187
 #15 0x00000000005b8dea in catch_exceptions (uiout=<optimised out>, func=func@entry=0x4b1800 <do_remote_fileio_request>, func_args=func_args@entry=0x127b240,
    mask=mask@entry=RETURN_MASK_ALL) at /home/yao/SourceCode/gnu/gdb/git/gdb/exceptions.c:167
 #16 0x00000000004b2fff in remote_fileio_request (buf=0x127b240 "Xf6fff038,0:", ctrlc_pending_p=0) at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:1255
 #17 0x0000000000496f12 in remote_wait_as (ptid=..., status=0x7fffffffdb20, options=1) at /home/yao/SourceCode/gnu/gdb/git/gdb/remote.c:6997

however, we did set rs->waiting_for_stop_reply to zero before Luis's

In fact, Luis's patch v1 is about
setting rs->waiting_for_stop_reply back to one after
remote_fileio_request, which is correct.  However during the review, the
patch is changed and ends up with "not setting rs->waiting_for_stop_reply
to zero".

I manually test GDB, but I don't have a way to run regression tests.


2016-01-29  Yao Qi  <>

	* remote.c (remote_wait_as): Set rs->waiting_for_stop_reply to
	0 before handling 'F' and set it back afterwards.
 gdb/remote.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gdb/remote.c b/gdb/remote.c
index d5701e3..f396a8f 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6994,8 +6994,16 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
       status->value.sig = GDB_SIGNAL_0;
     case 'F':		/* File-I/O request.  */
+      /* GDB may access the inferior memory while handling the File-I/O
+	 request, but we don't want it GDB accessing memory while waiting
+	 for a stop reply.  See the comments in putpkt_binary.  Set
+	 waiting_for_stop_reply to 0 temporarily.  */
+      rs->waiting_for_stop_reply = 0;
       remote_fileio_request (buf, rs->ctrlc_pending_p);
       rs->ctrlc_pending_p = 0;
+      /* GDB handled the File-I/O request, but the target is running
+	 again.  Keep waiting for events.  */
+      rs->waiting_for_stop_reply = 1;
     case 'N': case 'T': case 'S': case 'X': case 'W':

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