|
From: <sv...@va...> - 2005-06-19 21:10:47
|
Author: njn
Date: 2005-06-19 22:10:42 +0100 (Sun, 19 Jun 2005)
New Revision: 3960
Log:
Moved VG_(resolve_filename{,_nodup}) from m_syswrap into m_libcfile,
so that m_aspacemgr doesn't depend on m_syswrap any more.
Modified:
trunk/coregrind/m_aspacemgr/aspacemgr.c
trunk/coregrind/m_libcfile.c
trunk/coregrind/m_syswrap/syswrap-generic.c
trunk/coregrind/pub_core_libcfile.h
trunk/coregrind/pub_core_syswrap.h
Modified: trunk/coregrind/m_aspacemgr/aspacemgr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-06-19 19:38:03 UTC (rev =
3959)
+++ trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-06-19 21:10:42 UTC (rev =
3960)
@@ -35,14 +35,13 @@
#include "pub_core_aspacemgr.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
-#include "pub_core_libcfile.h" // For VG_(fstat)()
+#include "pub_core_libcfile.h"
#include "pub_core_libcmman.h"
#include "pub_core_libcprint.h"
#include "pub_core_libcproc.h"
#include "pub_core_mallocfree.h"
#include "pub_core_options.h"
#include "pub_core_syscall.h"
-#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
#include "pub_core_transtab.h"
#include "vki_unistd.h"
Modified: trunk/coregrind/m_libcfile.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_libcfile.c 2005-06-19 19:38:03 UTC (rev 3959)
+++ trunk/coregrind/m_libcfile.c 2005-06-19 21:10:42 UTC (rev 3960)
@@ -32,6 +32,7 @@
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcfile.h"
+#include "pub_core_libcprint.h"
#include "pub_core_mallocfree.h"
#include "pub_core_options.h"
#include "pub_core_syscall.h"
@@ -69,6 +70,36 @@
return newfd;
}
=20
+/* Given a file descriptor, attempt to deduce its filename. To do
+ this, we use /proc/self/fd/<FD>. If this doesn't point to a file,
+ or if it doesn't exist, we just return NULL. The caller is
+ responsible for copying the contents of buf out immediately. */
+static HChar resolve_filename_buf[VKI_PATH_MAX];
+HChar* VG_(resolve_filename_nodup) ( Int fd )
+{
+ HChar tmp[64];
+
+ VG_(sprintf)(tmp, "/proc/self/fd/%d", fd);
+ VG_(memset)(resolve_filename_buf, 0, VKI_PATH_MAX);
+
+ if (VG_(readlink)(tmp, resolve_filename_buf, VKI_PATH_MAX) =3D=3D -1)
+ return NULL;
+
+ return (resolve_filename_buf[0] =3D=3D '/')=20
+ ? resolve_filename_buf=20
+ : NULL;
+}
+
+/* Same as resolve_filename_nodup, except that the result is copied=20
+ into new memory which the caller is responsible for freeing. */
+HChar* VG_(resolve_filename) ( Int fd )
+{
+ HChar* transient =3D VG_(resolve_filename_nodup)(fd);
+ return transient
+ ? VG_(arena_strdup)(VG_AR_CORE, transient)
+ : NULL;
+}
+
/* Returns -1 on failure. */
Int VG_(open) ( const Char* pathname, Int flags, Int mode )
{ =20
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-generic.c 2005-06-19 19:38:03 UTC (=
rev 3959)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c 2005-06-19 21:10:42 UTC (=
rev 3960)
@@ -286,7 +286,6 @@
------------------------------------------------------------------ */
=20
/* One of these is allocated for each open file descriptor. */
-
typedef struct OpenFd
{
Int fd; /* The file descriptor */
@@ -296,51 +295,13 @@
} OpenFd;
=20
/* List of allocated file descriptors. */
-
static OpenFd *allocated_fds;
=20
/* Count of open file descriptors. */
-
static int fd_count =3D 0;
=20
=20
-
-/* Given a file descriptor, attempt to deduce its filename. To do
- this, we use /proc/self/fd/<FD>. If this doesn't point to a file,
- or if it doesn't exist, we just return NULL. The caller is
- responsible for copying the contents of buf out immediately. */
-
-static HChar resolve_filename_buf[VKI_PATH_MAX];
-
-HChar* VG_(resolve_filename_nodup) ( Int fd )
-{
- HChar tmp[64];
-
- VG_(sprintf)(tmp, "/proc/self/fd/%d", fd);
- VG_(memset)(resolve_filename_buf, 0, VKI_PATH_MAX);
-
- if (VG_(readlink)(tmp, resolve_filename_buf, VKI_PATH_MAX) =3D=3D -1)
- return NULL;
-
- return (resolve_filename_buf[0] =3D=3D '/')=20
- ? resolve_filename_buf=20
- : NULL;
-}
-
-/* Same as resolve_filename_nodup, except that the result is copied=20
- into new memory which the caller is responsible for freeing. */
-
-HChar* VG_(resolve_filename) ( Int fd )
-{
- HChar* transient =3D VG_(resolve_filename_nodup)(fd);
- return transient
- ? VG_(arena_strdup)(VG_AR_CORE, transient)
- : NULL;
-}
-
-
/* Note the fact that a file descriptor was just closed. */
-
static
void record_fd_close(ThreadId tid, Int fd)
{
@@ -373,7 +334,6 @@
some such thing) or that we don't know the filename. If the fd is
already open, then we're probably doing a dup2() to an existing fd,
so just overwrite the existing one. */
-
void VG_(record_fd_open)(ThreadId tid, Int fd, char *pathname)
{
OpenFd *i;
Modified: trunk/coregrind/pub_core_libcfile.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_libcfile.h 2005-06-19 19:38:03 UTC (rev 3959=
)
+++ trunk/coregrind/pub_core_libcfile.h 2005-06-19 21:10:42 UTC (rev 3960=
)
@@ -46,6 +46,10 @@
extern Int VG_(safe_fd) ( Int oldfd );
extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
=20
+/* Convert an fd into a filename */
+extern HChar* VG_(resolve_filename_nodup) ( Int fd );
+extern HChar* VG_(resolve_filename) ( Int fd );
+
/* Default destination port to be used in logging over a network, if
none specified. */
#define VG_CLO_DEFAULT_LOGPORT 1500
Modified: trunk/coregrind/pub_core_syswrap.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_syswrap.h 2005-06-19 19:38:03 UTC (rev 3959)
+++ trunk/coregrind/pub_core_syswrap.h 2005-06-19 21:10:42 UTC (rev 3960)
@@ -43,9 +43,6 @@
// as if the thread had been set up by clone()
extern void VGP_(main_thread_wrapper_NORETURN)(ThreadId tid);
=20
-extern HChar* VG_(resolve_filename_nodup)(Int fd);
-extern HChar* VG_(resolve_filename)(Int fd);
-
extern void VG_(client_syscall) ( ThreadId tid );
=20
extern void VG_(post_syscall) ( ThreadId tid );
|