This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
some ports leverage the argc/argn/argnlen syscalls to get at argv[] rather than the more complicated argv/argvlen syscalls. so add support for these to the common code. not that it makes too much of a difference today since these argv funcs are #if 0 pending something ... -mike 2010-02-05 Mike Frysinger <vapier@gentoo.org> * common/syscall.c (cb_syscall): Handle CB_SYS_argc, CB_SYS_argn, and CB_SYS_argnlen. RCS file: /cvs/src/src/sim/common/syscall.c,v retrieving revision 1.16 diff -u -p -r1.16 syscall.c --- sim/common/syscall.c 1 Jan 2010 10:03:27 -0000 1.16 +++ sim/common/syscall.c 5 Feb 2010 09:53:22 -0000 @@ -153,11 +153,13 @@ cb_syscall (cb, sc) CB_SYSCALL *sc; { TWORD result = 0, errcode = 0; + int host_syscall; if (sc->magic != CB_SYSCALL_MAGIC) abort (); - switch (cb_target_to_host_syscall (cb, sc->func)) + host_syscall = cb_target_to_host_syscall (cb, sc->func); + switch (host_syscall) { #if 0 /* FIXME: wip */ case CB_SYS_argvlen : @@ -248,6 +250,56 @@ cb_syscall (cb, sc) sc->result2 = envc; break; } + + /* Compute the number of arguments. */ + case CB_SYS_argc : + /* Compute the length of a specific argument. */ + case CB_SYS_argnlen : + /* Copy a specific argument. */ + case CB_SYS_argn : + { + int argc, len; + const char **argv = cb->init_argv; + + argc = 0; + if (argv) + { + for ( ; argv[argc]; ++argc) + continue; + } + if (host_syscall == CB_SYS_argc) + { + result = argc; + break; + } + + if (sc->arg1 < argc) + { + TADDR tbuf = sc->arg2; + int written, len = strlen (argv[sc->arg1]); + if (host_syscall == CB_SYS_argnlen) + { + result = len; + break; + } + + written = (*sc->write_mem) (cb, sc, tbuf, argv[sc->arg1], len + 1); + if (written != len) + { + result = -1; + errcode = EINVAL; + goto FinishSyscall; + } + result = sc->arg2; + } + else + { + result = -1; + errcode = EINVAL; + goto FinishSyscall; + } + } + break; #endif /* wip */ case CB_SYS_exit :
Attachment:
signature.asc
Description: This is a digitally signed message part.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |