1 /* This file is part of the program psim.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include "function_unit.h"
45 extern char **environ;
52 printf_filtered(const char *msg, ...)
61 error (char *msg, ...)
73 void *memory = malloc(size);
75 error("zmalloc failed\n");
76 memset(memory, 0, size);
89 printf_filtered("Usage:\n\tpsim [ -t <trace-option> ] [-m model] [-i] [-I] <image> [ <image-args> ... ]\n");
95 main(int argc, char **argv)
98 const char *name_of_file;
104 /* check for arguments -- note sim_calls.c also contains argument processing
105 code for the simulator linked within gdb. */
106 while ((letter = getopt (argc, argv, "Iim:t:")) != EOF)
110 trace_option(optarg);
127 name_of_file = argv[optind];
129 if (ppc_trace[trace_opts])
132 /* create the simulator */
133 system = psim_create(name_of_file);
135 /* fudge the environment so that _=prog-name */
136 arg_ = (char*)zalloc(strlen(argv[optind]) + strlen("_=") + 1);
138 strcat(arg_, argv[optind]);
143 psim_stack(system, &argv[optind], environ);
147 /* any final clean up */
149 psim_print_info (system, print_info);
151 /* why did we stop */
152 status = psim_get_status(system);
153 switch (status.reason) {
155 error("psim: continuing while stoped!\n");
158 error("psim: no trap insn\n");
161 return status.signal;
163 printf ("%s: Caught signal %d at address 0x%lx\n",
164 name_of_file, (int)status.signal,
165 (long)status.program_counter);
166 return status.signal;
168 error("unknown halt condition\n");