From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12000 invoked by alias); 11 Oct 2003 17:35:34 -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 11992 invoked from network); 11 Oct 2003 17:35:31 -0000 Received: from unknown (HELO localhost.redhat.com) (65.49.0.121) by sources.redhat.com with SMTP; 11 Oct 2003 17:35:31 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 007832B89; Sat, 11 Oct 2003 13:35:01 -0400 (EDT) Message-ID: <3F883F45.7040702@redhat.com> Date: Sat, 11 Oct 2003 17:35:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030820 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Joern Rennecke Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: Add ftruncate support to newlib/gdb-sim to unbreak -fprofile-arcs References: <200307091927.h69JRfs29157@linsvr3.uk.superh.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-10/txt/msg00406.txt.bz2 (Picking patches that were allowed to slip to the floor 6.0 :-() > gdb: > sim/common: > * callback.c (os_ftruncate, os_truncate): New functions. > (default_callback): Initialize ftruncate and truncate members. > sim/sh: > * syscall.h (SYS_truncate, SYS_ftruncate): Define. > * interp.c (trap): Add support for SYS_ftruncate and SYS_truncate. Joern, yes, ok. Andrew > Index: gdb/callback.h > =================================================================== > RCS file: /cvs/src/src/include/gdb/callback.h,v > retrieving revision 1.1 > diff -p -r1.1 callback.h > *** gdb/callback.h 9 Jun 2002 15:45:43 -0000 1.1 > --- gdb/callback.h 9 Jul 2003 18:48:30 -0000 > *************** struct host_callback_struct > *** 93,98 **** > --- 93,100 ---- > void (*flush_stderr) PARAMS ((host_callback *)); > int (*stat) PARAMS ((host_callback *, const char *, struct stat *)); > int (*fstat) PARAMS ((host_callback *, int, struct stat *)); > + int (*ftruncate) PARAMS ((host_callback *, int, long)); > + int (*truncate) PARAMS ((host_callback *, const char *, long)); > > /* When present, call to the client to give it the oportunity to > poll any io devices for a request to quit (indicated by a nonzero > Index: common/callback.c > =================================================================== > RCS file: /cvs/src/src/sim/common/callback.c,v > retrieving revision 1.5 > diff -p -r1.5 callback.c > *** common/callback.c 9 Jun 2002 15:45:45 -0000 1.5 > --- common/callback.c 9 Jul 2003 18:48:57 -0000 > *************** os_fstat (p, fd, buf) > *** 399,404 **** > --- 399,428 ---- > return wrap (p, fstat (fdmap (p, fd), buf)); > } > > + static int > + os_ftruncate (p, fd, len) > + host_callback *p; > + int fd; > + long len; > + { > + int result; > + > + result = fdbad (p, fd); > + if (result) > + return result; > + result = wrap (p, ftruncate (fdmap (p, fd), len)); > + return result; > + } > + > + static int > + os_truncate (p, file, len) > + host_callback *p; > + const char *file; > + long len; > + { > + return wrap (p, stat (file, len)); > + } > + > static int > os_shutdown (p) > host_callback *p; > *************** host_callback default_callback = > *** 537,542 **** > --- 561,569 ---- > > os_stat, > os_fstat, > + > + os_ftruncate, > + os_truncate, > > os_poll_quit, > > Index: sh/interp.c > =================================================================== > RCS file: /cvs/src/src/sim/sh/interp.c,v > retrieving revision 1.9 > diff -p -r1.9 interp.c > *** sh/interp.c 27 Feb 2003 23:26:34 -0000 1.9 > --- sh/interp.c 9 Jul 2003 18:48:57 -0000 > *************** trap (i, regs, insn_ptr, memory, maskl, > *** 1151,1156 **** > --- 1151,1167 ---- > case SYS_time: > regs[0] = get_now (); > break; > + case SYS_ftruncate: > + regs[0] = callback->ftruncate (callback, regs[5], regs[6]); > + break; > + case SYS_truncate: > + { > + int len = strswaplen (regs[5]); > + strnswap (regs[5], len); > + regs[0] = callback->truncate (callback, ptr (regs[5]), regs[6]); > + strnswap (regs[5], len); > + break; > + } > default: > regs[0] = -1; > break; > Index: sh/syscall.h > =================================================================== > RCS file: /cvs/src/src/sim/sh/syscall.h,v > retrieving revision 1.2 > diff -p -r1.2 syscall.h > *** sh/syscall.h 30 Jan 2001 23:03:56 -0000 1.2 > --- sh/syscall.h 9 Jul 2003 18:48:58 -0000 > *************** > *** 27,32 **** > --- 27,34 ---- > #define SYS_stat 38 > #define SYS_pipe 42 > #define SYS_execve 59 > + #define SYS_truncate 129 > + #define SYS_ftruncate 130 > #define SYS_argc 172 > #define SYS_argnlen 173 > #define SYS_argn 174 >