Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA:] Support lstat as simulator call.
@ 2004-12-07  2:29 Hans-Peter Nilsson
  2004-12-07  3:22 ` Hans-Peter Nilsson
  0 siblings, 1 reply; 3+ messages in thread
From: Hans-Peter Nilsson @ 2004-12-07  2:29 UTC (permalink / raw)
  To: gdb-patches

Covered by the (to-be-submitted) CRIS C testsuite.
Ok to commit?

sim/common:
	* syscall.c (cb_syscall) <case CB_SYS_lstat>: 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
  \f
  /* 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA:] Support lstat as simulator call.
  2004-12-07  2:29 [RFA:] Support lstat as simulator call Hans-Peter Nilsson
@ 2004-12-07  3:22 ` Hans-Peter Nilsson
  2004-12-12 18:04   ` Andrew Cagney
  0 siblings, 1 reply; 3+ messages in thread
From: Hans-Peter Nilsson @ 2004-12-07  3:22 UTC (permalink / raw)
  To: gdb-patches

> Date: Tue, 7 Dec 2004 02:43:16 +0100
> From: Hans-Peter Nilsson <hp@axis.com>

> *** 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));

Oops should have been "return wrap (p, lstat (file, buf));"
Sorry about that.

(Noticed because of a error-checking test-case that didn't show
up as KPASS...  The local equivalent had sysroot stuff here so
the code was slightly edited from the well-tested variant.)

brgds, H-P


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA:] Support lstat as simulator call.
  2004-12-07  3:22 ` Hans-Peter Nilsson
@ 2004-12-12 18:04   ` Andrew Cagney
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2004-12-12 18:04 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: gdb-patches

Hans-Peter Nilsson wrote:
>>Date: Tue, 7 Dec 2004 02:43:16 +0100
>>From: Hans-Peter Nilsson <hp@axis.com>

Yes (with tweak) and thanks for testing this.

  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.  */

Use /* FIXME: hpn/2004-12-12: ... */ or /* NOTE: hph/2004-12-12: ... */ 
so we know who and when the comment was added.

therwize, yes, ok,
Andrew

>>+   return (p, lstat (file, buf));
> 
> 
> Oops should have been "return wrap (p, lstat (file, buf));"
> Sorry about that.
> 
> (Noticed because of a error-checking test-case that didn't show
> up as KPASS...  The local equivalent had sysroot stuff here so
> the code was slightly edited from the well-tested variant.)
> 
> brgds, H-P
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-12-12 18:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-07  2:29 [RFA:] Support lstat as simulator call Hans-Peter Nilsson
2004-12-07  3:22 ` Hans-Peter Nilsson
2004-12-12 18:04   ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox