aboutsummaryrefslogtreecommitdiff
path: root/sim/h8300
diff options
context:
space:
mode:
authorDavid Edelsohn <dje.gcc@gmail.com>1996-03-11 21:59:22 +0000
committerDavid Edelsohn <dje.gcc@gmail.com>1996-03-11 21:59:22 +0000
commit741fd619cb043e018b67eace2023d19f59d470f0 (patch)
treeef789c009a0272ddc5e925f947280be00eb081a7 /sim/h8300
parent4dfb4ffcd1828740bf905bd018533aa84b24f486 (diff)
downloadgdb-741fd619cb043e018b67eace2023d19f59d470f0.zip
gdb-741fd619cb043e018b67eace2023d19f59d470f0.tar.gz
gdb-741fd619cb043e018b67eace2023d19f59d470f0.tar.bz2
(main): Print error message if argument is invalid.
(usage): Improve text.
Diffstat (limited to 'sim/h8300')
-rw-r--r--sim/h8300/run.c66
1 files changed, 35 insertions, 31 deletions
diff --git a/sim/h8300/run.c b/sim/h8300/run.c
index b7dd77c..a819569 100644
--- a/sim/h8300/run.c
+++ b/sim/h8300/run.c
@@ -67,49 +67,53 @@ main (ac, av)
default:
usage();
}
- ac -= optind;
- av += optind;
- if (ac != 1)
+ if (ac - optind != 1)
usage();
- name = *av;
+ name = av[ac - 1];
if (verbose)
printf ("run %s\n", name);
abfd = bfd_openr (name, "coff-h8300");
- if (abfd)
+ if (! abfd)
{
- if (bfd_check_format(abfd, bfd_object))
- {
- if (abfd->arch_info->mach == bfd_mach_h8300h)
- set_h8300h (1);
-
- for (s = abfd->sections; s; s=s->next)
- {
- char *buffer = 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);
- sim_resume(0,0);
- if (verbose)
- sim_info (verbose - 1);
- sim_stop_reason (&reason, &sigrc);
- /* FIXME: this test is insufficient but we can't do much
- about it until sim_stop_reason is cleaned up. */
- if (sigrc == SIGILL)
- abort ();
- return 0;
- }
+ fprintf (stderr, "%s: unable to open %s\n", av[0], name);
+ exit (1);
}
- return 1;
+ if (! bfd_check_format(abfd, bfd_object))
+ {
+ fprintf (stderr, "%s: %s is not a valid executable\n", av[0], name);
+ exit (1);
+ }
+
+ if (abfd->arch_info->mach == bfd_mach_h8300h)
+ set_h8300h (1);
+
+ for (s = abfd->sections; s; s=s->next)
+ {
+ char *buffer = 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);
+ sim_resume(0,0);
+ if (verbose)
+ sim_info (verbose - 1);
+ sim_stop_reason (&reason, &sigrc);
+ /* FIXME: this test is insufficient but we can't do much
+ about it until sim_stop_reason is cleaned up. */
+ if (sigrc == SIGILL)
+ abort ();
+ return 0;
}
+/* gdb callback used by simulator */
+
void
printf_filtered (va_alist)
va_dcl
@@ -126,6 +130,6 @@ printf_filtered (va_alist)
void
usage()
{
- fprintf (stderr, "usage: run [-tv] program\n");
+ fprintf (stderr, "usage: run [-h] [-t] [-v] [-c csize] program\n");
exit (1);
}