This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: how make program exit normally when execute command "run" on simulator
- From: Doug Evans <dje at google dot com>
- To: vincent chen <bartfj00 at gmail dot com>
- Cc: gdb at sourceware dot org
- Date: Mon, 17 May 2010 10:36:22 -0700
- Subject: Re: how make program exit normally when execute command "run" on simulator
- References: <AANLkTinEI9_Ut-JiGxxdGaHQhbOub3c0siwpbVeZ9tB1@mail.gmail.com>
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.