This is the mail archive of the gdb-patches@sources.redhat.com 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]

Re: RFA: Add ftruncate support to newlib/gdb-sim to unbreak -fprofile-arcs


(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






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]