From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gcj2L-00029L-ID for qemu-devel@nongnu.org; Wed, 25 Oct 2006 09:43:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gcj2H-00026Q-DM for qemu-devel@nongnu.org; Wed, 25 Oct 2006 09:43:16 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gcj2H-000269-7x for qemu-devel@nongnu.org; Wed, 25 Oct 2006 09:43:13 -0400 Received: from [195.141.71.141] (helo=mail.esmertec.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Gcj2G-0002al-0y for qemu-devel@nongnu.org; Wed, 25 Oct 2006 09:43:12 -0400 Received: from ddenholm by dalmore.esmertec.com with local (Exim 4.50) id 1Gcj25-0000GC-UF for qemu-devel@nongnu.org; Wed, 25 Oct 2006 14:43:01 +0100 From: Dave Denholm Date: Wed, 25 Oct 2006 14:43:01 +0100 In-Reply-To: (Dave Denholm's message of "Wed, 25 Oct 2006 13:04:12 +0100") Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] qemu user mode spins when stopped at a breakpoint Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, I've just noticed that if qemu is used in user mode, with a gdb attached, and it stops at a breakpoint, qemu spins consuming 100% cpu. Observed with both arm and mips (after applying the patch I sent earlier). The problem is in gdb_handlesig() in gdbstub.c - it uses a simple loop to read blocks from the gdb connection, but the socket has been set in non-blocking mode (around line 920 in gdb_accept), so this loop is an active spin. Simple fix is to put in a blocking call to poll() in the loop, either each time round, or whenever read() returns EWOULDBLOCK. However, it's not immediately clear to me why the socket needs to be set non-blocking..? I don't think user-mode currently allows gdb to interrupt the vm while it's running. That presumably wouldn't be too hard to do - either poll() the socket from the main loop (perhaps it's sufficient to check on system calls only ?), or arrange for a SIGIO to be delivered when data is recived on the socket. dd -- Dave Denholm http://www.esmertec.com