This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: What should a CPU simulator support?
- From: Jim Blandy <jimb at codesourcery dot com>
- To: Wenbo Yang <wenbo dot yang at simplnano dot com>
- Cc: dave dot tw at gmail dot com, gdb at sourceware dot org
- Date: Thu, 05 Jul 2007 12:14:39 -0700
- Subject: Re: What should a CPU simulator support?
- References: <468C57AE.8020801@simplnano.com>
Wenbo Yang <wenbo.yang@simplnano.com> 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.