From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9755 invoked by alias); 7 Dec 2004 01:43:24 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 9709 invoked from network); 7 Dec 2004 01:43:17 -0000 Received: from unknown (HELO krynn.se.axis.com) (193.13.178.10) by sourceware.org with SMTP; 7 Dec 2004 01:43:17 -0000 Received: from ignucius.se.axis.com (ignucius.se.axis.com [10.83.5.18]) by krynn.se.axis.com (8.12.9/8.12.9/Debian-5local0.1) with ESMTP id iB71hGAD027832; Tue, 7 Dec 2004 02:43:16 +0100 Received: from ignucius.se.axis.com (localhost [127.0.0.1]) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) with ESMTP id iB71hGdD016420; Tue, 7 Dec 2004 02:43:16 +0100 Received: (from hp@localhost) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) id iB71hG0m016416; Tue, 7 Dec 2004 02:43:16 +0100 Date: Tue, 07 Dec 2004 02:29:00 -0000 Message-Id: <200412070143.iB71hG0m016416@ignucius.se.axis.com> From: Hans-Peter Nilsson To: gdb-patches@sources.redhat.com Subject: [RFA:] Support lstat as simulator call. X-SW-Source: 2004-12/txt/msg00184.txt.bz2 Covered by the (to-be-submitted) CRIS C testsuite. Ok to commit? sim/common: * syscall.c (cb_syscall) : 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