This is the mail archive of the gdb-patches@sourceware.org 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: [patch, sim, mips] Implement unlink, lseek, and stat for MIPS


On Wednesday 10 July 2013 10:48:28 Steve Ellcey wrote:
> A while back I submitted a GCC patch that allowed me to build the Fortran
> compiler on a newlib based cross compiler.  While using the GNU simulator
> to test that, I found that a number of tests failed due to unimplemented
> system calls on the MIPS GNU simulator.  This patch implements unlink,
> lseek, and stat in the GNU simulator for MIPS.  There is a second small
> patch that I sent to newlib that generates the necessary functions for
> the simulator to see and intercept these functions like it does others
> that are already implemented such as open and close.

yeah, it'd be nice if mips could just use the already existing 
common/syscall.c and common/callback.c files where a bunch of funcs are already 
implemented ...

> --- a/sim/mips/interp.c
> +++ b/sim/mips/interp.c
>
> +/* We may need to swap stat data around before passing it on to the
> +   program being run.  */
> +#define copy16(x) (BigEndianMem ? bswap_16(x) : (x))
> +#define copy32(x) (BigEndianMem ? bswap_32(x) : (x))
> +
> +    case 15: /* int stat(const char *path, struct stat *buf); */
> +      {
> +	/* We need to put the data into the type of stat structure
> +	   that MIPS uses and make sure it has the correct endianness.
> +	   We are assuming that the host and MIPS agree on what the bits
> +	   in st_mode mean.  That appears to be true for x86 linux and
> +	   MIPS.  */

instead of doing this, can you use the existing stat cb handler instead ?

	host_callback *cb = STATE_CALLBACK (sd);
	struct stat statbuf;
	int result;

	result = (*cb->stat) (cb, path, &statbuf);

you'll need to initialize cb->stat_map to a string (probably in 
sim_create_inferior).  see bfin/interp.c:cb_linux_stat_map_32 as an example.
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


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