aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorsewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2005-09-27 19:20:21 +0000
committersewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2005-09-27 19:20:21 +0000
commit45f4e7c91119c7d01a59f5e827c67841632c9314 (patch)
treecf3699fede5e2136f3141b32b7d0324a39aa726d /include
parent1df54d2464f181a989638ef4307152482c2ad395 (diff)
downloadvalgrind-45f4e7c91119c7d01a59f5e827c67841632c9314.tar.gz
This commit merges in changes from branches/ASPACEM (specifically,
changes from r4341 through r4787 inclusive). That branch is now dead. Please do not commit anything else to it. For the most part the merge was not troublesome. The main areas of uncertainty are: - build system: I had to import by hand Makefile.core-AM_CPPFLAGS.am and include it in a couple of places. Building etc seems to still work, but I haven't tried building the documentation. - syscall wrappers: Following analysis by Greg & Nick, a whole lot of stuff was moved from -generic to -linux after the branch was created. I think that is satisfactorily glued back together now. - Regtests: although this appears to work, no .out files appear, which is strange, and makes it hard to diagnose regtest failures. In particular memcheck/tests/x86/scalar.stderr.exp remains in a conflicted state. - amd64 is broken (slightly), and ppc32 will be unbuildable. I'll attend to the former shortly. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4789 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am2
-rw-r--r--include/pub_tool_aspacemgr.h115
-rw-r--r--include/pub_tool_basics.h6
-rw-r--r--include/pub_tool_basics_asm.h4
-rw-r--r--include/pub_tool_clientstate.h77
-rw-r--r--include/pub_tool_libcbase.h8
-rw-r--r--include/pub_tool_libcfile.h10
-rw-r--r--include/pub_tool_libcmman.h41
-rw-r--r--include/pub_tool_libcprint.h14
-rw-r--r--include/pub_tool_libcproc.h7
-rw-r--r--include/pub_tool_mallocfree.h4
-rw-r--r--include/pub_tool_tooliface.h9
-rw-r--r--include/vki-amd64-linux.h1
-rw-r--r--include/vki-linux.h17
14 files changed, 234 insertions, 81 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 5398ce9c4..be65a1ad5 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -5,6 +5,7 @@ incinc_HEADERS = \
pub_tool_basics.h \
pub_tool_basics_asm.h \
pub_tool_aspacemgr.h \
+ pub_tool_clientstate.h \
pub_tool_cpuid.h \
pub_tool_debuginfo.h \
pub_tool_errormgr.h \
@@ -13,7 +14,6 @@ incinc_HEADERS = \
pub_tool_libcbase.h \
pub_tool_libcassert.h \
pub_tool_libcfile.h \
- pub_tool_libcmman.h \
pub_tool_libcprint.h \
pub_tool_libcproc.h \
pub_tool_libcsignal.h \
diff --git a/include/pub_tool_aspacemgr.h b/include/pub_tool_aspacemgr.h
index 92c102f87..51240bb3d 100644
--- a/include/pub_tool_aspacemgr.h
+++ b/include/pub_tool_aspacemgr.h
@@ -31,21 +31,110 @@
#ifndef __PUB_TOOL_ASPACEMGR_H
#define __PUB_TOOL_ASPACEMGR_H
-extern Bool VG_(is_client_addr) (Addr a);
-extern Bool VG_(is_shadow_addr) (Addr a);
-
-extern void *VG_(shadow_alloc)(UInt size);
-
-extern Bool VG_(is_addressable)(Addr p, SizeT sz, UInt prot);
-
-/* Calls into the core used by leak-checking */
-
-/* Calls "add_rootrange" with each range of memory which looks like a
- plausible source of root pointers. This is very Memcheck-specific --
- it's used in leak detection.
+//--------------------------------------------------------------
+// Definition of address-space segments
+
+/* Describes segment kinds. */
+typedef
+ enum {
+ SkFree, // unmapped space
+ SkAnonC, // anonymous mapping belonging to the client
+ SkAnonV, // anonymous mapping belonging to valgrind
+ SkFileC, // file mapping belonging to the client
+ SkFileV, // file mapping belonging to valgrind
+ SkResvn // reservation
+ }
+ SegKind;
+
+/* Describes how a reservation segment can be resized. */
+typedef
+ enum {
+ SmLower, // lower end can move up
+ SmFixed, // cannot be shrunk
+ SmUpper // upper end can move down
+ }
+ ShrinkMode;
+
+/* Describes a segment. Invariants:
+
+ kind == SkFree:
+ // the only meaningful fields are .start and .end
+
+ kind == SkAnon{C,V}:
+ // smode==SmFixed
+ // there's no associated file:
+ dev==ino==foff = 0, fnidx == -1
+ // segment may have permissions
+
+ kind == SkFile{C,V}:
+ // smode==SmFixed
+ moveLo == moveHi == NotMovable, maxlen == 0
+ // there is an associated file
+ // segment may have permissions
+
+ kind == SkResvn
+ // the segment may be resized if required
+ // there's no associated file:
+ dev==ino==foff = 0, fnidx == -1
+ // segment has no permissions
+ hasR==hasW==hasX==anyTranslated == False
+
+ Also: anyTranslated==True is only allowed in SkFileV and SkAnonV
+ (viz, not allowed to make translations from non-client areas)
*/
-extern void VG_(find_root_memory)(void (*add_rootrange)(Addr addr, SizeT sz));
+typedef
+ struct {
+ SegKind kind;
+ /* Extent (SkFree, SkAnon{C,V}, SkFile{C,V}, SkResvn) */
+ Addr start; // lowest address in range
+ Addr end; // highest address in range
+ /* Shrinkable? (SkResvn only) */
+ ShrinkMode smode;
+ /* Associated file (SkFile{C,V} only) */
+ UWord dev;
+ UWord ino;
+ ULong offset;
+ Int fnIdx; // file name table index, if name is known
+ /* Permissions (SkAnon{C,V}, SkFile{C,V} only) */
+ Bool hasR;
+ Bool hasW;
+ Bool hasX;
+ Bool hasT; // True --> translations have (or MAY have)
+ // been taken from this segment
+ Bool isCH; // True --> is client heap (SkAnonC ONLY)
+ /* Admin */
+ Bool mark;
+ }
+ NSegment;
+
+
+/* Collect up the start addresses of all non-free, non-resvn segments.
+ The interface is a bit strange in order to avoid potential
+ segment-creation races caused by dynamic allocation of the result
+ buffer *starts.
+
+ The function first computes how many entries in the result
+ buffer *starts will be needed. If this number <= nStarts,
+ they are placed in starts[0..], and the number is returned.
+ If nStarts is not large enough, nothing is written to
+ starts[0..], and the negation of the size is returned.
+
+ Correct use of this function may mean calling it multiple times in
+ order to establish a suitably-sized buffer. */
+extern Int VG_(am_get_segment_starts)( Addr* starts, Int nStarts );
+
+
+// See pub_core_aspacemgr.h for description.
+extern NSegment* VG_(am_find_nsegment) ( Addr a );
+
+// See pub_core_aspacemgr.h for description.
+extern Bool VG_(am_is_valid_for_client) ( Addr start, SizeT len,
+ UInt prot );
+
+// See pub_core_aspacemgr.h for description.
+/* Really just a wrapper around VG_(am_mmap_anon_float_valgrind). */
+extern void* VG_(am_shadow_alloc)(SizeT size);
#endif // __PUB_TOOL_ASPACEMGR_H
diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h
index f75b93622..7af5240e9 100644
--- a/include/pub_tool_basics.h
+++ b/include/pub_tool_basics.h
@@ -106,7 +106,7 @@ typedef struct {
SysRes;
/* ---------------------------------------------------------------------
- Miscellaneous (word size, endianness, regparmness)
+ Miscellaneous (word size, endianness, regparmness, stringification)
------------------------------------------------------------------ */
/* Word size: this is going to be either 4 or 8. */
@@ -132,6 +132,10 @@ SysRes;
# error Unknown arch
#endif
+/* Macro games */
+#define VG_STRINGIFZ(__str) #__str
+#define VG_STRINGIFY(__str) VG_STRINGIFZ(__str)
+
#endif /* __PUB_TOOL_BASICS_H */
/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_basics_asm.h b/include/pub_tool_basics_asm.h
index 65f479976..740eaba62 100644
--- a/include/pub_tool_basics_asm.h
+++ b/include/pub_tool_basics_asm.h
@@ -1,7 +1,7 @@
/*--------------------------------------------------------------------*/
-/*--- Header imported directly by every asm file, and indirectly ---*/
-/*--- (via pub_tool_basics.h) by every C file. ---*/
+/*--- Header imported directly by every tool asm file, and ---*/
+/*--- (via pub_tool_basics.h) by every tool C file. ---*/
/*--- pub_tool_basics_asm.h ---*/
/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_clientstate.h b/include/pub_tool_clientstate.h
new file mode 100644
index 000000000..065c2baa3
--- /dev/null
+++ b/include/pub_tool_clientstate.h
@@ -0,0 +1,77 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Misc client state info pub_tool_clientstate.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ jseward@acm.org
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PUB_TOOL_CLIENTSTATE_H
+#define __PUB_TOOL_CLIENTSTATE_H
+
+
+// Command line pieces, after they have been extracted from argv in
+// m_main.main(). These are all NULL-terminated vectors.
+
+/* Expandable arrays of strings. */
+typedef
+ struct {
+ Int size;
+ Int used;
+ HChar** strs;
+ }
+ XArrayStrings;
+
+/* Args for the client. */
+extern XArrayStrings VG_(args_for_client);
+
+/* Args for V. This is the concatenation of the following:
+ - contents of ~/.valgrindrc
+ - contents of $VALGRIND_OPTS
+ - contents of ./.valgrindrc
+ - args from the command line
+ in the stated order.
+
+ Only the last of these is passed onwards to child Valgrinds at
+ client sys_execve, since the children will re-acquire the first 3
+ categories for themselves. Therefore we also record the number of
+ these no-pass-at-execve arguments -- that is what
+ VG_(args_for_valgrind_noexecpass) is. */
+extern XArrayStrings VG_(args_for_valgrind);
+
+/* Number of leading args in VG_(args_for_valgrind) not to pass on at
+ exec time. */
+extern Int VG_(args_for_valgrind_noexecpass);
+
+/* The name of the client executable, as specified on the command
+ line. */
+extern HChar* VG_(args_the_exename);
+
+
+#endif // __PUB_TOOL_CLIENTSTATE_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_libcbase.h b/include/pub_tool_libcbase.h
index d1f7f5c1d..cc1a55e37 100644
--- a/include/pub_tool_libcbase.h
+++ b/include/pub_tool_libcbase.h
@@ -114,10 +114,10 @@ extern void VG_(ssort)( void* base, SizeT nmemb, SizeT size,
/* Returns the base-2 logarithm of x. */
extern Int VG_(log2) ( Int x );
-// A pseudo-random number generator returning a random UInt, and its
-// seed function.
-extern void VG_(srandom) ( UInt seed );
-extern UInt VG_(random) ( void );
+// A pseudo-random number generator returning a random UInt. If pSeed
+// is NULL, it uses its own seed, which starts at zero. If pSeed is
+// non-NULL, it uses and updates whatever pSeed points at.
+extern UInt VG_(random) ( /*MOD*/UInt* pSeed );
#endif // __PUB_TOOL_LIBCBASE_H
diff --git a/include/pub_tool_libcfile.h b/include/pub_tool_libcfile.h
index 2d89c5dc9..41da4a37e 100644
--- a/include/pub_tool_libcfile.h
+++ b/include/pub_tool_libcfile.h
@@ -40,19 +40,19 @@ extern void VG_(close) ( Int fd );
extern Int VG_(read) ( Int fd, void* buf, Int count);
extern Int VG_(write) ( Int fd, const void* buf, Int count);
extern Int VG_(pipe) ( Int fd[2] );
-extern OffT VG_(lseek) ( Int fd, OffT offset, Int whence);
+extern OffT VG_(lseek) ( Int fd, OffT offset, Int whence );
extern SysRes VG_(stat) ( Char* file_name, struct vki_stat* buf );
extern Int VG_(fstat) ( Int fd, struct vki_stat* buf );
-extern Int VG_(dup2) ( Int oldfd, Int newfd );
+extern SysRes VG_(dup) ( Int oldfd );
extern Int VG_(rename) ( Char* old_name, Char* new_name );
extern Int VG_(unlink) ( Char* file_name );
// Returns False on failure (eg. if the buffer isn't big enough).
-extern Bool VG_(getcwd) ( Char* buf, SizeT size );
+extern Bool VG_(getcwd) ( Char* buf, SizeT size );
-extern Int VG_(readlink)( Char* path, Char* buf, UInt bufsize );
-extern Int VG_(getdents)( UInt fd, struct vki_dirent *dirp, UInt count );
+extern Int VG_(readlink)( Char* path, Char* buf, UInt bufsize );
+extern Int VG_(getdents)( UInt fd, struct vki_dirent *dirp, UInt count );
#endif // __PUB_TOOL_LIBCFILE_H
diff --git a/include/pub_tool_libcmman.h b/include/pub_tool_libcmman.h
deleted file mode 100644
index 75d6c672b..000000000
--- a/include/pub_tool_libcmman.h
+++ /dev/null
@@ -1,41 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- Memory management libc stuff. pub_tool_libcmman.h ---*/
-/*--------------------------------------------------------------------*/
-
-/*
- This file is part of Valgrind, a dynamic binary instrumentation
- framework.
-
- Copyright (C) 2000-2005 Julian Seward
- jseward@acm.org
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307, USA.
-
- The GNU General Public License is contained in the file COPYING.
-*/
-
-#ifndef __PUB_TOOL_LIBCMMAN_H
-#define __PUB_TOOL_LIBCMMAN_H
-
-/* Get memory by anonymous mmap. */
-extern void* VG_(get_memory_from_mmap) ( SizeT nBytes, Char* who );
-
-#endif // __PUB_TOOL_LIBCMMAN_H
-
-/*--------------------------------------------------------------------*/
-/*--- end ---*/
-/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_libcprint.h b/include/pub_tool_libcprint.h
index 9a6ce995c..7fff4590d 100644
--- a/include/pub_tool_libcprint.h
+++ b/include/pub_tool_libcprint.h
@@ -39,11 +39,17 @@
* --log-fd/--log-file/--log-socket argument, which defaults to 2 (stderr).
* Hence no need for VG_(fprintf)().
*/
-extern UInt VG_(printf) ( const HChar *format, ... );
-extern UInt VG_(vprintf) ( const HChar *format, va_list vargs );
+extern UInt VG_(printf) ( const HChar *format, ... );
+extern UInt VG_(vprintf) ( const HChar *format, va_list vargs );
/* too noisy ... __attribute__ ((format (printf, 1, 2))) ; */
-extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... );
-extern UInt VG_(vsprintf)( Char* buf, const HChar* format, va_list vargs );
+
+extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... );
+extern UInt VG_(vsprintf) ( Char* buf, const HChar* format, va_list vargs );
+
+extern UInt VG_(snprintf) ( Char* buf, Int size,
+ const HChar *format, ... );
+extern UInt VG_(vsnprintf)( Char* buf, Int size,
+ const HChar *format, va_list vargs );
// Percentify n/m with d decimal places. Includes the '%' symbol at the end.
// Right justifies in 'buf'.
diff --git a/include/pub_tool_libcproc.h b/include/pub_tool_libcproc.h
index b4e008010..d89f4fc8c 100644
--- a/include/pub_tool_libcproc.h
+++ b/include/pub_tool_libcproc.h
@@ -38,8 +38,6 @@
/* Client args and environment. Note that VG_(client_argv)[] can be written
to by the client, so you should check each entry is non-NULL before
printing. VG_(client_envp) can be inspected with VG_(getenv)(). */
-extern Int VG_(client_argc);
-extern Char** VG_(client_argv);
extern Char** VG_(client_envp);
/* Looks up VG_(client_envp) */
@@ -66,11 +64,12 @@ extern Int VG_(setrlimit) ( Int resource, const struct vki_rlimit *rlim );
pids, etc
------------------------------------------------------------------ */
-extern Int VG_(gettid) ( void );
+extern Int VG_(gettid) ( void );
extern Int VG_(getpid) ( void );
extern Int VG_(getppid) ( void );
extern Int VG_(getpgrp) ( void );
-extern Int VG_(setpgid) ( Int pid, Int pgrp );
+extern Int VG_(geteuid) ( void );
+extern Int VG_(getegid) ( void );
/* ---------------------------------------------------------------------
Timing
diff --git a/include/pub_tool_mallocfree.h b/include/pub_tool_mallocfree.h
index 1fbf9f5c0..7a36c9e20 100644
--- a/include/pub_tool_mallocfree.h
+++ b/include/pub_tool_mallocfree.h
@@ -39,6 +39,10 @@ extern void* VG_(calloc) ( SizeT n, SizeT bytes_per_elem );
extern void* VG_(realloc) ( void* p, SizeT size );
extern Char* VG_(strdup) ( const Char* s );
+// TODO: move somewhere else
+// Call here to bomb the system when out of memory (mmap anon fails)
+extern void VG_(out_of_memory_NORETURN) ( HChar* who, SizeT szB );
+
#endif // __PUB_TOOL_MALLOCFREE_H
/*--------------------------------------------------------------------*/
diff --git a/include/pub_tool_tooliface.h b/include/pub_tool_tooliface.h
index b5f74cde6..e72a0298d 100644
--- a/include/pub_tool_tooliface.h
+++ b/include/pub_tool_tooliface.h
@@ -58,19 +58,16 @@ typedef struct _ToolInfo {
- any other tool-specific initialisation
*/
void (*tl_pre_clo_init) ( void );
-
- /* Specifies how big the shadow segment should be as a ratio to the
- client address space. 0 for no shadow segment. */
- float shadow_ratio;
} ToolInfo;
+extern const ToolInfo VG_(tool_info);
+
/* Every tool must include this macro somewhere, exactly once. */
-#define VG_DETERMINE_INTERFACE_VERSION(pre_clo_init, shadow) \
+#define VG_DETERMINE_INTERFACE_VERSION(pre_clo_init) \
const ToolInfo VG_(tool_info) = { \
.sizeof_ToolInfo = sizeof(ToolInfo), \
.interface_version = VG_CORE_INTERFACE_VERSION, \
.tl_pre_clo_init = pre_clo_init, \
- .shadow_ratio = shadow, \
};
/* ------------------------------------------------------------------ */
diff --git a/include/vki-amd64-linux.h b/include/vki-amd64-linux.h
index 7eb1906f3..611c57aa1 100644
--- a/include/vki-amd64-linux.h
+++ b/include/vki-amd64-linux.h
@@ -229,6 +229,7 @@ struct vki_sigcontext {
#define VKI_O_RDONLY 00
#define VKI_O_WRONLY 01
+#define VKI_O_RDWR 02
#define VKI_O_CREAT 0100 /* not fcntl */
#define VKI_O_EXCL 0200 /* not fcntl */
#define VKI_O_TRUNC 01000 /* not fcntl */
diff --git a/include/vki-linux.h b/include/vki-linux.h
index 5d6df36c6..1cd051793 100644
--- a/include/vki-linux.h
+++ b/include/vki-linux.h
@@ -1088,8 +1088,10 @@ struct vki_seminfo {
//----------------------------------------------------------------------
#define VKI_EPERM 1 /* Operation not permitted */
+#define VKI_ENOENT 2 /* No such file or directory */
#define VKI_ESRCH 3 /* No such process */
#define VKI_EINTR 4 /* Interrupted system call */
+#define VKI_ENOEXEC 8 /* Exec format error */
#define VKI_EBADF 9 /* Bad file number */
#define VKI_EAGAIN 11 /* Try again */
#define VKI_EWOULDBLOCK VKI_EAGAIN
@@ -1162,8 +1164,20 @@ struct vki_seminfo {
#define VKI_S_ISFIFO(m) (((m) & VKI_S_IFMT) == VKI_S_IFIFO)
#define VKI_S_ISSOCK(m) (((m) & VKI_S_IFMT) == VKI_S_IFSOCK)
+#define VKI_S_IRWXU 00700
#define VKI_S_IRUSR 00400
#define VKI_S_IWUSR 00200
+#define VKI_S_IXUSR 00100
+
+#define VKI_S_IRWXG 00070
+#define VKI_S_IRGRP 00040
+#define VKI_S_IWGRP 00020
+#define VKI_S_IXGRP 00010
+
+#define VKI_S_IRWXO 00007
+#define VKI_S_IROTH 00004
+#define VKI_S_IWOTH 00002
+#define VKI_S_IXOTH 00001
//----------------------------------------------------------------------
// From linux-2.6.8.1/include/linux/dirent.h
@@ -2008,10 +2022,13 @@ typedef __vki_kernel_uid32_t vki_qid_t; /* Type in which we store ids in memory
// From linux-2.6.9/include/linux/ptrace.h
//----------------------------------------------------------------------
+#define VKI_PTRACE_TRACEME 0
#define VKI_PTRACE_PEEKTEXT 1
#define VKI_PTRACE_PEEKDATA 2
#define VKI_PTRACE_PEEKUSR 3
+#define VKI_PTRACE_DETACH 0x11
+
#endif // __VKI_LINUX_H
/*--------------------------------------------------------------------*/