Received: from eggs.gnu.org ([140.186.70.92]:58635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RUfTB-00030V-6j for qemu-devel@nongnu.org; Sun, 27 Nov 2011 09:12:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RUfT9-0001Zu-Tn for qemu-devel@nongnu.org; Sun, 27 Nov 2011 09:12:37 -0500 Received: from nm20-vm1.bullet.mail.ne1.yahoo.com ([98.138.91.21]:21418) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RUfT9-0001Zo-KJ for qemu-devel@nongnu.org; Sun, 27 Nov 2011 09:12:35 -0500 Message-ID: <1322403154.50912.YahooMailClassic@web125402.mail.ne1.yahoo.com> Date: Sun, 27 Nov 2011 06:12:34 -0800 (PST) From: Rick Hodgin In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] Add native debugger List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel@nongnu.org Blue,=0A=0A=0A=0A--- On Sun, 11/27/11, Blue Swirl wr= ote:=0A> On Sun, Nov 27, 2011 at 04:10, Rick=0A> Hodgin =0A> wrote:=0A> > For i386, I'm considering writing a native debugger= =0A> for QEMU that is not GDB. It would allow a separate/new=0A> windowed i= nterface which would show disassembly, registers,=0A> stack, local variable= s, memory windows, etc., allowing the=0A> user to single-step through code = and trap opcodes like INT=0A> 1, INT 3, INT 4, etc. =A0It would be invoked = with something=0A> like "qemu -debugger" from the command line, and would h= ave=0A> a UI similar to Microsoft's Debugger in Visual Studio when=0A> no P= DB is available, but would show a similar type of=0A> disassembly form.=0A>= =0A> QEMU and the debugger should be kept separate. You should=0A> use the= GDB interface to implement the debugger, that way=0A> you can also test it= against known good configuration. For=0A> example, try to find out how GDB= performs single stepping=0A> (set remote debug 1).=0A=0AI appreciate this = advice. I'm looking for a native implementation within QEMU that is always = available, always on, always active (when enabled). In this way, whenever I= NT 3 opcodes are found, the debugger can intercept and leap into existence,= and without all of the gdb protocol overhead and parsing.=0A=0A> > I was l= ooking at the QEMU code and I can't find an=0A> > obvious place where it se= ems to iterate through each CPU=0A> > instruction, which is where I had in = mind to add a hook.=0A> >=0A> > Can someone get me pointed in the right dir= ection?=0A> > Where will I look for something like this:=0A> >=0A> > for (;= ;)=0A> > {=0A> > =A0execute_next_instruction();=0A> > }=0A> =0A> QEMU does = not work like that at all, it uses TCG, KVM or=0A> Xen to execute the code = and none of those use that kind=0A> of single instruction loop either.=0A= =0AThere must be some place where it fetches opcodes for what's coming up n= ext to execute. For my implementation I'm using a single i386 core, and th= at's all I'm concerned about for now. I'd like to intercept that part of t= he loop where cs:e/ip is used to retrieve the next opcode, so that I can ch= eck every instruction to see if the native debugger window has received GUI= stuff asking for a pause, if there are breakpoints, etc.=0A=0AI'd like hel= p on how to do this, and not advice on using gdb instead. There are some p= articular reasons I want to use my own native debugger in this way. I just= need pointed in the right direction to get started. That's for assistance= toward this end. :-)=0A=0AThanks and best regards,=0ARick C. Hodgin=0A