aboutsummaryrefslogtreecommitdiff
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-03-03 15:02:29 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-03-03 15:02:29 +0000
commit586314f2aa62990dead8144e780c4c8c498eece6 (patch)
tree59e8e588860b7430214833f82da84c762612c9b4 /linux-user/main.c
parent0ecfa9930c7615503ba629a61f7b94a0c3305af5 (diff)
better debug support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@18 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user/main.c')
-rw-r--r--linux-user/main.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 68858daf4c..cdd118f369 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -27,6 +27,11 @@
#include "cpu-i386.h"
+#define DEBUG_LOGFILE "/tmp/gemu.log"
+
+FILE *logfile = NULL;
+int loglevel;
+
unsigned long x86_stack_size;
unsigned long stktop;
@@ -83,7 +88,7 @@ int cpu_x86_inl(int addr)
void usage(void)
{
printf("gemu version 0.1, Copyright (c) 2003 Fabrice Bellard\n"
- "usage: gemu program [arguments...]\n"
+ "usage: gemu [-d] program [arguments...]\n"
"Linux x86 emulator\n"
);
exit(1);
@@ -95,11 +100,27 @@ int main(int argc, char **argv)
struct target_pt_regs regs1, *regs = &regs1;
struct image_info info1, *info = &info1;
CPUX86State *env;
+ int optind;
if (argc <= 1)
usage();
-
- filename = argv[1];
+ loglevel = 0;
+ optind = 1;
+ if (argv[optind] && !strcmp(argv[optind], "-d")) {
+ loglevel = 1;
+ optind++;
+ }
+ filename = argv[optind];
+
+ /* init debug */
+ if (loglevel) {
+ logfile = fopen(DEBUG_LOGFILE, "w");
+ if (!logfile) {
+ perror(DEBUG_LOGFILE);
+ exit(1);
+ }
+ setvbuf(logfile, NULL, _IOLBF, 0);
+ }
/* Zero out regs */
memset(regs, 0, sizeof(struct target_pt_regs));