X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=sim%2Fppc%2Fsim_calls.c;h=6fdca6a3aa6887afb7d99a4a56964c40a8c6c39e;hb=2e913166b1be63e4a327c9c2f37f0115fece6595;hp=32bd4f5f37b8ccbee5b87e5ce735a439681d45af;hpb=4dcb0cdda68278470579f3a9257a5860105e4e87;p=deliverable%2Fbinutils-gdb.git diff --git a/sim/ppc/sim_calls.c b/sim/ppc/sim_calls.c index 32bd4f5f37..6fdca6a3aa 100644 --- a/sim/ppc/sim_calls.c +++ b/sim/ppc/sim_calls.c @@ -1,6 +1,6 @@ /* This file is part of the program psim. - Copyright (C) 1994-1995, Andrew Cagney + Copyright (C) 1994-1996, Andrew Cagney This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,8 +23,8 @@ #include #include -#include "basics.h" #include "psim.h" +#include "options.h" #ifdef HAVE_STDLIB_H #include @@ -40,8 +40,6 @@ #include "../../gdb/defs.h" -#include "devices.h" - #include "../../gdb/remote-sim.h" #include "../../gdb/callback.h" @@ -49,58 +47,30 @@ /* Structures used by the simulator, for gdb just have static structures */ static psim *simulator; -static char *register_names[] = REGISTER_NAMES; -static int print_info = 0; +static device *root_device; +static const char *register_names[] = REGISTER_NAMES; void sim_open (char *args) { - int i; - + /* Note: The simulation is not created by sim_open() because + complete information is not yet available */ /* trace the call */ TRACE(trace_gdb, ("sim_open(args=%s) called\n", args ? args : "(null)")); + if (root_device != NULL) + printf_filtered("Warning - re-open of simulator leaks memory\n"); + root_device = psim_tree(); + simulator = NULL; + if (args) { char **argv = buildargv(args); - int argp = 0; - int argc; - for (argc = 0; argv[argc]; argc++); - - while (argp < argc) { - if (*argv[argp] != '-') - error ("Argument is not an option '%s'", argv[argp]); - - else { - /* check arguments -- note, main.c also contains argument processing - code for the standalone emulator. */ - char *p = argv[argp] + 1; - while (*p != '\0') { - switch (*p) { - default: - printf_filtered("Usage:\n\ttarget sim [ -t ]\n"); - trace_usage(); - error (""); - break; - case 't': - argp += 1; - if (argv[argp] == NULL) - error("Missing option for -t\n"); - trace_option(argv[argp]); /* better fail if NULL */ - break; - case 'I': - print_info = 1; - break; - } - p += 1; - } - } - argp += 1; - } + psim_options(root_device, argv); + freeargv(argv); } - /* do something */ - TRACE(trace_tbd, ("sim_open() - TBD - should parse the arguments\n")); - TRACE(trace_tbd, ("sim_open() - TBD - can not create simulator here as do not have description of it\n")); + if (ppc_trace[trace_opts]) + print_options (); } @@ -108,10 +78,8 @@ void sim_close (int quitting) { TRACE(trace_gdb, ("sim_close(quitting=%d) called\n", quitting)); - if (print_info) - psim_print_info (simulator, 1); - - /* nothing to do */ + if (ppc_trace[trace_print_info] && simulator != NULL) + psim_print_info (simulator, ppc_trace[trace_print_info]); } @@ -129,7 +97,7 @@ sim_load (char *prog, int from_tty) /* create the simulator */ TRACE(trace_gdb, ("sim_load() - first time, create the simulator\n")); - simulator = psim_create(argv[0]); + simulator = psim_create(argv[0], root_device); /* bring in all the data section */ psim_init(simulator); @@ -155,8 +123,8 @@ sim_read (SIM_ADDR mem, unsigned char *buf, int length) { int result = psim_read_memory(simulator, MAX_NR_PROCESSORS, buf, mem, length); - TRACE(trace_gdb, ("sim_read(mem=0x%x, buf=0x%x, length=%d) = %d\n", - mem, buf, length, result)); + TRACE(trace_gdb, ("sim_read(mem=0x%lx, buf=0x%lx, length=%d) = %d\n", + (long)mem, (long)buf, length, result)); return result; } @@ -167,8 +135,8 @@ sim_write (SIM_ADDR mem, unsigned char *buf, int length) int result = psim_write_memory(simulator, MAX_NR_PROCESSORS, buf, mem, length, 1/*violate_ro*/); - TRACE(trace_gdb, ("sim_write(mem=0x%x, buf=0x%x, length=%d) = %d\n", - mem, buf, length, result)); + TRACE(trace_gdb, ("sim_write(mem=0x%lx, buf=0x%lx, length=%d) = %d\n", + (long)mem, (long)buf, length, result)); return result; } @@ -179,8 +147,8 @@ sim_fetch_register (int regno, unsigned char *buf) if (simulator == NULL) { return; } - TRACE(trace_gdb, ("sim_fetch_register(regno=%d(%s), buf=0x%x)\n", - regno, register_names[regno], buf)); + TRACE(trace_gdb, ("sim_fetch_register(regno=%d(%s), buf=0x%lx)\n", + regno, register_names[regno], (long)buf)); psim_read_register(simulator, MAX_NR_PROCESSORS, buf, register_names[regno], raw_transfer); @@ -192,8 +160,8 @@ sim_store_register (int regno, unsigned char *buf) { if (simulator == NULL) return; - TRACE(trace_gdb, ("sim_store_register(regno=%d(%s), buf=0x%x)\n", - regno, register_names[regno], buf)); + TRACE(trace_gdb, ("sim_store_register(regno=%d(%s), buf=0x%lx)\n", + regno, register_names[regno], (long)buf)); psim_write_register(simulator, MAX_NR_PROCESSORS, buf, register_names[regno], raw_transfer); @@ -268,8 +236,8 @@ sim_stop_reason (enum sim_stop *reason, int *sigrc) } - TRACE(trace_gdb, ("sim_stop_reason(reason=0x%x(%d), sigrc=0x%x(%d))\n", - reason, *reason, sigrc, *sigrc)); + TRACE(trace_gdb, ("sim_stop_reason(reason=0x%lx(%ld), sigrc=0x%lx(%ld))\n", + (long)reason, (long)*reason, (long)sigrc, (long)*sigrc)); } @@ -285,7 +253,6 @@ void sim_resume (int step, int siggnal) { void (*prev) (); - unsigned_word program_counter; TRACE(trace_gdb, ("sim_resume(step=%d, siggnal=%d)\n", step, siggnal)); @@ -302,9 +269,15 @@ sim_resume (int step, int siggnal) } void -sim_do_command(char *cmd) +sim_do_command (char *cmd) { - TRACE(trace_gdb, ("sim_do_commands(cmd=%s) called\n", cmd)); + TRACE(trace_gdb, ("sim_do_commands(cmd=%s) called\n", + cmd ? cmd : "(null)")); + if (cmd) { + char **argv = buildargv(cmd); + psim_options(root_device, argv); + freeargv(argv); + } } void @@ -321,7 +294,7 @@ zalloc(long size) void *memory = (void*)xmalloc(size); if (memory == NULL) error("xmalloc failed\n"); - bzero(memory, size); + memset(memory, 0, size); return memory; } @@ -329,3 +302,8 @@ void zfree(void *data) { mfree(NULL, data); } + +void flush_stdoutput(void) +{ + gdb_flush (gdb_stdout); +}