Stop the emulation on ^C and finish the traces
This commit is contained in:
parent
9d7ff947b1
commit
626aa84814
@ -1,8 +1,18 @@
|
|||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <signal.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
static volatile int run = 1;
|
||||||
|
|
||||||
|
static void stop_emulation(int dummy)
|
||||||
|
{
|
||||||
|
UNUSED(dummy);
|
||||||
|
run = 0;
|
||||||
|
signal(SIGINT, SIG_DFL);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -21,9 +31,11 @@ main(int argc, char *argv[])
|
|||||||
if (emu_connect(emu) != 0)
|
if (emu_connect(emu) != 0)
|
||||||
die("emu_connect failed\n");
|
die("emu_connect failed\n");
|
||||||
|
|
||||||
|
signal(SIGINT, stop_emulation);
|
||||||
|
|
||||||
err("emulation starts");
|
err("emulation starts");
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
while ((ret = emu_step(emu)) == 0);
|
while (run && (ret = emu_step(emu)) == 0);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
err("emu_step failed");
|
err("emu_step failed");
|
||||||
@ -34,6 +46,9 @@ main(int argc, char *argv[])
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (run == 0)
|
||||||
|
err("stopping emulation by user (^C again to abort)");
|
||||||
|
|
||||||
if (emu_finish(emu) != 0) {
|
if (emu_finish(emu) != 0) {
|
||||||
err("emu_finish failed");
|
err("emu_finish failed");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user