aboutsummaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-11-16 01:26:47 -0500
committerMike Frysinger <vapier@gentoo.org>2021-11-16 02:13:42 -0500
commit85588c9ab947a4edfeedc7c14bd202d15ccfbbff (patch)
tree87aaa3c6e70ba77ea654eacc5dc85e924060749f /sim/common
parentfab6939b01da06e1b5f423a8c7f72160b0a1e35d (diff)
downloadgdb-85588c9ab947a4edfeedc7c14bd202d15ccfbbff.zip
gdb-85588c9ab947a4edfeedc7c14bd202d15ccfbbff.tar.gz
gdb-85588c9ab947a4edfeedc7c14bd202d15ccfbbff.tar.bz2
sim: syscall: hoist argc/argn/argnlen to common code
Now that the callback framework supports argv & envp, we can move the Blackfin implementation of these syscalls to the common code.
Diffstat (limited to 'sim/common')
-rw-r--r--sim/common/syscall.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/sim/common/syscall.c b/sim/common/syscall.c
index bad3b3b..df9dd92 100644
--- a/sim/common/syscall.c
+++ b/sim/common/syscall.c
@@ -141,6 +141,46 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc)
switch (cb_target_to_host_syscall (cb, sc->func))
{
+ case CB_SYS_argc:
+ result = countargv (cb->argv);
+ break;
+
+ case CB_SYS_argnlen:
+ {
+ if (sc->arg1 >= 0 && sc->arg1 < countargv (cb->argv))
+ result = strlen (cb->argv[sc->arg1]);
+ else
+ {
+ result = -1;
+ errcode = EINVAL;
+ }
+ }
+ break;
+
+ case CB_SYS_argn:
+ {
+ if (sc->arg1 >= 0 && sc->arg1 < countargv (cb->argv))
+ {
+ const char *argn = cb->argv[sc->arg1];
+ int len = strlen (argn);
+ int written = sc->write_mem (cb, sc, sc->arg2, argn, len + 1);
+
+ if (written == len + 1)
+ result = sc->arg2;
+ else
+ {
+ result = -1;
+ errcode = EINVAL;
+ }
+ }
+ else
+ {
+ result = -1;
+ errcode = EINVAL;
+ }
+ }
+ break;
+
case CB_SYS_argvlen :
{
/* Compute how much space is required to store the argv,envp