aboutsummaryrefslogtreecommitdiff
path: root/sim/ppc
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-01-02 02:34:05 -0500
committerMike Frysinger <vapier@gentoo.org>2016-01-02 03:38:29 -0500
commitdea827fc5c3349dc0308d0e22ab2d6791282cf8b (patch)
treea6139c6a170d62fe07d30cbc33a8050bf9c959cb /sim/ppc
parent4a2abdc468f9028435df0b30d9dab1b5ba9a7520 (diff)
downloadgdb-dea827fc5c3349dc0308d0e22ab2d6791282cf8b.zip
gdb-dea827fc5c3349dc0308d0e22ab2d6791282cf8b.tar.gz
gdb-dea827fc5c3349dc0308d0e22ab2d6791282cf8b.tar.bz2
sim: ppc: do not exit when parsing args w/gdb
When connecting to the simulator in gdb, we don't want it to exit on us when we pass down unknown/invalid/help/etc... options. Plumb down the kind argument so we can handle both gdb & psim interfaces.
Diffstat (limited to 'sim/ppc')
-rw-r--r--sim/ppc/ChangeLog15
-rw-r--r--sim/ppc/main.c4
-rw-r--r--sim/ppc/psim.c44
-rw-r--r--sim/ppc/psim.h6
-rw-r--r--sim/ppc/sim_calls.c3
5 files changed, 50 insertions, 22 deletions
diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog
index 7ce9a47..82fd50b 100644
--- a/sim/ppc/ChangeLog
+++ b/sim/ppc/ChangeLog
@@ -1,3 +1,18 @@
+2016-01-02 Mike Frysinger <vapier@gentoo.org>
+
+ * main.c (main): Pass SIM_OPEN_STANDALONE to psim_options and
+ psim_usage.
+ * psim.c (psim_usage): Add new kind arg. Only show bug URL and
+ exit when kind is SIM_OPEN_STANDALONE.
+ (psim_options): Add new kind arg. Pass kind down to all psim_usage
+ calls. Replace error/break calls after psim_usage with return NULL.
+ Only exit with version case when kind is SIM_OPEN_STANDALONE.
+ * psim.h: Include gdb/remote-sim.h.
+ (psim_options): Add new kind arg.
+ (psim_usage): Likewise.
+ * sim_calls.c (sim_open): Pass kind to psim_options. Return NULL
+ when it returns NULL.
+
2015-12-29 Kevin Buettner <kevinb@redhat.com>
* emul_netbsd.c (fd_closed): New static array.
diff --git a/sim/ppc/main.c b/sim/ppc/main.c
index fad6973..667c02f 100644
--- a/sim/ppc/main.c
+++ b/sim/ppc/main.c
@@ -270,13 +270,13 @@ main(int argc, char **argv)
device *root = psim_tree();
/* parse the arguments */
- argv = psim_options(root, argv + 1);
+ argv = psim_options (root, argv + 1, SIM_OPEN_STANDALONE);
if (argv[0] == NULL) {
if (ppc_trace[trace_opts]) {
print_options ();
return 0;
} else {
- psim_usage(0, 0);
+ psim_usage (0, 0, SIM_OPEN_STANDALONE);
}
}
name_of_file = argv[0];
diff --git a/sim/ppc/psim.c b/sim/ppc/psim.c
index 183b9f2..3e322e3 100644
--- a/sim/ppc/psim.c
+++ b/sim/ppc/psim.c
@@ -118,7 +118,7 @@ find_arg(char *err_msg,
INLINE_PSIM\
(void)
-psim_usage(int verbose, int help)
+psim_usage (int verbose, int help, SIM_OPEN_KIND kind)
{
printf_filtered("Usage:\n");
printf_filtered("\n");
@@ -217,9 +217,12 @@ psim_usage(int verbose, int help)
print_options();
}
- if (REPORT_BUGS_TO[0])
- printf ("Report bugs to %s\n", REPORT_BUGS_TO);
- exit (help ? 0 : 1);
+ if (kind == SIM_OPEN_STANDALONE)
+ {
+ if (REPORT_BUGS_TO[0])
+ printf ("Report bugs to %s\n", REPORT_BUGS_TO);
+ exit (help ? 0 : 1);
+ }
}
/* Test "string" for containing a string of digits that form a number
@@ -247,7 +250,8 @@ int is_num( char *string, int min, int max, int err)
INLINE_PSIM\
(char **)
psim_options(device *root,
- char **argv)
+ char **argv,
+ SIM_OPEN_KIND kind)
{
device *current = root;
int argp;
@@ -261,9 +265,8 @@ psim_options(device *root,
switch (*p) {
default:
printf_filtered ("Invalid Option: %s\n", argv[argp]);
- psim_usage(0, 0);
- error ("");
- break;
+ psim_usage (0, 0, kind);
+ return NULL;
case 'c':
param = find_arg("Missing <count> option for -c (max-iterations)\n", &argp, argv);
tree_parse(root, "/openprom/options/max-iterations %s", param);
@@ -282,7 +285,8 @@ psim_options(device *root,
else
{
printf_filtered ("Invalid <endian> option for -E (target-endian)\n");
- psim_usage (0, 0);
+ psim_usage (0, 0, kind);
+ return NULL;
}
break;
case 'f':
@@ -291,11 +295,11 @@ psim_options(device *root,
break;
case 'h':
case '?':
- psim_usage(1, 1);
- break;
+ psim_usage (1, 1, kind);
+ return NULL;
case 'H':
- psim_usage(2, 1);
- break;
+ psim_usage (2, 1, kind);
+ return NULL;
case 'i':
if (isdigit(p[1])) {
tree_parse(root, "/openprom/trace/print-info %c", p[1]);
@@ -356,7 +360,10 @@ psim_options(device *root,
printf_filtered("Warning - architecture parameter ignored\n");
}
else if (strcmp (argv[argp], "--help") == 0)
- psim_usage (0, 1);
+ {
+ psim_usage (0, 1, kind);
+ return NULL;
+ }
else if (strncmp (argv[argp], "--sysroot=",
sizeof ("--sysroot=") - 1) == 0)
/* Ignore this option. */
@@ -365,13 +372,16 @@ psim_options(device *root,
{
extern const char version[];
printf ("GNU simulator %s%s\n", PKGVERSION, version);
- exit (0);
+ if (kind == SIM_OPEN_STANDALONE)
+ exit (0);
+ else
+ return NULL;
}
else
{
printf_filtered ("Invalid option: %s\n", argv[argp]);
- psim_usage (0, 0);
- error ("");
+ psim_usage (0, 0, kind);
+ return NULL;
}
break;
}
diff --git a/sim/ppc/psim.h b/sim/ppc/psim.h
index 60fd9b9..07852c2 100644
--- a/sim/ppc/psim.h
+++ b/sim/ppc/psim.h
@@ -23,6 +23,7 @@
#include "basics.h"
+#include "gdb/remote-sim.h"
/* the system object */
/* typedef struct _psim psim; */
@@ -48,7 +49,8 @@ extern device *psim_tree
extern char **psim_options
(device *root,
- char **argv);
+ char **argv,
+ SIM_OPEN_KIND kind);
extern void psim_command
(device *root,
@@ -60,7 +62,7 @@ extern void psim_merge_device_file
const char *file_name);
extern void psim_usage
-(int verbose, int help);
+(int verbose, int help, SIM_OPEN_KIND kind);
/* create a new simulator from the device tree */
diff --git a/sim/ppc/sim_calls.c b/sim/ppc/sim_calls.c
index 4e61335..d25b46c 100644
--- a/sim/ppc/sim_calls.c
+++ b/sim/ppc/sim_calls.c
@@ -77,7 +77,8 @@ sim_open (SIM_OPEN_KIND kind,
root_device = psim_tree();
simulator = NULL;
- psim_options(root_device, argv + 1);
+ if (psim_options (root_device, argv + 1, kind) == NULL)
+ return NULL;
if (ppc_trace[trace_opts])
print_options ();