aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorJim Wilson <wilson@tuliptree.org>1995-10-22 20:22:02 +0000
committerJim Wilson <wilson@tuliptree.org>1995-10-22 20:22:02 +0000
commit3be50301d5a32cd8c061bb27353d783bb5861796 (patch)
treee7c6765ec667622f07a1ddc364d418aba2ba274a /sim
parent9ef450d85df654e748ece909cbe0cbed6e8a49c5 (diff)
downloadfsf-binutils-gdb-3be50301d5a32cd8c061bb27353d783bb5861796.zip
fsf-binutils-gdb-3be50301d5a32cd8c061bb27353d783bb5861796.tar.gz
fsf-binutils-gdb-3be50301d5a32cd8c061bb27353d783bb5861796.tar.bz2
Fix SH simulator to handle program exit correctly.
Diffstat (limited to 'sim')
-rw-r--r--sim/common/ChangeLog9
-rw-r--r--sim/common/run.c92
2 files changed, 59 insertions, 42 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 2216dda..7d92a22 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,12 @@
+Sat Oct 21 12:31:01 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * run.c (main): Always return sigrc at end.
+
+Tue Oct 10 12:03:13 1995 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * run.c (main): Print error diagnostic and exit if bfd_openr() or
+ bfd_check_format() fails.
+
Thu Sep 28 15:40:36 1995 steve chamberlain <sac@slash.cygnus.com>
* run.c, run.1: From sh directory.
diff --git a/sim/common/run.c b/sim/common/run.c
index 0bcfd3d..15bd029 100644
--- a/sim/common/run.c
+++ b/sim/common/run.c
@@ -86,57 +86,65 @@ main (ac, av)
{
printf ("run %s\n", name);
}
+
abfd = bfd_openr (name, 0);
+ if (!abfd)
+ {
+ fprintf (stderr, "run: can't open %s: %s\n",
+ name, bfd_errmsg(bfd_get_error()));
+ exit (1);
+ }
+
+ if (!bfd_check_format (abfd, bfd_object))
+ {
+ fprintf (stderr, "run: can't load %s: %s\n",
+ name, bfd_errmsg(bfd_get_error()));
+ exit (1);
+ }
+
+
sim_set_callbacks (&default_callback);
default_callback.init (&default_callback);
+
+ for (s = abfd->sections; s; s = s->next)
if (abfd)
{
- if (bfd_check_format (abfd, bfd_object))
- {
+ unsigned char *buffer = (unsigned char *)malloc (bfd_section_size (abfd, s));
+ bfd_get_section_contents (abfd,
+ s,
+ buffer,
+ 0,
+ bfd_section_size (abfd, s));
+ sim_write (s->vma, buffer, bfd_section_size (abfd, s));
+ }
+
+ start_address = bfd_get_start_address (abfd);
+ sim_create_inferior (start_address, NULL, NULL);
+
+ target_byte_order = abfd->xvec->byteorder_big_p ? 4321 : 1234;
- for (s = abfd->sections; s; s = s->next)
- {
- unsigned char *buffer = (unsigned char *)malloc (bfd_section_size (abfd, s));
- bfd_get_section_contents (abfd,
- s,
- buffer,
- 0,
- bfd_section_size (abfd, s));
- sim_write (s->vma, buffer, bfd_section_size (abfd, s));
- }
-
- start_address = bfd_get_start_address (abfd);
- sim_create_inferior (start_address, NULL, NULL);
-
- target_byte_order = abfd->xvec->byteorder_big_p ? 4321 : 1234;
-
- if (trace)
- {
- int done = 0;
- while (!done)
- {
- done = sim_trace ();
- }
- }
- else
- {
- sim_resume (0, 0);
- }
- if (verbose)
- sim_info (0);
-
- sim_stop_reason (&reason, &sigrc);
-
- if (sigrc == SIGQUIT)
- {
- return sim_get_quit_code();
- }
- else
- return sigrc;
+ if (trace)
+ {
+ int done = 0;
+ while (!done)
+ {
+ done = sim_trace ();
}
}
+ else
+ {
+ sim_resume (0, 0);
+ }
+ if (verbose)
+ sim_info (0);
+
+ sim_stop_reason (&reason, &sigrc);
- return 1;
+ /* If reason is sim_exited, then sigrc holds the exit code which we want
+ to return. If reason is sim_stopped or sim_signalled, then sigrc holds
+ the signal that the simulator received; we want to return that to
+ indicate failure. */
+ return sigrc;
}
void