From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21516 invoked by alias); 9 Jul 2003 19:27:57 -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 21147 invoked from network); 9 Jul 2003 19:27:46 -0000 Received: from unknown (HELO ns2.uk.superh.com) (193.128.105.170) by sources.redhat.com with SMTP; 9 Jul 2003 19:27:46 -0000 Received: from sh-uk-ex01.uk.w2k.superh.com (sh-uk-ex01 [192.168.16.17]) by ns2.uk.superh.com (8.11.6+Sun/8.11.6) with ESMTP id h69JN4K00867; Wed, 9 Jul 2003 20:23:04 +0100 (BST) Received: from linsvr3.uk.superh.com ([192.168.16.52]) by sh-uk-ex01.uk.w2k.superh.com with Microsoft SMTPSVC(5.0.2195.5329); Wed, 9 Jul 2003 20:28:15 +0100 Received: (from renneckej@localhost) by linsvr3.uk.superh.com (8.11.6/8.11.6) id h69JRfs29157; Wed, 9 Jul 2003 20:27:41 +0100 From: Joern Rennecke Message-Id: <200307091927.h69JRfs29157@linsvr3.uk.superh.com> Subject: RFA: Add ftruncate support to newlib/gdb-sim to unbreak -fprofile-arcs To: newlib@sources.redhat.com, gdb-patches@sources.redhat.com Date: Wed, 09 Jul 2003 19:27:00 -0000 Cc: gcc@gcc.gnu.org, nathan@codesourcery.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 09 Jul 2003 19:28:15.0038 (UTC) FILETIME=[3E23FDE0:01C34650] X-SW-Source: 2003-07/txt/msg00188.txt.bz2 The recent change to libgcov to use ftruncate has broken -fprofile-arcs functionality for the newlib-based sh-elf toolchain. The appended patches add ftruncate and truncate support to sh-elf newlib / gdb-sim . 2003-07-09 J"orn Rennecke newlib: * libc/include/sys/unistd.h (ftruncate, truncate): Also declare for __sh__. * libc/sys/sh/Makefile.am (lib_a_SOURCES): Add ftruncate.c and truncate.c. * libc/sys/sh/Makefile.in: Regenerate. * libc/sys/sh/sys/syscall.h: (SYS_truncate, SYS_ftruncate): Define. * libc/sys/sh/ftruncate.c: New file. * libc/sys/sh/truncate.c: Likewise. include/gdb: * callback.h (struct host_callback_struct): New members ftruncate and truncate. 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. Index: libc/include/sys/unistd.h =================================================================== RCS file: /cvs/src/src/newlib/libc/include/sys/unistd.h,v retrieving revision 1.43 diff -p -r1.43 unistd.h *** libc/include/sys/unistd.h 15 Apr 2003 20:13:49 -0000 1.43 --- libc/include/sys/unistd.h 9 Jul 2003 18:48:12 -0000 *************** int _EXFUN(getdtablesize, (void)); *** 180,189 **** --- 180,193 ---- int _EXFUN(setdtablesize, (int)); useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval)); unsigned _EXFUN(usleep, (unsigned int __useconds)); + #endif + #if defined(__CYGWIN__) || defined(__rtems__) || defined(__sh__) #if !defined(__INSIDE_CYGWIN__) int _EXFUN(ftruncate, (int __fd, off_t __length)); int _EXFUN(truncate, (const char *, off_t __length)); #endif + #endif + #if defined(__CYGWIN__) || defined(__rtems__) #if !(defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) /* winsock[2].h defines as __stdcall, and with int as 2nd arg */ int _EXFUN(gethostname, (char *__name, size_t __len)); Index: libc/sys/sh/Makefile.am =================================================================== RCS file: /cvs/src/src/newlib/libc/sys/sh/Makefile.am,v retrieving revision 1.1.1.1 diff -p -r1.1.1.1 Makefile.am *** libc/sys/sh/Makefile.am 17 Feb 2000 19:39:50 -0000 1.1.1.1 --- libc/sys/sh/Makefile.am 9 Jul 2003 18:48:12 -0000 *************** INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLA *** 6,12 **** noinst_LIBRARIES = lib.a ! lib_a_SOURCES = syscalls.c trap.S creat.c all: crt0.o --- 6,12 ---- noinst_LIBRARIES = lib.a ! lib_a_SOURCES = syscalls.c trap.S creat.c ftruncate.c truncate.c all: crt0.o Index: Makefile.in =================================================================== RCS file: /cvs/src/src/newlib/libc/sys/sh/Makefile.in,v retrieving revision 1.5 diff -p -r1.5 Makefile.in *** Makefile.in 4 Jul 2002 19:57:51 -0000 1.5 --- Makefile.in 9 Jul 2003 18:54:29 -0000 *************** *** 1,6 **** ! # Makefile.in generated automatically by automake 1.4 from Makefile.am ! # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. --- 1,6 ---- ! # Makefile.in generated automatically by automake 1.4-p5 from Makefile.am ! # Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. *************** INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLA *** 89,95 **** noinst_LIBRARIES = lib.a ! lib_a_SOURCES = syscalls.c trap.S creat.c ACLOCAL_AMFLAGS = -I ../../.. CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host --- 89,95 ---- noinst_LIBRARIES = lib.a ! lib_a_SOURCES = syscalls.c trap.S creat.c ftruncate.c truncate.c ACLOCAL_AMFLAGS = -I ../../.. CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host *************** DEFS = @DEFS@ -I. -I$(srcdir) *** 103,109 **** CPPFLAGS = @CPPFLAGS@ LIBS = @LIBS@ lib_a_LIBADD = ! lib_a_OBJECTS = syscalls.o trap.o creat.o CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) --- 103,109 ---- CPPFLAGS = @CPPFLAGS@ LIBS = @LIBS@ lib_a_LIBADD = ! lib_a_OBJECTS = syscalls.o trap.o creat.o ftruncate.o truncate.o CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) Index: libc/sys/sh/sys/syscall.h =================================================================== RCS file: /cvs/src/src/newlib/libc/sys/sh/sys/syscall.h,v retrieving revision 1.2 diff -p -r1.2 syscall.h *** libc/sys/sh/sys/syscall.h 1 Feb 2001 21:25:56 -0000 1.2 --- libc/sys/sh/sys/syscall.h 9 Jul 2003 18:48:12 -0000 *************** *** 27,32 **** --- 27,35 ---- #define SYS_pipe 42 #define SYS_execve 59 + #define SYS_truncate 129 + #define SYS_ftruncate 130 + #define SYS_argc 172 /* == 0xAC, for Argument Count :-) */ #define SYS_argnlen 173 #define SYS_argn 174 *** /dev/null Thu Aug 30 21:30:55 2001 --- libc/sys/sh/ftruncate.c Wed Jul 9 17:05:05 2003 *************** *** 0 **** --- 1,9 ---- + #include <_ansi.h> + #include + #include "sys/syscall.h" + + int + ftruncate (int file, off_t length) + { + return __trap34 (SYS_ftruncate, file, length, 0); + } *** /dev/null Thu Aug 30 21:30:55 2001 --- libc/sys/sh/truncate.c Wed Jul 9 17:18:48 2003 *************** *** 0 **** --- 1,9 ---- + #include <_ansi.h> + #include + #include "sys/syscall.h" + + int + truncate (const char *path, off_t length) + { + return __trap34 (SYS_ftruncate, path, length, 0); + } 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