1 /* front end to the simulator.
3 Written by Steve Chamberlain of Cygnus Support.
6 This file is part of H8/300 sim
9 THIS SOFTWARE IS NOT COPYRIGHTED
11 Cygnus offers the following for use in the public domain. Cygnus
12 makes no warranty with regard to the software or it's performance
13 and the user accepts the software "AS IS" with all faults.
15 CYGNUS DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO
16 THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
31 #include "remote-sim.h"
43 bfd_vma start_address;
52 while ((i = getopt (ac, av, "c:htv")) != EOF)
56 sim_csize (atoi (optarg));
77 printf ("run %s\n", name);
79 abfd = bfd_openr (name, "coff-h8300");
82 fprintf (stderr, "%s: unable to open %s\n", av[0], name);
86 if (! bfd_check_format(abfd, bfd_object))
88 fprintf (stderr, "%s: %s is not a valid executable\n", av[0], name);
92 if (abfd->arch_info->mach == bfd_mach_h8300h
93 /* start-sanitize-h8s */
94 || abfd->arch_info->mach == bfd_mach_h8300s
95 /* end-sanitize-h8s */
99 for (s = abfd->sections; s; s=s->next)
101 char *buffer = malloc(bfd_section_size(abfd,s));
102 bfd_get_section_contents(abfd, s, buffer, 0, bfd_section_size(abfd,s));
103 sim_write(s->vma, buffer, bfd_section_size(abfd,s));
106 start_address = bfd_get_start_address(abfd);
107 sim_create_inferior (start_address, NULL, NULL);
110 sim_info (verbose - 1);
111 sim_stop_reason (&reason, &sigrc);
112 /* FIXME: this test is insufficient but we can't do much
113 about it until sim_stop_reason is cleaned up. */
119 /* gdb callback used by simulator */
122 printf_filtered (va_alist)
129 msg = va_arg (args, char *);
130 vfprintf (stdout, msg, args);
137 fprintf (stderr, "usage: run [-h] [-t] [-v] [-c csize] program\n");