From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HjF6A-0004ja-Qr for qemu-devel@nongnu.org; Wed, 02 May 2007 09:42:26 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HjF68-0004jO-D8 for qemu-devel@nongnu.org; Wed, 02 May 2007 09:42:25 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjF68-0004j6-6Y for qemu-devel@nongnu.org; Wed, 02 May 2007 09:42:24 -0400 Received: from mail.codesourcery.com ([65.74.133.4]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HjEzh-00006l-Tr for qemu-devel@nongnu.org; Wed, 02 May 2007 09:35:46 -0400 From: Paul Brook Subject: Re: [Qemu-devel] Saving state on a context switch Date: Wed, 2 May 2007 14:35:40 +0100 References: <46388F60.6020406@wisc.edu> In-Reply-To: <46388F60.6020406@wisc.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200705021435.41647.paul@codesourcery.com> 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 Cc: eady On Wednesday 02 May 2007, eady wrote: > Can anyone think of a way to save and restore an additional cpu state > variable during a context switch without modifying the target operating > system? Basically I would like to add a variable to the CPUState > structure that is saved and restored with the registers. The short answer is that in general you can't. Processes and contexts are managed by the host OS, and it is responsible for switching state appropriately. Some hardware has features to assist this process, but often not enough to reliably identify a particular process. To do what you want generally requires intimite knowledge of the appropriate parts of your OS. Some debuggers are capable of doing this. There are patches to add scripting support to GDB for this purpose. I don't have a URL handy, check the gdb mailing lists. Paul