This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how make program exit normally when execute command "run" on simulator


On Thu, May 13, 2010 at 7:20 PM, vincent chen <bartfj00@gmail.com> wrote:
> Hi All,
>
> I'm trying to add a new target to gdb and I'd like to run on simulator first,
>
> most functions of simulator appear to run properly now,
>
> but I don't know how to make the program exit normally when execute
> the command "run" (no breakpoint exist),
>
> I saw other target like mips can exit normally, is there any special
> assemble code in program to control?
>

Assuming I'm parsing this correctly,

Handling exit() for the target program is generally done by issuing a
"system call" and having the simulator recognize and process it.
How are you making system calls in the new target?
Depending on the chip, you can either invent something or just
piggyback on an existing system-call-like instruction.

How you process the exit system call depends on how your simulator is
implemented.  Many of the gdb simulators use a common "engine" and
call sim_engine_halt to process the exit system call.

For examples, grep TARGET_SYS_exit sim/*/*.c in the gdb source tree.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]