From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17736 invoked by alias); 5 Jul 2007 19:14:46 -0000 Received: (qmail 17726 invoked by uid 22791); 5 Jul 2007 19:14:46 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 05 Jul 2007 19:14:42 +0000 Received: (qmail 31637 invoked from network); 5 Jul 2007 19:14:40 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 5 Jul 2007 19:14:40 -0000 To: Wenbo Yang Cc: dave.tw@gmail.com, gdb@sourceware.org Subject: Re: What should a CPU simulator support? References: <468C57AE.8020801@simplnano.com> From: Jim Blandy Date: Thu, 05 Jul 2007 19:14:00 -0000 In-Reply-To: <468C57AE.8020801@simplnano.com> (Wenbo Yang's message of "Thu, 05 Jul 2007 10:30:06 +0800") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-07/txt/msg00042.txt.bz2 Wenbo Yang writes: >> I'm trying to implement a gdb stub for a CPU simulator. >> The CPU simulator interprets each instruction in a big while loop. >> My question is: Is it enough for my simulator to support a single step >> run (simulate a single instruction per called) function to the gdb >> stub? > If your simulator supports "break" or similar instruction, and the GDB > for your architecture can do software single stepping, I think you can > realize this function. (I didn't see the original post, so I'm not sure I have the full context.) You really shouldn't need to mess with software single-stepping when using a simulator. It's a big distraction, and given the structure of your simulator, it should be easy to provide what GDB wants directly. The functions GDB requires are listed in 'include/gdb/remote-sim.h'; none of those should be hard to implement in a simulator; the 'sim' directory contains many examples of how to hook things up. You should consider using the 'sim/common' code if you can, but if not, look at 'sim/m32c' for a very simple-minded approach. gdb-if.c implements the remote-sim.h functions in terms of the rest of the sim, which was originally written as a stand-alone simulator.