This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA:] Support lstat as simulator call.
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 7 Dec 2004 02:43:16 +0100
- Subject: [RFA:] Support lstat as simulator call.
Covered by the (to-be-submitted) CRIS C testsuite.
Ok to commit?
sim/common:
* syscall.c (cb_syscall) <case CB_SYS_lstat>: New case.
* callback.c (os_lstat): New function.
include/gdb:
* callback.h (struct host_callback_struct): New member lstat.
(CB_SYS_lstat): New macro.
Index: callback.h
===================================================================
RCS file: /cvs/src/src/include/gdb/callback.h,v
retrieving revision 1.3
diff -c -p -r1.3 callback.h
*** callback.h 25 Jun 2004 16:48:01 -0000 1.3
--- callback.h 7 Dec 2004 01:41:07 -0000
*************** struct host_callback_struct
*** 93,98 ****
--- 93,99 ----
void (*flush_stderr) PARAMS ((host_callback *));
int (*stat) PARAMS ((host_callback *, const char *, struct stat *));
int (*fstat) PARAMS ((host_callback *, int, struct stat *));
+ int (*lstat) PARAMS ((host_callback *, const char *, struct stat *));
int (*ftruncate) PARAMS ((host_callback *, int, long));
int (*truncate) PARAMS ((host_callback *, const char *, long));
*************** extern host_callback default_callback;
*** 188,193 ****
--- 189,197 ----
#define CB_SYS_chmod 16
#define CB_SYS_utime 17
#define CB_SYS_time 18
+
+ /* More standard syscalls. */
+ #define CB_SYS_lstat 19
/* Struct use to pass and return information necessary to perform a
system call. */
Index: callback.c
===================================================================
RCS file: /cvs/src/src/sim/common/callback.c,v
retrieving revision 1.12
diff -c -p -r1.12 callback.c
*** callback.c 3 Dec 2004 23:34:55 -0000 1.12
--- callback.c 6 Dec 2004 17:10:25 -0000
*************** os_fstat (p, fd, buf)
*** 407,412 ****
--- 407,422 ----
return wrap (p, fstat (fdmap (p, fd), buf));
}
+ static int
+ os_lstat (p, file, buf)
+ host_callback *p;
+ const char *file;
+ struct stat *buf;
+ {
+ /* ??? Same issue here as with os_fstat. */
+ return (p, lstat (file, buf));
+ }
+
static int
os_ftruncate (p, fd, len)
host_callback *p;
*************** host_callback default_callback =
*** 589,594 ****
--- 599,605 ----
os_stat,
os_fstat,
+ os_lstat,
os_ftruncate,
os_truncate,
Index: syscall.c
===================================================================
RCS file: /cvs/src/src/sim/common/syscall.c,v
retrieving revision 1.3
diff -c -p -r1.3 syscall.c
*** syscall.c 10 May 2004 16:18:03 -0000 1.3
--- syscall.c 6 Dec 2004 17:10:25 -0000
*************** cb_syscall (cb, sc)
*** 444,449 ****
--- 471,520 ----
}
break;
+ case CB_SYS_lstat :
+ {
+ char *path, *buf;
+ int buflen;
+ struct stat statbuf;
+ TADDR addr = sc->arg2;
+
+ errcode = get_path (cb, sc, sc->arg1, &path);
+ if (errcode != 0)
+ {
+ result = -1;
+ goto FinishSyscall;
+ }
+ result = (*cb->lstat) (cb, path, &statbuf);
+ free (path);
+ if (result < 0)
+ goto ErrorFinish;
+
+ buflen = cb_host_to_target_stat (cb, NULL, NULL);
+ buf = xmalloc (buflen);
+ if (cb_host_to_target_stat (cb, &statbuf, buf) != buflen)
+ {
+ /* The translation failed. This is due to an internal
+ host program error, not the target's fault.
+ Unfortunately, it's hard to test this case, so there's no
+ test-case for this execution path. */
+ free (buf);
+ errcode = ENOSYS;
+ result = -1;
+ goto FinishSyscall;
+ }
+
+ if ((*sc->write_mem) (cb, sc, addr, buf, buflen) != buflen)
+ {
+ free (buf);
+ errcode = EINVAL;
+ result = -1;
+ goto FinishSyscall;
+ }
+
+ free (buf);
+ }
+ break;
+
case CB_SYS_time :
{
/* FIXME: May wish to change CB_SYS_time to something else.
brgds, H-P