Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 32966 | Differences between
and this patch

Collapse All | Expand All

(-)valgrind-2.1.0/coregrind/arch/x86-freebsd/vg_syscall.S (+195 lines)
Line 0 Link Here
1
2
##--------------------------------------------------------------------##
3
##--- Support for doing system calls.                              ---##
4
##---                                                 vg_syscall.S ---##
5
##--------------------------------------------------------------------##
6
7
/*
8
  This file is part of Valgrind, an extensible x86 protected-mode
9
  emulator for monitoring program execution on x86-Unixes.
10
11
  Copyright (C) 2000-2004 Julian Seward 
12
     jseward@acm.org
13
14
  This program is free software; you can redistribute it and/or
15
  modify it under the terms of the GNU General Public License as
16
  published by the Free Software Foundation; either version 2 of the
17
  License, or (at your option) any later version.
18
19
  This program is distributed in the hope that it will be useful, but
20
  WITHOUT ANY WARRANTY; without even the implied warranty of
21
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22
  General Public License for more details.
23
24
  You should have received a copy of the GNU General Public License
25
  along with this program; if not, write to the Free Software
26
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27
  02111-1307, USA.
28
29
  The GNU General Public License is contained in the file COPYING.
30
*/
31
32
#include "vg_constants.h"
33
#include "vg_unistd.h"
34
35
.globl	VG_(do_syscall)
36
37
/*
38
	Perform a Linux syscall with int 0x80
39
	
40
	Syscall args are passed on the stack
41
	Int VG_(do_syscall)(Int syscall_no, ...)
42
43
	This has no effect on the virtual machine; the expectation is
44
	that the syscall mechanism makes no useful changes to any
45
	register except %eax, which is returned.
46
 */
47
VG_(do_syscall):
48
	pop	%ecx
49
	pop	%eax
50
	push	%ecx
51
	int	$0x80
52
	push	%ecx
53
	jae	1f
54
	movl	$-1,%eax
55
1:
56
	ret
57
58
/*
59
	Perform a FreeBSD syscall with int 0x80, returning error flag
60
61
	Syscall args are passed on the stack
62
	Int VG_(do_syscall_err)(Int syscall_no, UInt edx, UInt* eflags, ...)
63
64
	This has no effect on the virtual machine; the expectation is
65
	that the syscall mechanism makes no useful changes to any
66
	register except %eax and %edx, which are returned.
67
 */
68
.globl	VG_(do_syscall_err)
69
VG_(do_syscall_err):
70
	movl	12(%esp),%ecx
71
	andb	$254,(%ecx)
72
	movl	(%esp),%eax
73
	movl	%eax,12(%esp)
74
	movl	4(%esp),%eax
75
	movl	8(%esp),%edx
76
	addl	$12,%esp
77
	int	$0x80
78
	jae	1f
79
	orb	$1,(%ecx)
80
1:
81
	movl	(%esp),%ecx
82
	push	%ecx
83
	push	%ecx
84
	push	%ecx
85
	ret
86
87
/*
88
	Perform a clone system call.  clone is strange because it has
89
	fork()-like return-twice semantics, so it needs special
90
	handling here.
91
92
	int VG_(clone)(int (*fn)(void *), void *child_stack, int flags, void *arg, 
93
	               0                  4                  8          12
94
		       pid_t *child_tid, pid_t *parent_tid)
95
		       16                20
96
97
 */
98
.globl VG_(clone)
99
VG_(clone):
100
	ret
101
102
/*
103
 *                8      12          16         20
104
 * rfork_thread(flags, stack_addr, start_fnc, start_arg);
105
 *
106
 * flags:		Flags to rfork system call.  See rfork(2).
107
 * stack_addr:		Top of stack for thread.
108
 * start_fnc:		Address of thread function to call in child.
109
 * start_arg:		Argument to pass to the thread function in child.
110
 */
111
112
.globl VG_(rfork_thread)
113
VG_(rfork_thread):
114
	pushl	%ebp
115
	movl	%esp, %ebp
116
	pushl	%esi
117
118
	/*
119
	 * Push thread info onto the new thread's stack
120
	 */
121
	movl	12(%ebp), %esi	# get stack addr
122
123
	subl	$4, %esi
124
	movl	20(%ebp), %eax	# get start argument
125
	movl	%eax, (%esi)
126
127
	subl	$4, %esi
128
	movl	16(%ebp), %eax	# get start thread address
129
	movl	%eax, (%esi)
130
131
	/*
132
	 * Prepare and execute the thread creation syscall
133
	 */
134
	pushl	8(%ebp)
135
	pushl	$0
136
	movl	$__NR_rfork, %eax
137
	int	$0x80
138
	jb 	2f
139
140
	/*
141
	 * Check to see if we are in the parent or child
142
	 */
143
	cmpl	$0, %edx
144
	jnz	1f
145
	addl	$8, %esp
146
	popl	%esi
147
	movl	%ebp, %esp
148
	popl	%ebp
149
	ret
150
	.p2align 2
151
152
	/*
153
	 * If we are in the child (new thread), then
154
	 * set-up the call to the internal subroutine.  If it
155
	 * returns, then call __exit.
156
	 */
157
1:
158
	movl	%esi,%esp
159
	popl	%eax
160
	call	*%eax
161
	addl	$4, %esp
162
163
	/*
164
	 * Exit system call
165
	 */
166
	pushl	%eax
167
	pushl	$0
168
	movl	$__NR_exit, %eax
169
	int	$0x80
170
171
	/*
172
	 * Branch here if the thread creation fails:
173
	 */
174
2:
175
	movl	$-1,%eax
176
	ret
177
	
178
.globl VG_(pipe)
179
VG_(pipe):
180
	mov	$__NR_pipe,%eax
181
	int	$0x80
182
	jb	1f
183
	movl	4(%esp),%ecx
184
	movl	%eax,(%ecx)
185
	movl	%edx,4(%ecx)
186
	movl	$0,%eax
187
	ret
188
1:
189
	negl	%eax
190
	ret
191
192
193
##--------------------------------------------------------------------##
194
##--- end                                             vg_syscall.S ---##
195
##--------------------------------------------------------------------##
(-)valgrind-2.1.0/coregrind/arch/x86-linux/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/coregrind/arch/x86-linux/CVS/Entries (+6 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Sat Jan  3 15:21:14 2004//
2
/Makefile.am/1.1/Sat Jan  3 15:21:14 2004//
3
/vg_libpthread.c/1.143/Sun Jan  4 16:43:21 2004//
4
/vg_libpthread_unimp.c/1.43/Sun Jan  4 16:43:21 2004//
5
/vg_syscall.S/1.11/Sun Jan  4 16:43:21 2004//
6
D
(-)valgrind-2.1.0/coregrind/arch/x86-linux/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/coregrind/arch/x86-linux
(-)valgrind-2.1.0/coregrind/arch/x86-linux/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/coregrind/arch/x86-linux/Makefile.am (+2 lines)
Line 0 Link Here
1
2
(-)valgrind-2.1.0/coregrind/arch/x86-linux/Makefile.in (+297 lines)
Line 0 Link Here
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
3
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
9
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
12
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
# PARTICULAR PURPOSE.
14
15
@SET_MAKE@
16
srcdir = @srcdir@
17
top_srcdir = @top_srcdir@
18
VPATH = @srcdir@
19
pkgdatadir = $(datadir)/@PACKAGE@
20
pkglibdir = $(libdir)/@PACKAGE@
21
pkgincludedir = $(includedir)/@PACKAGE@
22
top_builddir = ../../..
23
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24
INSTALL = @INSTALL@
25
install_sh_DATA = $(install_sh) -c -m 644
26
install_sh_PROGRAM = $(install_sh) -c
27
install_sh_SCRIPT = $(install_sh) -c
28
INSTALL_HEADER = $(INSTALL_DATA)
29
transform = $(program_transform_name)
30
NORMAL_INSTALL = :
31
PRE_INSTALL = :
32
POST_INSTALL = :
33
NORMAL_UNINSTALL = :
34
PRE_UNINSTALL = :
35
POST_UNINSTALL = :
36
host_triplet = @host@
37
subdir = coregrind/arch/x86-linux
38
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
39
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
40
am__aclocal_m4_deps = $(top_srcdir)/configure.in
41
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
42
	$(ACLOCAL_M4)
43
mkinstalldirs = $(mkdir_p)
44
CONFIG_HEADER = $(top_builddir)/config.h
45
CONFIG_CLEAN_FILES =
46
SOURCES =
47
DIST_SOURCES =
48
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
49
ACLOCAL = @ACLOCAL@
50
AMDEP_FALSE = @AMDEP_FALSE@
51
AMDEP_TRUE = @AMDEP_TRUE@
52
AMTAR = @AMTAR@
53
AUTOCONF = @AUTOCONF@
54
AUTOHEADER = @AUTOHEADER@
55
AUTOMAKE = @AUTOMAKE@
56
AWK = @AWK@
57
CC = @CC@
58
CCAS = @CCAS@
59
CCASFLAGS = @CCASFLAGS@
60
CCDEPMODE = @CCDEPMODE@
61
CFLAGS = @CFLAGS@
62
CPP = @CPP@
63
CPPFLAGS = @CPPFLAGS@
64
CXX = @CXX@
65
CXXDEPMODE = @CXXDEPMODE@
66
CXXFLAGS = @CXXFLAGS@
67
CYGPATH_W = @CYGPATH_W@
68
DEFAULT_SUPP = @DEFAULT_SUPP@
69
DEFS = @DEFS@
70
DEPDIR = @DEPDIR@
71
ECHO_C = @ECHO_C@
72
ECHO_N = @ECHO_N@
73
ECHO_T = @ECHO_T@
74
EGREP = @EGREP@
75
EXEEXT = @EXEEXT@
76
GDB = @GDB@
77
INSTALL_DATA = @INSTALL_DATA@
78
INSTALL_PROGRAM = @INSTALL_PROGRAM@
79
INSTALL_SCRIPT = @INSTALL_SCRIPT@
80
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
81
LDFLAGS = @LDFLAGS@
82
LIBOBJS = @LIBOBJS@
83
LIBS = @LIBS@
84
LN_S = @LN_S@
85
LTLIBOBJS = @LTLIBOBJS@
86
MAINT = @MAINT@
87
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
88
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
89
MAKEINFO = @MAKEINFO@
90
OBJEXT = @OBJEXT@
91
PACKAGE = @PACKAGE@
92
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
93
PACKAGE_NAME = @PACKAGE_NAME@
94
PACKAGE_STRING = @PACKAGE_STRING@
95
PACKAGE_TARNAME = @PACKAGE_TARNAME@
96
PACKAGE_VERSION = @PACKAGE_VERSION@
97
PATH_SEPARATOR = @PATH_SEPARATOR@
98
PERL = @PERL@
99
PREFERRED_STACK_BOUNDARY = @PREFERRED_STACK_BOUNDARY@
100
RANLIB = @RANLIB@
101
SET_MAKE = @SET_MAKE@
102
SHELL = @SHELL@
103
STRIP = @STRIP@
104
VERSION = @VERSION@
105
VG_PLATFORM = @VG_PLATFORM@
106
ac_ct_CC = @ac_ct_CC@
107
ac_ct_CXX = @ac_ct_CXX@
108
ac_ct_RANLIB = @ac_ct_RANLIB@
109
ac_ct_STRIP = @ac_ct_STRIP@
110
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
111
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
112
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
113
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
114
am__include = @am__include@
115
am__leading_dot = @am__leading_dot@
116
am__quote = @am__quote@
117
bindir = @bindir@
118
build = @build@
119
build_alias = @build_alias@
120
build_cpu = @build_cpu@
121
build_os = @build_os@
122
build_vendor = @build_vendor@
123
datadir = @datadir@
124
exec_prefix = @exec_prefix@
125
host = @host@
126
host_alias = @host_alias@
127
host_cpu = @host_cpu@
128
host_os = @host_os@
129
host_vendor = @host_vendor@
130
includedir = @includedir@
131
infodir = @infodir@
132
install_sh = @install_sh@
133
libdir = @libdir@
134
libexecdir = @libexecdir@
135
localstatedir = @localstatedir@
136
mandir = @mandir@
137
mkdir_p = @mkdir_p@
138
oldincludedir = @oldincludedir@
139
prefix = @prefix@
140
program_transform_name = @program_transform_name@
141
sbindir = @sbindir@
142
sharedstatedir = @sharedstatedir@
143
sysconfdir = @sysconfdir@
144
target_alias = @target_alias@
145
all: all-am
146
147
.SUFFIXES:
148
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
149
	@for dep in $?; do \
150
	  case '$(am__configure_deps)' in \
151
	    *$$dep*) \
152
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
153
		&& exit 0; \
154
	      exit 1;; \
155
	  esac; \
156
	done; \
157
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  coregrind/arch/x86-linux/Makefile'; \
158
	cd $(top_srcdir) && \
159
	  $(AUTOMAKE) --gnu  coregrind/arch/x86-linux/Makefile
160
.PRECIOUS: Makefile
161
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
162
	@case '$?' in \
163
	  *config.status*) \
164
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
165
	  *) \
166
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
167
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
168
	esac;
169
170
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
171
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
172
173
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
174
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
175
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
176
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
177
uninstall-info-am:
178
tags: TAGS
179
TAGS:
180
181
ctags: CTAGS
182
CTAGS:
183
184
185
distdir: $(DISTFILES)
186
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
187
	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
188
	list='$(DISTFILES)'; for file in $$list; do \
189
	  case $$file in \
190
	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
191
	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
192
	  esac; \
193
	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
194
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
195
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
196
	    dir="/$$dir"; \
197
	    $(mkdir_p) "$(distdir)$$dir"; \
198
	  else \
199
	    dir=''; \
200
	  fi; \
201
	  if test -d $$d/$$file; then \
202
	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
203
	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
204
	    fi; \
205
	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
206
	  else \
207
	    test -f $(distdir)/$$file \
208
	    || cp -p $$d/$$file $(distdir)/$$file \
209
	    || exit 1; \
210
	  fi; \
211
	done
212
check-am: all-am
213
check: check-am
214
all-am: Makefile
215
installdirs:
216
install: install-am
217
install-exec: install-exec-am
218
install-data: install-data-am
219
uninstall: uninstall-am
220
221
install-am: all-am
222
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
223
224
installcheck: installcheck-am
225
install-strip:
226
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
227
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
228
	  `test -z '$(STRIP)' || \
229
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
230
mostlyclean-generic:
231
232
clean-generic:
233
234
distclean-generic:
235
	-rm -f $(CONFIG_CLEAN_FILES)
236
237
maintainer-clean-generic:
238
	@echo "This command is intended for maintainers to use"
239
	@echo "it deletes files that may require special tools to rebuild."
240
clean: clean-am
241
242
clean-am: clean-generic mostlyclean-am
243
244
distclean: distclean-am
245
	-rm -f Makefile
246
distclean-am: clean-am distclean-generic
247
248
dvi: dvi-am
249
250
dvi-am:
251
252
html: html-am
253
254
info: info-am
255
256
info-am:
257
258
install-data-am:
259
260
install-exec-am:
261
262
install-info: install-info-am
263
264
install-man:
265
266
installcheck-am:
267
268
maintainer-clean: maintainer-clean-am
269
	-rm -f Makefile
270
maintainer-clean-am: distclean-am maintainer-clean-generic
271
272
mostlyclean: mostlyclean-am
273
274
mostlyclean-am: mostlyclean-generic
275
276
pdf: pdf-am
277
278
pdf-am:
279
280
ps: ps-am
281
282
ps-am:
283
284
uninstall-am: uninstall-info-am
285
286
.PHONY: all all-am check check-am clean clean-generic distclean \
287
	distclean-generic distdir dvi dvi-am html html-am info info-am \
288
	install install-am install-data install-data-am install-exec \
289
	install-exec-am install-info install-info-am install-man \
290
	install-strip installcheck installcheck-am installdirs \
291
	maintainer-clean maintainer-clean-generic mostlyclean \
292
	mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \
293
	uninstall-info-am
294
295
# Tell versions [3.59,3.63) of GNU make to not export all variables.
296
# Otherwise a system limit (for SysV at least) may be exceeded.
297
.NOEXPORT:
(-)valgrind-2.1.0/coregrind/arch/x86-linux/vg_libpthread.c (+3005 lines)
Line 0 Link Here
1
2
/*--------------------------------------------------------------------*/
3
/*--- A replacement for the standard libpthread.so.                ---*/
4
/*---                                              vg_libpthread.c ---*/
5
/*--------------------------------------------------------------------*/
6
7
/*
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
10
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
13
14
   This program is free software; you can redistribute it and/or
15
   modify it under the terms of the GNU General Public License as
16
   published by the Free Software Foundation; either version 2 of the
17
   License, or (at your option) any later version.
18
19
   This program is distributed in the hope that it will be useful, but
20
   WITHOUT ANY WARRANTY; without even the implied warranty of
21
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22
   General Public License for more details.
23
24
   You should have received a copy of the GNU General Public License
25
   along with this program; if not, write to the Free Software
26
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27
   02111-1307, USA.
28
29
   The GNU General Public License is contained in the file COPYING.
30
*/
31
32
/* ALL THIS CODE RUNS ON THE SIMULATED CPU.
33
34
   This is a replacement for the standard libpthread.so.  It is loaded
35
   as part of the client's image (if required) and directs pthread
36
   calls through to Valgrind's request mechanism. 
37
38
   A couple of caveats.
39
 
40
   1.  Since it's a binary-compatible replacement for an existing library, 
41
       we must take care to used exactly the same data layouts, etc, as 
42
       the standard pthread.so does.  
43
44
   2.  Since this runs as part of the client, there are no specific
45
       restrictions on what headers etc we can include, so long as
46
       this libpthread.so does not end up having dependencies on .so's
47
       which the real one doesn't.
48
49
   Later ... it appears we cannot call file-related stuff in libc here,
50
   perhaps fair enough.  Be careful what you call from here.  Even exit()
51
   doesn't work (gives infinite recursion and then stack overflow); hence
52
   myexit().  Also fprintf doesn't seem safe.
53
*/
54
55
#include "valgrind.h"    /* For the request-passing mechanism */
56
#include "vg_include.h"  /* For the VG_USERREQ__* constants */
57
58
#define __USE_UNIX98
59
#include <sys/types.h>
60
#include <pthread.h>
61
#undef __USE_UNIX98
62
63
#include <unistd.h>
64
#include <string.h>
65
#include <sys/time.h>
66
#include <sys/stat.h>
67
#include <sys/poll.h>
68
#include <stdio.h>
69
#include <errno.h>
70
71
#include <stdlib.h>
72
73
# define strong_alias(name, aliasname) \
74
  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
75
76
# define weak_alias(name, aliasname) \
77
  extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
78
79
80
/* ---------------------------------------------------------------------
81
   Forwardses.
82
   ------------------------------------------------------------------ */
83
84
#define WEAK	__attribute__((weak))
85
86
static
87
__inline__
88
int is_kerror ( int res )
89
{
90
   if (res >= -4095 && res <= -1)
91
      return 1;
92
   else
93
      return 0;
94
}
95
96
97
#ifdef GLIBC_2_3
98
   /* kludge by JRS (not from glibc) ... */
99
   typedef void* __locale_t;
100
101
   /* Copied from locale/locale.h in glibc-2.2.93 sources */
102
   /* This value can be passed to `uselocale' and may be returned by
103
      it.  Passing this value to any other function has undefined
104
      behavior.  */
105
#  define LC_GLOBAL_LOCALE       ((__locale_t) -1L)
106
   extern __locale_t __uselocale ( __locale_t );
107
#endif
108
109
static
110
void init_libc_tsd_keys ( void );
111
112
113
/* ---------------------------------------------------------------------
114
   Helpers.  We have to be pretty self-sufficient.
115
   ------------------------------------------------------------------ */
116
117
/* Number of times any given error message is printed. */
118
#define N_MOANS 3
119
120
/* Extract from Valgrind the value of VG_(clo_trace_pthread_level).
121
   Returns 0 (none) if not running on Valgrind. */
122
static
123
int get_pt_trace_level ( void )
124
{
125
   int res;
126
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
127
                           VG_USERREQ__GET_PTHREAD_TRACE_LEVEL,
128
                           0, 0, 0, 0);
129
   return res;
130
}
131
132
/* Don't do anything if we're not under Valgrind */
133
static __inline__
134
void ensure_valgrind ( char* caller )
135
{
136
   if (!RUNNING_ON_VALGRIND) {
137
      const char msg[] = "Warning: this libpthread.so should only be run with Valgrind\n";
138
      VG_(do_syscall)(__NR_write, 2, msg, sizeof(msg)-1);
139
      VG_(do_syscall)(__NR_exit, 1);
140
   }
141
}
142
143
/* While we're at it ... hook our own startup function into this
144
   game. */
145
146
static
147
__attribute__((noreturn))
148
void barf ( const char* str )
149
{
150
   char buf[1000];
151
   strcpy(buf, "\nvalgrind's libpthread.so: ");
152
   strcat(buf, str);
153
   strcat(buf, "\nPlease report this bug at: ");
154
   strcat(buf, VG_BUGS_TO);
155
   strcat(buf, "\n\n");
156
   VALGRIND_INTERNAL_PRINTF(buf);
157
   _exit(1);
158
   /* We have to persuade gcc into believing this doesn't return. */
159
   while (1) { };
160
}
161
162
163
static void cat_n_send ( char* s1, char* s2, char* s3 )
164
{
165
   char  buf[1000];
166
   if (get_pt_trace_level() >= 0) {
167
      snprintf(buf, sizeof(buf), "%s%s%s", s1, s2, s3);
168
      buf[sizeof(buf)-1] = '\0';
169
      VALGRIND_INTERNAL_PRINTF(buf);
170
   }
171
}
172
173
static void oh_dear ( char* fn, char* aux, char* s )
174
{
175
   cat_n_send    ( "warning: Valgrind's ", fn, s );
176
   if (NULL != aux)
177
      cat_n_send ( "         ", aux, "" );
178
   cat_n_send    ( "         your program may misbehave as a result", "", "" );
179
}
180
181
static void ignored ( char* fn, char* aux )
182
{
183
   oh_dear ( fn, aux, " does nothing" );
184
}
185
186
static void kludged ( char* fn, char* aux )
187
{
188
   oh_dear ( fn, aux, " is incomplete" );
189
}
190
191
192
__attribute__((noreturn))
193
void vgPlain_unimp ( char* fn )
194
{
195
   cat_n_send ( "valgrind's libpthread.so: UNIMPLEMENTED FUNCTION: ", fn, "" );
196
   barf("unimplemented function");
197
}
198
199
200
static
201
void my_assert_fail ( const Char* expr, const Char* file, Int line, const Char* fn )
202
{
203
   char buf[1000];
204
   static Bool entered = False;
205
   if (entered) 
206
      _exit(2);
207
   entered = True;
208
   sprintf(buf, "\n%s: %s:%d (%s): Assertion `%s' failed.\n",
209
                "valgrind", file, line, fn, expr );
210
   cat_n_send ( "", buf, "" );
211
   sprintf(buf, "Please report this bug at: %s\n\n", VG_BUGS_TO);
212
   cat_n_send ( "", buf, "" );
213
   _exit(1);
214
}
215
216
#define MY__STRING(__str)  #__str
217
218
#define my_assert(expr)                                               \
219
  ((void) ((expr) ? 0 :						      \
220
	   (my_assert_fail  (MY__STRING(expr),			      \
221
			      __FILE__, __LINE__,                     \
222
                              __PRETTY_FUNCTION__), 0)))
223
224
static
225
void my_free ( void* ptr )
226
{
227
#if 0
228
   int res;
229
   VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
230
                           VG_USERREQ__FREE, ptr, 0, 0, 0);
231
   my_assert(res == 0);
232
#else
233
   free(ptr);
234
#endif
235
}
236
237
238
static
239
void* my_malloc ( int nbytes )
240
{
241
   void* res;
242
#if 0
243
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
244
                           VG_USERREQ__MALLOC, nbytes, 0, 0, 0);
245
#else
246
   res = malloc(nbytes);
247
#endif
248
   my_assert(res != (void*)0);
249
   return res;
250
}
251
252
253
254
/* ---------------------------------------------------------------------
255
   Pass pthread_ calls to Valgrind's request mechanism.
256
   ------------------------------------------------------------------ */
257
258
259
/* ---------------------------------------------------
260
   Ummm ..
261
   ------------------------------------------------ */
262
263
static
264
void pthread_error ( const char* msg )
265
{
266
   int res;
267
   VALGRIND_MAGIC_SEQUENCE(res, 0,
268
                           VG_USERREQ__PTHREAD_ERROR, 
269
                           msg, 0, 0, 0);
270
}
271
272
273
/* ---------------------------------------------------
274
   Here so it can be inlined without complaint.
275
   ------------------------------------------------ */
276
277
__inline__
278
pthread_t pthread_self(void)
279
{
280
   int tid;
281
   ensure_valgrind("pthread_self");
282
   VALGRIND_MAGIC_SEQUENCE(tid, 0 /* default */,
283
                           VG_USERREQ__PTHREAD_GET_THREADID,
284
                           0, 0, 0, 0);
285
   if (tid < 1 || tid >= VG_N_THREADS)
286
      barf("pthread_self: invalid ThreadId");
287
   return tid;
288
}
289
290
291
/* ---------------------------------------------------
292
   THREAD ATTRIBUTES
293
   ------------------------------------------------ */
294
295
int pthread_attr_init(pthread_attr_t *attr)
296
{
297
   /* Just initialise the fields which we might look at. */
298
   attr->__detachstate = PTHREAD_CREATE_JOINABLE;
299
   /* Linuxthreads sets this field to the value __getpagesize(), so I
300
      guess the following is OK. */
301
   attr->__guardsize = VKI_BYTES_PER_PAGE;   return 0;
302
}
303
304
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
305
{
306
   if (detachstate != PTHREAD_CREATE_JOINABLE 
307
       && detachstate != PTHREAD_CREATE_DETACHED) {
308
      pthread_error("pthread_attr_setdetachstate: "
309
                    "detachstate is invalid");
310
      return EINVAL;
311
   }
312
   attr->__detachstate = detachstate;
313
   return 0;
314
}
315
316
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
317
{
318
   *detachstate = attr->__detachstate;
319
   return 0;
320
}
321
322
int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit)
323
{
324
   static int moans = N_MOANS;
325
   if (moans-- > 0) 
326
      ignored("pthread_attr_setinheritsched", NULL);
327
   return 0;
328
}
329
330
WEAK
331
int pthread_attr_setstacksize (pthread_attr_t *__attr,
332
                               size_t __stacksize)
333
{
334
   size_t limit;
335
   char buf[1024];
336
   ensure_valgrind("pthread_attr_setstacksize");
337
   limit = VG_PTHREAD_STACK_SIZE - VG_AR_CLIENT_STACKBASE_REDZONE_SZB 
338
                                 - 1000; /* paranoia */
339
   if (__stacksize < limit)
340
      return 0;
341
   snprintf(buf, sizeof(buf), "pthread_attr_setstacksize: "
342
            "requested size %d >= VG_PTHREAD_STACK_SIZE\n   "
343
            "edit vg_include.h and rebuild.", __stacksize);
344
   buf[sizeof(buf)-1] = '\0'; /* Make sure it is zero terminated */
345
   barf(buf);
346
}
347
348
349
/* This is completely bogus. */
350
int  pthread_attr_getschedparam(const  pthread_attr_t  *attr,  
351
                                struct sched_param *param)
352
{
353
   static int moans = N_MOANS;
354
   if (moans-- > 0) 
355
      kludged("pthread_attr_getschedparam", NULL);
356
#  ifdef HAVE_SCHED_PRIORITY
357
   if (param) param->sched_priority = 0; /* who knows */
358
#  else
359
   if (param) param->__sched_priority = 0; /* who knows */
360
#  endif
361
   return 0;
362
}
363
364
int  pthread_attr_setschedparam(pthread_attr_t  *attr,
365
                                const  struct sched_param *param)
366
{
367
   static int moans = N_MOANS;
368
   if (moans-- > 0) 
369
      ignored("pthread_attr_setschedparam", "(scheduling not changeable)");
370
   return 0;
371
}
372
373
int pthread_attr_destroy(pthread_attr_t *attr)
374
{
375
   static int moans = N_MOANS;
376
   if (moans-- > 0) 
377
      ignored("pthread_attr_destroy", NULL);
378
   return 0;
379
}
380
381
/* These are no-ops, as with LinuxThreads. */
382
int pthread_attr_setscope ( pthread_attr_t *attr, int scope )
383
{
384
   ensure_valgrind("pthread_attr_setscope");
385
   if (scope == PTHREAD_SCOPE_SYSTEM)
386
      return 0;
387
   pthread_error("pthread_attr_setscope: "
388
                 "invalid or unsupported scope");
389
   if (scope == PTHREAD_SCOPE_PROCESS)
390
      return ENOTSUP;
391
   return EINVAL;
392
}
393
394
int pthread_attr_getscope ( const pthread_attr_t *attr, int *scope )
395
{
396
   ensure_valgrind("pthread_attr_setscope");
397
   if (scope)
398
      *scope = PTHREAD_SCOPE_SYSTEM;
399
   return 0;
400
}
401
402
403
/* Pretty bogus.  Avoid if possible. */
404
int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
405
{
406
   int    detached;
407
   size_t limit;
408
   ensure_valgrind("pthread_getattr_np");
409
   kludged("pthread_getattr_np", NULL);
410
   limit = VG_PTHREAD_STACK_SIZE - VG_AR_CLIENT_STACKBASE_REDZONE_SZB 
411
                                 - 1000; /* paranoia */
412
   attr->__detachstate = PTHREAD_CREATE_JOINABLE;
413
   attr->__schedpolicy = SCHED_OTHER;
414
   attr->__schedparam.sched_priority = 0;
415
   attr->__inheritsched = PTHREAD_EXPLICIT_SCHED;
416
   attr->__scope = PTHREAD_SCOPE_SYSTEM;
417
   attr->__guardsize = VKI_BYTES_PER_PAGE;
418
   attr->__stackaddr = NULL;
419
   attr->__stackaddr_set = 0;
420
   attr->__stacksize = limit;
421
   VALGRIND_MAGIC_SEQUENCE(detached, (-1) /* default */,
422
                           VG_USERREQ__SET_OR_GET_DETACH, 
423
                           2 /* get */, thread, 0, 0);
424
   my_assert(detached == 0 || detached == 1);
425
   if (detached)
426
      attr->__detachstate = PTHREAD_CREATE_DETACHED;
427
   return 0;
428
}
429
430
431
/* Bogus ... */
432
WEAK
433
int pthread_attr_getstackaddr ( const pthread_attr_t * attr,
434
                                void ** stackaddr )
435
{
436
   ensure_valgrind("pthread_attr_getstackaddr");
437
   kludged("pthread_attr_getstackaddr", "(it always sets stackaddr to zero)");
438
   if (stackaddr)
439
      *stackaddr = NULL;
440
   return 0;
441
}
442
443
/* Not bogus (!) */
444
WEAK
445
int pthread_attr_getstacksize ( const pthread_attr_t * _attr, 
446
                                size_t * __stacksize )
447
{
448
   size_t limit;
449
   ensure_valgrind("pthread_attr_getstacksize");
450
   limit = VG_PTHREAD_STACK_SIZE - VG_AR_CLIENT_STACKBASE_REDZONE_SZB 
451
                                 - 1000; /* paranoia */
452
   if (__stacksize)
453
      *__stacksize = limit;
454
   return 0;
455
}
456
457
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
458
{
459
  if (policy != SCHED_OTHER && policy != SCHED_FIFO && policy != SCHED_RR)
460
    return EINVAL;
461
  attr->__schedpolicy = policy;
462
  return 0;
463
}
464
465
int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy)
466
{
467
  *policy = attr->__schedpolicy;
468
  return 0;
469
}
470
471
472
/* This is completely bogus.  We reject all attempts to change it from
473
   VKI_BYTES_PER_PAGE.  I don't have a clue what it's for so it seems
474
   safest to be paranoid. */
475
WEAK 
476
int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
477
{
478
   static int moans = N_MOANS;
479
480
   if (guardsize == VKI_BYTES_PER_PAGE)
481
      return 0;
482
483
   if (moans-- > 0) 
484
       ignored("pthread_attr_setguardsize",
485
               "(it ignores any guardsize != 4096)");
486
487
   return 0;
488
}
489
490
/* A straight copy of the LinuxThreads code. */
491
WEAK 
492
int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize)
493
{
494
   *guardsize = attr->__guardsize;
495
   return 0;
496
}  
497
498
/* Again, like LinuxThreads. */
499
500
static int concurrency_current_level = 0;
501
502
WEAK 
503
int pthread_setconcurrency(int new_level)
504
{
505
   if (new_level < 0)
506
      return EINVAL;
507
   else {
508
      concurrency_current_level = new_level;
509
      return 0;
510
   }
511
}
512
513
WEAK 
514
int pthread_getconcurrency(void)
515
{
516
   return concurrency_current_level;
517
}
518
519
520
521
/* --------------------------------------------------- 
522
   Helper functions for running a thread 
523
   and for clearing up afterwards.
524
   ------------------------------------------------ */
525
526
/* All exiting threads eventually pass through here, bearing the
527
   return value, or PTHREAD_CANCELED, in ret_val. */
528
static
529
__attribute__((noreturn))
530
void thread_exit_wrapper ( void* ret_val )
531
{
532
   int           detached, res;
533
   CleanupEntry  cu;
534
   pthread_key_t key;
535
   void**        specifics_ptr;
536
537
   /* Run this thread's cleanup handlers. */
538
   while (1) {
539
      VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
540
                              VG_USERREQ__CLEANUP_POP,
541
                              &cu, 0, 0, 0);
542
      if (res == -1) break; /* stack empty */
543
      my_assert(res == 0);
544
      if (0) printf("running exit cleanup handler");
545
      cu.fn ( cu.arg );
546
   }
547
548
   /* Run this thread's key finalizers.  Really this should be run
549
      PTHREAD_DESTRUCTOR_ITERATIONS times. */
550
   for (key = 0; key < VG_N_THREAD_KEYS; key++) {
551
      VALGRIND_MAGIC_SEQUENCE(res, (-2) /* default */,
552
                              VG_USERREQ__GET_KEY_D_AND_S,
553
                              key, &cu, 0, 0 );
554
      if (res == 0) {
555
         /* valid key */
556
         if (cu.fn && cu.arg)
557
            cu.fn /* destructor for key */ 
558
                  ( cu.arg /* specific for key for this thread */ );
559
         continue;
560
      }
561
      my_assert(res == -1);
562
   }
563
564
   /* Free up my specifics space, if any. */
565
   VALGRIND_MAGIC_SEQUENCE(specifics_ptr, 3 /* default */,
566
                           VG_USERREQ__PTHREAD_GETSPECIFIC_PTR,
567
                           pthread_self(), 0, 0, 0);
568
   my_assert(specifics_ptr != (void**)3);
569
   my_assert(specifics_ptr != (void**)1); /* 1 means invalid thread */
570
   if (specifics_ptr != NULL)
571
      my_free(specifics_ptr);
572
573
   /* Decide on my final disposition. */
574
   VALGRIND_MAGIC_SEQUENCE(detached, (-1) /* default */,
575
                           VG_USERREQ__SET_OR_GET_DETACH, 
576
                           2 /* get */, pthread_self(), 0, 0);
577
   my_assert(detached == 0 || detached == 1);
578
579
   if (detached) {
580
      /* Detached; I just quit right now. */
581
      VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
582
                              VG_USERREQ__QUIT, 0, 0, 0, 0);
583
   } else {
584
      /* Not detached; so I wait for a joiner. */
585
      VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
586
                              VG_USERREQ__WAIT_JOINER, ret_val, 0, 0, 0);
587
   }
588
   /* NOTREACHED */
589
   barf("thread_exit_wrapper: still alive?!");
590
}
591
592
593
/* This function is a wrapper function for running a thread.  It runs
594
   the root function specified in pthread_create, and then, should the
595
   root function return a value, it arranges to run the thread's
596
   cleanup handlers and exit correctly. */
597
598
/* Struct used to convey info from pthread_create to thread_wrapper.
599
   Must be careful not to pass to the child thread any pointers to
600
   objects which might be on the parent's stack.  */
601
typedef
602
   struct {
603
      int   attr__detachstate;
604
      void* (*root_fn) ( void* );
605
      void* arg;
606
   }
607
   NewThreadInfo;
608
609
610
/* This is passed to the VG_USERREQ__APPLY_IN_NEW_THREAD and so must
611
   not return.  Note that this runs in the new thread, not the
612
   parent. */
613
static
614
__attribute__((noreturn))
615
void thread_wrapper ( NewThreadInfo* info )
616
{
617
   int   attr__detachstate;
618
   void* (*root_fn) ( void* );
619
   void* arg;
620
   void* ret_val;
621
622
   attr__detachstate = info->attr__detachstate;
623
   root_fn           = info->root_fn;
624
   arg               = info->arg;
625
626
   /* Free up the arg block that pthread_create malloced. */
627
   my_free(info);
628
629
   /* Minimally observe the attributes supplied. */
630
   if (attr__detachstate != PTHREAD_CREATE_DETACHED
631
       && attr__detachstate != PTHREAD_CREATE_JOINABLE)
632
      pthread_error("thread_wrapper: invalid attr->__detachstate");
633
   if (attr__detachstate == PTHREAD_CREATE_DETACHED)
634
      pthread_detach(pthread_self());
635
636
#  ifdef GLIBC_2_3
637
   /* Set this thread's locale to the global (default) locale.  A hack
638
      in support of glibc-2.3.  This does the biz for the all new
639
      threads; the root thread is done with a horrible hack in
640
      init_libc_tsd_keys() below.
641
   */
642
   __uselocale(LC_GLOBAL_LOCALE);
643
#  endif
644
645
   /* The root function might not return.  But if it does we simply
646
      move along to thread_exit_wrapper.  All other ways out for the
647
      thread (cancellation, or calling pthread_exit) lead there
648
      too. */
649
   ret_val = root_fn(arg);
650
   thread_exit_wrapper(ret_val);
651
   /* NOTREACHED */
652
}
653
654
655
/* ---------------------------------------------------
656
   THREADs
657
   ------------------------------------------------ */
658
659
static void __valgrind_pthread_yield ( void )
660
{
661
   int res;
662
   ensure_valgrind("pthread_yield");
663
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
664
                           VG_USERREQ__PTHREAD_YIELD, 0, 0, 0, 0);
665
}
666
667
WEAK
668
int pthread_yield ( void )
669
{
670
   __valgrind_pthread_yield();
671
   return 0;
672
}
673
674
675
int pthread_equal(pthread_t thread1, pthread_t thread2)
676
{
677
   return thread1 == thread2 ? 1 : 0;
678
}
679
680
681
/* Bundle up the args into a malloc'd block and create a new thread
682
   consisting of thread_wrapper() applied to said malloc'd block. */
683
int
684
pthread_create (pthread_t *__restrict __thredd,
685
                __const pthread_attr_t *__restrict __attr,
686
                void *(*__start_routine) (void *),
687
                void *__restrict __arg)
688
{
689
   int            tid_child;
690
   NewThreadInfo* info;
691
692
   ensure_valgrind("pthread_create");
693
694
   /* make sure the tsd keys, and hence locale info, are initialised
695
      before we get into complications making new threads. */
696
   init_libc_tsd_keys();
697
698
   /* Allocate space for the arg block.  thread_wrapper will free
699
      it. */
700
   info = my_malloc(sizeof(NewThreadInfo));
701
   my_assert(info != NULL);
702
703
   if (__attr)
704
      info->attr__detachstate = __attr->__detachstate;
705
   else 
706
      info->attr__detachstate = PTHREAD_CREATE_JOINABLE;
707
708
   info->root_fn = __start_routine;
709
   info->arg     = __arg;
710
   VALGRIND_MAGIC_SEQUENCE(tid_child, VG_INVALID_THREADID /* default */,
711
                           VG_USERREQ__APPLY_IN_NEW_THREAD,
712
                           &thread_wrapper, info, 0, 0);
713
   my_assert(tid_child != VG_INVALID_THREADID);
714
715
   if (__thredd)
716
      *__thredd = tid_child;
717
   return 0; /* success */
718
}
719
720
721
int 
722
pthread_join (pthread_t __th, void **__thread_return)
723
{
724
   int res;
725
   ensure_valgrind("pthread_join");
726
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
727
                           VG_USERREQ__PTHREAD_JOIN,
728
                           __th, __thread_return, 0, 0);
729
   return res;
730
}
731
732
733
void pthread_exit(void *retval)
734
{
735
   ensure_valgrind("pthread_exit");
736
   /* Simple! */
737
   thread_exit_wrapper(retval);
738
}
739
740
741
int pthread_detach(pthread_t th)
742
{
743
   int res;
744
   ensure_valgrind("pthread_detach");
745
   /* First we enquire as to the current detach state. */
746
   VALGRIND_MAGIC_SEQUENCE(res, (-2) /* default */,
747
                           VG_USERREQ__SET_OR_GET_DETACH,
748
                           2 /* get */, th, 0, 0);
749
   if (res == -1) {
750
      /* not found */ 
751
      pthread_error("pthread_detach: "
752
                    "invalid target thread");
753
      return ESRCH;
754
   }
755
   if (res == 1) { 
756
      /* already detached */
757
      pthread_error("pthread_detach: "
758
                    "target thread is already detached");
759
      return EINVAL;
760
   }
761
   if (res == 0) {
762
      VALGRIND_MAGIC_SEQUENCE(res, (-2) /* default */,
763
                              VG_USERREQ__SET_OR_GET_DETACH,
764
                              1 /* set */, th, 0, 0);
765
      my_assert(res == 0);
766
      return 0;
767
   }
768
   barf("pthread_detach");
769
}
770
771
772
/* ---------------------------------------------------
773
   CLEANUP STACKS
774
   ------------------------------------------------ */
775
776
void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
777
                            void (*__routine) (void *),
778
                            void *__arg)
779
{
780
   int          res;
781
   CleanupEntry cu;
782
   ensure_valgrind("_pthread_cleanup_push");
783
   cu.fn  = __routine;
784
   cu.arg = __arg;
785
   VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
786
                           VG_USERREQ__CLEANUP_PUSH,
787
                           &cu, 0, 0, 0);
788
   my_assert(res == 0);
789
}
790
791
792
void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffer,
793
                                  void (*__routine) (void *),
794
                                  void *__arg)
795
{
796
   /* As _pthread_cleanup_push, but first save the thread's original
797
      cancellation type in __buffer and set it to Deferred. */
798
   int orig_ctype;
799
   ensure_valgrind("_pthread_cleanup_push_defer");
800
   /* Set to Deferred, and put the old cancellation type in res. */
801
   my_assert(-1 != PTHREAD_CANCEL_DEFERRED);
802
   my_assert(-1 != PTHREAD_CANCEL_ASYNCHRONOUS);
803
   my_assert(sizeof(struct _pthread_cleanup_buffer) >= sizeof(int));
804
   VALGRIND_MAGIC_SEQUENCE(orig_ctype, (-1) /* default */,
805
                           VG_USERREQ__SET_CANCELTYPE,
806
                           PTHREAD_CANCEL_DEFERRED, 0, 0, 0);   
807
   my_assert(orig_ctype != -1);
808
   *((int*)(__buffer)) = orig_ctype;
809
   /* Now push the cleanup. */
810
   _pthread_cleanup_push(NULL, __routine, __arg);
811
}
812
813
814
void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
815
                           int __execute)
816
{
817
   int          res;
818
   CleanupEntry cu;
819
   ensure_valgrind("_pthread_cleanup_push");
820
   cu.fn = cu.arg = NULL; /* paranoia */
821
   VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
822
                           VG_USERREQ__CLEANUP_POP,
823
                           &cu, 0, 0, 0);
824
   if (res == 0) {
825
      /* pop succeeded */
826
     if (__execute) {
827
        cu.fn ( cu.arg );
828
     }
829
     return;
830
   }   
831
   if (res == -1) {
832
      /* stack underflow */
833
      return;
834
   }
835
   barf("_pthread_cleanup_pop");
836
}
837
838
839
void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *__buffer,
840
                                   int __execute)
841
{
842
   int orig_ctype, fake_ctype;
843
   /* As _pthread_cleanup_pop, but after popping/running the handler,
844
      restore the thread's original cancellation type from the first
845
      word of __buffer. */
846
   _pthread_cleanup_pop(NULL, __execute);
847
   orig_ctype = *((int*)(__buffer));
848
   my_assert(orig_ctype == PTHREAD_CANCEL_DEFERRED
849
          || orig_ctype == PTHREAD_CANCEL_ASYNCHRONOUS);
850
   my_assert(-1 != PTHREAD_CANCEL_DEFERRED);
851
   my_assert(-1 != PTHREAD_CANCEL_ASYNCHRONOUS);
852
   my_assert(sizeof(struct _pthread_cleanup_buffer) >= sizeof(int));
853
   VALGRIND_MAGIC_SEQUENCE(fake_ctype, (-1) /* default */,
854
                           VG_USERREQ__SET_CANCELTYPE,
855
                           orig_ctype, 0, 0, 0); 
856
   my_assert(fake_ctype == PTHREAD_CANCEL_DEFERRED);
857
}
858
859
860
/* ---------------------------------------------------
861
   MUTEX ATTRIBUTES
862
   ------------------------------------------------ */
863
864
int __pthread_mutexattr_init(pthread_mutexattr_t *attr)
865
{
866
   attr->__mutexkind = PTHREAD_MUTEX_ERRORCHECK_NP;
867
   return 0;
868
}
869
870
int __pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
871
{
872
   switch (type) {
873
#     ifndef GLIBC_2_1    
874
      case PTHREAD_MUTEX_TIMED_NP:
875
      case PTHREAD_MUTEX_ADAPTIVE_NP:
876
#     endif
877
#     ifdef GLIBC_2_1    
878
      case PTHREAD_MUTEX_FAST_NP:
879
#     endif
880
      case PTHREAD_MUTEX_RECURSIVE_NP:
881
      case PTHREAD_MUTEX_ERRORCHECK_NP:
882
         attr->__mutexkind = type;
883
         return 0;
884
      default:
885
         pthread_error("pthread_mutexattr_settype: "
886
                       "invalid type");
887
         return EINVAL;
888
   }
889
}
890
891
int __pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
892
{
893
   return 0;
894
}
895
896
int __pthread_mutexattr_setpshared ( pthread_mutexattr_t* attr, int pshared)
897
{
898
  if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
899
    return EINVAL;
900
901
  /* For now it is not possible to shared a conditional variable.  */
902
  if (pshared != PTHREAD_PROCESS_PRIVATE)
903
    return ENOSYS;
904
905
  return 0;
906
}
907
908
909
/* ---------------------------------------------------
910
   MUTEXes
911
   ------------------------------------------------ */
912
913
int __pthread_mutex_init(pthread_mutex_t *mutex, 
914
                         const  pthread_mutexattr_t *mutexattr)
915
{
916
   mutex->__m_count = 0;
917
   mutex->__m_owner = (_pthread_descr)VG_INVALID_THREADID;
918
   mutex->__m_kind  = PTHREAD_MUTEX_ERRORCHECK_NP;
919
   if (mutexattr)
920
      mutex->__m_kind = mutexattr->__mutexkind;
921
   return 0;
922
}
923
924
925
int __pthread_mutex_lock(pthread_mutex_t *mutex)
926
{
927
   int res;
928
929
   if (RUNNING_ON_VALGRIND) {
930
      VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
931
                              VG_USERREQ__PTHREAD_MUTEX_LOCK,
932
                              mutex, 0, 0, 0);
933
      return res;
934
   } else {
935
      /* Play at locking */
936
      if (0)
937
	 kludged("prehistoric lock", NULL);
938
      mutex->__m_owner = (_pthread_descr)1;
939
      mutex->__m_count = 1;
940
      mutex->__m_kind |= VG_PTHREAD_PREHISTORY;
941
      return 0; /* success */
942
   }
943
}
944
945
946
int __pthread_mutex_trylock(pthread_mutex_t *mutex)
947
{
948
   int res;
949
950
   if (RUNNING_ON_VALGRIND) {
951
      VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
952
                              VG_USERREQ__PTHREAD_MUTEX_TRYLOCK,
953
                              mutex, 0, 0, 0);
954
      return res;
955
   } else {
956
      /* Play at locking */
957
      if (0)
958
	 kludged("prehistoric trylock", NULL);
959
      mutex->__m_owner = (_pthread_descr)1;
960
      mutex->__m_count = 1;
961
      mutex->__m_kind |= VG_PTHREAD_PREHISTORY;
962
      return 0; /* success */
963
   }
964
}
965
966
967
int __pthread_mutex_unlock(pthread_mutex_t *mutex)
968
{
969
   int res;
970
971
   if (RUNNING_ON_VALGRIND) {
972
      VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
973
                              VG_USERREQ__PTHREAD_MUTEX_UNLOCK,
974
                              mutex, 0, 0, 0);
975
      return res;
976
   } else {
977
      /* Play at locking */
978
      if (0)
979
	 kludged("prehistoric unlock", NULL);
980
      mutex->__m_owner = 0;
981
      mutex->__m_count = 0;
982
      mutex->__m_kind &= ~VG_PTHREAD_PREHISTORY;
983
      return 0; /* success */
984
   }
985
}
986
987
988
int __pthread_mutex_destroy(pthread_mutex_t *mutex)
989
{
990
   /* Valgrind doesn't hold any resources on behalf of the mutex, so no
991
      need to involve it. */
992
   if (mutex->__m_count > 0) {
993
      /* Oh, the horror.  glibc's internal use of pthreads "knows"
994
	 that destroying a lock does an implicit unlock.  Make it
995
	 explicit. */
996
      __pthread_mutex_unlock(mutex);
997
      pthread_error("pthread_mutex_destroy: "
998
		    "mutex is still in use");
999
      return EBUSY;
1000
   }
1001
   mutex->__m_count = 0;
1002
   mutex->__m_owner = (_pthread_descr)VG_INVALID_THREADID;
1003
   mutex->__m_kind  = PTHREAD_MUTEX_ERRORCHECK_NP;
1004
   return 0;
1005
}
1006
1007
1008
/* ---------------------------------------------------
1009
   CONDITION VARIABLES
1010
   ------------------------------------------------ */
1011
1012
/* LinuxThreads supports no attributes for conditions.  Hence ... */
1013
1014
int pthread_condattr_init(pthread_condattr_t *attr)
1015
{
1016
   return 0;
1017
}
1018
1019
int pthread_condattr_destroy(pthread_condattr_t *attr)
1020
{
1021
   return 0;
1022
}
1023
1024
int pthread_cond_init( pthread_cond_t *cond,
1025
		       const pthread_condattr_t *cond_attr)
1026
{
1027
   cond->__c_waiting = (_pthread_descr)VG_INVALID_THREADID;
1028
   return 0;
1029
}
1030
1031
int pthread_cond_destroy(pthread_cond_t *cond)
1032
{
1033
   /* should check that no threads are waiting on this CV */
1034
   static int moans = N_MOANS;
1035
   if (moans-- > 0) 
1036
      kludged("pthread_cond_destroy", 
1037
              "(it doesn't check if the cond is waited on)" );
1038
   return 0;
1039
}
1040
1041
/* ---------------------------------------------------
1042
   SCHEDULING
1043
   ------------------------------------------------ */
1044
1045
/* This is completely bogus. */
1046
int   pthread_getschedparam(pthread_t  target_thread,  
1047
                            int  *policy,
1048
                            struct sched_param *param)
1049
{
1050
   static int moans = N_MOANS;
1051
   if (moans-- > 0) 
1052
      kludged("pthread_getschedparam", NULL);
1053
   if (policy) *policy = SCHED_OTHER;
1054
#  ifdef HAVE_SCHED_PRIORITY
1055
   if (param) param->sched_priority = 0; /* who knows */
1056
#  else
1057
   if (param) param->__sched_priority = 0; /* who knows */
1058
#  endif
1059
   return 0;
1060
}
1061
1062
int pthread_setschedparam(pthread_t target_thread, 
1063
                          int policy, 
1064
                          const struct sched_param *param)
1065
{
1066
   static int moans = N_MOANS;
1067
   if (moans-- > 0) 
1068
      ignored("pthread_setschedparam", "(scheduling not changeable)");
1069
   return 0;
1070
}
1071
1072
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
1073
{
1074
   int res;
1075
   ensure_valgrind("pthread_cond_wait");
1076
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
1077
                           VG_USERREQ__PTHREAD_COND_WAIT,
1078
			   cond, mutex, 0, 0);
1079
   return res;
1080
}
1081
1082
int pthread_cond_timedwait ( pthread_cond_t *cond, 
1083
                             pthread_mutex_t *mutex, 
1084
                             const struct  timespec *abstime )
1085
{
1086
   int res;
1087
   unsigned int ms_now, ms_end;
1088
   struct  timeval timeval_now;
1089
   unsigned long long int ull_ms_now_after_1970;
1090
   unsigned long long int ull_ms_end_after_1970;
1091
1092
   ensure_valgrind("pthread_cond_timedwait");
1093
   VALGRIND_MAGIC_SEQUENCE(ms_now, 0xFFFFFFFF /* default */,
1094
                           VG_USERREQ__READ_MILLISECOND_TIMER,
1095
                           0, 0, 0, 0);
1096
   my_assert(ms_now != 0xFFFFFFFF);
1097
   res = gettimeofday(&timeval_now, NULL);
1098
   my_assert(res == 0);
1099
1100
   ull_ms_now_after_1970 
1101
      = 1000ULL * ((unsigned long long int)(timeval_now.tv_sec))
1102
        + ((unsigned long long int)(timeval_now.tv_usec / 1000000));
1103
   ull_ms_end_after_1970
1104
      = 1000ULL * ((unsigned long long int)(abstime->tv_sec))
1105
        + ((unsigned long long int)(abstime->tv_nsec / 1000000));
1106
   if (ull_ms_end_after_1970 < ull_ms_now_after_1970)
1107
      ull_ms_end_after_1970 = ull_ms_now_after_1970;
1108
   ms_end 
1109
      = ms_now + (unsigned int)(ull_ms_end_after_1970 - ull_ms_now_after_1970);
1110
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
1111
                           VG_USERREQ__PTHREAD_COND_TIMEDWAIT,
1112
			   cond, mutex, ms_end, 0);
1113
   return res;
1114
}
1115
1116
1117
int pthread_cond_signal(pthread_cond_t *cond)
1118
{
1119
   int res;
1120
   ensure_valgrind("pthread_cond_signal");
1121
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
1122
                           VG_USERREQ__PTHREAD_COND_SIGNAL,
1123
			   cond, 0, 0, 0);
1124
   return res;
1125
}
1126
1127
int pthread_cond_broadcast(pthread_cond_t *cond)
1128
{
1129
   int res;
1130
   ensure_valgrind("pthread_cond_broadcast");
1131
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
1132
                           VG_USERREQ__PTHREAD_COND_BROADCAST,
1133
			   cond, 0, 0, 0);
1134
   return res;
1135
}
1136
1137
1138
/* ---------------------------------------------------
1139
   CANCELLATION
1140
   ------------------------------------------------ */
1141
1142
int pthread_setcancelstate(int state, int *oldstate)
1143
{
1144
   int res;
1145
   ensure_valgrind("pthread_setcancelstate");
1146
   if (state != PTHREAD_CANCEL_ENABLE
1147
       && state != PTHREAD_CANCEL_DISABLE) {
1148
      pthread_error("pthread_setcancelstate: "
1149
                    "invalid state");
1150
      return EINVAL;
1151
   }
1152
   my_assert(-1 != PTHREAD_CANCEL_ENABLE);
1153
   my_assert(-1 != PTHREAD_CANCEL_DISABLE);
1154
   VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
1155
                           VG_USERREQ__SET_CANCELSTATE,
1156
                           state, 0, 0, 0);
1157
   my_assert(res != -1);
1158
   if (oldstate) 
1159
      *oldstate = res;
1160
   return 0;
1161
}
1162
1163
int pthread_setcanceltype(int type, int *oldtype)
1164
{
1165
   int res;
1166
   ensure_valgrind("pthread_setcanceltype");
1167
   if (type != PTHREAD_CANCEL_DEFERRED
1168
       && type != PTHREAD_CANCEL_ASYNCHRONOUS) {
1169
      pthread_error("pthread_setcanceltype: "
1170
                    "invalid type");
1171
      return EINVAL;
1172
   }
1173
   my_assert(-1 != PTHREAD_CANCEL_DEFERRED);
1174
   my_assert(-1 != PTHREAD_CANCEL_ASYNCHRONOUS);
1175
   VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
1176
                           VG_USERREQ__SET_CANCELTYPE,
1177
                           type, 0, 0, 0);
1178
   my_assert(res != -1);
1179
   if (oldtype) 
1180
      *oldtype = res;
1181
   return 0;
1182
}
1183
1184
int pthread_cancel(pthread_t thread)
1185
{
1186
   int res;
1187
   ensure_valgrind("pthread_cancel");
1188
   VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
1189
                           VG_USERREQ__SET_CANCELPEND,
1190
                           thread, &thread_exit_wrapper, 0, 0);
1191
   my_assert(res != -1);
1192
   return res;
1193
}
1194
1195
static
1196
void __my_pthread_testcancel(void)
1197
{
1198
   int res;
1199
   ensure_valgrind("__my_pthread_testcancel");
1200
   VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
1201
                           VG_USERREQ__TESTCANCEL,
1202
                           0, 0, 0, 0);
1203
   my_assert(res == 0);
1204
}
1205
1206
void pthread_testcancel ( void )
1207
{
1208
   __my_pthread_testcancel();
1209
}
1210
1211
1212
/* Not really sure what this is for.  I suspect for doing the POSIX
1213
   requirements for fork() and exec().  We do this internally anyway
1214
   whenever those syscalls are observed, so this could be superfluous,
1215
   but hey ... 
1216
*/
1217
void __pthread_kill_other_threads_np ( void )
1218
{
1219
   int res;
1220
   ensure_valgrind("__pthread_kill_other_threads_np");
1221
   VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
1222
                           VG_USERREQ__NUKE_OTHER_THREADS,
1223
                           0, 0, 0, 0);
1224
   my_assert(res == 0);
1225
}
1226
1227
1228
/* ---------------------------------------------------
1229
   SIGNALS
1230
   ------------------------------------------------ */
1231
1232
#include <signal.h>
1233
1234
int pthread_sigmask(int how, const sigset_t *newmask, 
1235
                             sigset_t *oldmask)
1236
{
1237
   int res;
1238
1239
   /* A bit subtle, because the scheduler expects newmask and oldmask
1240
      to be vki_sigset_t* rather than sigset_t*, and the two are
1241
      different.  Fortunately the first 64 bits of a sigset_t are
1242
      exactly a vki_sigset_t, so we just pass the pointers through
1243
      unmodified.  Haaaack! 
1244
1245
      Also mash the how value so that the SIG_ constants from glibc
1246
      constants to VKI_ constants, so that the former do not have to
1247
      be included into vg_scheduler.c. */
1248
1249
   ensure_valgrind("pthread_sigmask");
1250
1251
   switch (how) {
1252
      case SIG_SETMASK: how = VKI_SIG_SETMASK; break;
1253
      case SIG_BLOCK:   how = VKI_SIG_BLOCK; break;
1254
      case SIG_UNBLOCK: how = VKI_SIG_UNBLOCK; break;
1255
      default: pthread_error("pthread_sigmask: invalid how");
1256
               return EINVAL;
1257
   }
1258
1259
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
1260
                           VG_USERREQ__PTHREAD_SIGMASK,
1261
                           how, newmask, oldmask, 0);
1262
1263
   /* The scheduler tells us of any memory violations. */
1264
   return res == 0 ? 0 : EFAULT;
1265
}
1266
1267
int sigwait ( const sigset_t* set, int* sig )
1268
{
1269
   int res;
1270
   siginfo_t si;
1271
   
1272
   __my_pthread_testcancel();
1273
1274
   si.si_signo = 0;
1275
   res = sigtimedwait(set, &si, NULL);
1276
   *sig = si.si_signo;
1277
1278
   return 0;			/* always returns 0 */
1279
}
1280
1281
1282
int pthread_kill(pthread_t thread, int signo)
1283
{
1284
   int res;
1285
   ensure_valgrind("pthread_kill");
1286
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
1287
                           VG_USERREQ__PTHREAD_KILL, 
1288
                           thread, signo, 0, 0);
1289
   return res;
1290
}
1291
1292
1293
/* Copied verbatim from Linuxthreads */
1294
/* Redefine raise() to send signal to calling thread only,
1295
   as per POSIX 1003.1c */
1296
int raise (int sig)
1297
{
1298
  int retcode = pthread_kill(pthread_self(), sig);
1299
  if (retcode == 0) {
1300
    return 0;
1301
  } else {
1302
    *(__errno_location()) = retcode;
1303
    return -1;
1304
  }
1305
}
1306
1307
1308
1309
/* ---------------------------------------------------
1310
   THREAD-SPECIFICs
1311
   ------------------------------------------------ */
1312
1313
static
1314
int key_is_valid (pthread_key_t key)
1315
{
1316
   int res;
1317
   VALGRIND_MAGIC_SEQUENCE(res, 2 /* default */,
1318
                           VG_USERREQ__PTHREAD_KEY_VALIDATE,
1319
                           key, 0, 0, 0);
1320
   my_assert(res != 2);
1321
   return res;
1322
}
1323
1324
1325
/* Returns NULL if thread is invalid.  Otherwise, if the thread
1326
   already has a specifics area, return that.  Otherwise allocate it
1327
   one. */
1328
static
1329
void** get_or_allocate_specifics_ptr ( pthread_t thread )
1330
{
1331
   int    res, i;
1332
   void** specifics_ptr;
1333
   ensure_valgrind("get_or_allocate_specifics_ptr");
1334
1335
   /* Returns zero if the thread has no specific_ptr.  One if thread
1336
      is invalid.  Otherwise, the specific_ptr value.  This is
1337
      allocated with my_malloc and so is aligned and cannot be
1338
      confused with 1 or 3. */
1339
   VALGRIND_MAGIC_SEQUENCE(specifics_ptr, 3 /* default */,
1340
                           VG_USERREQ__PTHREAD_GETSPECIFIC_PTR,
1341
                           thread, 0, 0, 0);
1342
   my_assert(specifics_ptr != (void**)3);
1343
1344
   if (specifics_ptr == (void**)1) 
1345
      return NULL; /* invalid thread */
1346
1347
   if (specifics_ptr != NULL)
1348
      return specifics_ptr; /* already has a specifics ptr. */
1349
1350
   /* None yet ... allocate a new one.  Should never fail. */
1351
   specifics_ptr = my_malloc( VG_N_THREAD_KEYS * sizeof(void*) );
1352
   my_assert(specifics_ptr != NULL);
1353
1354
   VALGRIND_MAGIC_SEQUENCE(res, -1 /* default */,
1355
                           VG_USERREQ__PTHREAD_SETSPECIFIC_PTR,
1356
                           specifics_ptr, 0, 0, 0);
1357
   my_assert(res == 0);
1358
1359
   /* POSIX sez: "Upon thread creation, the value NULL shall be
1360
      associated with all defined keys in the new thread."  This
1361
      allocation is in effect a delayed allocation of the specific
1362
      data for a thread, at its first-use.  Hence we initialise it
1363
      here. */
1364
   for (i = 0; i < VG_N_THREAD_KEYS; i++) {
1365
      specifics_ptr[i] = NULL;
1366
   }
1367
1368
   return specifics_ptr;   
1369
}
1370
1371
1372
int __pthread_key_create(pthread_key_t *key,  
1373
                         void  (*destr_function)  (void *))
1374
{
1375
   void** specifics_ptr;
1376
   int    res, i;
1377
   ensure_valgrind("pthread_key_create");
1378
1379
   /* This writes *key if successful.  It should never fail. */
1380
   VALGRIND_MAGIC_SEQUENCE(res, 1 /* default */,
1381
                           VG_USERREQ__PTHREAD_KEY_CREATE,
1382
                           key, destr_function, 0, 0);
1383
   
1384
   if (res == 0) {
1385
      /* POSIX sez: "Upon key creation, the value NULL shall be
1386
	 associated with the new key in all active threads." */
1387
      for (i = 0; i < VG_N_THREADS; i++) {
1388
	 specifics_ptr = get_or_allocate_specifics_ptr(i);
1389
	 /* we get NULL if i is an invalid thread. */
1390
	 if (specifics_ptr != NULL)
1391
	    specifics_ptr[*key] = NULL;
1392
      }
1393
   }
1394
1395
   return res;
1396
}
1397
1398
int pthread_key_delete(pthread_key_t key)
1399
{
1400
   int res;
1401
   ensure_valgrind("pthread_key_delete");
1402
   if (!key_is_valid(key))
1403
      return EINVAL;
1404
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
1405
                           VG_USERREQ__PTHREAD_KEY_DELETE,
1406
                           key, 0, 0, 0);
1407
   my_assert(res == 0);
1408
   return 0;
1409
}
1410
1411
int __pthread_setspecific(pthread_key_t key, const void *pointer)
1412
{
1413
   void** specifics_ptr;
1414
   ensure_valgrind("pthread_setspecific");
1415
   
1416
   if (!key_is_valid(key))
1417
      return EINVAL;
1418
1419
   specifics_ptr = get_or_allocate_specifics_ptr(pthread_self());
1420
   specifics_ptr[key] = (void*)pointer;
1421
   return 0;
1422
}
1423
1424
void * __pthread_getspecific(pthread_key_t key)
1425
{
1426
   void** specifics_ptr;
1427
   ensure_valgrind("pthread_getspecific");
1428
1429
   if (!key_is_valid(key))
1430
      return NULL;
1431
1432
   specifics_ptr = get_or_allocate_specifics_ptr(pthread_self());
1433
   return specifics_ptr[key];
1434
}
1435
1436
1437
#ifdef GLIBC_2_3
1438
static
1439
void ** __pthread_getspecific_addr(pthread_key_t key)
1440
{
1441
   void** specifics_ptr;
1442
   ensure_valgrind("pthread_getspecific_addr");
1443
1444
   if (!key_is_valid(key))
1445
      return NULL;
1446
1447
   specifics_ptr = get_or_allocate_specifics_ptr(pthread_self());
1448
   return &(specifics_ptr[key]);
1449
}
1450
#endif
1451
1452
1453
/* ---------------------------------------------------
1454
   ONCEry
1455
   ------------------------------------------------ */
1456
1457
/* This protects reads and writes of the once_control variable
1458
   supplied.  It is never held whilst any particular initialiser is
1459
   running. */
1460
static pthread_mutex_t once_masterlock = PTHREAD_MUTEX_INITIALIZER;
1461
1462
/* Initialiser needs to be run. */
1463
#define P_ONCE_NOT_DONE  ((PTHREAD_ONCE_INIT) + 0)
1464
1465
/* Initialiser currently running. */
1466
#define P_ONCE_RUNNING   ((PTHREAD_ONCE_INIT) + 1)
1467
1468
/* Initialiser has completed. */
1469
#define P_ONCE_COMPLETED ((PTHREAD_ONCE_INIT) + 2)
1470
1471
int __pthread_once ( pthread_once_t *once_control, 
1472
                     void (*init_routine) (void) )
1473
{
1474
   int res;
1475
   int done;
1476
1477
#  define TAKE_LOCK                                   \
1478
      res = __pthread_mutex_lock(&once_masterlock);   \
1479
      my_assert(res == 0);
1480
1481
#  define RELEASE_LOCK                                \
1482
      res = __pthread_mutex_unlock(&once_masterlock); \
1483
      my_assert(res == 0);
1484
1485
   void cleanup(void *v) {
1486
      TAKE_LOCK;
1487
      *once_control = P_ONCE_NOT_DONE;
1488
      RELEASE_LOCK;
1489
   }
1490
1491
   ensure_valgrind("pthread_once");
1492
1493
   /* Grab the lock transiently, so we can safely see what state this
1494
      once_control is in. */
1495
1496
   TAKE_LOCK;
1497
1498
   switch (*once_control) {
1499
1500
      case P_ONCE_NOT_DONE:
1501
 	 /* Not started.  Change state to indicate running, drop the
1502
	    lock and run.  */
1503
         *once_control = P_ONCE_RUNNING;
1504
	 _pthread_cleanup_push(NULL, cleanup, NULL);
1505
	 RELEASE_LOCK;
1506
         init_routine();
1507
         /* re-take the lock, and set state to indicate done. */
1508
	 TAKE_LOCK;
1509
	 _pthread_cleanup_pop(NULL, False);
1510
         *once_control = P_ONCE_COMPLETED;
1511
	 RELEASE_LOCK;
1512
	 break;
1513
1514
      case P_ONCE_RUNNING:
1515
	 /* This is the tricky case.  The initialiser is running in
1516
            some other thread, but we have to delay this thread till
1517
            the other one completes.  So we sort-of busy wait.  In
1518
            fact it makes sense to yield now, because what we want to
1519
            happen is for the thread running the initialiser to
1520
            complete ASAP. */
1521
	 RELEASE_LOCK;
1522
         done = 0;
1523
         while (1) {
1524
            /* Let others run for a while. */
1525
	    __valgrind_pthread_yield();
1526
	    /* Grab the lock and see if we're done waiting. */
1527
	    TAKE_LOCK;
1528
            if (*once_control == P_ONCE_COMPLETED)
1529
               done = 1;
1530
	    RELEASE_LOCK;
1531
	    if (done)
1532
               break;
1533
	 }
1534
	 break;
1535
1536
      case P_ONCE_COMPLETED:
1537
      default: 
1538
 	 /* Easy.  It's already done.  Just drop the lock. */
1539
         RELEASE_LOCK;
1540
	 break;
1541
   }
1542
1543
   return 0;
1544
1545
#  undef TAKE_LOCK
1546
#  undef RELEASE_LOCK
1547
}
1548
1549
#undef P_ONCE_NOT_DONE
1550
#undef P_ONCE_RUNNING
1551
#undef P_ONCE_COMPLETED
1552
1553
1554
/* ---------------------------------------------------
1555
   MISC
1556
   ------------------------------------------------ */
1557
1558
static pthread_mutex_t pthread_atfork_lock 
1559
   = PTHREAD_MUTEX_INITIALIZER;
1560
1561
int __pthread_atfork ( void (*prepare)(void),
1562
                       void (*parent)(void),
1563
                       void (*child)(void) )
1564
{
1565
   int n, res;
1566
   ForkHandlerEntry entry;
1567
1568
   ensure_valgrind("pthread_atfork");
1569
   __pthread_mutex_lock(&pthread_atfork_lock);
1570
1571
   /* Fetch old counter */
1572
   VALGRIND_MAGIC_SEQUENCE(n, -2 /* default */,
1573
                           VG_USERREQ__GET_FHSTACK_USED,
1574
                           0, 0, 0, 0);
1575
   my_assert(n >= 0 && n < VG_N_FORKHANDLERSTACK);
1576
   if (n == VG_N_FORKHANDLERSTACK-1)
1577
      barf("pthread_atfork: VG_N_FORKHANDLERSTACK is too low; "
1578
           "increase and recompile");
1579
1580
   /* Add entry */
1581
   entry.prepare = *prepare;
1582
   entry.parent  = *parent;
1583
   entry.child   = *child;   
1584
   VALGRIND_MAGIC_SEQUENCE(res, -2 /* default */,
1585
                           VG_USERREQ__SET_FHSTACK_ENTRY,
1586
                           n, &entry, 0, 0);
1587
   my_assert(res == 0);
1588
1589
   /* Bump counter */
1590
   VALGRIND_MAGIC_SEQUENCE(res, -2 /* default */,
1591
                           VG_USERREQ__SET_FHSTACK_USED,
1592
                           n+1, 0, 0, 0);
1593
   my_assert(res == 0);
1594
1595
   __pthread_mutex_unlock(&pthread_atfork_lock);
1596
   return 0;
1597
}
1598
1599
1600
#ifdef GLIBC_2_3
1601
/* This seems to be a hook which appeared in glibc-2.3.2. */
1602
int __register_atfork ( void (*prepare)(void),
1603
                        void (*parent)(void),
1604
                        void (*child)(void) )
1605
{
1606
   return __pthread_atfork(prepare,parent,child);
1607
}
1608
#endif
1609
1610
WEAK 
1611
void __pthread_initialize ( void )
1612
{
1613
   ensure_valgrind("__pthread_initialize");
1614
}
1615
1616
1617
/* ---------------------------------------------------
1618
   LIBRARY-PRIVATE THREAD SPECIFIC STATE
1619
   ------------------------------------------------ */
1620
1621
#include <resolv.h>
1622
static int thread_specific_errno[VG_N_THREADS];
1623
static int thread_specific_h_errno[VG_N_THREADS];
1624
static struct __res_state
1625
           thread_specific_res_state[VG_N_THREADS];
1626
1627
#undef errno
1628
extern int errno;
1629
int* __errno_location ( void )
1630
{
1631
   int tid;
1632
   int *ret;
1633
1634
   ensure_valgrind("__errno_location");
1635
   VALGRIND_MAGIC_SEQUENCE(tid, 1 /* default */,
1636
                           VG_USERREQ__PTHREAD_GET_THREADID,
1637
                           0, 0, 0, 0);
1638
   /* 'cos I'm paranoid ... */
1639
   if (tid < 1 || tid >= VG_N_THREADS)
1640
      barf("__errno_location: invalid ThreadId");
1641
   if (tid == 1)
1642
      ret = &errno;
1643
   else
1644
      ret = &thread_specific_errno[tid];
1645
1646
   return ret;
1647
}
1648
1649
#undef h_errno
1650
extern int h_errno;
1651
int* __h_errno_location ( void )
1652
{
1653
   int tid;
1654
   /* ensure_valgrind("__h_errno_location"); */
1655
   VALGRIND_MAGIC_SEQUENCE(tid, 1 /* default */,
1656
                           VG_USERREQ__PTHREAD_GET_THREADID,
1657
                           0, 0, 0, 0);
1658
   /* 'cos I'm paranoid ... */
1659
   if (tid < 1 || tid >= VG_N_THREADS)
1660
      barf("__h_errno_location: invalid ThreadId");
1661
   if (tid == 1)
1662
      return &h_errno;
1663
   return & thread_specific_h_errno[tid];
1664
}
1665
1666
1667
#undef _res
1668
extern struct __res_state _res;
1669
struct __res_state* __res_state ( void )
1670
{
1671
   int tid;
1672
   /* ensure_valgrind("__res_state"); */
1673
   VALGRIND_MAGIC_SEQUENCE(tid, 1 /* default */,
1674
                           VG_USERREQ__PTHREAD_GET_THREADID,
1675
                           0, 0, 0, 0);
1676
   /* 'cos I'm paranoid ... */
1677
   if (tid < 1 || tid >= VG_N_THREADS)
1678
      barf("__res_state: invalid ThreadId");
1679
   if (tid == 1)
1680
      return & _res;
1681
   return & thread_specific_res_state[tid];
1682
}
1683
1684
1685
/* ---------------------------------------------------
1686
   LIBC-PRIVATE SPECIFIC DATA
1687
   ------------------------------------------------ */
1688
1689
/* Relies on assumption that initial private data is NULL.  This
1690
   should be fixed somehow. */
1691
1692
/* The allowable keys (indices) (all 3 of them). 
1693
   From sysdeps/pthread/bits/libc-tsd.h
1694
*/
1695
/* as per glibc anoncvs HEAD of 20021001. */
1696
enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
1697
                        _LIBC_TSD_KEY_DL_ERROR,
1698
                        _LIBC_TSD_KEY_RPC_VARS,
1699
                        _LIBC_TSD_KEY_LOCALE,
1700
                        _LIBC_TSD_KEY_CTYPE_B,
1701
                        _LIBC_TSD_KEY_CTYPE_TOLOWER,
1702
                        _LIBC_TSD_KEY_CTYPE_TOUPPER,
1703
                        _LIBC_TSD_KEY_N };
1704
1705
/* Auto-initialising subsystem.  libc_specifics_inited is set 
1706
   after initialisation.  libc_specifics_inited_mx guards it. */
1707
static int             libc_specifics_inited    = 0;
1708
static pthread_mutex_t libc_specifics_inited_mx = PTHREAD_MUTEX_INITIALIZER;
1709
1710
1711
/* These are the keys we must initialise the first time. */
1712
static pthread_key_t libc_specifics_keys[_LIBC_TSD_KEY_N];
1713
1714
1715
/* Initialise the keys, if they are not already initialised. */
1716
static
1717
void init_libc_tsd_keys ( void )
1718
{
1719
   int res, i;
1720
   pthread_key_t k;
1721
1722
   /* Don't fall into deadlock if we get called again whilst we still
1723
      hold the lock, via the __uselocale() call herein. */
1724
   if (libc_specifics_inited != 0)
1725
      return;
1726
1727
   /* Take the lock. */
1728
   res = __pthread_mutex_lock(&libc_specifics_inited_mx);
1729
   if (res != 0) barf("init_libc_tsd_keys: lock");
1730
1731
   /* Now test again, to be sure there is no mistake. */
1732
   if (libc_specifics_inited != 0) {
1733
      res = __pthread_mutex_unlock(&libc_specifics_inited_mx);
1734
      if (res != 0) barf("init_libc_tsd_keys: unlock(1)");
1735
      return;
1736
   }
1737
1738
   /* Actually do the initialisation. */
1739
   /* printf("INIT libc specifics\n"); */
1740
   for (i = 0; i < _LIBC_TSD_KEY_N; i++) {
1741
      res = __pthread_key_create(&k, NULL);
1742
      if (res != 0) barf("init_libc_tsd_keys: create");
1743
      libc_specifics_keys[i] = k;
1744
   }
1745
1746
   /* Signify init done. */
1747
   libc_specifics_inited = 1;
1748
1749
#  ifdef GLIBC_2_3
1750
   /* Set the initialising thread's locale to the global (default)
1751
      locale.  A hack in support of glibc-2.3.  This does the biz for
1752
      the root thread.  For all other threads we run this in
1753
      thread_wrapper(), which does the real work of
1754
      pthread_create(). */
1755
   /* assert that we are the root thread.  I don't know if this is
1756
      really a valid assertion to make; if it breaks I'll reconsider
1757
      it. */
1758
   my_assert(pthread_self() == 1);
1759
   __uselocale(LC_GLOBAL_LOCALE);
1760
#  endif
1761
1762
   /* Unlock and return. */
1763
   res = __pthread_mutex_unlock(&libc_specifics_inited_mx);
1764
   if (res != 0) barf("init_libc_tsd_keys: unlock");
1765
}
1766
1767
1768
static int
1769
libc_internal_tsd_set ( enum __libc_tsd_key_t key, 
1770
                        const void * pointer )
1771
{
1772
   int res;
1773
   /* printf("SET SET SET key %d ptr %p\n", key, pointer); */
1774
   if (key < _LIBC_TSD_KEY_MALLOC || key >= _LIBC_TSD_KEY_N)
1775
      barf("libc_internal_tsd_set: invalid key");
1776
   init_libc_tsd_keys();
1777
   res = __pthread_setspecific(libc_specifics_keys[key], pointer);
1778
   if (res != 0) barf("libc_internal_tsd_set: setspecific failed");
1779
   return 0;
1780
}
1781
1782
static void *
1783
libc_internal_tsd_get ( enum __libc_tsd_key_t key )
1784
{
1785
   void* v;
1786
   /* printf("GET GET GET key %d\n", key); */
1787
   if (key < _LIBC_TSD_KEY_MALLOC || key >= _LIBC_TSD_KEY_N)
1788
      barf("libc_internal_tsd_get: invalid key");
1789
   init_libc_tsd_keys();
1790
   v = __pthread_getspecific(libc_specifics_keys[key]);
1791
   /* if (v == NULL) barf("libc_internal_tsd_set: getspecific failed"); */
1792
   return v;
1793
}
1794
1795
1796
int (*__libc_internal_tsd_set)
1797
    (enum __libc_tsd_key_t key, const void * pointer)
1798
   = libc_internal_tsd_set;
1799
1800
void* (*__libc_internal_tsd_get)
1801
      (enum __libc_tsd_key_t key)
1802
   = libc_internal_tsd_get;
1803
1804
1805
#ifdef GLIBC_2_3
1806
/* This one was first spotted be me in the glibc-2.2.93 sources. */
1807
static void**
1808
libc_internal_tsd_address ( enum __libc_tsd_key_t key )
1809
{
1810
   void** v;
1811
   /* printf("ADDR ADDR ADDR key %d\n", key); */
1812
   if (key < _LIBC_TSD_KEY_MALLOC || key >= _LIBC_TSD_KEY_N)
1813
      barf("libc_internal_tsd_address: invalid key");
1814
   init_libc_tsd_keys();
1815
   v = __pthread_getspecific_addr(libc_specifics_keys[key]);
1816
   return v;
1817
}
1818
1819
void ** (*__libc_internal_tsd_address) 
1820
        (enum __libc_tsd_key_t key)
1821
   = libc_internal_tsd_address;
1822
#endif
1823
1824
1825
/* ---------------------------------------------------------------------
1826
   These are here (I think) because they are deemed cancellation
1827
   points by POSIX.  For the moment we'll simply pass the call along
1828
   to the corresponding thread-unaware (?) libc routine.
1829
   ------------------------------------------------------------------ */
1830
1831
#ifdef GLIBC_2_1
1832
extern
1833
int __sigaction
1834
             (int signum, 
1835
              const struct sigaction *act,  
1836
              struct  sigaction *oldact);
1837
#else
1838
extern
1839
int __libc_sigaction
1840
             (int signum, 
1841
              const struct sigaction *act,  
1842
              struct  sigaction *oldact);
1843
#endif
1844
int sigaction(int signum, 
1845
              const struct sigaction *act,  
1846
              struct  sigaction *oldact)
1847
{
1848
   __my_pthread_testcancel();
1849
#  ifdef GLIBC_2_1
1850
   return __sigaction(signum, act, oldact);
1851
#  else
1852
   return __libc_sigaction(signum, act, oldact);
1853
#  endif
1854
}
1855
1856
extern 
1857
int __libc_accept(int fd, struct sockaddr *addr, socklen_t *len);
1858
1859
WEAK int __accept(int fd, struct sockaddr *addr, socklen_t *len)
1860
{
1861
   __my_pthread_testcancel();
1862
   return __libc_accept(fd, addr, len);
1863
}
1864
strong_alias(__accept, accept);
1865
1866
extern
1867
int  __libc_connect(int  sockfd,  
1868
                    const  struct  sockaddr  *serv_addr, 
1869
                    socklen_t addrlen);
1870
WEAK
1871
int  connect(int  sockfd,  
1872
             const  struct  sockaddr  *serv_addr, 
1873
             socklen_t addrlen)
1874
{
1875
   __my_pthread_testcancel();
1876
   return __libc_connect(sockfd, serv_addr, addrlen);
1877
}
1878
1879
1880
extern
1881
int __libc_fcntl(int fd, int cmd, long arg);
1882
WEAK
1883
int fcntl(int fd, int cmd, long arg)
1884
{
1885
   __my_pthread_testcancel();
1886
   return __libc_fcntl(fd, cmd, arg);
1887
}
1888
1889
1890
extern 
1891
ssize_t __libc_write(int fd, const void *buf, size_t count);
1892
WEAK
1893
ssize_t write(int fd, const void *buf, size_t count)
1894
{
1895
   __my_pthread_testcancel();
1896
   return __libc_write(fd, buf, count);
1897
}
1898
1899
1900
extern 
1901
ssize_t __libc_read(int fd, void *buf, size_t count);
1902
WEAK
1903
ssize_t read(int fd, void *buf, size_t count)
1904
{
1905
   __my_pthread_testcancel();
1906
   return __libc_read(fd, buf, count);
1907
}
1908
1909
extern
1910
int __libc_open64(const char *pathname, int flags, mode_t mode);
1911
/* WEAK */
1912
int open64(const char *pathname, int flags, mode_t mode)
1913
{
1914
   return __libc_open64(pathname, flags, mode);
1915
}
1916
1917
extern
1918
int __libc_open(const char *pathname, int flags, mode_t mode);
1919
/* WEAK */
1920
int open(const char *pathname, int flags, mode_t mode)
1921
{
1922
   return __libc_open(pathname, flags, mode);
1923
}
1924
1925
extern
1926
int __libc_close(int fd);
1927
WEAK
1928
int close(int fd)
1929
{
1930
   __my_pthread_testcancel();
1931
   return __libc_close(fd);
1932
}
1933
1934
1935
extern
1936
pid_t __libc_waitpid(pid_t pid, int *status, int options);
1937
WEAK
1938
pid_t waitpid(pid_t pid, int *status, int options)
1939
{
1940
   __my_pthread_testcancel();
1941
   return __libc_waitpid(pid, status, options);
1942
}
1943
1944
1945
extern
1946
int __libc_nanosleep(const struct timespec *req, struct timespec *rem);
1947
WEAK
1948
int __nanosleep(const struct timespec *req, struct timespec *rem)
1949
{
1950
   __my_pthread_testcancel();
1951
   return __libc_nanosleep(req, rem);
1952
}
1953
1954
extern
1955
int __libc_pause(void);
1956
WEAK
1957
int __pause(void)
1958
{
1959
   __my_pthread_testcancel();
1960
   return __libc_pause();
1961
}
1962
1963
1964
extern
1965
int __libc_fsync(int fd);
1966
WEAK
1967
int fsync(int fd)
1968
{
1969
   __my_pthread_testcancel();
1970
   return __libc_fsync(fd);
1971
}
1972
1973
1974
extern
1975
off_t __libc_lseek(int fildes, off_t offset, int whence);
1976
WEAK
1977
off_t lseek(int fildes, off_t offset, int whence)
1978
{
1979
   __my_pthread_testcancel();
1980
   return __libc_lseek(fildes, offset, whence);
1981
}
1982
1983
1984
extern
1985
__off64_t __libc_lseek64(int fildes, __off64_t offset, int whence);
1986
WEAK
1987
__off64_t lseek64(int fildes, __off64_t offset, int whence)
1988
{
1989
   __my_pthread_testcancel();
1990
   return __libc_lseek64(fildes, offset, whence);
1991
}
1992
1993
1994
extern 
1995
ssize_t __libc_pread64 (int __fd, void *__buf, size_t __nbytes,
1996
                        __off64_t __offset);
1997
ssize_t __pread64 (int __fd, void *__buf, size_t __nbytes,
1998
                   __off64_t __offset)
1999
{
2000
   __my_pthread_testcancel();
2001
   return __libc_pread64(__fd, __buf, __nbytes, __offset);
2002
}
2003
2004
2005
extern
2006
ssize_t __libc_pwrite64 (int __fd, const void *__buf, size_t __nbytes,
2007
                        __off64_t __offset);
2008
ssize_t __pwrite64 (int __fd, const void *__buf, size_t __nbytes,
2009
                   __off64_t __offset)
2010
{
2011
   __my_pthread_testcancel();
2012
   return __libc_pwrite64(__fd, __buf, __nbytes, __offset);
2013
}
2014
2015
2016
extern 
2017
ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset);
2018
WEAK
2019
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
2020
{
2021
   __my_pthread_testcancel();
2022
   return __libc_pwrite(fd, buf, count, offset);
2023
}
2024
2025
2026
extern 
2027
ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset);
2028
WEAK
2029
ssize_t pread(int fd, void *buf, size_t count, off_t offset)
2030
{
2031
   __my_pthread_testcancel();
2032
   return __libc_pread(fd, buf, count, offset);
2033
}
2034
2035
extern
2036
int __libc_recv(int s, void *msg, size_t len, int flags);
2037
WEAK
2038
int recv(int s, void *msg, size_t len, int flags)
2039
{
2040
   __my_pthread_testcancel();
2041
   return __libc_recv(s, msg, len, flags);
2042
}
2043
2044
extern
2045
int __libc_send(int s, const void *msg, size_t len, int flags);
2046
WEAK
2047
int send(int s, const void *msg, size_t len, int flags)
2048
{
2049
   __my_pthread_testcancel();
2050
   return __libc_send(s, msg, len, flags);
2051
}
2052
2053
2054
extern 
2055
int __libc_sendmsg(int s, const struct msghdr *msg, int flags);
2056
WEAK
2057
int sendmsg(int s, const struct msghdr *msg, int flags)
2058
{
2059
   __my_pthread_testcancel();
2060
   return __libc_sendmsg(s, msg, flags);
2061
}
2062
2063
2064
extern
2065
int __libc_recvmsg(int s, struct msghdr *msg, int flags);
2066
WEAK
2067
int recvmsg(int s, struct msghdr *msg, int flags)
2068
{
2069
   __my_pthread_testcancel();
2070
   return __libc_recvmsg(s, msg, flags);
2071
}
2072
2073
2074
extern
2075
int __libc_recvfrom(int s, void *buf, size_t len, int flags,
2076
                    struct sockaddr *from, socklen_t *fromlen);
2077
WEAK
2078
int recvfrom(int s, void *buf, size_t len, int flags,
2079
             struct sockaddr *from, socklen_t *fromlen)
2080
{
2081
   __my_pthread_testcancel();
2082
   return __libc_recvfrom(s, buf, len, flags, from, fromlen);
2083
}
2084
2085
2086
extern
2087
int __libc_sendto(int s, const void *msg, size_t len, int flags, 
2088
                  const struct sockaddr *to, socklen_t tolen);
2089
WEAK
2090
int sendto(int s, const void *msg, size_t len, int flags, 
2091
           const struct sockaddr *to, socklen_t tolen)
2092
{
2093
   __my_pthread_testcancel();
2094
   return __libc_sendto(s, msg, len, flags, to, tolen);
2095
}
2096
2097
2098
extern 
2099
int __libc_system(const char* str);
2100
WEAK
2101
int system(const char* str)
2102
{
2103
   __my_pthread_testcancel();
2104
   return __libc_system(str);
2105
}
2106
2107
2108
extern
2109
pid_t __libc_wait(int *status);
2110
WEAK
2111
pid_t wait(int *status)
2112
{
2113
   __my_pthread_testcancel();
2114
   return __libc_wait(status);
2115
}
2116
2117
2118
extern
2119
int __libc_msync(const void *start, size_t length, int flags);
2120
WEAK
2121
int msync(const void *start, size_t length, int flags)
2122
{
2123
   __my_pthread_testcancel();
2124
   return __libc_msync(start, length, flags);
2125
}
2126
2127
strong_alias(close, __close)
2128
strong_alias(fcntl, __fcntl)
2129
strong_alias(lseek, __lseek)
2130
strong_alias(open, __open)
2131
strong_alias(open64, __open64)
2132
strong_alias(read, __read)
2133
strong_alias(wait, __wait)
2134
strong_alias(write, __write)
2135
strong_alias(connect, __connect)
2136
strong_alias(send, __send)
2137
2138
weak_alias (__pread64, pread64)
2139
weak_alias (__pwrite64, pwrite64)
2140
weak_alias(__nanosleep, nanosleep)
2141
weak_alias(__pause, pause)
2142
2143
2144
extern  
2145
void __libc_longjmp(jmp_buf env, int val) __attribute((noreturn));
2146
/* not weak: WEAK */
2147
void longjmp(jmp_buf env, int val)
2148
{
2149
   __libc_longjmp(env, val);
2150
}
2151
2152
2153
extern void __libc_siglongjmp (sigjmp_buf env, int val)
2154
                               __attribute__ ((noreturn));
2155
void siglongjmp(sigjmp_buf env, int val)
2156
{
2157
   kludged("siglongjmp", "(it ignores cleanup handlers)");
2158
   __libc_siglongjmp(env, val);
2159
}
2160
2161
2162
/*--- fork and its helper ---*/
2163
2164
static
2165
void run_fork_handlers ( int what )
2166
{
2167
   ForkHandlerEntry entry;
2168
   int n_h, n_handlers, i, res;
2169
2170
   my_assert(what == 0 || what == 1 || what == 2);
2171
2172
   /* Fetch old counter */
2173
   VALGRIND_MAGIC_SEQUENCE(n_handlers, -2 /* default */,
2174
                           VG_USERREQ__GET_FHSTACK_USED,
2175
                           0, 0, 0, 0);
2176
   my_assert(n_handlers >= 0 && n_handlers < VG_N_FORKHANDLERSTACK);
2177
2178
   /* Prepare handlers (what == 0) are called in opposite order of
2179
      calls to pthread_atfork.  Parent and child handlers are called
2180
      in the same order as calls to pthread_atfork. */
2181
   if (what == 0)
2182
      n_h = n_handlers - 1;
2183
   else
2184
      n_h = 0;
2185
2186
   for (i = 0; i < n_handlers; i++) {
2187
      VALGRIND_MAGIC_SEQUENCE(res, -2 /* default */,
2188
                              VG_USERREQ__GET_FHSTACK_ENTRY,
2189
                              n_h, &entry, 0, 0);
2190
      my_assert(res == 0);
2191
      switch (what) {
2192
         case 0:  if (entry.prepare) entry.prepare(); 
2193
                  n_h--; break;
2194
         case 1:  if (entry.parent) entry.parent(); 
2195
                  n_h++; break;
2196
         case 2:  if (entry.child) entry.child(); 
2197
                  n_h++; break;
2198
         default: barf("run_fork_handlers: invalid what");
2199
      }
2200
   }
2201
2202
   if (what != 0 /* prepare */) {
2203
      /* Empty out the stack. */
2204
      VALGRIND_MAGIC_SEQUENCE(res, -2 /* default */,
2205
                              VG_USERREQ__SET_FHSTACK_USED,
2206
                              0, 0, 0, 0);
2207
      my_assert(res == 0);
2208
   }
2209
}
2210
2211
extern
2212
pid_t __libc_fork(void);
2213
pid_t __fork(void)
2214
{
2215
   pid_t pid;
2216
   __my_pthread_testcancel();
2217
   __pthread_mutex_lock(&pthread_atfork_lock);
2218
2219
   run_fork_handlers(0 /* prepare */);
2220
   pid = __libc_fork();
2221
   if (pid == 0) {
2222
      /* I am the child */
2223
      run_fork_handlers(2 /* child */);
2224
      __pthread_mutex_unlock(&pthread_atfork_lock);
2225
      __pthread_mutex_init(&pthread_atfork_lock, NULL);
2226
   } else {
2227
      /* I am the parent */
2228
      run_fork_handlers(1 /* parent */);
2229
      __pthread_mutex_unlock(&pthread_atfork_lock);
2230
   }
2231
   return pid;
2232
}
2233
2234
2235
pid_t __vfork(void)
2236
{
2237
   return __fork();
2238
}
2239
2240
2241
2242
/* ---------------------------------------------------------------------
2243
   Hacky implementation of semaphores.
2244
   ------------------------------------------------------------------ */
2245
2246
#include <semaphore.h>
2247
2248
/* This is a terrible way to do the remapping.  Plan is to import an
2249
   AVL tree at some point. */
2250
2251
typedef
2252
   struct {
2253
      pthread_mutex_t se_mx;
2254
      pthread_cond_t se_cv;
2255
      int count;
2256
      int waiters;
2257
   }
2258
   vg_sem_t;
2259
2260
static pthread_mutex_t se_remap_mx = PTHREAD_MUTEX_INITIALIZER;
2261
2262
static int      se_remap_used = 0;
2263
static sem_t*   se_remap_orig[VG_N_SEMAPHORES];
2264
static vg_sem_t se_remap_new[VG_N_SEMAPHORES];
2265
2266
static vg_sem_t* se_remap ( sem_t* orig )
2267
{
2268
   int res, i;
2269
   res = __pthread_mutex_lock(&se_remap_mx);
2270
   my_assert(res == 0);
2271
2272
   for (i = 0; i < se_remap_used; i++) {
2273
      if (se_remap_orig[i] == orig)
2274
         break;
2275
   }
2276
   if (i == se_remap_used) {
2277
      if (se_remap_used == VG_N_SEMAPHORES) {
2278
         res = pthread_mutex_unlock(&se_remap_mx);
2279
         my_assert(res == 0);
2280
         barf("VG_N_SEMAPHORES is too low.  Increase and recompile.");
2281
      }
2282
      se_remap_used++;
2283
      se_remap_orig[i] = orig;
2284
      /* printf("allocated semaphore %d\n", i); */
2285
   }
2286
   res = __pthread_mutex_unlock(&se_remap_mx);
2287
   my_assert(res == 0);
2288
   return &se_remap_new[i];
2289
}
2290
2291
static void se_unmap( sem_t* orig )
2292
{
2293
   int res, i;
2294
   res = __pthread_mutex_lock(&se_remap_mx);
2295
   my_assert(res == 0);
2296
2297
   for (i = 0; i < se_remap_used; i++) {
2298
      if (se_remap_orig[i] == orig)
2299
         break;
2300
   }
2301
   if (i == se_remap_used) {
2302
      res = pthread_mutex_unlock(&se_remap_mx);
2303
      my_assert(res == 0);
2304
      barf("se_unmap: unmapping invalid semaphore");
2305
   } else {
2306
      se_remap_orig[i] = se_remap_orig[--se_remap_used];
2307
      se_remap_orig[se_remap_used] = 0;
2308
      memset(&se_remap_new[se_remap_used], 0,
2309
             sizeof(se_remap_new[se_remap_used]));
2310
   }
2311
   res = pthread_mutex_unlock(&se_remap_mx);
2312
   my_assert(res == 0);
2313
}
2314
2315
int sem_init(sem_t *sem, int pshared, unsigned int value)
2316
{
2317
   int       res;
2318
   vg_sem_t* vg_sem;
2319
   ensure_valgrind("sem_init");
2320
   if (pshared != 0) {
2321
      pthread_error("sem_init: unsupported pshared value");
2322
      *(__errno_location()) = ENOSYS;
2323
      return -1;
2324
   }
2325
   vg_sem = se_remap(sem);
2326
   res = pthread_mutex_init(&vg_sem->se_mx, NULL);
2327
   my_assert(res == 0);
2328
   res = pthread_cond_init(&vg_sem->se_cv, NULL);
2329
   my_assert(res == 0);
2330
   vg_sem->count = value;
2331
   return 0;
2332
}
2333
2334
2335
int sem_wait ( sem_t* sem ) 
2336
{
2337
   int       res;
2338
   vg_sem_t* vg_sem;
2339
   ensure_valgrind("sem_wait");
2340
   vg_sem = se_remap(sem);
2341
   res = __pthread_mutex_lock(&vg_sem->se_mx);
2342
   my_assert(res == 0);
2343
   while (vg_sem->count == 0) {
2344
      ++vg_sem->waiters;
2345
      res = pthread_cond_wait(&vg_sem->se_cv, &vg_sem->se_mx);
2346
      --vg_sem->waiters;
2347
      my_assert(res == 0);
2348
   }
2349
   vg_sem->count--;
2350
   res = __pthread_mutex_unlock(&vg_sem->se_mx);
2351
   my_assert(res == 0);
2352
   return 0;
2353
}
2354
2355
int sem_post ( sem_t* sem ) 
2356
{
2357
   int       res;
2358
   vg_sem_t* vg_sem; 
2359
   ensure_valgrind("sem_post");
2360
   vg_sem = se_remap(sem);
2361
   res = __pthread_mutex_lock(&vg_sem->se_mx);
2362
   my_assert(res == 0);
2363
   if (vg_sem->count == 0) {
2364
      vg_sem->count++;
2365
      res = pthread_cond_broadcast(&vg_sem->se_cv);
2366
      my_assert(res == 0);
2367
   } else {
2368
      vg_sem->count++;
2369
   }
2370
   res = __pthread_mutex_unlock(&vg_sem->se_mx);
2371
   my_assert(res == 0);
2372
   return 0;
2373
}
2374
2375
2376
int sem_trywait ( sem_t* sem ) 
2377
{
2378
   int       ret, res;
2379
   vg_sem_t* vg_sem; 
2380
   ensure_valgrind("sem_trywait");
2381
   vg_sem = se_remap(sem);
2382
   res = __pthread_mutex_lock(&vg_sem->se_mx);
2383
   my_assert(res == 0);
2384
   if (vg_sem->count > 0) { 
2385
      vg_sem->count--; 
2386
      ret = 0; 
2387
   } else { 
2388
      ret = -1; 
2389
      *(__errno_location()) = EAGAIN; 
2390
   }
2391
   res = __pthread_mutex_unlock(&vg_sem->se_mx);
2392
   my_assert(res == 0);
2393
   return ret;
2394
}
2395
2396
2397
int sem_getvalue(sem_t* sem, int * sval)
2398
{
2399
   int res;
2400
   vg_sem_t* vg_sem; 
2401
   ensure_valgrind("sem_getvalue");
2402
   vg_sem = se_remap(sem);
2403
   res = __pthread_mutex_lock(&vg_sem->se_mx);
2404
   my_assert(res == 0);
2405
   *sval = vg_sem->count;
2406
   res = __pthread_mutex_unlock(&vg_sem->se_mx);
2407
   my_assert(res == 0);
2408
   return 0;
2409
}
2410
2411
2412
int sem_destroy(sem_t * sem)
2413
{
2414
   /* if someone waiting on this semaphore, errno = EBUSY, return -1 */
2415
   vg_sem_t* vg_sem;
2416
   int res;
2417
   ensure_valgrind("sem_destroy");
2418
   vg_sem = se_remap(sem);
2419
   res = __pthread_mutex_lock(&vg_sem->se_mx);
2420
   my_assert(res == 0);
2421
   if (vg_sem->waiters > 0)
2422
   {
2423
      *(__errno_location()) = EBUSY;
2424
      res = __pthread_mutex_unlock(&vg_sem->se_mx);
2425
      my_assert(res == 0);
2426
      return -1;
2427
   }
2428
   res = pthread_cond_destroy(&vg_sem->se_cv);
2429
   my_assert(res == 0);
2430
   res = __pthread_mutex_unlock(&vg_sem->se_mx);
2431
   my_assert(res == 0);
2432
   res = pthread_mutex_destroy(&vg_sem->se_mx);
2433
   my_assert(res == 0);
2434
   se_unmap(sem);
2435
   return 0;
2436
}
2437
2438
  
2439
int sem_timedwait(sem_t* sem, const struct timespec *abstime) 
2440
{ 
2441
   int       res; 
2442
   vg_sem_t* vg_sem; 
2443
   ensure_valgrind("sem_timedwait"); 
2444
   vg_sem = se_remap(sem); 
2445
   res = __pthread_mutex_lock(&vg_sem->se_mx); 
2446
   my_assert(res == 0); 
2447
   while ( vg_sem->count == 0 && res != ETIMEDOUT ) { 
2448
      ++vg_sem->waiters;
2449
      res = pthread_cond_timedwait(&vg_sem->se_cv, &vg_sem->se_mx, abstime); 
2450
      --vg_sem->waiters;
2451
   } 
2452
   if ( vg_sem->count > 0 ) { 
2453
      vg_sem->count--; 
2454
      res = __pthread_mutex_unlock(&vg_sem->se_mx); 
2455
      my_assert(res == 0 ); 
2456
      return 0; 
2457
   } else { 
2458
      res = __pthread_mutex_unlock(&vg_sem->se_mx); 
2459
      my_assert(res == 0 ); 
2460
      *(__errno_location()) = ETIMEDOUT; 
2461
      return -1; 
2462
   } 
2463
} 
2464
 
2465
2466
/* ---------------------------------------------------------------------
2467
   Reader-writer locks.
2468
   ------------------------------------------------------------------ */
2469
2470
typedef 
2471
   struct {
2472
      int             initted;  /* != 0 --> in use; sanity check only */
2473
      int             prefer_w; /* != 0 --> prefer writer */
2474
      int             nwait_r;  /* # of waiting readers */
2475
      int             nwait_w;  /* # of waiting writers */
2476
      pthread_cond_t  cv_r;     /* for signalling readers */
2477
      pthread_cond_t  cv_w;     /* for signalling writers */
2478
      pthread_mutex_t mx;
2479
      int             status;
2480
      /* allowed range for status: >= -1.  -1 means 1 writer currently
2481
         active, >= 0 means N readers currently active. */
2482
   } 
2483
   vg_rwlock_t;
2484
2485
2486
static pthread_mutex_t rw_remap_mx = PTHREAD_MUTEX_INITIALIZER;
2487
2488
static int                 rw_remap_used = 0;
2489
static pthread_rwlock_t*   rw_remap_orig[VG_N_RWLOCKS];
2490
static vg_rwlock_t         rw_remap_new[VG_N_RWLOCKS];
2491
2492
2493
static 
2494
void init_vg_rwlock ( vg_rwlock_t* vg_rwl )
2495
{
2496
   int res = 0;
2497
   vg_rwl->initted = 1;
2498
   vg_rwl->prefer_w = 1;
2499
   vg_rwl->nwait_r = 0;
2500
   vg_rwl->nwait_w = 0;
2501
   vg_rwl->status = 0;
2502
   res = pthread_mutex_init(&vg_rwl->mx, NULL);
2503
   res |= pthread_cond_init(&vg_rwl->cv_r, NULL);
2504
   res |= pthread_cond_init(&vg_rwl->cv_w, NULL);
2505
   my_assert(res == 0);
2506
}
2507
2508
2509
/* Take the address of a LinuxThreads rwlock_t and return the shadow
2510
   address of our version.  Further, if the LinuxThreads version
2511
   appears to have been statically initialised, do the same to the one
2512
   we allocate here.  The pthread_rwlock_t.__rw_readers field is set
2513
   to zero by PTHREAD_RWLOCK_INITIALIZER, so we take zero as meaning
2514
   uninitialised and non-zero meaning initialised. 
2515
*/
2516
static vg_rwlock_t* rw_remap ( pthread_rwlock_t* orig )
2517
{
2518
   int          res, i;
2519
   vg_rwlock_t* vg_rwl;
2520
   res = __pthread_mutex_lock(&rw_remap_mx);
2521
   my_assert(res == 0);
2522
2523
   for (i = 0; i < rw_remap_used; i++) {
2524
      if (rw_remap_orig[i] == orig)
2525
         break;
2526
   }
2527
   if (i == rw_remap_used) {
2528
      if (rw_remap_used == VG_N_RWLOCKS) {
2529
         res = __pthread_mutex_unlock(&rw_remap_mx);
2530
         my_assert(res == 0);
2531
         barf("VG_N_RWLOCKS is too low.  Increase and recompile.");
2532
      }
2533
      rw_remap_used++;
2534
      rw_remap_orig[i] = orig;
2535
      rw_remap_new[i].initted = 0;
2536
      if (0) printf("allocated rwlock %d\n", i);
2537
   }
2538
   res = __pthread_mutex_unlock(&rw_remap_mx);
2539
   my_assert(res == 0);
2540
   vg_rwl = &rw_remap_new[i];
2541
2542
   /* Initialise the shadow, if required. */
2543
   if (orig->__rw_readers == 0) {
2544
      orig->__rw_readers = 1;
2545
      init_vg_rwlock(vg_rwl);
2546
      if (orig->__rw_kind == PTHREAD_RWLOCK_PREFER_READER_NP)
2547
         vg_rwl->prefer_w = 0;
2548
   }
2549
2550
   return vg_rwl;
2551
}
2552
2553
2554
int pthread_rwlock_init ( pthread_rwlock_t* orig,
2555
                          const pthread_rwlockattr_t* attr )
2556
{
2557
   vg_rwlock_t* rwl;
2558
   if (0) printf ("pthread_rwlock_init\n");
2559
   /* Force the remapper to initialise the shadow. */
2560
   orig->__rw_readers = 0;
2561
   /* Install the lock preference; the remapper needs to know it. */
2562
   orig->__rw_kind = PTHREAD_RWLOCK_DEFAULT_NP;
2563
   if (attr)
2564
      orig->__rw_kind = attr->__lockkind;
2565
   rwl = rw_remap ( orig );
2566
   return 0;
2567
}
2568
2569
2570
static 
2571
void pthread_rwlock_rdlock_CANCEL_HDLR ( void* rwl_v )
2572
{
2573
   vg_rwlock_t* rwl = (vg_rwlock_t*)rwl_v;
2574
   rwl->nwait_r--;
2575
   pthread_mutex_unlock (&rwl->mx);
2576
}
2577
2578
2579
int pthread_rwlock_rdlock ( pthread_rwlock_t* orig )
2580
{
2581
   int res;
2582
   vg_rwlock_t* rwl;
2583
   if (0) printf ("pthread_rwlock_rdlock\n");
2584
   rwl = rw_remap ( orig );
2585
   res = __pthread_mutex_lock(&rwl->mx);
2586
   my_assert(res == 0);
2587
   if (!rwl->initted) {
2588
      res = __pthread_mutex_unlock(&rwl->mx);
2589
      my_assert(res == 0);
2590
      return EINVAL;
2591
   }
2592
   if (rwl->status < 0) {
2593
      my_assert(rwl->status == -1);
2594
      rwl->nwait_r++;
2595
      pthread_cleanup_push( pthread_rwlock_rdlock_CANCEL_HDLR, rwl );
2596
      while (1) {
2597
         if (rwl->status == 0) break;
2598
         res = pthread_cond_wait(&rwl->cv_r, &rwl->mx);
2599
         my_assert(res == 0);
2600
      }
2601
      pthread_cleanup_pop(0);
2602
      rwl->nwait_r--;
2603
   }
2604
   my_assert(rwl->status >= 0);
2605
   rwl->status++;
2606
   res = __pthread_mutex_unlock(&rwl->mx);
2607
   my_assert(res == 0);
2608
   return 0;
2609
}
2610
2611
2612
int pthread_rwlock_tryrdlock ( pthread_rwlock_t* orig )
2613
{
2614
   int res;
2615
   vg_rwlock_t* rwl;
2616
   if (0) printf ("pthread_rwlock_tryrdlock\n");
2617
   rwl = rw_remap ( orig );
2618
   res = __pthread_mutex_lock(&rwl->mx);
2619
   my_assert(res == 0);
2620
   if (!rwl->initted) {
2621
      res = __pthread_mutex_unlock(&rwl->mx);
2622
      my_assert(res == 0);
2623
      return EINVAL;
2624
   }
2625
   if (rwl->status == -1) {
2626
      /* Writer active; we have to give up. */
2627
      res = __pthread_mutex_unlock(&rwl->mx);
2628
      my_assert(res == 0);
2629
      return EBUSY;
2630
   }
2631
   /* Success */
2632
   my_assert(rwl->status >= 0);
2633
   rwl->status++;
2634
   res = __pthread_mutex_unlock(&rwl->mx);
2635
   my_assert(res == 0);
2636
   return 0;
2637
}
2638
2639
2640
static 
2641
void pthread_rwlock_wrlock_CANCEL_HDLR ( void* rwl_v )
2642
{
2643
   vg_rwlock_t* rwl = (vg_rwlock_t*)rwl_v;
2644
   rwl->nwait_w--;
2645
   pthread_mutex_unlock (&rwl->mx);
2646
}
2647
2648
2649
int pthread_rwlock_wrlock ( pthread_rwlock_t* orig )
2650
{
2651
   int res;
2652
   vg_rwlock_t* rwl;
2653
   if (0) printf ("pthread_rwlock_wrlock\n");
2654
   rwl = rw_remap ( orig );
2655
   res = __pthread_mutex_lock(&rwl->mx);
2656
   my_assert(res == 0);
2657
   if (!rwl->initted) {
2658
      res = __pthread_mutex_unlock(&rwl->mx);
2659
      my_assert(res == 0);
2660
      return EINVAL;
2661
   }
2662
   if (rwl->status != 0) {
2663
      rwl->nwait_w++;
2664
      pthread_cleanup_push( pthread_rwlock_wrlock_CANCEL_HDLR, rwl );
2665
      while (1) {
2666
         if (rwl->status == 0) break;
2667
         res = pthread_cond_wait(&rwl->cv_w, &rwl->mx);
2668
         my_assert(res == 0);
2669
      }
2670
      pthread_cleanup_pop(0);
2671
      rwl->nwait_w--;
2672
   }
2673
   my_assert(rwl->status == 0);
2674
   rwl->status = -1;
2675
   res = __pthread_mutex_unlock(&rwl->mx);
2676
   my_assert(res == 0);
2677
   return 0;
2678
}
2679
2680
2681
int pthread_rwlock_trywrlock ( pthread_rwlock_t* orig )
2682
{
2683
   int res;
2684
   vg_rwlock_t* rwl;
2685
   if (0) printf ("pthread_wrlock_trywrlock\n");
2686
   rwl = rw_remap ( orig );
2687
   res = __pthread_mutex_lock(&rwl->mx);
2688
   my_assert(res == 0);
2689
   if (!rwl->initted) {
2690
      res = __pthread_mutex_unlock(&rwl->mx);
2691
      my_assert(res == 0);
2692
      return EINVAL;
2693
   }
2694
   if (rwl->status != 0) {
2695
      /* Reader(s) or a writer active; we have to give up. */
2696
      res = __pthread_mutex_unlock(&rwl->mx);
2697
      my_assert(res == 0);
2698
      return EBUSY;
2699
   }
2700
   /* Success */
2701
   my_assert(rwl->status == 0);
2702
   rwl->status = -1;
2703
   res = __pthread_mutex_unlock(&rwl->mx);
2704
   my_assert(res == 0);
2705
   return 0;
2706
}
2707
2708
2709
int pthread_rwlock_unlock ( pthread_rwlock_t* orig )
2710
{
2711
   int res;
2712
   vg_rwlock_t* rwl;
2713
   if (0) printf ("pthread_rwlock_unlock\n");
2714
   rwl = rw_remap ( orig );
2715
   rwl = rw_remap ( orig );
2716
   res = __pthread_mutex_lock(&rwl->mx);
2717
   my_assert(res == 0);
2718
   if (!rwl->initted) {
2719
      res = __pthread_mutex_unlock(&rwl->mx);
2720
      my_assert(res == 0);
2721
      return EINVAL;
2722
   }
2723
   if (rwl->status == 0) {
2724
      res = __pthread_mutex_unlock(&rwl->mx);
2725
      my_assert(res == 0);
2726
      return EPERM;
2727
   }
2728
   my_assert(rwl->status != 0);
2729
   if (rwl->status == -1) {
2730
     rwl->status = 0;
2731
   } else {
2732
     my_assert(rwl->status > 0);
2733
     rwl->status--;
2734
   }
2735
2736
   my_assert(rwl->status >= 0);
2737
2738
   if (rwl->prefer_w) {
2739
2740
      /* Favour waiting writers, if any. */
2741
      if (rwl->nwait_w > 0) {
2742
         /* Writer(s) are waiting. */
2743
         if (rwl->status == 0) {
2744
            /* We can let a writer in. */
2745
            res = pthread_cond_signal(&rwl->cv_w);
2746
            my_assert(res == 0);
2747
         } else {
2748
            /* There are still readers active.  Do nothing; eventually
2749
               they will disappear, at which point a writer will be
2750
               admitted. */
2751
         }
2752
      } 
2753
      else
2754
      /* No waiting writers. */
2755
      if (rwl->nwait_r > 0) {
2756
         /* Let in a waiting reader. */
2757
         res = pthread_cond_signal(&rwl->cv_r);
2758
         my_assert(res == 0);
2759
      }
2760
2761
   } else {
2762
2763
      /* Favour waiting readers, if any. */
2764
      if (rwl->nwait_r > 0) {
2765
         /* Reader(s) are waiting; let one in. */
2766
         res = pthread_cond_signal(&rwl->cv_r);
2767
         my_assert(res == 0);
2768
      } 
2769
      else
2770
      /* No waiting readers. */
2771
      if (rwl->nwait_w > 0 && rwl->status == 0) {
2772
         /* We have waiting writers and no active readers; let a
2773
            writer in. */
2774
         res = pthread_cond_signal(&rwl->cv_w);
2775
         my_assert(res == 0);
2776
      }
2777
   }
2778
2779
   res = __pthread_mutex_unlock(&rwl->mx);
2780
   my_assert(res == 0);
2781
   return 0;   
2782
}
2783
2784
2785
int pthread_rwlock_destroy ( pthread_rwlock_t *orig )
2786
{
2787
   int res;
2788
   vg_rwlock_t* rwl;
2789
   if (0) printf ("pthread_rwlock_destroy\n");
2790
   rwl = rw_remap ( orig );
2791
   res = __pthread_mutex_lock(&rwl->mx);
2792
   my_assert(res == 0);
2793
   if (!rwl->initted) {
2794
      res = __pthread_mutex_unlock(&rwl->mx);
2795
      my_assert(res == 0);
2796
      return EINVAL;
2797
   }
2798
   if (rwl->status != 0 || rwl->nwait_r > 0 || rwl->nwait_w > 0) {
2799
      res = __pthread_mutex_unlock(&rwl->mx);
2800
      my_assert(res == 0);
2801
      return EBUSY;
2802
   }
2803
   rwl->initted = 0;
2804
   res = __pthread_mutex_unlock(&rwl->mx);
2805
   my_assert(res == 0);
2806
   return 0;
2807
}
2808
2809
2810
/* Copied directly from LinuxThreads. */
2811
int
2812
pthread_rwlockattr_init (pthread_rwlockattr_t *attr)
2813
{
2814
  attr->__lockkind = 0;
2815
  attr->__pshared = PTHREAD_PROCESS_PRIVATE;
2816
2817
  return 0;
2818
}
2819
2820
/* Copied directly from LinuxThreads. */
2821
int
2822
pthread_rwlockattr_destroy (pthread_rwlockattr_t *attr)
2823
{
2824
  return 0;
2825
}
2826
2827
/* Copied directly from LinuxThreads. */
2828
int
2829
pthread_rwlockattr_setpshared (pthread_rwlockattr_t *attr, int pshared)
2830
{
2831
  if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
2832
    return EINVAL;
2833
2834
  /* For now it is not possible to shared a conditional variable.  */
2835
  if (pshared != PTHREAD_PROCESS_PRIVATE)
2836
    return ENOSYS;
2837
2838
  attr->__pshared = pshared;
2839
2840
  return 0;
2841
}
2842
2843
2844
2845
/* ---------------------------------------------------------------------
2846
   Manage the allocation and use of RT signals.  The Valgrind core
2847
   uses one.  glibc needs us to implement this to make RT signals
2848
   work; things just seem to crash if we don't.
2849
   ------------------------------------------------------------------ */
2850
int __libc_current_sigrtmin (void)
2851
{
2852
   int res;
2853
2854
   VALGRIND_MAGIC_SEQUENCE(res, 0, 
2855
			   VG_USERREQ__GET_SIGRT_MIN,
2856
			   0, 0, 0, 0);
2857
2858
   return res;
2859
}
2860
2861
int __libc_current_sigrtmax (void)
2862
{
2863
   int res;
2864
2865
   VALGRIND_MAGIC_SEQUENCE(res, 0, 
2866
			   VG_USERREQ__GET_SIGRT_MAX,
2867
			   0, 0, 0, 0);
2868
2869
   return res;
2870
}
2871
2872
int __libc_allocate_rtsig (int high)
2873
{
2874
   int res;
2875
2876
   VALGRIND_MAGIC_SEQUENCE(res, 0, 
2877
			   VG_USERREQ__ALLOC_RTSIG,
2878
			   high, 0, 0, 0);
2879
2880
   return res;
2881
}
2882
2883
/* ---------------------------------------------------------------------
2884
   B'stard.
2885
   ------------------------------------------------------------------ */
2886
strong_alias(__pthread_mutex_lock, pthread_mutex_lock)
2887
strong_alias(__pthread_mutex_trylock, pthread_mutex_trylock)
2888
strong_alias(__pthread_mutex_unlock, pthread_mutex_unlock)
2889
strong_alias(__pthread_mutexattr_init, pthread_mutexattr_init)
2890
  weak_alias(__pthread_mutexattr_settype, pthread_mutexattr_settype)
2891
  weak_alias(__pthread_mutexattr_setpshared, pthread_mutexattr_setpshared)
2892
strong_alias(__pthread_mutex_init, pthread_mutex_init)
2893
strong_alias(__pthread_mutexattr_destroy, pthread_mutexattr_destroy)
2894
strong_alias(__pthread_mutex_destroy, pthread_mutex_destroy)
2895
strong_alias(__pthread_once, pthread_once)
2896
strong_alias(__pthread_atfork, pthread_atfork)
2897
strong_alias(__pthread_key_create, pthread_key_create)
2898
strong_alias(__pthread_getspecific, pthread_getspecific)
2899
strong_alias(__pthread_setspecific, pthread_setspecific)
2900
2901
#ifndef GLIBC_2_1
2902
strong_alias(sigaction, __sigaction)
2903
#endif
2904
     
2905
weak_alias(__fork, fork)
2906
weak_alias(__vfork, vfork)
2907
weak_alias (__pthread_kill_other_threads_np, pthread_kill_other_threads_np)
2908
2909
/*--------------------------------------------------*/
2910
2911
weak_alias(pthread_rwlock_rdlock, __pthread_rwlock_rdlock)
2912
weak_alias(pthread_rwlock_unlock, __pthread_rwlock_unlock)
2913
weak_alias(pthread_rwlock_wrlock, __pthread_rwlock_wrlock)
2914
2915
weak_alias(pthread_rwlock_destroy, __pthread_rwlock_destroy)
2916
weak_alias(pthread_rwlock_init, __pthread_rwlock_init)
2917
weak_alias(pthread_rwlock_tryrdlock, __pthread_rwlock_tryrdlock)
2918
weak_alias(pthread_rwlock_trywrlock, __pthread_rwlock_trywrlock)
2919
2920
2921
/* I've no idea what these are, but they get called quite a lot.
2922
   Anybody know? */
2923
2924
#ifndef __UCLIBC__
2925
#undef _IO_flockfile
2926
void _IO_flockfile ( _IO_FILE * file )
2927
{
2928
   pthread_mutex_lock(file->_lock);
2929
}
2930
weak_alias(_IO_flockfile, flockfile);
2931
2932
#undef _IO_funlockfile
2933
void _IO_funlockfile ( _IO_FILE * file )
2934
{
2935
   pthread_mutex_unlock(file->_lock);
2936
}
2937
weak_alias(_IO_funlockfile, funlockfile);
2938
#endif
2939
2940
2941
/* This doesn't seem to be needed to simulate libpthread.so's external
2942
   interface, but many people complain about its absence. */
2943
2944
strong_alias(__pthread_mutexattr_settype, __pthread_mutexattr_setkind_np)
2945
weak_alias(__pthread_mutexattr_setkind_np, pthread_mutexattr_setkind_np)
2946
2947
/* POSIX spinlocks, taken from glibc linuxthreads/sysdeps/i386 */
2948
2949
typedef volatile int pthread_spinlock_t; /* Huh?  Guarded by __USE_XOPEN2K */
2950
2951
int pthread_spin_init(pthread_spinlock_t *lock, int pshared)
2952
{
2953
  /* We can ignore the `pshared' parameter.  Since we are busy-waiting
2954
     all processes which can access the memory location `lock' points
2955
     to can use the spinlock.  */
2956
  *lock = 1;
2957
  return 0;
2958
}
2959
2960
int pthread_spin_lock(pthread_spinlock_t *lock)
2961
{
2962
  asm volatile
2963
    ("\n"
2964
     "1:\n\t"
2965
     "lock; decl %0\n\t"
2966
     "js 2f\n\t"
2967
     ".section .text.spinlock,\"ax\"\n"
2968
     "2:\n\t"
2969
     "cmpl $0,%0\n\t"
2970
     "rep; nop\n\t"
2971
     "jle 2b\n\t"
2972
     "jmp 1b\n\t"
2973
     ".previous"
2974
     : "=m" (*lock));
2975
  return 0;
2976
}
2977
2978
int pthread_spin_unlock(pthread_spinlock_t *lock)
2979
{
2980
  asm volatile
2981
    ("movl $1,%0"
2982
     : "=m" (*lock));
2983
  return 0;
2984
}
2985
2986
int pthread_spin_destroy(pthread_spinlock_t *lock)
2987
{
2988
  /* Nothing to do.  */
2989
  return 0;
2990
}
2991
2992
int pthread_spin_trylock(pthread_spinlock_t *lock)
2993
{
2994
  int oldval;
2995
2996
  asm volatile
2997
    ("xchgl %0,%1"
2998
     : "=r" (oldval), "=m" (*lock)
2999
     : "0" (0));
3000
  return oldval > 0 ? 0 : EBUSY;
3001
}
3002
3003
/*--------------------------------------------------------------------*/
3004
/*--- end                                          vg_libpthread.c ---*/
3005
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/arch/x86-linux/vg_libpthread_unimp.c (+272 lines)
Line 0 Link Here
1
2
/*--------------------------------------------------------------------*/
3
/*--- Give dummy bindings for everything the real libpthread.so    ---*/
4
/*--- binds.                                 vg_libpthread_unimp.c ---*/
5
/*--------------------------------------------------------------------*/
6
7
/*
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
10
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
13
14
   This program is free software; you can redistribute it and/or
15
   modify it under the terms of the GNU General Public License as
16
   published by the Free Software Foundation; either version 2 of the
17
   License, or (at your option) any later version.
18
19
   This program is distributed in the hope that it will be useful, but
20
   WITHOUT ANY WARRANTY; without even the implied warranty of
21
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22
   General Public License for more details.
23
24
   You should have received a copy of the GNU General Public License
25
   along with this program; if not, write to the Free Software
26
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27
   02111-1307, USA.
28
29
   The GNU General Public License is contained in the file COPYING.
30
*/
31
32
/* ---------------------------------------------------------------------
33
   ALL THIS CODE RUNS ON THE SIMULATED CPU.
34
   Give a binding for everything the real libpthread.so binds.
35
   ------------------------------------------------------------------ */
36
37
#include "vg_include.h"  /* For GLIBC_2_3, or not, as the case may be */
38
39
extern void vgPlain_unimp ( char* );
40
#define unimp(str) vgPlain_unimp(str)
41
42
//void _IO_flockfile ( void )  { unimp("_IO_flockfile"); }
43
void _IO_ftrylockfile ( void )  { unimp("_IO_ftrylockfile"); }
44
//void _IO_funlockfile ( void )  { unimp("_IO_funlockfile"); }
45
//void __close ( void )  { unimp("__close"); }
46
//void __connect ( void )  { unimp("__connect"); }
47
//void __errno_location ( void )  { unimp("__errno_location"); }
48
//void __fcntl ( void )  { unimp("__fcntl"); }
49
//void __fork ( void )  { unimp("__fork"); }
50
//void __h_errno_location ( void )  { unimp("__h_errno_location"); }
51
//void __libc_allocate_rtsig ( void )  { unimp("__libc_allocate_rtsig"); }
52
//void __libc_current_sigrtmax ( void )  { unimp("__libc_current_sigrtmax"); }
53
//void __libc_current_sigrtmin ( void )  { unimp("__libc_current_sigrtmin"); }
54
//void __lseek ( void )  { unimp("__lseek"); }
55
//void __open ( void )  { unimp("__open"); }
56
//void __open64 ( void )  { unimp("__open64"); }
57
//void __pread64 ( void )  { unimp("__pread64"); }
58
//void __pthread_atfork ( void )  { unimp("__pthread_atfork"); }
59
//void __pthread_getspecific ( void )  { unimp("__pthread_getspecific"); }
60
//void __pthread_key_create ( void )  { unimp("__pthread_key_create"); }
61
//void __pthread_kill_other_threads_np ( void )  { unimp("__pthread_kill_other_threads_np"); }
62
//void __pthread_mutex_destroy ( void )  { unimp("__pthread_mutex_destroy"); }
63
//void __pthread_mutex_init ( void )  { unimp("__pthread_mutex_init"); }
64
//void __pthread_mutex_lock ( void )  { unimp("__pthread_mutex_lock"); }
65
//void __pthread_mutex_trylock ( void )  { unimp("__pthread_mutex_trylock"); }
66
//void __pthread_mutex_unlock ( void )  { unimp("__pthread_mutex_unlock"); }
67
//void __pthread_mutexattr_destroy ( void )  { unimp("__pthread_mutexattr_destroy"); }
68
//void __pthread_mutexattr_init ( void )  { unimp("__pthread_mutexattr_init"); }
69
//void __pthread_mutexattr_settype ( void )  { unimp("__pthread_mutexattr_settype"); }
70
//void __pthread_once ( void )  { unimp("__pthread_once"); }
71
//void __pthread_setspecific ( void )  { unimp("__pthread_setspecific"); }
72
//void __pwrite64 ( void )  { unimp("__pwrite64"); }
73
//void __read ( void )  { unimp("__read"); }
74
//void __res_state ( void )  { unimp("__res_state"); }
75
//void __send ( void )  { unimp("__send"); }
76
//void __sigaction ( void )  { unimp("__sigaction"); }
77
//--//void __vfork ( void )  { unimp("__vfork"); }
78
//void __wait ( void )  { unimp("__wait"); }
79
//void __write ( void )  { unimp("__write"); }
80
//void _pthread_cleanup_pop ( void )  { unimp("_pthread_cleanup_pop"); }
81
//void _pthread_cleanup_pop_restore ( void )  { unimp("_pthread_cleanup_pop_restore"); }
82
//void _pthread_cleanup_push ( void )  { unimp("_pthread_cleanup_push"); }
83
//void _pthread_cleanup_push_defer ( void )  { unimp("_pthread_cleanup_push_defer"); }
84
//void longjmp ( void )  { unimp("longjmp"); }
85
//void pthread_atfork ( void )  { unimp("pthread_atfork"); }
86
//void pthread_attr_destroy ( void )  { unimp("pthread_attr_destroy"); }
87
//void pthread_attr_getdetachstate ( void )  { unimp("pthread_attr_getdetachstate"); }
88
void pthread_attr_getinheritsched ( void )  { unimp("pthread_attr_getinheritsched"); }
89
//void pthread_attr_getschedparam ( void )  { unimp("pthread_attr_getschedparam"); }
90
//void pthread_attr_getschedpolicy ( void )  { unimp("pthread_attr_getschedpolicy"); }
91
//void pthread_attr_getscope ( void )  { unimp("pthread_attr_getscope"); }
92
93
//void pthread_attr_setdetachstate ( void )  { unimp("pthread_attr_setdetachstate"); }
94
//void pthread_attr_setinheritsched ( void )  { unimp("pthread_attr_setinheritsched"); }
95
//void pthread_attr_setschedparam ( void )  { unimp("pthread_attr_setschedparam"); }
96
//void pthread_attr_setschedpolicy ( void )  { unimp("pthread_attr_setschedpolicy"); }
97
//void pthread_attr_setscope ( void )  { unimp("pthread_attr_setscope"); }
98
void pthread_barrier_destroy ( void )  { unimp("pthread_barrier_destroy"); }
99
void pthread_barrier_init ( void )  { unimp("pthread_barrier_init"); }
100
void pthread_barrier_wait ( void )  { unimp("pthread_barrier_wait"); }
101
void pthread_barrierattr_destroy ( void )  { unimp("pthread_barrierattr_destroy"); }
102
void pthread_barrierattr_init ( void )  { unimp("pthread_barrierattr_init"); }
103
void pthread_barrierattr_setpshared ( void )  { unimp("pthread_barrierattr_setpshared"); }
104
//void pthread_cancel ( void )  { unimp("pthread_cancel"); }
105
//void pthread_cond_broadcast ( void )  { unimp("pthread_cond_broadcast"); }
106
//void pthread_cond_destroy ( void )  { unimp("pthread_cond_destroy"); }
107
//void pthread_cond_init ( void )  { unimp("pthread_cond_init"); }
108
//void pthread_cond_signal ( void )  { unimp("pthread_cond_signal"); }
109
//void pthread_cond_timedwait ( void )  { unimp("pthread_cond_timedwait"); }
110
//void pthread_cond_wait ( void )  { unimp("pthread_cond_wait"); }
111
//void pthread_condattr_destroy ( void )  { unimp("pthread_condattr_destroy"); }
112
void pthread_condattr_getpshared ( void )  { unimp("pthread_condattr_getpshared"); }
113
//void pthread_condattr_init ( void )  { unimp("pthread_condattr_init"); }
114
void pthread_condattr_setpshared ( void )  { unimp("pthread_condattr_setpshared"); }
115
//void pthread_detach ( void )  { unimp("pthread_detach"); }
116
//void pthread_equal ( void )  { unimp("pthread_equal"); }
117
//void pthread_exit ( void )  { unimp("pthread_exit"); }
118
//void pthread_getattr_np ( void )  { unimp("pthread_getattr_np"); }
119
void pthread_getcpuclockid ( void )  { unimp("pthread_getcpuclockid"); }
120
//void pthread_getschedparam ( void )  { unimp("pthread_getschedparam"); }
121
//void pthread_getspecific ( void )  { unimp("pthread_getspecific"); }
122
//void pthread_join ( void )  { unimp("pthread_join"); }
123
//void pthread_key_create ( void )  { unimp("pthread_key_create"); }
124
//void pthread_key_delete ( void )  { unimp("pthread_key_delete"); }
125
//void pthread_kill ( void )  { unimp("pthread_kill"); }
126
//void pthread_mutex_destroy ( void )  { unimp("pthread_mutex_destroy"); }
127
//void pthread_mutex_init ( void )  { unimp("pthread_mutex_init"); }
128
//void pthread_mutex_lock ( void )  { unimp("pthread_mutex_lock"); }
129
void pthread_mutex_timedlock ( void )  { unimp("pthread_mutex_timedlock"); }
130
//void pthread_mutex_trylock ( void )  { unimp("pthread_mutex_trylock"); }
131
//void pthread_mutex_unlock ( void )  { unimp("pthread_mutex_unlock"); }
132
//void pthread_mutexattr_destroy ( void )  { unimp("pthread_mutexattr_destroy"); }
133
//void pthread_mutexattr_init ( void )  { unimp("pthread_mutexattr_init"); }
134
//void pthread_once ( void )  { unimp("pthread_once"); }
135
//void pthread_rwlock_destroy ( void )  { unimp("pthread_rwlock_destroy"); }
136
//void pthread_rwlock_init ( void )  { unimp("pthread_rwlock_init"); }
137
//void pthread_rwlock_rdlock ( void )  { unimp("pthread_rwlock_rdlock"); }
138
void pthread_rwlock_timedrdlock ( void )  { unimp("pthread_rwlock_timedrdlock"); }
139
void pthread_rwlock_timedwrlock ( void )  { unimp("pthread_rwlock_timedwrlock"); }
140
//void pthread_rwlock_tryrdlock ( void )  { unimp("pthread_rwlock_tryrdlock"); }
141
//void pthread_rwlock_trywrlock ( void )  { unimp("pthread_rwlock_trywrlock"); }
142
//void pthread_rwlock_unlock ( void )  { unimp("pthread_rwlock_unlock"); }
143
//void pthread_rwlock_wrlock ( void )  { unimp("pthread_rwlock_wrlock"); }
144
//void pthread_rwlockattr_destroy ( void )  { unimp("pthread_rwlockattr_destroy"); }
145
void pthread_rwlockattr_getkind_np ( void )  { unimp("pthread_rwlockattr_getkind_np"); }
146
void pthread_rwlockattr_getpshared ( void )  { unimp("pthread_rwlockattr_getpshared"); }
147
//void pthread_rwlockattr_init ( void )  { unimp("pthread_rwlockattr_init"); }
148
void pthread_rwlockattr_setkind_np ( void )  { unimp("pthread_rwlockattr_setkind_np"); }
149
//void pthread_rwlockattr_setpshared ( void )  { unimp("pthread_rwlockattr_setpshared"); }
150
//void pthread_self ( void )  { unimp("pthread_self"); }
151
//void pthread_setcancelstate ( void )  { unimp("pthread_setcancelstate"); }
152
//void pthread_setcanceltype ( void )  { unimp("pthread_setcanceltype"); }
153
//void pthread_setschedparam ( void )  { unimp("pthread_setschedparam"); }
154
//void pthread_setspecific ( void )  { unimp("pthread_setspecific"); }
155
//void pthread_sigmask ( void )  { unimp("pthread_sigmask"); }
156
//void pthread_testcancel ( void )  { unimp("pthread_testcancel"); }
157
//void raise ( void )  { unimp("raise"); }
158
void sem_close ( void )  { unimp("sem_close"); }
159
void sem_open ( void )  { unimp("sem_open"); }
160
//void sem_timedwait ( void )  { unimp("sem_timedwait"); }
161
void sem_unlink ( void )  { unimp("sem_unlink"); }
162
//void sigaction ( void )  { unimp("sigaction"); }
163
//void siglongjmp ( void )  { unimp("siglongjmp"); }
164
//void sigwait ( void )  { unimp("sigwait"); }
165
166
void __pthread_clock_gettime ( void ) { unimp("__pthread_clock_gettime"); }
167
void __pthread_clock_settime ( void ) { unimp("__pthread_clock_settime"); }
168
#ifdef GLIBC_2_3
169
/* Needed for Red Hat 8.0 */
170
__asm__(".symver __pthread_clock_gettime,"
171
        "__pthread_clock_gettime@GLIBC_PRIVATE");
172
__asm__(".symver __pthread_clock_settime,"
173
        "__pthread_clock_settime@GLIBC_PRIVATE");
174
#endif
175
176
177
#if 0
178
void pthread_create@@GLIBC_2.1 ( void )  { unimp("pthread_create@@GLIBC_2.1"); }
179
void pthread_create@GLIBC_2.0 ( void )  { unimp("pthread_create@GLIBC_2.0"); }
180
181
void sem_wait@@GLIBC_2.1 ( void )  { unimp("sem_wait@@GLIBC_2.1"); }
182
void sem_wait@GLIBC_2.0 ( void )  { unimp("sem_wait@GLIBC_2.0"); }
183
184
void sem_trywait@@GLIBC_2.1 ( void )  { unimp("sem_trywait@@GLIBC_2.1"); }
185
void sem_trywait@GLIBC_2.0 ( void )  { unimp("sem_trywait@GLIBC_2.0"); }
186
187
void sem_post@@GLIBC_2.1 ( void )  { unimp("sem_post@@GLIBC_2.1"); }
188
void sem_post@GLIBC_2.0 ( void )  { unimp("sem_post@GLIBC_2.0"); }
189
190
void sem_destroy@@GLIBC_2.1 ( void )  { unimp("sem_destroy@@GLIBC_2.1"); }
191
void sem_destroy@GLIBC_2.0 ( void )  { unimp("sem_destroy@GLIBC_2.0"); }
192
void sem_getvalue@@GLIBC_2.1 ( void )  { unimp("sem_getvalue@@GLIBC_2.1"); }
193
void sem_getvalue@GLIBC_2.0 ( void )  { unimp("sem_getvalue@GLIBC_2.0"); }
194
void sem_init@@GLIBC_2.1 ( void )  { unimp("sem_init@@GLIBC_2.1"); }
195
void sem_init@GLIBC_2.0 ( void )  { unimp("sem_init@GLIBC_2.0"); }
196
197
void pthread_attr_init@@GLIBC_2.1 ( void )  { unimp("pthread_attr_init@@GLIBC_2.1"); }
198
void pthread_attr_init@GLIBC_2.0 ( void )  { unimp("pthread_attr_init@GLIBC_2.0"); }
199
#endif
200
201
202
203
# define strong_alias(name, aliasname) \
204
  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
205
206
# define weak_alias(name, aliasname) \
207
  extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
208
209
//weak_alias(pthread_rwlock_destroy, __pthread_rwlock_destroy)
210
//weak_alias(pthread_rwlock_init, __pthread_rwlock_init)
211
//weak_alias(pthread_rwlock_tryrdlock, __pthread_rwlock_tryrdlock)
212
//weak_alias(pthread_rwlock_trywrlock, __pthread_rwlock_trywrlock)
213
//weak_alias(pthread_rwlock_wrlock, __pthread_rwlock_wrlock)
214
weak_alias(_IO_ftrylockfile, ftrylockfile)
215
216
//__attribute__((weak)) void pread ( void ) { vgPlain_unimp("pread"); }
217
//__attribute__((weak)) void pwrite ( void ) { vgPlain_unimp("pwrite"); }
218
//__attribute__((weak)) void msync ( void ) { vgPlain_unimp("msync"); }
219
//__attribute__((weak)) void pause ( void ) { vgPlain_unimp("pause"); }
220
//__attribute__((weak)) void recvfrom ( void ) { vgPlain_unimp("recvfrom"); }
221
//__attribute__((weak)) void recvmsg ( void ) { vgPlain_unimp("recvmsg"); }
222
//__attribute__((weak)) void sendmsg ( void ) { vgPlain_unimp("sendmsg"); }
223
__attribute__((weak)) void tcdrain ( void ) { vgPlain_unimp("tcdrain"); }
224
//--//__attribute__((weak)) void vfork ( void ) { vgPlain_unimp("vfork"); }
225
226
//__attribute__((weak)) void pthread_attr_getguardsize ( void )
227
//                      { vgPlain_unimp("pthread_attr_getguardsize"); }
228
__attribute__((weak)) void pthread_attr_getstack ( void )
229
                      { vgPlain_unimp("pthread_attr_getstack"); }
230
__attribute__((weak)) void pthread_attr_getstackaddr ( void )
231
                      { vgPlain_unimp("pthread_attr_getstackaddr"); }
232
__attribute__((weak)) void pthread_attr_getstacksize ( void )
233
                      { vgPlain_unimp("pthread_attr_getstacksize"); }
234
//__attribute__((weak)) void pthread_attr_setguardsize ( void )
235
//                      { vgPlain_unimp("pthread_attr_setguardsize"); }
236
__attribute__((weak)) void pthread_attr_setstack ( void )
237
                      { vgPlain_unimp("pthread_attr_setstack"); }
238
__attribute__((weak)) void pthread_attr_setstackaddr ( void )
239
                      { vgPlain_unimp("pthread_attr_setstackaddr"); }
240
//__attribute__((weak)) void pthread_attr_setstacksize ( void )
241
//                      { vgPlain_unimp("pthread_attr_setstacksize"); }
242
//__attribute__((weak)) void pthread_getconcurrency ( void )
243
//                      { vgPlain_unimp("pthread_getconcurrency"); }
244
//__attribute__((weak)) void pthread_kill_other_threads_np ( void )
245
//                      { vgPlain_unimp("pthread_kill_other_threads_np"); }
246
__attribute__((weak)) void pthread_mutexattr_getkind_np ( void )
247
                      { vgPlain_unimp("pthread_mutexattr_getkind_np"); }
248
__attribute__((weak)) void pthread_mutexattr_getpshared ( void )
249
                      { vgPlain_unimp("pthread_mutexattr_getpshared"); }
250
__attribute__((weak)) void pthread_mutexattr_gettype ( void )
251
                      { vgPlain_unimp("pthread_mutexattr_gettype"); }
252
__attribute__((weak)) void pthread_mutexattr_setkind_np ( void )
253
                      { vgPlain_unimp("pthread_mutexattr_setkind_np"); }
254
//__attribute__((weak)) void pthread_mutexattr_setpshared ( void )
255
//                      { vgPlain_unimp("pthread_mutexattr_setpshared"); }
256
//__attribute__((weak)) void pthread_setconcurrency ( void )
257
//                      { vgPlain_unimp("pthread_setconcurrency"); }
258
//__attribute__((weak)) void pthread_spin_destroy ( void )
259
//                      { vgPlain_unimp("pthread_spin_destroy"); }
260
//__attribute__((weak)) void pthread_spin_init ( void )
261
//                      { vgPlain_unimp("pthread_spin_init"); }
262
//__attribute__((weak)) void pthread_spin_lock ( void )
263
//                      { vgPlain_unimp("pthread_spin_lock"); }
264
//__attribute__((weak)) void pthread_spin_trylock ( void )
265
//                      { vgPlain_unimp("pthread_spin_trylock"); }
266
//__attribute__((weak)) void pthread_spin_unlock ( void )
267
//                      { vgPlain_unimp("pthread_spin_unlock"); }
268
269
270
/*--------------------------------------------------------------------*/
271
/*--- end                                    vg_libpthread_unimp.c ---*/
272
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/arch/x86-linux/vg_syscall.S (+118 lines)
Line 0 Link Here
1
2
##--------------------------------------------------------------------##
3
##--- Support for doing system calls.                              ---##
4
##---                                                 vg_syscall.S ---##
5
##--------------------------------------------------------------------##
6
7
/*
8
  This file is part of Valgrind, an extensible x86 protected-mode
9
  emulator for monitoring program execution on x86-Unixes.
10
11
  Copyright (C) 2000-2004 Julian Seward 
12
     jseward@acm.org
13
14
  This program is free software; you can redistribute it and/or
15
  modify it under the terms of the GNU General Public License as
16
  published by the Free Software Foundation; either version 2 of the
17
  License, or (at your option) any later version.
18
19
  This program is distributed in the hope that it will be useful, but
20
  WITHOUT ANY WARRANTY; without even the implied warranty of
21
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22
  General Public License for more details.
23
24
  You should have received a copy of the GNU General Public License
25
  along with this program; if not, write to the Free Software
26
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27
  02111-1307, USA.
28
29
  The GNU General Public License is contained in the file COPYING.
30
*/
31
32
#include "vg_constants.h"
33
#include "vg_unistd.h"
34
35
.globl	VG_(do_syscall)
36
37
/*
38
	Perform a Linux syscall with int 0x80
39
	
40
	Syscall args are passed on the stack
41
	Int VG_(do_syscall)(Int syscall_no, ...)
42
43
	This has no effect on the virtual machine; the expectation is
44
	that the syscall mechanism makes no useful changes to any
45
	register except %eax, which is returned.
46
 */
47
VG_(do_syscall):
48
	push	%esi
49
	push	%edi
50
	push	%ebx
51
	push	%ebp
52
	movl	16+ 4(%esp),%eax
53
	movl	16+ 8(%esp),%ebx
54
	movl	16+12(%esp),%ecx
55
	movl	16+16(%esp),%edx
56
	movl	16+20(%esp),%esi
57
	movl	16+24(%esp),%edi
58
	movl	16+28(%esp),%ebp
59
	int	$0x80
60
	popl	%ebp
61
	popl	%ebx
62
	popl	%edi
63
	popl	%esi
64
	ret
65
66
/*
67
	Perform a clone system call.  clone is strange because it has
68
	fork()-like return-twice semantics, so it needs special
69
	handling here.
70
71
	int VG_(clone)(int (*fn)(void *), void *child_stack, int flags, void *arg, 
72
	               0                  4                  8          12
73
		       pid_t *child_tid, pid_t *parent_tid)
74
		       16                20
75
76
 */
77
.globl VG_(clone)
78
VG_(clone):
79
#define FSZ	(4+4+4)			/* frame size = retaddr+ebx+edi */
80
	push	%ebx
81
	push	%edi
82
	/* set up child stack with function and arg */
83
	movl	 4+FSZ(%esp), %ecx	/* child stack */
84
	movl	12+FSZ(%esp), %ebx	/* fn arg */
85
	movl	 0+FSZ(%esp), %eax	/* fn */
86
	lea	-8(%ecx), %ecx		/* make space on stack */
87
	movl	%ebx, 4(%ecx)		/*   fn arg */
88
	movl	%eax, 0(%ecx)		/*   fn */
89
90
	/* get other args to clone */
91
	movl	 8+FSZ(%esp), %ebx	/* flags */
92
	movl	20+FSZ(%esp), %edx	/* parent tid * */
93
	movl	16+FSZ(%esp), %edi	/* child tid * */
94
	movl	$__NR_clone, %eax
95
	int	$0x80
96
	testl	%eax, %eax
97
	jnz	1f
98
99
	/* CHILD - call thread function */
100
	popl	%eax
101
	call	*%eax
102
103
	/* exit with result */
104
	movl	%eax, %ebx
105
	movl	$__NR_exit, %eax
106
	int	$0x80
107
108
	/* Hm, exit returned */
109
	ud2
110
		
111
1:	/* PARENT or ERROR */
112
	pop	%edi
113
	pop	%ebx
114
	ret
115
	
116
##--------------------------------------------------------------------##
117
##--- end                                             vg_syscall.S ---##
118
##--------------------------------------------------------------------##
(-)valgrind-2.1.0/coregrind/demangle/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/coregrind/demangle/CVS/Entries (+11 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Mon Sep 23 11:36:28 2002//
2
/Makefile.am/1.11/Thu Jun 12 14:12:55 2003//
3
/ansidecl.h/1.1.1.1/Fri Mar 22 01:29:43 2002//
4
/cp-demangle.c/1.5/Fri Jul  4 16:14:15 2003//
5
/cplus-dem.c/1.5/Fri Jul  4 16:14:15 2003//
6
/demangle.h/1.1.1.1/Fri Mar 22 01:29:43 2002//
7
/dyn-string.c/1.4/Mon Feb 24 10:49:08 2003//
8
/dyn-string.h/1.1.1.1/Fri Mar 22 01:29:43 2002//
9
/safe-ctype.c/1.2/Mon Feb 24 10:49:08 2003//
10
/safe-ctype.h/1.1.1.1/Fri Mar 22 01:29:43 2002//
11
D
(-)valgrind-2.1.0/coregrind/demangle/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/coregrind/demangle
(-)valgrind-2.1.0/coregrind/demangle/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/coregrind/demangle/Makefile.in (-81 / +90 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 14-19 Link Here
14
14
15
@SET_MAKE@
15
@SET_MAKE@
16
16
17
18
SOURCES = $(libdemangle_a_SOURCES)
19
17
srcdir = @srcdir@
20
srcdir = @srcdir@
18
top_srcdir = @top_srcdir@
21
top_srcdir = @top_srcdir@
19
VPATH = @srcdir@
22
VPATH = @srcdir@
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
24
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
25
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
26
top_builddir = ../..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
27
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
28
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
29
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
38
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
39
POST_UNINSTALL = :
38
host_triplet = @host@
40
host_triplet = @host@
41
subdir = coregrind/demangle
42
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
43
	$(srcdir)/Makefile.in
44
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
45
am__aclocal_m4_deps = $(top_srcdir)/configure.in
46
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
47
	$(ACLOCAL_M4)
48
mkinstalldirs = $(mkdir_p)
49
CONFIG_HEADER = $(top_builddir)/config.h
50
CONFIG_CLEAN_FILES =
51
AR = ar
52
ARFLAGS = cru
53
LIBRARIES = $(noinst_LIBRARIES)
54
libdemangle_a_AR = $(AR) $(ARFLAGS)
55
libdemangle_a_LIBADD =
56
am_libdemangle_a_OBJECTS = cp-demangle.$(OBJEXT) cplus-dem.$(OBJEXT) \
57
	dyn-string.$(OBJEXT) safe-ctype.$(OBJEXT)
58
libdemangle_a_OBJECTS = $(am_libdemangle_a_OBJECTS)
59
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
60
depcomp = $(SHELL) $(top_srcdir)/depcomp
61
am__depfiles_maybe = depfiles
62
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cp-demangle.Po \
63
@AMDEP_TRUE@	./$(DEPDIR)/cplus-dem.Po ./$(DEPDIR)/dyn-string.Po \
64
@AMDEP_TRUE@	./$(DEPDIR)/safe-ctype.Po
65
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
66
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
67
CCLD = $(CC)
68
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
69
SOURCES = $(libdemangle_a_SOURCES)
70
DIST_SOURCES = $(libdemangle_a_SOURCES)
71
HEADERS = $(noinst_HEADERS)
72
ETAGS = etags
73
CTAGS = ctags
74
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
75
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
76
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
77
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
128
SHELL = @SHELL@
93
STRIP = @STRIP@
129
STRIP = @STRIP@
94
VERSION = @VERSION@
130
VERSION = @VERSION@
131
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
132
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
133
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
134
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
160
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
161
localstatedir = @localstatedir@
125
mandir = @mandir@
162
mandir = @mandir@
163
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
164
oldincludedir = @oldincludedir@
127
prefix = @prefix@
165
prefix = @prefix@
128
program_transform_name = @program_transform_name@
166
program_transform_name = @program_transform_name@
Lines 130-191 Link Here
130
sharedstatedir = @sharedstatedir@
168
sharedstatedir = @sharedstatedir@
131
sysconfdir = @sysconfdir@
169
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
170
target_alias = @target_alias@
133
134
AM_CPPFLAGS = -I$(top_srcdir)/coregrind -I$(top_srcdir)/include
171
AM_CPPFLAGS = -I$(top_srcdir)/coregrind -I$(top_srcdir)/include
135
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer -g
172
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer -g
136
137
noinst_HEADERS = \
173
noinst_HEADERS = \
138
	ansidecl.h     \
174
	ansidecl.h     \
139
	dyn-string.h   \
175
	dyn-string.h   \
140
	demangle.h     \
176
	demangle.h     \
141
	safe-ctype.h 
177
	safe-ctype.h 
142
178
143
144
noinst_LIBRARIES = libdemangle.a
179
noinst_LIBRARIES = libdemangle.a
145
146
libdemangle_a_SOURCES = \
180
libdemangle_a_SOURCES = \
147
	cp-demangle.c cplus-dem.c dyn-string.c safe-ctype.c
181
	cp-demangle.c cplus-dem.c dyn-string.c safe-ctype.c
148
182
149
subdir = coregrind/demangle
150
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
151
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
152
CONFIG_HEADER = $(top_builddir)/config.h
153
CONFIG_CLEAN_FILES =
154
LIBRARIES = $(noinst_LIBRARIES)
155
156
libdemangle_a_AR = $(AR) cru
157
libdemangle_a_LIBADD =
158
am_libdemangle_a_OBJECTS = cp-demangle.$(OBJEXT) cplus-dem.$(OBJEXT) \
159
	dyn-string.$(OBJEXT) safe-ctype.$(OBJEXT)
160
libdemangle_a_OBJECTS = $(am_libdemangle_a_OBJECTS)
161
162
DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
163
depcomp = $(SHELL) $(top_srcdir)/depcomp
164
am__depfiles_maybe = depfiles
165
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cp-demangle.Po \
166
@AMDEP_TRUE@	./$(DEPDIR)/cplus-dem.Po ./$(DEPDIR)/dyn-string.Po \
167
@AMDEP_TRUE@	./$(DEPDIR)/safe-ctype.Po
168
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
169
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
170
CCLD = $(CC)
171
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
172
DIST_SOURCES = $(libdemangle_a_SOURCES)
173
HEADERS = $(noinst_HEADERS)
174
175
DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in
176
SOURCES = $(libdemangle_a_SOURCES)
177
178
all: all-am
183
all: all-am
179
184
180
.SUFFIXES:
185
.SUFFIXES:
181
.SUFFIXES: .c .o .obj
186
.SUFFIXES: .c .o .obj
182
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
187
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
188
	@for dep in $?; do \
189
	  case '$(am__configure_deps)' in \
190
	    *$$dep*) \
191
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
192
		&& exit 0; \
193
	      exit 1;; \
194
	  esac; \
195
	done; \
196
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  coregrind/demangle/Makefile'; \
183
	cd $(top_srcdir) && \
197
	cd $(top_srcdir) && \
184
	  $(AUTOMAKE) --gnu  coregrind/demangle/Makefile
198
	  $(AUTOMAKE) --gnu  coregrind/demangle/Makefile
185
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
199
.PRECIOUS: Makefile
186
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
200
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
187
201
	@case '$?' in \
188
AR = ar
202
	  *config.status*) \
203
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
204
	  *) \
205
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
206
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
207
	esac;
208
209
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
210
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
211
212
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
213
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
214
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
215
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
189
216
190
clean-noinstLIBRARIES:
217
clean-noinstLIBRARIES:
191
	-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
218
	-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
Lines 195-201 Link Here
195
	$(RANLIB) libdemangle.a
222
	$(RANLIB) libdemangle.a
196
223
197
mostlyclean-compile:
224
mostlyclean-compile:
198
	-rm -f *.$(OBJEXT) core *.core
225
	-rm -f *.$(OBJEXT)
199
226
200
distclean-compile:
227
distclean-compile:
201
	-rm -f *.tab.c
228
	-rm -f *.tab.c
Lines 205-244 Link Here
205
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dyn-string.Po@am__quote@
232
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dyn-string.Po@am__quote@
206
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/safe-ctype.Po@am__quote@
233
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/safe-ctype.Po@am__quote@
207
234
208
distclean-depend:
209
	-rm -rf ./$(DEPDIR)
210
211
.c.o:
235
.c.o:
212
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
236
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
213
@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
237
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
214
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
215
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
216
@am__fastdepCC_TRUE@	fi
217
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
238
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
218
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
239
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
219
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
240
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
220
@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
241
@am__fastdepCC_FALSE@	$(COMPILE) -c $<
221
242
222
.c.obj:
243
.c.obj:
223
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
244
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
224
@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
245
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
225
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
226
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
227
@am__fastdepCC_TRUE@	fi
228
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
246
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
229
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
247
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
230
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
248
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
231
@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
249
@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
232
uninstall-info-am:
250
uninstall-info-am:
233
251
234
ETAGS = etags
235
ETAGSFLAGS =
236
237
CTAGS = ctags
238
CTAGSFLAGS =
239
240
tags: TAGS
241
242
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
252
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
243
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
253
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
244
	unique=`for i in $$list; do \
254
	unique=`for i in $$list; do \
Lines 247-252 Link Here
247
	  $(AWK) '    { files[$$0] = 1; } \
257
	  $(AWK) '    { files[$$0] = 1; } \
248
	       END { for (i in files) print i; }'`; \
258
	       END { for (i in files) print i; }'`; \
249
	mkid -fID $$unique
259
	mkid -fID $$unique
260
tags: TAGS
250
261
251
TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
262
TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
252
		$(TAGS_FILES) $(LISP)
263
		$(TAGS_FILES) $(LISP)
Lines 261-267 Link Here
261
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
272
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
262
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
273
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
263
	     $$tags $$unique
274
	     $$tags $$unique
264
265
ctags: CTAGS
275
ctags: CTAGS
266
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
276
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
267
		$(TAGS_FILES) $(LISP)
277
		$(TAGS_FILES) $(LISP)
Lines 284-293 Link Here
284
294
285
distclean-tags:
295
distclean-tags:
286
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
296
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
287
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
288
289
top_distdir = ../..
290
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
291
297
292
distdir: $(DISTFILES)
298
distdir: $(DISTFILES)
293
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
299
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 301-307 Link Here
301
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
307
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
302
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
308
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
303
	    dir="/$$dir"; \
309
	    dir="/$$dir"; \
304
	    $(mkinstalldirs) "$(distdir)$$dir"; \
310
	    $(mkdir_p) "$(distdir)$$dir"; \
305
	  else \
311
	  else \
306
	    dir=''; \
312
	    dir=''; \
307
	  fi; \
313
	  fi; \
Lines 319-325 Link Here
319
check-am: all-am
325
check-am: all-am
320
check: check-am
326
check: check-am
321
all-am: Makefile $(LIBRARIES) $(HEADERS)
327
all-am: Makefile $(LIBRARIES) $(HEADERS)
322
323
installdirs:
328
installdirs:
324
install: install-am
329
install: install-am
325
install-exec: install-exec-am
330
install-exec: install-exec-am
Lines 332-338 Link Here
332
installcheck: installcheck-am
337
installcheck: installcheck-am
333
install-strip:
338
install-strip:
334
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
339
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
335
	  INSTALL_STRIP_FLAG=-s \
340
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
336
	  `test -z '$(STRIP)' || \
341
	  `test -z '$(STRIP)' || \
337
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
342
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
338
mostlyclean-generic:
343
mostlyclean-generic:
Lines 340-346 Link Here
340
clean-generic:
345
clean-generic:
341
346
342
distclean-generic:
347
distclean-generic:
343
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
348
	-rm -f $(CONFIG_CLEAN_FILES)
344
349
345
maintainer-clean-generic:
350
maintainer-clean-generic:
346
	@echo "This command is intended for maintainers to use"
351
	@echo "This command is intended for maintainers to use"
Lines 350-363 Link Here
350
clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
355
clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
351
356
352
distclean: distclean-am
357
distclean: distclean-am
353
358
	-rm -rf ./$(DEPDIR)
354
distclean-am: clean-am distclean-compile distclean-depend \
359
	-rm -f Makefile
355
	distclean-generic distclean-tags
360
distclean-am: clean-am distclean-compile distclean-generic \
361
	distclean-tags
356
362
357
dvi: dvi-am
363
dvi: dvi-am
358
364
359
dvi-am:
365
dvi-am:
360
366
367
html: html-am
368
361
info: info-am
369
info: info-am
362
370
363
info-am:
371
info-am:
Lines 373-379 Link Here
373
installcheck-am:
381
installcheck-am:
374
382
375
maintainer-clean: maintainer-clean-am
383
maintainer-clean: maintainer-clean-am
376
384
	-rm -rf ./$(DEPDIR)
385
	-rm -f Makefile
377
maintainer-clean-am: distclean-am maintainer-clean-generic
386
maintainer-clean-am: distclean-am maintainer-clean-generic
378
387
379
mostlyclean: mostlyclean-am
388
mostlyclean: mostlyclean-am
Lines 392-399 Link Here
392
401
393
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
402
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
394
	clean-noinstLIBRARIES ctags distclean distclean-compile \
403
	clean-noinstLIBRARIES ctags distclean distclean-compile \
395
	distclean-depend distclean-generic distclean-tags distdir dvi \
404
	distclean-generic distclean-tags distdir dvi dvi-am html \
396
	dvi-am info info-am install install-am install-data \
405
	html-am info info-am install install-am install-data \
397
	install-data-am install-exec install-exec-am install-info \
406
	install-data-am install-exec install-exec-am install-info \
398
	install-info-am install-man install-strip installcheck \
407
	install-info-am install-man install-strip installcheck \
399
	installcheck-am installdirs maintainer-clean \
408
	installcheck-am installdirs maintainer-clean \
(-)valgrind-2.1.0/coregrind/docs/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/coregrind/docs/CVS/Entries (+6 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Mon Sep 23 11:36:29 2002//
2
/Makefile.am/1.4/Fri Nov 14 17:47:52 2003//
3
/coregrind_core.html/1.26/Sun Feb  1 17:29:59 2004//
4
/coregrind_intro.html/1.8/Wed Jan 21 13:59:23 2004//
5
/coregrind_tools.html/1.1/Fri Nov 14 17:47:52 2003//
6
D
(-)valgrind-2.1.0/coregrind/docs/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/coregrind/docs
(-)valgrind-2.1.0/coregrind/docs/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/coregrind/docs/Makefile.in (-38 / +64 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
21
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
23
top_builddir = ../..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
25
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
26
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
35
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
36
POST_UNINSTALL = :
38
host_triplet = @host@
37
host_triplet = @host@
38
subdir = coregrind/docs
39
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
40
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
41
am__aclocal_m4_deps = $(top_srcdir)/configure.in
42
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
43
	$(ACLOCAL_M4)
44
mkinstalldirs = $(mkdir_p)
45
CONFIG_HEADER = $(top_builddir)/config.h
46
CONFIG_CLEAN_FILES =
47
SOURCES =
48
DIST_SOURCES =
49
am__installdirs = $(DESTDIR)$(docdir)
50
docDATA_INSTALL = $(INSTALL_DATA)
51
DATA = $(doc_DATA)
52
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
53
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
54
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
55
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
106
SHELL = @SHELL@
93
STRIP = @STRIP@
107
STRIP = @STRIP@
94
VERSION = @VERSION@
108
VERSION = @VERSION@
109
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
110
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
111
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
112
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
138
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
139
localstatedir = @localstatedir@
125
mandir = @mandir@
140
mandir = @mandir@
141
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
142
oldincludedir = @oldincludedir@
127
prefix = @prefix@
143
prefix = @prefix@
128
program_transform_name = @program_transform_name@
144
program_transform_name = @program_transform_name@
Lines 131-162 Link Here
131
sysconfdir = @sysconfdir@
147
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
148
target_alias = @target_alias@
133
docdir = $(datadir)/doc/valgrind
149
docdir = $(datadir)/doc/valgrind
134
135
doc_DATA = coregrind_core.html coregrind_intro.html coregrind_tools.html
150
doc_DATA = coregrind_core.html coregrind_intro.html coregrind_tools.html
136
137
EXTRA_DIST = $(doc_DATA)
151
EXTRA_DIST = $(doc_DATA)
138
subdir = coregrind/docs
139
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
140
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
141
CONFIG_HEADER = $(top_builddir)/config.h
142
CONFIG_CLEAN_FILES =
143
DIST_SOURCES =
144
DATA = $(doc_DATA)
145
146
DIST_COMMON = Makefile.am Makefile.in
147
all: all-am
152
all: all-am
148
153
149
.SUFFIXES:
154
.SUFFIXES:
150
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
155
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
156
	@for dep in $?; do \
157
	  case '$(am__configure_deps)' in \
158
	    *$$dep*) \
159
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
160
		&& exit 0; \
161
	      exit 1;; \
162
	  esac; \
163
	done; \
164
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  coregrind/docs/Makefile'; \
151
	cd $(top_srcdir) && \
165
	cd $(top_srcdir) && \
152
	  $(AUTOMAKE) --gnu  coregrind/docs/Makefile
166
	  $(AUTOMAKE) --gnu  coregrind/docs/Makefile
153
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
167
.PRECIOUS: Makefile
154
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
168
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
169
	@case '$?' in \
170
	  *config.status*) \
171
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
172
	  *) \
173
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
174
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
175
	esac;
176
177
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
178
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
179
180
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
181
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
182
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
183
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
155
uninstall-info-am:
184
uninstall-info-am:
156
docDATA_INSTALL = $(INSTALL_DATA)
157
install-docDATA: $(doc_DATA)
185
install-docDATA: $(doc_DATA)
158
	@$(NORMAL_INSTALL)
186
	@$(NORMAL_INSTALL)
159
	$(mkinstalldirs) $(DESTDIR)$(docdir)
187
	$(mkdir_p) $(DESTDIR)$(docdir)
160
	@list='$(doc_DATA)'; for p in $$list; do \
188
	@list='$(doc_DATA)'; for p in $$list; do \
161
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
189
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
162
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
190
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
Lines 177-186 Link Here
177
ctags: CTAGS
205
ctags: CTAGS
178
CTAGS:
206
CTAGS:
179
207
180
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
181
182
top_distdir = ../..
183
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
184
208
185
distdir: $(DISTFILES)
209
distdir: $(DISTFILES)
186
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
210
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 194-200 Link Here
194
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
218
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
195
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
219
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
196
	    dir="/$$dir"; \
220
	    dir="/$$dir"; \
197
	    $(mkinstalldirs) "$(distdir)$$dir"; \
221
	    $(mkdir_p) "$(distdir)$$dir"; \
198
	  else \
222
	  else \
199
	    dir=''; \
223
	    dir=''; \
200
	  fi; \
224
	  fi; \
Lines 212-220 Link Here
212
check-am: all-am
236
check-am: all-am
213
check: check-am
237
check: check-am
214
all-am: Makefile $(DATA)
238
all-am: Makefile $(DATA)
215
216
installdirs:
239
installdirs:
217
	$(mkinstalldirs) $(DESTDIR)$(docdir)
240
	$(mkdir_p) $(DESTDIR)$(docdir)
218
install: install-am
241
install: install-am
219
install-exec: install-exec-am
242
install-exec: install-exec-am
220
install-data: install-data-am
243
install-data: install-data-am
Lines 226-232 Link Here
226
installcheck: installcheck-am
249
installcheck: installcheck-am
227
install-strip:
250
install-strip:
228
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
251
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
229
	  INSTALL_STRIP_FLAG=-s \
252
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
230
	  `test -z '$(STRIP)' || \
253
	  `test -z '$(STRIP)' || \
231
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
254
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
232
mostlyclean-generic:
255
mostlyclean-generic:
Lines 234-240 Link Here
234
clean-generic:
257
clean-generic:
235
258
236
distclean-generic:
259
distclean-generic:
237
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
260
	-rm -f $(CONFIG_CLEAN_FILES)
238
261
239
maintainer-clean-generic:
262
maintainer-clean-generic:
240
	@echo "This command is intended for maintainers to use"
263
	@echo "This command is intended for maintainers to use"
Lines 244-256 Link Here
244
clean-am: clean-generic mostlyclean-am
267
clean-am: clean-generic mostlyclean-am
245
268
246
distclean: distclean-am
269
distclean: distclean-am
247
270
	-rm -f Makefile
248
distclean-am: clean-am distclean-generic
271
distclean-am: clean-am distclean-generic
249
272
250
dvi: dvi-am
273
dvi: dvi-am
251
274
252
dvi-am:
275
dvi-am:
253
276
277
html: html-am
278
254
info: info-am
279
info: info-am
255
280
256
info-am:
281
info-am:
Lines 266-272 Link Here
266
installcheck-am:
291
installcheck-am:
267
292
268
maintainer-clean: maintainer-clean-am
293
maintainer-clean: maintainer-clean-am
269
294
	-rm -f Makefile
270
maintainer-clean-am: distclean-am maintainer-clean-generic
295
maintainer-clean-am: distclean-am maintainer-clean-generic
271
296
272
mostlyclean: mostlyclean-am
297
mostlyclean: mostlyclean-am
Lines 284-296 Link Here
284
uninstall-am: uninstall-docDATA uninstall-info-am
309
uninstall-am: uninstall-docDATA uninstall-info-am
285
310
286
.PHONY: all all-am check check-am clean clean-generic distclean \
311
.PHONY: all all-am check check-am clean clean-generic distclean \
287
	distclean-generic distdir dvi dvi-am info info-am install \
312
	distclean-generic distdir dvi dvi-am html html-am info info-am \
288
	install-am install-data install-data-am install-docDATA \
313
	install install-am install-data install-data-am \
289
	install-exec install-exec-am install-info install-info-am \
314
	install-docDATA install-exec install-exec-am install-info \
290
	install-man install-strip installcheck installcheck-am \
315
	install-info-am install-man install-strip installcheck \
291
	installdirs maintainer-clean maintainer-clean-generic \
316
	installcheck-am installdirs maintainer-clean \
292
	mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
317
	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
293
	uninstall-am uninstall-docDATA uninstall-info-am
318
	pdf-am ps ps-am uninstall uninstall-am uninstall-docDATA \
319
	uninstall-info-am
294
320
295
# Tell versions [3.59,3.63) of GNU make to not export all variables.
321
# Tell versions [3.59,3.63) of GNU make to not export all variables.
296
# Otherwise a system limit (for SysV at least) may be exceeded.
322
# Otherwise a system limit (for SysV at least) may be exceeded.
(-)valgrind-2.1.0/coregrind/docs/coregrind_core.html (-127 / +132 lines)
Lines 1-9 Link Here
1
1
2
2
3
<a name="core"></a>
3
<a name="core"></a>
4
<h2>2&nbsp; Using and understanding the Valgrind core services</h2>
4
<h2>2&nbsp; Using and understanding the Valgrind core</h2>
5
5
6
This section describes the core services, flags and behaviours.  That
6
This section describes the Valgrind core services, flags and behaviours.  That
7
means it is relevant regardless of what particular tool you are using.
7
means it is relevant regardless of what particular tool you are using.
8
A point of terminology: most references to "valgrind" in the rest of
8
A point of terminology: most references to "valgrind" in the rest of
9
this section (Section 2) refer to the valgrind core services.
9
this section (Section 2) refer to the valgrind core services.
Lines 14-43 Link Here
14
14
15
Valgrind is designed to be as non-intrusive as possible. It works
15
Valgrind is designed to be as non-intrusive as possible. It works
16
directly with existing executables. You don't need to recompile,
16
directly with existing executables. You don't need to recompile,
17
relink, or otherwise modify, the program to be checked. Simply place
17
relink, or otherwise modify, the program to be checked.
18
the word <code>valgrind</code> at the start of the command line
19
normally used to run the program, and tell it what tool you want to
20
use.
21
18
22
<p>
19
Simply put <code>valgrind --tool=<i>tool_name</i></code> at the start of
23
So, for example, if you want to run the command <code>ls -l</code>
20
the command line normally used to run the program.  For example,
24
using the heavyweight memory-checking tool, issue the command:
21
if want to run the command <code>ls -l</code>
25
<code>valgrind --tool=memcheck ls -l</code>.  The <code>--tool=</code>
22
using the heavyweight memory-checking tool Memcheck, issue the command:
26
parameter tells the core which tool is to be used.
23
27
24
  <blockquote>
28
<p>
25
  <code>valgrind --tool=memcheck ls -l</code>.  
29
To preserve compatibility with the 1.0.X series, if you do not specify
26
  </blockquote>
30
a tool, the default is to use Memcheck.  That means the above
31
example simplifies to: <code>valgrind ls -l</code>.
32
27
33
<p>Regardless of which tool is in use, Valgrind takes control of your
28
<p>Regardless of which tool is in use, Valgrind takes control of your
34
program before it starts.  Debugging information is read from the
29
program before it starts.  Debugging information is read from the
35
executable and associated libraries, so that error messages can be
30
executable and associated libraries, so that error messages and other
36
phrased in terms of source code locations (if that is appropriate).
31
outputs can be phrased in terms of source code locations (if that is
32
appropriate)
37
33
38
<p>
34
<p>
39
Your program is then run on a synthetic x86 CPU provided by the
35
Your program is then run on a synthetic x86 CPU provided by the
40
valgrind core.  As new code is executed for the first time, the core
36
Valgrind core.  As new code is executed for the first time, the core
41
hands the code to the selected tool.  The tool adds its own
37
hands the code to the selected tool.  The tool adds its own
42
instrumentation code to this and hands the result back to the core,
38
instrumentation code to this and hands the result back to the core,
43
which coordinates the continued execution of this instrumented code.
39
which coordinates the continued execution of this instrumented code.
Lines 48-55 Link Here
48
memory access and every value computed, increasing the size of the
44
memory access and every value computed, increasing the size of the
49
code at least 12 times, and making it run 25-50 times slower than
45
code at least 12 times, and making it run 25-50 times slower than
50
natively.  At the other end of the spectrum, the ultra-trivial "none"
46
natively.  At the other end of the spectrum, the ultra-trivial "none"
51
tool adds no instrumentation at all and causes in total "only" about a
47
tool (a.k.a. Nulgrind) adds no instrumentation at all and causes in total
52
4 times slowdown.  
48
"only" about a 4 times slowdown.  
53
49
54
<p>
50
<p>
55
Valgrind simulates every single instruction your program executes.
51
Valgrind simulates every single instruction your program executes.
Lines 59-87 Link Here
59
X client libraries, Qt, if you work with KDE, and so on.  
55
X client libraries, Qt, if you work with KDE, and so on.  
60
56
61
<p>
57
<p>
62
If -- as is usually the case -- you're using one of the
58
If you're using one of the error-detection tools, Valgrind will often
63
error-detection tools, valgrind will often detect errors in
59
detect errors in libraries, for example the GNU C or X11 libraries,
64
libraries, for example the GNU C or X11 libraries, which you have to
60
which you have to use.  You might not be interested in these errors,
65
use.  Since you're probably using valgrind to debug your own
61
since you probably have noo control over that code.  Therefore, Valgrind
66
application, and not those libraries, you don't want to see those
62
allows you to selectively suppress errors, by recording them in a
67
errors and probably can't fix them anyway.
63
suppressions file which is read when Valgrind starts up.  The build
68
64
mechanism attempts to select suppressions which give reasonable
69
<p>
65
behaviour for the libc and XFree86 versions detected on your machine.
70
So, rather than swamping you with errors in which you are not
66
To make it easier to write suppressions, you can use the
71
interested, Valgrind allows you to selectively suppress errors, by
67
<code>--gen-suppressions=yes</code> option which tells Valgrind to print
72
recording them in a suppressions file which is read when Valgrind
68
out a suppression for each error that appears, which you can then copy
73
starts up.  The build mechanism attempts to select suppressions which
69
into a suppressions file.
74
give reasonable behaviour for the libc and XFree86 versions detected
70
75
on your machine.  To make it easier to write suppressions, you can use
71
<p>
76
the <code>--gen-suppressions=yes</code> option which tells Valgrind to
72
Different error-checking tools report different kinds of errors.  The
77
print out a suppression for each error that appears, which you can
73
suppression mechanism therefore allows you to say which tool or tool(s)
78
then copy into a suppressions file.
74
each suppression applies to.
79
80
<p>
81
Different tools report different kinds of errors.  The suppression
82
mechanism therefore allows you to say which tool or tool(s) each
83
suppression applies to.
84
85
75
86
76
87
<a name="started"></a>
77
<a name="started"></a>
Lines 89-95 Link Here
89
79
90
First off, consider whether it might be beneficial to recompile your
80
First off, consider whether it might be beneficial to recompile your
91
application and supporting libraries with debugging info enabled (the
81
application and supporting libraries with debugging info enabled (the
92
<code>-g</code> flag).  Without debugging info, the best valgrind
82
<code>-g</code> flag).  Without debugging info, the best Valgrind tools
93
will be able to do is guess which function a particular piece of code
83
will be able to do is guess which function a particular piece of code
94
belongs to, which makes both error messages and profiling output
84
belongs to, which makes both error messages and profiling output
95
nearly useless.  With <code>-g</code>, you'll hopefully get messages
85
nearly useless.  With <code>-g</code>, you'll hopefully get messages
Lines 100-106 Link Here
100
C++, is <code>-fno-inline</code>.  That makes it easier to see the
90
C++, is <code>-fno-inline</code>.  That makes it easier to see the
101
function-call chain, which can help reduce confusion when navigating
91
function-call chain, which can help reduce confusion when navigating
102
around large C++ apps.  For whatever it's worth, debugging
92
around large C++ apps.  For whatever it's worth, debugging
103
OpenOffice.org with Valgrind is a bit easier when using this flag.
93
OpenOffice.org with Memcheck is a bit easier when using this flag.
104
94
105
<p>
95
<p>
106
You don't have to do this, but doing so helps Valgrind produce more
96
You don't have to do this, but doing so helps Valgrind produce more
Lines 109-116 Link Here
109
or some other debugger.
99
or some other debugger.
110
100
111
<p>
101
<p>
112
This paragraph applies only if you plan to use Memcheck
102
This paragraph applies only if you plan to use Memcheck:
113
(which is the default): On rare occasions, optimisation levels
103
On rare occasions, optimisation levels
114
at <code>-O2</code> and above have been observed to generate code which
104
at <code>-O2</code> and above have been observed to generate code which
115
fools Memcheck into wrongly reporting uninitialised value
105
fools Memcheck into wrongly reporting uninitialised value
116
errors.  We have looked in detail into fixing this, and unfortunately 
106
errors.  We have looked in detail into fixing this, and unfortunately 
Lines 132-138 Link Here
132
122
133
<p>
123
<p>
134
When you're ready to roll, just run your application as you would
124
When you're ready to roll, just run your application as you would
135
normally, but place <code>valgrind --tool=the-selected-tool</code> in
125
normally, but place <code>valgrind --tool=<i>tool_name</i></code> in
136
front of your usual command-line invocation.  Note that you should run
126
front of your usual command-line invocation.  Note that you should run
137
the real (machine-code) executable here.  If your application is
127
the real (machine-code) executable here.  If your application is
138
started by, for example, a shell or perl script, you'll need to modify
128
started by, for example, a shell or perl script, you'll need to modify
Lines 147-153 Link Here
147
<a name="comment"></a>
137
<a name="comment"></a>
148
<h3>2.3&nbsp; The commentary</h3>
138
<h3>2.3&nbsp; The commentary</h3>
149
139
150
Valgrind writes a commentary, a stream of text, detailing error
140
Valgrind tools write a commentary, a stream of text, detailing error
151
reports and other significant events.  All lines in the commentary
141
reports and other significant events.  All lines in the commentary
152
have following form:<br>
142
have following form:<br>
153
<pre>
143
<pre>
Lines 159-172 Link Here
159
to differentiate commentaries from different processes which have
149
to differentiate commentaries from different processes which have
160
become merged together, for whatever reason.
150
become merged together, for whatever reason.
161
151
162
<p>By default, Valgrind writes only essential messages to the commentary,
152
<p>By default, Valgrind tools write only essential messages to the commentary,
163
so as to avoid flooding you with information of secondary importance.
153
so as to avoid flooding you with information of secondary importance.
164
If you want more information about what is happening, re-run, passing
154
If you want more information about what is happening, re-run, passing
165
the <code>-v</code> flag to Valgrind.
155
the <code>-v</code> flag to Valgrind.
166
156
167
<p>
157
<p>
168
Version 2 of valgrind gives significantly more flexibility than 1.0.X
158
You can direct the commentary to three different places:
169
does about where that stream is sent to.  You have three options:
170
159
171
<ul>
160
<ul>
172
<li>The default: send it to a file descriptor, which is by default 2
161
<li>The default: send it to a file descriptor, which is by default 2
Lines 195-203 Link Here
195
    defined by the constant <code>VG_CLO_DEFAULT_LOGPORT</code>
184
    defined by the constant <code>VG_CLO_DEFAULT_LOGPORT</code>
196
    in the sources.
185
    in the sources.
197
    <p>
186
    <p>
198
    Note, unfortunately, that you have to use an IP address here --
187
    Note, unfortunately, that you have to use an IP address here, rather
199
    for technical reasons, valgrind's core itself can't use the GNU C
188
    than a hostname.
200
    library, and this makes it difficult to do hostname-to-IP lookups.
201
    <p>
189
    <p>
202
    Writing to a network socket is pretty useless if you don't have
190
    Writing to a network socket is pretty useless if you don't have
203
    something listening at the other end.  We provide a simple
191
    something listening at the other end.  We provide a simple
Lines 221-232 Link Here
221
    <li><code>portnumber</code>: changes the port it listens on from
209
    <li><code>portnumber</code>: changes the port it listens on from
222
        the default (1500).  The specified port must be in the range
210
        the default (1500).  The specified port must be in the range
223
        1024 to 65535.  The same restriction applies to port numbers
211
        1024 to 65535.  The same restriction applies to port numbers
224
        specified by a <code>--logsocket=</code> to valgrind itself.
212
        specified by a <code>--logsocket=</code> to Valgrind itself.
225
    </ul>
213
    </ul>
226
    <p>
214
    <p>
227
    If a valgrinded process fails to connect to a listener, for
215
    If a valgrinded process fails to connect to a listener, for
228
    whatever reason (the listener isn't running, invalid or
216
    whatever reason (the listener isn't running, invalid or
229
    unreachable host or port, etc), valgrind switches back to writing
217
    unreachable host or port, etc), Valgrind switches back to writing
230
    the commentary to stderr.  The same goes for any process which
218
    the commentary to stderr.  The same goes for any process which
231
    loses an established connection to a listener.  In other words,
219
    loses an established connection to a listener.  In other words,
232
    killing the listener doesn't kill the processes sending data to
220
    killing the listener doesn't kill the processes sending data to
Lines 235-241 Link Here
235
<p>
223
<p>
236
Here is an important point about the relationship between the
224
Here is an important point about the relationship between the
237
commentary and profiling output from tools.  The commentary contains a
225
commentary and profiling output from tools.  The commentary contains a
238
mix of messages from the valgrind core and the selected tool.  If the
226
mix of messages from the Valgrind core and the selected tool.  If the
239
tool reports errors, it will report them to the commentary.  However,
227
tool reports errors, it will report them to the commentary.  However,
240
if the tool does profiling, the profile data will be written to a file
228
if the tool does profiling, the profile data will be written to a file
241
of some kind, depending on the tool, and independent of what
229
of some kind, depending on the tool, and independent of what
Lines 311-317 Link Here
311
299
312
<p>
300
<p>
313
To avoid this cutoff you can use the <code>--error-limit=no</code>
301
To avoid this cutoff you can use the <code>--error-limit=no</code>
314
flag.  Then valgrind will always show errors, regardless of how many
302
flag.  Then Valgrind will always show errors, regardless of how many
315
there are.  Use this flag carefully, since it may have a dire effect
303
there are.  Use this flag carefully, since it may have a dire effect
316
on performance.
304
on performance.
317
305
Lines 386-392 Link Here
386
      </pre>
374
      </pre>
387
      (Nb: no spaces are allowed).
375
      (Nb: no spaces are allowed).
388
      <p>      
376
      <p>      
389
      Recall that valgrind-2.0.X is a modular system, in which
377
      Recall that Valgrind-2.0.X is a modular system, in which
390
      different instrumentation tools can observe your program whilst
378
      different instrumentation tools can observe your program whilst
391
      it is running.  Since different tools detect different kinds of
379
      it is running.  Since different tools detect different kinds of
392
      errors, it is necessary to say which tool(s) the suppression is
380
      errors, it is necessary to say which tool(s) the suppression is
Lines 478-497 Link Here
478
<h3>2.6&nbsp; Command-line flags for the Valgrind core</h3>
466
<h3>2.6&nbsp; Command-line flags for the Valgrind core</h3>
479
467
480
468
481
As mentioned above, valgrind's core accepts a common set of flags.
469
As mentioned above, Valgrind's core accepts a common set of flags.
482
The tools also accept tool-specific flags, which are documented
470
The tools also accept tool-specific flags, which are documented
483
seperately for each tool.  
471
seperately for each tool.  
484
472
485
You invoke Valgrind like this:
473
You invoke Valgrind like this:
486
<pre>
474
<pre>
487
  valgrind [options-for-Valgrind] your-prog [options for your-prog]
475
  valgrind --tool=<i>tool_name</i> [options-for-Valgrind] your-prog [options for your-prog]
488
</pre>
476
</pre>
489
477
490
<p>Note that Valgrind also reads options from the environment variable
491
<code>$VALGRIND_OPTS</code>, and processes them before the command-line
492
options.  Options for the valgrind core may be freely mixed with those
493
for the selected tool.
494
495
<p>Valgrind's default settings succeed in giving reasonable behaviour
478
<p>Valgrind's default settings succeed in giving reasonable behaviour
496
in most cases.  We group the available options by rough categories.
479
in most cases.  We group the available options by rough categories.
497
480
Lines 512-519 Link Here
512
      <p>Show help for all options, both for the core and for the
495
      <p>Show help for all options, both for the core and for the
513
      selected tool. </li><br><p>
496
      selected tool. </li><br><p>
514
497
498
  <li><code>--help-debug</code><br>
499
      <p>Same as <code>--help</code>, but also lists debugging options which
500
      usually are only of use to developers.</li><br><p>
501
515
  <li><code>--version</code><br> <p>Show the version number of the
502
  <li><code>--version</code><br> <p>Show the version number of the
516
      valgrind core.  Tools can have their own version numbers.  There
503
      Valgrind core.  Tools can have their own version numbers.  There
517
      is a scheme in place to ensure that tools only execute when the
504
      is a scheme in place to ensure that tools only execute when the
518
      core version is one they are known to work with.  This was done
505
      core version is one they are known to work with.  This was done
519
      to minimise the chances of strange problems arising from
506
      to minimise the chances of strange problems arising from
Lines 558-564 Link Here
558
      <p>Specifies that Valgrind should send all of its messages to
545
      <p>Specifies that Valgrind should send all of its messages to
559
      the specified port at the specified IP address.  The port may be
546
      the specified port at the specified IP address.  The port may be
560
      omitted, in which case port 1500 is used.  If a connection
547
      omitted, in which case port 1500 is used.  If a connection
561
      cannot be made to the specified socket, valgrind falls back to
548
      cannot be made to the specified socket, Valgrind falls back to
562
      writing output to the standard error (stderr).  This option is
549
      writing output to the standard error (stderr).  This option is
563
      intended to be used in conjunction with the
550
      intended to be used in conjunction with the
564
      <code>valgrind-listener</code> program.  For further details,
551
      <code>valgrind-listener</code> program.  For further details,
Lines 603-609 Link Here
603
      </li><br><p>
590
      </li><br><p>
604
591
605
  <li><code>--error-limit=yes</code> [default]<br>
592
  <li><code>--error-limit=yes</code> [default]<br>
606
      <code>--error-limit=no</code> <p>When enabled, valgrind stops
593
      <code>--error-limit=no</code> <p>When enabled, Valgrind stops
607
      reporting errors after 30000 in total, or 300 different ones,
594
      reporting errors after 30000 in total, or 300 different ones,
608
      have been seen.  This is to stop the error tracking machinery
595
      have been seen.  This is to stop the error tracking machinery
609
      from becoming a huge performance overhead in programs with many
596
      from becoming a huge performance overhead in programs with many
Lines 633-639 Link Here
633
      <br>
620
      <br>
634
      <code>---- Print suppression ? --- [Return/N/n/Y/y/C/c] ----</code>
621
      <code>---- Print suppression ? --- [Return/N/n/Y/y/C/c] ----</code>
635
      <p>
622
      <p>
636
      The prompt's behaviour is the same as for the <code>--gdb-attach</code>
623
      The prompt's behaviour is the same as for the <code>--db-attach</code>
637
      option.
624
      option.
638
      <p>
625
      <p>
639
      If you choose to, Valgrind will print out a suppression for this error.
626
      If you choose to, Valgrind will print out a suppression for this error.
Lines 663-690 Link Here
663
      socket details.
650
      socket details.
664
      <br><p>
651
      <br><p>
665
652
666
  <li><code>--gdb-attach=no</code> [default]<br>
653
  <li><code>--db-attach=no</code> [default]<br>
667
      <code>--gdb-attach=yes</code>
654
      <code>--db-attach=yes</code>
668
      <p>When enabled, Valgrind will pause after every error shown,
655
      <p>When enabled, Valgrind will pause after every error shown,
669
      and print the line
656
      and print the line
670
      <br>
657
      <br>
671
      <code>---- Attach to GDB ? --- [Return/N/n/Y/y/C/c] ----</code>
658
      <code>---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ----</code>
672
      <p>
659
      <p>
673
      Pressing <code>Ret</code>, or <code>N</code> <code>Ret</code>
660
      Pressing <code>Ret</code>, or <code>N</code> <code>Ret</code>
674
      or <code>n</code> <code>Ret</code>, causes Valgrind not to
661
      or <code>n</code> <code>Ret</code>, causes Valgrind not to
675
      start GDB for this error.
662
      start a debugger for this error.
676
      <p>
663
      <p>
677
      <code>Y</code> <code>Ret</code>
664
      <code>Y</code> <code>Ret</code>
678
      or <code>y</code> <code>Ret</code> causes Valgrind to
665
      or <code>y</code> <code>Ret</code> causes Valgrind to
679
      start GDB, for the program at this point.  When you have
666
      start a debugger, for the program at this point.  When you have
680
      finished with GDB, quit from it, and the program will continue.
667
      finished with the debugger, quit from it, and the program will continue.
681
      Trying to continue from inside GDB doesn't work.
668
      Trying to continue from inside the debugger doesn't work.
682
      <p>
669
      <p>
683
      <code>C</code> <code>Ret</code>
670
      <code>C</code> <code>Ret</code>
684
      or <code>c</code> <code>Ret</code> causes Valgrind not to
671
      or <code>c</code> <code>Ret</code> causes Valgrind not to
685
      start GDB, and not to ask again.
672
      start a debugger, and not to ask again.
686
      <p>
673
      <p>
687
      <code>--gdb-attach=yes</code> conflicts with
674
      <code>--db-attach=yes</code> conflicts with
688
      <code>--trace-children=yes</code>.  You can't use them together.
675
      <code>--trace-children=yes</code>.  You can't use them together.
689
      Valgrind refuses to start up in this situation.  1 May 2002:
676
      Valgrind refuses to start up in this situation.  1 May 2002:
690
      this is a historical relic which could be easily fixed if it
677
      this is a historical relic which could be easily fixed if it
Lines 695-710 Link Here
695
      socket, I guess this option doesn't make any sense.  Caveat emptor.
682
      socket, I guess this option doesn't make any sense.  Caveat emptor.
696
      </li><br><p>
683
      </li><br><p>
697
684
698
  <li><code>--gdb-path=/path/to/gdb</code>
685
  <li><code>--db-command=&lt;command&gt;</code> [default: gdb -nw %f %p]<br>
699
      <p>This specifies how Valgrind will invoke GDB.  By default, it
686
      <p>This specifies how Valgrind will invoke the debugger.  By
700
      will use whatever GDB is detected at build time, 
687
      default it will use whatever GDB is detected at build time, 
701
      which is usually <code>/usr/bin/gdb</code>.  Using this command,
688
      which is usually <code>/usr/bin/gdb</code>.  Using this command,
702
      you can specify some alternative path to the GDB you want to
689
      you can specify some alternative command to invoke the debugger
703
      use.
690
      you want to use.
691
      <p>
692
      The command string given can include one or instances of the
693
      %p and %f expansions. Each instance of %p expands to the PID of
694
      the process to be debugged and each instance of %f expands to
695
      the path to the executable for the process to be debugged.
704
      </li><br><p>
696
      </li><br><p>
705
697
706
  <li><code>--input-fd=&lt;number&gt;</code> [default=0, stdin]<br>
698
  <li><code>--input-fd=&lt;number&gt;</code> [default=0, stdin]<br>
707
      <p>When using <code>--gdb-attach=yes</code> and 
699
      <p>When using <code>--db-attach=yes</code> and 
708
         <code>--gen-suppressions=yes</code>, Valgrind will stop
700
         <code>--gen-suppressions=yes</code>, Valgrind will stop
709
      so as to read keyboard input from you, when each error occurs. 
701
      so as to read keyboard input from you, when each error occurs. 
710
      By default it reads from the standard input (stdin), which is
702
      By default it reads from the standard input (stdin), which is
Lines 719-732 Link Here
719
and Addrcheck), the following options apply.
711
and Addrcheck), the following options apply.
720
<ul>
712
<ul>
721
  <li><code>--alignment=&lt;number&gt;</code> [default: 4]<br> <p>By
713
  <li><code>--alignment=&lt;number&gt;</code> [default: 4]<br> <p>By
722
      default valgrind's <code>malloc</code>, <code>realloc</code>,
714
      default Valgrind's <code>malloc</code>, <code>realloc</code>,
723
      etc, return 4-byte aligned addresses.  These are suitable for
715
      etc, return 4-byte aligned addresses.  These are suitable for
724
      any accesses on x86 processors. 
716
      any accesses on x86 processors. 
725
      Some programs might however assume that <code>malloc</code> et
717
      Some programs might however assume that <code>malloc</code> et
726
      al return 8- or more aligned memory.
718
      al return 8- or more aligned memory.  The supplied value must be
727
      These programs are broken and should be fixed, but
728
      if this is impossible for whatever reason the alignment can be
729
      increased using this parameter.  The supplied value must be
730
      between 4 and 4096 inclusive, and must be a power of two.</li><br><p>
719
      between 4 and 4096 inclusive, and must be a power of two.</li><br><p>
731
720
732
  <li><code>--sloppy-malloc=no</code> [default]<br>
721
  <li><code>--sloppy-malloc=no</code> [default]<br>
Lines 777-783 Link Here
777
      segmentation faults.  This is particularly noticeable on Red Hat
766
      segmentation faults.  This is particularly noticeable on Red Hat
778
      7.1.  So this flag is provided in order to inhibit the run of
767
      7.1.  So this flag is provided in order to inhibit the run of
779
      <code>__libc_freeres</code>.  If your program seems to run fine
768
      <code>__libc_freeres</code>.  If your program seems to run fine
780
      on valgrind, but segfaults at exit, you may find that
769
      on Valgrind, but segfaults at exit, you may find that
781
      <code>--run-libc-freeres=no</code> fixes that, although at the
770
      <code>--run-libc-freeres=no</code> fixes that, although at the
782
      cost of possibly falsely reporting space leaks in
771
      cost of possibly falsely reporting space leaks in
783
      <code>libc.so</code>.
772
      <code>libc.so</code>.
Lines 889-897 Link Here
889
878
890
  <li><code>--profile=no</code><br>
879
  <li><code>--profile=no</code><br>
891
      <code>--profile=yes</code> [default]
880
      <code>--profile=yes</code> [default]
892
      <p>When enabled, does crude internal profiling of valgrind 
881
      <p>When enabled, does crude internal profiling of Valgrind 
893
      itself.  This is not for profiling your programs.  Rather it is
882
      itself.  This is not for profiling your programs.  Rather it is
894
      to allow the developers to assess where valgrind is spending
883
      to allow the developers to assess where Valgrind is spending
895
      its time.  The tools must be built for profiling for this to
884
      its time.  The tools must be built for profiling for this to
896
      work.
885
      work.
897
      </li><br><p>
886
      </li><br><p>
Lines 935-947 Link Here
935
      </li><br>
924
      </li><br>
936
      <p>
925
      <p>
937
926
938
  <li><code>--stop-after=&lt;number></code> 
939
      [default: infinity, more or less]
940
      <p>After &lt;number> basic blocks have been executed, shut down
941
      Valgrind and switch back to running the client on the real CPU.
942
      </li><br>
943
      <p>
944
945
  <li><code>--dump-error=&lt;number></code> [default: inactive]
927
  <li><code>--dump-error=&lt;number></code> [default: inactive]
946
      <p>After the program has exited, show gory details of the
928
      <p>After the program has exited, show gory details of the
947
      translation of the basic block containing the &lt;number>'th
929
      translation of the basic block containing the &lt;number>'th
Lines 952-957 Link Here
952
      <p>
934
      <p>
953
</ul>
935
</ul>
954
936
937
<h4>Setting default options</h4>
938
939
<p>Note that Valgrind also reads options from three places:
940
<ul>
941
<li>The file <code>~/.valgrindrc</code>
942
<li>The environment variable <code>$VALGRIND_OPTS</code>
943
<li>The file <code>./.valgrindrc</code>
944
</ul>
945
These are processed in the given order, before the command-line options.
946
Options processed later override those processed earlier;  for example,
947
options in <code>./.valgrindrc</code> will take precedence over those in
948
<code>~/.valgrindrc</code>.  The first two are particularly useful for
949
setting the default tool to use.
950
<p>
951
Any tool-specific options put in <code>$VALGRIND_OPTS</code> or the
952
<code>.valgrindrc</code> files should be prefixed with the tool name and
953
a colon.  For example, if you want Memcheck to always do leak checking,
954
you can put the following entry in <code>~/.valgrindrc</code>:
955
956
<pre>
957
    --memcheck:leak-check=yes
958
</pre>
959
960
This will be ignored if any tool other than Memcheck is run.
961
Without the <code>memcheck:</code> part, this will cause problems if you
962
select other tools that don't understand <code>--leak-check=yes</code>.
963
955
964
956
<a name="clientreq"></a>
965
<a name="clientreq"></a>
957
<h3>2.7&nbsp; The Client Request mechanism</h3>
966
<h3>2.7&nbsp; The Client Request mechanism</h3>
Lines 993-999 Link Here
993
    of code in the specified address range.  Useful if you are
1002
    of code in the specified address range.  Useful if you are
994
    debugging a JITter or some other dynamic code generation system.
1003
    debugging a JITter or some other dynamic code generation system.
995
    After this call, attempts to execute code in the invalidated
1004
    After this call, attempts to execute code in the invalidated
996
    address range will cause valgrind to make new translations of that
1005
    address range will cause Valgrind to make new translations of that
997
    code, which is probably the semantics you want.  Note that this is
1006
    code, which is probably the semantics you want.  Note that this is
998
    implemented naively, and involves checking all 200191 entries in
1007
    implemented naively, and involves checking all 200191 entries in
999
    the translation table to see if any of them overlap the specified
1008
    the translation table to see if any of them overlap the specified
Lines 1077-1083 Link Here
1077
if you have some kind of concurrency, critical race, locking, or
1086
if you have some kind of concurrency, critical race, locking, or
1078
similar, bugs.
1087
similar, bugs.
1079
<p>
1088
<p>
1080
As of the valgrind-1.0 release, the state of pthread support was as follows:
1089
As of the Valgrind-1.0 release, the state of pthread support was as follows:
1081
<ul>
1090
<ul>
1082
<li>Mutexes, condition variables, thread-specific data,
1091
<li>Mutexes, condition variables, thread-specific data,
1083
    <code>pthread_once</code>, reader-writer locks, semaphores,
1092
    <code>pthread_once</code>, reader-writer locks, semaphores,
Lines 1163-1169 Link Here
1163
1172
1164
<p>The translator/instrumentor has a lot of assertions in it.  They
1173
<p>The translator/instrumentor has a lot of assertions in it.  They
1165
are permanently enabled, and I have no plans to disable them.  If one
1174
are permanently enabled, and I have no plans to disable them.  If one
1166
of these breaks, please mail me!
1175
of these breaks, please mail us!
1167
1176
1168
<p>If you get an assertion failure on the expression
1177
<p>If you get an assertion failure on the expression
1169
<code>chunkSane(ch)</code> in <code>vg_free()</code> in
1178
<code>chunkSane(ch)</code> in <code>vg_free()</code> in
Lines 1186-1198 Link Here
1186
a kernel 2.2.X or 2.4.X system, subject to the following constraints:
1195
a kernel 2.2.X or 2.4.X system, subject to the following constraints:
1187
1196
1188
<ul>
1197
<ul>
1189
  <li>No MMX, SSE, SSE2, 3DNow instructions.  If the translator
1198
  <li>No support for 3DNow instructions.  If the translator encounters
1190
      encounters these, Valgrind will simply give up.  It may be
1199
      these, Valgrind will generate a SIGILL when the instruction is
1191
      possible to add support for them at a later time. Intel added a
1200
      executed.</li>
1192
      few instructions such as "cmov" to the integer instruction set
1193
      on Pentium and later processors, and these are supported.
1194
      Nevertheless it's safest to think of Valgrind as implementing
1195
      the 486 instruction set.</li>
1196
      <p>
1201
      <p>
1197
1202
1198
  <li>Pthreads support is improving, but there are still significant
1203
  <li>Pthreads support is improving, but there are still significant
Lines 1214-1220 Link Here
1214
1219
1215
  <li>If your program does its own memory management, rather than
1220
  <li>If your program does its own memory management, rather than
1216
      using malloc/new/free/delete, it should still work, but
1221
      using malloc/new/free/delete, it should still work, but
1217
      Valgrind's error checking won't be so effective.</li>
1222
      Valgrind's error checking won't be so effective.
1223
      If you describe your program's memory management scheme
1224
      using "client requests" (Section 3.7 of this manual),
1225
      Memcheck can do better.  Nevertheless, using malloc/new
1226
      and free/delete is still the best approach.
1227
      </li>
1218
      <p>
1228
      <p>
1219
1229
1220
  <li>Valgrind's signal simulation is not as robust as it could be.
1230
  <li>Valgrind's signal simulation is not as robust as it could be.
Lines 1238-1244 Link Here
1238
  <li>x86 instructions, and system calls, have been implemented on
1248
  <li>x86 instructions, and system calls, have been implemented on
1239
      demand.  So it's possible, although unlikely, that a program
1249
      demand.  So it's possible, although unlikely, that a program
1240
      will fall over with a message to that effect.  If this happens,
1250
      will fall over with a message to that effect.  If this happens,
1241
      please mail me ALL the details printed out, so I can try and
1251
      please report ALL the details printed out, so we can try and
1242
      implement the missing feature.</li>
1252
      implement the missing feature.</li>
1243
      <p>
1253
      <p>
1244
1254
Lines 1247-1257 Link Here
1247
      approach to FPU emulation.</li>
1257
      approach to FPU emulation.</li>
1248
      <p>
1258
      <p>
1249
1259
1250
  <li>You can't Valgrind-ize statically linked binaries.  Valgrind
1251
      relies on the dynamic-link mechanism to gain control at
1252
      startup.</li>
1253
      <p>
1254
1255
  <li>Memory consumption of your program is majorly increased whilst
1260
  <li>Memory consumption of your program is majorly increased whilst
1256
      running under Valgrind.  This is due to the large amount of
1261
      running under Valgrind.  This is due to the large amount of
1257
      administrative information maintained behind the scenes.  Another
1262
      administrative information maintained behind the scenes.  Another
Lines 1483-1498 Link Here
1483
==25832== 223 translations, 3626 bytes in, 56801 bytes out.
1488
==25832== 223 translations, 3626 bytes in, 56801 bytes out.
1484
</pre>
1489
</pre>
1485
<p>The GCC folks fixed this about a week before gcc-3.0 shipped.
1490
<p>The GCC folks fixed this about a week before gcc-3.0 shipped.
1486
<hr width="100%">
1487
<p>
1491
<p>
1488
1492
1489
</body>
1493
<a name="warnings"></a>
1490
</html>
1494
<h3>2.15&nbsp; Warning messages you might see</h3>
1491
1492
1493
<h2>Misc text looking for a home</h2>
1494
1495
<h4>2.6.6&nbsp; Warning messages you might see</h4>
1496
1495
1497
Most of these only appear if you run in verbose mode (enabled by
1496
Most of these only appear if you run in verbose mode (enabled by
1498
<code>-v</code>):
1497
<code>-v</code>):
Lines 1554-1556 Link Here
1554
     Diagnostic message, mostly for benefit of the valgrind
1553
     Diagnostic message, mostly for benefit of the valgrind
1555
     developers, to do with memory permissions.
1554
     developers, to do with memory permissions.
1556
</ul>
1555
</ul>
1556
1557
</body>
1558
</html>
1559
1560
1561
(-)valgrind-2.1.0/coregrind/docs/coregrind_intro.html (-51 / +35 lines)
Lines 39-64 Link Here
39
    lying undetected for long periods, then causing occasional,
39
    lying undetected for long periods, then causing occasional,
40
    difficult-to-diagnose crashes.
40
    difficult-to-diagnose crashes.
41
<p>
41
<p>
42
<li><b>Cachegrind</b> is a cache profiler.  It performs detailed simulation of
43
    the I1, D1 and L2 caches in your CPU and so can accurately
44
    pinpoint the sources of cache misses in your code.  If you desire,
45
    it will show the number of cache misses, memory references and
46
    instructions accruing to each line of source code, with
47
    per-function, per-module and whole-program summaries.  If you ask
48
    really nicely it will even show counts for each individual x86
49
    instruction.
50
    <p>
51
    Cachegrind auto-detects your machine's cache configuration
52
    using the <code>CPUID</code> instruction, and so needs no further
53
    configuration info, in most cases.
54
    <p>
55
    Cachegrind is nicely complemented by Josef Weidendorfer's
56
    amazing KCacheGrind visualisation tool (<A
57
    HREF="http://kcachegrind.sourceforge.net">
58
    http://kcachegrind.sourceforge.net</A>), a KDE application which
59
    presents these profiling results in a graphical and
60
    easier-to-understand form.
61
<p>
62
<li><b>Addrcheck</b> is a lightweight version of
42
<li><b>Addrcheck</b> is a lightweight version of
63
    Memcheck.  It is identical to Memcheck except
43
    Memcheck.  It is identical to Memcheck except
64
    for the single detail that it does not do any uninitialised-value
44
    for the single detail that it does not do any uninitialised-value
Lines 84-89 Link Here
84
    to run KDE for long periods at a time like this, collecting up
64
    to run KDE for long periods at a time like this, collecting up
85
    all the addressing errors that appear.
65
    all the addressing errors that appear.
86
<p>
66
<p>
67
<li><b>Cachegrind</b> is a cache profiler.  It performs detailed simulation of
68
    the I1, D1 and L2 caches in your CPU and so can accurately
69
    pinpoint the sources of cache misses in your code.  If you desire,
70
    it will show the number of cache misses, memory references and
71
    instructions accruing to each line of source code, with
72
    per-function, per-module and whole-program summaries.  If you ask
73
    really nicely it will even show counts for each individual x86
74
    instruction.
75
    <p>
76
    Cachegrind auto-detects your machine's cache configuration
77
    using the <code>CPUID</code> instruction, and so needs no further
78
    configuration info, in most cases.
79
    <p>
80
    Cachegrind is nicely complemented by Josef Weidendorfer's
81
    amazing KCacheGrind visualisation tool (<A
82
    HREF="http://kcachegrind.sourceforge.net">
83
    http://kcachegrind.sourceforge.net</A>), a KDE application which
84
    presents these profiling results in a graphical and
85
    easier-to-understand form.
86
<p>
87
<li><b>Helgrind</b> finds data races in multithreaded programs.
87
<li><b>Helgrind</b> finds data races in multithreaded programs.
88
    Helgrind looks for
88
    Helgrind looks for
89
    memory locations which are accessed by more than one (POSIX
89
    memory locations which are accessed by more than one (POSIX
Lines 104-110 Link Here
104
</ul>
104
</ul>
105
105
106
A number of minor tools (<b>corecheck</b>, <b>lackey</b> and
106
A number of minor tools (<b>corecheck</b>, <b>lackey</b> and
107
<b>none</b>) are also supplied.  These aren't particularly useful --
107
<b>Nulgrind</b>) are also supplied.  These aren't particularly useful --
108
they exist to illustrate how to create simple tools and to help the
108
they exist to illustrate how to create simple tools and to help the
109
valgrind developers in various ways.
109
valgrind developers in various ways.
110
110
Lines 119-125 Link Here
119
attempted to ensure that it works on machines with kernel 2.2 or 2.4
119
attempted to ensure that it works on machines with kernel 2.2 or 2.4
120
and glibc 2.1.X, 2.2.X or 2.3.1.  This should cover the vast majority
120
and glibc 2.1.X, 2.2.X or 2.3.1.  This should cover the vast majority
121
of modern Linux installations.  Note that glibc-2.3.2+, with the
121
of modern Linux installations.  Note that glibc-2.3.2+, with the
122
NPTL (next generation posix threads?) package won't work.  We hope to
122
NPTL (Native Posix Threads Library) package won't work.  We hope to
123
be able to fix this, but it won't be easy.
123
be able to fix this, but it won't be easy.
124
124
125
125
Lines 137-178 Link Here
137
<a name="intro-navigation"></a>
137
<a name="intro-navigation"></a>
138
<h3>1.2&nbsp; How to navigate this manual</h3>
138
<h3>1.2&nbsp; How to navigate this manual</h3>
139
139
140
Valgrind is structured as a set of core services supporting a number
140
The Valgrind distribution consists of the Valgrind core, upon which are
141
of profiling and debugging tools.  This manual is structured
141
built Valgrind tools, which do different kinds of debugging and
142
similarly.  Below, we continue with a description of the valgrind
142
profiling.  This manual is structured similarly.  
143
core, how to use it, and the flags it supports.
143
144
144
<p>
145
<p>
145
First, we describe the Valgrind core, how to use it, and the flags it
146
The tools each have their own chapters in this manual.  You only need
146
supports.  Then, each tool has its own chapter in this manual.  You only
147
to read the documentation for the core services and for the tool(s)
147
need to read the documentation for the core and for the tool(s) you
148
you actually use, although you may find it helpful to be at least a
148
actually use, although you may find it helpful to be at least a little
149
little bit familar with what all tools do.  If you want to write a new
149
bit familar with what all tools do.  If you're new to all this, you 
150
tool, read <A HREF="coregrind_tools.html">this</A>.
150
probably want to run the Memcheck tool.  If you want to write a new tool,
151
151
read <A HREF="coregrind_tools.html">this</A>.
152
<p>
153
If you're new to all this, you're most likely to be using the Memcheck
154
tool, since that's the one selected by default.  So, read the rest of
155
this page, and the section Memcheck.
156
152
157
<p>
153
<p>
158
Be aware that the core understands some command line flags, and the
154
Be aware that the core understands some command line flags, and the
159
tools have their own flags which they know about.  This means
155
tools have their own flags which they know about.  This means
160
there is no central place describing all the flags that are accepted
156
there is no central place describing all the flags that are accepted
161
-- you have to read the flags documentation both for 
157
-- you have to read the flags documentation both for 
162
<A HREF="coregrind_core.html#core">valgrind's core</A>
158
<A HREF="coregrind_core.html#core">Valgrind's core</A>
163
and for the tool you want to use.
159
and for the tool you want to use.
164
160
165
<p>
161
<p>
166
<a name="intro-migrating"></a>
167
<h4>1.2.1&nbsp; For users migrating from valgrind-1.0.X</h4>
168
<p>
169
Valgrind-2.0.X is a major redesign of the 1.0.X series.  You should at
170
least be familiar with the concept of the core/tool division,
171
as explained above in the Introduction.  Having said that, we've tried
172
to make the command line handling and behaviour as
173
backwards-compatible as we can.  In particular, just running
174
<code>valgrind [args-for-valgrind] my_prog [args-for-my-prog]</code>
175
should work pretty much as before.
176
177
<p>
178
162
(-)valgrind-2.1.0/coregrind/dosyms (+31 lines)
Line 0 Link Here
1
#!/bin/sh
2
3
# A simple script to help me ensure that my libpthread.so looks
4
# from the outside, to the linker, identical to the original.
5
6
nm /lib/libpthread.so.0 | grep " T " | cut -c 10- > orig-T
7
nm /lib/libpthread.so.0 | grep " D " | cut -c 10- > orig-D
8
nm /lib/libpthread.so.0 | grep " W " | cut -c 10- > orig-W
9
nm /lib/libpthread.so.0 | grep " U " | cut -c 10- > orig-U
10
11
nm ./libpthread.so | grep " T " | cut -c 10- > mine-T
12
nm ./libpthread.so | grep " D " | cut -c 10- > mine-D
13
nm ./libpthread.so | grep " W " | cut -c 10- > mine-W
14
nm ./libpthread.so | grep " U " | cut -c 10- > mine-U
15
16
echo ========================== TEXT orig vs mine =========================
17
sdiff -w 80 orig-T mine-T
18
echo
19
20
echo ========================== WEAK orig vs mine =========================
21
sdiff -w 80 orig-W mine-W
22
echo
23
24
echo ========================== DATA orig vs mine =========================
25
sdiff -w 80 orig-D mine-D
26
echo
27
28
echo ========================== UNDF orig vs mine =========================
29
sdiff -w 80 orig-U mine-U
30
echo
31
(-)valgrind-2.1.0/coregrind/gen_toolint.pl (+292 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
#  This file is part of Valgrind, an extensible x86 protected-mode
4
#  emulator for monitoring program execution on x86-Unixes.
5
#
6
#  Copyright (C) 2000-2004 Julian Seward 
7
#     jseward@acm.org
8
#
9
#  This program is free software; you can redistribute it and/or
10
#  modify it under the terms of the GNU General Public License as
11
#  published by the Free Software Foundation; either version 2 of the
12
#  License, or (at your option) any later version.
13
#
14
#  This program is distributed in the hope that it will be useful, but
15
#  WITHOUT ANY WARRANTY; without even the implied warranty of
16
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
#  General Public License for more details.
18
#
19
#  You should have received a copy of the GNU General Public License
20
#  along with this program; if not, write to the Free Software
21
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
#  02111-1307, USA.
23
#
24
#  The GNU General Public License is contained in the file COPYING.
25
26
use strict;
27
use warnings;
28
29
my $output = shift @ARGV;
30
my $indent = "";
31
my $headerguard;
32
my $include;
33
my $passcomment = 1;
34
my $pre;
35
my $post;
36
my $generate;
37
38
my $struct = "VG_(tool_interface)";
39
40
my %pfxmap = ("track" => "SK_",
41
	      "tool"  => "SK_",
42
	      "malloc"=> "SK_",
43
	     );
44
45
sub getargnames(@) {
46
    my @args = @_;
47
    my @ret;
48
49
    foreach my $a (@args) {
50
	my @pieces = split /\s+/, $a;
51
	my $name = pop @pieces;
52
	push @ret, $name unless $name eq "void";
53
    }
54
    return @ret;
55
}
56
57
sub getargtypes(@) {
58
    my @args = @_;
59
    my @ret;
60
61
    foreach my $a (@args) {
62
	my @pieces = split /\s+/, $a;
63
	pop @pieces;
64
	push @ret, (join " ", @pieces);
65
    }
66
    @ret = "void" if ($#ret == -1);
67
    return @ret;
68
}
69
70
# Different output modes
71
if ($output eq "callwrap") {
72
    $include = "vg_include.h";
73
    $generate = sub ($$$@) {
74
	my ($pfx, $ret, $func, @args) = @_;
75
	my $args = join ", ", @args;
76
	my $argnames = join ", ", getargnames(@args);
77
	print "$ret $pfxmap{$pfx}($func)($args)\n{\n";
78
	print "   return (*$struct.${pfx}_$func)($argnames);\n";
79
	print "}\n";
80
    }
81
} elsif ($output eq "proto") {
82
    $include = "vg_include.h";
83
    $generate = sub ($$$@) {
84
	my ($pfx, $ret, $func, @args) = @_;
85
	my $args = join ', ', @args;
86
87
	print "$ret $pfxmap{$pfx}($func)($args);\n";
88
	print "Bool VG_(defined_$func)(void);\n";
89
    }
90
} elsif ($output eq "toolproto") {
91
    $generate = sub ($$$@) {
92
	my ($pfx, $ret, $func, @args) = @_;
93
	my $args = join ', ', @args;
94
95
	print "$ret $pfxmap{$pfx}($func)($args);\n";
96
    }
97
} elsif ($output eq "missingfuncs") {
98
    $include = "vg_include.h";
99
    $generate = sub ($$$@) {
100
	my ($pfx, $ret, $func, @args) = @_;
101
	my $args = join ", ", @args;
102
103
	print "static $ret missing_${pfx}_$func($args) {\n";
104
	print "   VG_(missing_tool_func)(\"${pfx}_$func\");\n";
105
	print "}\n";
106
	print "Bool VG_(defined_$func)(void) {\n";
107
	print "   return $struct.${pfx}_$func != missing_${pfx}_$func;\n";
108
	print "}\n\n";
109
    };
110
    $indent = "   ";
111
} elsif ($output eq "struct") {
112
    $include = "vg_include.h";
113
    $pre = sub () {
114
	print "typedef struct {\n";
115
    };
116
    $post = sub () {
117
	print "} VgToolInterface;\n\n";
118
	print "extern VgToolInterface $struct;\n"
119
    };
120
    $generate = sub ($$$@) {
121
	my ($pfx, $ret, $func, @args) = @_;
122
	my $args = join ", ", @args;
123
124
	print "$indent$ret (*${pfx}_$func)($args);\n";
125
    };
126
    $indent = "   ";
127
    $headerguard=$output;
128
} elsif ($output eq "structdef") {
129
    $include = "vg_toolint.h";
130
    $pre = sub () {
131
	print "VgToolInterface $struct = {\n";
132
    };
133
    $post = sub () {
134
	print "};\n";
135
    };
136
    $generate = sub ($$$@) {
137
	my ($pfx, $ret, $func, @args) = @_;
138
139
	print "$indent.${pfx}_$func = missing_${pfx}_$func,\n"
140
    };
141
    $indent = "   ";
142
} elsif ($output eq "initfunc") {
143
    $include = "vg_skin.h";
144
    $generate = sub ($$$@) {
145
	my ($pfx, $ret, $func, @args) = @_;
146
	my $args = join ", ", @args;
147
	my $argnames = join ", ", getargnames(@args);
148
149
	print <<EOF;
150
void VG_(init_$func)($ret (*func)($args))
151
{
152
	if (func == NULL)
153
		func = missing_${pfx}_$func;
154
	if (VG_(defined_$func)())
155
		VG_(printf)("Warning tool is redefining $func\\n");
156
	if (func == SK_($func))
157
		VG_(printf)("Warning tool is defining $func recursively\\n");
158
	$struct.${pfx}_$func = func;
159
}
160
EOF
161
    }
162
} elsif ($output eq "initproto") {
163
    $generate = sub ($$$@) {
164
	my ($pfx, $ret, $func, @args) = @_;
165
	my $args = join ', ', @args;
166
	print "void VG_(init_$func)($ret (*func)($args));\n";
167
    };
168
    $headerguard=$output;
169
} elsif ($output eq "initdlsym") {
170
    $pre = sub () {
171
	print <<EOF;
172
#include <dlfcn.h>
173
void VG_(tool_init_dlsym)(void *dlhandle)
174
{
175
   void *ret;
176
177
EOF
178
    };
179
    $post = sub () {
180
	print "}\n";
181
    };
182
    $generate = sub ($$$@) {
183
	my ($pfx, $ret, $func, @args) = @_;
184
	my $args = join ", ", getargtypes(@args);
185
186
	print <<EOF;
187
   ret = dlsym(dlhandle, "vgSkin_$func");
188
   if (ret != NULL)
189
      VG_(init_$func)(($ret (*)($args))ret);
190
191
EOF
192
    };
193
194
    $passcomment = 0;
195
}
196
197
die "Unknown output format \"$output\"" unless defined $generate;
198
199
print "/* Generated by \"gen_toolint.pl $output\" */\n";
200
201
print <<EOF if defined $headerguard;
202
203
#ifndef VG_toolint_$headerguard
204
#define VG_toolint_$headerguard
205
206
EOF
207
208
print <<EOF if defined $include;
209
#include \"$include\"
210
EOF
211
212
&$pre() if defined $pre;	# preamble
213
214
my $state = "idle";
215
216
my $buf;
217
my $lines;
218
my $prefix;
219
220
while(<STDIN>) {
221
    # skip simple comments
222
    next if (/^#[^#]/);
223
224
    if (/^:/) {
225
	s/^://;
226
	chomp;
227
	$prefix=$_;
228
	next;
229
    }
230
231
    # look for inserted comments
232
    if (/^##/) {
233
	if ($state eq "idle") {
234
	    $state = "comment";
235
	    $lines = 1;
236
	    $_ =~ s,^## ,/* ,;
237
	    $buf = $_;
238
	    next;
239
	} elsif ($state eq "comment") {
240
	    $lines++;
241
	    $_ =~ s,^## ,   ,;
242
	    print $indent.$buf if $passcomment;
243
	    $buf = $_;
244
	    next;
245
	}
246
	next;
247
    }
248
249
    # blank lines in a comment are part of the comment
250
    if (/^\s*$/) {
251
	if ($state eq "comment") {
252
	    $lines++;
253
	    print $indent.$buf if $passcomment;
254
	    $buf = "\n";
255
	} else {
256
	    print "\n" if $passcomment;
257
	}
258
	next;
259
    }
260
261
    # coming out of a comment
262
    if ($state eq "comment") {
263
	chomp $buf;
264
265
	if ($passcomment) {
266
	    if ($lines == 1) {
267
		print "$indent$buf */\n";
268
	    } else {
269
		print "$indent$buf\n$indent */\n";
270
	    }
271
	}
272
	$buf = "";
273
	$state = "idle";
274
    }
275
276
    chomp;
277
    my @func = split /,\s*/;
278
279
    my $rettype = shift @func;
280
    my $funcname = shift @func;
281
282
    @func = "void" if scalar @func == 0;
283
284
    &$generate ($prefix, $rettype, $funcname, @func);
285
}
286
287
&$post() if defined $post;	# postamble
288
289
print <<EOF if defined $headerguard;
290
291
#endif /* VG_toolint_$headerguard */
292
EOF
(-)valgrind-2.1.0/coregrind/stage1.c (+215 lines)
Line 0 Link Here
1
2
/*--------------------------------------------------------------------*/
3
/*--- Startup: preliminaries                              stage1.c ---*/
4
/*--------------------------------------------------------------------*/
5
6
/*
7
   This file is part of Valgrind, an extensible x86 protected-mode
8
   emulator for monitoring program execution on x86-Unixes.
9
10
   Copyright (C) 2000-2004 Julian Seward 
11
      jseward@acm.org
12
13
   This program is free software; you can redistribute it and/or
14
   modify it under the terms of the GNU General Public License as
15
   published by the Free Software Foundation; either version 2 of the
16
   License, or (at your option) any later version.
17
18
   This program is distributed in the hope that it will be useful, but
19
   WITHOUT ANY WARRANTY; without even the implied warranty of
20
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21
   General Public License for more details.
22
23
   You should have received a copy of the GNU General Public License
24
   along with this program; if not, write to the Free Software
25
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26
   02111-1307, USA.
27
28
   The GNU General Public License is contained in the file COPYING.
29
*/
30
31
#define _FILE_OFFSET_BITS	64
32
33
#include <stdio.h>
34
#include <elf.h>
35
#include <string.h>
36
#include <stdlib.h>
37
#include <assert.h>
38
#include <signal.h>
39
#include <fcntl.h>
40
#include <errno.h>
41
42
#include "vg_include.h"
43
44
#include "ume.h"
45
#include "ume_arch.h"
46
#include "ume_archdefs.h"
47
48
static int stack[SIGSTKSZ*4];
49
static int our_argc;
50
51
/* Where we expect to find all our aux files (namely, stage2) */
52
static const char *valgrind_lib = VG_LIBDIR;
53
54
/* stage2's name */
55
static const char stage2[] = "stage2";
56
57
/* Modify the auxv the kernel gave us to make it look like we were
58
   execed as the shared object.
59
60
   This also inserts a new entry into the auxv table so we can
61
   communicate some extra information to stage2 (namely, the fd of the
62
   padding file, so it can identiry and remove the padding later).
63
*/
64
static void *fix_auxv(void *v_init_esp, const struct exeinfo *info)
65
{
66
   struct ume_auxv *auxv;
67
   int *newesp;
68
   int seen;
69
   int delta;
70
   int i;
71
   static const int new_entries = 2;
72
73
   /* make sure we're running on the private stack */
74
   assert(&delta >= stack && &delta < &stack[sizeof(stack)/sizeof(*stack)]);
75
   
76
   /* find the beginning of the AUXV table */
77
   auxv = find_auxv(v_init_esp);
78
79
   /* Work out how we should move things to make space for the new
80
      auxv entry. It seems that ld.so wants a 16-byte aligned stack on
81
      entry, so make sure that's the case. */
82
   newesp = (int *)(((unsigned long)v_init_esp - new_entries * sizeof(*auxv)) & ~0xf);
83
   delta = (char *)v_init_esp - (char *)newesp;
84
85
   memmove(newesp, v_init_esp, (char *)auxv - (char *)v_init_esp);
86
   
87
   v_init_esp = (void *)newesp;
88
   auxv -= delta/sizeof(*auxv);
89
90
   /* stage2 needs this so it can clean up the padding we leave in
91
      place when we start it */
92
   auxv[0].a_type = AT_UME_PADFD;
93
   auxv[0].u.a_val = as_getpadfd();
94
95
   /* This will be needed by valgrind itself so that it can
96
      subsequently execve() children.  This needs to be done here
97
      because /proc/self/exe will go away once we unmap stage1. */
98
   auxv[1].a_type = AT_UME_EXECFD;
99
   auxv[1].u.a_val = open("/proc/self/exe", O_RDONLY);
100
101
   /* make sure the rest are sane */
102
   for(i = new_entries; i < delta/sizeof(*auxv); i++) {
103
      auxv[i].a_type = AT_IGNORE;
104
      auxv[i].u.a_val = 0;
105
   }
106
107
   /* OK, go through and patch up the auxv entries to match the new
108
      executable */
109
   seen = 0;
110
   for(; auxv->a_type != AT_NULL; auxv++) {
111
      if (0)
112
	 printf("doing auxv %p %4x: %d %p\n", auxv, auxv->a_type, auxv->u.a_val, auxv->u.a_ptr);
113
114
      switch(auxv->a_type) {
115
      case AT_PHDR:
116
	 seen |= 1;
117
	 auxv->u.a_val = info->phdr;
118
	 break;
119
120
      case AT_PHNUM:
121
	 seen |= 2;
122
	 auxv->u.a_val = info->phnum;
123
	 break;
124
125
      case AT_BASE:
126
	 seen |= 4;
127
	 auxv->u.a_val = info->interp_base;
128
	 break;
129
130
      case AT_ENTRY:
131
	 seen |= 8;
132
	 auxv->u.a_val = info->entry;
133
	 break;
134
      }
135
   }
136
137
   /* If we didn't see all the entries we need to fix up, then we
138
      can't make the new executable viable. */
139
   if (seen != 0xf) {
140
      fprintf(stderr, "fix_auxv: we didn't see enough auxv entries (seen=%x)\n", seen);
141
      exit(1);
142
   }
143
144
   return v_init_esp;
145
}
146
147
static void hoops(void)
148
{
149
   int err;
150
   struct exeinfo info;
151
   extern char _end;
152
   int *esp;
153
   char buf[strlen(valgrind_lib) + sizeof(stage2) + 16];
154
155
   info.exe_base = PGROUNDUP(&_end);
156
   info.exe_end  = PGROUNDDN(ume_exec_esp);
157
158
   /* XXX FIXME: how can stage1 know where stage2 wants things placed?
159
      Options:
160
      - we could look for a symbol
161
      - it could have a special PHDR (v. ELF specific)
162
      - something else?
163
    */
164
   info.map_base = 0xb0000000;
165
   info.setbrk = 1;		/* ask do_exec to move the brk-base */
166
   info.argv = NULL;
167
168
   snprintf(buf, sizeof(buf), "%s/%s", valgrind_lib, stage2);
169
170
   err = do_exec(buf, &info);
171
172
   if (err != 0) {
173
      fprintf(stderr, "failed to load %s: %s\n",
174
	      buf, strerror(err));
175
      exit(1);
176
   }
177
178
   /* Make sure stage2's dynamic linker can't tromp on the lower part
179
      of the address space. */
180
   as_pad(0, (void *)info.map_base);
181
   
182
   esp = fix_auxv(ume_exec_esp, &info);
183
184
   if (0) {
185
      int prmap(void *start, void *end, const char *perm, off_t off, int maj, int min, int ino) {
186
	 printf("mapping %10p-%10p %s %02x:%02x %d\n",
187
		start, end, perm, maj, min, ino);
188
	 return 1;
189
      }
190
      printf("---------- launch stage 2 ----------\n");
191
      printf("eip=%p esp=%p\n", (void *)info.init_eip, esp);
192
      foreach_map(prmap);
193
   }
194
195
   ume_go(info.init_eip, (addr_t)esp);   
196
}
197
198
int main(int argc, char **argv)
199
{
200
   const char *cp = getenv(VALGRINDLIB);
201
202
   if (cp != NULL)
203
      valgrind_lib = cp;
204
205
   assert(ume_exec_esp != NULL);
206
207
   our_argc = argc;
208
209
   /* move onto another stack so we can play with the main one */
210
   ume_go((addr_t)hoops, (addr_t)stack + sizeof(stack));
211
}
212
213
/*--------------------------------------------------------------------*/
214
/*--- end                                                 stage1.c ---*/
215
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/toolfuncs.def (+302 lines)
Line 0 Link Here
1
# Tool interface functions
2
# The format for an interface function definition is:
3
#	return_type,	func_name,	type arg, type arg
4
# If the function has no arguments, specify no arguments (rather than void)
5
#
6
# Comments starting with "##" are turned into C comments in the output
7
#
8
# Lines starting with : set the prefix
9
10
## These are the parameterised functions in the core.  The default definitions
11
## are overridden by LD_PRELOADed skin version.  At the very least, a skin
12
## must define the fundamental template functions.  Depending on what needs
13
## are set, extra template functions will be used too.  Functions are
14
## grouped under the needs that govern their use.
15
16
:tool
17
## ------------------------------------------------------------------
18
## Fundamental template functions
19
20
## Do initialisation that can only be done after command line processing.
21
void,		post_clo_init
22
23
## Instrument a basic block.  Must be a true function, ie. the same input
24
## always results in the same output, because basic blocks can be
25
## retranslated.  Unless you're doing something really strange...
26
## 'orig_addr' is the address of the first instruction in the block.
27
UCodeBlock*,	instrument,	UCodeBlock* cb, Addr orig_addr
28
29
## Finish up, print out any results, etc.  `exitcode' is program's exit
30
## code.  The shadow (if the `shadow_regs' need is set) can be found with
31
## VG_(get_shadow_archreg)(R_EBX), since %ebx holds the argument to the
32
## exit() syscall.
33
void,	fini,	Int exitcode
34
35
36
## ------------------------------------------------------------------
37
## VG_(needs).core_errors
38
39
## (none needed)
40
41
## ------------------------------------------------------------------
42
## VG_(needs).skin_errors
43
44
## Identify if two errors are equal, or equal enough.  `res' indicates how
45
## close is "close enough".  `res' should be passed on as necessary, eg. if
46
## the Error's `extra' part contains an ExeContext, `res' should be
47
## passed to VG_(eq_ExeContext)() if the ExeContexts are considered.  Other
48
## than that, probably don't worry about it unless you have lots of very
49
## similar errors occurring.
50
Bool,	eq_SkinError,	VgRes res, Error* e1, Error* e2
51
52
## Print error context.
53
void,	pp_SkinError,	Error* err
54
55
## Should fill in any details that could be postponed until after the
56
## decision whether to ignore the error (ie. details not affecting the
57
## result of SK_(eq_SkinError)()).  This saves time when errors are ignored.
58
## Yuk.
59
60
## Return value: must be the size of the `extra' part in bytes -- used by
61
## the core to make a copy.
62
UInt,	update_extra,	Error* err
63
64
## Return value indicates recognition.  If recognised, must set skind using
65
## VG_(set_supp_kind)().
66
Bool,	recognised_suppression,	Char* name, Supp* su
67
68
## Read any extra info for this suppression kind.  Most likely for filling
69
## in the `extra' and `string' parts (with VG_(set_supp_{extra, string})())
70
## of a suppression if necessary.  Should return False if a syntax error
71
## occurred, True otherwise.
72
Bool,	read_extra_suppression_info,	Int fd, Char* buf, Int nBuf, Supp* su
73
74
## This should just check the kinds match and maybe some stuff in the
75
## `string' and `extra' field if appropriate (using VG_(get_supp_*)() to
76
## get the relevant suppression parts).
77
Bool,	error_matches_suppression,		Error* err, Supp* su
78
79
## This should return the suppression name, for --gen-suppressions, or NULL
80
## if that error type cannot be suppressed.  This is the inverse of
81
## SK_(recognised_suppression)().
82
Char*,	get_error_name,			Error* err
83
84
## This should print any extra info for the error, for --gen-suppressions,
85
## including the newline.  This is the inverse of
86
## SK_(read_extra_suppression_info)().
87
void,	print_extra_suppression_info,	Error* err
88
89
90
## ------------------------------------------------------------------
91
## VG_(needs).basic_block_discards
92
93
## Should discard any information that pertains to specific basic blocks
94
## or instructions within the address range given.
95
void,	discard_basic_block_info,		Addr a, UInt size
96
97
98
## ------------------------------------------------------------------
99
## VG_(needs).shadow_regs
100
101
## No functions must be defined, but the post_reg[s]_write_* events should
102
## be tracked.
103
104
## ------------------------------------------------------------------
105
## VG_(needs).command_line_options
106
107
## Return True if option was recognised.  Presumably sets some state to
108
## record the option as well.
109
Bool,	process_cmd_line_option,	Char* argv
110
111
## Print out command line usage for options for normal skin operation.
112
void,	print_usage
113
114
## Print out command line usage for options for debugging the skin.
115
void,	print_debug_usage
116
117
## ------------------------------------------------------------------
118
## VG_(needs).client_requests
119
120
## If using client requests, the number of the first request should be equal
121
## to VG_USERREQ_SKIN_BASE('X', 'Y'), where 'X' and 'Y' form a suitable two
122
## character identification for the string.  The second and subsequent
123
## requests should follow.
124
125
## This function should use the VG_IS_SKIN_USERREQ macro (in
126
## include/valgrind.h) to first check if it's a request for this skin.  Then
127
## should handle it if it's recognised (and return True), or return False if
128
## not recognised.  arg_block[0] holds the request number, any further args
129
## from the request are in arg_block[1..].  'ret' is for the return value...
130
## it should probably be filled, if only with 0.
131
Bool, handle_client_request, ThreadId tid, UInt* arg_block, UInt* ret
132
133
134
## ------------------------------------------------------------------
135
## VG_(needs).extends_UCode
136
137
## 'X' prefix indicates eXtended UCode.
138
Int, get_Xreg_usage, UInstr* u, Tag tag, Int* regs, Bool* isWrites
139
void, emit_XUInstr, UInstr* u, RRegSet regs_live_before
140
Bool, sane_XUInstr, Bool beforeRA, Bool beforeLiveness, UInstr* u
141
Char *, name_XUOpcode, Opcode opc
142
void, pp_XUInstr, UInstr* u
143
144
145
## ------------------------------------------------------------------
146
## VG_(needs).syscall_wrapper
147
148
## If either of the pre_ functions malloc() something to return, the
149
## corresponding post_ function had better free() it!
150
151
void *, pre_syscall, ThreadId tid, UInt syscallno, Bool is_blocking
152
void, post_syscall, ThreadId tid, UInt syscallno, void* pre_result, Int res, Bool is_blocking
153
154
155
## ---------------------------------------------------------------------
156
##   VG_(needs).sanity_checks
157
158
## Can be useful for ensuring a skin's correctness.  SK_(cheap_sanity_check)
159
## is called very frequently;  SK_(expensive_sanity_check) is called less
160
## frequently and can be more involved.
161
Bool, cheap_sanity_check
162
Bool, expensive_sanity_check
163
164
165
## ================================================================================
166
## Event tracking functions
167
:track
168
169
## Events happening in core to track.  To be notified, pass a callback
170
## function to the appropriate function.  To ignore an event, don't do
171
## anything (default is for events to be ignored).
172
173
## Note that most events aren't passed a ThreadId.  To find out the ThreadId
174
## of the affected thread, use VG_(get_current_or_recent_tid)().  For the
175
## ones passed a ThreadId, use that instead, since
176
## VG_(get_current_or_recent_tid)() might not give the right ThreadId in
177
## that case.
178
179
## Memory events (Nb: to track heap allocation/freeing, a skin must replace
180
## malloc() et al.  See above how to do this.)
181
182
## These ones occur at startup, upon some signals, and upon some syscalls
183
void,	new_mem_startup,	Addr a, UInt len, Bool rr, Bool ww, Bool xx
184
void,	new_mem_stack_signal,	Addr a, UInt len
185
void,	new_mem_brk,	Addr a, UInt len
186
void,	new_mem_mmap,	Addr a, UInt len, Bool rr, Bool ww, Bool xx
187
188
void,	copy_mem_remap,	Addr from, Addr to, UInt len
189
void,	change_mem_mprotect,	Addr a, UInt len, Bool rr, Bool ww, Bool xx
190
void,	die_mem_stack_signal,	Addr a, UInt len
191
void,	die_mem_brk,	Addr a, UInt len
192
void,	die_mem_munmap,	Addr a, UInt len
193
194
## These ones are called when %esp changes.  A skin could track these itself
195
## (except for ban_mem_stack) but it's much easier to use the core's help.
196
197
## The specialised ones are called in preference to the general one, if they
198
## are defined.  These functions are called a lot if they are used, so
199
## specialising can optimise things significantly.  If any of the
200
## specialised cases are defined, the general case must be defined too.
201
202
## Nb: they must all use the __attribute__((regparm(n))) attribute.
203
void,	new_mem_stack_4,	Addr new_ESP
204
void,	new_mem_stack_8,	Addr new_ESP
205
void,	new_mem_stack_12,	Addr new_ESP
206
void,	new_mem_stack_16,	Addr new_ESP
207
void,	new_mem_stack_32,	Addr new_ESP
208
void,	new_mem_stack,	Addr a, UInt len
209
210
void,	die_mem_stack_4,	Addr die_ESP
211
void,	die_mem_stack_8,	Addr die_ESP
212
void,	die_mem_stack_12,	Addr die_ESP
213
void,	die_mem_stack_16,	Addr die_ESP
214
void,	die_mem_stack_32,	Addr die_ESP
215
void,	die_mem_stack,	Addr a, UInt len
216
217
## Used for redzone at end of thread stacks
218
void,	ban_mem_stack,	Addr a, UInt len
219
220
## These ones occur around syscalls, signal handling, etc
221
void,	pre_mem_read,	CorePart part, ThreadId tid, Char* s, Addr a, UInt size
222
void,	pre_mem_read_asciiz,	CorePart part, ThreadId tid, Char* s, Addr a
223
void,	pre_mem_write,	CorePart part, ThreadId tid, Char* s, Addr a, UInt size
224
## Not implemented yet -- have to add in lots of places, which is a
225
## pain.  Won't bother unless/until there's a need.
226
## void (*post_mem_read)  ( ThreadState* tst, Char* s, Addr a, UInt size );
227
void,	post_mem_write,	Addr a, UInt size
228
229
230
## Register events -- if `shadow_regs' need is set, all should probably be
231
## used.  Use VG_(set_thread_shadow_archreg)() to set the shadow of the
232
## changed register.
233
234
## Use VG_(set_shadow_archreg)() to set the eight general purpose regs,
235
## and use VG_(set_shadow_eflags)() to set eflags.
236
void,	post_regs_write_init,	void
237
238
## Use VG_(set_thread_shadow_archreg)() to set the shadow regs for these
239
## events.
240
void,	post_reg_write_syscall_return,	ThreadId tid, UInt reg
241
void,	post_reg_write_deliver_signal,	ThreadId tid, UInt reg
242
void,	post_reg_write_pthread_return,	ThreadId tid, UInt reg
243
void,	post_reg_write_clientreq_return,	ThreadId tid, UInt reg
244
## This one is called for malloc() et al if they are replaced by a skin.
245
void,	post_reg_write_clientcall_return,	ThreadId tid, UInt reg, Addr f
246
247
248
## Scheduler events (not exhaustive)
249
void,	thread_run,	ThreadId tid
250
251
252
## Thread events (not exhaustive)
253
254
## Called during thread create, before the new thread has run any
255
## instructions (or touched any memory).
256
void,	post_thread_create,	ThreadId tid, ThreadId child
257
void,	post_thread_join,	ThreadId joiner, ThreadId joinee
258
259
260
## Mutex events (not exhaustive)
261
## "void *mutex" is really a pthread_mutex *
262
263
## Called before a thread can block while waiting for a mutex (called
264
## regardless of whether the thread will block or not).
265
void,	pre_mutex_lock,	ThreadId tid, void* mutex
266
## Called once the thread actually holds the mutex (always paired with
267
## pre_mutex_lock).
268
void,	post_mutex_lock,	ThreadId tid, void* mutex
269
## Called after a thread has released a mutex (no need for a corresponding
270
## pre_mutex_unlock, because unlocking can't block).
271
void,	post_mutex_unlock,	ThreadId tid, void* mutex
272
273
## Signal events (not exhaustive)
274
275
## ... pre_send_signal, post_send_signal ...
276
277
## Called before a signal is delivered;  `alt_stack' indicates if it is
278
## delivered on an alternative stack. 
279
void,	 pre_deliver_signal,	ThreadId tid, Int sigNo, Bool alt_stack
280
## Called after a signal is delivered.  Nb: unfortunately, if the signal
281
## handler longjmps, this won't be called.
282
void,	post_deliver_signal,	ThreadId tid, Int sigNo
283
284
285
## Others... condition variable...
286
## ...
287
288
## Shadow memory management
289
void,	init_shadow_page,	Addr p
290
291
## ================================================================================
292
## malloc and friends
293
:malloc
294
void*,	malloc,			Int n
295
void*,	__builtin_new,		Int n
296
void*,	__builtin_vec_new,	Int n
297
void*,	memalign,		Int align, Int n
298
void*,	calloc,			Int nmemb, Int n
299
void,	free,			void* p
300
void,	__builtin_delete,	void* p
301
void,	__builtin_vec_delete,	void* p
302
void*,	realloc,		void* p, Int size
(-)valgrind-2.1.0/coregrind/ume.c (+704 lines)
Line 0 Link Here
1
2
/*--------------------------------------------------------------------*/
3
/*--- User-mode execve()                                     ume.c ---*/
4
/*--------------------------------------------------------------------*/
5
6
/*
7
   This file is part of Valgrind, an extensible x86 protected-mode
8
   emulator for monitoring program execution on x86-Unixes.
9
10
   Copyright (C) 2000-2004 Julian Seward 
11
      jseward@acm.org
12
13
   This program is free software; you can redistribute it and/or
14
   modify it under the terms of the GNU General Public License as
15
   published by the Free Software Foundation; either version 2 of the
16
   License, or (at your option) any later version.
17
18
   This program is distributed in the hope that it will be useful, but
19
   WITHOUT ANY WARRANTY; without even the implied warranty of
20
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21
   General Public License for more details.
22
23
   You should have received a copy of the GNU General Public License
24
   along with this program; if not, write to the Free Software
25
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26
   02111-1307, USA.
27
28
   The GNU General Public License is contained in the file COPYING.
29
*/
30
31
/*
32
  User-mode exec
33
34
  This bootstraps Valgrind.  This code decides on the layout of the
35
  client and Valgrind address spaces, loads valgrind.so and the
36
  skin.so into the valgrind part, loads the client executable (and the
37
  dynamic linker, if necessary) into the client part, and calls into
38
  Valgrind proper.
39
40
  The code is careful not to allow spurious mappings to appear in the
41
  wrong parts of the address space.  In particular, to make sure
42
  dlopen puts things in the right place, it will pad out the forbidden
43
  chunks of address space so that dlopen is forced to put things where
44
  we want them.
45
46
  The memory map it creates is:
47
48
  CLIENT_BASE    +-------------------------+
49
                 | client address space    |
50
	         :                         :
51
	         :                         :
52
		 | client stack            |
53
  client_end     +-------------------------+
54
                 | redzone                 |
55
  shadow_base    +-------------------------+
56
                 |                         |
57
	         : shadow memory for skins :
58
	         | (may be 0 sized)        |
59
  shadow_end     +-------------------------+
60
                 : gap (may be 0 sized)    :
61
  valgrind_base  +-------------------------+
62
                 | valgrind .so files      |
63
		 | and mappings            |
64
  valgrind_mmap_end                        -
65
                 | kickstart executable    |
66
                 -                         -
67
                 | valgrind heap  vvvvvvvvv|
68
  valgrind_end   -                         -
69
		 | valgrind stack ^^^^^^^^^|
70
                 +-------------------------+
71
		 : kernel                  :
72
 */
73
74
#define _GNU_SOURCE
75
#define _FILE_OFFSET_BITS 64
76
77
#include "vg_include.h"
78
79
#include <stddef.h>
80
#include <sys/mman.h>
81
#include <fcntl.h>
82
#include <errno.h>
83
#include <elf.h>
84
#include <stdio.h>
85
#include <string.h>
86
#include <stdlib.h>
87
#include <unistd.h>
88
#include <sys/stat.h>
89
#include <dlfcn.h>
90
#include <assert.h>
91
92
#include "ume.h"
93
94
static int padfile = -1;
95
static struct stat padstat;
96
97
extern int kickstart_base;	/* linker created */
98
99
void foreach_map(int (*fn)(void *start, void *end,
100
			   const char *perm, off_t offset,
101
			   int maj, int min, int ino))
102
{
103
   static char buf[10240];
104
   char *bufptr = buf;
105
   int ret, fd;
106
107
   fd = open("/proc/self/maps", O_RDONLY);
108
109
   if (fd == -1) {
110
      perror("open /proc/self/maps");
111
      return;
112
   }
113
114
   ret = read(fd, buf, sizeof(buf));
115
116
   if (ret == -1) {
117
      perror("read /proc/self/maps");
118
      close(fd);
119
      return;
120
   }
121
   close(fd);
122
123
   if (ret == sizeof(buf)) {
124
      fprintf(stderr, "buf too small\n");
125
      return;
126
   }
127
128
   while(bufptr && bufptr < buf+ret) {
129
      char perm[5];
130
      off_t offset;
131
      int maj, min;
132
      int ino;
133
      void *segstart, *segend;
134
135
      sscanf(bufptr, "%p-%p %s %Lx %x:%x %d",
136
	     &segstart, &segend, perm, &offset, &maj, &min, &ino);
137
      bufptr = strchr(bufptr, '\n');
138
      if (bufptr != NULL)
139
	 bufptr++; /* skip \n */
140
141
      if (!(*fn)(segstart, segend, perm, offset, maj, min, ino))
142
	 break;
143
   }
144
}
145
146
/* pad all the empty spaces in a range of address space to stop
147
   interlopers */
148
void as_pad(void *start, void *end)
149
{
150
   char buf[1024];
151
   char *addr;
152
153
   int fillgap(void *segstart, void *segend, const char *perm, off_t off, 
154
	       int maj, int min, int ino) {
155
      if (segstart >= end)
156
	 return 0;
157
158
      if ((char *)segstart > addr)
159
	 mmap(addr, (char *)segstart-addr, PROT_NONE, MAP_FIXED|MAP_PRIVATE,
160
	      padfile, 0);
161
      addr = segend;
162
	 
163
      return 1;
164
   }
165
166
   if (padfile == -1) {
167
      int seq = 1;
168
      do {
169
	 sprintf(buf, "/tmp/.pad.%d.%d", getpid(), seq++);
170
	 padfile = open(buf, O_RDWR|O_CREAT|O_EXCL, 0);
171
	 unlink(buf);
172
	 if (padfile == -1 && errno != EEXIST)
173
	    exit(44);
174
      } while(padfile == -1);
175
      fstat(padfile, &padstat);
176
   }
177
178
   addr = start;
179
180
   foreach_map(fillgap);
181
	
182
   if (addr < (char *)end)
183
      mmap(addr, (char *)end-addr, PROT_NONE, MAP_FIXED|MAP_PRIVATE,
184
	   padfile, 0);
185
}
186
187
/* remove padding from a range of address space - padding is always a
188
   mapping of padfile*/
189
void as_unpad(void *start, void *end)
190
{
191
   int killpad(void *segstart, void *segend, const char *perm, off_t off, 
192
	       int maj, int min, int ino) {
193
      void *b, *e;
194
195
      if (padstat.st_dev != makedev(maj, min) || padstat.st_ino != ino)
196
	 return 1;
197
198
      if (segend <= start || segstart >= end)
199
	 return 1;
200
201
      if (segstart <= start)
202
	 b = start;
203
      else
204
	 b = segstart;
205
206
      if (segend >= end)
207
	 e = end;
208
      else
209
	 e = segend;
210
211
      munmap(b, (char *)e-(char *)b);
212
213
      return 1;
214
   }
215
216
   if (padfile == -1)	/* no padfile, no padding */
217
      return;
218
219
   foreach_map(killpad);
220
}
221
222
void as_closepadfile(void)
223
{
224
   /* don't unpad */
225
   close(padfile);
226
   padfile = -1;
227
}
228
229
int as_getpadfd(void)
230
{
231
   return padfile;
232
}
233
234
void as_setpadfd(int fd)
235
{
236
   as_closepadfile();
237
   padfile = fd;
238
   fstat(padfile, &padstat);
239
}
240
241
struct ume_auxv *find_auxv(int *esp)
242
{
243
   esp++;			/* skip argc */
244
245
   while(*esp != 0)		/* skip argv */
246
      esp++;
247
   esp++;
248
249
   while(*esp != 0)		/* skip env */
250
      esp++;
251
   esp++;
252
   
253
   return (struct ume_auxv *)esp;
254
}
255
256
257
struct elfinfo *readelf(int fd, const char *filename)
258
{
259
   struct elfinfo *e = malloc(sizeof(*e));
260
   int phsz;
261
262
   e->fd = fd;
263
264
   if (pread(fd, &e->e, sizeof(e->e), 0) != sizeof(e->e)) {
265
      fprintf(stderr, "%s: can't read elf header: %s\n", 
266
	      filename, strerror(errno));
267
      return NULL;
268
   }
269
270
   if (memcmp(&e->e.e_ident[0], ELFMAG, SELFMAG) != 0) {
271
      fprintf(stderr, "%s: bad ELF magic\n",
272
	      filename);
273
      return NULL;
274
   }
275
   if (e->e.e_ident[EI_CLASS] != ELFCLASS32) {
276
      fprintf(stderr, "Can only handle 32-bit executables\n");
277
      return NULL;
278
   }
279
   if (e->e.e_ident[EI_DATA] != ELFDATA2LSB) {
280
      fprintf(stderr, "Expecting little-endian\n");
281
      return NULL;
282
   }
283
   if (!(e->e.e_type == ET_EXEC || e->e.e_type == ET_DYN)) {
284
      fprintf(stderr, "need executable\n");
285
      return NULL;
286
   }
287
288
   if (e->e.e_machine != EM_386) {
289
      fprintf(stderr, "need x86\n");
290
      return NULL;
291
   }
292
293
   if (e->e.e_phentsize != sizeof(ESZ(Phdr))) {
294
      fprintf(stderr, "sizeof Phdr wrong\n");
295
      return NULL;
296
   }
297
298
   phsz = sizeof(ESZ(Phdr)) * e->e.e_phnum;
299
   e->p = malloc(phsz);
300
301
   if (pread(fd, e->p, phsz, e->e.e_phoff) != phsz) {
302
      fprintf(stderr, "can't read phdr: %s\n", strerror(errno));
303
      return NULL;
304
   }
305
306
   return e;
307
}
308
309
#define REMAINS(x, a)   ((x)        & ((a)-1))
310
311
/* Map an ELF file.  Returns the brk address. */
312
ESZ(Addr) mapelf(struct elfinfo *e, ESZ(Addr) base, int setbrk)
313
{
314
   int i;
315
   ESZ(Addr) elfbrk = 0;
316
317
   for(i = 0; i < e->e.e_phnum; i++) {
318
      ESZ(Phdr) *ph = &e->p[i];
319
      ESZ(Addr) addr, brkaddr;
320
      ESZ(Word) memsz;
321
322
      if (ph->p_type != PT_LOAD)
323
	 continue;
324
325
      addr = ph->p_vaddr+base;
326
      memsz = ph->p_memsz;
327
      brkaddr = addr+memsz;
328
329
      if (brkaddr > elfbrk)
330
	 elfbrk = brkaddr;
331
   }
332
333
   if (setbrk) {
334
      /* sneaking up on the brk limit works better than actually
335
	 jumping directly there.  Unfortunately, setting the brk is
336
	 tested against the datasize rlimit, even though we're not
337
	 actually using any memory. */
338
      char *b = sbrk(0);
339
      char *initb = (char *)PGROUNDUP(b);
340
341
      while(b < (char *)elfbrk) {
342
	 unsigned delta = (char *)elfbrk - b;
343
	 static const unsigned limit = 256*1024*1024;
344
	 char *bb;
345
346
	 if (delta > limit)
347
	    delta = limit;
348
	 //printf("elfbrk=%p b=%p delta=%u\n", elfbrk, b, delta);
349
	 bb = sbrk(delta);
350
	 if (bb != b) {
351
	    fprintf(stderr, "sbrk failed while adjusting brk base: "
352
		    "perhaps we hit the datasize ulimit?\n");
353
	    return 0;
354
	 }
355
	 b += delta;
356
      }
357
      munmap(initb, (char *)PGROUNDDN(elfbrk)-initb);
358
   }
359
360
   for(i = 0; i < e->e.e_phnum; i++) {
361
      ESZ(Phdr) *ph = &e->p[i];
362
      ESZ(Addr) addr, bss, brkaddr;
363
      ESZ(Off) off;
364
      ESZ(Word) filesz;
365
      ESZ(Word) memsz;
366
      ESZ(Word) align;
367
      unsigned prot = 0;
368
369
      if (ph->p_type != PT_LOAD)
370
	 continue;
371
372
      if (ph->p_flags & PF_X)
373
	 prot |= PROT_EXEC;
374
      if (ph->p_flags & PF_W)
375
	 prot |= PROT_WRITE;
376
      if (ph->p_flags & PF_R)
377
	 prot |= PROT_READ;
378
379
      align = ph->p_align;
380
381
      addr = ph->p_vaddr+base;
382
      off =  ph->p_offset;
383
      filesz = ph->p_filesz;
384
      bss = addr+filesz;
385
      memsz = ph->p_memsz;
386
      brkaddr = addr+memsz;
387
388
      mmap((char *)ROUNDDN(addr, align), ROUNDUP(bss, align)-ROUNDDN(addr, align),
389
	   prot, MAP_FIXED|MAP_PRIVATE, e->fd, ROUNDDN(off, align));
390
391
      /* if memsz > filesz, then we need to fill the remainder with zeroed pages */
392
      if (memsz > filesz) {
393
	 UInt bytes;
394
395
	 bytes = ROUNDUP(brkaddr, align)-ROUNDUP(bss, align);
396
	 if (bytes > 0)
397
	    mmap((char *)ROUNDUP(bss, align), bytes,
398
		 prot, MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
399
400
	 bytes = bss & (VKI_BYTES_PER_PAGE - 1);
401
	 if (bytes > 0) {
402
	    bytes = VKI_BYTES_PER_PAGE - bytes;
403
	    memset((char *)bss, 0, bytes);
404
	 }
405
      }
406
   }
407
408
   return elfbrk;
409
}
410
411
412
static int do_exec_inner(const char *exe, struct exeinfo *info);
413
414
415
static int match_ELF(const char *hdr, int len)
416
{
417
   ESZ(Ehdr) *e = (ESZ(Ehdr) *)hdr;
418
   return (len > sizeof(*e)) && memcmp(&e->e_ident[0], ELFMAG, SELFMAG) == 0;
419
}
420
421
static int load_ELF(char *hdr, int len, int fd, const char *name, struct exeinfo *info)
422
{
423
   struct elfinfo *e;
424
   struct elfinfo *interp = NULL;
425
   ESZ(Addr) minaddr = ~0;
426
   ESZ(Addr) maxaddr = 0;
427
   ESZ(Addr) interp_addr = 0;
428
   ESZ(Word) interp_size = 0;
429
   int i;
430
   void *entry;
431
432
   e = readelf(fd, name);
433
434
   if (e == NULL)
435
      return ENOEXEC;
436
437
   info->phnum = e->e.e_phnum;
438
   info->entry = e->e.e_entry;
439
440
   for(i = 0; i < e->e.e_phnum; i++) {
441
      ESZ(Phdr) *ph = &e->p[i];
442
443
      switch(ph->p_type) {
444
      case PT_PHDR:
445
	 info->phdr = ph->p_vaddr;
446
	 break;
447
448
      case PT_LOAD:
449
	 if (ph->p_vaddr < minaddr)
450
	    minaddr = ph->p_vaddr;
451
	 if (ph->p_vaddr+ph->p_memsz > maxaddr)
452
	    maxaddr = ph->p_vaddr+ph->p_memsz;
453
	 break;
454
			
455
      case PT_INTERP: {
456
	 char *buf = malloc(ph->p_filesz+1);
457
	 int j;
458
	 int intfd;
459
	 int baseaddr_set;
460
461
	 pread(fd, buf, ph->p_filesz, ph->p_offset);
462
	 buf[ph->p_filesz] = '\0';
463
464
	 intfd = open(buf, O_RDONLY);
465
	 if (intfd == -1) {
466
	    perror("open interp");
467
	    exit(1);
468
	 }
469
470
	 interp = readelf(intfd, buf);
471
	 if (interp == NULL) {
472
	    fprintf(stderr, "Can't read interpreter\n");
473
	    return 1;
474
	 }
475
	 free(buf);
476
477
	 baseaddr_set = 0;
478
	 for(j = 0; j < interp->e.e_phnum; j++) {
479
	    ESZ(Phdr) *iph = &interp->p[j];
480
	    ESZ(Addr) end;
481
482
	    if (iph->p_type != PT_LOAD)
483
	       continue;
484
	    
485
	    if (!baseaddr_set) {
486
	       interp_addr = iph->p_vaddr;
487
	       baseaddr_set = 1;
488
	    }
489
490
	    /* assumes that all segments in the interp are close */
491
	    end = (iph->p_vaddr - interp_addr) + iph->p_memsz;
492
493
	    if (end > interp_size)
494
	       interp_size = end;
495
	 }
496
	 break;
497
      }
498
      }
499
   }
500
501
   if (info->exe_base != info->exe_end) {
502
      if (minaddr >= maxaddr ||
503
	  (minaddr < info->exe_base ||
504
	   maxaddr > info->exe_end)) {
505
	 fprintf(stderr, "Executable is mapped outside of range %p-%p\n",
506
		 (void *)info->exe_base, (void *)info->exe_end);
507
	 return ENOMEM;
508
      }
509
   }
510
511
   info->brkbase = mapelf(e, 0, info->setbrk);		/* map the executable */
512
513
   if (info->brkbase == 0)
514
      return ENOMEM;
515
516
   if (interp != NULL) {
517
      /* reserve a chunk of address space for interpreter */
518
      char *base = (char *)info->exe_base;
519
      char *baseoff;
520
      int flags = MAP_PRIVATE|MAP_ANONYMOUS;
521
522
      if (info->map_base != 0) {
523
	 base = (char *)info->map_base;
524
	 flags |= MAP_FIXED;
525
      }
526
527
      base = mmap(base, interp_size, PROT_NONE, flags, -1, 0);
528
529
      baseoff = base - interp_addr;
530
531
      mapelf(interp, (ESZ(Addr))baseoff, 0);
532
533
      close(interp->fd);
534
      free(interp);
535
536
      entry = baseoff + interp->e.e_entry;
537
      info->interp_base = (ESZ(Addr))base;
538
   } else
539
      entry = (void *)e->e.e_entry;
540
541
   info->exe_base = minaddr;
542
   info->exe_end = maxaddr;
543
544
   info->init_eip = (addr_t)entry;
545
546
   free(e);
547
548
   return 0;
549
}
550
551
552
static int match_script(const char *hdr, Int len)
553
{
554
   return (len > 2) && memcmp(hdr, "#!", 2) == 0;
555
}
556
557
static int load_script(char *hdr, int len, int fd, const char *name, struct exeinfo *info)
558
{
559
   char *interp;
560
   char *const end = hdr+len;
561
   char *cp;
562
   char *arg = NULL;
563
   int eol;
564
565
   interp = hdr + 2;
566
   while(interp < end && (*interp == ' ' || *interp == '\t'))
567
      interp++;
568
569
   if (*interp != '/')
570
      return ENOEXEC;		/* absolute path only for interpreter */
571
572
   /* skip over interpreter name */
573
   for(cp = interp; cp < end && *cp != ' ' && *cp != '\t' && *cp != '\n'; cp++)
574
      ;
575
576
   eol = (*cp == '\n');
577
578
   *cp++ = '\0';
579
580
   if (!eol && cp < end) {
581
      /* skip space before arg */
582
      while (cp < end && (*cp == '\t' || *cp == ' '))
583
	 cp++;
584
585
      /* arg is from here to eol */
586
      arg = cp;
587
      while (cp < end && *cp != '\n')
588
	 cp++;
589
      *cp = '\0';
590
   }
591
   
592
   info->argv0 = strdup(interp);
593
   assert(NULL != info->argv0);
594
   if (arg != NULL && *arg != '\0') {
595
      info->argv1 = strdup(arg);
596
      assert(NULL != info->argv1);
597
   }
598
599
   if (info->argv && info->argv[0] != NULL)
600
      info->argv[0] = (char *)name;
601
602
   if (0)
603
      printf("#! script: argv0=\"%s\" argv1=\"%s\"\n",
604
	     info->argv0, info->argv1);
605
606
   return do_exec_inner(interp, info);
607
}
608
609
struct binfmt {
610
   int	(*match)(const char *hdr, int len);
611
   int	(*load) (      char *hdr, int len, int fd, const char *name, struct exeinfo *);
612
};
613
614
static const struct binfmt formats[] = {
615
   { match_ELF,		load_ELF },
616
   { match_script,	load_script },
617
};
618
619
620
static int do_exec_inner(const char *exe, struct exeinfo *info)
621
{
622
   int fd;
623
   char buf[VKI_BYTES_PER_PAGE];
624
   int bufsz;
625
   int i;
626
   int ret;
627
   struct stat st;
628
629
   fd = open(exe, O_RDONLY);
630
   if (fd == -1) {
631
      if (0)
632
	 fprintf(stderr, "Can't open executable %s: %s\n",
633
		 exe, strerror(errno));
634
      return errno;
635
   }
636
637
   if (fstat(fd, &st) == -1) 
638
      return errno;
639
   else {
640
      uid_t uid = geteuid();
641
      gid_t gid = getegid();
642
      gid_t groups[32];
643
      int ngrp = getgroups(32, groups);
644
645
      if (st.st_mode & (S_ISUID | S_ISGID)) {
646
	 fprintf(stderr, "Can't execute suid/sgid executable %s\n", exe);
647
	 return EACCES;
648
      }
649
650
      if (uid == st.st_uid) {
651
	 if (!(st.st_mode & S_IXUSR))
652
	    return EACCES;
653
      } else {
654
	 int grpmatch = 0;
655
656
	 if (gid == st.st_gid)
657
	    grpmatch = 1;
658
	 else 
659
	    for(i = 0; i < ngrp; i++)
660
	       if (groups[i] == st.st_gid) {
661
		  grpmatch = 1;
662
		  break;
663
	       }
664
665
	 if (grpmatch) {
666
	    if (!(st.st_mode & S_IXGRP))
667
	       return EACCES;
668
	 } else if (!(st.st_mode & S_IXOTH))
669
	    return EACCES;
670
      }
671
   }
672
673
   bufsz = pread(fd, buf, sizeof(buf), 0);
674
   if (bufsz < 0) {
675
      fprintf(stderr, "Can't read executable header: %s\n",
676
	      strerror(errno));
677
      close(fd);
678
      return errno;
679
   }
680
681
   ret = ENOEXEC;
682
   for(i = 0; i < sizeof(formats)/sizeof(*formats); i++) {
683
      if ((formats[i].match)(buf, bufsz)) {
684
	 ret = (formats[i].load)(buf, bufsz, fd, exe, info);
685
	 break;
686
      }
687
   }
688
689
   close(fd);
690
691
   return ret;
692
}
693
694
int do_exec(const char *exe, struct exeinfo *info)
695
{
696
   info->argv0 = NULL;
697
   info->argv1 = NULL;
698
699
   return do_exec_inner(exe, info);
700
}
701
702
/*--------------------------------------------------------------------*/
703
/*--- end                                                    ume.c ---*/
704
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/ume.h (+103 lines)
Line 0 Link Here
1
2
/*
3
   This file is part of Valgrind, an extensible x86 protected-mode
4
   emulator for monitoring program execution on x86-Unixes.
5
6
   Copyright (C) 2000-2004 Julian Seward 
7
      jseward@acm.org
8
9
   This program is free software; you can redistribute it and/or
10
   modify it under the terms of the GNU General Public License as
11
   published by the Free Software Foundation; either version 2 of the
12
   License, or (at your option) any later version.
13
14
   This program is distributed in the hope that it will be useful, but
15
   WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
   General Public License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program; if not, write to the Free Software
21
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
   02111-1307, USA.
23
24
   The GNU General Public License is contained in the file COPYING.
25
*/
26
27
#ifndef _COREGRIND_UME_H
28
#define _COREGRIND_UME_H
29
30
#include <elf.h>
31
#include <sys/types.h>
32
33
#if	ELFSZ == 64
34
#define ESZ(x)	Elf64_##x
35
#elif	ELFSZ == 32
36
#define ESZ(x)	Elf32_##x
37
#else
38
#error ELFSZ needs to ==32 or ==64
39
#endif
40
41
/* Integer type the same size as a pointer */
42
typedef ESZ(Addr) addr_t;
43
44
struct exeinfo
45
{
46
   int		setbrk;		/* INPUT: if true, set the brk segment base */
47
   addr_t	map_base;	/* INPUT: if non-zero, base address of mappings  */
48
49
   addr_t	exe_base;	/* INOUT: lowest (allowed) address of exe	*/
50
   addr_t	exe_end;	/* INOUT: highest (allowed) address	*/
51
52
   addr_t	phdr;		/* address phdr was mapped at		*/
53
   int		phnum;		/* number of phdrs			*/
54
   addr_t	interp_base;	/* where interpreter (ld.so) was mapped	*/
55
   addr_t	entry;		/* entrypoint in main executable	*/
56
   addr_t	init_eip;	/* initial eip				*/
57
   addr_t	brkbase;	/* base address of brk segment		*/
58
59
   /* these are the extra args added by #! scripts */
60
   char		*argv0;		/* INPUT: the interpreter name */
61
   char		*argv1;		/* INPUT: the args for the interpreter */
62
63
   char		**argv;		/* INPUT: the original argv */
64
};
65
66
int do_exec(const char *exe, struct exeinfo *info);
67
68
void foreach_map(int (*fn)(void *start, void *end,
69
			   const char *perm, off_t offset,
70
			   int maj, int min, int ino));
71
void as_pad(void *start, void *end);
72
void as_unpad(void *start, void *end);
73
void as_closepadfile(void);
74
int  as_getpadfd(void);
75
void as_setpadfd(int);
76
77
struct elfinfo
78
{
79
   ESZ(Ehdr)	e;
80
   ESZ(Phdr)	*p;
81
   int		fd;
82
};
83
84
struct elfinfo *readelf(int fd, const char *filename);
85
ESZ(Addr) mapelf(struct elfinfo *e, ESZ(Addr) base, int setbrk);
86
87
struct ume_auxv
88
{
89
   int	a_type;
90
   union {
91
      void *a_ptr;
92
      int   a_val;
93
      void (*a_fcn)(void);
94
   } u;
95
};
96
97
struct ume_auxv *find_auxv(int *orig_esp);
98
99
/* Our private auxv entries */
100
#define AT_UME_PADFD	0xff01	/* padding file fd */
101
#define AT_UME_EXECFD	0xff02	/* stage1 executable fd */
102
103
#endif /* _COREGRIND_UME_H */
(-)valgrind-2.1.0/coregrind/ume_arch.h (+36 lines)
Line 0 Link Here
1
2
/*
3
   This file is part of Valgrind, an extensible x86 protected-mode
4
   emulator for monitoring program execution on x86-Unixes.
5
6
   Copyright (C) 2000-2004 Julian Seward 
7
      jseward@acm.org
8
9
   This program is free software; you can redistribute it and/or
10
   modify it under the terms of the GNU General Public License as
11
   published by the Free Software Foundation; either version 2 of the
12
   License, or (at your option) any later version.
13
14
   This program is distributed in the hope that it will be useful, but
15
   WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
   General Public License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program; if not, write to the Free Software
21
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
   02111-1307, USA.
23
24
   The GNU General Public License is contained in the file COPYING.
25
*/
26
27
#ifndef UME_ARCH
28
#define UME_ARCH
29
30
#include "ume.h"
31
32
void ume_go(addr_t eip, addr_t esp) __attribute__((noreturn));
33
34
extern void *ume_exec_esp;	/* esp on entry at exec time */
35
36
#endif /* UME_ARCH */
(-)valgrind-2.1.0/coregrind/valgrind.in (-175 lines)
Lines 1-175 Link Here
1
#!/bin/sh
2
##--------------------------------------------------------------------##
3
##--- The startup script.                                 valgrind ---##
4
##--------------------------------------------------------------------##
5
6
#  This file is part of Valgrind, an extensible x86 protected-mode
7
#  emulator for monitoring program execution on x86-Unixes.
8
#
9
#  Copyright (C) 2002-2003 Julian Seward
10
#     jseward@acm.org
11
#
12
#  This program is free software; you can redistribute it and/or
13
#  modify it under the terms of the GNU General Public License as
14
#  published by the Free Software Foundation; either version 2 of the
15
#  License, or (at your option) any later version.
16
#
17
#  This program is distributed in the hope that it will be useful, but
18
#  WITHOUT ANY WARRANTY; without even the implied warranty of
19
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
#  General Public License for more details.
21
#
22
#  You should have received a copy of the GNU General Public License
23
#  along with this program; if not, write to the Free Software
24
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25
#  02111-1307, USA.
26
#
27
#  The GNU General Public License is contained in the file COPYING.
28
29
30
# Should point to the installation directory
31
prefix="@prefix@"
32
exec_prefix="@exec_prefix@"
33
VALGRIND="@libdir@/valgrind"
34
35
# Other stuff ...
36
version="@VERSION@"
37
emailto="jseward@acm.org"
38
39
# The default name of the suppressions file
40
vgsupp="--suppressions=$VALGRIND/default.supp"
41
42
# Valgrind options
43
vgopts=
44
45
# Tool to use, chosen by --tool=<foo>, defaults to Memcheck 
46
tool=memcheck
47
48
# --in-place=<dir> arg, for using non-installed version
49
in_place_arg=
50
51
# Default core+tool to use are the installed ones
52
coredir=$VALGRIND
53
tooldir=$VALGRIND
54
55
# Collect up args for Valgrind.  Only some are intercepted here;
56
# the rest are passed to vg_main.c.  Allow --skin for backwards compatibility.
57
while [ $# != 0 ]
58
do
59
  arg=$1
60
  case "$arg" in
61
    --version)              echo "valgrind-$version"; exit 1 ;;
62
    --tool=*)               tool=`echo $arg | sed 's/--tool=//'`;  shift;;
63
    --skin=*)               tool=`echo $arg | sed 's/--skin=//'`;  shift;;
64
    --in-place=*)           in_place_arg=$arg;        shift;;
65
    -*)                     vgopts="$vgopts $arg";    shift;;
66
    *)                      break;;
67
  esac
68
done
69
70
71
# If running uninstalled version in-place...
72
if [ z"$in_place_arg" != z ]; then
73
   in_place_dir=`echo $in_place_arg | sed 's/--in-place=//'`
74
   tooldir="$in_place_dir/$tool"
75
   coredir="$in_place_dir/coregrind/.in_place"
76
   vgsupp="--suppressions=$in_place_dir/default.supp"
77
fi
78
79
# Setup tool shared object.
80
tool_so="vgskin_${tool}.so"
81
if [ ! -r "$tooldir/$tool_so" ] ; then
82
   echo
83
   echo "Tool error:"
84
   echo "  The shared library \`$tool_so' for the chosen"
85
   echo "  tool \`$tool' could not be found in"
86
   echo "  $tooldir"
87
   echo
88
   exit 1
89
fi
90
91
VG_ARGS="$VALGRIND_OPTS $vgsupp $vgopts"
92
93
export VG_ARGS
94
95
# Red Hat Linux 9 uses NPTL, which has a kernel interface 
96
# unlike the linuxthreads interface valgrind expects.  We can
97
# tell the dynamic loader to disable this interface using
98
# an environment variable.
99
100
if getconf GNU_LIBPTHREAD_VERSION 2>/dev/null | grep -qi NPTL 2>/dev/null; then
101
   LD_ASSUME_KERNEL=2.4.1
102
   export LD_ASSUME_KERNEL
103
fi
104
105
# Check that the program looks ok
106
is_prog=0
107
108
if [ $# != 0 ] ; then
109
110
   # Ensure the program exists.  Ignore any error messages from 'which'.
111
   which_prog=`which $1 2> /dev/null`
112
   if [ z$which_prog = z ] && (echo "$1" | grep -q '/'); then
113
      which_prog=$1
114
   fi
115
116
   if  [ z$which_prog = z ]; then
117
      echo "$0: '$1' not found in \$PATH, aborting."
118
      exit
119
   fi
120
121
   if [ $# != 0 ] ; then
122
      case `file -L "$which_prog"` in       # must follow symlinks, hence -L
123
      # Ensure the program isn't statically linked.
124
      *"statically linked"*)
125
        echo "\`$which_prog' is statically linked"
126
        echo "Valgrind only works on dynamically linked executables;  your"
127
        echo "program must rely on at least one shared object for Valgrind"
128
        echo "to work with it.  Read FAQ #5 for more information."
129
        exit 1 ;;
130
      # Ensure that there are no setuid or gid flags
131
      *:\ set?id\ ELF*)
132
        echo "\`$which_prog' is suid/sgid."
133
        echo "Valgrind can't handle these executables, as it"
134
        echo "requires the LD_PRELOAD feature in order to work."
135
        echo ""
136
        echo "Remove those flags and try again."
137
        echo ""
138
        exit 1
139
        ;;
140
      esac
141
   fi
142
143
   is_prog=1
144
fi
145
146
# A bit subtle.  The LD_PRELOAD added entry must be absolute
147
# and not depend on LD_LIBRARY_PATH.  This is so that we can
148
# mess with LD_LIBRARY_PATH for child processes, which makes
149
# libpthread.so fall out of visibility, independently of
150
# whether valgrind.so is visible.
151
152
LD_LIBRARY_PATH=$coredir:$LD_LIBRARY_PATH
153
export LD_LIBRARY_PATH
154
155
# Insert tool .so before valgrind.so to override template functions.
156
LD_PRELOAD=$tooldir/$tool_so:$coredir/valgrind.so:$LD_PRELOAD
157
export LD_PRELOAD
158
#LD_DEBUG=files
159
#LD_DEBUG=symbols
160
#export LD_DEBUG
161
    
162
# Actually run the program, under Valgrind's control
163
if [ $is_prog = 1 ] ; then
164
   exec "$@"
165
else
166
   # If no command given, act like -h was given so vg_main.c prints out the
167
   # usage string.  And pass to 'exec' the name of any program -- it doesn't
168
   # matter which -- because it won't be run anyway (we use 'true').
169
   VG_ARGS="$VG_ARGS -h"
170
   exec true
171
fi
172
173
##--------------------------------------------------------------------##
174
##--- end                                                 valgrind ---##
175
##--------------------------------------------------------------------##
(-)valgrind-2.1.0/coregrind/valgrind.vs (-1 / +2 lines)
Lines 1-9 Link Here
1
VALGRIND_2.0 {
1
{
2
	global:
2
	global:
3
		vgPlain_*;
3
		vgPlain_*;
4
		vgSkin_*;
4
		vgSkin_*;
5
		vgProf_*;
5
		vgProf_*;
6
                vgOff_*;
6
                vgOff_*;
7
7
	local:
8
	local:
8
		*;		# default to hidden
9
		*;		# default to hidden
9
};
10
};
(-)valgrind-2.1.0/coregrind/vg_constants.h (-1 / +92 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 48-53 Link Here
48
   scheduler.  */
48
   scheduler.  */
49
#define VG_TRC_EBP_JMP_SYSCALL    19 /* EBP and TRC */
49
#define VG_TRC_EBP_JMP_SYSCALL    19 /* EBP and TRC */
50
#define VG_TRC_EBP_JMP_CLIENTREQ  23 /* EBP and TRC */
50
#define VG_TRC_EBP_JMP_CLIENTREQ  23 /* EBP and TRC */
51
#define VG_TRC_EBP_JMP_YIELD      27 /* EBP and TRC */
51
52
52
#define VG_TRC_INNER_FASTMISS     31 /* TRC only; means fast-cache miss. */
53
#define VG_TRC_INNER_FASTMISS     31 /* TRC only; means fast-cache miss. */
53
#define VG_TRC_INNER_COUNTERZERO  29 /* TRC only; means bb ctr == 0 */
54
#define VG_TRC_INNER_COUNTERZERO  29 /* TRC only; means bb ctr == 0 */
Lines 65-70 Link Here
65
/* Offset of code in a TCEntry */
66
/* Offset of code in a TCEntry */
66
#define VG_CODE_OFFSET		(8 + VG_MAX_JUMPS * 2)
67
#define VG_CODE_OFFSET		(8 + VG_MAX_JUMPS * 2)
67
68
69
/* Client address space segment limit descriptor entry */
70
#define VG_POINTERCHECK_SEGIDX	1
71
68
/* Debugging hack for assembly code ... sigh. */
72
/* Debugging hack for assembly code ... sigh. */
69
#if 0
73
#if 0
70
#define OYNK(nnn) pushal;  pushl $nnn; call VG_(oynk) ; addl $4,%esp; popal
74
#define OYNK(nnn) pushal;  pushl $nnn; call VG_(oynk) ; addl $4,%esp; popal
Lines 90-95 Link Here
90
/* Assembly code stubs make this request */
94
/* Assembly code stubs make this request */
91
#define VG_USERREQ__SIGNAL_RETURNS          0x4001
95
#define VG_USERREQ__SIGNAL_RETURNS          0x4001
92
96
97
/* 
98
   0 - standard feature flags
99
   1 - Intel extended flags
100
   2 - Valgrind internal flags
101
   3 - AMD-specific flags
102
 */
103
#define VG_N_FEATURE_WORDS	4
104
105
#define VG_X86_FEAT		0
106
#define VG_EXT_FEAT		1
107
#define VG_INT_FEAT		2
108
#define VG_AMD_FEAT		3
109
110
/* CPU features (generic) */
111
#define VG_X86_FEAT_FPU		(VG_X86_FEAT*32 + 0)
112
#define VG_X86_FEAT_VME		(VG_X86_FEAT*32 + 1)
113
#define VG_X86_FEAT_DE		(VG_X86_FEAT*32 + 2)
114
#define VG_X86_FEAT_PSE		(VG_X86_FEAT*32 + 3)
115
#define VG_X86_FEAT_TSC		(VG_X86_FEAT*32 + 4)
116
#define VG_X86_FEAT_MSR		(VG_X86_FEAT*32 + 5)
117
#define VG_X86_FEAT_PAE		(VG_X86_FEAT*32 + 6)
118
#define VG_X86_FEAT_MCE		(VG_X86_FEAT*32 + 7)
119
#define VG_X86_FEAT_CX8		(VG_X86_FEAT*32 + 8)
120
#define VG_X86_FEAT_APIC	(VG_X86_FEAT*32 + 9)
121
#define VG_X86_FEAT_SEP		(VG_X86_FEAT*32 + 11)
122
#define VG_X86_FEAT_MTRR	(VG_X86_FEAT*32 + 12)
123
#define VG_X86_FEAT_PGE		(VG_X86_FEAT*32 + 13)
124
#define VG_X86_FEAT_MCA		(VG_X86_FEAT*32 + 14)
125
#define VG_X86_FEAT_CMOV	(VG_X86_FEAT*32 + 15)
126
#define VG_X86_FEAT_PAT		(VG_X86_FEAT*32 + 16)
127
#define VG_X86_FEAT_PSE36	(VG_X86_FEAT*32 + 17)
128
#define VG_X86_FEAT_CLFSH	(VG_X86_FEAT*32 + 19)
129
#define VG_X86_FEAT_DS		(VG_X86_FEAT*32 + 21)
130
#define VG_X86_FEAT_ACPI	(VG_X86_FEAT*32 + 22)
131
#define VG_X86_FEAT_MMX		(VG_X86_FEAT*32 + 23)
132
#define VG_X86_FEAT_FXSR	(VG_X86_FEAT*32 + 24)
133
#define VG_X86_FEAT_SSE		(VG_X86_FEAT*32 + 25)
134
#define VG_X86_FEAT_SSE2	(VG_X86_FEAT*32 + 26)
135
#define VG_X86_FEAT_SS		(VG_X86_FEAT*32 + 27)
136
#define VG_X86_FEAT_HT		(VG_X86_FEAT*32 + 28)
137
#define VG_X86_FEAT_TM		(VG_X86_FEAT*32 + 29)
138
#define VG_X86_FEAT_IA64	(VG_X86_FEAT*32 + 30)
139
#define VG_X86_FEAT_PBE		(VG_X86_FEAT*32 + 31)
140
141
/* Intel extended feature word */
142
#define VG_X86_FEAT_SSE3	(VG_EXT_FEAT*32 + 0)
143
#define VG_X86_FEAT_MON		(VG_EXT_FEAT*32 + 3)
144
#define VG_X86_FEAT_DSCPL	(VG_EXT_FEAT*32 + 4)
145
#define VG_X86_FEAT_EST		(VG_EXT_FEAT*32 + 7)
146
#define VG_X86_FEAT_TM2		(VG_EXT_FEAT*32 + 8)
147
#define VG_X86_FEAT_CNXTID	(VG_EXT_FEAT*32 + 10)
148
149
/* Used internally to mark whether CPUID is even implemented */
150
#define VG_X86_FEAT_CPUID	(VG_INT_FEAT*32 + 0)
151
152
/* AMD special features */
153
#define VG_AMD_FEAT_SYSCALL	(VG_AMD_FEAT*32 + 11)
154
#define VG_AMD_FEAT_NXP		(VG_AMD_FEAT*32 + 20)
155
#define VG_AMD_FEAT_MMXEXT	(VG_AMD_FEAT*32 + 22)
156
#define VG_AMD_FEAT_FFXSR	(VG_AMD_FEAT*32 + 25)
157
#define VG_AMD_FEAT_LONGMODE	(VG_AMD_FEAT*32 + 29)
158
#define VG_AMD_FEAT_3DNOWEXT	(VG_AMD_FEAT*32 + 30)
159
#define VG_AMD_FEAT_3DNOW	(VG_AMD_FEAT*32 + 31)
160
161
/* Various environment variables we pay attention to */
162
163
/* The directory we look for all our auxillary files in */
164
#define VALGRINDLIB	"VALGRINDLIB"
165
166
/* Additional command-line arguments; they are overridden by actual
167
   command-line option.  Each argument is separated by spaces.  There
168
   is no quoting mechanism.
169
 */
170
#define VALGRINDOPTS	"VALGRIND_OPTS"
171
172
/* If this variable is present in the environment, then valgrind will
173
   not parse the command line for options at all; all options come
174
   from this variable.  Arguments are terminated by ^A (\001).  There
175
   is no quoting mechanism.
176
177
   This variable is not expected to be set by anything other than
178
   Valgrind itself, as part of its handling of execve with
179
   --trace-children=yes.  This variable should not be present in the
180
   client environment.
181
 */
182
#define VALGRINDCLO	"_VALGRIND_CLO"
183
93
#endif /* ndef __VG_CONSTANTS_H */
184
#endif /* ndef __VG_CONSTANTS_H */
94
185
95
/*--------------------------------------------------------------------*/
186
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/vg_default.c (-103 / +3 lines)
Lines 9-15 Link Here
9
   This file is part of Valgrind, an extensible x86 protected-mode
9
   This file is part of Valgrind, an extensible x86 protected-mode
10
   emulator for monitoring program execution on x86-Unixes.
10
   emulator for monitoring program execution on x86-Unixes.
11
11
12
   Copyright (C) 2000-2003 Nicholas Nethercote
12
   Copyright (C) 2000-2004 Nicholas Nethercote
13
      njn25@cam.ac.uk
13
      njn25@cam.ac.uk
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 31-40 Link Here
31
*/
31
*/
32
32
33
33
34
/* These functions aren't intended to be run.  Replacement functions used by
35
 * the chosen tool are substituted by compiling the tool into a .so and
36
 * LD_PRELOADing it.  Nasty :) */
37
38
#include "vg_include.h"
34
#include "vg_include.h"
39
35
40
/* ---------------------------------------------------------------------
36
/* ---------------------------------------------------------------------
Lines 44-51 Link Here
44
/* If the tool fails to define one or more of the required functions,
40
/* If the tool fails to define one or more of the required functions,
45
 * make it very clear what went wrong! */
41
 * make it very clear what went wrong! */
46
42
47
static __attribute__ ((noreturn))
43
__attribute__ ((noreturn))
48
void fund_panic ( const Char* fn )
44
void VG_(missing_tool_func) ( const Char* fn )
49
{
45
{
50
   VG_(printf)(
46
   VG_(printf)(
51
      "\nTool error:\n"
47
      "\nTool error:\n"
Lines 56-72 Link Here
56
}
52
}
57
53
58
static __attribute__ ((noreturn))
54
static __attribute__ ((noreturn))
59
void non_fund_panic ( const Char* fn )
60
{
61
   VG_(printf)(
62
      "\nTool error:\n"
63
      "  The tool you have selected is missing the function `%s'\n"
64
      "  required by one of its needs.\n\n",
65
      fn);
66
   VG_(skin_panic)("Missing tool function");
67
}
68
69
static __attribute__ ((noreturn))
70
void malloc_panic ( const Char* fn )
55
void malloc_panic ( const Char* fn )
71
{
56
{
72
   VG_(printf)(
57
   VG_(printf)(
Lines 77-158 Link Here
77
   VG_(skin_panic)("Missing tool function");
62
   VG_(skin_panic)("Missing tool function");
78
}
63
}
79
64
80
#define FUND(proto)                       \
81
__attribute__((weak))                     \
82
proto                                     \
83
{                                         \
84
   fund_panic(__PRETTY_FUNCTION__);       \
85
}
86
87
#define NON_FUND(proto)                   \
88
__attribute__((weak))                     \
89
proto                                     \
90
{                                         \
91
   non_fund_panic(__PRETTY_FUNCTION__);   \
92
}
93
94
#define MALLOC(proto)                     \
95
__attribute__((weak))                     \
96
proto                                     \
97
{                                         \
98
   malloc_panic(__PRETTY_FUNCTION__);     \
99
}
100
101
/* ---------------------------------------------------------------------
102
   Default functions
103
   ------------------------------------------------------------------ */
104
105
/* Fundamental template functions */
106
FUND( void        SK_(pre_clo_init) (void) );
107
FUND( void        SK_(post_clo_init)(void) );
108
FUND( UCodeBlock* SK_(instrument)   (UCodeBlock* cb, Addr not_used) );
109
FUND( void        SK_(fini)         (Int exitcode) );
110
111
/* For error reporting and suppression handling */
112
NON_FUND( Bool  SK_(eq_SkinError)(VgRes res, Error* e1, Error* e2) );
113
NON_FUND( void  SK_(pp_SkinError)(Error* err) );
114
NON_FUND( UInt  SK_(update_extra)(Error* err) );
115
NON_FUND( Bool  SK_(recognised_suppression)(Char* name, Supp* su) );
116
NON_FUND( Bool  SK_(read_extra_suppression_info)(Int fd, Char* buf, Int nBuf,
117
                                                 Supp* su) );
118
NON_FUND( Bool  SK_(error_matches_suppression)(Error* err, Supp* su) );
119
NON_FUND( Char* SK_(get_error_name)(Error* err) );
120
NON_FUND( void  SK_(print_extra_suppression_info)(Error* err) );
121
122
/* For throwing out basic block level info when code is invalidated */
123
NON_FUND( void SK_(discard_basic_block_info)(Addr a, UInt size) );
124
125
/* For throwing out basic block level info when code is invalidated */
126
NON_FUND( void SK_(written_shadow_regs_values)(UInt* gen_reg, UInt* eflags) );
127
128
/* Command line arg handling functions */
129
NON_FUND( Bool SK_(process_cmd_line_option)(Char* argv) );
130
NON_FUND( void SK_(print_usage)(void) );
131
NON_FUND( void SK_(print_debug_usage)(void) );
132
133
/* Client request template function */
134
NON_FUND( Bool SK_(handle_client_request)(ThreadId tid, UInt* arg_block,
135
                                          UInt *ret) );
136
137
/* UCode extension */
138
NON_FUND( void  SK_(emit_XUInstr)  (UInstr* u, RRegSet regs_live_before) );
139
NON_FUND( Bool  SK_(sane_XUInstr)  (Bool beforeRA, Bool beforeLiveness, 
140
                                    UInstr* u) );
141
NON_FUND( Char* SK_(name_XUOpcode) (Opcode opc) );
142
NON_FUND( void  SK_(pp_XUInstr)    (UInstr* u) );
143
NON_FUND( Int   SK_(get_Xreg_usage)(UInstr* u, Tag tag, Int* regs,
144
                                    Bool* isWrites) );               
145
146
/* Syscall wrapping */
147
NON_FUND( void* SK_(pre_syscall) (ThreadId tid, UInt syscallno,
148
                                  Bool is_blocking) );
149
NON_FUND( void  SK_(post_syscall)(ThreadId tid, UInt syscallno,
150
                                 void* pre_result, Int res, Bool is_blocking) );
151
152
/* Sanity checks */
153
NON_FUND( Bool SK_(cheap_sanity_check)(void) );
154
NON_FUND( Bool SK_(expensive_sanity_check)(void) );
155
156
/*------------------------------------------------------------*/
65
/*------------------------------------------------------------*/
157
/*--- Replacing malloc et al                               ---*/
66
/*--- Replacing malloc et al                               ---*/
158
/*------------------------------------------------------------*/
67
/*------------------------------------------------------------*/
Lines 188-202 Link Here
188
      malloc_panic(__PRETTY_FUNCTION__);
97
      malloc_panic(__PRETTY_FUNCTION__);
189
}
98
}
190
99
191
MALLOC( void* SK_(__builtin_new)    ( Int size ) );
192
MALLOC( void* SK_(__builtin_vec_new)( Int size ) );
193
MALLOC( void* SK_(memalign)         ( Int align, Int size ) );
194
MALLOC( void* SK_(calloc)           ( Int nmemb, Int size ) );
195
196
MALLOC( void  SK_(__builtin_delete)     ( void* p ) );
197
MALLOC( void  SK_(__builtin_vec_delete) ( void* p ) );
198
MALLOC( void* SK_(realloc)              ( void* p, Int new_size ) );
199
200
/*--------------------------------------------------------------------*/
100
/*--------------------------------------------------------------------*/
201
/*--- end                                            vg_defaults.c ---*/
101
/*--- end                                            vg_defaults.c ---*/
202
/*--------------------------------------------------------------------*/
102
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/vg_demangle.c (-1 / +1 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/coregrind/vg_dispatch.S (-25 / +23 lines)
Lines 8-14 Link Here
8
  This file is part of Valgrind, an extensible x86 protected-mode
8
  This file is part of Valgrind, an extensible x86 protected-mode
9
  emulator for monitoring program execution on x86-Unixes.
9
  emulator for monitoring program execution on x86-Unixes.
10
10
11
  Copyright (C) 2000-2003 Julian Seward 
11
  Copyright (C) 2000-2004 Julian Seward 
12
     jseward@acm.org
12
     jseward@acm.org
13
13
14
  This program is free software; you can redistribute it and/or
14
  This program is free software; you can redistribute it and/or
Lines 76-81 Link Here
76
	pushl	%edi
76
	pushl	%edi
77
	pushl	%ebp
77
	pushl	%ebp
78
78
79
	/* check to see if we're doing pointer checking */
80
	movb	VG_(clo_pointercheck), %al
81
	testb	%al,%al
82
	jz	1f
83
	
84
	pushl	%fs						/* save %fs     */
85
	mov	$(VG_POINTERCHECK_SEGIDX << 3) + 7, %eax	/* load new %fs */
86
	movw	%ax,%fs
87
88
1:	
79
	/* Set up the baseBlock pointer */
89
	/* Set up the baseBlock pointer */
80
	movl	$VG_(baseBlock), %ebp
90
	movl	$VG_(baseBlock), %ebp
81
91
Lines 99-106 Link Here
99
	
109
	
100
	   If %ebp has any other value, we panic.
110
	   If %ebp has any other value, we panic.
101
	*/
111
	*/
102
	cmpl	$VG_(baseBlock), %ebp
112
	/*cmpl	$VG_(baseBlock), %ebp*/
103
	jnz	dispatch_exceptional
113
	/*jnz	dispatch_exceptional*/
104
	/* fall into main loop */
114
	/* fall into main loop */
105
115
106
116
Lines 137-143 Link Here
137
	jmp	run_innerloop_exit
147
	jmp	run_innerloop_exit
138
	
148
	
139
run_innerloop_exit:
149
run_innerloop_exit:
140
	popl	%ebp
150
	movb	VG_(clo_pointercheck), %bl
151
	testb	%bl,%bl
152
	jz	1f
153
154
	/* restore %fs */
155
	popl	%fs
156
	
157
1:	popl	%ebp
141
	popl	%edi
158
	popl	%edi
142
	popl	%esi
159
	popl	%esi
143
	popl	%edx
160
	popl	%edx
Lines 152-183 Link Here
152
*/
169
*/
153
dispatch_exceptional:
170
dispatch_exceptional:
154
	/* this is jumped to only, not fallen-through from above */
171
	/* this is jumped to only, not fallen-through from above */
155
	cmpl	$VG_TRC_EBP_JMP_SYSCALL, %ebp
156
	jz	dispatch_syscall
157
	cmpl	$VG_TRC_EBP_JMP_CLIENTREQ, %ebp
158
	jz	dispatch_clientreq
159
	cmpl	$VG_TRC_INNER_COUNTERZERO, %ebp
172
	cmpl	$VG_TRC_INNER_COUNTERZERO, %ebp
160
	jz	counter_is_zero
173
	jz	counter_is_zero
161
	
162
	/* ebp has an invalid value ... crap out. */
163
	pushl	$panic_msg_ebp
164
	call	VG_(core_panic)
165
	/* (never returns) */
166
174
167
dispatch_syscall:
168
	/* save %eax in %EIP and defer to sched */
175
	/* save %eax in %EIP and defer to sched */
169
	movl	$VG_(baseBlock), %ebp
170
	movl	VGOFF_(m_eip), %esi
176
	movl	VGOFF_(m_eip), %esi
171
	movl	%eax, (%ebp, %esi, 4)
177
	movl	%eax, VG_(baseBlock)(,%esi, 4)
172
	movl	$VG_TRC_EBP_JMP_SYSCALL, %eax
178
	movl	%ebp, %eax
173
	jmp	run_innerloop_exit
174
	
175
dispatch_clientreq:
176
	/* save %eax in %EIP and defer to sched */
177
	movl	$VG_(baseBlock), %ebp
178
	movl	VGOFF_(m_eip), %esi
179
	movl	%eax, (%ebp, %esi, 4)
180
	movl	$VG_TRC_EBP_JMP_CLIENTREQ, %eax
181
	jmp	run_innerloop_exit
179
	jmp	run_innerloop_exit
182
180
183
181
(-)valgrind-2.1.0/coregrind/vg_dummy_profile.c (-1 / +1 lines)
Lines 9-15 Link Here
9
   This file is part of Valgrind, an extensible x86 protected-mode
9
   This file is part of Valgrind, an extensible x86 protected-mode
10
   emulator for monitoring program execution on x86-Unixes.
10
   emulator for monitoring program execution on x86-Unixes.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/coregrind/vg_dwarf.c (-1 / +1 lines)
Lines 6-12 Link Here
6
   This file is part of Valgrind, an extensible x86 protected-mode
6
   This file is part of Valgrind, an extensible x86 protected-mode
7
   emulator for monitoring program execution on x86-Unixes.
7
   emulator for monitoring program execution on x86-Unixes.
8
8
9
   Copyright (C) 2000-2003 Julian Seward
9
   Copyright (C) 2000-2004 Julian Seward
10
      jseward@acm.org
10
      jseward@acm.org
11
11
12
   This program is free software; you can redistribute it and/or
12
   This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/coregrind/vg_errcontext.c (-33 / +22 lines)
Lines 7-13 Link Here
7
   This file is part of Valgrind, an extensible x86 protected-mode
7
   This file is part of Valgrind, an extensible x86 protected-mode
8
   emulator for monitoring program execution on x86-Unixes.
8
   emulator for monitoring program execution on x86-Unixes.
9
9
10
   Copyright (C) 2000-2003 Julian Seward 
10
   Copyright (C) 2000-2004 Julian Seward 
11
      jseward@acm.org
11
      jseward@acm.org
12
12
13
   This program is free software; you can redistribute it and/or
13
   This program is free software; you can redistribute it and/or
Lines 111-117 Link Here
111
   }
111
   }
112
}
112
}
113
113
114
/* Figure out if we want to attach for GDB for this error, possibly
114
/* Figure out if we want to perform a given action for this error, possibly
115
   by asking the user. */
115
   by asking the user. */
116
Bool VG_(is_action_requested) ( Char* action, Bool* clo )
116
Bool VG_(is_action_requested) ( Char* action, Bool* clo )
117
{
117
{
Lines 191-197 Link Here
191
   vg_assert( tid < VG_N_THREADS );
191
   vg_assert( tid < VG_N_THREADS );
192
}
192
}
193
193
194
void VG_(gen_suppression)(Error* err)
194
static void gen_suppression(Error* err)
195
{
195
{
196
   Int         i;
196
   Int         i;
197
   UChar       buf[M_VG_ERRTXT];
197
   UChar       buf[M_VG_ERRTXT];
Lines 247-276 Link Here
247
}
247
}
248
248
249
static 
249
static 
250
void do_actions_on_error(Error* err, Bool allow_GDB_attach)
250
void do_actions_on_error(Error* err, Bool allow_db_attach)
251
{
251
{
252
   /* Perhaps we want a GDB attach at this point? */
252
   /* Perhaps we want a debugger attach at this point? */
253
   if (allow_GDB_attach &&
253
   if (allow_db_attach &&
254
       VG_(is_action_requested)( "Attach to GDB", & VG_(clo_GDB_attach) )) 
254
       VG_(is_action_requested)( "Attach to debugger", & VG_(clo_db_attach) )) 
255
   {
255
   {
256
      Addr m_eip, m_esp, m_ebp; 
256
      VG_(printf)("starting debugger\n");
257
      
257
      VG_(start_debugger)( err->tid );
258
      if (VG_(is_running_thread)( err->tid )) {
259
         m_eip = VG_(baseBlock)[VGOFF_(m_eip)];
260
         m_esp = VG_(baseBlock)[VGOFF_(m_esp)];
261
         m_ebp = VG_(baseBlock)[VGOFF_(m_ebp)];
262
      } else {
263
         ThreadState* tst = & VG_(threads)[ err->tid ];
264
         m_eip = tst->m_eip;
265
         m_esp = tst->m_esp;
266
         m_ebp = tst->m_ebp;
267
      }
268
      VG_(swizzle_esp_then_start_GDB)( m_eip, m_esp, m_ebp );
269
   }
258
   }
270
   /* Or maybe we want to generate the error's suppression? */
259
   /* Or maybe we want to generate the error's suppression? */
271
   if (VG_(is_action_requested)( "Print suppression",
260
   if (VG_(is_action_requested)( "Print suppression",
272
                                 & VG_(clo_gen_suppressions) )) {
261
                                 & VG_(clo_gen_suppressions) )) {
273
      VG_(gen_suppression)(err);
262
      gen_suppression(err);
274
   }
263
   }
275
}
264
}
276
265
Lines 423-429 Link Here
423
      pp_Error(p, False);
412
      pp_Error(p, False);
424
      is_first_shown_context = False;
413
      is_first_shown_context = False;
425
      vg_n_errs_shown++;
414
      vg_n_errs_shown++;
426
      do_actions_on_error(p, /*allow_GDB_attach*/True);
415
      do_actions_on_error(p, /*allow_db_attach*/True);
427
   } else {
416
   } else {
428
      vg_n_errs_suppressed++;
417
      vg_n_errs_suppressed++;
429
      p->supp->count++;
418
      p->supp->count++;
Lines 431-437 Link Here
431
}
420
}
432
421
433
/* Second top-level entry point to the error management subsystem, for
422
/* Second top-level entry point to the error management subsystem, for
434
   errors that the skin want to report immediately, eg. because they're
423
   errors that the tool wants to report immediately, eg. because they're
435
   guaranteed to only happen once.  This avoids all the recording and
424
   guaranteed to only happen once.  This avoids all the recording and
436
   comparing stuff.  But they can be suppressed;  returns True if it is
425
   comparing stuff.  But they can be suppressed;  returns True if it is
437
   suppressed.  Bool `print_error' dictates whether to print the error. 
426
   suppressed.  Bool `print_error' dictates whether to print the error. 
Lines 439-445 Link Here
439
*/
428
*/
440
Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s,
429
Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s,
441
                         void* extra, ExeContext* where, Bool print_error,
430
                         void* extra, ExeContext* where, Bool print_error,
442
                         Bool allow_GDB_attach, Bool count_error )
431
                         Bool allow_db_attach, Bool count_error )
443
{
432
{
444
   Error  err;
433
   Error  err;
445
434
Lines 464-470 Link Here
464
         pp_Error(&err, False);
453
         pp_Error(&err, False);
465
         is_first_shown_context = False;
454
         is_first_shown_context = False;
466
      }
455
      }
467
      do_actions_on_error(&err, allow_GDB_attach);
456
      do_actions_on_error(&err, allow_db_attach);
468
457
469
      return False;
458
      return False;
470
459
Lines 638-646 Link Here
638
}
627
}
639
628
640
629
641
/* Look for "skin" in a string like "skin1,skin2,skin3" */
630
/* Look for "tool" in a string like "tool1,tool2,tool3" */
642
static __inline__
631
static __inline__
643
Bool skin_name_present(Char *name, Char *names)
632
Bool tool_name_present(Char *name, Char *names)
644
{
633
{
645
   Bool  found;
634
   Bool  found;
646
   Char *s = NULL;   /* Shut gcc up */
635
   Char *s = NULL;   /* Shut gcc up */
Lines 664-670 Link Here
664
   Int   fd, i;
653
   Int   fd, i;
665
   Bool  eof;
654
   Bool  eof;
666
   Char  buf[N_BUF+1];
655
   Char  buf[N_BUF+1];
667
   Char* skin_names;
656
   Char* tool_names;
668
   Char* supp_name;
657
   Char* supp_name;
669
658
670
   fd = VG_(open)( filename, VKI_O_RDONLY, 0 );
659
   fd = VG_(open)( filename, VKI_O_RDONLY, 0 );
Lines 675-681 Link Here
675
   }
664
   }
676
665
677
   while (True) {
666
   while (True) {
678
      /* Assign and initialise the two suppression halves (core and skin) */
667
      /* Assign and initialise the two suppression halves (core and tool) */
679
      Supp* supp;
668
      Supp* supp;
680
      supp        = VG_(arena_malloc)(VG_AR_CORE, sizeof(Supp));
669
      supp        = VG_(arena_malloc)(VG_AR_CORE, sizeof(Supp));
681
      supp->count = 0;
670
      supp->count = 0;
Lines 704-714 Link Here
704
      }
693
      }
705
      buf[i]    = '\0';    /* Replace ':', splitting into two strings */
694
      buf[i]    = '\0';    /* Replace ':', splitting into two strings */
706
695
707
      skin_names = & buf[0];
696
      tool_names = & buf[0];
708
      supp_name  = & buf[i+1];
697
      supp_name  = & buf[i+1];
709
698
710
      /* Is it a core suppression? */
699
      /* Is it a core suppression? */
711
      if (VG_(needs).core_errors && skin_name_present("core", skin_names))
700
      if (VG_(needs).core_errors && tool_name_present("core", tool_names))
712
      {
701
      {
713
         if (VG_STREQ(supp_name, "PThread"))
702
         if (VG_STREQ(supp_name, "PThread"))
714
            supp->skind = PThreadSupp;
703
            supp->skind = PThreadSupp;
Lines 716-724 Link Here
716
            goto syntax_error;
705
            goto syntax_error;
717
      }
706
      }
718
707
719
      /* Is it a skin suppression? */
708
      /* Is it a tool suppression? */
720
      else if (VG_(needs).skin_errors && 
709
      else if (VG_(needs).skin_errors && 
721
               skin_name_present(VG_(details).name, skin_names))
710
               tool_name_present(VG_(details).name, tool_names))
722
      {
711
      {
723
         if (SK_(recognised_suppression)(supp_name, supp)) 
712
         if (SK_(recognised_suppression)(supp_name, supp)) 
724
         {
713
         {
(-)valgrind-2.1.0/coregrind/vg_execontext.c (-1 / +16 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 319-324 Link Here
319
      *esp                = tst->m_esp; 
319
      *esp                = tst->m_esp; 
320
      *stack_highest_word = tst->stack_highest_word;
320
      *stack_highest_word = tst->stack_highest_word;
321
   }
321
   }
322
323
   /* Nasty little hack to deal with sysinfo syscalls - if libc is
324
      using the sysinfo page for syscalls (the TLS version does), then
325
      eip will always appear to be in that page when doing a syscall,
326
      not the actual libc function doing the syscall.  This check sees
327
      if EIP is within the syscall code, and pops the return address
328
      off the stack so that eip is placed within the library function
329
      calling the syscall.  This makes stack backtraces much more
330
      useful.  */
331
   if (*eip >= VG_(client_trampoline_code)+VG_(tramp_syscall_offset) &&
332
       *eip < VG_(client_trampoline_code)+VG_(trampoline_code_length) &&
333
       VG_(is_addressable)(*esp, sizeof(Addr))) {
334
      *eip = *(Addr *)*esp;
335
      *esp += sizeof(Addr);
336
   }
322
}
337
}
323
338
324
ExeContext* VG_(get_ExeContext) ( ThreadId tid )
339
ExeContext* VG_(get_ExeContext) ( ThreadId tid )
(-)valgrind-2.1.0/coregrind/vg_from_ucode.c (-49 / +284 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 80-85 Link Here
80
	UPD_Both,		/* both are current */
80
	UPD_Both,		/* both are current */
81
} eflags_state;
81
} eflags_state;
82
82
83
/* ia32 static prediction is very simple.  Other implementations are
84
   more complex, so we get the condition anyway. */
85
static JumpPred static_pred(Condcode cond, Int forward)
86
{
87
   if (cond == CondAlways)
88
      return JP_TAKEN;
89
   
90
   return forward ? JP_NOT_TAKEN : JP_TAKEN;
91
}
92
93
static const Char *predstr(JumpPred p)
94
{
95
   if (!VG_(clo_branchpred))
96
      return "";
97
98
   switch(p) {
99
   default:
100
   case JP_NONE:	return "";
101
   case JP_TAKEN:	return ",pt";
102
   case JP_NOT_TAKEN:	return ",pn";
103
   }
104
}
105
83
/* single site for resetting state */
106
/* single site for resetting state */
84
static void reset_state(void)
107
static void reset_state(void)
85
{
108
{
Lines 215-220 Link Here
215
   VG_(emitB) ( (l >> 24) & 0x000000FF );
238
   VG_(emitB) ( (l >> 24) & 0x000000FF );
216
}
239
}
217
240
241
/* This bit is ORd onto the size to indicate that it's a client
242
   pointer which needs bounds checking. */
243
#define DO_BOUNDSCHECK	(1<<8)
244
245
/* If the user asks for it, generate bounds checks on application
246
   pointer dereferences, in the form of a segment override. */
247
static __inline__ void boundscheck()
248
{
249
   if (VG_(clo_pointercheck))
250
      VG_(emitB)(0x64);		/* %fs prefix - see vg_dispatch.S */
251
}
252
253
218
static void emit_get_eflags ( void )
254
static void emit_get_eflags ( void )
219
{
255
{
220
   Int off = 4 * VGOFF_(m_eflags);
256
   Int off = 4 * VGOFF_(m_eflags);
Lines 771-776 Link Here
771
void VG_(emit_movv_reg_offregmem) ( Int sz, Int reg, Int off, Int areg )
807
void VG_(emit_movv_reg_offregmem) ( Int sz, Int reg, Int off, Int areg )
772
{
808
{
773
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
809
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
810
811
   if (sz & DO_BOUNDSCHECK) {
812
      boundscheck();
813
      sz &= ~DO_BOUNDSCHECK;
814
   }
815
774
   if (sz == 2) VG_(emitB) ( 0x66 );
816
   if (sz == 2) VG_(emitB) ( 0x66 );
775
   VG_(emitB) ( 0x89 ); /* MOV Gv, Ev */
817
   VG_(emitB) ( 0x89 ); /* MOV Gv, Ev */
776
   VG_(emit_amode_offregmem_reg) ( off, areg, reg );
818
   VG_(emit_amode_offregmem_reg) ( off, areg, reg );
Lines 782-787 Link Here
782
static void emit_movv_regmem_reg ( Int sz, Int reg1, Int reg2 )
824
static void emit_movv_regmem_reg ( Int sz, Int reg1, Int reg2 )
783
{
825
{
784
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
826
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
827
828
   if (sz & DO_BOUNDSCHECK) {
829
      boundscheck();
830
      sz &= ~DO_BOUNDSCHECK;
831
   }
832
785
   if (sz == 2) VG_(emitB) ( 0x66 );
833
   if (sz == 2) VG_(emitB) ( 0x66 );
786
   VG_(emitB) ( 0x8B ); /* MOV Ev, Gv */
834
   VG_(emitB) ( 0x8B ); /* MOV Ev, Gv */
787
   emit_amode_regmem_reg ( reg1, reg2 );
835
   emit_amode_regmem_reg ( reg1, reg2 );
Lines 793-798 Link Here
793
static void emit_movv_reg_regmem ( Int sz, Int reg1, Int reg2 )
841
static void emit_movv_reg_regmem ( Int sz, Int reg1, Int reg2 )
794
{
842
{
795
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
843
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
844
845
   if (sz & DO_BOUNDSCHECK) {
846
      boundscheck();
847
      sz &= ~DO_BOUNDSCHECK;
848
   }
849
796
   if (sz == 2) VG_(emitB) ( 0x66 );
850
   if (sz == 2) VG_(emitB) ( 0x66 );
797
   VG_(emitB) ( 0x89 ); /* MOV Gv, Ev */
851
   VG_(emitB) ( 0x89 ); /* MOV Gv, Ev */
798
   emit_amode_regmem_reg ( reg2, reg1 );
852
   emit_amode_regmem_reg ( reg2, reg1 );
Lines 1205-1213 Link Here
1205
                   nameIReg(1,reg1), nameIReg(1,reg2));
1259
                   nameIReg(1,reg1), nameIReg(1,reg2));
1206
}
1260
}
1207
1261
1208
static void emit_movb_reg_regmem ( Int reg1, Int reg2 )
1262
static void emit_movb_reg_regmem ( Bool bounds, Int reg1, Int reg2 )
1209
{
1263
{
1210
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
1264
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
1265
1266
   if (bounds)
1267
      boundscheck();
1268
1211
   VG_(emitB) ( 0x88 ); /* MOV G1, E1 */
1269
   VG_(emitB) ( 0x88 ); /* MOV G1, E1 */
1212
   emit_amode_regmem_reg ( reg2, reg1 );
1270
   emit_amode_regmem_reg ( reg2, reg1 );
1213
   if (dis)
1271
   if (dis)
Lines 1290-1298 Link Here
1290
/*--- zero-extended load emitters                  ---*/
1348
/*--- zero-extended load emitters                  ---*/
1291
/*----------------------------------------------------*/
1349
/*----------------------------------------------------*/
1292
1350
1293
void VG_(emit_movzbl_offregmem_reg) ( Int off, Int regmem, Int reg )
1351
void VG_(emit_movzbl_offregmem_reg) ( Bool bounds, Int off, Int regmem, Int reg )
1294
{
1352
{
1295
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
1353
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
1354
   if (bounds)
1355
      boundscheck();
1296
   VG_(emitB) ( 0x0F ); VG_(emitB) ( 0xB6 ); /* MOVZBL */
1356
   VG_(emitB) ( 0x0F ); VG_(emitB) ( 0xB6 ); /* MOVZBL */
1297
   VG_(emit_amode_offregmem_reg) ( off, regmem, reg );
1357
   VG_(emit_amode_offregmem_reg) ( off, regmem, reg );
1298
   if (dis)
1358
   if (dis)
Lines 1300-1308 Link Here
1300
                   off, nameIReg(4,regmem), nameIReg(4,reg));
1360
                   off, nameIReg(4,regmem), nameIReg(4,reg));
1301
}
1361
}
1302
1362
1303
static void emit_movzbl_regmem_reg ( Int reg1, Int reg2 )
1363
static void emit_movzbl_regmem_reg ( Bool bounds, Int reg1, Int reg2 )
1304
{
1364
{
1305
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
1365
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
1366
1367
   if (bounds)
1368
      boundscheck();
1369
1306
   VG_(emitB) ( 0x0F ); VG_(emitB) ( 0xB6 ); /* MOVZBL */
1370
   VG_(emitB) ( 0x0F ); VG_(emitB) ( 0xB6 ); /* MOVZBL */
1307
   emit_amode_regmem_reg ( reg1, reg2 );
1371
   emit_amode_regmem_reg ( reg1, reg2 );
1308
   if (dis)
1372
   if (dis)
Lines 1310-1318 Link Here
1310
                                               nameIReg(4,reg2));
1374
                                               nameIReg(4,reg2));
1311
}
1375
}
1312
1376
1313
void VG_(emit_movzwl_offregmem_reg) ( Int off, Int areg, Int reg )
1377
void VG_(emit_movzwl_offregmem_reg) ( Bool bounds, Int off, Int areg, Int reg )
1314
{
1378
{
1315
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
1379
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
1380
1381
   if (bounds)
1382
      boundscheck();
1383
1316
   VG_(emitB) ( 0x0F ); VG_(emitB) ( 0xB7 ); /* MOVZWL */
1384
   VG_(emitB) ( 0x0F ); VG_(emitB) ( 0xB7 ); /* MOVZWL */
1317
   VG_(emit_amode_offregmem_reg) ( off, areg, reg );
1385
   VG_(emit_amode_offregmem_reg) ( off, areg, reg );
1318
   if (dis)
1386
   if (dis)
Lines 1320-1328 Link Here
1320
                   off, nameIReg(4,areg), nameIReg(4,reg));
1388
                   off, nameIReg(4,areg), nameIReg(4,reg));
1321
}
1389
}
1322
1390
1323
void VG_( emit_movzwl_regmem_reg ) ( Int reg1, Int reg2 )
1391
void VG_( emit_movzwl_regmem_reg ) ( Bool bounds, Int reg1, Int reg2 )
1324
{
1392
{
1325
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
1393
   VG_(new_emit)(False, FlagsEmpty, FlagsEmpty);
1394
1395
   if (bounds)
1396
      boundscheck();
1397
1326
   VG_(emitB) ( 0x0F ); VG_(emitB) ( 0xB7 ); /* MOVZWL */
1398
   VG_(emitB) ( 0x0F ); VG_(emitB) ( 0xB7 ); /* MOVZWL */
1327
   emit_amode_regmem_reg ( reg1, reg2 );
1399
   emit_amode_regmem_reg ( reg1, reg2 );
1328
   if (dis)
1400
   if (dis)
Lines 1394-1399 Link Here
1394
                              Int reg )
1466
                              Int reg )
1395
{
1467
{
1396
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1468
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1469
1470
   boundscheck();		/* assume all FPU ops are the client's */
1471
1397
   VG_(emitB) ( first_byte );
1472
   VG_(emitB) ( first_byte );
1398
   emit_amode_regmem_reg ( reg, second_byte_masked >> 3 );
1473
   emit_amode_regmem_reg ( reg, second_byte_masked >> 3 );
1399
   if (dis)
1474
   if (dis)
Lines 1409-1414 Link Here
1409
                               Int ireg )
1484
                               Int ireg )
1410
{
1485
{
1411
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1486
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1487
1488
   boundscheck();
1489
1412
   VG_(emitB) ( 0x0F );
1490
   VG_(emitB) ( 0x0F );
1413
   VG_(emitB) ( first_byte );
1491
   VG_(emitB) ( first_byte );
1414
   second_byte &= 0x38; /* mask out mod and rm fields */
1492
   second_byte &= 0x38; /* mask out mod and rm fields */
Lines 1427-1432 Link Here
1427
                         Int ireg )
1505
                         Int ireg )
1428
{
1506
{
1429
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1507
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1508
1509
   boundscheck();
1510
1430
   VG_(emitB) ( first_byte );
1511
   VG_(emitB) ( first_byte );
1431
   VG_(emitB) ( second_byte );
1512
   VG_(emitB) ( second_byte );
1432
   third_byte &= 0x38; /* mask out mod and rm fields */
1513
   third_byte &= 0x38; /* mask out mod and rm fields */
Lines 1437-1442 Link Here
1437
                  nameIReg(4,ireg) );
1518
                  nameIReg(4,ireg) );
1438
}
1519
}
1439
1520
1521
static void emit_SSE2e1 ( FlagSet uses_sflags, 
1522
                          FlagSet sets_sflags,
1523
                          UChar first_byte, 
1524
                          UChar second_byte, 
1525
                         UChar third_byte,
1526
                          UChar fourth_byte,
1527
                          Int ireg )
1528
{
1529
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1530
   VG_(emitB) ( first_byte );
1531
   VG_(emitB) ( second_byte );
1532
   third_byte &= 0x38; /* mask out mod and rm fields */
1533
   third_byte |= 0xC0; /* set top two bits: mod = 11b */
1534
   third_byte |= (ireg & 7); /* patch in our ireg */
1535
   VG_(emitB) ( third_byte );
1536
   VG_(emitB) ( fourth_byte );
1537
   if (dis)
1538
      VG_(printf)(
1539
         "\n\t\tsse2e1--0x%x:0x%x:0x%x:0x%x-(%s)\n", 
1540
         (UInt)first_byte, (UInt)second_byte, 
1541
         (UInt)third_byte, (UInt)fourth_byte,
1542
         nameIReg(4,ireg) 
1543
      );
1544
}
1545
1546
static void emit_SSE2g1 ( FlagSet uses_sflags, 
1547
                          FlagSet sets_sflags,
1548
                          UChar first_byte, 
1549
                          UChar second_byte, 
1550
                          UChar third_byte,
1551
                          UChar fourth_byte,
1552
                          Int ireg )
1553
{
1554
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1555
   VG_(emitB) ( first_byte );
1556
   VG_(emitB) ( second_byte );
1557
   third_byte &= 0xC7; /* mask out reg field */
1558
   third_byte |= 0xC0; /* set top two bits: mod = 11b */
1559
   third_byte |= ((ireg & 7) << 3); /* patch in our ireg */
1560
   VG_(emitB) ( third_byte );
1561
   VG_(emitB) ( fourth_byte );
1562
   if (dis)
1563
      VG_(printf)(
1564
         "\n\t\tsse2g1_reg_wr--0x%x:0x%x:0x%x:0x%x-(%s)\n", 
1565
         (UInt)first_byte, (UInt)second_byte, 
1566
         (UInt)third_byte, (UInt)fourth_byte,
1567
         nameIReg(4,ireg) 
1568
      );
1569
}
1570
1571
static void emit_SSE2g ( FlagSet uses_sflags, 
1572
                         FlagSet sets_sflags,
1573
                         UChar first_byte, 
1574
                         UChar second_byte, 
1575
                        UChar third_byte,
1576
                         Int ireg )
1577
{
1578
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1579
   VG_(emitB) ( first_byte );
1580
   VG_(emitB) ( second_byte );
1581
   third_byte &= 0xC7; /* mask out reg field */
1582
   third_byte |= 0xC0; /* set top two bits: mod = 11b */
1583
   third_byte |= ((ireg & 7) << 3); /* patch in our ireg */
1584
   VG_(emitB) ( third_byte );
1585
   if (dis)
1586
      VG_(printf)(
1587
         "\n\t\tsse2g--0x%x:0x%x:0x%x-(%s)\n", 
1588
         (UInt)first_byte, (UInt)second_byte, (UInt)third_byte,
1589
         nameIReg(4,ireg) 
1590
      );
1591
}
1592
1440
static void emit_SSE2a1 ( FlagSet uses_sflags, 
1593
static void emit_SSE2a1 ( FlagSet uses_sflags, 
1441
                          FlagSet sets_sflags,
1594
                          FlagSet sets_sflags,
1442
                          UChar first_byte, 
1595
                          UChar first_byte, 
Lines 1446-1451 Link Here
1446
                          Int ireg )
1599
                          Int ireg )
1447
{
1600
{
1448
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1601
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1602
1603
   boundscheck();
1604
1449
   VG_(emitB) ( first_byte );
1605
   VG_(emitB) ( first_byte );
1450
   VG_(emitB) ( second_byte );
1606
   VG_(emitB) ( second_byte );
1451
   third_byte &= 0x38; /* mask out mod and rm fields */
1607
   third_byte &= 0x38; /* mask out mod and rm fields */
Lines 1467-1472 Link Here
1467
                         Int ireg )
1623
                         Int ireg )
1468
{
1624
{
1469
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1625
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1626
1627
   boundscheck();
1628
1470
   VG_(emitB) ( first_byte );
1629
   VG_(emitB) ( first_byte );
1471
   VG_(emitB) ( second_byte );
1630
   VG_(emitB) ( second_byte );
1472
   VG_(emitB) ( third_byte );
1631
   VG_(emitB) ( third_byte );
Lines 1593-1598 Link Here
1593
                          Int ireg )
1752
                          Int ireg )
1594
{
1753
{
1595
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1754
   VG_(new_emit)(True, uses_sflags, sets_sflags);
1755
1756
   boundscheck();
1757
1596
   VG_(emitB) ( first_byte );
1758
   VG_(emitB) ( first_byte );
1597
   VG_(emitB) ( second_byte );
1759
   VG_(emitB) ( second_byte );
1598
   VG_(emitB) ( third_byte );
1760
   VG_(emitB) ( third_byte );
Lines 1870-1877 Link Here
1870
2032
1871
static inline Int mk_tgt(Int state, Int addr)
2033
static inline Int mk_tgt(Int state, Int addr)
1872
{
2034
{
1873
   vg_assert(state == TGT_UNDEF 
2035
   vg_assert(state == TGT_UNDEF ||
1874
             || state == TGT_FORWARD || state == TGT_BACKWARD);
2036
	     state == TGT_FORWARD ||
2037
	     state == TGT_BACKWARD);
1875
   vg_assert((addr & 0xffff0000) == 0);
2038
   vg_assert((addr & 0xffff0000) == 0);
1876
2039
1877
   return state | addr;
2040
   return state | addr;
Lines 1930-1955 Link Here
1930
/* Emit a jump short with an 8-bit signed offset.  Note that the
2093
/* Emit a jump short with an 8-bit signed offset.  Note that the
1931
   offset is that which should be added to %eip once %eip has been
2094
   offset is that which should be added to %eip once %eip has been
1932
   advanced over this insn.  */
2095
   advanced over this insn.  */
1933
void VG_(emit_jcondshort_delta) ( Bool simd_flags, Condcode cond, Int delta )
2096
void VG_(emit_jcondshort_delta) ( Bool simd_flags, Condcode cond, Int delta, JumpPred pred )
1934
{
2097
{
1935
   vg_assert(delta >= -128 && delta <= 127);
2098
   vg_assert(delta >= -128 && delta <= 127);
1936
   VG_(new_emit)(simd_flags, FlagsOSZCP, FlagsEmpty);
2099
   VG_(new_emit)(simd_flags, FlagsOSZCP, FlagsEmpty);
2100
2101
   if (VG_(clo_branchpred) && 
2102
       pred != JP_NONE && 
2103
       pred != static_pred(cond, delta > 0))
2104
      VG_(emitB)(pred == JP_TAKEN ? 0x3e : 0x2e);
2105
1937
   VG_(emitB) ( 0x70 + (UInt)cond );
2106
   VG_(emitB) ( 0x70 + (UInt)cond );
1938
   VG_(emitB) ( (UChar)delta );
2107
   VG_(emitB) ( (UChar)delta );
1939
   if (dis)
2108
   if (dis)
1940
      VG_(printf)( "\n\t\tj%s-8\t%%eip+%d\n", 
2109
      VG_(printf)( "\n\t\tj%s-8%s\t%%eip+%d\n", 
1941
                   VG_(name_UCondcode)(cond), delta );
2110
                   VG_(name_UCondcode)(cond), predstr(pred), delta );
1942
}
2111
}
1943
2112
1944
/* Same as above, but defers emitting the delta  */
2113
/* Same as above, but defers emitting the delta  */
1945
void VG_(emit_jcondshort_target) ( Bool simd, Condcode cond, Int *tgt )
2114
void VG_(emit_jcondshort_target) ( Bool simd, Condcode cond, Int *tgt, JumpPred pred )
1946
{
2115
{
1947
   VG_(new_emit)(simd, FlagsOSZCP, FlagsEmpty);
2116
   VG_(new_emit)(simd, FlagsOSZCP, FlagsEmpty);
2117
2118
   if (VG_(clo_branchpred) &&
2119
       pred != JP_NONE && 
2120
       pred != static_pred(cond, tgt_state(*tgt) != TGT_BACKWARD))
2121
      VG_(emitB)(pred == JP_TAKEN ? 0x3e : 0x2e);
2122
1948
   VG_(emitB) ( 0x70 + (UInt)cond );
2123
   VG_(emitB) ( 0x70 + (UInt)cond );
1949
   VG_(emit_target_delta) (tgt);
2124
   VG_(emit_target_delta) (tgt);
1950
   if (dis)
2125
   if (dis)
1951
      VG_(printf)( "\n\t\tj%s-8\t%%eip+(%d)\n", 
2126
      VG_(printf)( "\n\t\tj%s-8%s\t%%eip+(%d)\n", 
1952
                   VG_(name_UCondcode)(cond), tgt_addr(*tgt) );
2127
                   VG_(name_UCondcode)(cond), predstr(pred), tgt_addr(*tgt) );
1953
}
2128
}
1954
2129
1955
2130
Lines 2067-2079 Link Here
2067
	 dispatch loop.  We still need to keep it the same size as the
2242
	 dispatch loop.  We still need to keep it the same size as the
2068
	 call sequence. */
2243
	 call sequence. */
2069
      VG_(emitB) ( 0xC3 );	/* ret */
2244
      VG_(emitB) ( 0xC3 );	/* ret */
2070
      VG_(emitB) ( 0x90 );	/* nop */
2245
      VG_(emitB) ( 0x8d );	/* 4 byte nop (lea    0x0(%esi,1),%esi) */
2071
      VG_(emitB) ( 0x90 );	/* nop */
2246
      VG_(emitB) ( 0x74 );
2072
      VG_(emitB) ( 0x90 );	/* nop */
2247
      VG_(emitB) ( 0x26 );
2073
      VG_(emitB) ( 0x90 );	/* nop */
2248
      VG_(emitB) ( 0x00 );
2074
2249
2075
      if (dis)
2250
      if (dis)
2076
	 VG_(printf)("\n\t\tret; nop; nop; nop; nop\n");
2251
	 VG_(printf)("\n\t\tret; nop4\n");
2077
2252
2078
      if (0 && VG_(clo_verbosity))
2253
      if (0 && VG_(clo_verbosity))
2079
	 VG_(message)(Vg_DebugMsg, "too many chained jumps in basic-block");
2254
	 VG_(message)(Vg_DebugMsg, "too many chained jumps in basic-block");
Lines 2087-2093 Link Here
2087
      VG_(emitB) ( 0x90 );		/* NOP */
2262
      VG_(emitB) ( 0x90 );		/* NOP */
2088
2263
2089
      if (dis)
2264
      if (dis)
2090
	 VG_(printf)("\n\t\tud2; ud2; nop\n");
2265
	 VG_(printf)("\n\t\tud2; ud2; nop /* call VG_(patchme) */\n");
2091
   }
2266
   }
2092
}   
2267
}   
2093
2268
Lines 2449-2454 Link Here
2449
      case JmpClientReq: 
2624
      case JmpClientReq: 
2450
         VG_(emit_movv_lit_reg) ( 4, VG_TRC_EBP_JMP_CLIENTREQ, R_EBP );
2625
         VG_(emit_movv_lit_reg) ( 4, VG_TRC_EBP_JMP_CLIENTREQ, R_EBP );
2451
         break;
2626
         break;
2627
      case JmpYield: 
2628
         VG_(emit_movv_lit_reg) ( 4, VG_TRC_EBP_JMP_YIELD, R_EBP );
2629
         break;
2452
      default: 
2630
      default: 
2453
         VG_(core_panic)("load_ebp_from_JmpKind");
2631
         VG_(core_panic)("load_ebp_from_JmpKind");
2454
   }
2632
   }
Lines 2547-2558 Link Here
2547
2725
2548
	    if (cond == CondLE) {
2726
	    if (cond == CondLE) {
2549
	       /* test Z */
2727
	       /* test Z */
2550
	       VG_(emit_jcondshort_target)(False, CondS, &tgt_jump);
2728
	       VG_(emit_jcondshort_target)(False, CondS, &tgt_jump, JP_NONE);
2551
	       /* test OF != SF */
2729
	       /* test OF != SF */
2552
	       cond = CondP;
2730
	       cond = CondP;
2553
	    } else {
2731
	    } else {
2554
	       /* test Z */
2732
	       /* test Z */
2555
	       VG_(emit_jcondshort_target)(False, CondS, &tgt2);
2733
	       VG_(emit_jcondshort_target)(False, CondS, &tgt2, JP_NONE);
2556
	       /* test OF == SF */
2734
	       /* test OF == SF */
2557
	       cond = CondNP;
2735
	       cond = CondNP;
2558
	    }
2736
	    }
Lines 2634-2640 Link Here
2634
      }
2812
      }
2635
   }
2813
   }
2636
2814
2637
   VG_(emit_jcondshort_target) ( simd, cond, &tgt );
2815
   VG_(emit_jcondshort_target) ( simd, cond, &tgt, JP_NONE );
2638
2816
2639
   VG_(target_forward)(&tgt_jump);
2817
   VG_(target_forward)(&tgt_jump);
2640
   synth_jmp_lit ( addr, JmpBoring );
2818
   synth_jmp_lit ( addr, JmpBoring );
Lines 2653-2659 Link Here
2653
 
2831
 
2654
   VG_(emit_cmpl_zero_reg) ( False, reg );
2832
   VG_(emit_cmpl_zero_reg) ( False, reg );
2655
2833
2656
   VG_(emit_jcondshort_target) ( False, CondNZ, &tgt );
2834
   VG_(emit_jcondshort_target) ( False, CondNZ, &tgt, JP_NONE );
2657
   synth_jmp_lit ( addr, JmpBoring );
2835
   synth_jmp_lit ( addr, JmpBoring );
2658
 
2836
 
2659
   VG_(target_forward)(&tgt);
2837
   VG_(target_forward)(&tgt);
Lines 2670-2679 Link Here
2670
2848
2671
static void synth_mov_regmem_reg ( Int size, Int reg1, Int reg2 ) 
2849
static void synth_mov_regmem_reg ( Int size, Int reg1, Int reg2 ) 
2672
{
2850
{
2673
   switch (size) {
2851
   switch (size & ~DO_BOUNDSCHECK) {
2674
      case 4: emit_movv_regmem_reg ( 4, reg1, reg2 ); break;
2852
      case 4: emit_movv_regmem_reg ( size, reg1, reg2 ); break;
2675
      case 2: VG_(emit_movzwl_regmem_reg) ( reg1, reg2 ); break;
2853
      case 2: VG_(emit_movzwl_regmem_reg) ( size & DO_BOUNDSCHECK, reg1, reg2 ); break;
2676
      case 1: emit_movzbl_regmem_reg ( reg1, reg2 ); break;
2854
      case 1: emit_movzbl_regmem_reg ( size & DO_BOUNDSCHECK, reg1, reg2 ); break;
2677
      default: VG_(core_panic)("synth_mov_regmem_reg");
2855
      default: VG_(core_panic)("synth_mov_regmem_reg");
2678
   }  
2856
   }  
2679
}
2857
}
Lines 2681-2690 Link Here
2681
2859
2682
static void synth_mov_offregmem_reg ( Int size, Int off, Int areg, Int reg ) 
2860
static void synth_mov_offregmem_reg ( Int size, Int off, Int areg, Int reg ) 
2683
{
2861
{
2684
   switch (size) {
2862
   switch (size & ~DO_BOUNDSCHECK) {
2685
      case 4: VG_(emit_movv_offregmem_reg) ( 4, off, areg, reg ); break;
2863
      case 4: VG_(emit_movv_offregmem_reg) ( 4, off, areg, reg ); break;
2686
      case 2: VG_(emit_movzwl_offregmem_reg) ( off, areg, reg ); break;
2864
      case 2: VG_(emit_movzwl_offregmem_reg) ( size & DO_BOUNDSCHECK, off, areg, reg ); break;
2687
      case 1: VG_(emit_movzbl_offregmem_reg) ( off, areg, reg ); break;
2865
      case 1: VG_(emit_movzbl_offregmem_reg) ( size & DO_BOUNDSCHECK, off, areg, reg ); break;
2688
      default: VG_(core_panic)("synth_mov_offregmem_reg");
2866
      default: VG_(core_panic)("synth_mov_offregmem_reg");
2689
   }  
2867
   }  
2690
}
2868
}
Lines 2713-2729 Link Here
2713
static void synth_mov_reg_memreg ( Int size, Int reg1, Int reg2 )
2891
static void synth_mov_reg_memreg ( Int size, Int reg1, Int reg2 )
2714
{
2892
{
2715
   Int s1;
2893
   Int s1;
2716
   switch (size) {
2894
   switch (size & ~DO_BOUNDSCHECK) {
2717
      case 4: emit_movv_reg_regmem ( 4, reg1, reg2 ); break;
2895
      case 4: 
2718
      case 2: emit_movv_reg_regmem ( 2, reg1, reg2 ); break;
2896
      case 2: emit_movv_reg_regmem ( size, reg1, reg2 ); break;
2719
      case 1: if (reg1 < 4) {
2897
      case 1: if (reg1 < 4) {
2720
                 emit_movb_reg_regmem ( reg1, reg2 ); 
2898
                 emit_movb_reg_regmem ( size & DO_BOUNDSCHECK, reg1, reg2 ); 
2721
              }
2899
              }
2722
              else {
2900
              else {
2723
                 /* Choose a swap reg which is < 4 and not reg1 or reg2. */
2901
                 /* Choose a swap reg which is < 4 and not reg1 or reg2. */
2724
                 for (s1 = 0; s1 == reg1 || s1 == reg2; s1++) ;
2902
                 for (s1 = 0; s1 == reg1 || s1 == reg2; s1++) ;
2725
                 emit_swapl_reg_reg ( s1, reg1 );
2903
                 emit_swapl_reg_reg ( s1, reg1 );
2726
                 emit_movb_reg_regmem ( s1, reg2 );
2904
                 emit_movb_reg_regmem ( size & DO_BOUNDSCHECK, s1, reg2 );
2727
                 emit_swapl_reg_reg ( s1, reg1 );
2905
                 emit_swapl_reg_reg ( s1, reg1 );
2728
              }
2906
              }
2729
              break;
2907
              break;
Lines 3167-3173 Link Here
3167
3345
3168
   VG_(init_target)(&tgt);
3346
   VG_(init_target)(&tgt);
3169
3347
3170
   VG_(emit_jcondshort_target) ( True, invertCondition(cond), &tgt);
3348
   VG_(emit_jcondshort_target) ( True, invertCondition(cond), &tgt, JP_NONE);
3171
   emit_movl_reg_reg ( src, dst );
3349
   emit_movl_reg_reg ( src, dst );
3172
3350
3173
   VG_(target_forward)(&tgt);
3351
   VG_(target_forward)(&tgt);
Lines 3473-3486 Link Here
3473
      case STORE: {
3651
      case STORE: {
3474
         vg_assert(u->tag1 == RealReg);
3652
         vg_assert(u->tag1 == RealReg);
3475
         vg_assert(u->tag2 == RealReg);
3653
         vg_assert(u->tag2 == RealReg);
3476
         synth_mov_reg_memreg ( u->size, u->val1, u->val2 );
3654
         synth_mov_reg_memreg ( u->size | DO_BOUNDSCHECK, u->val1, u->val2 );
3477
         break;
3655
         break;
3478
      }
3656
      }
3479
3657
3480
      case LOAD: {
3658
      case LOAD: {
3481
         vg_assert(u->tag1 == RealReg);
3659
         vg_assert(u->tag1 == RealReg);
3482
         vg_assert(u->tag2 == RealReg);
3660
         vg_assert(u->tag2 == RealReg);
3483
         synth_mov_regmem_reg ( u->size, u->val1, u->val2 );
3661
         synth_mov_regmem_reg ( u->size | DO_BOUNDSCHECK, u->val1, u->val2 );
3484
         break;
3662
         break;
3485
      }
3663
      }
3486
3664
Lines 3969-3975 Link Here
3969
4147
3970
      case SSE2a_MemWr:
4148
      case SSE2a_MemWr:
3971
      case SSE2a_MemRd:
4149
      case SSE2a_MemRd:
3972
         vg_assert(u->size == 4 || u->size == 16);
4150
         vg_assert(u->size == 4 || u->size == 8
4151
                   || u->size == 16 || u->size == 512);
3973
         vg_assert(u->tag1 == Lit16);
4152
         vg_assert(u->tag1 == Lit16);
3974
         vg_assert(u->tag2 == Lit16);
4153
         vg_assert(u->tag2 == Lit16);
3975
         vg_assert(u->tag3 == RealReg);
4154
         vg_assert(u->tag3 == RealReg);
Lines 3984-3991 Link Here
3984
                      u->val3 );
4163
                      u->val3 );
3985
         break;
4164
         break;
3986
4165
4166
      case SSE2g_RegWr:
4167
         vg_assert(u->size == 4);
4168
         vg_assert(u->tag1 == Lit16);
4169
         vg_assert(u->tag2 == Lit16);
4170
         vg_assert(u->tag3 == RealReg);
4171
         vg_assert(!anyFlagUse(u));
4172
         if (!(*sselive)) {
4173
            emit_get_sse_state();
4174
            *sselive = True;
4175
         }
4176
         emit_SSE2g ( u->flags_r, u->flags_w,
4177
                      (u->val1 >> 8) & 0xFF,
4178
                      u->val1 & 0xFF,
4179
                      u->val2 & 0xFF,
4180
                      u->val3 );
4181
         break;
4182
4183
      case SSE2g1_RegWr:
4184
         vg_assert(u->size == 4);
4185
         vg_assert(u->tag1 == Lit16);
4186
         vg_assert(u->tag2 == Lit16);
4187
         vg_assert(u->tag3 == RealReg);
4188
         vg_assert(!anyFlagUse(u));
4189
         if (!(*sselive)) {
4190
            emit_get_sse_state();
4191
            *sselive = True;
4192
         }
4193
         emit_SSE2g1 ( u->flags_r, u->flags_w,
4194
                       (u->val1 >> 8) & 0xFF,
4195
                       u->val1 & 0xFF,
4196
                       u->val2 & 0xFF,
4197
                       u->lit32 & 0xFF,
4198
                       u->val3 );
4199
         break;
4200
4201
      case SSE2e1_RegRd:
4202
         vg_assert(u->size == 2);
4203
         vg_assert(u->tag1 == Lit16);
4204
         vg_assert(u->tag2 == Lit16);
4205
         vg_assert(u->tag3 == RealReg);
4206
         vg_assert(!anyFlagUse(u));
4207
         if (!(*sselive)) {
4208
            emit_get_sse_state();
4209
            *sselive = True;
4210
         }
4211
         emit_SSE2e1 ( u->flags_r, u->flags_w,
4212
                       (u->val1 >> 8) & 0xFF,
4213
                       u->val1 & 0xFF,
4214
                       u->val2 & 0xFF,
4215
                       u->lit32 & 0xFF,
4216
                       u->val3 );
4217
         break;
4218
3987
      case SSE2a1_MemRd:
4219
      case SSE2a1_MemRd:
3988
         vg_assert(u->size == 4 || u->size == 16);
4220
         vg_assert(u->size == 4 || u->size == 8 || u->size == 16);
3989
         vg_assert(u->tag1 == Lit16);
4221
         vg_assert(u->tag1 == Lit16);
3990
         vg_assert(u->tag2 == Lit16);
4222
         vg_assert(u->tag2 == Lit16);
3991
         vg_assert(u->tag3 == RealReg);
4223
         vg_assert(u->tag3 == RealReg);
Lines 4088-4094 Link Here
4088
         break;
4320
         break;
4089
4321
4090
      case SSE3a1_MemRd:
4322
      case SSE3a1_MemRd:
4091
         vg_assert(u->size == 16);
4323
         vg_assert(u->size == 8 || u->size == 16);
4092
         vg_assert(u->tag1 == Lit16);
4324
         vg_assert(u->tag1 == Lit16);
4093
         vg_assert(u->tag2 == Lit16);
4325
         vg_assert(u->tag2 == Lit16);
4094
         vg_assert(u->tag3 == RealReg);
4326
         vg_assert(u->tag3 == RealReg);
Lines 4102-4108 Link Here
4102
                      u->val1 & 0xFF,
4334
                      u->val1 & 0xFF,
4103
                      (u->val2 >> 8) & 0xFF,
4335
                      (u->val2 >> 8) & 0xFF,
4104
                      u->val2 & 0xFF,
4336
                      u->val2 & 0xFF,
4105
                      (u->lit32 >> 8) & 0xFF,
4337
                      u->lit32 & 0xFF,
4106
                      u->val3 );
4338
                      u->val3 );
4107
         break;
4339
         break;
4108
4340
Lines 4219-4234 Link Here
4219
4451
4220
   if (dis) VG_(printf)("Generated x86 code:\n");
4452
   if (dis) VG_(printf)("Generated x86 code:\n");
4221
4453
4222
   /* Generate decl VG_(dispatch_ctr) and drop into dispatch if we hit
4454
   /* Generate subl $1, VG_(dispatch_ctr) and drop into dispatch if we hit
4223
      zero.  We have to do this regardless of whether we're t-chaining
4455
      zero.  We have to do this regardless of whether we're t-chaining
4224
      or not. */
4456
      or not. (The ia32 optimisation guide recommends sub over dec.) */
4225
   VG_(init_target)(&tgt);
4457
   VG_(init_target)(&tgt);
4226
   VG_(new_emit)(False, FlagsEmpty, FlagsOSZAP);
4458
   VG_(new_emit)(False, FlagsEmpty, FlagsOSZAP);
4227
   VG_(emitB) (0xFF);	/* decl */
4459
   VG_(emitB) (0x83);	/* subl */
4228
   emit_amode_litmem_reg((Addr)&VG_(dispatch_ctr), 1);
4460
   emit_amode_litmem_reg((Addr)&VG_(dispatch_ctr), 5);
4461
   VG_(emitB) (0x01);
4462
4229
   if (dis)
4463
   if (dis)
4230
      VG_(printf)("\n\t\tdecl (%p)\n", &VG_(dispatch_ctr));
4464
      VG_(printf)("\n\t\tsubl $1, (%p)\n", &VG_(dispatch_ctr));
4231
   VG_(emit_jcondshort_target)(False, CondNZ, &tgt);
4465
4466
   VG_(emit_jcondshort_target)(False, CondNZ, &tgt, JP_TAKEN);
4232
   VG_(emit_movv_lit_reg) ( 4, VG_TRC_INNER_COUNTERZERO, R_EBP );
4467
   VG_(emit_movv_lit_reg) ( 4, VG_TRC_INNER_COUNTERZERO, R_EBP );
4233
   emit_ret();
4468
   emit_ret();
4234
   VG_(target_forward)(&tgt);
4469
   VG_(target_forward)(&tgt);
(-)valgrind-2.1.0/coregrind/vg_hashtable.c (-1 / +1 lines)
Lines 7-13 Link Here
7
   This file is part of Valgrind, an extensible x86 protected-mode
7
   This file is part of Valgrind, an extensible x86 protected-mode
8
   emulator for monitoring program execution on x86-Unixes.
8
   emulator for monitoring program execution on x86-Unixes.
9
9
10
   Copyright (C) 2000-2003 Julian Seward 
10
   Copyright (C) 2000-2004 Julian Seward 
11
      jseward@acm.org
11
      jseward@acm.org
12
12
13
   This program is free software; you can redistribute it and/or
13
   This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/coregrind/vg_helpers.S (-50 / +147 lines)
Lines 1-4 Link Here
1
2
##--------------------------------------------------------------------##
1
##--------------------------------------------------------------------##
3
##--- Support routines for the JITter output.                      ---##
2
##--- Support routines for the JITter output.                      ---##
4
##---                                                 vg_helpers.S ---##
3
##---                                                 vg_helpers.S ---##
Lines 8-14 Link Here
8
  This file is part of Valgrind, an extensible x86 protected-mode
7
  This file is part of Valgrind, an extensible x86 protected-mode
9
  emulator for monitoring program execution on x86-Unixes.
8
  emulator for monitoring program execution on x86-Unixes.
10
9
11
  Copyright (C) 2000-2003 Julian Seward 
10
  Copyright (C) 2000-2004 Julian Seward 
12
     jseward@acm.org
11
     jseward@acm.org
13
12
14
  This program is free software; you can redistribute it and/or
13
  This program is free software; you can redistribute it and/or
Lines 38-46 Link Here
38
   to the request.  In both cases we use the user request mechanism.
37
   to the request.  In both cases we use the user request mechanism.
39
   You need to to read the definition of VALGRIND_MAGIC_SEQUENCE
38
   You need to to read the definition of VALGRIND_MAGIC_SEQUENCE
40
   in valgrind.h to make sense of this.
39
   in valgrind.h to make sense of this.
41
*/
40
42
.global VG_(signalreturn_bogusRA)
41
   This isn't used in-place.  It is copied into the client address space
43
VG_(signalreturn_bogusRA):
42
   at an arbitary address.  Therefore, this code must be completely
43
   position-independent.
44
*/
45
.global VG_(trampoline_code_start)
46
.global VG_(trampoline_code_length)
47
.global VG_(tramp_sigreturn_offset)
48
.global VG_(tramp_syscall_offset)
49
	
50
VG_(trampoline_code_start):
51
sigreturn_start:	
44
	subl	$20, %esp	# allocate arg block
52
	subl	$20, %esp	# allocate arg block
45
	movl	%esp, %edx	# %edx == &_zzq_args[0]
53
	movl	%esp, %edx	# %edx == &_zzq_args[0]
46
	movl	$VG_USERREQ__SIGNAL_RETURNS, 0(%edx)	# request
54
	movl	$VG_USERREQ__SIGNAL_RETURNS, 0(%edx)	# request
Lines 57-72 Link Here
57
	roll $13, %eax
65
	roll $13, %eax
58
	roll $19, %eax
66
	roll $19, %eax
59
	# should never get here
67
	# should never get here
60
	pushl	$signalreturn_bogusRA_panic_msg
68
	ud2
61
	call	VG_(core_panic)
62
	
63
.data
64
signalreturn_bogusRA_panic_msg:
65
.ascii	"vg_signalreturn_bogusRA: VG_USERREQ__SIGNAL_RETURNS was missed"
66
.byte	0
67
.text	
68
	
69
69
70
	# We can point our sysinfo stuff here
71
	.align 16
72
syscall_start:	
73
	int	$0x80
74
	ret
75
tramp_code_end:
76
			
77
.data
78
VG_(trampoline_code_length):
79
	.long tramp_code_end - VG_(trampoline_code_start)
80
VG_(tramp_sigreturn_offset):
81
	.long sigreturn_start - VG_(trampoline_code_start)
82
VG_(tramp_syscall_offset):
83
	.long syscall_start - VG_(trampoline_code_start)
84
.text
70
85
71
	
86
	
72
/* ------------------ REAL CPU HELPERS ------------------ */
87
/* ------------------ REAL CPU HELPERS ------------------ */
Lines 79-84 Link Here
79
	* integer multiplication
94
	* integer multiplication
80
        * setting and getting obscure eflags
95
        * setting and getting obscure eflags
81
	* double-length shifts
96
	* double-length shifts
97
        * eight byte compare and exchange
82
	
98
	
83
   All routines use a standard calling convention designed for
99
   All routines use a standard calling convention designed for
84
   calling from translations, in which the incoming args are
100
   calling from translations, in which the incoming args are
Lines 174-226 Link Here
174
	dummy, replaced by %EDX value
190
	dummy, replaced by %EDX value
175
	RA   <- %esp
191
	RA   <- %esp
176
192
177
   For simulating the cpuid instruction, we will
193
   We save registers and package up the args so we can call a C helper
178
   issue a "real" cpuid instruction and then mask out
194
   for all this.
179
   the bits of the features we do not support currently (3dnow mostly).
180
181
   Dirk Mueller <mueller@kde.org>
182
183
   http://www.sandpile.org/ia32/cpuid.htm
184
185
   references: 
186
187
   pre-MMX pentium:
188
189
   <werner> cpuid words (0): 0x1 0x756e6547 0x6c65746e 0x49656e69
190
   <werner> cpuid words (1): 0x52b 0x0 0x0 0x1bf
191
*/
195
*/
192
.global VG_(helper_CPUID)
196
.global VG_(helper_CPUID)
193
VG_(helper_CPUID):
197
VG_(helper_CPUID):
198
	pushl	%ebp
199
	movl	%esp,%ebp
194
	pushl	%eax
200
	pushl	%eax
195
	pushl	%ebx
201
	pushl	%ebx
196
	pushl	%ecx
202
	pushl	%ecx
197
	pushl	%edx
203
	pushl	%edx
198
	movl	32(%esp), %eax
204
	pushl	%esi
199
205
	pushl	%edi
200
        cmpl	$0x80000001, %eax
206
	pushf
201
        je	cpuid_no3dnow
202
203
	cpuid
204
	jmp	cpuid__99
205
206
cpuid_no3dnow:
207
	cpuid
208
	
207
	
209
	andl	$0x3fffffff, %edx
208
	lea	2*4(%ebp),%eax	/* &edx */
209
	pushl	%eax
210
	addl	$4,%eax		/* &ecx */
211
	pushl	%eax
212
	addl	$4,%eax		/* &ebx */
213
	pushl	%eax
214
	addl	$4,%eax		/* &eax */
215
	pushl	%eax
216
	pushl	(%eax)		/* eax */
210
217
211
cpuid__99:
218
	call	VG_(helperc_CPUID)
212
	movl	%edx, 20(%esp)
219
	addl	$20,%esp
213
	movl	%ecx, 24(%esp)
214
	movl	%ebx, 28(%esp)
215
	movl	%eax, 32(%esp)
216
220
221
	popf
222
	popl	%edi
223
	popl	%esi
217
	popl	%edx
224
	popl	%edx
218
	popl	%ecx
225
	popl	%ecx
219
	popl	%ebx
226
	popl	%ebx
220
	popl	%eax
227
	popl	%eax
228
	popl	%ebp
221
	ret
229
	ret
222
230
223
224
/* Fetch the FPU status register.
231
/* Fetch the FPU status register.
225
   On entry:
232
   On entry:
226
	dummy, replaced by result
233
	dummy, replaced by result
Lines 308-320 Link Here
308
       ret
315
       ret
309
	
316
	
310
317
318
/* Similarly, do %ax = AAS(%ax). */
319
.global VG_(helper_AAS)
320
VG_(helper_AAS):
321
       pushl   %eax
322
       movl    8(%esp), %eax
323
       aas
324
       movl    %eax, 8(%esp)
325
       popl    %eax
326
       ret
327
328
329
/* Similarly, do %ax = AAA(%ax). */
330
.global VG_(helper_AAA)
331
VG_(helper_AAA):
332
       pushl   %eax
333
       movl    8(%esp), %eax
334
       aaa
335
       movl    %eax, 8(%esp)
336
       popl    %eax
337
       ret
338
339
340
/* Similarly, do %ax = AAD(%ax). */
341
.global VG_(helper_AAD)
342
VG_(helper_AAD):
343
       pushl   %eax
344
       movl    8(%esp), %eax
345
       aad
346
       movl    %eax, 8(%esp)
347
       popl    %eax
348
       ret
349
350
351
/* Similarly, do %ax = AAM(%ax). */
352
.global VG_(helper_AAM)
353
VG_(helper_AAM):
354
       pushl   %eax
355
       movl    8(%esp), %eax
356
       aam
357
       movl    %eax, 8(%esp)
358
       popl    %eax
359
       ret
360
	
361
311
/* Bit scan forwards/reverse.  Sets flags (??).
362
/* Bit scan forwards/reverse.  Sets flags (??).
312
   On entry:
363
   On entry:
313
	value, replaced by result
364
	value, replaced by result
314
	RA   <- %esp
365
	RA   <- %esp
315
*/
366
*/
316
.global VG_(helper_bsr)
367
.global VG_(helper_bsrw)
317
VG_(helper_bsr):
368
VG_(helper_bsrw):
369
	pushl	%eax
370
	movw	12(%esp), %ax
371
	bsrw	8(%esp), %ax
372
	movw	%ax, 12(%esp)
373
	popl	%eax
374
	ret
375
376
.global VG_(helper_bsrl)
377
VG_(helper_bsrl):
318
	pushl	%eax
378
	pushl	%eax
319
	movl	12(%esp), %eax
379
	movl	12(%esp), %eax
320
	bsrl	8(%esp), %eax
380
	bsrl	8(%esp), %eax
Lines 322-329 Link Here
322
	popl	%eax
382
	popl	%eax
323
	ret
383
	ret
324
384
325
.global VG_(helper_bsf)
385
.global VG_(helper_bsfw)
326
VG_(helper_bsf):
386
VG_(helper_bsfw):
387
	pushl	%eax
388
	movw	12(%esp), %ax
389
	bsfw	8(%esp), %ax
390
	movw	%ax, 12(%esp)
391
	popl	%eax
392
	ret
393
394
.global VG_(helper_bsfl)
395
VG_(helper_bsfl):
327
	pushl	%eax
396
	pushl	%eax
328
	movl	12(%esp), %eax
397
	movl	12(%esp), %eax
329
	bsfl	8(%esp), %eax
398
	bsfl	8(%esp), %eax
Lines 441-447 Link Here
441
	popl	%eax
510
	popl	%eax
442
	ret
511
	ret
443
512
444
/* Clear/set the carry flag. */
513
/* Clear/set/complement the carry flag. */
445
.global VG_(helper_CLC)
514
.global VG_(helper_CLC)
446
VG_(helper_CLC):
515
VG_(helper_CLC):
447
        clc
516
        clc
Lines 452-457 Link Here
452
        stc
521
        stc
453
        ret
522
        ret
454
523
524
.global VG_(helper_CMC)
525
VG_(helper_CMC):
526
        cmc
527
        ret
528
455
/* Signed 32-to-64 multiply. */
529
/* Signed 32-to-64 multiply. */
456
.globl VG_(helper_imul_32_64)
530
.globl VG_(helper_imul_32_64)
457
VG_(helper_imul_32_64):
531
VG_(helper_imul_32_64):
Lines 615-620 Link Here
615
	ret
689
	ret
616
690
617
691
692
/* Eight byte compare and exchange. */
693
.globl VG_(helper_cmpxchg8b)
694
VG_(helper_cmpxchg8b):
695
        pushl %eax
696
        pushl %ebx
697
        pushl %ecx
698
        pushl %edx
699
        movl 20(%esp), %eax
700
        movl 24(%esp), %edx
701
        movl 28(%esp), %ebx
702
        movl 32(%esp), %ecx
703
        cmpxchg8b 36(%esp)
704
        movl %eax, 20(%esp)
705
        movl %edx, 24(%esp)
706
        movl %ebx, 28(%esp)
707
        movl %ecx, 32(%esp)
708
        popl %edx
709
        popl %ecx
710
        popl %ebx
711
        popl %eax
712
        ret
713
714
618
/* Undefined instruction (generates SIGILL) */
715
/* Undefined instruction (generates SIGILL) */
619
.globl VG_(helper_undefined_instruction)
716
.globl VG_(helper_undefined_instruction)
620
VG_(helper_undefined_instruction):
717
VG_(helper_undefined_instruction):
(-)valgrind-2.1.0/coregrind/vg_include.h (-210 / +233 lines)
Lines 9-15 Link Here
9
   This file is part of Valgrind, an extensible x86 protected-mode
9
   This file is part of Valgrind, an extensible x86 protected-mode
10
   emulator for monitoring program execution on x86-Unixes.
10
   emulator for monitoring program execution on x86-Unixes.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 49-54 Link Here
49
#include "vg_skin.h"
49
#include "vg_skin.h"
50
#include "valgrind.h"
50
#include "valgrind.h"
51
51
52
#undef SK_
53
#define SK_(x)	vgSkinInternal_##x
54
52
/* Total number of spill slots available for allocation, if a TempReg
55
/* Total number of spill slots available for allocation, if a TempReg
53
   doesn't make it into a RealReg.  Just bomb the entire system if
56
   doesn't make it into a RealReg.  Just bomb the entire system if
54
   this value is too small; we don't expect it will ever get
57
   this value is too small; we don't expect it will ever get
Lines 105-118 Link Here
105
   give finer interleaving but much increased scheduling overheads. */
108
   give finer interleaving but much increased scheduling overheads. */
106
#define VG_SCHEDULING_QUANTUM   50000
109
#define VG_SCHEDULING_QUANTUM   50000
107
110
108
/* Maximum FD Valgrind can use for its internal file descriptors. */
111
/* Number of file descriptors that Valgrind tries to reserve for
109
#define VG_MAX_SAFE_FD	1024	/* usual ulimit */
112
   it's own use - two per thread plues a small number of extras. */
110
113
#define VG_N_RESERVED_FDS (VG_N_THREADS*2 + 4)
111
/* Maximum allowed application-visible file descriptor.  Valgrind's
112
   internal fds hide above this (starting at VG_MAX_FD+1).  This is
113
   derived from the default fd limit (1024) minus the 2 fds per thread
114
   and a small number of extra fds. */
115
#define VG_MAX_FD	(VG_MAX_SAFE_FD - (VG_N_THREADS*2 + 4))
116
114
117
/* Stack size for a thread.  We try and check that they do not go
115
/* Stack size for a thread.  We try and check that they do not go
118
   beyond it. */
116
   beyond it. */
Lines 137-142 Link Here
137
#define VG_STACK_SIZE_W       10000
135
#define VG_STACK_SIZE_W       10000
138
#define VG_SIGSTACK_SIZE_W    10000
136
#define VG_SIGSTACK_SIZE_W    10000
139
137
138
/* Useful macros */
139
/* a - alignment - must be a power of 2 */
140
#define ROUNDDN(p, a)	((Addr)(p) & ~((a)-1))
141
#define ROUNDUP(p, a)	ROUNDDN((p)+(a)-1, (a))
142
#define PGROUNDDN(p)	ROUNDDN(p, VKI_BYTES_PER_PAGE)
143
#define PGROUNDUP(p)	ROUNDUP(p, VKI_BYTES_PER_PAGE)
144
145
140
/* ---------------------------------------------------------------------
146
/* ---------------------------------------------------------------------
141
   Basic types
147
   Basic types
142
   ------------------------------------------------------------------ */
148
   ------------------------------------------------------------------ */
Lines 157-162 Link Here
157
/* The max number of suppression files. */
163
/* The max number of suppression files. */
158
#define VG_CLO_MAX_SFILES 10
164
#define VG_CLO_MAX_SFILES 10
159
165
166
/* Default debugger command. */
167
#define VG_CLO_DEFAULT_DBCOMMAND GDB_PATH " -nw %f %p"
168
160
/* Describes where logging output is to be sent. */
169
/* Describes where logging output is to be sent. */
161
typedef
170
typedef
162
   enum {
171
   enum {
Lines 171-182 Link Here
171
/* pgrp of process (global to all threads) */
180
/* pgrp of process (global to all threads) */
172
extern Int VG_(main_pgrp);
181
extern Int VG_(main_pgrp);
173
182
183
/* Maximum allowed application-visible file descriptor */
184
extern Int VG_(max_fd);
185
174
/* Should we stop collecting errors if too many appear?  default: YES */
186
/* Should we stop collecting errors if too many appear?  default: YES */
175
extern Bool  VG_(clo_error_limit);
187
extern Bool  VG_(clo_error_limit);
176
/* Enquire about whether to attach to GDB at errors?   default: NO */
188
/* Enquire about whether to attach to a debugger at errors?   default: NO */
177
extern Bool  VG_(clo_GDB_attach);
189
extern Bool  VG_(clo_db_attach);
178
/* The path to GDB?  default: whatever ./configure found */
190
/* The debugger command?  default: whatever gdb ./configure found */
179
extern Char* VG_(clo_GDB_path);
191
extern Char* VG_(clo_db_command);
180
/* Enquire about generating a suppression for each error?   default: NO */
192
/* Enquire about generating a suppression for each error?   default: NO */
181
extern Bool  VG_(clo_gen_suppressions);
193
extern Bool  VG_(clo_gen_suppressions);
182
/* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
194
/* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
Lines 231-238 Link Here
231
/* DEBUG: print pthread (mutex etc) events?  default: 0 (none), 1
243
/* DEBUG: print pthread (mutex etc) events?  default: 0 (none), 1
232
   (some), 2 (all) */
244
   (some), 2 (all) */
233
extern Int   VG_(clo_trace_pthread_level);
245
extern Int   VG_(clo_trace_pthread_level);
234
/* Stop after this many basic blocks.  default: Infinity. */
235
extern ULong VG_(clo_stop_after);
236
/* Display gory details for the k'th most popular error.  default:
246
/* Display gory details for the k'th most popular error.  default:
237
   Infinity. */
247
   Infinity. */
238
extern Int   VG_(clo_dump_error);
248
extern Int   VG_(clo_dump_error);
Lines 259-267 Link Here
259
extern Bool  VG_(clo_run_libc_freeres);
269
extern Bool  VG_(clo_run_libc_freeres);
260
/* Use the basic-block chaining optimisation?  Default: YES */
270
/* Use the basic-block chaining optimisation?  Default: YES */
261
extern Bool VG_(clo_chain_bb);
271
extern Bool VG_(clo_chain_bb);
272
/* Generate branch-prediction hints? */
273
extern Bool VG_(clo_branchpred);
262
/* Continue stack traces below main()?  Default: NO */
274
/* Continue stack traces below main()?  Default: NO */
263
extern Bool VG_(clo_show_below_main);
275
extern Bool VG_(clo_show_below_main);
264
276
/* Test each client pointer dereference to check it's within the
277
   client address space bounds */
278
extern Bool VG_(clo_pointercheck);
265
279
266
/* ---------------------------------------------------------------------
280
/* ---------------------------------------------------------------------
267
   Debugging and profiling stuff
281
   Debugging and profiling stuff
Lines 319-414 Link Here
319
      Bool syscall_wrapper;
333
      Bool syscall_wrapper;
320
      Bool sanity_checks;
334
      Bool sanity_checks;
321
      Bool data_syms;
335
      Bool data_syms;
336
      Bool shadow_memory;
322
   } 
337
   } 
323
   VgNeeds;
338
   VgNeeds;
324
339
325
extern VgNeeds VG_(needs);
340
extern VgNeeds VG_(needs);
326
341
327
/* Events happening in core to track.  To be notified, assign a function
342
extern void VG_(tool_init_dlsym)(void *dlhandle);
328
   to the function pointer.  To ignore an event, don't do anything
329
   (default assignment is to NULL in which case the call is skipped). */
330
typedef
331
   struct {
332
      /* Memory events */
333
      void (*new_mem_startup)( Addr a, UInt len, Bool rr, Bool ww, Bool xx );
334
      void (*new_mem_stack_signal)  ( Addr a, UInt len );
335
      void (*new_mem_brk)    ( Addr a, UInt len );
336
      void (*new_mem_mmap)   ( Addr a, UInt len, Bool rr, Bool ww, Bool xx );
337
338
      void (*copy_mem_remap) ( Addr from, Addr to, UInt len );
339
      void (*change_mem_mprotect) ( Addr a, UInt len, Bool rr, Bool ww, Bool xx );
340
      void (*die_mem_stack_signal)  ( Addr a, UInt len );
341
      void (*die_mem_brk)    ( Addr a, UInt len );
342
      void (*die_mem_munmap) ( Addr a, UInt len );
343
344
      void (*new_mem_stack_4)  ( Addr new_ESP );
345
      void (*new_mem_stack_8)  ( Addr new_ESP );
346
      void (*new_mem_stack_12) ( Addr new_ESP );
347
      void (*new_mem_stack_16) ( Addr new_ESP );
348
      void (*new_mem_stack_32) ( Addr new_ESP );
349
      void (*new_mem_stack)    ( Addr a, UInt len );
350
351
      void (*die_mem_stack_4)  ( Addr die_ESP );
352
      void (*die_mem_stack_8)  ( Addr die_ESP );
353
      void (*die_mem_stack_12) ( Addr die_ESP );
354
      void (*die_mem_stack_16) ( Addr die_ESP );
355
      void (*die_mem_stack_32) ( Addr die_ESP );
356
      void (*die_mem_stack)    ( Addr a, UInt len );
357
358
      void (*ban_mem_stack)  ( Addr a, UInt len );
359
360
      void (*pre_mem_read)   ( CorePart part, ThreadId tid,
361
                               Char* s, Addr a, UInt size );
362
      void (*pre_mem_read_asciiz) ( CorePart part, ThreadId tid,
363
                                    Char* s, Addr a );
364
      void (*pre_mem_write)  ( CorePart part, ThreadId tid,
365
                               Char* s, Addr a, UInt size );
366
      /* Not implemented yet -- have to add in lots of places, which is a
367
         pain.  Won't bother unless/until there's a need. */
368
      /* void (*post_mem_read)  ( ThreadState* tst, Char* s, 
369
                                  Addr a, UInt size ); */
370
      void (*post_mem_write) ( Addr a, UInt size );
371
372
373
      /* Register events */
374
      void (*post_regs_write_init)             ( void );
375
      void (*post_reg_write_syscall_return)    ( ThreadId tid, UInt reg );
376
      void (*post_reg_write_deliver_signal)    ( ThreadId tid, UInt reg );
377
      void (*post_reg_write_pthread_return)    ( ThreadId tid, UInt reg );
378
      void (*post_reg_write_clientreq_return)  ( ThreadId tid, UInt reg );
379
      void (*post_reg_write_clientcall_return) ( ThreadId tid, UInt reg,
380
                                                 Addr f );
381
382
383
      /* Scheduler events (not exhaustive) */
384
      void (*thread_run) ( ThreadId tid );
385
386
387
      /* Thread events (not exhaustive) */
388
      void (*post_thread_create) ( ThreadId tid, ThreadId child );
389
      void (*post_thread_join)   ( ThreadId joiner, ThreadId joinee );
390
391
392
      /* Mutex events (not exhaustive) */
393
      void (*pre_mutex_lock)    ( ThreadId tid, 
394
                                  void* /*pthread_mutex_t* */ mutex );
395
      void (*post_mutex_lock)   ( ThreadId tid, 
396
                                  void* /*pthread_mutex_t* */ mutex );
397
      void (*post_mutex_unlock) ( ThreadId tid, 
398
                                  void* /*pthread_mutex_t* */ mutex );
399
400
      /* Signal events (not exhaustive) */
401
      void (* pre_deliver_signal) ( ThreadId tid, Int sigNo, Bool alt_stack );
402
      void (*post_deliver_signal) ( ThreadId tid, Int sigNo );
403
404
      
405
      /* Others... condition variable... */
406
      /* ... */
407
   }
408
   VgTrackEvents;
409
410
extern VgTrackEvents VG_(track_events);
411
343
344
#include "vg_toolint.h"
412
345
413
/* ---------------------------------------------------------------------
346
/* ---------------------------------------------------------------------
414
   Exports of vg_needs.c
347
   Exports of vg_needs.c
Lines 423-429 Link Here
423
/* Allocation arenas.  
356
/* Allocation arenas.  
424
357
425
      CORE      for the core's general use.
358
      CORE      for the core's general use.
426
      SKIN      for the skin to use (and the only one it uses).
359
      TOOL      for the tool to use (and the only one it uses).
427
      SYMTAB    for Valgrind's symbol table storage.
360
      SYMTAB    for Valgrind's symbol table storage.
428
      JITTER    for small storage during translation.
361
      JITTER    for small storage during translation.
429
      CLIENT    for the client's mallocs/frees, if the skin replaces glibc's
362
      CLIENT    for the client's mallocs/frees, if the skin replaces glibc's
Lines 440-446 Link Here
440
#define VG_N_ARENAS        9 
373
#define VG_N_ARENAS        9 
441
374
442
#define VG_AR_CORE         0
375
#define VG_AR_CORE         0
443
#define VG_AR_SKIN         1
376
#define VG_AR_TOOL         1
444
#define VG_AR_SYMTAB       2
377
#define VG_AR_SYMTAB       2
445
#define VG_AR_JITTER       3
378
#define VG_AR_JITTER       3
446
#define VG_AR_CLIENT       4
379
#define VG_AR_CLIENT       4
Lines 550-555 Link Here
550
483
551
/* Denote the finish of VG_(__libc_freeres_wrapper). */
484
/* Denote the finish of VG_(__libc_freeres_wrapper). */
552
#define VG_USERREQ__LIBC_FREERES_DONE       0x3029
485
#define VG_USERREQ__LIBC_FREERES_DONE       0x3029
486
#define VG_USERREQ__REGISTER_LIBC_FREERES   0x302A
487
488
/* Allocate RT signals */
489
#define VG_USERREQ__GET_SIGRT_MIN	    0x302B
490
#define VG_USERREQ__GET_SIGRT_MAX	    0x302C
491
#define VG_USERREQ__ALLOC_RTSIG		    0x302D
492
493
/* Hook for replace_malloc.o to get malloc functions */
494
#define VG_USERREQ__GET_MALLOCFUNCS	    0x3030
495
496
/* Hook for interface to vg_inject.so */
497
#define VG_USERREQ__REGISTER_REDIRECT_SYM   0x3031
498
#define VG_USERREQ__REGISTER_REDIRECT_ADDR  0x3032
553
499
554
/* Cosmetic ... */
500
/* Cosmetic ... */
555
#define VG_USERREQ__GET_PTHREAD_TRACE_LEVEL 0x3101
501
#define VG_USERREQ__GET_PTHREAD_TRACE_LEVEL 0x3101
Lines 566-574 Link Here
566
*/
512
*/
567
513
568
514
569
/* The scheduler does need to know the address of it so it can be
515
struct vg_mallocfunc_info {
570
   called at program exit. */
516
   /* things vg_replace_malloc.o needs to know about */
571
extern void VG_(__libc_freeres_wrapper)( void );
517
   Addr	sk_malloc;
518
   Addr	sk_calloc;
519
   Addr	sk_realloc;
520
   Addr	sk_memalign;
521
   Addr	sk___builtin_new;
522
   Addr	sk___builtin_vec_new;
523
   Addr	sk_free;
524
   Addr	sk___builtin_delete;
525
   Addr	sk___builtin_vec_delete;
526
527
   Addr	arena_payload_szB;
528
529
   Bool	clo_sloppy_malloc;
530
   Bool	clo_trace_malloc;
531
};
572
532
573
__attribute__((weak))
533
__attribute__((weak))
574
int
534
int
Lines 665-675 Link Here
665
         VG_(allocate_LDT_for_thread) ( VgLdtEntry* parent_ldt );
625
         VG_(allocate_LDT_for_thread) ( VgLdtEntry* parent_ldt );
666
extern void       
626
extern void       
667
         VG_(deallocate_LDT_for_thread) ( VgLdtEntry* ldt );
627
         VG_(deallocate_LDT_for_thread) ( VgLdtEntry* ldt );
628
extern void       
629
         VG_(clear_TLS_for_thread) ( VgLdtEntry* tls );
668
630
669
/* Simulate the modify_ldt syscall. */
631
/* Simulate the modify_ldt syscall. */
670
extern Int VG_(sys_modify_ldt) ( ThreadId tid,
632
extern Int VG_(sys_modify_ldt) ( ThreadId tid,
671
                                 Int func, void* ptr, UInt bytecount );
633
                                 Int func, void* ptr, UInt bytecount );
672
634
635
/* Simulate the {get,set}_thread_area syscalls. */
636
extern Int VG_(sys_set_thread_area) ( ThreadId tid,
637
                                      struct vki_modify_ldt_ldt_s* info );
638
extern Int VG_(sys_get_thread_area) ( ThreadId tid,
639
                                      struct vki_modify_ldt_ldt_s* info );
640
673
/* Called from generated code.  Given a segment selector and a virtual
641
/* Called from generated code.  Given a segment selector and a virtual
674
   address, return a linear address, and do limit checks too. */
642
   address, return a linear address, and do limit checks too. */
675
extern Addr VG_(do_useseg) ( UInt seg_selector, Addr virtual_addr );
643
extern Addr VG_(do_useseg) ( UInt seg_selector, Addr virtual_addr );
Lines 805-812 Link Here
805
   */
773
   */
806
   vki_ksigset_t sig_mask;
774
   vki_ksigset_t sig_mask;
807
775
808
   /* Effective signal mask.  This is the mask which is currently
776
   /* Effective signal mask.  This is the mask which currently
809
      applying; it may be different from sig_mask while a signal
777
      applies; it may be different from sig_mask while a signal
810
      handler is running.
778
      handler is running.
811
    */
779
    */
812
   vki_ksigset_t eff_sig_mask;
780
   vki_ksigset_t eff_sig_mask;
Lines 844-854 Link Here
844
      deallocate this at thread exit. */
812
      deallocate this at thread exit. */
845
   VgLdtEntry* ldt;
813
   VgLdtEntry* ldt;
846
814
815
   /* TLS table. This consists of a small number (currently 3) of
816
      entries from the Global Descriptor Table. */
817
   VgLdtEntry tls[VKI_GDT_TLS_ENTRIES];
818
847
   /* Saved machine context.  Note the FPU state, %EIP and segment
819
   /* Saved machine context.  Note the FPU state, %EIP and segment
848
      registers are not shadowed.
820
      registers are not shadowed.
849
821
850
      Although the segment registers are 16 bits long, storage
822
      Although the segment registers are 16 bits long, storage
851
      management here, in VG_(baseBlock) and in VG_(m_state_static) is
823
      management here and in VG_(baseBlock) is
852
      simplified if we pretend they are 32 bits. */
824
      simplified if we pretend they are 32 bits. */
853
   UInt m_cs;
825
   UInt m_cs;
854
   UInt m_ss;
826
   UInt m_ss;
Lines 936-943 Link Here
936
                            even if we wait for a long time */
908
                            even if we wait for a long time */
937
      VgSrc_ExitSyscall, /* client called exit().  This is the normal
909
      VgSrc_ExitSyscall, /* client called exit().  This is the normal
938
                            route out. */
910
                            route out. */
939
      VgSrc_BbsDone,     /* In a debugging run, the specified number of
940
                            bbs has been completed. */
941
      VgSrc_FatalSig	 /* Killed by the default action of a fatal
911
      VgSrc_FatalSig	 /* Killed by the default action of a fatal
942
			    signal */
912
			    signal */
943
   }
913
   }
Lines 1087-1096 Link Here
1087
/* Skins use VG_(strdup)() which doesn't expose ArenaId */
1057
/* Skins use VG_(strdup)() which doesn't expose ArenaId */
1088
extern Char* VG_(arena_strdup) ( ArenaId aid, const Char* s);
1058
extern Char* VG_(arena_strdup) ( ArenaId aid, const Char* s);
1089
1059
1090
/* Skins shouldn't need these...(?) */
1091
extern void VG_(start_rdtsc_calibration) ( void );
1092
extern void VG_(end_rdtsc_calibration) ( void );
1093
1094
extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
1060
extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
1095
extern Int VG_(select)( Int n, 
1061
extern Int VG_(select)( Int n, 
1096
                        vki_fd_set* readfds, 
1062
                        vki_fd_set* readfds, 
Lines 1101-1106 Link Here
1101
extern Int VG_(nanosleep)( const struct vki_timespec *req, 
1067
extern Int VG_(nanosleep)( const struct vki_timespec *req, 
1102
                           struct vki_timespec *rem );
1068
                           struct vki_timespec *rem );
1103
1069
1070
/* system/mman.h */
1071
extern void* VG_(mmap)( void* start, UInt length,
1072
                        UInt prot, UInt flags, UInt fd, UInt offset );
1073
extern Int  VG_(munmap)( void* start, Int length );
1074
extern Int  VG_(mprotect)( void *start, Int length, UInt prot );
1075
1076
1104
/* Move an fd into the Valgrind-safe range */
1077
/* Move an fd into the Valgrind-safe range */
1105
Int VG_(safe_fd)(Int oldfd);
1078
Int VG_(safe_fd)(Int oldfd);
1106
1079
Lines 1109-1114 Link Here
1109
/* --- Connecting over the network --- */
1082
/* --- Connecting over the network --- */
1110
extern Int VG_(connect_via_socket)( UChar* str );
1083
extern Int VG_(connect_via_socket)( UChar* str );
1111
1084
1085
/* Environment manipulations */
1086
extern Char **VG_(env_clone) ( Char **oldenv );
1087
extern Char* VG_(env_getenv) ( Char **env, Char* varname );
1088
extern Char **VG_(env_setenv) ( Char ***envp, const Char* varname, const Char *val );
1089
extern void  VG_(env_unsetenv) ( Char **env, const Char *varname );
1112
1090
1113
/* ---------------------------------------------------------------------
1091
/* ---------------------------------------------------------------------
1114
   Exports of vg_message.c
1092
   Exports of vg_message.c
Lines 1154-1159 Link Here
1154
   Exports of vg_to_ucode.c
1132
   Exports of vg_to_ucode.c
1155
   ------------------------------------------------------------------ */
1133
   ------------------------------------------------------------------ */
1156
1134
1135
Bool VG_(cpu_has_feature)(UInt feat);
1136
1157
extern Int   VG_(disBB)          ( UCodeBlock* cb, Addr eip0 );
1137
extern Int   VG_(disBB)          ( UCodeBlock* cb, Addr eip0 );
1158
1138
1159
/* ---------------------------------------------------------------------
1139
/* ---------------------------------------------------------------------
Lines 1301-1308 Link Here
1301
1281
1302
extern Bool VG_(is_action_requested) ( Char* action, Bool* clo );
1282
extern Bool VG_(is_action_requested) ( Char* action, Bool* clo );
1303
1283
1304
extern void VG_(gen_suppression) ( Error* err );
1305
1306
extern UInt VG_(n_errs_found);
1284
extern UInt VG_(n_errs_found);
1307
1285
1308
/* ---------------------------------------------------------------------
1286
/* ---------------------------------------------------------------------
Lines 1318-1324 Link Here
1318
   it's read from the buffer filled by VG_(read_procselfmaps_contents)(). */
1296
   it's read from the buffer filled by VG_(read_procselfmaps_contents)(). */
1319
extern 
1297
extern 
1320
void VG_(parse_procselfmaps) (
1298
void VG_(parse_procselfmaps) (
1321
   void (*record_mapping)( Addr, UInt, Char, Char, Char, UInt, UChar* )
1299
   void (*record_mapping)( Addr addr, UInt len, Char rr, Char ww, Char xx, 
1300
			   UInt dev, UInt ino, ULong foff, const UChar *filename )
1322
);
1301
);
1323
1302
1324
1303
Lines 1326-1352 Link Here
1326
   Exports of vg_symtab2.c
1305
   Exports of vg_symtab2.c
1327
   ------------------------------------------------------------------ */
1306
   ------------------------------------------------------------------ */
1328
1307
1308
typedef struct _Segment Segment;
1309
1310
extern Bool VG_(is_object_file)   ( const void *hdr );
1329
extern void VG_(mini_stack_dump)  ( Addr eips[], UInt n_eips );
1311
extern void VG_(mini_stack_dump)  ( Addr eips[], UInt n_eips );
1330
extern void VG_(read_all_symbols) ( void );
1312
extern SegInfo * VG_(read_seg_symbols) ( Segment *seg );
1331
extern void VG_(read_seg_symbols) ( Addr start, UInt size, 
1332
                                    Char rr, Char ww, Char xx,
1333
                                    UInt foffset, UChar* filename );
1334
extern void VG_(unload_symbols)   ( Addr start, UInt length );
1313
extern void VG_(unload_symbols)   ( Addr start, UInt length );
1314
extern void VG_(symtab_incref)	  ( SegInfo * );
1315
extern void VG_(symtab_decref)	  ( SegInfo *, Addr a, UInt len );
1335
1316
1336
extern Bool VG_(get_fnname_nodemangle)( Addr a, Char* fnname, Int n_fnname );
1317
extern Bool VG_(get_fnname_nodemangle)( Addr a, Char* fnname, Int n_fnname );
1337
extern Int  VG_(setup_code_redirect_table) ( void );
1338
1339
typedef
1340
   struct {
1341
      Addr entry_pt_orig;
1342
      Addr entry_pt_subst;
1343
   }
1344
   CodeRedirect;
1345
1318
1346
#define VG_N_CODE_REDIRECTS 10
1319
/* Set up some default redirects */
1347
extern CodeRedirect VG_(code_redirect_table)[VG_N_CODE_REDIRECTS];
1320
extern void VG_(setup_code_redirect_table) ( void );
1348
/* Table is terminated by a NULL entry_pt_orig field. */
1349
1321
1322
/* Redirection machinery */
1323
extern void VG_(add_redirect_sym)(const Char *from_lib, const Char *from_sym,
1324
				  const Char *to_lib, const Char *to_sym);
1325
extern void VG_(add_redirect_addr)(const Char *from_lib, const Char *from_sym,
1326
				   Addr to_addr);
1327
extern Addr VG_(code_redirect)	  (Addr orig);
1350
1328
1351
/* ---------------------------------------------------------------------
1329
/* ---------------------------------------------------------------------
1352
   Exports of vg_main.c
1330
   Exports of vg_main.c
Lines 1354-1360 Link Here
1354
1332
1355
/* Is this a SSE/SSE2-capable CPU?  If so, we had better save/restore
1333
/* Is this a SSE/SSE2-capable CPU?  If so, we had better save/restore
1356
   the SSE state all over the place.  This is set up very early, in
1334
   the SSE state all over the place.  This is set up very early, in
1357
   vg_startup.S.  We have to determine it early since we can't even
1335
   main().  We have to determine it early since we can't even
1358
   correctly snapshot the startup machine state without it. */
1336
   correctly snapshot the startup machine state without it. */
1359
extern Bool VG_(have_ssestate);
1337
extern Bool VG_(have_ssestate);
1360
1338
Lines 1365-1390 Link Here
1365
/* Sanity checks which may be done at any time.  The scheduler decides when. */
1343
/* Sanity checks which may be done at any time.  The scheduler decides when. */
1366
extern void VG_(do_sanity_checks) ( Bool force_expensive );
1344
extern void VG_(do_sanity_checks) ( Bool force_expensive );
1367
1345
1368
/* A structure used as an intermediary when passing the simulated
1346
/* Address space */
1369
   CPU's state to some assembly fragments, particularly system calls.
1347
extern Addr VG_(client_base);	/* client address space limits */
1370
   Stuff is copied from baseBlock to here, the assembly magic runs,
1348
extern Addr VG_(client_end);
1371
   and then the inverse copy is done.  Alignment: the SSE state must
1349
extern Addr VG_(client_mapbase); /* base of mappings */
1372
   be 16-byte aligned.  We ask for the whole struct to be 16-byte
1350
extern Addr VG_(clstk_base);	/* client stack range */
1373
   aligned, and the SSE state starts at the 6+8+1+1th == 16th word,
1351
extern Addr VG_(clstk_end);
1374
   so it too must be 16-byte aligned.  Consequence: change this struct
1352
extern Addr VG_(client_trampoline_code);
1375
   only _very carefully_ !  See also above comment re masking MXCSR. 
1353
1376
*/
1354
extern Addr VG_(brk_base);	/* start of brk */
1377
__attribute__ ((aligned (16)))
1355
extern Addr VG_(brk_limit);	/* current brk */
1378
extern UInt VG_(m_state_static) [6 /* segment regs, Intel order */
1356
extern Addr VG_(shadow_base);	/* skin's shadow memory */
1379
                                 + 8 /* int regs, in Intel order */ 
1357
extern Addr VG_(shadow_end);
1380
                                 + 1 /* %eflags */ 
1358
extern Addr VG_(valgrind_base);	/* valgrind's address range */
1381
                                 + 1 /* %eip */
1359
extern Addr VG_(valgrind_mmap_end);
1382
                                 + VG_SIZE_OF_SSESTATE_W /* SSE state */
1360
extern Addr VG_(valgrind_end);
1383
                                ];
1361
1384
1362
/* stage1 executable file descriptor */
1385
/* Handy fns for doing the copy back and forth. */
1363
extern Int  VG_(vgexecfd);
1386
extern void VG_(copy_baseBlock_to_m_state_static) ( void );
1364
1387
extern void VG_(copy_m_state_static_to_baseBlock) ( void );
1365
/* client executable file descriptor */
1366
extern Int  VG_(clexecfd);
1367
1368
/* Path to all our library/aux files */
1369
extern const Char *VG_(libdir);
1388
1370
1389
/* Determine if %esp adjustment must be noted */
1371
/* Determine if %esp adjustment must be noted */
1390
extern Bool VG_(need_to_handle_esp_assignment) ( void );
1372
extern Bool VG_(need_to_handle_esp_assignment) ( void );
Lines 1394-1429 Link Here
1394
extern void VG_(unimplemented) ( Char* msg )
1376
extern void VG_(unimplemented) ( Char* msg )
1395
            __attribute__((__noreturn__));
1377
            __attribute__((__noreturn__));
1396
1378
1397
/* The stack on which Valgrind runs.  We can't use the same stack as the
1398
   simulatee -- that's an important design decision.  */
1399
extern UInt VG_(stack)[VG_STACK_SIZE_W];
1400
1401
/* Similarly, we have to ask for signals to be delivered on an alternative
1379
/* Similarly, we have to ask for signals to be delivered on an alternative
1402
   stack, since it is possible, although unlikely, that we'll have to run
1380
   stack, since it is possible, although unlikely, that we'll have to run
1403
   client code from inside the Valgrind-installed signal handler.  If this
1381
   client code from inside the Valgrind-installed signal handler.  If this
1404
   happens it will be done by vg_deliver_signal_immediately(). */
1382
   happens it will be done by vg_deliver_signal_immediately(). */
1405
extern UInt VG_(sigstack)[VG_SIGSTACK_SIZE_W];
1383
extern UInt VG_(sigstack)[VG_SIGSTACK_SIZE_W];
1406
1384
1407
/* Holds client's %esp at the point we gained control.  From this the
1385
/* Valgrind's argc and argv */
1408
   client's argc, argv and envp are deduced. */
1386
extern Int    VG_(vg_argc);
1409
extern Addr   VG_(esp_at_startup);
1387
extern Char **VG_(vg_argv);
1410
1388
1411
/* Indicates presence, and holds address of client's sysinfo page, a
1389
/* Indicates presence, and holds address of client's sysinfo page, a
1412
   feature of some modern kernels used to provide vsyscalls, etc. */
1390
   feature of some modern kernels used to provide vsyscalls, etc. */
1413
extern Bool VG_(sysinfo_page_exists);
1391
extern Bool VG_(sysinfo_page_exists);
1414
extern Addr VG_(sysinfo_page_addr);
1392
extern Addr VG_(sysinfo_page_addr);
1415
1393
1416
/* Remove valgrind.so and skin's .so from a LD_PRELOAD=... string so child
1394
/* Walk through a colon separated list variable, removing entries
1417
   processes don't get traced into.  Also mess up $libdir/valgrind so that
1395
   which match pattern. */
1418
   our libpthread.so disappears from view. */
1396
extern void VG_(mash_colon_env)(Char *varp, const Char *pattern);
1419
void VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH) ( Char* ld_preload_str,
1397
1420
                                                Char* ld_library_path_str );
1398
/* Something of a function looking for a home ... start up debugger. */
1421
1399
extern void VG_(start_debugger) ( Int tid );
1422
/* Something of a function looking for a home ... start up GDB.  This
1423
   is called from VG_(swizzle_esp_then_start_GDB) and so runs on the
1424
   *client's* stack.  This is necessary to give GDB the illusion that
1425
   the client program really was running on the real cpu. */
1426
extern void VG_(start_GDB_whilst_on_client_stack) ( void );
1427
1400
1428
/* VG_(bbs_done) in include/vg_skin.h */
1401
/* VG_(bbs_done) in include/vg_skin.h */
1429
1402
Lines 1433-1441 Link Here
1433
/* Counts downwards in vg_run_innerloop. */
1406
/* Counts downwards in vg_run_innerloop. */
1434
extern UInt VG_(dispatch_ctr);
1407
extern UInt VG_(dispatch_ctr);
1435
1408
1436
/* Is the client running on the simulated CPU or the real one? */
1437
extern Bool VG_(running_on_simd_CPU); /* Initially False */
1438
1439
/* This is the ThreadId of the last thread the scheduler ran. */
1409
/* This is the ThreadId of the last thread the scheduler ran. */
1440
extern ThreadId VG_(last_run_tid);
1410
extern ThreadId VG_(last_run_tid);
1441
1411
Lines 1499-1525 Link Here
1499
UInt VG_(insertDflag)(UInt eflags, Int d);
1469
UInt VG_(insertDflag)(UInt eflags, Int d);
1500
Int VG_(extractDflag)(UInt eflags);
1470
Int VG_(extractDflag)(UInt eflags);
1501
1471
1502
/* start address and size of the initial stack */
1503
extern Addr VG_(foundstack_start);
1504
extern UInt VG_(foundstack_size);
1505
1506
1507
/* ---------------------------------------------------------------------
1472
/* ---------------------------------------------------------------------
1508
   Exports of vg_memory.c
1473
   Exports of vg_memory.c
1509
   ------------------------------------------------------------------ */
1474
   ------------------------------------------------------------------ */
1510
1475
1511
extern void VG_(init_memory)        ( void );
1476
/* A Segment is mapped piece of client memory.  This covers all kinds
1512
extern void VG_(new_exeseg_startup) ( Addr a, UInt len, Char rr, Char ww,
1477
   of mapped memory (exe, brk, mmap, .so, shm, stack, etc)
1513
                                      Char xx, UInt foffset,
1478
1514
                                      UChar* filename );
1479
   We try to encode everything we know about a particular segment here.
1515
extern void VG_(new_exeseg_mmap)    ( Addr a, UInt len );
1480
*/
1516
extern void VG_(remove_if_exeseg)   ( Addr a, UInt len );
1481
#define SF_FIXED	(1 <<  0) /* client asked for MAP_FIXED			*/
1482
#define SF_SHARED	(1 <<  1) /* shared					*/
1483
#define SF_SHM		(1 <<  2) /* SYSV SHM (also SF_SHARED)			*/
1484
#define SF_MMAP		(1 <<  3) /* mmap memory				*/
1485
#define SF_FILE		(1 <<  4) /* mapping is backed by a file		*/
1486
#define SF_STACK	(1 <<  5) /* is a stack					*/
1487
#define SF_GROWDOWN	(1 <<  6) /* segment grows down				*/
1488
#define SF_GROWUP	(1 <<  7) /* segment grows up				*/
1489
#define SF_EXEC		(1 <<  8) /* segment created by exec			*/
1490
#define SF_DYNLIB	(1 <<  9) /* mapped from dynamic library		*/
1491
#define SF_NOSYMS	(1 << 10) /* don't load syms, even if present           */
1492
#define SF_BRK		(1 << 11) /* brk segment                                */
1493
#define SF_CORE		(1 << 12) /* allocated by core on behalf of the client  */
1494
#define SF_VALGRIND	(1 << 13) /* a valgrind-internal mapping - not in client*/
1495
#define SF_CODE		(1 << 14) /* segment contains cached code               */
1496
1497
struct _Segment {
1498
   UInt		prot;		/* VKI_PROT_*				*/
1499
   UInt		flags;		/* SF_*					*/
1500
1501
   Addr		addr;		/* mapped addr (page aligned)		*/
1502
   UInt		len;		/* size of mapping (page aligned)	*/
1503
1504
   /* These are valid if (flags & SF_FILE) */
1505
   ULong	offset;		/* file offset				*/
1506
   const Char	*filename;	/* filename (NULL if unknown)		*/
1507
   UInt		dev;		/* device				*/
1508
   UInt		ino;		/* inode				*/
1509
1510
   SegInfo	*symtab;	/* symbol table				*/
1511
};
1512
1513
/* segment mapped from a file descriptor */
1514
extern void VG_(map_fd_segment)  (Addr addr, UInt len, UInt prot, UInt flags, 
1515
				  Int fd, ULong off, const Char *filename);
1516
1517
/* segment mapped from a file */
1518
extern void VG_(map_file_segment)(Addr addr, UInt len, UInt prot, UInt flags, 
1519
				  UInt dev, UInt ino, ULong off, const Char *filename);
1520
1521
/* simple segment */
1522
extern void VG_(map_segment)     (Addr addr, UInt len, UInt prot, UInt flags);
1523
1524
extern void VG_(unmap_range)   (Addr addr, UInt len);
1525
extern void VG_(mprotect_range)(Addr addr, UInt len, UInt prot);
1526
extern Addr VG_(find_map_space)(Addr base, UInt len, Bool for_client);
1527
1528
extern Segment *VG_(find_segment)(Addr a);
1529
extern Segment *VG_(next_segment)(Segment *);
1530
1531
extern Bool     VG_(seg_contains)(const Segment *s, Addr ptr, UInt size);
1532
extern Bool     VG_(seg_overlaps)(const Segment *s, Addr ptr, UInt size);
1517
1533
1518
extern __attribute__((regparm(1))) 
1534
extern __attribute__((regparm(1))) 
1519
       void VG_(unknown_esp_update) ( Addr new_ESP );
1535
       void VG_(unknown_esp_update) ( Addr new_ESP );
1520
1536
1521
extern Bool VG_(is_addressable)(Addr p, Int sz);
1522
1523
/* ---------------------------------------------------------------------
1537
/* ---------------------------------------------------------------------
1524
   Exports of vg_proxylwp.c
1538
   Exports of vg_proxylwp.c
1525
   ------------------------------------------------------------------ */
1539
   ------------------------------------------------------------------ */
Lines 1536-1542 Link Here
1536
extern void VG_(proxy_sigack)   ( ThreadId tid, const vki_ksigset_t *);
1550
extern void VG_(proxy_sigack)   ( ThreadId tid, const vki_ksigset_t *);
1537
extern void VG_(proxy_abort_syscall) ( ThreadId tid );
1551
extern void VG_(proxy_abort_syscall) ( ThreadId tid );
1538
extern void VG_(proxy_waitsig)  ( void );
1552
extern void VG_(proxy_waitsig)  ( void );
1539
extern void VG_(proxy_wait_sys)	(ThreadId tid);
1553
extern void VG_(proxy_wait_sys)	(ThreadId tid, Bool restart);
1540
1554
1541
extern void VG_(proxy_shutdown) ( void );	/* shut down the syscall workers */
1555
extern void VG_(proxy_shutdown) ( void );	/* shut down the syscall workers */
1542
extern Int  VG_(proxy_resfd)    ( void );	/* FD something can select on to know 
1556
extern Int  VG_(proxy_resfd)    ( void );	/* FD something can select on to know 
Lines 1551-1565 Link Here
1551
extern void VG_(proxy_handlesig)( const vki_ksiginfo_t *siginfo, 
1565
extern void VG_(proxy_handlesig)( const vki_ksiginfo_t *siginfo, 
1552
				  const struct vki_sigcontext *sigcontext );
1566
				  const struct vki_sigcontext *sigcontext );
1553
1567
1568
/* Get the PID/TID of the ProxyLWP. */
1569
extern Int VG_(proxy_id)(ThreadId tid);
1570
1554
1571
1555
/* ---------------------------------------------------------------------
1572
/* ---------------------------------------------------------------------
1556
   Exports of vg_syscalls.c
1573
   Exports of vg_syscalls.c
1557
   ------------------------------------------------------------------ */
1574
   ------------------------------------------------------------------ */
1558
1575
1559
extern void VG_(init_dataseg_end_for_brk) ( void );
1576
extern Char *VG_(resolve_filename)(Int fd);
1560
1577
1561
extern Bool VG_(pre_syscall) ( ThreadId tid );
1578
extern Bool VG_(pre_syscall) ( ThreadId tid );
1562
extern void VG_(post_syscall)( ThreadId tid );
1579
extern void VG_(post_syscall)( ThreadId tid, Bool restart );
1563
extern void VG_(restart_syscall) ( ThreadId tid );
1580
extern void VG_(restart_syscall) ( ThreadId tid );
1564
1581
1565
extern Bool VG_(is_kerror) ( Int res );
1582
extern Bool VG_(is_kerror) ( Int res );
Lines 1603-1619 Link Here
1603
			Int *child_tid, Int *parent_tid);
1620
			Int *child_tid, Int *parent_tid);
1604
1621
1605
/* ---------------------------------------------------------------------
1622
/* ---------------------------------------------------------------------
1606
   Exports of vg_startup.S
1607
   ------------------------------------------------------------------ */
1608
1609
extern void VG_(switch_to_real_CPU) ( void );
1610
1611
extern void VG_(swizzle_esp_then_start_GDB) ( Addr m_eip_at_error,
1612
                                              Addr m_esp_at_error,
1613
                                              Addr m_ebp_at_error );
1614
1615
1616
/* ---------------------------------------------------------------------
1617
   Exports of vg_dispatch.S
1623
   Exports of vg_dispatch.S
1618
   ------------------------------------------------------------------ */
1624
   ------------------------------------------------------------------ */
1619
1625
Lines 1650-1655 Link Here
1650
1656
1651
extern void VG_(helper_CLC);
1657
extern void VG_(helper_CLC);
1652
extern void VG_(helper_STC);
1658
extern void VG_(helper_STC);
1659
extern void VG_(helper_CMC);
1653
1660
1654
extern void VG_(helper_shldl);
1661
extern void VG_(helper_shldl);
1655
extern void VG_(helper_shldw);
1662
extern void VG_(helper_shldw);
Lines 1662-1691 Link Here
1662
extern void VG_(helper_RDTSC);
1669
extern void VG_(helper_RDTSC);
1663
extern void VG_(helper_CPUID);
1670
extern void VG_(helper_CPUID);
1664
1671
1665
extern void VG_(helper_bsf);
1672
extern void VG_(helper_bsfw);
1666
extern void VG_(helper_bsr);
1673
extern void VG_(helper_bsfl);
1674
extern void VG_(helper_bsrw);
1675
extern void VG_(helper_bsrl);
1667
1676
1668
extern void VG_(helper_fstsw_AX);
1677
extern void VG_(helper_fstsw_AX);
1669
extern void VG_(helper_SAHF);
1678
extern void VG_(helper_SAHF);
1670
extern void VG_(helper_LAHF);
1679
extern void VG_(helper_LAHF);
1671
extern void VG_(helper_DAS);
1680
extern void VG_(helper_DAS);
1672
extern void VG_(helper_DAA);
1681
extern void VG_(helper_DAA);
1682
extern void VG_(helper_AAS);
1683
extern void VG_(helper_AAA);
1684
extern void VG_(helper_AAD);
1685
extern void VG_(helper_AAM);
1686
1687
extern void VG_(helper_cmpxchg8b);
1673
1688
1674
extern void VG_(helper_undefined_instruction);
1689
extern void VG_(helper_undefined_instruction);
1675
1690
1676
/* NOT A FUNCTION; this is a bogus RETURN ADDRESS. */
1691
/* Information about trampoline code (for signal return and syscalls) */
1677
extern void VG_(signalreturn_bogusRA)( void );
1692
extern const Char VG_(trampoline_code_start);
1693
extern const Int  VG_(trampoline_code_length);
1694
extern const Int  VG_(tramp_sigreturn_offset);
1695
extern const Int  VG_(tramp_syscall_offset);
1678
1696
1679
/* ---------------------------------------------------------------------
1697
/* ---------------------------------------------------------------------
1680
   Things relating to the used skin
1698
   Things relating to the used skin
1681
   ------------------------------------------------------------------ */
1699
   ------------------------------------------------------------------ */
1682
1700
1683
#define VG_TRACK(fn, args...)          \
1701
#define VG_TRACK(fn, args...) 			\
1684
   do {                                \
1702
   do {						\
1685
      if (VG_(track_events).fn)        \
1703
      if (VG_(defined_##fn)())			\
1686
         VG_(track_events).fn(args);   \
1704
	 SK_(fn)(args);				\
1687
   } while (0)
1705
   } while(0)
1688
1706
1707
__attribute__ ((noreturn))
1708
extern void VG_(missing_tool_func) ( const Char* fn );
1689
1709
1690
/* ---------------------------------------------------------------------
1710
/* ---------------------------------------------------------------------
1691
   The state of the simulated CPU.
1711
   The state of the simulated CPU.
Lines 1757-1762 Link Here
1757
/* This thread's LDT pointer. */
1777
/* This thread's LDT pointer. */
1758
extern Int VGOFF_(ldt);
1778
extern Int VGOFF_(ldt);
1759
1779
1780
/* This thread's TLS pointer. */
1781
extern Int VGOFF_(tls);
1782
1760
/* Nb: Most helper offsets are in include/vg_skin.h, for use by skins */
1783
/* Nb: Most helper offsets are in include/vg_skin.h, for use by skins */
1761
1784
1762
extern Int VGOFF_(helper_undefined_instruction);
1785
extern Int VGOFF_(helper_undefined_instruction);
(-)valgrind-2.1.0/coregrind/vg_instrument.c (-1 / +1 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Nicholas Nethercote
11
   Copyright (C) 2000-2004 Nicholas Nethercote
12
      njn25@cam.ac.uk
12
      njn25@cam.ac.uk
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/coregrind/vg_intercept.c (-123 / +55 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 33-170 Link Here
33
/* ---------------------------------------------------------------------
33
/* ---------------------------------------------------------------------
34
   ALL THE CODE IN THIS FILE RUNS ON THE SIMULATED CPU.  It is
34
   ALL THE CODE IN THIS FILE RUNS ON THE SIMULATED CPU.  It is
35
   intended for various reasons as drop-in replacements for libc
35
   intended for various reasons as drop-in replacements for libc
36
   functions.  These functions have global visibility (obviously) and
36
   functions.  These functions are not called directly - they're the
37
   have no prototypes in vg_include.h, since they are not intended to
37
   targets of code redirection.  They're named the same as the library
38
   be called from within Valgrind.
38
   functions they replace so that messages printing their names are
39
   sensible, but the we don't really require the dynamic linker to find
40
   them.
39
   ------------------------------------------------------------------ */
41
   ------------------------------------------------------------------ */
40
42
41
/* General idea (2003-Apr-26) is that master implementations of
42
   selected functions are done as VGR_(fnname).  Then we route
43
   all calls to the master, both here and in vg_libpthread.c.
44
   This means we no longer have to rely on the semantics of weak
45
   symbols, which seems to have changed in glibc >= 2.3.2 in such
46
   a way as to make the previous interception scheme stop working.
47
*/
48
49
#include "valgrind.h"
43
#include "valgrind.h"
50
#include "vg_include.h"
44
#include "vg_include.h"
51
#include "vg_kerneliface.h"
45
#include <unistd.h>
52
46
#include <signal.h>
53
/* This has some nasty duplication of stuff from vg_libpthread.c */
54
55
#include <errno.h>
56
#include <sys/types.h>
57
#include <stdio.h>
58
#include <sys/ipc.h>
59
#include <sys/msg.h>
60
#ifdef KERNEL_2_6
61
#include <linux/compiler.h>
62
#endif
63
#include <asm/ipc.h>		/* for ipc_kludge */
64
#include <sys/poll.h>
65
#include <sys/socket.h>
66
#include <sys/uio.h>
67
#ifdef HAVE_SYS_TIME_H
68
#include <sys/time.h>
69
#endif
70
71
/* --------------------------------------------------------------- */
72
73
/* Just start up Valgrind if it's not already going.  VG_(startup)()
74
   detects and ignores second and subsequent calls. */
75
47
76
/* We need this guy -- it's in valgrind.so. */
48
static void init(void) __attribute__((constructor));
77
extern void VG_(startup) ( void );
49
static int init_done;
78
50
79
static __inline__
51
int raise(int sig)
80
void ensure_valgrind ( char* caller )
81
{
52
{
82
   VG_(startup)();
53
   if (!init_done)
83
}
54
      init();
84
55
85
static __inline__
56
   return kill(getpid(), sig);
86
int is_kerror ( int res )
87
{
88
   if (res >= -4095 && res <= -1)
89
      return 1;
90
   else
91
      return 0;
92
}
57
}
58
int __libc_raise(int) __attribute__((alias("raise"), visibility("protected")));
59
int __GI_raise(int) __attribute__((alias("raise"), visibility("protected")));
93
60
94
/* --------------------------------------------------------------- */
61
/* Don't alias, so there's no chance that "gsignal" will appear in a
95
62
   message instead of "raise" */
96
/* Extract from Valgrind the value of VG_(clo_trace_pthread_level).
63
int gsignal(int sig)
97
   Returns 0 (none) if not running on Valgrind. */
98
static
99
int get_pt_trace_level ( void )
100
{
64
{
101
   int res;
65
   return raise(sig);
102
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
103
                           VG_USERREQ__GET_PTHREAD_TRACE_LEVEL,
104
                           0, 0, 0, 0);
105
   return res;
106
}
66
}
107
67
108
static 
109
void cat_n_send ( char* pre, char* msg )
110
{
111
   char  buf[1000];
112
   if (get_pt_trace_level() >= 0) {
113
      snprintf(buf, sizeof(buf), "%s%s", pre, msg );
114
      buf[sizeof(buf)-1] = '\0';
115
      VALGRIND_NON_SIMD_CALL2(VG_(message), Vg_UserMsg, buf);
116
   }
117
}
118
119
static
120
void my_exit ( int arg )
121
{
122
   VG_(do_syscall)(__NR_exit_group, arg);
123
   VG_(do_syscall)(__NR_exit, arg);
124
}
125
126
static
127
void my_assert_fail ( const Char* expr, const Char* file, Int line, const Char* fn )
128
{
129
   char buf[1000];
130
   static Bool entered = False;
131
   if (entered) 
132
      my_exit(2);
133
   entered = True;
134
   sprintf(buf, "\n%s: %s:%d (%s): Assertion `%s' failed.\n",
135
                "valgrind", file, line, fn, expr );
136
   cat_n_send ( "", buf );
137
   sprintf(buf, "Please report this bug at: %s\n\n", VG_BUGS_TO);
138
   my_exit(1);
139
}
140
141
#define MY__STRING(__str)  #__str
142
143
#define my_assert(expr)                                               \
144
  ((void) ((expr) ? 0 :						      \
145
	   (my_assert_fail  (MY__STRING(expr),			      \
146
			      __FILE__, __LINE__,                     \
147
                              __PRETTY_FUNCTION__), 0)))
148
149
/* --------------------------------------------------------------- */
150
151
static __inline__
152
void __my_pthread_testcancel(void)
153
{
154
   int res;
155
   ensure_valgrind("__my_pthread_testcancel");
156
   VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
157
                           VG_USERREQ__TESTCANCEL,
158
                           0, 0, 0, 0);
159
   my_assert(res == 0);
160
}
161
162
163
/* ---------------------------------------------------------------------
68
/* ---------------------------------------------------------------------
164
   Hook for running __libc_freeres once the program exits.
69
   Hook for running __libc_freeres once the program exits.
165
   ------------------------------------------------------------------ */
70
   ------------------------------------------------------------------ */
166
71
167
void VG_(__libc_freeres_wrapper)( void )
72
static void VGINJ_(__libc_freeres_wrapper)( void )
168
{
73
{
169
   int res;
74
   int res;
170
#ifndef __UCLIBC__
75
#ifndef __UCLIBC__
Lines 174-191 Link Here
174
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
79
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
175
                           VG_USERREQ__LIBC_FREERES_DONE, 0, 0, 0, 0);
80
                           VG_USERREQ__LIBC_FREERES_DONE, 0, 0, 0, 0);
176
   /*NOTREACHED*/
81
   /*NOTREACHED*/
177
   vg_assert(12345+54321 == 999999);
82
   *(int *)0 = 'x';
178
}
83
}
179
84
180
/* ---------------------------------------------------------------------
85
static const struct {
181
   Useful for skins that want to replace certain functions
86
   const char *fromlib, *fromsym;
182
   ------------------------------------------------------------------ */
87
   const void *toaddr;
88
} redirects[] = {
89
#define _S(x)	#x
90
#define S(x)	_S(x)
91
#define E(l, pfx, s)	{ "soname:" l, pfx #s, (void *)s }
92
#define R(l, s)						\
93
   E(l, "", s),						\
94
   E(l, "__", s),					\
95
   E(l, "__libc_", s),					\
96
   E(l, "__GI_", s)
97
98
   R("libc.so.6", raise),
99
   R("libc.so.6", gsignal),
100
#undef R
101
};
183
102
184
Bool VG_(is_running_on_simd_CPU)(void)
103
static void init(void)
185
{
104
{
186
   return VG_(running_on_simd_CPU);
105
   int i;
187
}
106
   int res;
188
107
108
   if (init_done)
109
      return;
110
   init_done = 1;
111
112
   VALGRIND_MAGIC_SEQUENCE(res, -1, VG_USERREQ__REGISTER_LIBC_FREERES,
113
			   (Addr)VGINJ_(__libc_freeres_wrapper), 0, 0, 0);
114
115
   for(i = 0; i < sizeof(redirects)/sizeof(*redirects); i++) {
116
      VALGRIND_MAGIC_SEQUENCE(res, -1, VG_USERREQ__REGISTER_REDIRECT_ADDR,
117
			      redirects[i].fromlib, redirects[i].fromsym,
118
			      redirects[i].toaddr, 0);
119
   }
120
}
189
121
190
122
191
/*--------------------------------------------------------------------*/
123
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/vg_ldt.c (-25 / +121 lines)
Lines 7-13 Link Here
7
   This file is part of Valgrind, an extensible x86 protected-mode
7
   This file is part of Valgrind, an extensible x86 protected-mode
8
   emulator for monitoring program execution on x86-Unixes.
8
   emulator for monitoring program execution on x86-Unixes.
9
9
10
   Copyright (C) 2000-2003 Julian Seward 
10
   Copyright (C) 2000-2004 Julian Seward 
11
      jseward@acm.org
11
      jseward@acm.org
12
12
13
   This program is free software; you can redistribute it and/or
13
   This program is free software; you can redistribute it and/or
Lines 121-126 Link Here
121
121
122
122
123
123
124
/* Clear a TLS array. */
125
void VG_(clear_TLS_for_thread) ( VgLdtEntry* tls )
126
{
127
   VgLdtEntry* tlsp;
128
129
   if (0)
130
      VG_(printf)("clear_TLS_for_thread\n" );
131
132
   for (tlsp = tls; tlsp < tls + VKI_GDT_TLS_ENTRIES; tlsp++) {
133
      tlsp->LdtEnt.Words.word1 = 0;
134
      tlsp->LdtEnt.Words.word2 = 0;
135
   }
136
137
   return;
138
}
139
140
141
124
/* Fish the base field out of an VgLdtEntry.  This is the only part we
142
/* Fish the base field out of an VgLdtEntry.  This is the only part we
125
   are particularly interested in. */
143
   are particularly interested in. */
126
144
Lines 151-159 Link Here
151
*/
169
*/
152
Addr VG_(do_useseg) ( UInt seg_selector, Addr virtual_addr )
170
Addr VG_(do_useseg) ( UInt seg_selector, Addr virtual_addr )
153
{
171
{
154
   Addr        base;
172
   UInt table;
155
   UInt        limit;
173
   Addr base;
156
   VgLdtEntry* the_ldt;
174
   UInt limit;
157
175
158
   if (0) 
176
   if (0) 
159
      VG_(printf)("do_useseg: seg_selector = %p, vaddr = %p\n", 
177
      VG_(printf)("do_useseg: seg_selector = %p, vaddr = %p\n", 
Lines 161-191 Link Here
161
179
162
   seg_selector &= 0x0000FFFF;
180
   seg_selector &= 0x0000FFFF;
163
  
181
  
164
   /* Sanity check the segment selector.  Ensure that TI=1 (LDT) and
182
   /* Sanity check the segment selector.  Ensure that RPL=11b (least
165
      that RPL=11b (least privilege).  These form the bottom 3 bits
183
      privilege).  This forms the bottom 2 bits of the selector. */
166
      of the selector. */
184
   vg_assert((seg_selector & 3) == 3);
167
   vg_assert((seg_selector & 7) == 7);
185
186
   /* Extract the table number */
187
   table = (seg_selector & 4) >> 2;
168
188
169
   /* convert it onto a table index */
189
   /* Convert the segment selector onto a table index */
170
   seg_selector >>= 3;
190
   seg_selector >>= 3;
171
   vg_assert(seg_selector >= 0 && seg_selector < 8192);
172
191
173
   /* Come up with a suitable LDT entry.  We look at the thread's LDT,
192
   if (table == 0) {
174
      which is pointed to by a VG_(baseBlock) entry.  If null, we will
193
      VgLdtEntry* the_tls;
175
      use an implied zero-entry -- although this usually implies the
194
176
      program is in deep trouble, since it is using LDT entries which
195
      vg_assert(seg_selector >= VKI_GDT_TLS_MIN && seg_selector < VKI_GDT_TLS_MAX);
177
      it probably hasn't set up. */
196
178
   the_ldt = (VgLdtEntry*)VG_(baseBlock)[VGOFF_(ldt)];
197
      /* Come up with a suitable GDT entry.  We look at the thread's TLS
179
   if (the_ldt == NULL) {
198
	 array, which is pointed to by a VG_(baseBlock) entry. */
180
      base = 0;
199
      the_tls = (VgLdtEntry*)VG_(baseBlock)[VGOFF_(tls)];
181
      limit = 0;
200
      base = (Addr)wine_ldt_get_base ( &the_tls[seg_selector-VKI_GDT_TLS_MIN] );
182
      VG_(message)(
201
      limit = (UInt)wine_ldt_get_limit ( &the_tls[seg_selector-VKI_GDT_TLS_MIN] );
183
         Vg_UserMsg,
184
         "Warning: segment-override prefix encountered, but thread has no LDT"
185
      );
186
   } else {
202
   } else {
187
      base = (Addr)wine_ldt_get_base ( &the_ldt[seg_selector] );
203
      VgLdtEntry* the_ldt;
188
      limit = (UInt)wine_ldt_get_limit ( &the_ldt[seg_selector] );
204
205
      vg_assert(seg_selector >= 0 && seg_selector < 8192);
206
207
      /* Come up with a suitable LDT entry.  We look at the thread's LDT,
208
	 which is pointed to by a VG_(baseBlock) entry.  If null, we will
209
	 use an implied zero-entry -- although this usually implies the
210
	 program is in deep trouble, since it is using LDT entries which
211
	 it probably hasn't set up. */
212
      the_ldt = (VgLdtEntry*)VG_(baseBlock)[VGOFF_(ldt)];
213
      if (the_ldt == NULL) {
214
	 base = 0;
215
	 limit = 0;
216
	 VG_(message)(
217
            Vg_UserMsg,
218
	    "Warning: segment-override prefix encountered, but thread has no LDT"
219
	 );
220
      } else {
221
	 base = (Addr)wine_ldt_get_base ( &the_ldt[seg_selector] );
222
	 limit = (UInt)wine_ldt_get_limit ( &the_ldt[seg_selector] );
223
      }
189
   }
224
   }
190
225
191
   /* Note, this check is just slightly too slack.  Really it should
226
   /* Note, this check is just slightly too slack.  Really it should
Lines 199-204 Link Here
199
      );
234
      );
200
   }
235
   }
201
236
237
   if (0) 
238
      VG_(printf)("do_useseg: base = %p, addr = %p\n", 
239
                  base, base + virtual_addr);
240
202
   return base + virtual_addr;
241
   return base + virtual_addr;
203
}
242
}
204
243
Lines 367-372 Link Here
367
}
406
}
368
407
369
408
409
Int VG_(sys_set_thread_area) ( ThreadId tid,
410
                               struct vki_modify_ldt_ldt_s* info )
411
{
412
   Int idx = info->entry_number;
413
414
   if (idx == -1) {
415
      for (idx = 0; idx < VKI_GDT_TLS_ENTRIES; idx++) {
416
         VgLdtEntry* tls = VG_(threads)[tid].tls + idx;
417
418
         if (tls->LdtEnt.Words.word1 == 0 && tls->LdtEnt.Words.word2 == 0)
419
            break;
420
      }
421
422
      if (idx == VKI_GDT_TLS_ENTRIES)
423
         return -VKI_ESRCH;
424
   } else if (idx < VKI_GDT_TLS_MIN || idx > VKI_GDT_TLS_MAX) {
425
      return -VKI_EINVAL;
426
   } else {
427
      idx = info->entry_number - VKI_GDT_TLS_MIN;
428
   }
429
430
   translate_to_hw_format(info, VG_(threads)[tid].tls + idx, 0);
431
432
   info->entry_number = idx + VKI_GDT_TLS_MIN;
433
434
   return 0;
435
}
436
437
438
Int VG_(sys_get_thread_area) ( ThreadId tid,
439
                               struct vki_modify_ldt_ldt_s* info )
440
{
441
   Int idx = info->entry_number;
442
   VgLdtEntry* tls;
443
444
   if (idx < VKI_GDT_TLS_MIN || idx > VKI_GDT_TLS_MAX)
445
      return -VKI_EINVAL;
446
447
   tls = VG_(threads)[tid].tls + idx - VKI_GDT_TLS_MIN;
448
449
   info->base_addr = ( tls->LdtEnt.Bits.BaseHi << 24 ) |
450
                     ( tls->LdtEnt.Bits.BaseMid << 16 ) |
451
                     tls->LdtEnt.Bits.BaseLow;
452
   info->limit = ( tls->LdtEnt.Bits.LimitHi << 16 ) |
453
                   tls->LdtEnt.Bits.LimitLow;
454
   info->seg_32bit = tls->LdtEnt.Bits.Default_Big;
455
   info->contents = ( tls->LdtEnt.Bits.Type >> 2 ) & 0x3;
456
   info->read_exec_only = ( tls->LdtEnt.Bits.Type & 0x1 ) ^ 0x1;
457
   info->limit_in_pages = tls->LdtEnt.Bits.Granularity;
458
   info->seg_not_present = tls->LdtEnt.Bits.Pres ^ 0x1;
459
   info->useable = tls->LdtEnt.Bits.Sys;
460
   info->reserved = 0;
461
462
   return 0;
463
}
464
465
370
/*--------------------------------------------------------------------*/
466
/*--------------------------------------------------------------------*/
371
/*--- end                                                 vg_ldt.c ---*/
467
/*--- end                                                 vg_ldt.c ---*/
372
/*--------------------------------------------------------------------*/
468
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/vg_libpthread.c (-76 / +292 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 60-65 Link Here
60
#include <pthread.h>
60
#include <pthread.h>
61
#undef __USE_UNIX98
61
#undef __USE_UNIX98
62
62
63
#define __USE_GNU
64
#include <dlfcn.h>
65
#undef __USE_GNU
66
63
#include <unistd.h>
67
#include <unistd.h>
64
#include <string.h>
68
#include <string.h>
65
#include <sys/time.h>
69
#include <sys/time.h>
Lines 68-73 Link Here
68
#include <stdio.h>
72
#include <stdio.h>
69
#include <errno.h>
73
#include <errno.h>
70
74
75
#include <stdlib.h>
71
76
72
# define strong_alias(name, aliasname) \
77
# define strong_alias(name, aliasname) \
73
  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
78
  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
Lines 106-111 Link Here
106
#endif
111
#endif
107
112
108
static
113
static
114
void init_thread_specific_state ( void );
115
116
static
109
void init_libc_tsd_keys ( void );
117
void init_libc_tsd_keys ( void );
110
118
111
119
Lines 128-167 Link Here
128
   return res;
136
   return res;
129
}
137
}
130
138
131
static
139
/* Don't do anything if we're not under Valgrind */
132
void my_exit ( int arg )
133
{
134
   VG_(do_syscall)(__NR_exit, arg);
135
   /*NOTREACHED*/
136
}
137
138
/* Apparently unused. 
139
static
140
void my_write ( int fd, const void *buf, int count )
141
{
142
   VG_(do_syscall)(__NR_write, fd, (int)buf, count );
143
}
144
*/
145
146
/* We need this guy -- it's in valgrind.so. */
147
extern void VG_(startup) ( void );
148
149
150
/* Just start up Valgrind if it's not already going.  VG_(startup)()
151
   detects and ignores second and subsequent calls. */
152
static __inline__
140
static __inline__
153
void ensure_valgrind ( char* caller )
141
void ensure_valgrind ( char* caller )
154
{
142
{
155
   VG_(startup)();
143
   if (!RUNNING_ON_VALGRIND) {
144
      const char msg[] = "Warning: this libpthread.so should only be run with Valgrind\n";
145
      VG_(do_syscall)(__NR_write, 2, msg, sizeof(msg)-1);
146
      VG_(do_syscall)(__NR_exit, 1);
147
   }
156
}
148
}
157
149
158
/* While we're at it ... hook our own startup function into this
150
/* While we're at it ... hook our own startup function into this
159
   game. */
151
   game. */
160
__asm__ (
161
   ".section .init\n"
162
   "\tcall vgPlain_startup"
163
);
164
165
152
166
static
153
static
167
__attribute__((noreturn))
154
__attribute__((noreturn))
Lines 173-180 Link Here
173
   strcat(buf, "\nPlease report this bug at: ");
160
   strcat(buf, "\nPlease report this bug at: ");
174
   strcat(buf, VG_BUGS_TO);
161
   strcat(buf, VG_BUGS_TO);
175
   strcat(buf, "\n\n");
162
   strcat(buf, "\n\n");
176
   VALGRIND_NON_SIMD_CALL2(VG_(message), Vg_UserMsg, buf);
163
   VALGRIND_INTERNAL_PRINTF(buf);
177
   my_exit(1);
164
   _exit(1);
178
   /* We have to persuade gcc into believing this doesn't return. */
165
   /* We have to persuade gcc into believing this doesn't return. */
179
   while (1) { };
166
   while (1) { };
180
}
167
}
Lines 186-192 Link Here
186
   if (get_pt_trace_level() >= 0) {
173
   if (get_pt_trace_level() >= 0) {
187
      snprintf(buf, sizeof(buf), "%s%s%s", s1, s2, s3);
174
      snprintf(buf, sizeof(buf), "%s%s%s", s1, s2, s3);
188
      buf[sizeof(buf)-1] = '\0';
175
      buf[sizeof(buf)-1] = '\0';
189
      VALGRIND_NON_SIMD_CALL2(VG_(message), Vg_UserMsg, buf);
176
      VALGRIND_INTERNAL_PRINTF(buf);
190
   }
177
   }
191
}
178
}
192
179
Lines 223-235 Link Here
223
   char buf[1000];
210
   char buf[1000];
224
   static Bool entered = False;
211
   static Bool entered = False;
225
   if (entered) 
212
   if (entered) 
226
      my_exit(2);
213
      _exit(2);
227
   entered = True;
214
   entered = True;
228
   sprintf(buf, "\n%s: %s:%d (%s): Assertion `%s' failed.\n",
215
   sprintf(buf, "\n%s: %s:%d (%s): Assertion `%s' failed.\n",
229
                "valgrind", file, line, fn, expr );
216
                "valgrind", file, line, fn, expr );
230
   cat_n_send ( "", buf, "" );
217
   cat_n_send ( "", buf, "" );
231
   sprintf(buf, "Please report this bug at: %s\n\n", VG_BUGS_TO);
218
   sprintf(buf, "Please report this bug at: %s\n\n", VG_BUGS_TO);
232
   my_exit(1);
219
   cat_n_send ( "", buf, "" );
220
   _exit(1);
233
}
221
}
234
222
235
#define MY__STRING(__str)  #__str
223
#define MY__STRING(__str)  #__str
Lines 243-252 Link Here
243
static
231
static
244
void my_free ( void* ptr )
232
void my_free ( void* ptr )
245
{
233
{
234
#if 0
246
   int res;
235
   int res;
247
   VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
236
   VALGRIND_MAGIC_SEQUENCE(res, (-1) /* default */,
248
                           VG_USERREQ__FREE, ptr, 0, 0, 0);
237
                           VG_USERREQ__FREE, ptr, 0, 0, 0);
249
   my_assert(res == 0);
238
   my_assert(res == 0);
239
#else
240
   free(ptr);
241
#endif
250
}
242
}
251
243
252
244
Lines 254-261 Link Here
254
void* my_malloc ( int nbytes )
246
void* my_malloc ( int nbytes )
255
{
247
{
256
   void* res;
248
   void* res;
249
#if 0
257
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
250
   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
258
                           VG_USERREQ__MALLOC, nbytes, 0, 0, 0);
251
                           VG_USERREQ__MALLOC, nbytes, 0, 0, 0);
252
#else
253
   res = malloc(nbytes);
254
#endif
259
   my_assert(res != (void*)0);
255
   my_assert(res != (void*)0);
260
   return res;
256
   return res;
261
}
257
}
Lines 534-539 Link Here
534
   and for clearing up afterwards.
530
   and for clearing up afterwards.
535
   ------------------------------------------------ */
531
   ------------------------------------------------ */
536
532
533
typedef void *(*__attribute__ ((regparm (3), stdcall)) allocate_tls_t) (void *result);
534
typedef void (*__attribute__ ((regparm (3), stdcall)) deallocate_tls_t) (void *tcb, int dealloc_tcb);
535
536
static allocate_tls_t allocate_tls = NULL;
537
static deallocate_tls_t deallocate_tls = NULL;
538
539
static
540
int get_gs()
541
{
542
   int gs;
543
544
   asm volatile ("movw %%gs, %w0" : "=q" (gs));
545
546
   return gs & 0xffff;
547
}
548
549
static
550
void set_gs( int gs )
551
{
552
   asm volatile ("movw %w0, %%gs" :: "q" (gs));
553
}
554
555
static
556
void *get_tcb()
557
{
558
   void *tcb;
559
560
   asm volatile ("movl %%gs:0, %0" : "=r" (tcb));
561
562
   return tcb;
563
}
564
537
/* All exiting threads eventually pass through here, bearing the
565
/* All exiting threads eventually pass through here, bearing the
538
   return value, or PTHREAD_CANCELED, in ret_val. */
566
   return value, or PTHREAD_CANCELED, in ret_val. */
539
static
567
static
Lines 580-586 Link Here
580
   my_assert(specifics_ptr != (void**)1); /* 1 means invalid thread */
608
   my_assert(specifics_ptr != (void**)1); /* 1 means invalid thread */
581
   if (specifics_ptr != NULL)
609
   if (specifics_ptr != NULL)
582
      my_free(specifics_ptr);
610
      my_free(specifics_ptr);
583
611
   
612
   /* Free up any TLS data */
613
   if ((get_gs() & 7) == 3 && pthread_self() > 1) {
614
      my_assert(deallocate_tls != NULL);
615
      deallocate_tls(get_tcb(), 1);
616
   }
617
   
584
   /* Decide on my final disposition. */
618
   /* Decide on my final disposition. */
585
   VALGRIND_MAGIC_SEQUENCE(detached, (-1) /* default */,
619
   VALGRIND_MAGIC_SEQUENCE(detached, (-1) /* default */,
586
                           VG_USERREQ__SET_OR_GET_DETACH, 
620
                           VG_USERREQ__SET_OR_GET_DETACH, 
Lines 611-622 Link Here
611
   objects which might be on the parent's stack.  */
645
   objects which might be on the parent's stack.  */
612
typedef
646
typedef
613
   struct {
647
   struct {
614
      int   attr__detachstate;
648
      int           attr__detachstate;
615
      void* (*root_fn) ( void* );
649
      void*         tls_data;
616
      void* arg;
650
      int           tls_segment;
651
      unsigned long sysinfo;
652
      void*         (*root_fn) ( void* );
653
      void*         arg;
617
   }
654
   }
618
   NewThreadInfo;
655
   NewThreadInfo;
619
656
657
/* Struct used to describe a TDB header, copied from glibc. */
658
typedef
659
   struct {
660
      void *tcb;
661
      void *dtv;
662
      void *self;
663
      int multiple_threads;
664
      unsigned long sysinfo;
665
   }
666
   tcbhead_t;
620
667
621
/* This is passed to the VG_USERREQ__APPLY_IN_NEW_THREAD and so must
668
/* This is passed to the VG_USERREQ__APPLY_IN_NEW_THREAD and so must
622
   not return.  Note that this runs in the new thread, not the
669
   not return.  Note that this runs in the new thread, not the
Lines 625-639 Link Here
625
__attribute__((noreturn))
672
__attribute__((noreturn))
626
void thread_wrapper ( NewThreadInfo* info )
673
void thread_wrapper ( NewThreadInfo* info )
627
{
674
{
628
   int   attr__detachstate;
675
   int           attr__detachstate;
629
   void* (*root_fn) ( void* );
676
   void*         tls_data;
630
   void* arg;
677
   int           tls_segment;
631
   void* ret_val;
678
   unsigned long sysinfo;
679
   void*         (*root_fn) ( void* );
680
   void*         arg;
681
   void*         ret_val;
632
682
633
   attr__detachstate = info->attr__detachstate;
683
   attr__detachstate = info->attr__detachstate;
684
   tls_data          = info->tls_data;
685
   tls_segment       = info->tls_segment;
686
   sysinfo           = info->sysinfo;
634
   root_fn           = info->root_fn;
687
   root_fn           = info->root_fn;
635
   arg               = info->arg;
688
   arg               = info->arg;
636
689
690
   if (tls_data) {
691
      tcbhead_t *tcb = tls_data;
692
      struct vki_modify_ldt_ldt_s ldt_info;
693
694
      /* Fill in the TCB header */
695
      tcb->tcb = tcb;
696
      tcb->self = tcb;
697
      tcb->multiple_threads = 1;
698
      tcb->sysinfo = sysinfo;
699
      
700
      /* Fill in an LDT descriptor */
701
      ldt_info.entry_number = tls_segment;
702
      ldt_info.base_addr = (unsigned long)tls_data;
703
      ldt_info.limit = 0xfffff;
704
      ldt_info.seg_32bit = 1;
705
      ldt_info.contents = 0;
706
      ldt_info.read_exec_only = 0;
707
      ldt_info.limit_in_pages = 1;
708
      ldt_info.seg_not_present = 0;
709
      ldt_info.useable = 1;
710
      ldt_info.reserved = 0;
711
      
712
      /* Install the thread area */
713
      VG_(do_syscall)(__NR_set_thread_area, &ldt_info);
714
      
715
      /* Setup the GS segment register */
716
      set_gs(ldt_info.entry_number * 8 + 3);
717
   }
718
637
   /* Free up the arg block that pthread_create malloced. */
719
   /* Free up the arg block that pthread_create malloced. */
638
   my_free(info);
720
   my_free(info);
639
721
Lines 644-649 Link Here
644
   if (attr__detachstate == PTHREAD_CREATE_DETACHED)
726
   if (attr__detachstate == PTHREAD_CREATE_DETACHED)
645
      pthread_detach(pthread_self());
727
      pthread_detach(pthread_self());
646
728
729
   /* Initialise thread specific state */
730
   init_thread_specific_state();
731
647
#  ifdef GLIBC_2_3
732
#  ifdef GLIBC_2_3
648
   /* Set this thread's locale to the global (default) locale.  A hack
733
   /* Set this thread's locale to the global (default) locale.  A hack
649
      in support of glibc-2.3.  This does the biz for the all new
734
      in support of glibc-2.3.  This does the biz for the all new
Lines 699-704 Link Here
699
{
784
{
700
   int            tid_child;
785
   int            tid_child;
701
   NewThreadInfo* info;
786
   NewThreadInfo* info;
787
   int            gs;
702
788
703
   ensure_valgrind("pthread_create");
789
   ensure_valgrind("pthread_create");
704
790
Lines 716-721 Link Here
716
   else 
802
   else 
717
      info->attr__detachstate = PTHREAD_CREATE_JOINABLE;
803
      info->attr__detachstate = PTHREAD_CREATE_JOINABLE;
718
804
805
   gs = get_gs();
806
807
   if ((gs & 7) == 3) {
808
      tcbhead_t *tcb = get_tcb();
809
810
      if (allocate_tls == NULL || deallocate_tls == NULL) {
811
         allocate_tls = (allocate_tls_t)dlsym(RTLD_DEFAULT, "_dl_allocate_tls");
812
         deallocate_tls = (deallocate_tls_t)dlsym(RTLD_DEFAULT, "_dl_deallocate_tls");
813
      }
814
815
      my_assert(allocate_tls != NULL);
816
      
817
      info->tls_data = allocate_tls(NULL);
818
      info->tls_segment = gs >> 3;
819
      info->sysinfo = tcb->sysinfo;
820
821
      tcb->multiple_threads = 1;
822
   } else {
823
      info->tls_data = NULL;
824
      info->tls_segment = -1;
825
      info->sysinfo = 0;
826
   }
827
719
   info->root_fn = __start_routine;
828
   info->root_fn = __start_routine;
720
   info->arg     = __arg;
829
   info->arg     = __arg;
721
   VALGRIND_MAGIC_SEQUENCE(tid_child, VG_INVALID_THREADID /* default */,
830
   VALGRIND_MAGIC_SEQUENCE(tid_child, VG_INVALID_THREADID /* default */,
Lines 1033-1039 Link Here
1033
}
1142
}
1034
1143
1035
int pthread_cond_init( pthread_cond_t *cond,
1144
int pthread_cond_init( pthread_cond_t *cond,
1036
                       const pthread_condattr_t *cond_attr)
1145
		       const pthread_condattr_t *cond_attr)
1037
{
1146
{
1038
   cond->__c_waiting = (_pthread_descr)VG_INVALID_THREADID;
1147
   cond->__c_waiting = (_pthread_descr)VG_INVALID_THREADID;
1039
   return 0;
1148
   return 0;
Lines 1278-1291 Link Here
1278
int sigwait ( const sigset_t* set, int* sig )
1387
int sigwait ( const sigset_t* set, int* sig )
1279
{
1388
{
1280
   int res;
1389
   int res;
1281
   vki_ksiginfo_t si;
1390
   siginfo_t si;
1282
   
1391
   
1283
   __my_pthread_testcancel();
1392
   __my_pthread_testcancel();
1284
1393
1285
   /* As with pthread_sigmask we deliberately confuse sigset_t with
1286
      vki_ksigset_t. */
1287
   si.si_signo = 0;
1394
   si.si_signo = 0;
1288
   res = VG_(ksigtimedwait)((const vki_ksigset_t *)set, &si, NULL);
1395
   res = sigtimedwait(set, &si, NULL);
1289
   *sig = si.si_signo;
1396
   *sig = si.si_signo;
1290
1397
1291
   return 0;			/* always returns 0 */
1398
   return 0;			/* always returns 0 */
Lines 1632-1661 Link Here
1632
   ------------------------------------------------ */
1739
   ------------------------------------------------ */
1633
1740
1634
#include <resolv.h>
1741
#include <resolv.h>
1635
static int thread_specific_errno[VG_N_THREADS];
1636
static int thread_specific_h_errno[VG_N_THREADS];
1637
static struct __res_state
1638
           thread_specific_res_state[VG_N_THREADS];
1639
1742
1640
#undef errno
1743
typedef
1641
extern int errno;
1744
   struct {
1745
     int                *errno_ptr;
1746
     int                *h_errno_ptr;
1747
     struct __res_state *res_state_ptr;
1748
     int                errno_data;
1749
     int                h_errno_data;
1750
     struct __res_state res_state_data;
1751
   }
1752
   ThreadSpecificState;
1753
1754
static ThreadSpecificState thread_specific_state[VG_N_THREADS];
1755
1756
static
1757
void init_thread_specific_state ( void )
1758
{
1759
  int tid = pthread_self();
1760
  
1761
   thread_specific_state[tid].errno_ptr = NULL;
1762
   thread_specific_state[tid].h_errno_ptr = NULL;
1763
   thread_specific_state[tid].res_state_ptr = NULL;
1764
}
1765
1642
int* __errno_location ( void )
1766
int* __errno_location ( void )
1643
{
1767
{
1644
   int tid;
1768
   int tid;
1645
   /* ensure_valgrind("__errno_location"); */
1769
1770
   ensure_valgrind("__errno_location");
1646
   VALGRIND_MAGIC_SEQUENCE(tid, 1 /* default */,
1771
   VALGRIND_MAGIC_SEQUENCE(tid, 1 /* default */,
1647
                           VG_USERREQ__PTHREAD_GET_THREADID,
1772
                           VG_USERREQ__PTHREAD_GET_THREADID,
1648
                           0, 0, 0, 0);
1773
                           0, 0, 0, 0);
1649
   /* 'cos I'm paranoid ... */
1774
   /* 'cos I'm paranoid ... */
1650
   if (tid < 1 || tid >= VG_N_THREADS)
1775
   if (tid < 1 || tid >= VG_N_THREADS)
1651
      barf("__errno_location: invalid ThreadId");
1776
      barf("__errno_location: invalid ThreadId");
1652
   if (tid == 1)
1777
   if (thread_specific_state[tid].errno_ptr == NULL) {
1653
      return &errno;
1778
      if ((get_gs() & 7) == 3)
1654
   return & thread_specific_errno[tid];
1779
         thread_specific_state[tid].errno_ptr = dlsym(RTLD_DEFAULT, "errno");
1780
      else if (tid == 1)
1781
         thread_specific_state[tid].errno_ptr = dlvsym(RTLD_DEFAULT, "errno", "GLIBC_2.0");
1782
      else
1783
         thread_specific_state[tid].errno_ptr = &thread_specific_state[tid].errno_data;
1784
   }
1785
   return thread_specific_state[tid].errno_ptr;
1655
}
1786
}
1656
1787
1657
#undef h_errno
1658
extern int h_errno;
1659
int* __h_errno_location ( void )
1788
int* __h_errno_location ( void )
1660
{
1789
{
1661
   int tid;
1790
   int tid;
Lines 1666-1679 Link Here
1666
   /* 'cos I'm paranoid ... */
1795
   /* 'cos I'm paranoid ... */
1667
   if (tid < 1 || tid >= VG_N_THREADS)
1796
   if (tid < 1 || tid >= VG_N_THREADS)
1668
      barf("__h_errno_location: invalid ThreadId");
1797
      barf("__h_errno_location: invalid ThreadId");
1669
   if (tid == 1)
1798
   if (thread_specific_state[tid].h_errno_ptr == NULL) {
1670
      return &h_errno;
1799
      if ((get_gs() & 7) == 3)
1671
   return & thread_specific_h_errno[tid];
1800
         thread_specific_state[tid].h_errno_ptr = dlsym(RTLD_DEFAULT, "h_errno");
1801
      else if (tid == 1)
1802
         thread_specific_state[tid].h_errno_ptr = dlvsym(RTLD_DEFAULT, "h_errno", "GLIBC_2.0");
1803
      else
1804
         thread_specific_state[tid].h_errno_ptr = &thread_specific_state[tid].h_errno_data;
1805
   }
1806
   return thread_specific_state[tid].h_errno_ptr;
1672
}
1807
}
1673
1808
1674
1675
#undef _res
1676
extern struct __res_state _res;
1677
struct __res_state* __res_state ( void )
1809
struct __res_state* __res_state ( void )
1678
{
1810
{
1679
   int tid;
1811
   int tid;
Lines 1684-1692 Link Here
1684
   /* 'cos I'm paranoid ... */
1816
   /* 'cos I'm paranoid ... */
1685
   if (tid < 1 || tid >= VG_N_THREADS)
1817
   if (tid < 1 || tid >= VG_N_THREADS)
1686
      barf("__res_state: invalid ThreadId");
1818
      barf("__res_state: invalid ThreadId");
1687
   if (tid == 1)
1819
   if (thread_specific_state[tid].res_state_ptr == NULL) {
1688
      return & _res;
1820
      if ((get_gs() & 7) == 3) {
1689
   return & thread_specific_res_state[tid];
1821
         struct __res_state **resp = dlsym(RTLD_DEFAULT, "__resp");
1822
         
1823
         thread_specific_state[tid].res_state_ptr = *resp;
1824
      } else if (tid == 1) {
1825
         thread_specific_state[tid].res_state_ptr = dlvsym(RTLD_DEFAULT, "_res", "GLIBC_2.0");
1826
      } else {
1827
         thread_specific_state[tid].res_state_ptr = &thread_specific_state[tid].res_state_data;
1828
      }
1829
   }
1830
   return thread_specific_state[tid].res_state_ptr;
1690
}
1831
}
1691
1832
1692
1833
Lines 2261-2266 Link Here
2261
      pthread_mutex_t se_mx;
2402
      pthread_mutex_t se_mx;
2262
      pthread_cond_t se_cv;
2403
      pthread_cond_t se_cv;
2263
      int count;
2404
      int count;
2405
      int waiters;
2264
   }
2406
   }
2265
   vg_sem_t;
2407
   vg_sem_t;
2266
2408
Lines 2295-2300 Link Here
2295
   return &se_remap_new[i];
2437
   return &se_remap_new[i];
2296
}
2438
}
2297
2439
2440
static void se_unmap( sem_t* orig )
2441
{
2442
   int res, i;
2443
   res = __pthread_mutex_lock(&se_remap_mx);
2444
   my_assert(res == 0);
2445
2446
   for (i = 0; i < se_remap_used; i++) {
2447
      if (se_remap_orig[i] == orig)
2448
         break;
2449
   }
2450
   if (i == se_remap_used) {
2451
      res = pthread_mutex_unlock(&se_remap_mx);
2452
      my_assert(res == 0);
2453
      barf("se_unmap: unmapping invalid semaphore");
2454
   } else {
2455
      se_remap_orig[i] = se_remap_orig[--se_remap_used];
2456
      se_remap_orig[se_remap_used] = 0;
2457
      memset(&se_remap_new[se_remap_used], 0,
2458
             sizeof(se_remap_new[se_remap_used]));
2459
   }
2460
   res = pthread_mutex_unlock(&se_remap_mx);
2461
   my_assert(res == 0);
2462
}
2298
2463
2299
int sem_init(sem_t *sem, int pshared, unsigned int value)
2464
int sem_init(sem_t *sem, int pshared, unsigned int value)
2300
{
2465
{
Lines 2315-2321 Link Here
2315
   return 0;
2480
   return 0;
2316
}
2481
}
2317
2482
2318
2319
int sem_wait ( sem_t* sem ) 
2483
int sem_wait ( sem_t* sem ) 
2320
{
2484
{
2321
   int       res;
2485
   int       res;
Lines 2325-2331 Link Here
2325
   res = __pthread_mutex_lock(&vg_sem->se_mx);
2489
   res = __pthread_mutex_lock(&vg_sem->se_mx);
2326
   my_assert(res == 0);
2490
   my_assert(res == 0);
2327
   while (vg_sem->count == 0) {
2491
   while (vg_sem->count == 0) {
2492
      ++vg_sem->waiters;
2328
      res = pthread_cond_wait(&vg_sem->se_cv, &vg_sem->se_mx);
2493
      res = pthread_cond_wait(&vg_sem->se_cv, &vg_sem->se_mx);
2494
      --vg_sem->waiters;
2329
      my_assert(res == 0);
2495
      my_assert(res == 0);
2330
   }
2496
   }
2331
   vg_sem->count--;
2497
   vg_sem->count--;
Lines 2378-2395 Link Here
2378
2544
2379
int sem_getvalue(sem_t* sem, int * sval)
2545
int sem_getvalue(sem_t* sem, int * sval)
2380
{
2546
{
2547
   int res;
2381
   vg_sem_t* vg_sem; 
2548
   vg_sem_t* vg_sem; 
2382
   ensure_valgrind("sem_trywait");
2549
   ensure_valgrind("sem_getvalue");
2383
   vg_sem = se_remap(sem);
2550
   vg_sem = se_remap(sem);
2551
   res = __pthread_mutex_lock(&vg_sem->se_mx);
2552
   my_assert(res == 0);
2384
   *sval = vg_sem->count;
2553
   *sval = vg_sem->count;
2554
   res = __pthread_mutex_unlock(&vg_sem->se_mx);
2555
   my_assert(res == 0);
2385
   return 0;
2556
   return 0;
2386
}
2557
}
2387
2558
2388
2559
2389
int sem_destroy(sem_t * sem)
2560
int sem_destroy(sem_t * sem)
2390
{
2561
{
2391
   kludged("sem_destroy", "(it always succeeds, even if semaphore waited on)");
2392
   /* if someone waiting on this semaphore, errno = EBUSY, return -1 */
2562
   /* if someone waiting on this semaphore, errno = EBUSY, return -1 */
2563
   vg_sem_t* vg_sem;
2564
   int res;
2565
   ensure_valgrind("sem_destroy");
2566
   vg_sem = se_remap(sem);
2567
   res = __pthread_mutex_lock(&vg_sem->se_mx);
2568
   my_assert(res == 0);
2569
   if (vg_sem->waiters > 0)
2570
   {
2571
      *(__errno_location()) = EBUSY;
2572
      res = __pthread_mutex_unlock(&vg_sem->se_mx);
2573
      my_assert(res == 0);
2574
      return -1;
2575
   }
2576
   res = pthread_cond_destroy(&vg_sem->se_cv);
2577
   my_assert(res == 0);
2578
   res = __pthread_mutex_unlock(&vg_sem->se_mx);
2579
   my_assert(res == 0);
2580
   res = pthread_mutex_destroy(&vg_sem->se_mx);
2581
   my_assert(res == 0);
2582
   se_unmap(sem);
2393
   return 0;
2583
   return 0;
2394
}
2584
}
2395
2585
Lines 2403-2409 Link Here
2403
   res = __pthread_mutex_lock(&vg_sem->se_mx); 
2593
   res = __pthread_mutex_lock(&vg_sem->se_mx); 
2404
   my_assert(res == 0); 
2594
   my_assert(res == 0); 
2405
   while ( vg_sem->count == 0 && res != ETIMEDOUT ) { 
2595
   while ( vg_sem->count == 0 && res != ETIMEDOUT ) { 
2596
      ++vg_sem->waiters;
2406
      res = pthread_cond_timedwait(&vg_sem->se_cv, &vg_sem->se_mx, abstime); 
2597
      res = pthread_cond_timedwait(&vg_sem->se_cv, &vg_sem->se_mx, abstime); 
2598
      --vg_sem->waiters;
2407
   } 
2599
   } 
2408
   if ( vg_sem->count > 0 ) { 
2600
   if ( vg_sem->count > 0 ) { 
2409
      vg_sem->count--; 
2601
      vg_sem->count--; 
Lines 2805-2821 Link Here
2805
   ------------------------------------------------------------------ */
2997
   ------------------------------------------------------------------ */
2806
int __libc_current_sigrtmin (void)
2998
int __libc_current_sigrtmin (void)
2807
{
2999
{
2808
   return VG_(sig_rtmin);
3000
   int res;
3001
3002
   VALGRIND_MAGIC_SEQUENCE(res, 0, 
3003
			   VG_USERREQ__GET_SIGRT_MIN,
3004
			   0, 0, 0, 0);
3005
3006
   return res;
2809
}
3007
}
2810
3008
2811
int __libc_current_sigrtmax (void)
3009
int __libc_current_sigrtmax (void)
2812
{
3010
{
2813
   return VG_(sig_rtmax);
3011
   int res;
3012
3013
   VALGRIND_MAGIC_SEQUENCE(res, 0, 
3014
			   VG_USERREQ__GET_SIGRT_MAX,
3015
			   0, 0, 0, 0);
3016
3017
   return res;
2814
}
3018
}
2815
3019
2816
int __libc_allocate_rtsig (int high)
3020
int __libc_allocate_rtsig (int high)
2817
{
3021
{
2818
   return VG_(sig_alloc_rtsig)(high);
3022
   int res;
3023
3024
   VALGRIND_MAGIC_SEQUENCE(res, 0, 
3025
			   VG_USERREQ__ALLOC_RTSIG,
3026
			   high, 0, 0, 0);
3027
3028
   return res;
2819
}
3029
}
2820
3030
2821
/* ---------------------------------------------------------------------
3031
/* ---------------------------------------------------------------------
Lines 2856-2870 Link Here
2856
weak_alias(pthread_rwlock_trywrlock, __pthread_rwlock_trywrlock)
3066
weak_alias(pthread_rwlock_trywrlock, __pthread_rwlock_trywrlock)
2857
3067
2858
3068
2859
/* I've no idea what these are, but they get called quite a lot.
2860
   Anybody know? */
2861
2862
#ifndef __UCLIBC__
3069
#ifndef __UCLIBC__
3070
/* These are called as part of stdio to lock the FILE structure for MT
3071
   programs.  Unfortunately, the lock is not always a pthreads lock -
3072
   the NPTL version uses a lighter-weight lock which uses futex
3073
   directly (and uses a structure which is smaller than
3074
   pthread_mutex).  So basically, this is completely broken on recent
3075
   glibcs. */
3076
2863
#undef _IO_flockfile
3077
#undef _IO_flockfile
2864
void _IO_flockfile ( _IO_FILE * file )
3078
void _IO_flockfile ( _IO_FILE * file )
2865
{
3079
{
2866
   pthread_mutex_lock(file->_lock);
3080
   pthread_mutex_lock(file->_lock);
2867
}
3081
}
3082
strong_alias(_IO_flockfile, __flockfile);
2868
weak_alias(_IO_flockfile, flockfile);
3083
weak_alias(_IO_flockfile, flockfile);
2869
3084
2870
#undef _IO_funlockfile
3085
#undef _IO_funlockfile
Lines 2872-2877 Link Here
2872
{
3087
{
2873
   pthread_mutex_unlock(file->_lock);
3088
   pthread_mutex_unlock(file->_lock);
2874
}
3089
}
3090
strong_alias(_IO_funlockfile, __funlockfile);
2875
weak_alias(_IO_funlockfile, funlockfile);
3091
weak_alias(_IO_funlockfile, funlockfile);
2876
#endif
3092
#endif
2877
3093
(-)valgrind-2.1.0/coregrind/vg_libpthread.vs (-18 / +194 lines)
Lines 1-22 Link Here
1
  GLIBC_2.0 {
2
    pthread_join; pthread_self; pthread_equal;
3
    pthread_exit; pthread_detach;
1
4
2
GLIBC_2.0 {
5
    pthread_getschedparam; pthread_setschedparam;
3
};
4
6
5
GLIBC_2.1 {
7
    pthread_attr_destroy;
6
} GLIBC_2.0;
8
    pthread_attr_getdetachstate; pthread_attr_setdetachstate;
9
    pthread_attr_getschedparam; pthread_attr_setschedparam;
10
    pthread_attr_getschedpolicy; pthread_attr_setschedpolicy;
11
    pthread_attr_getinheritsched; pthread_attr_setinheritsched;
12
    pthread_attr_getscope; pthread_attr_setscope;
7
13
8
GLIBC_2.2 {
14
    pthread_mutex_init; pthread_mutex_destroy;
9
} GLIBC_2.1;
15
    pthread_mutex_lock; pthread_mutex_trylock; pthread_mutex_unlock;
10
16
11
GLIBC_2.2.3 {
17
    pthread_mutexattr_init; pthread_mutexattr_destroy;
12
   __pthread_clock_gettime;
18
13
   __pthread_clock_settime;
19
    # Don't version these, because it doesn't matter for Valgrind's libpthread
14
} GLIBC_2.2;
20
    #pthread_cond_init; pthread_cond_destroy;
15
21
    #pthread_cond_wait; pthread_cond_timedwait;
16
GLIBC_2.3.2 {
22
    #pthread_cond_signal; pthread_cond_broadcast;
17
} GLIBC_2.2;
23
18
24
    pthread_condattr_destroy; pthread_condattr_init;
19
GLIBC_PRIVATE {
25
20
   __pthread_clock_gettime;
26
    pthread_cancel; pthread_testcancel;
21
   __pthread_clock_settime;
27
    pthread_setcancelstate; pthread_setcanceltype;
22
};
28
29
    pthread_sigmask; pthread_kill;
30
31
    pthread_key_create; pthread_key_delete;
32
    pthread_getspecific; pthread_setspecific;
33
34
    pthread_once;
35
36
    pthread_atfork;
37
38
    flockfile; funlockfile; ftrylockfile;
39
40
    # Non-standard POSIX1.x functions.
41
    pthread_mutexattr_getkind_np; pthread_mutexattr_setkind_np;
42
43
    # Protected names for functions used in other shared objects.
44
    __pthread_mutex_init; __pthread_mutex_destroy;
45
    __pthread_mutex_lock; __pthread_mutex_trylock; __pthread_mutex_unlock;
46
    __pthread_mutexattr_init; __pthread_mutexattr_destroy;
47
    __pthread_mutexattr_settype;
48
    __pthread_key_create; __pthread_getspecific; __pthread_setspecific;
49
    __pthread_once; __pthread_atfork;
50
    _IO_flockfile; _IO_ftrylockfile; _IO_funlockfile;
51
52
    # Hidden entry point (through macros).
53
    #_pthread_cleanup_pop; _pthread_cleanup_pop_restore; _pthread_cleanup_push;
54
    #_pthread_cleanup_push_defer;
55
56
    # Semaphores.
57
    #sem_destroy; sem_getvalue; sem_init; sem_post; sem_trywait; sem_wait;
58
59
    # Special fork handling.
60
    fork; __fork; vfork;
61
62
    # Cancellation points.
63
    close; __close; fcntl; __fcntl; read; __read; write; __write; accept;
64
    connect; __connect; recv; recvfrom; recvmsg; send; __send; sendmsg; sendto;
65
    fsync; lseek; __lseek; msync; nanosleep; open; __open; pause; tcdrain;
66
    system; wait; __wait; waitpid;
67
68
    # Hidden entry point (through macros).
69
    _pthread_cleanup_push; _pthread_cleanup_pop;
70
    _pthread_cleanup_push_defer; _pthread_cleanup_pop_restore;
71
72
    pthread_kill_other_threads_np;
73
74
    # The error functions.
75
    __errno_location; __h_errno_location;
76
77
    # Functions which previously have been overwritten.
78
    sigwait; sigaction; __sigaction; _exit; _Exit; longjmp; siglongjmp;
79
    raise;
80
  };
81
82
  GLIBC_2.1 {
83
    pthread_create;
84
    pthread_attr_init;
85
86
    pthread_attr_getguardsize; pthread_attr_setguardsize;
87
    pthread_attr_getstackaddr; pthread_attr_setstackaddr;
88
    pthread_attr_getstacksize; pthread_attr_setstacksize;
89
90
    pthread_mutexattr_gettype; pthread_mutexattr_settype;
91
92
    pthread_rwlock_init; pthread_rwlock_destroy;
93
    pthread_rwlock_rdlock; pthread_rwlock_wrlock; pthread_rwlock_unlock;
94
    pthread_rwlock_tryrdlock; pthread_rwlock_trywrlock;
95
96
    pthread_rwlockattr_init; pthread_rwlockattr_destroy;
97
    pthread_rwlockattr_getpshared; pthread_rwlockattr_setpshared;
98
    pthread_rwlockattr_getkind_np; pthread_rwlockattr_setkind_np;
99
100
    pthread_getconcurrency; pthread_setconcurrency;
101
102
    # Semaphores.
103
    sem_destroy; sem_getvalue; sem_init; sem_post; sem_trywait; sem_wait;
104
105
    __libc_current_sigrtmin; __libc_current_sigrtmax;
106
    __libc_allocate_rtsig;
107
  } GLIBC_2.0;
108
109
  GLIBC_2.1.1 {
110
    sem_close; sem_open; sem_unlink;
111
  } GLIBC_2.1;
112
113
  GLIBC_2.1.2 {
114
    __vfork;
115
  } GLIBC_2.1.1;
116
117
  GLIBC_2.2 {
118
    pthread_mutexattr_getpshared; pthread_mutexattr_setpshared;
119
120
    pthread_condattr_getpshared; pthread_condattr_setpshared;
121
122
    # New functions from IEEE Std. 1003.1-2001.
123
    pthread_mutex_timedlock;
124
125
    pthread_rwlock_timedrdlock; pthread_rwlock_timedwrlock;
126
127
    pthread_attr_getstack; pthread_attr_setstack;
128
129
    pthread_spin_destroy; pthread_spin_init; pthread_spin_lock;
130
    pthread_spin_trylock; pthread_spin_unlock;
131
132
    pthread_barrier_init; pthread_barrier_destroy; pthread_barrier_wait;
133
    pthread_barrierattr_destroy; pthread_barrierattr_init;
134
    pthread_barrierattr_setpshared;
135
136
    sem_timedwait;
137
138
    pthread_yield;
139
140
    pthread_getcpuclockid;
141
142
    # Cancellation points.
143
    lseek64; open64; __open64; pread; pread64; __pread64; pwrite; pwrite64;
144
    __pwrite64;
145
146
    # Names used internally.
147
    __pthread_rwlock_init; __pthread_rwlock_destroy;
148
    __pthread_rwlock_rdlock; __pthread_rwlock_tryrdlock;
149
    __pthread_rwlock_wrlock; __pthread_rwlock_trywrlock;
150
    __pthread_rwlock_unlock;
151
152
    __res_state;
153
  } GLIBC_2.1.2;
154
155
  GLIBC_2.2.3 {
156
    # Extensions.
157
    pthread_getattr_np;
158
  } GLIBC_2.2;
159
160
  GLIBC_2.2.6 {
161
    # Cancellation wrapper
162
    __nanosleep;
163
  } GLIBC_2.2.3;
164
165
  GLIBC_2.3.2 {
166
    # Changed pthread_cond_t.
167
    # Don't version these, because it doesn't matter for Valgrind's libpthread
168
    #pthread_cond_init; pthread_cond_destroy;
169
    #pthread_cond_wait; pthread_cond_timedwait;
170
    #pthread_cond_signal; pthread_cond_broadcast;
171
  } GLIBC_2.2.6;
172
173
  GLIBC_2.3.3 {
174
    # 1003.1-2001 function accidentally left out in 2.2.
175
    pthread_barrierattr_getpshared;
176
177
    # Unix CS option.
178
    pthread_condattr_getclock; pthread_condattr_setclock;
179
180
    # Proposed API extensions.
181
    pthread_tryjoin_np; pthread_timedjoin_np;
182
183
    # New cancellation cleanup handling.
184
    __pthread_register_cancel; __pthread_unregister_cancel;
185
    __pthread_register_cancel_defer; __pthread_unregister_cancel_restore;
186
    __pthread_unwind_next;
187
    __pthread_cleanup_routine;
188
189
    # New affinity interfaces.
190
    pthread_getaffinity_np; pthread_setaffinity_np;
191
    pthread_attr_getaffinity_np; pthread_attr_setaffinity_np;
192
  } GLIBC_2.3.2;
193
194
  GLIBC_PRIVATE {
195
    __pthread_initialize_minimal; __pthread_cleanup_upto;
196
    __pthread_clock_gettime; __pthread_clock_settime;
197
    __pthread_unwind;
198
  };
(-)valgrind-2.1.0/coregrind/vg_libpthread_unimp.c (-1 / +1 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/coregrind/vg_main.c (-1333 / +2344 lines)
Lines 1-14 Link Here
1
1
2
/*--------------------------------------------------------------------*/
2
/*--------------------------------------------------------------------*/
3
/*--- C startup stuff, reached from vg_startup.S.                  ---*/
3
/*--- Startup: the real stuff                            vg_main.c ---*/
4
/*---                                                    vg_main.c ---*/
5
/*--------------------------------------------------------------------*/
4
/*--------------------------------------------------------------------*/
6
5
7
/*
6
/*
8
   This file is part of Valgrind, an extensible x86 protected-mode
7
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
8
   emulator for monitoring program execution on x86-Unixes.
10
9
11
   Copyright (C) 2000-2003 Julian Seward 
10
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
11
      jseward@acm.org
13
12
14
   This program is free software; you can redistribute it and/or
13
   This program is free software; you can redistribute it and/or
Lines 29-124 Link Here
29
   The GNU General Public License is contained in the file COPYING.
28
   The GNU General Public License is contained in the file COPYING.
30
*/
29
*/
31
30
31
#define _FILE_OFFSET_BITS 64
32
32
#include "vg_include.h"
33
#include "vg_include.h"
34
#include "ume.h"
35
#include "ume_arch.h"
36
#include "ume_archdefs.h"
37
38
#include <dirent.h>
39
#include <dlfcn.h>
40
#include <errno.h>
41
#include <fcntl.h>
42
#include <stdio.h>
43
#include <stdlib.h>
44
#include <string.h>
45
#include <sys/mman.h>
46
#include <sys/types.h>
47
#include <sys/stat.h>
48
#include <sys/ptrace.h>
49
#include <sys/signal.h>
50
#include <sys/user.h>
51
#include <sys/wait.h>
52
#include <unistd.h>
53
54
#ifndef AT_SYSINFO
55
#define AT_SYSINFO		32
56
#endif /* AT_SYSINFO */
57
58
#ifndef AT_SYSINFO_EHDR
59
#define AT_SYSINFO_EHDR		33
60
#endif /* AT_SYSINFO_EHDR */
61
62
#ifndef AT_SECURE
63
#define AT_SECURE 23   /* secure mode boolean */
64
#endif	/* AT_SECURE */
65
66
/* Amount to reserve for Valgrind's internal heap */
67
#define VALGRIND_HEAPSIZE	(128*1024*1024)
68
69
/* Amount to reserve for Valgrind's internal mappings */
70
#define VALGRIND_MAPSIZE	(128*1024*1024)
71
72
/* redzone gap between client address space and shadow */
73
#define REDZONE_SIZE		(1 * 1024*1024)
74
75
/* size multiple for client address space */
76
#define CLIENT_SIZE_MULTIPLE	(64 * 1024*1024)
77
78
#define ISSPACE(cc)      ((cc) == ' ' || (cc) == '\t' || (cc) == '\n')
79
80
/*====================================================================*/
81
/*=== Global entities not referenced from generated code           ===*/
82
/*====================================================================*/
33
83
34
/* ---------------------------------------------------------------------
84
/* ---------------------------------------------------------------------
35
   Compute offsets into baseBlock.  See comments in vg_include.h.
85
   Startup stuff                            
36
   ------------------------------------------------------------------ */
86
   ------------------------------------------------------------------ */
87
/* linker-defined base address */
88
extern char kickstart_base;	
37
89
38
/* The variables storing offsets. */
90
/* Client address space, lowest to highest (see top of ume.c) */
39
91
Addr VG_(client_base);           /* client address space limits */
40
#define INVALID_OFFSET (-1)
92
Addr VG_(client_end);
93
Addr VG_(client_mapbase);
94
Addr VG_(client_trampoline_code);
95
Addr VG_(clstk_base);
96
Addr VG_(clstk_end);
97
98
Addr VG_(brk_base);	         /* start of brk */
99
Addr VG_(brk_limit);	         /* current brk */
100
101
Addr VG_(shadow_base);	         /* skin's shadow memory */
102
Addr VG_(shadow_end);
103
104
Addr VG_(valgrind_base);	 /* valgrind's address range */
105
Addr VG_(valgrind_mmap_end);	 /* valgrind's mmaps are between valgrind_base and here */
106
Addr VG_(valgrind_end);
107
108
/* This is set early to indicate whether this CPU has the
109
   SSE/fxsave/fxrestor features.  */
110
Bool VG_(have_ssestate);
41
111
42
Int VGOFF_(m_eax) = INVALID_OFFSET;
112
/* Indicates presence, and holds address of client's sysinfo page, a
43
Int VGOFF_(m_ecx) = INVALID_OFFSET;
113
   feature of some modern kernels used to provide vsyscalls, etc. */
44
Int VGOFF_(m_edx) = INVALID_OFFSET;
114
Bool VG_(sysinfo_page_exists) = False;
45
Int VGOFF_(m_ebx) = INVALID_OFFSET;
115
Addr VG_(sysinfo_page_addr) = 0;
46
Int VGOFF_(m_esp) = INVALID_OFFSET;
47
Int VGOFF_(m_ebp) = INVALID_OFFSET;
48
Int VGOFF_(m_esi) = INVALID_OFFSET;
49
Int VGOFF_(m_edi) = INVALID_OFFSET;
50
Int VGOFF_(m_eflags) = INVALID_OFFSET;
51
Int VGOFF_(m_dflag)  = INVALID_OFFSET;
52
Int VGOFF_(m_ssestate) = INVALID_OFFSET;
53
Int VGOFF_(ldt)   = INVALID_OFFSET;
54
Int VGOFF_(m_cs)  = INVALID_OFFSET;
55
Int VGOFF_(m_ss)  = INVALID_OFFSET;
56
Int VGOFF_(m_ds)  = INVALID_OFFSET;
57
Int VGOFF_(m_es)  = INVALID_OFFSET;
58
Int VGOFF_(m_fs)  = INVALID_OFFSET;
59
Int VGOFF_(m_gs)  = INVALID_OFFSET;
60
Int VGOFF_(m_eip) = INVALID_OFFSET;
61
Int VGOFF_(spillslots) = INVALID_OFFSET;
62
Int VGOFF_(sh_eax) = INVALID_OFFSET;
63
Int VGOFF_(sh_ecx) = INVALID_OFFSET;
64
Int VGOFF_(sh_edx) = INVALID_OFFSET;
65
Int VGOFF_(sh_ebx) = INVALID_OFFSET;
66
Int VGOFF_(sh_esp) = INVALID_OFFSET;
67
Int VGOFF_(sh_ebp) = INVALID_OFFSET;
68
Int VGOFF_(sh_esi) = INVALID_OFFSET;
69
Int VGOFF_(sh_edi) = INVALID_OFFSET;
70
Int VGOFF_(sh_eflags) = INVALID_OFFSET;
71
72
Int VGOFF_(helper_idiv_64_32) = INVALID_OFFSET;
73
Int VGOFF_(helper_div_64_32) = INVALID_OFFSET;
74
Int VGOFF_(helper_idiv_32_16) = INVALID_OFFSET;
75
Int VGOFF_(helper_div_32_16) = INVALID_OFFSET;
76
Int VGOFF_(helper_idiv_16_8) = INVALID_OFFSET;
77
Int VGOFF_(helper_div_16_8) = INVALID_OFFSET;
78
Int VGOFF_(helper_imul_32_64) = INVALID_OFFSET;
79
Int VGOFF_(helper_mul_32_64) = INVALID_OFFSET;
80
Int VGOFF_(helper_imul_16_32) = INVALID_OFFSET;
81
Int VGOFF_(helper_mul_16_32) = INVALID_OFFSET;
82
Int VGOFF_(helper_imul_8_16) = INVALID_OFFSET;
83
Int VGOFF_(helper_mul_8_16) = INVALID_OFFSET;
84
Int VGOFF_(helper_CLD) = INVALID_OFFSET;
85
Int VGOFF_(helper_STD) = INVALID_OFFSET;
86
Int VGOFF_(helper_get_dirflag) = INVALID_OFFSET;
87
Int VGOFF_(helper_CLC) = INVALID_OFFSET;
88
Int VGOFF_(helper_STC) = INVALID_OFFSET;
89
Int VGOFF_(helper_shldl) = INVALID_OFFSET;
90
Int VGOFF_(helper_shldw) = INVALID_OFFSET;
91
Int VGOFF_(helper_shrdl) = INVALID_OFFSET;
92
Int VGOFF_(helper_shrdw) = INVALID_OFFSET;
93
Int VGOFF_(helper_IN) = INVALID_OFFSET;
94
Int VGOFF_(helper_OUT) = INVALID_OFFSET;
95
Int VGOFF_(helper_RDTSC) = INVALID_OFFSET;
96
Int VGOFF_(helper_CPUID) = INVALID_OFFSET;
97
Int VGOFF_(helper_BSWAP) = INVALID_OFFSET;
98
Int VGOFF_(helper_bsf) = INVALID_OFFSET;
99
Int VGOFF_(helper_bsr) = INVALID_OFFSET;
100
Int VGOFF_(helper_fstsw_AX) = INVALID_OFFSET;
101
Int VGOFF_(helper_SAHF) = INVALID_OFFSET;
102
Int VGOFF_(helper_LAHF) = INVALID_OFFSET;
103
Int VGOFF_(helper_DAS) = INVALID_OFFSET;
104
Int VGOFF_(helper_DAA) = INVALID_OFFSET;
105
Int VGOFF_(helper_undefined_instruction) = INVALID_OFFSET;
106
116
107
/* MAX_NONCOMPACT_HELPERS can be increased easily.  If MAX_COMPACT_HELPERS is
117
/* stage1 (main) executable */
108
 * increased too much, they won't really be compact any more... */
118
Int  VG_(vgexecfd) = -1;
109
#define  MAX_COMPACT_HELPERS     8
110
#define  MAX_NONCOMPACT_HELPERS  50 
111
119
112
UInt VG_(n_compact_helpers)    = 0;
120
/* client executable */
113
UInt VG_(n_noncompact_helpers) = 0;
121
Int  VG_(clexecfd) = -1;
114
122
115
Addr VG_(compact_helper_addrs)  [MAX_COMPACT_HELPERS];
123
/* Path to library directory */
116
Int  VG_(compact_helper_offsets)[MAX_COMPACT_HELPERS];
124
const Char *VG_(libdir) = VG_LIBDIR;
117
Addr VG_(noncompact_helper_addrs)  [MAX_NONCOMPACT_HELPERS];
118
Int  VG_(noncompact_helper_offsets)[MAX_NONCOMPACT_HELPERS];
119
125
120
/* This is the actual defn of baseblock. */
126
/* our argc/argv */
121
UInt VG_(baseBlock)[VG_BASEBLOCK_WORDS];
127
Int  VG_(vg_argc);
128
Char **VG_(vg_argv);
122
129
123
/* PID of the main thread */
130
/* PID of the main thread */
124
Int VG_(main_pid);
131
Int VG_(main_pid);
Lines 126-534 Link Here
126
/* PGRP of process */
133
/* PGRP of process */
127
Int VG_(main_pgrp);
134
Int VG_(main_pgrp);
128
135
129
/* Words. */
136
/* Maximum allowed application-visible file descriptor */
130
static Int baB_off = 0;
137
Int VG_(max_fd) = -1;
138
139
/* As deduced from esp_at_startup, the client's argc, argv[] and
140
   envp[] as extracted from the client's stack at startup-time. */
141
Int    VG_(client_argc);
142
Char** VG_(client_argv);
143
Char** VG_(client_envp);
144
145
/* ---------------------------------------------------------------------
146
   Running stuff                            
147
   ------------------------------------------------------------------ */
148
/* Our signal delivery stack. */
149
UInt VG_(sigstack)[VG_SIGSTACK_SIZE_W];
150
151
/* Saving stuff across system calls. */
152
__attribute__ ((aligned (16)))
153
UInt VG_(real_sse_state_saved_over_syscall)[VG_SIZE_OF_SSESTATE_W];
154
Addr VG_(esp_saved_over_syscall);
131
155
132
/* jmp_buf for fatal signals */
156
/* jmp_buf for fatal signals */
133
Int	VG_(fatal_sigNo) = -1;
157
Int	VG_(fatal_sigNo) = -1;
134
Bool	VG_(fatal_signal_set) = False;
158
Bool	VG_(fatal_signal_set) = False;
135
jmp_buf VG_(fatal_signal_jmpbuf);
159
jmp_buf VG_(fatal_signal_jmpbuf);
136
160
137
/* Returns the offset, in words. */
161
/* Counts downwards in VG_(run_innerloop). */
138
static Int alloc_BaB ( Int words )
162
UInt VG_(dispatch_ctr);
163
164
/* 64-bit counter for the number of basic blocks done. */
165
ULong VG_(bbs_done);
166
167
/* This is the ThreadId of the last thread the scheduler ran. */
168
ThreadId VG_(last_run_tid) = 0;
169
170
/* Tell the logging mechanism whether we are logging to a file
171
   descriptor or a socket descriptor. */
172
Bool VG_(logging_to_filedes) = True;
173
174
/* This Bool is needed by wrappers in vg_clientmalloc.c to decide how
175
   to behave.  Initially we say False. */
176
Bool VG_(running_on_simd_CPU) = False;
177
178
/* This is the argument to __NR_exit() supplied by the first thread to
179
   call that syscall.  We eventually pass that to __NR_exit() for
180
   real. */
181
Int VG_(exitcode) = 0;
182
183
184
/*====================================================================*/
185
/*=== Counters, for profiling purposes only                        ===*/
186
/*====================================================================*/
187
188
/* Number of lookups which miss the fast tt helper. */
189
UInt VG_(tt_fast_misses) = 0;
190
191
192
/* Counts for TT/TC informational messages. */
193
194
/* Number and total o/t size of translations overall. */
195
UInt VG_(overall_in_count) = 0;
196
UInt VG_(overall_in_osize) = 0;
197
UInt VG_(overall_in_tsize) = 0;
198
/* Number and total o/t size of discards overall. */
199
UInt VG_(overall_out_count) = 0;
200
UInt VG_(overall_out_osize) = 0;
201
UInt VG_(overall_out_tsize) = 0;
202
/* The number of discards of TT/TC. */
203
UInt VG_(number_of_tc_discards) = 0;
204
/* Counts of chain and unchain operations done. */
205
UInt VG_(bb_enchain_count) = 0;
206
UInt VG_(bb_dechain_count) = 0;
207
/* Number of unchained jumps performed. */
208
UInt VG_(unchained_jumps_done) = 0;
209
210
211
/* Counts pertaining to the register allocator. */
212
213
/* total number of uinstrs input to reg-alloc */
214
UInt VG_(uinstrs_prealloc) = 0;
215
216
/* total number of uinstrs added due to spill code */
217
UInt VG_(uinstrs_spill) = 0;
218
219
/* number of bbs requiring spill code */
220
UInt VG_(translations_needing_spill) = 0;
221
222
/* total of register ranks over all translations */
223
UInt VG_(total_reg_rank) = 0;
224
225
226
/* Counts pertaining to internal sanity checking. */
227
UInt VG_(sanity_fast_count) = 0;
228
UInt VG_(sanity_slow_count) = 0;
229
230
/* Counts pertaining to the scheduler. */
231
UInt VG_(num_scheduling_events_MINOR) = 0;
232
UInt VG_(num_scheduling_events_MAJOR) = 0;
233
234
235
static __inline__ Int safe_idiv(Int a, Int b)
139
{
236
{
140
   Int off = baB_off;
237
   return (b == 0 ? 0 : a / b);
141
   baB_off += words;
238
}
142
   if (baB_off >= VG_BASEBLOCK_WORDS)
143
      VG_(core_panic)( "alloc_BaB: baseBlock is too small");
144
239
145
   return off;   
240
static void show_counts ( void )
241
{
242
   VG_(message)(Vg_DebugMsg,
243
		"    TT/TC: %d tc sectors discarded.",
244
                VG_(number_of_tc_discards) );
245
   VG_(message)(Vg_DebugMsg,
246
                "           %d chainings, %d unchainings.",
247
                VG_(bb_enchain_count), VG_(bb_dechain_count) );
248
   VG_(message)(Vg_DebugMsg,
249
                "translate: new     %d (%d -> %d; ratio %d:10)",
250
                VG_(overall_in_count),
251
                VG_(overall_in_osize),
252
                VG_(overall_in_tsize),
253
                safe_idiv(10*VG_(overall_in_tsize), VG_(overall_in_osize)));
254
   VG_(message)(Vg_DebugMsg,
255
                "           discard %d (%d -> %d; ratio %d:10).",
256
                VG_(overall_out_count),
257
                VG_(overall_out_osize),
258
                VG_(overall_out_tsize),
259
                safe_idiv(10*VG_(overall_out_tsize), VG_(overall_out_osize)));
260
   VG_(message)(Vg_DebugMsg,
261
      " dispatch: %llu jumps (bb entries), of which %u (%lu%%) were unchained.",
262
      VG_(bbs_done), 
263
      VG_(unchained_jumps_done),
264
      ((ULong)(100) * (ULong)(VG_(unchained_jumps_done)))
265
         / ( VG_(bbs_done)==0 ? 1 : VG_(bbs_done) )
266
   );
267
268
   VG_(message)(Vg_DebugMsg,
269
      "           %d/%d major/minor sched events.  %d tt_fast misses.", 
270
                     VG_(num_scheduling_events_MAJOR), 
271
                     VG_(num_scheduling_events_MINOR), 
272
                     VG_(tt_fast_misses));
273
274
   VG_(message)(Vg_DebugMsg, 
275
                "reg-alloc: %d t-req-spill, "
276
                "%d+%d orig+spill uis, %d total-reg-r.",
277
                VG_(translations_needing_spill),
278
                VG_(uinstrs_prealloc),
279
                VG_(uinstrs_spill),
280
                VG_(total_reg_rank) );
281
   VG_(message)(Vg_DebugMsg, 
282
                "   sanity: %d cheap, %d expensive checks.",
283
                VG_(sanity_fast_count), 
284
                VG_(sanity_slow_count) );
285
   VG_(print_ccall_stats)();
146
}
286
}
147
287
148
/* Align offset, in *bytes* */
288
149
static void align_BaB ( UInt align )
289
/*====================================================================*/
290
/*=== Miscellaneous global functions                               ===*/
291
/*====================================================================*/
292
293
/* Start debugger and get it to attach to this process.  Called if the
294
   user requests this service after an error has been shown, so she can
295
   poke around and look at parameters, memory, etc.  You can't
296
   meaningfully get the debugger to continue the program, though; to
297
   continue, quit the debugger.  */
298
void VG_(start_debugger) ( Int tid )
299
{
300
   Int pid;
301
302
   if ((pid = fork()) == 0) {
303
      ptrace(PTRACE_TRACEME, 0, NULL, NULL);
304
      VG_(kkill)(VG_(getpid)(), VKI_SIGSTOP);
305
306
   } else if (pid > 0) {
307
      struct user_regs_struct regs;
308
      Int status;
309
      Int res;
310
311
      if (VG_(is_running_thread)( tid )) {
312
         regs.xcs = VG_(baseBlock)[VGOFF_(m_cs)];
313
         regs.xss = VG_(baseBlock)[VGOFF_(m_ss)];
314
         regs.xds = VG_(baseBlock)[VGOFF_(m_ds)];
315
         regs.xes = VG_(baseBlock)[VGOFF_(m_es)];
316
         regs.xfs = VG_(baseBlock)[VGOFF_(m_fs)];
317
         regs.xgs = VG_(baseBlock)[VGOFF_(m_gs)];
318
         regs.eax = VG_(baseBlock)[VGOFF_(m_eax)];
319
         regs.ebx = VG_(baseBlock)[VGOFF_(m_ebx)];
320
         regs.ecx = VG_(baseBlock)[VGOFF_(m_ecx)];
321
         regs.edx = VG_(baseBlock)[VGOFF_(m_edx)];
322
         regs.esi = VG_(baseBlock)[VGOFF_(m_esi)];
323
         regs.edi = VG_(baseBlock)[VGOFF_(m_edi)];
324
         regs.ebp = VG_(baseBlock)[VGOFF_(m_ebp)];
325
         regs.esp = VG_(baseBlock)[VGOFF_(m_esp)];
326
         regs.eflags = VG_(baseBlock)[VGOFF_(m_eflags)];
327
         regs.eip = VG_(baseBlock)[VGOFF_(m_eip)];
328
      } else {
329
         ThreadState* tst = & VG_(threads)[ tid ];
330
         
331
         regs.xcs = tst->m_cs;
332
         regs.xss = tst->m_ss;
333
         regs.xds = tst->m_ds;
334
         regs.xes = tst->m_es;
335
         regs.xfs = tst->m_fs;
336
         regs.xgs = tst->m_gs;
337
         regs.eax = tst->m_eax;
338
         regs.ebx = tst->m_ebx;
339
         regs.ecx = tst->m_ecx;
340
         regs.edx = tst->m_edx;
341
         regs.esi = tst->m_esi;
342
         regs.edi = tst->m_edi;
343
         regs.ebp = tst->m_ebp;
344
         regs.esp = tst->m_esp;
345
         regs.eflags = tst->m_eflags;
346
         regs.eip = tst->m_eip;
347
      }
348
349
      if ((res = VG_(waitpid)(pid, &status, 0)) == pid &&
350
          WIFSTOPPED(status) && WSTOPSIG(status) == SIGSTOP &&
351
          ptrace(PTRACE_SETREGS, pid, NULL, &regs) == 0 &&
352
          ptrace(PTRACE_DETACH, pid, NULL, SIGSTOP) == 0) {
353
         Char pidbuf[15];
354
         Char file[30];
355
         Char buf[100];
356
         Char *bufptr;
357
         Char *cmdptr;
358
         
359
         VG_(sprintf)(pidbuf, "%d", pid);
360
         VG_(sprintf)(file, "/proc/%d/fd/%d", pid, VG_(clexecfd));
361
 
362
         bufptr = buf;
363
         cmdptr = VG_(clo_db_command);
364
         
365
         while (*cmdptr) {
366
            switch (*cmdptr) {
367
               case '%':
368
                  switch (*++cmdptr) {
369
                     case 'f':
370
                        VG_(memcpy)(bufptr, file, VG_(strlen)(file));
371
                        bufptr += VG_(strlen)(file);
372
                        cmdptr++;
373
                        break;
374
                  case 'p':
375
                     VG_(memcpy)(bufptr, pidbuf, VG_(strlen)(pidbuf));
376
                     bufptr += VG_(strlen)(pidbuf);
377
                     cmdptr++;
378
                     break;
379
                  default:
380
                     *bufptr++ = *cmdptr++;
381
                     break;
382
                  }
383
                  break;
384
               default:
385
                  *bufptr++ = *cmdptr++;
386
                  break;
387
            }
388
         }
389
         
390
         *bufptr++ = '\0';
391
  
392
         VG_(message)(Vg_UserMsg, "starting debugger with cmd: %s", buf);
393
         res = VG_(system)(buf);
394
         if (res == 0) {      
395
            VG_(message)(Vg_UserMsg, "");
396
            VG_(message)(Vg_UserMsg, 
397
                         "Debugger has detached.  Valgrind regains control.  We continue.");
398
         } else {
399
            VG_(message)(Vg_UserMsg, "Apparently failed!");
400
            VG_(message)(Vg_UserMsg, "");
401
         }
402
      }
403
404
      VG_(kkill)(pid, VKI_SIGKILL);
405
      VG_(waitpid)(pid, &status, 0);
406
   }
407
}
408
409
410
/* Print some helpful-ish text about unimplemented things, and give
411
   up. */
412
void VG_(unimplemented) ( Char* msg )
150
{
413
{
151
   vg_assert(2 == align || 4 == align || 8 == align || 16 == align);
414
   VG_(message)(Vg_UserMsg, "");
152
   baB_off +=  (align-1);
415
   VG_(message)(Vg_UserMsg, 
153
   baB_off &= ~(align-1);
416
      "Valgrind detected that your program requires");
417
   VG_(message)(Vg_UserMsg, 
418
      "the following unimplemented functionality:");
419
   VG_(message)(Vg_UserMsg, "   %s", msg);
420
   VG_(message)(Vg_UserMsg,
421
      "This may be because the functionality is hard to implement,");
422
   VG_(message)(Vg_UserMsg,
423
      "or because no reasonable program would behave this way,");
424
   VG_(message)(Vg_UserMsg,
425
      "or because nobody has yet needed it.  In any case, let us know at");
426
   VG_(message)(Vg_UserMsg,
427
      "%s and/or try to work around the problem, if you can.", VG_BUGS_TO);
428
   VG_(message)(Vg_UserMsg,
429
      "");
430
   VG_(message)(Vg_UserMsg,
431
      "Valgrind has to exit now.  Sorry.  Bye!");
432
   VG_(message)(Vg_UserMsg,
433
      "");
434
   VG_(pp_sched_status)();
435
   VG_(exit)(1);
154
}
436
}
155
437
156
/* Allocate 1 word in baseBlock and set it to the given value. */
438
Addr VG_(get_stack_pointer) ( void )
157
static Int alloc_BaB_1_set ( Addr a )
158
{
439
{
159
   Int off = alloc_BaB(1);
440
   return VG_(baseBlock)[VGOFF_(m_esp)];
160
   VG_(baseBlock)[off] = (UInt)a;
161
   return off;
162
}
441
}
163
442
164
/* Registers a function in compact_helper_addrs;  compact_helper_offsets is
443
/* Debugging thing .. can be called from assembly with OYNK macro. */
165
   filled in later. */
444
void VG_(oynk) ( Int n )
166
void VG_(register_compact_helper)(Addr a)
167
{
445
{
168
   if (MAX_COMPACT_HELPERS <= VG_(n_compact_helpers)) {
446
   OINK(n);
169
      VG_(printf)("Can only register %d compact helpers\n", 
447
}
170
                  MAX_COMPACT_HELPERS);
448
171
      VG_(core_panic)("Too many compact helpers registered");
449
/* Initialize the PID and PGRP of scheduler LWP; this is also called
450
   in any new children after fork. */
451
static void newpid(ThreadId unused)
452
{
453
   /* PID of scheduler LWP */
454
   VG_(main_pid)  = VG_(getpid)();
455
   VG_(main_pgrp) = VG_(getpgrp)();
456
}
457
458
/*====================================================================*/
459
/*=== Check we were launched by stage 1                            ===*/
460
/*====================================================================*/
461
462
/* Look for our AUXV table */
463
static void scan_auxv(void)
464
{
465
   const struct ume_auxv *auxv = find_auxv((int *)ume_exec_esp);
466
   int found = 0;
467
468
   for (; auxv->a_type != AT_NULL; auxv++)
469
      switch(auxv->a_type) {
470
      case AT_UME_PADFD:
471
	 as_setpadfd(auxv->u.a_val);
472
	 found |= 1;
473
	 break;
474
475
      case AT_UME_EXECFD:
476
	 VG_(vgexecfd) = auxv->u.a_val;
477
	 found |= 2;
478
	 break;
479
      }
480
481
   if ( ! (1|2) ) {
482
      fprintf(stderr, "stage2 must be launched by stage1\n");
483
      exit(127);
484
   }
485
}
486
487
488
/*====================================================================*/
489
/*=== Address space determination                                  ===*/
490
/*====================================================================*/
491
492
/* Pad client space so it doesn't get filled in before the right time */
493
static void layout_client_space(Addr argc_addr)
494
{
495
   VG_(client_base)       = CLIENT_BASE;
496
   VG_(valgrind_mmap_end) = (addr_t)&kickstart_base; /* end of V's mmaps */
497
   VG_(valgrind_base)     = VG_(valgrind_mmap_end) - VALGRIND_MAPSIZE;
498
   VG_(valgrind_end)      = ROUNDUP(argc_addr, 0x10000); /* stack */
499
500
   if (0)
501
      printf("client base:        %x\n"
502
             "valgrind base--end: %x--%x (%x)\n"
503
             "valgrind mmap end:  %x\n\n",
504
             VG_(client_base),
505
             VG_(valgrind_base), VG_(valgrind_end),
506
             VG_(valgrind_end) - VG_(valgrind_base),
507
             VG_(valgrind_mmap_end));
508
509
   as_pad((void *)VG_(client_base), (void *)VG_(valgrind_base));
510
}
511
512
static void layout_remaining_space(float ratio)
513
{
514
   /* This tries to give the client as large as possible address space while
515
    * taking into account the tool's shadow needs.  */
516
   addr_t client_size = ROUNDDN((VG_(valgrind_base) - REDZONE_SIZE) / (1. + ratio), 
517
                         CLIENT_SIZE_MULTIPLE);
518
   addr_t shadow_size = PGROUNDUP(client_size * ratio);
519
520
   VG_(client_end)     = VG_(client_base) + client_size;
521
   VG_(client_mapbase) = PGROUNDDN((client_size/4)*3); /* where !FIXED mmap goes */
522
   VG_(client_trampoline_code) = VG_(client_end) - VKI_BYTES_PER_PAGE;
523
524
   VG_(shadow_base) = VG_(client_end) + REDZONE_SIZE;
525
   VG_(shadow_end)  = VG_(shadow_base) + shadow_size;
526
527
   if (0)
528
      printf("client base--end:   %x--%x (%x)\n"
529
             "client mapbase:     %x\n"
530
             "shadow base--end:   %x--%x (%x)\n\n",
531
             VG_(client_base), VG_(client_end), client_size,
532
             VG_(client_mapbase),
533
             VG_(shadow_base), VG_(shadow_end), shadow_size);
534
535
   // Ban redzone
536
   mmap((void *)VG_(client_end), REDZONE_SIZE, PROT_NONE,
537
	MAP_FIXED|MAP_ANON|MAP_PRIVATE, -1, 0);
538
539
   // Make client hole
540
   munmap((void*)VG_(client_base), client_size);
541
542
   // Map shadow memory.
543
   // Initially all inaccessible, incrementally initialized as it is used
544
   if (shadow_size != 0)
545
      mmap((char *)VG_(shadow_base), shadow_size, PROT_NONE,
546
         MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0);
547
}
548
549
/*====================================================================*/
550
/*=== Command line setup                                           ===*/
551
/*====================================================================*/
552
553
/* Nb: malloc'd memory never freed -- kept throughout like argv, envp */
554
static char* get_file_clo(char* dir)
555
{
556
#  define FLEN 512
557
   Int fd, n;
558
   struct stat s1;
559
   char* f_clo = NULL;
560
   char filename[FLEN];
561
562
   snprintf(filename, FLEN, "%s/.valgrindrc", ( NULL == dir ? "" : dir ) );
563
   fd = VG_(open)(filename, 0, VKI_S_IRUSR);
564
   if ( fd > 0 ) {
565
      if ( 0 == fstat(fd, &s1) ) {
566
         f_clo = malloc(s1.st_size+1);
567
         vg_assert(f_clo);
568
         n = read(fd, f_clo, s1.st_size);
569
         if (n == -1) n = 0;
570
         f_clo[n] = '\0';
571
      }
572
      close(fd);
172
   }
573
   }
173
   VG_(compact_helper_addrs)[VG_(n_compact_helpers)] = a;
574
   return f_clo;
174
   VG_(n_compact_helpers)++;
575
#  undef FLEN
175
}
576
}
176
577
177
/* Registers a function in noncompact_helper_addrs;  noncompact_helper_offsets
578
static Int count_args(char* s)
178
 * is filled in later.
179
 */
180
void VG_(register_noncompact_helper)(Addr a)
181
{
579
{
182
   if (MAX_NONCOMPACT_HELPERS <= VG_(n_noncompact_helpers)) {
580
   Int n = 0;
183
      VG_(printf)("Can only register %d non-compact helpers\n", 
581
   if (s) {
184
                  MAX_NONCOMPACT_HELPERS);
582
      char* cp = s;
185
      VG_(printf)("Try increasing MAX_NON_COMPACT_HELPERS\n");
583
      while (True) {
186
      VG_(core_panic)("Too many non-compact helpers registered");
584
         // We have alternating sequences: blanks, non-blanks, blanks...
585
         // count the non-blanks sequences.
586
         while ( ISSPACE(*cp) )         cp++;
587
         if    ( !*cp )                 break;
588
         n++;
589
         while ( !ISSPACE(*cp) && *cp ) cp++;
590
      }
187
   }
591
   }
188
   VG_(noncompact_helper_addrs)[VG_(n_noncompact_helpers)] = a;
592
   return n;
189
   VG_(n_noncompact_helpers)++;
190
}
593
}
191
594
192
/* Allocate offsets in baseBlock for the skin helpers */
595
/* add args out of environment, skipping multiple spaces and -- args */
193
static 
596
static char** copy_args( char* s, char** to )
194
void assign_helpers_in_baseBlock(UInt n, Int offsets[], Addr addrs[])
195
{
597
{
196
   UInt i;
598
   if (s) {
197
   for (i = 0; i < n; i++) 
599
      char* cp = s;
198
      offsets[i] = alloc_BaB_1_set( addrs[i] );
600
      while (True) {
601
         // We have alternating sequences: blanks, non-blanks, blanks...
602
         // copy the non-blanks sequences, and add terminating '\0'
603
         while ( ISSPACE(*cp) )         cp++;
604
         if    ( !*cp )                 break;
605
         *to++ = cp;
606
         while ( !ISSPACE(*cp) && *cp ) cp++;
607
         if ( *cp ) *cp++ = '\0';            // terminate if necessary
608
         if (VG_STREQ(to[-1], "--")) to--;   // undo any '--' arg
609
      }
610
   }
611
   return to;
199
}
612
}
200
613
201
Bool VG_(need_to_handle_esp_assignment)(void)
614
// Augment command line with arguments from environment and .valgrindrc
615
// files.
616
static void augment_command_line(Int* vg_argc_inout, char*** vg_argv_inout)
617
{
618
   int    vg_argc = *vg_argc_inout;
619
   char** vg_argv = *vg_argv_inout;
620
621
   char*  env_clo = getenv(VALGRINDOPTS);
622
   char*  f1_clo  = get_file_clo( getenv("HOME") );
623
   char*  f2_clo  = get_file_clo(".");
624
625
   /* copy any extra args from file or environment, if present */
626
   if ( (env_clo && *env_clo) || (f1_clo && *f1_clo) || (f2_clo && *f2_clo) ) {
627
      /* ' ' separated extra options */
628
      char **from;
629
      char **to;
630
      int env_arg_count, f1_arg_count, f2_arg_count;
631
      
632
      env_arg_count = count_args(env_clo);
633
      f1_arg_count  = count_args(f1_clo);
634
      f2_arg_count  = count_args(f2_clo);
635
636
      if (0)
637
	 printf("extra-argc=%d %d %d\n",
638
		env_arg_count, f1_arg_count, f2_arg_count);
639
640
      /* +2: +1 for null-termination, +1 for added '--' */
641
      from    = vg_argv;
642
      vg_argv = malloc( (vg_argc + env_arg_count + f1_arg_count 
643
                          + f2_arg_count + 2) * sizeof(char **));
644
      to      = vg_argv;
645
646
      /* copy argv[0] */
647
      *to++ = *from++;
648
649
      /* Copy extra args from env var and file, in the order: ~/.valgrindrc,
650
       * $VALGRIND_OPTS, ./.valgrindrc -- more local options are put later
651
       * to override less local ones. */
652
      to = copy_args(f1_clo,  to);
653
      to = copy_args(env_clo, to);
654
      to = copy_args(f2_clo,  to);
655
656
      /* copy original arguments, stopping at command or -- */
657
      while (*from) {
658
	 if (**from != '-')
659
	    break;
660
	 if (VG_STREQ(*from, "--")) {
661
	    from++;		/* skip -- */
662
	    break;
663
	 }
664
	 *to++ = *from++;
665
      }
666
667
      /* add -- */
668
      *to++ = "--";
669
670
      vg_argc = to - vg_argv;
671
672
      /* copy rest of original command line, then NULL */
673
      while (*from) *to++ = *from++;
674
      *to = NULL;
675
   }
676
677
   *vg_argc_inout = vg_argc;
678
   *vg_argv_inout = vg_argv;
679
}
680
681
static void get_command_line( int argc, char** argv,
682
                              Int* vg_argc_out, Char*** vg_argv_out, 
683
                                                char*** cl_argv_out )
202
{
684
{
203
   return ( VG_(track_events).new_mem_stack_4  ||
685
   int    vg_argc;
204
            VG_(track_events).die_mem_stack_4  ||
686
   char** vg_argv;
205
            VG_(track_events).new_mem_stack_8  ||
687
   char** cl_argv;
206
            VG_(track_events).die_mem_stack_8  ||
688
   char*  env_clo = getenv(VALGRINDCLO);
207
            VG_(track_events).new_mem_stack_12 ||
689
208
            VG_(track_events).die_mem_stack_12 ||
690
   if (env_clo != NULL && *env_clo != '\0') {
209
            VG_(track_events).new_mem_stack_16 ||
691
      char *cp;
210
            VG_(track_events).die_mem_stack_16 ||
692
      char **cpp;
211
            VG_(track_events).new_mem_stack_32 ||
693
212
            VG_(track_events).die_mem_stack_32 ||
694
      /* OK, we're getting all our arguments from the environment - the
213
            VG_(track_events).new_mem_stack    ||
695
	 entire command line belongs to the client (including argv[0]) */
214
            VG_(track_events).die_mem_stack
696
      vg_argc = 1;		/* argv[0] */
215
          );
697
      for (cp = env_clo; *cp; cp++)
698
	 if (*cp == '\01')
699
	    vg_argc++;
700
701
      vg_argv = malloc(sizeof(char **) * (vg_argc + 1));
702
703
      cpp = vg_argv;
704
705
      *cpp++ = "valgrind";	/* nominal argv[0] */
706
      *cpp++ = env_clo;
707
708
      for (cp = env_clo; *cp; cp++) {
709
	 if (*cp == '\01') {
710
	    *cp++ = '\0';	/* chop it up in place */
711
	    *cpp++ = cp;
712
	 }
713
      }
714
      *cpp = NULL;
715
      cl_argv = argv;
716
717
   } else {
718
      /* Count the arguments on the command line. */
719
      vg_argv = argv;
720
721
      for (vg_argc = 1; vg_argc < argc; vg_argc++) {
722
	 if (argv[vg_argc][0] != '-') /* exe name */
723
	    break;
724
	 if (VG_STREQ(argv[vg_argc], "--")) { /* dummy arg */
725
	    vg_argc++;
726
	    break;
727
	 }
728
      }
729
      cl_argv = &argv[vg_argc];
730
731
      /* Get extra args from VALGRIND_OPTS and .valgrindrc files.
732
       * Note we don't do this if getting args from VALGRINDCLO. */
733
      augment_command_line(&vg_argc, &vg_argv);
734
   }
735
736
   if (0) {
737
      Int i;
738
      for (i = 0; i < vg_argc; i++)
739
         printf("vg_argv[%d]=\"%s\"\n", i, vg_argv[i]);
740
   }
741
742
   *vg_argc_out =         vg_argc;
743
   *vg_argv_out = (Char**)vg_argv;
744
   *cl_argv_out =         cl_argv;
216
}
745
}
217
746
218
/* Here we assign actual offsets.  It's important to get the most
747
219
   popular referents within 128 bytes of the start, so we can take
748
/*====================================================================*/
220
   advantage of short addressing modes relative to %ebp.  Popularity
749
/*=== Environment and stack setup                                  ===*/
221
   of offsets was measured on 22 Feb 02 running a KDE application, and
750
/*====================================================================*/
222
   the slots rearranged accordingly, with a 1.5% reduction in total
751
223
   size of translations. */
752
/* Scan a colon-separated list, and call a function on each element.
224
static void vg_init_baseBlock ( void )
753
   The string must be mutable, because we insert a temporary '\0', but
754
   the string will end up unmodified.  (*func) should return 1 if it
755
   doesn't need to see any more.
756
*/
757
static void scan_colsep(char *colsep, int (*func)(const char *))
225
{
758
{
226
   /* Those with offsets under 128 are carefully chosen. */
759
   char *cp, *entry;
760
   int end;
227
761
228
   /* WORD offsets in this column */
762
   if (colsep == NULL ||
229
   /* 0   */ VGOFF_(m_eax)     = alloc_BaB(1);
763
       *colsep == '\0')
230
   /* 1   */ VGOFF_(m_ecx)     = alloc_BaB(1);
764
      return;
231
   /* 2   */ VGOFF_(m_edx)     = alloc_BaB(1);
232
   /* 3   */ VGOFF_(m_ebx)     = alloc_BaB(1);
233
   /* 4   */ VGOFF_(m_esp)     = alloc_BaB(1);
234
   /* 5   */ VGOFF_(m_ebp)     = alloc_BaB(1);
235
   /* 6   */ VGOFF_(m_esi)     = alloc_BaB(1);
236
   /* 7   */ VGOFF_(m_edi)     = alloc_BaB(1);
237
   /* 8   */ VGOFF_(m_eflags)  = alloc_BaB(1);
238
765
239
   if (VG_(needs).shadow_regs) {
766
   entry = cp = colsep;
240
      /* 9   */ VGOFF_(sh_eax)    = alloc_BaB(1);
767
241
      /* 10  */ VGOFF_(sh_ecx)    = alloc_BaB(1);
768
   do {
242
      /* 11  */ VGOFF_(sh_edx)    = alloc_BaB(1);
769
      end = (*cp == '\0');
243
      /* 12  */ VGOFF_(sh_ebx)    = alloc_BaB(1);
770
244
      /* 13  */ VGOFF_(sh_esp)    = alloc_BaB(1);
771
      if (*cp == ':' || *cp == '\0') {
245
      /* 14  */ VGOFF_(sh_ebp)    = alloc_BaB(1);
772
	 char save = *cp;
246
      /* 15  */ VGOFF_(sh_esi)    = alloc_BaB(1);
773
247
      /* 16  */ VGOFF_(sh_edi)    = alloc_BaB(1);
774
	 *cp = '\0';
248
      /* 17  */ VGOFF_(sh_eflags) = alloc_BaB(1);
775
	 if ((*func)(entry))
776
	    end = 1;
777
	 *cp = save;
778
	 entry = cp+1;
779
      }
780
      cp++;
781
   } while(!end);
782
}
783
784
/* Prepare the client's environment.  This is basically a copy of our
785
   environment, except:
786
   1. LD_LIBRARY_PATH=$VALGRINDLIB:$LD_LIBRARY_PATH
787
   2. LD_PRELOAD=$VALGRINDLIB/vg_inject.so:($VALGRINDLIB/vgpreload_TOOL.so:)?$LD_PRELOAD
788
789
   If any of these is missing, then it is added.
790
791
   Yummy.  String hacking in C.
792
793
   If this needs to handle any more variables it should be hacked
794
   into something table driven.
795
 */
796
static char **fix_environment(char **origenv, const char *preload)
797
{
798
   static const char inject_so[]          = "vg_inject.so";
799
   static const char ld_library_path[]    = "LD_LIBRARY_PATH=";
800
   static const char ld_preload[]         = "LD_PRELOAD=";
801
   static const char valgrind_clo[]       = VALGRINDCLO "=";
802
   static const int  ld_library_path_len  = sizeof(ld_library_path)-1;
803
   static const int  ld_preload_len       = sizeof(ld_preload)-1;
804
   static const int  valgrind_clo_len     = sizeof(valgrind_clo)-1;
805
   int ld_preload_done       = 0;
806
   int ld_library_path_done  = 0;
807
   char *inject_path;
808
   int   inject_path_len;
809
   int vgliblen = strlen(VG_(libdir));
810
   char **cpp;
811
   char **ret;
812
   int envc;
813
   const int preloadlen = (preload == NULL) ? 0 : strlen(preload);
814
815
   /* Find the vg_inject.so; also make room for the tool preload
816
      library */
817
   inject_path_len = sizeof(inject_so) + vgliblen + preloadlen + 16;
818
   inject_path = malloc(inject_path_len);
819
820
   if (preload)
821
      snprintf(inject_path, inject_path_len, "%s/%s:%s", 
822
	       VG_(libdir), inject_so, preload);
823
   else
824
      snprintf(inject_path, inject_path_len, "%s/%s", 
825
	       VG_(libdir), inject_so);
826
   
827
   /* Count the original size of the env */
828
   envc = 0;			/* trailing NULL */
829
   for (cpp = origenv; cpp && *cpp; cpp++)
830
      envc++;
831
832
   /* Allocate a new space */
833
   ret = malloc(sizeof(char *) * (envc+3+1)); /* 3 new entries + NULL */
834
835
   /* copy it over */
836
   for (cpp = ret; *origenv; )
837
      *cpp++ = *origenv++;
838
   *cpp = NULL;
839
   
840
   vg_assert(envc == (cpp - ret));
841
842
   /* Walk over the new environment, mashing as we go */
843
   for (cpp = ret; cpp && *cpp; cpp++) {
844
      if (memcmp(*cpp, ld_library_path, ld_library_path_len) == 0) {
845
	 int done = 0;
846
	 int contains(const char *p) {
847
	    if (VG_STREQ(p, VG_(libdir))) {
848
	       done = 1;
849
	       return 1;
850
	    }
851
	    return 0;
852
	 }
853
854
	 /* If the LD_LIBRARY_PATH already contains libdir, then don't
855
	    bother adding it again, even if it isn't the first (it
856
	    seems that the Java runtime will keep reexecing itself
857
	    unless its paths are at the front of LD_LIBRARY_PATH) */
858
	 scan_colsep(*cpp + ld_library_path_len, contains);
859
860
	 if (!done) {
861
	    int len = strlen(*cpp) + vgliblen*2 + 16;
862
	    char *cp = malloc(len);
863
864
	    snprintf(cp, len, "%s%s:%s",
865
		     ld_library_path, VG_(libdir),
866
		     (*cpp)+ld_library_path_len);
867
868
	    *cpp = cp;
869
	 }
870
871
	 ld_library_path_done = 1;
872
      } else if (memcmp(*cpp, ld_preload, ld_preload_len) == 0) {
873
	 int len = strlen(*cpp) + inject_path_len;
874
	 char *cp = malloc(len);
875
876
	 snprintf(cp, len, "%s%s:%s",
877
		  ld_preload, inject_path, (*cpp)+ld_preload_len);
878
879
	 *cpp = cp;
880
	 
881
	 ld_preload_done = 1;
882
      } else if (memcmp(*cpp, valgrind_clo, valgrind_clo_len) == 0) {
883
	 *cpp = "";
884
      }
249
   }
885
   }
250
886
251
   /* 9,10,11 or 18,19,20... depends on number whether shadow regs are used
887
   /* Add the missing bits */
252
    * and on compact helpers registered */ 
253
888
254
   /* Make these most-frequently-called specialised ones compact, if they
889
   if (!ld_library_path_done) {
255
      are used. */
890
      int len = ld_library_path_len + vgliblen*2 + 16;
256
   if (VG_(track_events).new_mem_stack_4)
891
      char *cp = malloc(len);
257
      VG_(register_compact_helper)( (Addr) VG_(track_events).new_mem_stack_4);
258
892
259
   if (VG_(track_events).die_mem_stack_4)
893
      snprintf(cp, len, "%s%s", ld_library_path, VG_(libdir));
260
      VG_(register_compact_helper)( (Addr) VG_(track_events).die_mem_stack_4);
261
894
262
   /* (9 or 18) + n_compact_helpers  */
895
      ret[envc++] = cp;
263
   /* Allocate slots for compact helpers */
896
   }
264
   assign_helpers_in_baseBlock(VG_(n_compact_helpers), 
265
                               VG_(compact_helper_offsets), 
266
                               VG_(compact_helper_addrs));
267
897
268
   /* (9/10 or 18/19) + n_compact_helpers */
898
   if (!ld_preload_done) {
269
   VGOFF_(m_eip) = alloc_BaB(1);
899
      int len = ld_preload_len + inject_path_len;
900
      char *cp = malloc(len);
901
      
902
      snprintf(cp, len, "%s%s",
903
	       ld_preload, inject_path);
904
      
905
      ret[envc++] = cp;
906
   }
270
907
271
   /* There are currently 24 spill slots */
908
   ret[envc] = NULL;
272
   /* (11+/20+ .. 32+/43+) + n_compact_helpers.  This can overlap the magic
273
    * boundary at >= 32 words, but most spills are to low numbered spill
274
    * slots, so the ones above the boundary don't see much action. */
275
   VGOFF_(spillslots) = alloc_BaB(VG_MAX_SPILLSLOTS);
276
909
277
   /* I gave up counting at this point.  Since they're above the
910
   return ret;
278
      short-amode-boundary, there's no point. */
911
}
279
912
280
   VGOFF_(m_dflag) = alloc_BaB(1);
913
extern char **environ;		/* our environment */
914
//#include <error.h>
281
915
282
   /* The FPU/SSE state.  This _must_ be 16-byte aligned. */
916
/* Add a string onto the string table, and return its address */
283
   align_BaB(16);
917
static char *copy_str(char **tab, const char *str)
284
   VGOFF_(m_ssestate) = alloc_BaB(VG_SIZE_OF_SSESTATE_W);
918
{
285
   vg_assert( 
919
   char *cp = *tab;
286
      (  ((UInt)(& VG_(baseBlock)[VGOFF_(m_ssestate)]))
920
   char *orig = cp;
287
         % 16  )
921
288
      == 0
922
   while(*str)
289
   );
923
      *cp++ = *str++;
924
   *cp++ = '\0';
925
926
   if (0)
927
      printf("copied %p \"%s\" len %d\n",
928
	     orig, orig, cp-orig);
929
930
   *tab = cp;
931
932
   return orig;
933
}
934
935
/* 
936
   This sets up the client's initial stack, containing the args,
937
   environment and aux vector.
938
939
   The format of the stack is:
940
941
   higher address +-----------------+
942
		  | Trampoline code |
943
		  +-----------------+
944
                  |                 |
945
		  : string table    :
946
		  |                 |
947
		  +-----------------+
948
		  | AT_NULL         |
949
		  -                 -
950
		  | auxv            |
951
		  +-----------------+
952
		  |  NULL           |
953
		  -                 -
954
		  | envp            |
955
		  +-----------------+
956
		  |  NULL           |
957
		  -                 -
958
		  | argv            |
959
		  +-----------------+
960
		  | argc            |
961
   lower address  +-----------------+ <- esp
962
                  | undefined       |
963
		  :                 :
964
 */
965
static Addr setup_client_stack(char **orig_argv, char **orig_envp, 
966
			       const struct exeinfo *info,
967
                               UInt** client_auxv)
968
{
969
   char **cpp;
970
   char *strtab;		/* string table */
971
   char *stringbase;
972
   addr_t *ptr;
973
   struct ume_auxv *auxv;
974
   const struct ume_auxv *orig_auxv;
975
   const struct ume_auxv *cauxv;
976
   unsigned stringsize;		/* total size of strings in bytes */
977
   unsigned auxsize;		/* total size of auxv in bytes */
978
   int argc;			/* total argc */
979
   int envc;			/* total number of env vars */
980
   unsigned stacksize;		/* total client stack size */
981
   addr_t cl_esp;		/* client stack base (initial esp) */
982
983
   /* use our own auxv as a prototype */
984
   orig_auxv = find_auxv(ume_exec_esp);
985
986
   /* ==================== compute sizes ==================== */
987
988
   /* first of all, work out how big the client stack will be */
989
   stringsize = 0;
990
991
   /* paste on the extra args if the loader needs them (ie, the #! 
992
      interpreter and its argument) */
993
   argc = 0;
994
   if (info->argv0 != NULL) {
995
      argc++;
996
      stringsize += strlen(info->argv0) + 1;
997
   }
998
   if (info->argv1 != NULL) {
999
      argc++;
1000
      stringsize += strlen(info->argv1) + 1;
1001
   }
1002
1003
   /* now scan the args we're given... */
1004
   for (cpp = orig_argv; *cpp; cpp++) {
1005
      argc++;
1006
      stringsize += strlen(*cpp) + 1;
1007
   }
1008
   
1009
   /* ...and the environment */
1010
   envc = 0;
1011
   for (cpp = orig_envp; cpp && *cpp; cpp++) {
1012
      envc++;
1013
      stringsize += strlen(*cpp) + 1;
1014
   }
1015
1016
   /* now, how big is the auxv? */
1017
   auxsize = sizeof(*auxv);	/* there's always at least one entry: AT_NULL */
1018
   for (cauxv = orig_auxv; cauxv->a_type != AT_NULL; cauxv++) {
1019
      if (cauxv->a_type == AT_PLATFORM)
1020
	 stringsize += strlen(cauxv->u.a_ptr) + 1;
1021
      auxsize += sizeof(*cauxv);
1022
   }
1023
1024
   /* OK, now we know how big the client stack is */
1025
   stacksize =
1026
      sizeof(int) +			/* argc */
1027
      sizeof(char **)*argc +		/* argv */
1028
      sizeof(char **) +			/* terminal NULL */
1029
      sizeof(char **)*envc +		/* envp */
1030
      sizeof(char **) +			/* terminal NULL */
1031
      auxsize +				/* auxv */
1032
      ROUNDUP(stringsize, sizeof(int)) +/* strings (aligned) */
1033
      VKI_BYTES_PER_PAGE;		/* page for trampoline code */
1034
1035
   /* cl_esp is the client's stack pointer */
1036
   cl_esp = VG_(client_end) - stacksize;
1037
   cl_esp = ROUNDDN(cl_esp, 16); /* make stack 16 byte aligned */
1038
1039
   if (0)
1040
      printf("stringsize=%d auxsize=%d stacksize=%d\n",
1041
	     stringsize, auxsize, stacksize);
1042
1043
1044
   /* base of the string table (aligned) */
1045
   stringbase = strtab = (char *)(VG_(client_trampoline_code) - ROUNDUP(stringsize, sizeof(int)));
1046
1047
   VG_(clstk_base) = PGROUNDDN(cl_esp);
1048
   VG_(clstk_end)  = VG_(client_end);
1049
1050
   /* ==================== allocate space ==================== */
1051
1052
   /* allocate a stack - mmap enough space for the stack */
1053
   mmap((void *)PGROUNDDN(cl_esp),
1054
	VG_(client_end) - PGROUNDDN(cl_esp),
1055
	PROT_READ | PROT_WRITE | PROT_EXEC, 
1056
	MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
1057
   
290
1058
291
   /* This thread's LDT pointer, and segment registers. */
1059
   /* ==================== copy client stack ==================== */
292
   VGOFF_(ldt)   = alloc_BaB(1);
293
   VGOFF_(m_cs)  = alloc_BaB(1);
294
   VGOFF_(m_ss)  = alloc_BaB(1);
295
   VGOFF_(m_ds)  = alloc_BaB(1);
296
   VGOFF_(m_es)  = alloc_BaB(1);
297
   VGOFF_(m_fs)  = alloc_BaB(1);
298
   VGOFF_(m_gs)  = alloc_BaB(1);
299
1060
300
   VG_(register_noncompact_helper)( (Addr) & VG_(do_useseg) );
1061
   ptr = (addr_t *)cl_esp;
301
1062
302
#define REG(kind, size) \
1063
   /* --- argc --- */
303
   if (VG_(track_events).kind##_mem_stack##size) \
1064
   *ptr++ = argc;		/* client argc */
304
      VG_(register_noncompact_helper)(           \
305
          (Addr) VG_(track_events).kind##_mem_stack##size );
306
1065
307
   REG(new, _8);
1066
   /* --- argv --- */
308
   REG(new, _12);
1067
   if (info->argv0) {
309
   REG(new, _16);
1068
      *ptr++ = (addr_t)copy_str(&strtab, info->argv0);
310
   REG(new, _32);
1069
      free(info->argv0);
311
   REG(new, );
1070
   }
312
   REG(die, _8);
1071
   if (info->argv1) {
313
   REG(die, _12);
1072
      *ptr++ = (addr_t)copy_str(&strtab, info->argv1);
314
   REG(die, _16);
1073
      free(info->argv1);
315
   REG(die, _32);
1074
   }
316
   REG(die, );
1075
   for (cpp = orig_argv; *cpp; ptr++, cpp++) {
317
#undef REG
1076
      *ptr = (addr_t)copy_str(&strtab, *cpp);
1077
   }
1078
   *ptr++ = 0;
1079
1080
   /* --- envp --- */
1081
   VG_(client_envp) = (Char **)ptr;
1082
   for (cpp = orig_envp; cpp && *cpp; ptr++, cpp++)
1083
      *ptr = (addr_t)copy_str(&strtab, *cpp);
1084
   *ptr++ = 0;
1085
1086
   /* --- auxv --- */
1087
   auxv = (struct ume_auxv *)ptr;
1088
   *client_auxv = (UInt *)auxv;
1089
1090
   for (; orig_auxv->a_type != AT_NULL; auxv++, orig_auxv++) {
1091
      /* copy the entry... */
1092
      *auxv = *orig_auxv;
1093
1094
      /* ...and fix up the copy */
1095
      switch(auxv->a_type) {
1096
      case AT_PHDR:
1097
	 if (info->phdr == 0)
1098
	    auxv->a_type = AT_IGNORE;
1099
	 else
1100
	    auxv->u.a_val = info->phdr;
1101
	 break;
318
1102
319
   if (VG_(need_to_handle_esp_assignment)())
1103
      case AT_PHNUM:
320
      VG_(register_noncompact_helper)((Addr) VG_(unknown_esp_update));
1104
	 if (info->phdr == 0)
1105
	    auxv->a_type = AT_IGNORE;
1106
	 else
1107
	    auxv->u.a_val = info->phnum;
1108
	 break;
321
1109
322
   /* Helper functions. */
1110
      case AT_BASE:
323
   VGOFF_(helper_idiv_64_32)
1111
	 if (info->interp_base == 0)
324
      = alloc_BaB_1_set( (Addr) & VG_(helper_idiv_64_32));
1112
	    auxv->a_type = AT_IGNORE;
325
   VGOFF_(helper_div_64_32)
1113
	 else
326
      = alloc_BaB_1_set( (Addr) & VG_(helper_div_64_32));
1114
	    auxv->u.a_val = info->interp_base;
327
   VGOFF_(helper_idiv_32_16)
1115
	 break;
328
      = alloc_BaB_1_set( (Addr) & VG_(helper_idiv_32_16));
329
   VGOFF_(helper_div_32_16)
330
      = alloc_BaB_1_set( (Addr) & VG_(helper_div_32_16));
331
   VGOFF_(helper_idiv_16_8)
332
      = alloc_BaB_1_set( (Addr) & VG_(helper_idiv_16_8));
333
   VGOFF_(helper_div_16_8)
334
      = alloc_BaB_1_set( (Addr) & VG_(helper_div_16_8));
335
336
   VGOFF_(helper_imul_32_64)
337
      = alloc_BaB_1_set( (Addr) & VG_(helper_imul_32_64));
338
   VGOFF_(helper_mul_32_64)
339
      = alloc_BaB_1_set( (Addr) & VG_(helper_mul_32_64));
340
   VGOFF_(helper_imul_16_32)
341
      = alloc_BaB_1_set( (Addr) & VG_(helper_imul_16_32));
342
   VGOFF_(helper_mul_16_32)
343
      = alloc_BaB_1_set( (Addr) & VG_(helper_mul_16_32));
344
   VGOFF_(helper_imul_8_16)
345
      = alloc_BaB_1_set( (Addr) & VG_(helper_imul_8_16));
346
   VGOFF_(helper_mul_8_16)
347
      = alloc_BaB_1_set( (Addr) & VG_(helper_mul_8_16));
348
349
   VGOFF_(helper_CLD)
350
      = alloc_BaB_1_set( (Addr) & VG_(helper_CLD));
351
   VGOFF_(helper_STD)
352
      = alloc_BaB_1_set( (Addr) & VG_(helper_STD));
353
   VGOFF_(helper_get_dirflag)
354
      = alloc_BaB_1_set( (Addr) & VG_(helper_get_dirflag));
355
356
   VGOFF_(helper_CLC)
357
      = alloc_BaB_1_set( (Addr) & VG_(helper_CLC));
358
   VGOFF_(helper_STC)
359
      = alloc_BaB_1_set( (Addr) & VG_(helper_STC));
360
361
   VGOFF_(helper_shldl)
362
      = alloc_BaB_1_set( (Addr) & VG_(helper_shldl));
363
   VGOFF_(helper_shldw)
364
      = alloc_BaB_1_set( (Addr) & VG_(helper_shldw));
365
   VGOFF_(helper_shrdl)
366
      = alloc_BaB_1_set( (Addr) & VG_(helper_shrdl));
367
   VGOFF_(helper_shrdw)
368
      = alloc_BaB_1_set( (Addr) & VG_(helper_shrdw));
369
370
   VGOFF_(helper_RDTSC)
371
      = alloc_BaB_1_set( (Addr) & VG_(helper_RDTSC));
372
   VGOFF_(helper_CPUID)
373
      = alloc_BaB_1_set( (Addr) & VG_(helper_CPUID));
374
375
   VGOFF_(helper_bsf)
376
      = alloc_BaB_1_set( (Addr) & VG_(helper_bsf));
377
   VGOFF_(helper_bsr)
378
      = alloc_BaB_1_set( (Addr) & VG_(helper_bsr));
379
380
   VGOFF_(helper_fstsw_AX)
381
      = alloc_BaB_1_set( (Addr) & VG_(helper_fstsw_AX));
382
   VGOFF_(helper_SAHF)
383
      = alloc_BaB_1_set( (Addr) & VG_(helper_SAHF));
384
   VGOFF_(helper_LAHF)
385
      = alloc_BaB_1_set( (Addr) & VG_(helper_LAHF));
386
   VGOFF_(helper_DAS)
387
      = alloc_BaB_1_set( (Addr) & VG_(helper_DAS));
388
   VGOFF_(helper_DAA)
389
      = alloc_BaB_1_set( (Addr) & VG_(helper_DAA));
390
   VGOFF_(helper_IN)
391
      = alloc_BaB_1_set( (Addr) & VG_(helper_IN));
392
   VGOFF_(helper_OUT)
393
      = alloc_BaB_1_set( (Addr) & VG_(helper_OUT));
394
1116
395
   VGOFF_(helper_undefined_instruction)
1117
      case AT_PLATFORM:		/* points to a platform description string */
396
      = alloc_BaB_1_set( (Addr) & VG_(helper_undefined_instruction));
1118
	 auxv->u.a_ptr = copy_str(&strtab, orig_auxv->u.a_ptr);
1119
	 break;
397
1120
398
   /* Allocate slots for noncompact helpers */
1121
      case AT_ENTRY:
399
   assign_helpers_in_baseBlock(VG_(n_noncompact_helpers), 
1122
	 auxv->u.a_val = info->entry;
400
                               VG_(noncompact_helper_offsets), 
1123
	 break;
401
                               VG_(noncompact_helper_addrs));
402
1124
1125
      case AT_IGNORE:
1126
      case AT_EXECFD:
1127
      case AT_PHENT:
1128
      case AT_PAGESZ:
1129
      case AT_FLAGS:
1130
      case AT_NOTELF:
1131
      case AT_UID:
1132
      case AT_EUID:
1133
      case AT_GID:
1134
      case AT_EGID:
1135
      case AT_CLKTCK:
1136
      case AT_HWCAP:
1137
      case AT_FPUCW:
1138
      case AT_DCACHEBSIZE:
1139
      case AT_ICACHEBSIZE:
1140
      case AT_UCACHEBSIZE:
1141
	 /* All these are pointerless, so we don't need to do anything
1142
	    about them. */
1143
	 break;
403
1144
404
   /* Initialise slots that require it */
1145
      case AT_SECURE:
405
   VG_(copy_m_state_static_to_baseBlock)();
1146
	 /* If this is 1, then it means that this program is running
1147
	    suid, and therefore the dynamic linker should be careful
1148
	    about LD_PRELOAD, etc.  However, since stage1 (the thing
1149
	    the kernel actually execve's) should never be SUID, and we
1150
	    need LD_PRELOAD/LD_LIBRARY_PATH to work for the client, we
1151
	    set AT_SECURE to 0. */
1152
	 auxv->u.a_val = 0;
1153
	 break;
406
1154
407
   /* Pretend the root thread has a completely empty LDT to start with. */
1155
      case AT_SYSINFO:
408
   VG_(baseBlock)[VGOFF_(ldt)] = (UInt)NULL;
1156
	 /* Leave this unmolested for now, but we'll update it later
1157
	    when we set up the client trampoline code page */
1158
	 break;
409
1159
410
   /* Initialise shadow regs */
1160
      case AT_SYSINFO_EHDR:
411
   if (VG_(needs).shadow_regs) {
1161
	 /* Trash this, because we don't reproduce it */
412
      VG_(baseBlock)[VGOFF_(sh_esp)]    = 
1162
	 auxv->a_type = AT_IGNORE;
413
      VG_(baseBlock)[VGOFF_(sh_ebp)]    =
1163
	 break;
414
      VG_(baseBlock)[VGOFF_(sh_eax)]    =
1164
415
      VG_(baseBlock)[VGOFF_(sh_ecx)]    =
1165
      default:
416
      VG_(baseBlock)[VGOFF_(sh_edx)]    =
1166
	 /* stomp out anything we don't know about */
417
      VG_(baseBlock)[VGOFF_(sh_ebx)]    =
1167
	 if (0)
418
      VG_(baseBlock)[VGOFF_(sh_esi)]    =
1168
	    printf("stomping auxv entry %d\n", auxv->a_type);
419
      VG_(baseBlock)[VGOFF_(sh_edi)]    = 0;
1169
	 auxv->a_type = AT_IGNORE;
420
      VG_(baseBlock)[VGOFF_(sh_eflags)] = 0;
1170
	 break;
421
      VG_TRACK( post_regs_write_init );
1171
	 
1172
      }
422
   }
1173
   }
423
}
1174
   *auxv = *orig_auxv;
1175
   vg_assert(auxv->a_type == AT_NULL);
424
1176
1177
   vg_assert((strtab-stringbase) == stringsize);
425
1178
426
/* ---------------------------------------------------------------------
1179
   return cl_esp;
427
   Global entities which are not referenced from generated code.
1180
}
428
   ------------------------------------------------------------------ */
429
1181
430
/* The stack on which Valgrind runs.  We can't use the same stack as
1182
/*====================================================================*/
431
   the simulatee -- that's an important design decision.  */
1183
/*=== Find executable                                              ===*/
432
UInt VG_(stack)[VG_STACK_SIZE_W];
1184
/*====================================================================*/
433
1185
434
/* Ditto our signal delivery stack. */
1186
static const char* find_executable(const char* exec)
435
UInt VG_(sigstack)[VG_SIGSTACK_SIZE_W];
1187
{
1188
   vg_assert(NULL != exec);
1189
   if (strchr(exec, '/') == NULL) {
1190
      /* no '/' - we need to search the path */
1191
      char *path = getenv("PATH");
1192
      int pathlen = path ? strlen(path) : 0;
436
1193
437
/* Saving stuff across system calls. */
1194
      int match_exe(const char *entry) {
438
__attribute__ ((aligned (16)))
1195
         char buf[pathlen + strlen(entry) + 3];
439
UInt VG_(real_sse_state_saved_over_syscall)[VG_SIZE_OF_SSESTATE_W];
440
Addr VG_(esp_saved_over_syscall);
441
1196
442
/* Counts downwards in vg_run_innerloop. */
1197
         /* empty PATH element means . */
443
UInt VG_(dispatch_ctr);
1198
         if (*entry == '\0')
1199
            entry = ".";
444
1200
1201
         snprintf(buf, sizeof(buf), "%s/%s", entry, exec);
445
1202
446
/* 64-bit counter for the number of basic blocks done. */
1203
         if (access(buf, R_OK|X_OK) == 0) {
447
ULong VG_(bbs_done);
1204
            exec = strdup(buf);
448
/* 64-bit counter for the number of bbs to go before a debug exit. */
1205
            vg_assert(NULL != exec);
449
ULong VG_(bbs_to_go);
1206
            return 1;
1207
         }
1208
         return 0;
1209
      }
1210
      scan_colsep(path, match_exe);
1211
   }
1212
   return exec;
1213
}
450
1214
451
/* This is the ThreadId of the last thread the scheduler ran. */
452
ThreadId VG_(last_run_tid) = 0;
453
1215
454
/* This is the argument to __NR_exit() supplied by the first thread to
1216
/*====================================================================*/
455
   call that syscall.  We eventually pass that to __NR_exit() for
1217
/*=== Loading tools                                                ===*/
456
   real. */
1218
/*====================================================================*/
457
Int VG_(exitcode) = 0;
458
1219
459
/* Tell the logging mechanism whether we are logging to a file
1220
static void list_tools(void)
460
   descriptor or a socket descriptor. */
1221
{
461
Bool VG_(logging_to_filedes) = True;
1222
   DIR *dir = opendir(VG_(libdir));
1223
   struct dirent *de;
1224
   int first = 1;
462
1225
463
/* Is this a SSE/SSE2-capable CPU?  If so, we had better save/restore
1226
   if (dir == NULL) {
464
   the SSE state all over the place.  This is set up very early, in
1227
      fprintf(stderr, "Can't open %s: %s (installation problem?)\n",
465
   vg_startup.S.  We have to determine it early since we can't even
1228
	      VG_(libdir), strerror(errno));
466
   correctly snapshot the startup machine state without it. */
1229
      return;
467
/* Initially True.  Safer to err on the side of SSEness and get SIGILL
1230
   }
468
   than to not notice for some reason that we have SSE and get weird
469
   errors later on. */
470
Bool VG_(have_ssestate) = True;
471
1231
1232
   while((de = readdir(dir)) != NULL) {
1233
      int len = strlen(de->d_name);
472
1234
473
/* ---------------------------------------------------------------------
1235
      /* look for vgskin_TOOL.so names */
474
   Counters, for informational purposes only.
1236
      if (len > (7+1+3) &&   /* "vgskin_" + at least 1-char toolname + ".so" */
475
   ------------------------------------------------------------------ */
1237
	  strncmp(de->d_name, "vgskin_", 7) == 0 &&
1238
	  VG_STREQ(de->d_name + len - 3, ".so")) {
1239
	 if (first) {
1240
	    printf("Available tools:\n");
1241
	    first = 0;
1242
	 }
1243
	 de->d_name[len-3] = '\0';
1244
	 printf("\t%s\n", de->d_name+7);
1245
      }
1246
   }
476
1247
477
/* Number of lookups which miss the fast tt helper. */
1248
   closedir(dir);
478
UInt VG_(tt_fast_misses) = 0;
479
1249
1250
   if (first)
1251
      printf("No tools available in \"%s\" (installation problem?)\n",
1252
	     VG_(libdir));
1253
}
480
1254
481
/* Counts for TT/TC informational messages. */
482
1255
483
/* Number and total o/t size of translations overall. */
1256
/* Find and load a tool, and check it looks ok.  Also looks to see if there's 
484
UInt VG_(overall_in_count) = 0;
1257
 * a matching vgpreload_*.so file, and returns its name in *preloadpath. */
485
UInt VG_(overall_in_osize) = 0;
1258
static void load_tool( const char *toolname, void** handle_out,
486
UInt VG_(overall_in_tsize) = 0;
1259
                       ToolInfo** toolinfo_out, char **preloadpath_out )
487
/* Number and total o/t size of discards overall. */
1260
{
488
UInt VG_(overall_out_count) = 0;
1261
   Bool      ok;
489
UInt VG_(overall_out_osize) = 0;
1262
   int       len = strlen(VG_(libdir)) + strlen(toolname)*2 + 16;
490
UInt VG_(overall_out_tsize) = 0;
1263
   char      buf[len];
491
/* The number of discards of TT/TC. */
1264
   void*     handle;
492
UInt VG_(number_of_tc_discards) = 0;
1265
   ToolInfo* toolinfo;
493
/* Counts of chain and unchain operations done. */
1266
   char*     preloadpath = NULL;
494
UInt VG_(bb_enchain_count) = 0;
1267
   Int*      vg_malloc_redzonep;
495
UInt VG_(bb_dechain_count) = 0;
496
/* Number of unchained jumps performed. */
497
UInt VG_(unchained_jumps_done) = 0;
498
1268
1269
   // XXX: allowing full paths for --tool option -- does it make sense?
1270
   // Doesn't allow for vgpreload_<tool>.so.
499
1271
500
/* Counts pertaining to the register allocator. */
1272
   if (strchr(toolname, '/') != 0) {
1273
      /* toolname contains '/', and so must be a pathname */
1274
      handle = dlopen(toolname, RTLD_NOW);
1275
   } else {
1276
      /* just try in the libdir */
1277
      snprintf(buf, len, "%s/vgskin_%s.so", VG_(libdir), toolname);
1278
      handle = dlopen(buf, RTLD_NOW);
1279
1280
      if (handle != NULL) {
1281
	 snprintf(buf, len, "%s/vgpreload_%s.so", VG_(libdir), toolname);
1282
	 if (access(buf, R_OK) == 0) {
1283
	    preloadpath = strdup(buf);
1284
            vg_assert(NULL != preloadpath);
1285
         }
1286
      }
1287
   }
501
1288
502
/* total number of uinstrs input to reg-alloc */
1289
   ok = (NULL != handle);
503
UInt VG_(uinstrs_prealloc) = 0;
1290
   if (!ok) {
1291
      fprintf(stderr, "Can't open tool \"%s\": %s\n", toolname, dlerror());
1292
      goto bad_load;
1293
   }
1294
1295
   toolinfo = dlsym(handle, "vgSkin_tool_info");
1296
   ok = (NULL != toolinfo);
1297
   if (!ok) {
1298
      fprintf(stderr, "Tool \"%s\" doesn't define SK_(tool_info) - "
1299
                      "add VG_DETERMINE_INTERFACE_VERSION?\n", toolname);
1300
      goto bad_load;
1301
   }
1302
1303
   ok = (toolinfo->sizeof_ToolInfo == sizeof(*toolinfo) &&
1304
     toolinfo->interface_major_version == VG_CORE_INTERFACE_MAJOR_VERSION &&
1305
     toolinfo->sk_pre_clo_init != NULL);
1306
   if (!ok) { 
1307
      fprintf(stderr, "Error:\n"
1308
              "  Tool and core interface versions do not match.\n"
1309
              "  Interface version used by core is: %d.%d (size %d)\n"
1310
              "  Interface version used by tool is: %d.%d (size %d)\n"
1311
              "  The major version numbers must match.\n",
1312
              VG_CORE_INTERFACE_MAJOR_VERSION, 
1313
              VG_CORE_INTERFACE_MINOR_VERSION,
1314
              sizeof(*toolinfo),
1315
              toolinfo->interface_major_version,
1316
              toolinfo->interface_minor_version, 
1317
              toolinfo->sizeof_ToolInfo);
1318
      fprintf(stderr, "  You need to at least recompile, and possibly update,\n");
1319
      if (VG_CORE_INTERFACE_MAJOR_VERSION > toolinfo->interface_major_version)
1320
         fprintf(stderr, "  your skin to work with this version of Valgrind.\n");
1321
      else
1322
         fprintf(stderr, "  your version of Valgrind to work with this skin.\n");
1323
      goto bad_load;
1324
   }
504
1325
505
/* total number of uinstrs added due to spill code */
1326
   // Set redzone size for V's allocator
506
UInt VG_(uinstrs_spill) = 0;
1327
   vg_malloc_redzonep = dlsym(handle, STR(VG_(vg_malloc_redzone_szB)));
1328
   if ( NULL != vg_malloc_redzonep ) {
1329
      VG_(vg_malloc_redzone_szB) = *vg_malloc_redzonep;
1330
   }
507
1331
508
/* number of bbs requiring spill code */
1332
   vg_assert(NULL != handle && NULL != toolinfo);
509
UInt VG_(translations_needing_spill) = 0;
1333
   *handle_out      = handle;
1334
   *toolinfo_out    = toolinfo;
1335
   *preloadpath_out = preloadpath;
1336
   return;
510
1337
511
/* total of register ranks over all translations */
512
UInt VG_(total_reg_rank) = 0;
513
1338
1339
 bad_load:
1340
   if (handle != NULL)
1341
      dlclose(handle);
1342
1343
   fprintf(stderr, "Aborting: couldn't load tool\n");
1344
   list_tools();
1345
   exit(127);
1346
}
1347
1348
/*====================================================================*/
1349
/*=== Loading the client                                           ===*/
1350
/*====================================================================*/
1351
1352
static void load_client(char* cl_argv[], const char* exec,    
1353
                 /*inout*/Int* need_help,
1354
                 /*out*/struct exeinfo* info, /*out*/Addr* client_eip)
1355
{
1356
   // If they didn't specify an executable with --exec, and didn't specify 
1357
   // --help, then use client argv[0] (searching $PATH if necessary).
1358
   if (NULL == exec && !*need_help) {
1359
      if (cl_argv[0] == NULL || 
1360
          ( NULL == (exec = find_executable(cl_argv[0])) ) )
1361
      {
1362
         *need_help = 1;
1363
      }
1364
   }
514
1365
515
/* Counts pertaining to internal sanity checking. */
1366
   info->map_base = VG_(client_mapbase);
516
UInt VG_(sanity_fast_count) = 0;
1367
   info->setbrk   = False;
517
UInt VG_(sanity_slow_count) = 0;
518
1368
519
/* Counts pertaining to the scheduler. */
1369
   info->exe_base = VG_(client_base);
520
UInt VG_(num_scheduling_events_MINOR) = 0;
1370
   info->exe_end  = VG_(client_end);
521
UInt VG_(num_scheduling_events_MAJOR) = 0;
1371
   info->argv     = cl_argv;
1372
1373
   if (*need_help) {
1374
      VG_(clexecfd) = -1;
1375
      info->argv0 = NULL;
1376
      info->argv1 = NULL;
1377
   } else {
1378
      Int ret;
1379
      VG_(clexecfd) = VG_(open)(exec, O_RDONLY, VKI_S_IRUSR);
1380
      ret = do_exec(exec, info);
1381
      if (ret != 0) {
1382
         fprintf(stderr, "do_exec(%s) failed: %s\n", exec, strerror(ret));
1383
         exit(127);
1384
      }
1385
   }
522
1386
1387
   /* Copy necessary bits of 'info' that were filled in */
1388
   *client_eip = info->init_eip;
1389
   VG_(brk_base) = VG_(brk_limit) = info->brkbase;
1390
}
523
1391
524
/* ---------------------------------------------------------------------
1392
525
   Values derived from command-line options.
1393
/*====================================================================*/
526
   ------------------------------------------------------------------ */
1394
/*=== Command-line: variables, processing                          ===*/
1395
/*====================================================================*/
527
1396
528
/* Define, and set defaults. */
1397
/* Define, and set defaults. */
529
Bool   VG_(clo_error_limit)    = True;
1398
Bool   VG_(clo_error_limit)    = True;
530
Bool   VG_(clo_GDB_attach)     = False;
1399
Bool   VG_(clo_db_attach)      = False;
531
Char*  VG_(clo_GDB_path)       = GDB_PATH;
1400
Char*  VG_(clo_db_command)     = VG_CLO_DEFAULT_DBCOMMAND;
532
Bool   VG_(clo_gen_suppressions) = False;
1401
Bool   VG_(clo_gen_suppressions) = False;
533
Int    VG_(sanity_level)       = 1;
1402
Int    VG_(sanity_level)       = 1;
534
Int    VG_(clo_verbosity)      = 1;
1403
Int    VG_(clo_verbosity)      = 1;
Lines 554-560 Link Here
554
Bool   VG_(clo_trace_symtab)   = False;
1423
Bool   VG_(clo_trace_symtab)   = False;
555
Bool   VG_(clo_trace_sched)    = False;
1424
Bool   VG_(clo_trace_sched)    = False;
556
Int    VG_(clo_trace_pthread_level) = 0;
1425
Int    VG_(clo_trace_pthread_level) = 0;
557
ULong  VG_(clo_stop_after)     = 1000000000000000LL;
558
Int    VG_(clo_dump_error)     = 0;
1426
Int    VG_(clo_dump_error)     = 0;
559
Int    VG_(clo_backtrace_size) = 4;
1427
Int    VG_(clo_backtrace_size) = 4;
560
Char*  VG_(clo_weird_hacks)    = NULL;
1428
Char*  VG_(clo_weird_hacks)    = NULL;
Lines 562-567 Link Here
562
Bool   VG_(clo_track_fds)      = False;
1430
Bool   VG_(clo_track_fds)      = False;
563
Bool   VG_(clo_chain_bb)       = True;
1431
Bool   VG_(clo_chain_bb)       = True;
564
Bool   VG_(clo_show_below_main) = False;
1432
Bool   VG_(clo_show_below_main) = False;
1433
Bool   VG_(clo_pointercheck)   = True;
1434
Bool   VG_(clo_branchpred)     = False;
565
1435
566
static Bool   VG_(clo_wait_for_gdb)   = False;
1436
static Bool   VG_(clo_wait_for_gdb)   = False;
567
1437
Lines 574-604 Link Here
574
Bool   VG_(clo_lowlat_syscalls) = False; /* low-latency syscalls */
1444
Bool   VG_(clo_lowlat_syscalls) = False; /* low-latency syscalls */
575
Bool   VG_(clo_lowlat_signals)  = False; /* low-latency signals */
1445
Bool   VG_(clo_lowlat_signals)  = False; /* low-latency signals */
576
1446
577
/* This Bool is needed by wrappers in vg_clientmalloc.c to decide how
578
   to behave.  Initially we say False. */
579
Bool VG_(running_on_simd_CPU) = False;
580
581
/* Holds client's %esp at the point we gained control. */
582
Addr VG_(esp_at_startup);
583
584
/* Indicates presence, and holds address of client's sysinfo page, a
585
   feature of some modern kernels used to provide vsyscalls, etc. */
586
Bool VG_(sysinfo_page_exists) = False;
587
Addr VG_(sysinfo_page_addr) = 0;
588
589
/* As deduced from VG_(esp_at_startup), the client's argc, argv[] and
590
   envp[] as extracted from the client's stack at startup-time. */
591
Int    VG_(client_argc);
592
Char** VG_(client_argv);
593
Char** VG_(client_envp);
594
595
/* A place into which to copy the value of env var VG_ARGS, so we
596
   don't have to modify the original. */
597
static Char vg_cmdline_copy[M_VG_CMDLINE_STRLEN];
598
599
/* ---------------------------------------------------------------------
600
   Processing of command-line options.
601
   ------------------------------------------------------------------ */
602
1447
603
void VG_(bad_option) ( Char* opt )
1448
void VG_(bad_option) ( Char* opt )
604
{
1449
{
Lines 615-644 Link Here
615
   VG_(clo_log_to)     = VgLogTo_Fd;
1460
   VG_(clo_log_to)     = VgLogTo_Fd;
616
   VG_(clo_logfile_fd) = 2; /* stderr */
1461
   VG_(clo_logfile_fd) = 2; /* stderr */
617
   VG_(printf)(
1462
   VG_(printf)(
618
      "valgrind.so: Startup or configuration error:\n   %s\n", msg);
1463
      "valgrind: Startup or configuration error:\n   %s\n", msg);
619
   VG_(printf)(
1464
   VG_(printf)(
620
      "valgrind.so: Unable to start up properly.  Giving up.\n");
1465
      "valgrind: Unable to start up properly.  Giving up.\n");
621
   VG_(exit)(1);
1466
   VG_(exit)(1);
622
}
1467
}
623
1468
624
static void args_grok_error ( Char* msg )
1469
void usage ( Bool debug_help )
625
{
626
   VG_(shutdown_logging)();
627
   VG_(clo_log_to)     = VgLogTo_Fd;
628
   VG_(clo_logfile_fd) = 2; /* stderr */
629
   VG_(printf)("valgrind.so: When searching for "
630
               "client's argc/argc/envp:\n\t%s\n", msg);
631
   config_error("couldn't find client's argc/argc/envp");
632
}   
633
634
static void usage ( void )
635
{
1470
{
636
   Char* usage1 = 
1471
   Char* usage1 = 
637
"usage: valgrind [options] prog-and-args\n"
1472
"usage: valgrind --tool=<toolname> [options] prog-and-args\n"
638
"\n"
1473
"\n"
639
"  common user options for all Valgrind tools, with defaults in [ ]:\n"
1474
"  common user options for all Valgrind tools, with defaults in [ ]:\n"
640
"    --tool=<name>             Use the Valgrind tool named <name> [memcheck]\n"
1475
"    --tool=<name>             Use the Valgrind tool named <name>\n"
641
"    --help                    show this message\n"
1476
"    --help                    show this message\n"
1477
"    --help-debug              show this message, plus debugging options\n"
642
"    --version                 show version\n"
1478
"    --version                 show version\n"
643
"    -q --quiet                run silently; only print error msgs\n"
1479
"    -q --quiet                run silently; only print error msgs\n"
644
"    -v --verbose              be more verbose, incl counts of errors\n"
1480
"    -v --verbose              be more verbose, incl counts of errors\n"
Lines 656-661 Link Here
656
"			       a signal [no]\n"
1492
"			       a signal [no]\n"
657
"    --lowlat-syscalls=no|yes  improve wake-up latency when a thread's\n"
1493
"    --lowlat-syscalls=no|yes  improve wake-up latency when a thread's\n"
658
"			       syscall completes [no]\n"
1494
"			       syscall completes [no]\n"
1495
"    --pointercheck=no|yes     enforce client address space limits [yes]\n"
659
"\n"
1496
"\n"
660
"  user options for Valgrind tools that report errors:\n"
1497
"  user options for Valgrind tools that report errors:\n"
661
"    --logfile-fd=<number>     file descriptor for messages [2=stderr]\n"
1498
"    --logfile-fd=<number>     file descriptor for messages [2=stderr]\n"
Lines 668-678 Link Here
668
"    --suppressions=<filename> suppress errors described in <filename>\n"
1505
"    --suppressions=<filename> suppress errors described in <filename>\n"
669
"    --gen-suppressions=no|yes print suppressions for errors detected [no]\n"
1506
"    --gen-suppressions=no|yes print suppressions for errors detected [no]\n"
670
1507
671
"    --gdb-attach=no|yes       start GDB when errors detected? [no]\n"
1508
"    --db-attach=no|yes        start debugger when errors detected? [no]\n"
672
"    --gdb-path=/path/to/gdb   path to the GDB to use [/usr/bin/gdb]\n"
1509
"    --db-command=<command>    command to start debugger [gdb -nw %%f %%p]\n"
673
"    --input-fd=<number>       file descriptor for (gdb) input [0=stdin]\n"
1510
"    --input-fd=<number>       file descriptor for input [0=stdin]\n"
674
"\n"
1511
"\n";
675
"  user options for %s:\n";
676
1512
677
   Char* usage2 = 
1513
   Char* usage2 = 
678
"\n"
1514
"\n"
Lines 682-708 Link Here
682
"    --optimise=no|yes         improve intermediate code? [yes]\n"
1518
"    --optimise=no|yes         improve intermediate code? [yes]\n"
683
"    --profile=no|yes          profile? (tool must be built for it) [no]\n"
1519
"    --profile=no|yes          profile? (tool must be built for it) [no]\n"
684
"    --chain-bb=no|yes         do basic-block chaining? [yes]\n"
1520
"    --chain-bb=no|yes         do basic-block chaining? [yes]\n"
1521
"    --branchpred=yes|no       generate branch prediction hints [no]\n"
685
"    --trace-codegen=<XXXXX>   show generated code? (X = 0|1) [00000]\n"
1522
"    --trace-codegen=<XXXXX>   show generated code? (X = 0|1) [00000]\n"
686
"    --trace-syscalls=no|yes   show all system calls? [no]\n"
1523
"    --trace-syscalls=no|yes   show all system calls? [no]\n"
687
"    --trace-signals=no|yes    show signal handling details? [no]\n"
1524
"    --trace-signals=no|yes    show signal handling details? [no]\n"
688
"    --trace-symtab=no|yes     show symbol table details? [no]\n"
1525
"    --trace-symtab=no|yes     show symbol table details? [no]\n"
689
"    --trace-sched=no|yes      show thread scheduler details? [no]\n"
1526
"    --trace-sched=no|yes      show thread scheduler details? [no]\n"
690
"    --trace-pthread=none|some|all  show pthread event details? [none]\n"
1527
"    --trace-pthread=none|some|all  show pthread event details? [none]\n"
691
"    --stop-after=<number>     switch to real CPU after executing\n"
692
"                              <number> basic blocks [infinity]\n"
693
"    --wait-for-gdb=yes|no     pause on startup to wait for gdb attach\n"
1528
"    --wait-for-gdb=yes|no     pause on startup to wait for gdb attach\n"
694
"\n"
1529
"\n"
695
"  debugging options for Valgrind tools that report errors\n"
1530
"  debugging options for Valgrind tools that report errors\n"
696
"    --dump-error=<number>     show translation for basic block associated\n"
1531
"    --dump-error=<number>     show translation for basic block associated\n"
697
"                              with <number>'th error context [0=show none]\n"
1532
"                              with <number>'th error context [0=show none]\n"
698
"\n"
1533
"\n";
699
"  debugging options for %s:\n";
700
1534
701
   Char* usage3 =
1535
   Char* usage3 =
702
"\n"
1536
"\n"
703
"  Extra options are read from env variable $VALGRIND_OPTS\n"
1537
"  Extra options read from ~/.valgrindrc, $VALGRIND_OPTS, ./.valgrindrc\n"
704
"\n"
1538
"\n"
705
"  Valgrind is Copyright (C) 2000-2003 Julian Seward\n"
1539
"  Valgrind is Copyright (C) 2000-2004 Julian Seward\n"
706
"  and licensed under the GNU General Public License, version 2.\n"
1540
"  and licensed under the GNU General Public License, version 2.\n"
707
"  Bug reports, feedback, admiration, abuse, etc, to: %s.\n"
1541
"  Bug reports, feedback, admiration, abuse, etc, to: %s.\n"
708
"\n"
1542
"\n"
Lines 710-726 Link Here
710
"  tool's start-up message for more information.\n"
1544
"  tool's start-up message for more information.\n"
711
"\n";
1545
"\n";
712
1546
713
   VG_(printf)(usage1, VG_(details).name);
1547
   VG_(printf)(usage1);
714
   /* Don't print skin string directly for security, ha! */
1548
   if (VG_(details).name) {
715
   if (VG_(needs).command_line_options)
1549
      VG_(printf)("  user options for %s:\n", VG_(details).name);
716
      SK_(print_usage)();
1550
      /* Don't print skin string directly for security, ha! */
717
   else
1551
      if (VG_(needs).command_line_options)
718
      VG_(printf)("    (none)\n");
1552
	 SK_(print_usage)();
719
   VG_(printf)(usage2, VG_(details).name);
1553
      else
720
   if (VG_(needs).command_line_options)
1554
	 VG_(printf)("    (none)\n");
721
      SK_(print_debug_usage)();
1555
   }
722
   else
1556
   if (debug_help) {
723
      VG_(printf)("    (none)\n");
1557
      VG_(printf)(usage2);
1558
1559
      if (VG_(details).name) {
1560
         VG_(printf)("  debugging options for %s:\n", VG_(details).name);
1561
      
1562
         if (VG_(needs).command_line_options)
1563
            SK_(print_debug_usage)();
1564
         else
1565
            VG_(printf)("    (none)\n");
1566
      }
1567
   }
724
   VG_(printf)(usage3, VG_BUGS_TO);
1568
   VG_(printf)(usage3, VG_BUGS_TO);
725
1569
726
   VG_(shutdown_logging)();
1570
   VG_(shutdown_logging)();
Lines 729-768 Link Here
729
   VG_(exit)(1);
1573
   VG_(exit)(1);
730
}
1574
}
731
1575
1576
static void pre_process_cmd_line_options
1577
      ( Int* need_help, const char** tool, const char** exec )
1578
{
1579
   UInt i;
1580
1581
   /* parse the options we have (only the options we care about now) */
1582
   for (i = 1; i < VG_(vg_argc); i++) {
732
1583
733
/* Callback for looking for the stack segment. */
1584
      if (strcmp(VG_(vg_argv)[i], "--version") == 0) {
734
Addr VG_(foundstack_start) = (Addr)NULL;
1585
         printf("valgrind-" VERSION "\n");
735
UInt VG_(foundstack_size)  = 0;
1586
         exit(1);
1587
1588
      } else if (strcmp(VG_(vg_argv)[i], "--help") == 0) {
1589
         *need_help = 1;
1590
1591
      } else if (strcmp(VG_(vg_argv)[i], "--help-debug") == 0) {
1592
         *need_help = 2;
1593
1594
      } else if (strncmp(VG_(vg_argv)[i], "--tool=", 7) == 0 ||
1595
	         strncmp(VG_(vg_argv)[i], "--skin=", 7) == 0) {
1596
	 *tool = &VG_(vg_argv)[i][7];
1597
	 
1598
      } else if (strncmp(VG_(vg_argv)[i], "--exec=", 7) == 0) {
1599
	 *exec = &VG_(vg_argv)[i][7];
1600
      }
1601
   }
736
1602
737
static void vg_findstack_callback ( Addr start, UInt size, 
1603
   /* If no tool specified, can give usage message without loading tool */
738
                                    Char r, Char w, Char x, 
1604
   if (*tool == NULL) {
739
                                    UInt foffset, UChar* filename )
1605
      if (!need_help)
740
{
1606
	 list_tools();
741
   Addr lastword;
1607
      usage(/*help-debug?*/False);
742
   if (size == 0) return;
743
   if (r != 'r' || w != 'w' 
744
       /* || x != 'x'  --not necessarily so on x86-64*/
745
      ) return;
746
   lastword = start + size - 4;
747
   if (start <= VG_(esp_at_startup) 
748
       && VG_(esp_at_startup) <= lastword) {
749
      VG_(foundstack_start) = start;
750
      VG_(foundstack_size) = size;
751
      vg_assert(VG_(foundstack_size) > 0);
752
   }
1608
   }
753
}
1609
}
754
1610
755
1611
static void process_cmd_line_options 
756
1612
      ( UInt* client_auxv, Addr esp_at_startup, 
757
static void process_cmd_line_options ( void )
1613
        const char* toolname, Int need_help )
758
{
1614
{
759
   Char* argv[M_VG_CMDLINE_OPTS];
1615
   Int  i, eventually_logfile_fd;
760
   Int   argc;
1616
   Int *auxp;
761
   Char* p;
1617
   Int  toolname_len = VG_(strlen)(toolname);
762
   Char* str;
763
   Int   i, eventually_logfile_fd, ctr;
764
765
#  define ISSPACE(cc)      ((cc) == ' ' || (cc) == '\t' || (cc) == '\n')
766
1618
767
   /* log to stderr by default, but usage message goes to stdout */
1619
   /* log to stderr by default, but usage message goes to stdout */
768
   eventually_logfile_fd = 2; 
1620
   eventually_logfile_fd = 2; 
Lines 772-1069 Link Here
772
   VG_(startup_logging)();
1624
   VG_(startup_logging)();
773
1625
774
   /* Check for sane path in ./configure --prefix=... */
1626
   /* Check for sane path in ./configure --prefix=... */
775
   if (VG_(strlen)(VG_LIBDIR) < 1 
1627
   if (VG_LIBDIR[0] != '/') 
776
       || VG_LIBDIR[0] != '/') 
777
     config_error("Please use absolute paths in "
1628
     config_error("Please use absolute paths in "
778
                  "./configure --prefix=... or --libdir=...");
1629
                  "./configure --prefix=... or --libdir=...");
779
1630
780
   /* (Suggested by Fabrice Bellard ... )
1631
   for (auxp = client_auxv; auxp[0] != VKI_AT_NULL; auxp += 2) {
781
      We look for the Linux ELF table and go down until we find the
1632
      switch(auxp[0]) {
782
      envc & envp. It is not fool-proof, but these structures should
1633
      case VKI_AT_SYSINFO:
783
      change less often than the libc ones. */
1634
	 VG_(sysinfo_page_exists) = True;
784
   {
1635
	 auxp[1] = (Int)(VG_(client_trampoline_code) + VG_(tramp_syscall_offset));
785
       Int* sp;
1636
	 VG_(sysinfo_page_addr) = auxp[1];
786
1637
	 break;
787
       /* Look for the stack segment by parsing /proc/self/maps and
788
	  looking for a section bracketing VG_(esp_at_startup) which
789
	  has rwx permissions and no associated file.  Note that this uses
790
          the /proc/self/maps contents read at the start of VG_(main)(),
791
          and doesn't re-read /proc/self/maps. */
792
793
       VG_(parse_procselfmaps)( vg_findstack_callback );
794
795
       /* Now foundstack_start and foundstack_size should delimit the stack. */
796
       if (VG_(foundstack_size) == 0) {
797
          args_grok_error("Cannot determine stack segment "
798
                          "from /proc/self/maps");
799
       }
800
801
       if (0)
802
          VG_(printf)("stack segment is %p .. %p\n", 
803
                      VG_(foundstack_start), 
804
                      VG_(foundstack_start) + VG_(foundstack_size) - 4 );
805
806
       sp = (UInt*)(VG_(foundstack_start) + VG_(foundstack_size) );
807
       if ((((UInt)(sp)) % VKI_BYTES_PER_PAGE) != 0) {
808
          args_grok_error("Stack segment is not page aligned?!");
809
       }
810
811
       /* we locate: NEW_AUX_ENT(1, AT_PAGESZ, ELF_EXEC_PAGESIZE) in
812
          the elf interpreter table */
813
814
       sp -= 2;
815
       while (sp[0] != VKI_AT_PAGESZ || sp[1] != 4096) {
816
           /* VG_(printf)("trying %p\n", sp); */
817
           sp--;
818
       }
819
820
       if (sp[2] == VKI_AT_BASE 
821
           && sp[0] == VKI_AT_PAGESZ
822
           && sp[-2] == VKI_AT_PHNUM
823
           && sp[-4] == VKI_AT_PHENT
824
           && sp[-6] == VKI_AT_PHDR
825
           && sp[-6-1] == 0) {
826
          if (0)
827
             VG_(printf)("Looks like you've got a 2.2.X kernel here.\n");
828
          sp -= 6;
829
       } else
830
       if (sp[2] == VKI_AT_CLKTCK
831
           && sp[0] == VKI_AT_PAGESZ
832
           && sp[-2] == VKI_AT_HWCAP
833
           && sp[-2-1] == 0) {
834
          if (0)
835
             VG_(printf)("Looks like you've got a 2.4.X kernel here.\n");
836
          sp -= 2;
837
       } else
838
       if (sp[2] == VKI_AT_CLKTCK
839
           && sp[0] == VKI_AT_PAGESZ
840
           && sp[-2] == VKI_AT_HWCAP
841
           && sp[-4] == VKI_AT_SYSINFO
842
           && sp[-4-1] == 0) {
843
          if (0)
844
             VG_(printf)("Looks like you've got a 2.4.X kernel with "
845
                         "a sysinfo page at %x here.\n", sp[-3]);
846
	  VG_(sysinfo_page_exists) = True;
847
	  VG_(sysinfo_page_addr) = sp[-3];
848
          sp -= 4;
849
       } else
850
       if (sp[2] == VKI_AT_CLKTCK
851
           && sp[0] == VKI_AT_PAGESZ
852
           && sp[-2] == VKI_AT_HWCAP
853
           && sp[-4] == VKI_AT_USER_AUX_SEGMENT
854
           && sp[-4-1] == 0) {
855
          if (0)
856
             VG_(printf)("Looks like you've got a R-H Limbo 2.4.X "
857
                         "kernel here.\n");
858
          sp -= 4;
859
       } else
860
       if (sp[2] == VKI_AT_CLKTCK
861
           && sp[0] == VKI_AT_PAGESZ
862
           && sp[-2] == VKI_AT_HWCAP
863
           && sp[-2-20-1] == 0) {
864
          if (0)
865
             VG_(printf)("Looks like you've got a early 2.4.X kernel here.\n");
866
          sp -= 22;
867
       } else
868
       if (sp[2] == VKI_AT_CLKTCK
869
           && sp[0] == VKI_AT_PAGESZ
870
           && sp[-2] == VKI_AT_HWCAP
871
           && sp[-4-1] == 0) {
872
          if (0)
873
             VG_(printf)("Looks like a 2.5.43-2.5.67 kernel here.\n");
874
          sp -= 4;
875
       } else
876
       if (sp[2] == VKI_AT_CLKTCK
877
           && sp[0] == VKI_AT_PAGESZ
878
           && sp[-2] == VKI_AT_HWCAP
879
           && sp[-6] == VKI_AT_SYSINFO
880
           && sp[-6-1] == 0) {
881
          if (0)
882
             VG_(printf)("Looks like a >= 2.5.68 kernel with "
883
                         "a sysinfo page at %x here.\n", sp[-5]);
884
	  VG_(sysinfo_page_exists) = True;
885
	  VG_(sysinfo_page_addr) = sp[-5];
886
          sp -= 6;
887
       } else
888
         args_grok_error(
889
            "ELF frame does not look like 2.2.X or 2.4.X.\n   "
890
            "See kernel sources linux/fs/binfmt_elf.c to make sense of this."
891
         );
892
893
       sp--;
894
       if (*sp != 0)
895
	 args_grok_error("can't find NULL at end of env[]");
896
897
       /* sp now points to NULL at the end of env[] */
898
       ctr = 0;
899
       while (True) {
900
           sp --;
901
           if (*sp == 0) break;
902
           if (++ctr >= 2000)
903
              args_grok_error(
904
                 "suspiciously many (2000) env[] entries; giving up");
905
           
906
       }
907
       /* sp now points to NULL at the end of argv[] */
908
       VG_(client_envp) = (Char**)(sp+1);
909
910
       ctr = 0;
911
       VG_(client_argc) = 0;
912
       while (True) {
913
          sp--;
914
          if (*sp == VG_(client_argc))
915
             break;
916
          VG_(client_argc)++;
917
           if (++ctr >= 1000)
918
              args_grok_error(
919
                 "suspiciously many (1000) argv[] entries; giving up");
920
       }
921
922
       VG_(client_argv) = (Char**)(sp+1);
923
   }
924
925
   /* Now that VG_(client_envp) has been set, we can extract the args
926
      for Valgrind itself.  Copy into global var so that we don't have to
927
      write zeroes to the getenv'd value itself. */
928
   str = VG_(getenv)("VG_ARGS");
929
   argc = 0;
930
931
   if (!str) {
932
      config_error("Can't read options from env var VG_ARGS.");
933
   }
934
935
   if (VG_(strlen)(str) >= M_VG_CMDLINE_STRLEN-1) {
936
      config_error("Command line length exceeds M_CMDLINE_STRLEN.");
937
   }
938
   VG_(strcpy)(vg_cmdline_copy, str);
939
   str = NULL;
940
941
   p = &vg_cmdline_copy[0];
942
   while (True) {
943
      while (ISSPACE(*p)) { *p = 0; p++; }
944
      if (*p == 0) break;
945
      if (argc < M_VG_CMDLINE_OPTS-1) { 
946
         argv[argc] = p; argc++; 
947
      } else {
948
         config_error(
949
            "Found more than M_CMDLINE_OPTS command-line opts.");
950
      }
1638
      }
951
      while (*p != 0 && !ISSPACE(*p)) p++;
1639
   } 
952
   }
953
1640
954
   for (i = 0; i < argc; i++) {
1641
   if (need_help)
1642
      usage(/*--help-debug?*/need_help == 2);
955
1643
956
      if      (VG_CLO_STREQ(argv[i], "-v") ||
1644
   /* We know the initial ESP is pointing at argc/argv */
957
               VG_CLO_STREQ(argv[i], "--verbose"))
1645
   VG_(client_argc) = *(Int *)esp_at_startup;
1646
   VG_(client_argv) = (Char **)(esp_at_startup + sizeof(Int));
1647
1648
   for (i = 1; i < VG_(vg_argc); i++) {
1649
1650
      Char* arg = VG_(vg_argv)[i];
1651
1652
      // XXX: allow colons in options, for Josef
1653
1654
      /* Look for matching "--toolname:foo" */
1655
      if (VG_(strstr)(arg, ":")) {
1656
         if (VG_CLO_STREQN(2,            arg,                "--") && 
1657
             VG_CLO_STREQN(toolname_len, arg+2,              toolname) &&
1658
             VG_CLO_STREQN(1,            arg+2+toolname_len, ":"))
1659
         {
1660
            // prefix matches, convert "--toolname:foo" to "--foo"
1661
            if (0)
1662
               VG_(printf)("tool-specific arg: %s\n", arg);
1663
            arg += toolname_len + 1;
1664
            arg[0] = '-';
1665
            arg[1] = '-';
1666
1667
         } else {
1668
            // prefix doesn't match, skip to next arg
1669
            continue;
1670
         }
1671
      }
1672
      
1673
      /* Ignore these options - they've already been handled */
1674
      if (VG_CLO_STREQN(7, arg, "--tool=") ||
1675
	  VG_CLO_STREQN(7, arg, "--skin="))
1676
	 continue;
1677
      if (VG_CLO_STREQN(7, arg, "--exec="))
1678
	 continue;
1679
1680
      if (     VG_CLO_STREQ(arg, "--"))
1681
	 continue;
1682
      else if (VG_CLO_STREQ(arg, "-v") ||
1683
               VG_CLO_STREQ(arg, "--verbose"))
958
         VG_(clo_verbosity)++;
1684
         VG_(clo_verbosity)++;
959
      else if (VG_CLO_STREQ(argv[i], "-q") ||
1685
      else if (VG_CLO_STREQ(arg, "-q") ||
960
               VG_CLO_STREQ(argv[i], "--quiet"))
1686
               VG_CLO_STREQ(arg, "--quiet"))
961
         VG_(clo_verbosity)--;
1687
         VG_(clo_verbosity)--;
962
1688
963
      else if (VG_CLO_STREQ(argv[i], "--error-limit=yes"))
1689
      else if (VG_CLO_STREQ(arg, "--error-limit=yes"))
964
         VG_(clo_error_limit) = True;
1690
         VG_(clo_error_limit) = True;
965
      else if (VG_CLO_STREQ(argv[i], "--error-limit=no"))
1691
      else if (VG_CLO_STREQ(arg, "--error-limit=no"))
966
         VG_(clo_error_limit) = False;
1692
         VG_(clo_error_limit) = False;
967
1693
968
      else if (VG_CLO_STREQ(argv[i], "--gdb-attach=yes"))
1694
      else if (VG_CLO_STREQ(arg, "--db-attach=yes"))
969
         VG_(clo_GDB_attach) = True;
1695
         VG_(clo_db_attach) = True;
970
      else if (VG_CLO_STREQ(argv[i], "--gdb-attach=no"))
1696
      else if (VG_CLO_STREQ(arg, "--db-attach=no"))
971
         VG_(clo_GDB_attach) = False;
1697
         VG_(clo_db_attach) = False;
972
1698
973
      else if (VG_CLO_STREQN(11,argv[i], "--gdb-path="))
1699
      else if (VG_CLO_STREQN(13,arg, "--db-command="))
974
         VG_(clo_GDB_path) = &argv[i][11];
1700
         VG_(clo_db_command) = &arg[13];
975
1701
976
      else if (VG_CLO_STREQ(argv[i], "--gen-suppressions=yes"))
1702
      else if (VG_CLO_STREQ(arg, "--gen-suppressions=yes"))
977
         VG_(clo_gen_suppressions) = True;
1703
         VG_(clo_gen_suppressions) = True;
978
      else if (VG_CLO_STREQ(argv[i], "--gen-suppressions=no"))
1704
      else if (VG_CLO_STREQ(arg, "--gen-suppressions=no"))
979
         VG_(clo_gen_suppressions) = False;
1705
         VG_(clo_gen_suppressions) = False;
980
1706
981
      else if (VG_CLO_STREQ(argv[i], "--show-below-main=yes"))
1707
      else if (VG_CLO_STREQ(arg, "--show-below-main=yes"))
982
         VG_(clo_show_below_main) = True;
1708
         VG_(clo_show_below_main) = True;
983
      else if (VG_CLO_STREQ(argv[i], "--show-below-main=no"))
1709
      else if (VG_CLO_STREQ(arg, "--show-below-main=no"))
984
         VG_(clo_show_below_main) = False;
1710
         VG_(clo_show_below_main) = False;
985
1711
986
      else if (VG_CLO_STREQ(argv[i], "--demangle=yes"))
1712
      else if (VG_CLO_STREQ(arg, "--pointercheck=yes"))
1713
         VG_(clo_pointercheck) = True;
1714
      else if (VG_CLO_STREQ(arg, "--pointercheck=no"))
1715
         VG_(clo_pointercheck) = False;
1716
1717
      else if (VG_CLO_STREQ(arg, "--demangle=yes"))
987
         VG_(clo_demangle) = True;
1718
         VG_(clo_demangle) = True;
988
      else if (VG_CLO_STREQ(argv[i], "--demangle=no"))
1719
      else if (VG_CLO_STREQ(arg, "--demangle=no"))
989
         VG_(clo_demangle) = False;
1720
         VG_(clo_demangle) = False;
990
1721
991
      else if (VG_CLO_STREQ(argv[i], "--trace-children=yes"))
1722
      else if (VG_CLO_STREQ(arg, "--trace-children=yes"))
992
         VG_(clo_trace_children) = True;
1723
         VG_(clo_trace_children) = True;
993
      else if (VG_CLO_STREQ(argv[i], "--trace-children=no"))
1724
      else if (VG_CLO_STREQ(arg, "--trace-children=no"))
994
         VG_(clo_trace_children) = False;
1725
         VG_(clo_trace_children) = False;
995
1726
996
      else if (VG_CLO_STREQ(argv[i], "--run-libc-freeres=yes"))
1727
      else if (VG_CLO_STREQ(arg, "--run-libc-freeres=yes"))
997
         VG_(clo_run_libc_freeres) = True;
1728
         VG_(clo_run_libc_freeres) = True;
998
      else if (VG_CLO_STREQ(argv[i], "--run-libc-freeres=no"))
1729
      else if (VG_CLO_STREQ(arg, "--run-libc-freeres=no"))
999
         VG_(clo_run_libc_freeres) = False;
1730
         VG_(clo_run_libc_freeres) = False;
1000
1731
1001
      else if (VG_CLO_STREQ(argv[i], "--track-fds=yes"))
1732
      else if (VG_CLO_STREQ(arg, "--track-fds=yes"))
1002
         VG_(clo_track_fds) = True;
1733
         VG_(clo_track_fds) = True;
1003
      else if (VG_CLO_STREQ(argv[i], "--track-fds=no"))
1734
      else if (VG_CLO_STREQ(arg, "--track-fds=no"))
1004
         VG_(clo_track_fds) = False;
1735
         VG_(clo_track_fds) = False;
1005
1736
1006
      else if (VG_CLO_STREQN(15, argv[i], "--sanity-level="))
1737
      else if (VG_CLO_STREQN(15, arg, "--sanity-level="))
1007
         VG_(sanity_level) = (Int)VG_(atoll)(&argv[i][15]);
1738
         VG_(sanity_level) = (Int)VG_(atoll)(&arg[15]);
1008
1739
1009
      else if (VG_CLO_STREQN(13, argv[i], "--logfile-fd=")) {
1740
      else if (VG_CLO_STREQN(13, arg, "--logfile-fd=")) {
1010
         VG_(clo_log_to)       = VgLogTo_Fd;
1741
         VG_(clo_log_to)       = VgLogTo_Fd;
1011
         VG_(clo_logfile_name) = NULL;
1742
         VG_(clo_logfile_name) = NULL;
1012
         eventually_logfile_fd = (Int)VG_(atoll)(&argv[i][13]);
1743
         eventually_logfile_fd = (Int)VG_(atoll)(&arg[13]);
1013
      }
1744
      }
1014
1745
1015
      else if (VG_CLO_STREQN(10, argv[i], "--logfile=")) {
1746
      else if (VG_CLO_STREQN(10, arg, "--logfile=")) {
1016
         VG_(clo_log_to)       = VgLogTo_File;
1747
         VG_(clo_log_to)       = VgLogTo_File;
1017
         VG_(clo_logfile_name) = &argv[i][10];
1748
         VG_(clo_logfile_name) = &arg[10];
1018
      }
1749
      }
1019
1750
1020
      else if (VG_CLO_STREQN(12, argv[i], "--logsocket=")) {
1751
      else if (VG_CLO_STREQN(12, arg, "--logsocket=")) {
1021
         VG_(clo_log_to)       = VgLogTo_Socket;
1752
         VG_(clo_log_to)       = VgLogTo_Socket;
1022
         VG_(clo_logfile_name) = &argv[i][12];
1753
         VG_(clo_logfile_name) = &arg[12];
1023
      }
1754
      }
1024
1755
1025
      else if (VG_CLO_STREQN(11, argv[i], "--input-fd="))
1756
      else if (VG_CLO_STREQN(11, arg, "--input-fd="))
1026
         VG_(clo_input_fd)     = (Int)VG_(atoll)(&argv[i][11]);
1757
         VG_(clo_input_fd)     = (Int)VG_(atoll)(&arg[11]);
1027
1758
1028
      else if (VG_CLO_STREQN(15, argv[i], "--suppressions=")) {
1759
      else if (VG_CLO_STREQN(15, arg, "--suppressions=")) {
1029
         if (VG_(clo_n_suppressions) >= VG_CLO_MAX_SFILES) {
1760
         if (VG_(clo_n_suppressions) >= VG_CLO_MAX_SFILES) {
1030
            VG_(message)(Vg_UserMsg, "Too many suppression files specified.");
1761
            VG_(message)(Vg_UserMsg, "Too many suppression files specified.");
1031
            VG_(message)(Vg_UserMsg, 
1762
            VG_(message)(Vg_UserMsg, 
1032
                         "Increase VG_CLO_MAX_SFILES and recompile.");
1763
                         "Increase VG_CLO_MAX_SFILES and recompile.");
1033
            VG_(bad_option)(argv[i]);
1764
            VG_(bad_option)(arg);
1034
         }
1765
         }
1035
         VG_(clo_suppressions)[VG_(clo_n_suppressions)] = &argv[i][15];
1766
         VG_(clo_suppressions)[VG_(clo_n_suppressions)] = &arg[15];
1036
         VG_(clo_n_suppressions)++;
1767
         VG_(clo_n_suppressions)++;
1037
      }
1768
      }
1038
      else if (VG_CLO_STREQ(argv[i], "--profile=yes"))
1769
      else if (VG_CLO_STREQ(arg, "--profile=yes"))
1039
         VG_(clo_profile) = True;
1770
         VG_(clo_profile) = True;
1040
      else if (VG_CLO_STREQ(argv[i], "--profile=no"))
1771
      else if (VG_CLO_STREQ(arg, "--profile=no"))
1041
         VG_(clo_profile) = False;
1772
         VG_(clo_profile) = False;
1042
1773
1043
      else if (VG_CLO_STREQ(argv[i], "--chain-bb=yes"))
1774
      else if (VG_CLO_STREQ(arg, "--chain-bb=yes"))
1044
	 VG_(clo_chain_bb) = True;
1775
	 VG_(clo_chain_bb) = True;
1045
      else if (VG_CLO_STREQ(argv[i], "--chain-bb=no"))
1776
      else if (VG_CLO_STREQ(arg, "--chain-bb=no"))
1046
	 VG_(clo_chain_bb) = False;
1777
	 VG_(clo_chain_bb) = False;
1047
1778
1048
      else if (VG_CLO_STREQ(argv[i], "--single-step=yes"))
1779
      else if (VG_CLO_STREQ(arg, "--branchpred=yes"))
1780
	 VG_(clo_branchpred) = True;
1781
      else if (VG_CLO_STREQ(arg, "--branchpred=no"))
1782
	 VG_(clo_branchpred) = False;
1783
1784
      else if (VG_CLO_STREQ(arg, "--single-step=yes"))
1049
         VG_(clo_single_step) = True;
1785
         VG_(clo_single_step) = True;
1050
      else if (VG_CLO_STREQ(argv[i], "--single-step=no"))
1786
      else if (VG_CLO_STREQ(arg, "--single-step=no"))
1051
         VG_(clo_single_step) = False;
1787
         VG_(clo_single_step) = False;
1052
1788
1053
      else if (VG_CLO_STREQ(argv[i], "--optimise=yes"))
1789
      else if (VG_CLO_STREQ(arg, "--optimise=yes"))
1054
         VG_(clo_optimise) = True;
1790
         VG_(clo_optimise) = True;
1055
      else if (VG_CLO_STREQ(argv[i], "--optimise=no"))
1791
      else if (VG_CLO_STREQ(arg, "--optimise=no"))
1056
         VG_(clo_optimise) = False;
1792
         VG_(clo_optimise) = False;
1057
1793
1058
      /* "vwxyz" --> 000zyxwv (binary) */
1794
      /* "vwxyz" --> 000zyxwv (binary) */
1059
      else if (VG_CLO_STREQN(16, argv[i], "--trace-codegen=")) {
1795
      else if (VG_CLO_STREQN(16, arg, "--trace-codegen=")) {
1060
         Int j;
1796
         Int j;
1061
         char* opt = & argv[i][16];
1797
         char* opt = & arg[16];
1062
   
1798
   
1063
         if (5 != VG_(strlen)(opt)) {
1799
         if (5 != VG_(strlen)(opt)) {
1064
            VG_(message)(Vg_UserMsg, 
1800
            VG_(message)(Vg_UserMsg, 
1065
                         "--trace-codegen argument must have 5 digits");
1801
                         "--trace-codegen argument must have 5 digits");
1066
            VG_(bad_option)(argv[i]);
1802
            VG_(bad_option)(arg);
1067
         }
1803
         }
1068
         for (j = 0; j < 5; j++) {
1804
         for (j = 0; j < 5; j++) {
1069
            if      ('0' == opt[j]) { /* do nothing */ }
1805
            if      ('0' == opt[j]) { /* do nothing */ }
Lines 1071-1165 Link Here
1071
            else {
1807
            else {
1072
               VG_(message)(Vg_UserMsg, "--trace-codegen argument can only "
1808
               VG_(message)(Vg_UserMsg, "--trace-codegen argument can only "
1073
                                        "contain 0s and 1s");
1809
                                        "contain 0s and 1s");
1074
               VG_(bad_option)(argv[i]);
1810
               VG_(bad_option)(arg);
1075
            }
1811
            }
1076
         }
1812
         }
1077
      }
1813
      }
1078
1814
1079
      else if (VG_CLO_STREQ(argv[i], "--trace-syscalls=yes"))
1815
      else if (VG_CLO_STREQ(arg, "--trace-syscalls=yes"))
1080
         VG_(clo_trace_syscalls) = True;
1816
         VG_(clo_trace_syscalls) = True;
1081
      else if (VG_CLO_STREQ(argv[i], "--trace-syscalls=no"))
1817
      else if (VG_CLO_STREQ(arg, "--trace-syscalls=no"))
1082
         VG_(clo_trace_syscalls) = False;
1818
         VG_(clo_trace_syscalls) = False;
1083
1819
1084
      else if (VG_CLO_STREQ(argv[i], "--trace-signals=yes"))
1820
      else if (VG_CLO_STREQ(arg, "--trace-signals=yes"))
1085
         VG_(clo_trace_signals) = True;
1821
         VG_(clo_trace_signals) = True;
1086
      else if (VG_CLO_STREQ(argv[i], "--trace-signals=no"))
1822
      else if (VG_CLO_STREQ(arg, "--trace-signals=no"))
1087
         VG_(clo_trace_signals) = False;
1823
         VG_(clo_trace_signals) = False;
1088
1824
1089
      else if (VG_CLO_STREQ(argv[i], "--trace-symtab=yes"))
1825
      else if (VG_CLO_STREQ(arg, "--trace-symtab=yes"))
1090
         VG_(clo_trace_symtab) = True;
1826
         VG_(clo_trace_symtab) = True;
1091
      else if (VG_CLO_STREQ(argv[i], "--trace-symtab=no"))
1827
      else if (VG_CLO_STREQ(arg, "--trace-symtab=no"))
1092
         VG_(clo_trace_symtab) = False;
1828
         VG_(clo_trace_symtab) = False;
1093
1829
1094
      else if (VG_CLO_STREQ(argv[i], "--trace-sched=yes"))
1830
      else if (VG_CLO_STREQ(arg, "--trace-sched=yes"))
1095
         VG_(clo_trace_sched) = True;
1831
         VG_(clo_trace_sched) = True;
1096
      else if (VG_CLO_STREQ(argv[i], "--trace-sched=no"))
1832
      else if (VG_CLO_STREQ(arg, "--trace-sched=no"))
1097
         VG_(clo_trace_sched) = False;
1833
         VG_(clo_trace_sched) = False;
1098
1834
1099
      else if (VG_CLO_STREQ(argv[i], "--trace-pthread=none"))
1835
      else if (VG_CLO_STREQ(arg, "--trace-pthread=none"))
1100
         VG_(clo_trace_pthread_level) = 0;
1836
         VG_(clo_trace_pthread_level) = 0;
1101
      else if (VG_CLO_STREQ(argv[i], "--trace-pthread=some"))
1837
      else if (VG_CLO_STREQ(arg, "--trace-pthread=some"))
1102
         VG_(clo_trace_pthread_level) = 1;
1838
         VG_(clo_trace_pthread_level) = 1;
1103
      else if (VG_CLO_STREQ(argv[i], "--trace-pthread=all"))
1839
      else if (VG_CLO_STREQ(arg, "--trace-pthread=all"))
1104
         VG_(clo_trace_pthread_level) = 2;
1840
         VG_(clo_trace_pthread_level) = 2;
1105
1841
1106
      else if (VG_CLO_STREQN(14, argv[i], "--weird-hacks="))
1842
      else if (VG_CLO_STREQN(14, arg, "--weird-hacks="))
1107
         VG_(clo_weird_hacks) = &argv[i][14];
1843
         VG_(clo_weird_hacks) = &arg[14];
1108
1844
1109
      else if (VG_CLO_STREQN(17, argv[i], "--signal-polltime="))
1845
      else if (VG_CLO_STREQN(17, arg, "--signal-polltime="))
1110
	 VG_(clo_signal_polltime) = VG_(atoll)(&argv[i][17]);
1846
	 VG_(clo_signal_polltime) = VG_(atoll)(&arg[17]);
1111
1847
1112
      else if (VG_CLO_STREQ(argv[i], "--lowlat-signals=yes"))
1848
      else if (VG_CLO_STREQ(arg, "--lowlat-signals=yes"))
1113
	 VG_(clo_lowlat_signals) = True;
1849
	 VG_(clo_lowlat_signals) = True;
1114
      else if (VG_CLO_STREQ(argv[i], "--lowlat-signals=no"))
1850
      else if (VG_CLO_STREQ(arg, "--lowlat-signals=no"))
1115
	 VG_(clo_lowlat_signals) = False;
1851
	 VG_(clo_lowlat_signals) = False;
1116
1852
1117
      else if (VG_CLO_STREQ(argv[i], "--lowlat-syscalls=yes"))
1853
      else if (VG_CLO_STREQ(arg, "--lowlat-syscalls=yes"))
1118
	 VG_(clo_lowlat_syscalls) = True;
1854
	 VG_(clo_lowlat_syscalls) = True;
1119
      else if (VG_CLO_STREQ(argv[i], "--lowlat-syscalls=no"))
1855
      else if (VG_CLO_STREQ(arg, "--lowlat-syscalls=no"))
1120
	 VG_(clo_lowlat_syscalls) = False;
1856
	 VG_(clo_lowlat_syscalls) = False;
1121
1857
1122
      else if (VG_CLO_STREQN(13, argv[i], "--stop-after="))
1858
      else if (VG_CLO_STREQN(13, arg, "--dump-error="))
1123
         VG_(clo_stop_after) = VG_(atoll)(&argv[i][13]);
1859
         VG_(clo_dump_error) = (Int)VG_(atoll)(&arg[13]);
1124
1125
      else if (VG_CLO_STREQN(13, argv[i], "--dump-error="))
1126
         VG_(clo_dump_error) = (Int)VG_(atoll)(&argv[i][13]);
1127
1860
1128
      else if (VG_CLO_STREQ(argv[i], "--wait-for-gdb=yes"))
1861
      else if (VG_CLO_STREQ(arg, "--wait-for-gdb=yes"))
1129
	 VG_(clo_wait_for_gdb) = True;
1862
	 VG_(clo_wait_for_gdb) = True;
1130
      else if (VG_CLO_STREQ(argv[i], "--wait-for-gdb=no"))
1863
      else if (VG_CLO_STREQ(arg, "--wait-for-gdb=no"))
1131
	 VG_(clo_wait_for_gdb) = False;
1864
	 VG_(clo_wait_for_gdb) = False;
1132
1865
1133
      else if (VG_CLO_STREQN(14, argv[i], "--num-callers=")) {
1866
      else if (VG_CLO_STREQN(14, arg, "--num-callers=")) {
1134
         /* Make sure it's sane. */
1867
         /* Make sure it's sane. */
1135
	 VG_(clo_backtrace_size) = (Int)VG_(atoll)(&argv[i][14]);
1868
	 VG_(clo_backtrace_size) = (Int)VG_(atoll)(&arg[14]);
1136
         if (VG_(clo_backtrace_size) < 1)
1869
         if (VG_(clo_backtrace_size) < 1)
1137
            VG_(clo_backtrace_size) = 1;
1870
            VG_(clo_backtrace_size) = 1;
1138
         if (VG_(clo_backtrace_size) >= VG_DEEPEST_BACKTRACE)
1871
         if (VG_(clo_backtrace_size) >= VG_DEEPEST_BACKTRACE)
1139
            VG_(clo_backtrace_size) = VG_DEEPEST_BACKTRACE;
1872
            VG_(clo_backtrace_size) = VG_DEEPEST_BACKTRACE;
1140
      }
1873
      }
1141
1874
1142
      else if (VG_(needs).command_line_options) {
1875
      else if ( ! VG_(needs).command_line_options
1143
         Bool ok = SK_(process_cmd_line_option)(argv[i]);
1876
             || ! SK_(process_cmd_line_option)(arg) ) {
1144
         if (!ok)
1877
         usage(/*--help-debug?*/need_help == 2);
1145
            usage();
1146
      }
1878
      }
1147
      else
1148
         usage();
1149
   }
1879
   }
1150
1880
1151
#  undef ISSPACE
1152
1153
   if (VG_(clo_verbosity) < 0)
1881
   if (VG_(clo_verbosity) < 0)
1154
      VG_(clo_verbosity) = 0;
1882
      VG_(clo_verbosity) = 0;
1155
1883
1156
   if (VG_(clo_GDB_attach) && VG_(clo_trace_children)) {
1884
   if (VG_(clo_db_attach) && VG_(clo_trace_children)) {
1157
      VG_(message)(Vg_UserMsg, "");
1885
      VG_(message)(Vg_UserMsg, "");
1158
      VG_(message)(Vg_UserMsg, 
1886
      VG_(message)(Vg_UserMsg, 
1159
         "--gdb-attach=yes conflicts with --trace-children=yes");
1887
         "--db-attach=yes conflicts with --trace-children=yes");
1160
      VG_(message)(Vg_UserMsg, 
1888
      VG_(message)(Vg_UserMsg, 
1161
         "Please choose one or the other, but not both.");
1889
         "Please choose one or the other, but not both.");
1162
      VG_(bad_option)("--gdb-attach=yes and --trace-children=yes");
1890
      VG_(bad_option)("--db-attach=yes and --trace-children=yes");
1163
   }
1891
   }
1164
1892
1165
   /* Set up logging now.  After this is done, VG_(clo_logfile_fd)
1893
   /* Set up logging now.  After this is done, VG_(clo_logfile_fd)
Lines 1188-1194 Link Here
1188
         vg_assert(VG_(clo_logfile_name) != NULL);
1916
         vg_assert(VG_(clo_logfile_name) != NULL);
1189
         vg_assert(VG_(strlen)(VG_(clo_logfile_name)) <= 900); /* paranoia */
1917
         vg_assert(VG_(strlen)(VG_(clo_logfile_name)) <= 900); /* paranoia */
1190
1918
1191
	 for(;;) {
1919
	 for (;;) {
1192
	    if (seq == 0)
1920
	    if (seq == 0)
1193
	       VG_(sprintf)(logfilename, "%s.pid%d",
1921
	       VG_(sprintf)(logfilename, "%s.pid%d",
1194
			    VG_(clo_logfile_name), pid );
1922
			    VG_(clo_logfile_name), pid );
Lines 1202-1208 Link Here
1202
			   VKI_O_CREAT|VKI_O_WRONLY|VKI_O_EXCL|VKI_O_TRUNC, 
1930
			   VKI_O_CREAT|VKI_O_WRONLY|VKI_O_EXCL|VKI_O_TRUNC, 
1203
			   VKI_S_IRUSR|VKI_S_IWUSR);
1931
			   VKI_S_IRUSR|VKI_S_IWUSR);
1204
	    if (eventually_logfile_fd >= 0) {
1932
	    if (eventually_logfile_fd >= 0) {
1205
	       VG_(clo_logfile_fd) = eventually_logfile_fd;
1933
	       VG_(clo_logfile_fd) = VG_(safe_fd)(eventually_logfile_fd);
1206
	       break;
1934
	       break;
1207
	    } else {
1935
	    } else {
1208
	       if (eventually_logfile_fd != -VKI_EEXIST) {
1936
	       if (eventually_logfile_fd != -VKI_EEXIST) {
Lines 1251-1257 Link Here
1251
   }
1979
   }
1252
1980
1253
   /* Move logfile_fd into the safe range, so it doesn't conflict with any app fds */
1981
   /* Move logfile_fd into the safe range, so it doesn't conflict with any app fds */
1254
   eventually_logfile_fd = VG_(fcntl)(VG_(clo_logfile_fd), VKI_F_DUPFD, VG_MAX_FD+1);
1982
   eventually_logfile_fd = VG_(fcntl)(VG_(clo_logfile_fd), VKI_F_DUPFD, VG_(max_fd)+1);
1255
   if (eventually_logfile_fd < 0)
1983
   if (eventually_logfile_fd < 0)
1256
      VG_(message)(Vg_UserMsg, "valgrind: failed to move logfile fd into safe range");
1984
      VG_(message)(Vg_UserMsg, "valgrind: failed to move logfile fd into safe range");
1257
   else {
1985
   else {
Lines 1279-1285 Link Here
1279
         "Using valgrind-%s, a program supervision framework for x86-linux.",
2007
         "Using valgrind-%s, a program supervision framework for x86-linux.",
1280
         VERSION);
2008
         VERSION);
1281
      VG_(message)(Vg_UserMsg, 
2009
      VG_(message)(Vg_UserMsg, 
1282
         "Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.");
2010
         "Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward.");
1283
   }
2011
   }
1284
2012
1285
   if (VG_(clo_verbosity) > 0 && VG_(clo_log_to) != VgLogTo_Fd) {
2013
   if (VG_(clo_verbosity) > 0 && VG_(clo_log_to) != VgLogTo_Fd) {
Lines 1294-1336 Link Here
1294
   if (VG_(clo_verbosity) > 1) {
2022
   if (VG_(clo_verbosity) > 1) {
1295
      if (VG_(clo_log_to) != VgLogTo_Fd)
2023
      if (VG_(clo_log_to) != VgLogTo_Fd)
1296
         VG_(message)(Vg_UserMsg, "");
2024
         VG_(message)(Vg_UserMsg, "");
2025
      VG_(message)(Vg_UserMsg, "Valgrind library directory: %s", VG_(libdir));
1297
      VG_(message)(Vg_UserMsg, "Command line");
2026
      VG_(message)(Vg_UserMsg, "Command line");
1298
      for (i = 0; i < VG_(client_argc); i++)
2027
      for (i = 0; i < VG_(client_argc); i++)
1299
         VG_(message)(Vg_UserMsg, "   %s", VG_(client_argv)[i]);
2028
         VG_(message)(Vg_UserMsg, "   %s", VG_(client_argv)[i]);
1300
2029
1301
      VG_(message)(Vg_UserMsg, "Startup, with flags:");
2030
      VG_(message)(Vg_UserMsg, "Startup, with flags:");
1302
      for (i = 0; i < argc; i++) {
2031
      for (i = 1; i < VG_(vg_argc); i++) {
1303
         VG_(message)(Vg_UserMsg, "   %s", argv[i]);
2032
         VG_(message)(Vg_UserMsg, "   %s", VG_(vg_argv)[i]);
1304
      }
2033
      }
1305
   }
2034
   }
2035
2036
   if (VG_(clo_n_suppressions) < VG_CLO_MAX_SFILES-1 &&
2037
       (VG_(needs).core_errors || VG_(needs).skin_errors)) {
2038
      /* If there are no suppression files specified and the skin
2039
	 needs one, load the default */
2040
      static const Char default_supp[] = "default.supp";
2041
      Int len = VG_(strlen)(VG_(libdir)) + 1 + sizeof(default_supp);
2042
      Char *buf = VG_(arena_malloc)(VG_AR_CORE, len);
2043
      VG_(sprintf)(buf, "%s/%s", VG_(libdir), default_supp);
2044
      VG_(clo_suppressions)[VG_(clo_n_suppressions)] = buf;
2045
      VG_(clo_n_suppressions)++;
2046
   }
2047
2048
   if (VG_(clo_gen_suppressions) && 
2049
       !VG_(needs).core_errors && !VG_(needs).skin_errors) {
2050
      config_error("Can't use --gen-suppressions=yes with this skin,\n"
2051
                   "   as it doesn't generate errors.");
2052
   }
2053
}
2054
2055
2056
/*====================================================================*/
2057
/*=== File descriptor setup                                        ===*/
2058
/*====================================================================*/
2059
2060
static void setup_file_descriptors(void)
2061
{
2062
   struct vki_rlimit rl;
2063
2064
   /* Get the current file descriptor limits. */
2065
   if (VG_(getrlimit)(VKI_RLIMIT_NOFILE, &rl) < 0) {
2066
      rl.rlim_cur = 1024;
2067
      rl.rlim_max = 1024;
2068
   }
2069
2070
   /* Work out where to move the soft limit to. */
2071
   if (rl.rlim_cur + VG_N_RESERVED_FDS <= rl.rlim_max) {
2072
      rl.rlim_cur = rl.rlim_cur + VG_N_RESERVED_FDS;
2073
   } else {
2074
      rl.rlim_cur = rl.rlim_max;
2075
   }
2076
2077
   /* Reserve some file descriptors for our use. */
2078
   VG_(max_fd) = rl.rlim_cur - VG_N_RESERVED_FDS;
2079
2080
   /* Update the soft limit. */
2081
   VG_(setrlimit)(VKI_RLIMIT_NOFILE, &rl);
2082
2083
   if (VG_(vgexecfd) != -1)
2084
      VG_(vgexecfd) = VG_(safe_fd)( VG_(vgexecfd) );
2085
   if (VG_(clexecfd) != -1)
2086
      VG_(clexecfd) = VG_(safe_fd)( VG_(clexecfd) );
2087
}
2088
2089
2090
/*====================================================================*/
2091
/*=== baseBlock: definition + setup                                ===*/
2092
/*====================================================================*/
2093
2094
/* The variables storing offsets. */
2095
2096
#define INVALID_OFFSET (-1)
2097
2098
Int VGOFF_(m_eax) = INVALID_OFFSET;
2099
Int VGOFF_(m_ecx) = INVALID_OFFSET;
2100
Int VGOFF_(m_edx) = INVALID_OFFSET;
2101
Int VGOFF_(m_ebx) = INVALID_OFFSET;
2102
Int VGOFF_(m_esp) = INVALID_OFFSET;
2103
Int VGOFF_(m_ebp) = INVALID_OFFSET;
2104
Int VGOFF_(m_esi) = INVALID_OFFSET;
2105
Int VGOFF_(m_edi) = INVALID_OFFSET;
2106
Int VGOFF_(m_eflags) = INVALID_OFFSET;
2107
Int VGOFF_(m_dflag)  = INVALID_OFFSET;
2108
Int VGOFF_(m_ssestate) = INVALID_OFFSET;
2109
Int VGOFF_(ldt)   = INVALID_OFFSET;
2110
Int VGOFF_(tls)   = INVALID_OFFSET;
2111
Int VGOFF_(m_cs)  = INVALID_OFFSET;
2112
Int VGOFF_(m_ss)  = INVALID_OFFSET;
2113
Int VGOFF_(m_ds)  = INVALID_OFFSET;
2114
Int VGOFF_(m_es)  = INVALID_OFFSET;
2115
Int VGOFF_(m_fs)  = INVALID_OFFSET;
2116
Int VGOFF_(m_gs)  = INVALID_OFFSET;
2117
Int VGOFF_(m_eip) = INVALID_OFFSET;
2118
Int VGOFF_(spillslots) = INVALID_OFFSET;
2119
Int VGOFF_(sh_eax) = INVALID_OFFSET;
2120
Int VGOFF_(sh_ecx) = INVALID_OFFSET;
2121
Int VGOFF_(sh_edx) = INVALID_OFFSET;
2122
Int VGOFF_(sh_ebx) = INVALID_OFFSET;
2123
Int VGOFF_(sh_esp) = INVALID_OFFSET;
2124
Int VGOFF_(sh_ebp) = INVALID_OFFSET;
2125
Int VGOFF_(sh_esi) = INVALID_OFFSET;
2126
Int VGOFF_(sh_edi) = INVALID_OFFSET;
2127
Int VGOFF_(sh_eflags) = INVALID_OFFSET;
2128
2129
Int VGOFF_(helper_idiv_64_32) = INVALID_OFFSET;
2130
Int VGOFF_(helper_div_64_32) = INVALID_OFFSET;
2131
Int VGOFF_(helper_idiv_32_16) = INVALID_OFFSET;
2132
Int VGOFF_(helper_div_32_16) = INVALID_OFFSET;
2133
Int VGOFF_(helper_idiv_16_8) = INVALID_OFFSET;
2134
Int VGOFF_(helper_div_16_8) = INVALID_OFFSET;
2135
Int VGOFF_(helper_imul_32_64) = INVALID_OFFSET;
2136
Int VGOFF_(helper_mul_32_64) = INVALID_OFFSET;
2137
Int VGOFF_(helper_imul_16_32) = INVALID_OFFSET;
2138
Int VGOFF_(helper_mul_16_32) = INVALID_OFFSET;
2139
Int VGOFF_(helper_imul_8_16) = INVALID_OFFSET;
2140
Int VGOFF_(helper_mul_8_16) = INVALID_OFFSET;
2141
Int VGOFF_(helper_CLD) = INVALID_OFFSET;
2142
Int VGOFF_(helper_STD) = INVALID_OFFSET;
2143
Int VGOFF_(helper_get_dirflag) = INVALID_OFFSET;
2144
Int VGOFF_(helper_CLC) = INVALID_OFFSET;
2145
Int VGOFF_(helper_STC) = INVALID_OFFSET;
2146
Int VGOFF_(helper_CMC) = INVALID_OFFSET;
2147
Int VGOFF_(helper_shldl) = INVALID_OFFSET;
2148
Int VGOFF_(helper_shldw) = INVALID_OFFSET;
2149
Int VGOFF_(helper_shrdl) = INVALID_OFFSET;
2150
Int VGOFF_(helper_shrdw) = INVALID_OFFSET;
2151
Int VGOFF_(helper_IN) = INVALID_OFFSET;
2152
Int VGOFF_(helper_OUT) = INVALID_OFFSET;
2153
Int VGOFF_(helper_RDTSC) = INVALID_OFFSET;
2154
Int VGOFF_(helper_CPUID) = INVALID_OFFSET;
2155
Int VGOFF_(helper_BSWAP) = INVALID_OFFSET;
2156
Int VGOFF_(helper_bsfw) = INVALID_OFFSET;
2157
Int VGOFF_(helper_bsfl) = INVALID_OFFSET;
2158
Int VGOFF_(helper_bsrw) = INVALID_OFFSET;
2159
Int VGOFF_(helper_bsrl) = INVALID_OFFSET;
2160
Int VGOFF_(helper_fstsw_AX) = INVALID_OFFSET;
2161
Int VGOFF_(helper_SAHF) = INVALID_OFFSET;
2162
Int VGOFF_(helper_LAHF) = INVALID_OFFSET;
2163
Int VGOFF_(helper_DAS) = INVALID_OFFSET;
2164
Int VGOFF_(helper_DAA) = INVALID_OFFSET;
2165
Int VGOFF_(helper_AAS) = INVALID_OFFSET;
2166
Int VGOFF_(helper_AAA) = INVALID_OFFSET;
2167
Int VGOFF_(helper_AAD) = INVALID_OFFSET;
2168
Int VGOFF_(helper_AAM) = INVALID_OFFSET;
2169
Int VGOFF_(helper_cmpxchg8b) = INVALID_OFFSET;
2170
Int VGOFF_(helper_undefined_instruction) = INVALID_OFFSET;
2171
2172
/* MAX_NONCOMPACT_HELPERS can be increased easily.  If MAX_COMPACT_HELPERS is
2173
 * increased too much, they won't really be compact any more... */
2174
#define  MAX_COMPACT_HELPERS     8
2175
#define  MAX_NONCOMPACT_HELPERS  50 
1306
2176
1307
   if (VG_(clo_n_suppressions) == 0 && 
2177
UInt VG_(n_compact_helpers)    = 0;
1308
       (VG_(needs).core_errors || VG_(needs).skin_errors)) {
2178
UInt VG_(n_noncompact_helpers) = 0;
1309
      config_error("No error-suppression files were specified.");
1310
   }
1311
2179
1312
   if (VG_(clo_gen_suppressions) && 
2180
Addr VG_(compact_helper_addrs)  [MAX_COMPACT_HELPERS];
1313
       !VG_(needs).core_errors && !VG_(needs).skin_errors) {
2181
Int  VG_(compact_helper_offsets)[MAX_COMPACT_HELPERS];
1314
      config_error("Can't use --gen-suppressions=yes with this skin,\n"
2182
Addr VG_(noncompact_helper_addrs)  [MAX_NONCOMPACT_HELPERS];
1315
                   "   as it doesn't generate errors.");
2183
Int  VG_(noncompact_helper_offsets)[MAX_NONCOMPACT_HELPERS];
1316
   }
1317
2184
1318
}
2185
/* This is the actual defn of baseblock. */
2186
UInt VG_(baseBlock)[VG_BASEBLOCK_WORDS];
1319
2187
1320
/* ---------------------------------------------------------------------
2188
/* Words. */
1321
   Copying to/from m_state_static.
2189
static Int baB_off = 0;
1322
   ------------------------------------------------------------------ */
1323
2190
1324
/* See comment about this in vg_include.h.  Change only with
1325
   great care.
1326
*/
1327
__attribute__ ((aligned (16)))
1328
UInt VG_(m_state_static) [6 /* segment regs, Intel order */
1329
                          + 8 /* int regs, in Intel order */ 
1330
                          + 1 /* %eflags */ 
1331
                          + 1 /* %eip */
1332
                          + VG_SIZE_OF_SSESTATE_W /* FPU state */
1333
                         ];
1334
2191
1335
UInt VG_(insertDflag)(UInt eflags, Int d)
2192
UInt VG_(insertDflag)(UInt eflags, Int d)
1336
{
2193
{
Lines 1355-1589 Link Here
1355
   return ret;
2212
   return ret;
1356
}
2213
}
1357
2214
1358
void VG_(copy_baseBlock_to_m_state_static) ( void )
2215
/* Returns the offset, in words. */
2216
static Int alloc_BaB ( Int words )
2217
{
2218
   Int off = baB_off;
2219
   baB_off += words;
2220
   if (baB_off >= VG_BASEBLOCK_WORDS)
2221
      VG_(core_panic)( "alloc_BaB: baseBlock is too small");
2222
2223
   return off;   
2224
}
2225
2226
/* Align offset, in *bytes* */
2227
static void align_BaB ( UInt align )
1359
{
2228
{
1360
   Int i;
2229
   vg_assert(2 == align || 4 == align || 8 == align || 16 == align);
1361
   VG_(m_state_static)[ 0/4] = VG_(baseBlock)[VGOFF_(m_cs)];
2230
   baB_off +=  (align-1);
1362
   VG_(m_state_static)[ 4/4] = VG_(baseBlock)[VGOFF_(m_ss)];
2231
   baB_off &= ~(align-1);
1363
   VG_(m_state_static)[ 8/4] = VG_(baseBlock)[VGOFF_(m_ds)];
1364
   VG_(m_state_static)[12/4] = VG_(baseBlock)[VGOFF_(m_es)];
1365
   VG_(m_state_static)[16/4] = VG_(baseBlock)[VGOFF_(m_fs)];
1366
   VG_(m_state_static)[20/4] = VG_(baseBlock)[VGOFF_(m_gs)];
1367
1368
   VG_(m_state_static)[24/4] = VG_(baseBlock)[VGOFF_(m_eax)];
1369
   VG_(m_state_static)[28/4] = VG_(baseBlock)[VGOFF_(m_ecx)];
1370
   VG_(m_state_static)[32/4] = VG_(baseBlock)[VGOFF_(m_edx)];
1371
   VG_(m_state_static)[36/4] = VG_(baseBlock)[VGOFF_(m_ebx)];
1372
   VG_(m_state_static)[40/4] = VG_(baseBlock)[VGOFF_(m_esp)];
1373
   VG_(m_state_static)[44/4] = VG_(baseBlock)[VGOFF_(m_ebp)];
1374
   VG_(m_state_static)[48/4] = VG_(baseBlock)[VGOFF_(m_esi)];
1375
   VG_(m_state_static)[52/4] = VG_(baseBlock)[VGOFF_(m_edi)];
1376
1377
   VG_(m_state_static)[56/4] 
1378
      = VG_(insertDflag)(VG_(baseBlock)[VGOFF_(m_eflags)],
1379
                         VG_(baseBlock)[VGOFF_(m_dflag)]);
1380
   VG_(m_state_static)[60/4] = VG_(baseBlock)[VGOFF_(m_eip)];
1381
1382
   for (i = 0; i < VG_SIZE_OF_SSESTATE_W; i++)
1383
      VG_(m_state_static)[64/4 + i] 
1384
         = VG_(baseBlock)[VGOFF_(m_ssestate) + i];
1385
}
2232
}
1386
2233
2234
/* Allocate 1 word in baseBlock and set it to the given value. */
2235
static Int alloc_BaB_1_set ( Addr a )
2236
{
2237
   Int off = alloc_BaB(1);
2238
   VG_(baseBlock)[off] = (UInt)a;
2239
   return off;
2240
}
1387
2241
1388
void VG_(copy_m_state_static_to_baseBlock) ( void )
2242
/* Registers a function in compact_helper_addrs;  compact_helper_offsets is
1389
{
2243
   filled in later. */
1390
   Int i;
2244
void VG_(register_compact_helper)(Addr a)
1391
   VG_(baseBlock)[VGOFF_(m_cs)] = VG_(m_state_static)[ 0/4];
2245
{
1392
   VG_(baseBlock)[VGOFF_(m_ss)] = VG_(m_state_static)[ 4/4];
2246
   if (MAX_COMPACT_HELPERS <= VG_(n_compact_helpers)) {
1393
   VG_(baseBlock)[VGOFF_(m_ds)] = VG_(m_state_static)[ 8/4];
2247
      VG_(printf)("Can only register %d compact helpers\n", 
1394
   VG_(baseBlock)[VGOFF_(m_es)] = VG_(m_state_static)[12/4];
2248
                  MAX_COMPACT_HELPERS);
1395
   VG_(baseBlock)[VGOFF_(m_fs)] = VG_(m_state_static)[16/4];
2249
      VG_(core_panic)("Too many compact helpers registered");
1396
   VG_(baseBlock)[VGOFF_(m_gs)] = VG_(m_state_static)[20/4];
2250
   }
1397
2251
   VG_(compact_helper_addrs)[VG_(n_compact_helpers)] = a;
1398
   VG_(baseBlock)[VGOFF_(m_eax)] = VG_(m_state_static)[24/4];
2252
   VG_(n_compact_helpers)++;
1399
   VG_(baseBlock)[VGOFF_(m_ecx)] = VG_(m_state_static)[28/4];
1400
   VG_(baseBlock)[VGOFF_(m_edx)] = VG_(m_state_static)[32/4];
1401
   VG_(baseBlock)[VGOFF_(m_ebx)] = VG_(m_state_static)[36/4];
1402
   VG_(baseBlock)[VGOFF_(m_esp)] = VG_(m_state_static)[40/4];
1403
   VG_(baseBlock)[VGOFF_(m_ebp)] = VG_(m_state_static)[44/4];
1404
   VG_(baseBlock)[VGOFF_(m_esi)] = VG_(m_state_static)[48/4];
1405
   VG_(baseBlock)[VGOFF_(m_edi)] = VG_(m_state_static)[52/4];
1406
1407
   VG_(baseBlock)[VGOFF_(m_eflags)] 
1408
      = VG_(m_state_static)[56/4] & ~EFlagD;
1409
   VG_(baseBlock)[VGOFF_(m_dflag)] 
1410
      = VG_(extractDflag)(VG_(m_state_static)[56/4]);
1411
1412
   VG_(baseBlock)[VGOFF_(m_eip)] = VG_(m_state_static)[60/4];
1413
1414
   for (i = 0; i < VG_SIZE_OF_SSESTATE_W; i++)
1415
      VG_(baseBlock)[VGOFF_(m_ssestate) + i]
1416
         = VG_(m_state_static)[64/4 + i];
1417
}
2253
}
1418
2254
1419
Addr VG_(get_stack_pointer) ( void )
2255
/* Registers a function in noncompact_helper_addrs;  noncompact_helper_offsets
2256
 * is filled in later.
2257
 */
2258
void VG_(register_noncompact_helper)(Addr a)
1420
{
2259
{
1421
   return VG_(baseBlock)[VGOFF_(m_esp)];
2260
   if (MAX_NONCOMPACT_HELPERS <= VG_(n_noncompact_helpers)) {
2261
      VG_(printf)("Can only register %d non-compact helpers\n", 
2262
                  MAX_NONCOMPACT_HELPERS);
2263
      VG_(printf)("Try increasing MAX_NON_COMPACT_HELPERS\n");
2264
      VG_(core_panic)("Too many non-compact helpers registered");
2265
   }
2266
   VG_(noncompact_helper_addrs)[VG_(n_noncompact_helpers)] = a;
2267
   VG_(n_noncompact_helpers)++;
1422
}
2268
}
1423
2269
1424
/* Some random tests needed for leak checking */
2270
/* Allocate offsets in baseBlock for the skin helpers */
2271
static 
2272
void assign_helpers_in_baseBlock(UInt n, Int offsets[], Addr addrs[])
2273
{
2274
   UInt i;
2275
   for (i = 0; i < n; i++) 
2276
      offsets[i] = alloc_BaB_1_set( addrs[i] );
2277
}
1425
2278
1426
Bool VG_(within_stack)(Addr a)
2279
Bool VG_(need_to_handle_esp_assignment)(void)
1427
{
2280
{
1428
   if (a >= ((Addr)(&VG_(stack)))
2281
   return ( VG_(defined_new_mem_stack_4)()  ||
1429
       && a <= ((Addr)(&VG_(stack))) + sizeof(VG_(stack)))
2282
            VG_(defined_die_mem_stack_4)()  ||
1430
      return True;
2283
            VG_(defined_new_mem_stack_8)()  ||
1431
   else
2284
            VG_(defined_die_mem_stack_8)()  ||
1432
      return False;
2285
            VG_(defined_new_mem_stack_12)() ||
2286
            VG_(defined_die_mem_stack_12)() ||
2287
            VG_(defined_new_mem_stack_16)() ||
2288
            VG_(defined_die_mem_stack_16)() ||
2289
            VG_(defined_new_mem_stack_32)() ||
2290
            VG_(defined_die_mem_stack_32)() ||
2291
            VG_(defined_new_mem_stack)()    ||
2292
            VG_(defined_die_mem_stack)()
2293
          );
1433
}
2294
}
1434
2295
1435
Bool VG_(within_m_state_static_OR_threads)(Addr a)
2296
/* Here we assign actual offsets.  It's important to get the most
2297
   popular referents within 128 bytes of the start, so we can take
2298
   advantage of short addressing modes relative to %ebp.  Popularity
2299
   of offsets was measured on 22 Feb 02 running a KDE application, and
2300
   the slots rearranged accordingly, with a 1.5% reduction in total
2301
   size of translations. */
2302
static void init_baseBlock ( Addr client_eip, Addr esp_at_startup )
1436
{
2303
{
1437
   if (a >= ((Addr)(&VG_(m_state_static)))
2304
   /* Those with offsets under 128 are carefully chosen. */
1438
       && a < ((Addr)(&VG_(m_state_static))) + sizeof(VG_(m_state_static)))
2305
1439
      return True;
2306
   /* WORD offsets in this column */
2307
   /* 0   */ VGOFF_(m_eax)     = alloc_BaB_1_set(0);
2308
   /* 1   */ VGOFF_(m_ecx)     = alloc_BaB_1_set(0);
2309
   /* 2   */ VGOFF_(m_edx)     = alloc_BaB_1_set(0);
2310
   /* 3   */ VGOFF_(m_ebx)     = alloc_BaB_1_set(0);
2311
   /* 4   */ VGOFF_(m_esp)     = alloc_BaB_1_set(esp_at_startup);
2312
   /* 5   */ VGOFF_(m_ebp)     = alloc_BaB_1_set(0);
2313
   /* 6   */ VGOFF_(m_esi)     = alloc_BaB_1_set(0);
2314
   /* 7   */ VGOFF_(m_edi)     = alloc_BaB_1_set(0);
2315
   /* 8   */ VGOFF_(m_eflags)  = alloc_BaB_1_set(0);
2316
2317
   if (VG_(needs).shadow_regs) {
2318
      /* 9   */ VGOFF_(sh_eax)    = alloc_BaB_1_set(0);
2319
      /* 10  */ VGOFF_(sh_ecx)    = alloc_BaB_1_set(0);
2320
      /* 11  */ VGOFF_(sh_edx)    = alloc_BaB_1_set(0);
2321
      /* 12  */ VGOFF_(sh_ebx)    = alloc_BaB_1_set(0);
2322
      /* 13  */ VGOFF_(sh_esp)    = alloc_BaB_1_set(0);
2323
      /* 14  */ VGOFF_(sh_ebp)    = alloc_BaB_1_set(0);
2324
      /* 15  */ VGOFF_(sh_esi)    = alloc_BaB_1_set(0);
2325
      /* 16  */ VGOFF_(sh_edi)    = alloc_BaB_1_set(0);
2326
      /* 17  */ VGOFF_(sh_eflags) = alloc_BaB_1_set(0);
2327
      VG_TRACK( post_regs_write_init );
2328
   }
2329
2330
   /* 9,10,11 or 18,19,20... depends on number whether shadow regs are used
2331
    * and on compact helpers registered */ 
2332
2333
   /* Make these most-frequently-called specialised ones compact, if they
2334
      are used. */
2335
   if (VG_(defined_new_mem_stack_4)())
2336
      VG_(register_compact_helper)( (Addr) VG_(tool_interface).track_new_mem_stack_4);
2337
2338
   if (VG_(defined_die_mem_stack_4)())
2339
      VG_(register_compact_helper)( (Addr) VG_(tool_interface).track_die_mem_stack_4);
2340
2341
   /* (9 or 18) + n_compact_helpers  */
2342
   /* Allocate slots for compact helpers */
2343
   assign_helpers_in_baseBlock(VG_(n_compact_helpers), 
2344
                               VG_(compact_helper_offsets), 
2345
                               VG_(compact_helper_addrs));
2346
2347
   /* (9/10 or 18/19) + n_compact_helpers */
2348
   VGOFF_(m_eip) = alloc_BaB_1_set(client_eip);
2349
2350
   /* There are currently 24 spill slots */
2351
   /* (11+/20+ .. 32+/43+) + n_compact_helpers.  This can overlap the magic
2352
    * boundary at >= 32 words, but most spills are to low numbered spill
2353
    * slots, so the ones above the boundary don't see much action. */
2354
   VGOFF_(spillslots) = alloc_BaB(VG_MAX_SPILLSLOTS);
2355
2356
   /* I gave up counting at this point.  Since they're above the
2357
      short-amode-boundary, there's no point. */
2358
2359
   VGOFF_(m_dflag) = alloc_BaB_1_set(1);  // 1 == forward D-flag
2360
2361
   /* The FPU/SSE state.  This _must_ be 16-byte aligned.  Initial
2362
      state doesn't matter much, as long as it's not totally borked. */
2363
   align_BaB(16);
2364
   VGOFF_(m_ssestate) = alloc_BaB(VG_SIZE_OF_SSESTATE_W);
2365
   vg_assert( 
2366
      0 == ( ((UInt)(& VG_(baseBlock)[VGOFF_(m_ssestate)])) % 16 )
2367
   );
2368
2369
   /* I assume that if we have SSE2 we also have SSE */
2370
   VG_(have_ssestate) = 
2371
	   VG_(cpu_has_feature)(VG_X86_FEAT_FXSR) &&
2372
	   VG_(cpu_has_feature)(VG_X86_FEAT_SSE);
2373
2374
   /* set up an initial FPU state (doesn't really matter what it is,
2375
      so long as it's somewhat valid) */
2376
   if (!VG_(have_ssestate))
2377
      asm volatile("fwait; fnsave %0; fwait; frstor %0; fwait" 
2378
                   : 
2379
                   : "m" (VG_(baseBlock)[VGOFF_(m_ssestate)]) 
2380
                   : "cc", "memory");
2381
   else
2382
      asm volatile("fwait; fxsave %0; fwait; andl $0xffbf, %1;"
2383
                   "fxrstor %0; fwait"
2384
                   : 
2385
                   : "m" (VG_(baseBlock)[VGOFF_(m_ssestate)]), 
2386
                     "m" (VG_(baseBlock)[VGOFF_(m_ssestate)+(24/4)]) 
2387
                   : "cc", "memory");
2388
2389
   if (0) {
2390
      if (VG_(have_ssestate))
2391
         VG_(printf)("Looks like a SSE-capable CPU\n");
2392
      else
2393
         VG_(printf)("Looks like a MMX-only CPU\n");
2394
   }
2395
2396
   /* LDT pointer: pretend the root thread has an empty LDT to start with. */
2397
   VGOFF_(ldt)   = alloc_BaB_1_set((UInt)NULL);
2398
2399
   /* TLS pointer: pretend the root thread has no TLS array for now. */
2400
   VGOFF_(tls)   = alloc_BaB_1_set((UInt)NULL);
2401
2402
   /* segment registers */
2403
   VGOFF_(m_cs)  = alloc_BaB_1_set(0);
2404
   VGOFF_(m_ss)  = alloc_BaB_1_set(0);
2405
   VGOFF_(m_ds)  = alloc_BaB_1_set(0);
2406
   VGOFF_(m_es)  = alloc_BaB_1_set(0);
2407
   VGOFF_(m_fs)  = alloc_BaB_1_set(0);
2408
   VGOFF_(m_gs)  = alloc_BaB_1_set(0);
2409
2410
   VG_(register_noncompact_helper)( (Addr) & VG_(do_useseg) );
2411
2412
#define REG(kind, size) \
2413
   if (VG_(defined_##kind##_mem_stack##size)()) \
2414
      VG_(register_noncompact_helper)(           \
2415
          (Addr) VG_(tool_interface).track_##kind##_mem_stack##size );
2416
   REG(new, _8);
2417
   REG(new, _12);
2418
   REG(new, _16);
2419
   REG(new, _32);
2420
   REG(new, );
2421
   REG(die, _8);
2422
   REG(die, _12);
2423
   REG(die, _16);
2424
   REG(die, _32);
2425
   REG(die, );
2426
#undef REG
2427
2428
   if (VG_(need_to_handle_esp_assignment)())
2429
      VG_(register_noncompact_helper)((Addr) VG_(unknown_esp_update));
2430
2431
#  define HELPER(name) \
2432
   VGOFF_(helper_##name) = alloc_BaB_1_set( (Addr) & VG_(helper_##name))
2433
2434
   /* Helper functions. */
2435
   HELPER(idiv_64_32);     HELPER(div_64_32);
2436
   HELPER(idiv_32_16);     HELPER(div_32_16);
2437
   HELPER(idiv_16_8);      HELPER(div_16_8);
2438
2439
   HELPER(imul_32_64);     HELPER(mul_32_64);
2440
   HELPER(imul_16_32);     HELPER(mul_16_32);
2441
   HELPER(imul_8_16);      HELPER(mul_8_16);
2442
2443
   HELPER(CLD);            HELPER(STD);
2444
   HELPER(get_dirflag);
2445
2446
   HELPER(CLC);            HELPER(STC);
2447
   HELPER(CMC);
2448
2449
   HELPER(shldl);          HELPER(shldw);
2450
   HELPER(shrdl);          HELPER(shrdw);
2451
2452
   HELPER(RDTSC);          HELPER(CPUID);
1440
2453
1441
   if (a >= ((Addr)(&VG_(threads)[0]))
2454
   HELPER(bsfw);           HELPER(bsfl);
1442
       && a < ((Addr)(&VG_(threads)[VG_N_THREADS])))
2455
   HELPER(bsrw);           HELPER(bsrl);
1443
      return True;
1444
2456
1445
   return False;
2457
   HELPER(fstsw_AX);
2458
   HELPER(SAHF);           HELPER(LAHF);
2459
   HELPER(DAS);            HELPER(DAA);
2460
   HELPER(AAS);            HELPER(AAA);
2461
   HELPER(AAD);            HELPER(AAM);
2462
   HELPER(IN);             HELPER(OUT);
2463
   HELPER(cmpxchg8b);
2464
2465
   HELPER(undefined_instruction);
2466
2467
#  undef HELPER
2468
2469
   /* Allocate slots for noncompact helpers */
2470
   assign_helpers_in_baseBlock(VG_(n_noncompact_helpers), 
2471
                               VG_(noncompact_helper_offsets), 
2472
                               VG_(noncompact_helper_addrs));
1446
}
2473
}
1447
2474
1448
/* ---------------------------------------------------------------------
1449
   Show accumulated counts.
1450
   ------------------------------------------------------------------ */
1451
2475
1452
static __inline__ Int safe_idiv(Int a, Int b)
2476
/*====================================================================*/
2477
/*=== Setup pointercheck                                           ===*/
2478
/*====================================================================*/
2479
2480
static void setup_pointercheck(void)
2481
{
2482
   int ret;
2483
2484
   if (VG_(clo_pointercheck)) {
2485
      vki_modify_ldt_t ldt = { 
2486
         VG_POINTERCHECK_SEGIDX,    // entry_number
2487
         VG_(client_base),          // base_addr
2488
         (VG_(client_end)-VG_(client_base)) / VKI_BYTES_PER_PAGE, // limit
2489
         1,                         // seg_32bit
2490
         0,                         // contents: data, RW, non-expanding
2491
         0,                         // ! read_exec_only
2492
         1,                         // limit_in_pages
2493
         0,                         // ! seg not present
2494
         1,                         // useable
2495
      };
2496
      ret = VG_(do_syscall)(__NR_modify_ldt, 1, &ldt, sizeof(ldt));
2497
      if (ret < 0) {
2498
	 VG_(message)(Vg_UserMsg,
2499
		      "Warning: ignoring --pointercheck=yes, "
2500
		      "because modify_ldt failed (errno=%d)", -ret);
2501
	 VG_(clo_pointercheck) = False;
2502
      }
2503
   }
2504
}
2505
2506
/*====================================================================*/
2507
/*===  Initialise program data/text, etc.                          ===*/
2508
/*====================================================================*/
2509
2510
static void build_valgrind_map_callback 
2511
      ( Addr start, UInt size, Char rr, Char ww, Char xx, 
2512
        UInt dev, UInt ino, ULong foffset, const UChar* filename )
1453
{
2513
{
1454
   return (b == 0 ? 0 : a / b);
2514
   UInt prot  = 0;
2515
   UInt flags = SF_MMAP|SF_NOSYMS;
2516
   Bool is_stack_segment;
2517
2518
   is_stack_segment = 
2519
      (start == VG_(clstk_base) && (start+size) == VG_(clstk_end));
2520
2521
   /* Only record valgrind mappings for now, without loading any
2522
      symbols.  This is so we know where the free space is before we
2523
      start allocating more memory (note: heap is OK, it's just mmap
2524
      which is the problem here). */
2525
   if (start >= VG_(valgrind_base) && (start+size) <= VG_(valgrind_end)) {
2526
      flags |= SF_VALGRIND;
2527
      VG_(map_file_segment)(start, size, prot, flags, dev, ino, foffset, filename);
2528
   }
1455
}
2529
}
1456
2530
1457
static void vg_show_counts ( void )
2531
// Global var used to pass local data to callback
2532
Addr esp_at_startup___global_arg = 0;
2533
2534
static void build_segment_map_callback 
2535
      ( Addr start, UInt size, Char rr, Char ww, Char xx,
2536
        UInt dev, UInt ino, ULong foffset, const UChar* filename )
1458
{
2537
{
1459
   VG_(message)(Vg_DebugMsg,
2538
   UInt prot = 0;
1460
		"    TT/TC: %d tc sectors discarded.",
2539
   UInt flags;
1461
                VG_(number_of_tc_discards) );
2540
   Bool is_stack_segment;
1462
   VG_(message)(Vg_DebugMsg,
2541
   Addr r_esp;
1463
                "           %d chainings, %d unchainings.",
1464
                VG_(bb_enchain_count), VG_(bb_dechain_count) );
1465
   VG_(message)(Vg_DebugMsg,
1466
                "translate: new     %d (%d -> %d; ratio %d:10)",
1467
                VG_(overall_in_count),
1468
                VG_(overall_in_osize),
1469
                VG_(overall_in_tsize),
1470
                safe_idiv(10*VG_(overall_in_tsize), VG_(overall_in_osize)));
1471
   VG_(message)(Vg_DebugMsg,
1472
                "           discard %d (%d -> %d; ratio %d:10).",
1473
                VG_(overall_out_count),
1474
                VG_(overall_out_osize),
1475
                VG_(overall_out_tsize),
1476
                safe_idiv(10*VG_(overall_out_tsize), VG_(overall_out_osize)));
1477
   VG_(message)(Vg_DebugMsg,
1478
      " dispatch: %llu jumps (bb entries), of which %u (%lu%%) were unchained.",
1479
      VG_(bbs_done), 
1480
      VG_(unchained_jumps_done),
1481
      ((ULong)(100) * (ULong)(VG_(unchained_jumps_done)))
1482
         / ( VG_(bbs_done)==0 ? 1 : VG_(bbs_done) )
1483
   );
1484
2542
1485
   VG_(message)(Vg_DebugMsg,
2543
   is_stack_segment 
1486
      "           %d/%d major/minor sched events.  %d tt_fast misses.", 
2544
      = (start == VG_(clstk_base) && (start+size) == VG_(clstk_end));
1487
                     VG_(num_scheduling_events_MAJOR), 
1488
                     VG_(num_scheduling_events_MINOR), 
1489
                     VG_(tt_fast_misses));
1490
2545
1491
   VG_(message)(Vg_DebugMsg, 
2546
   if (rr == 'r') prot |= VKI_PROT_READ;
1492
                "reg-alloc: %d t-req-spill, "
2547
   if (ww == 'w') prot |= VKI_PROT_WRITE;
1493
                "%d+%d orig+spill uis, %d total-reg-r.",
2548
   if (xx == 'x') prot |= VKI_PROT_EXEC;
1494
                VG_(translations_needing_spill),
2549
1495
                VG_(uinstrs_prealloc),
2550
   if (is_stack_segment)
1496
                VG_(uinstrs_spill),
2551
      flags = SF_STACK | SF_GROWDOWN;
1497
                VG_(total_reg_rank) );
2552
   else
1498
   VG_(message)(Vg_DebugMsg, 
2553
      flags = SF_EXEC|SF_MMAP;
1499
                "   sanity: %d cheap, %d expensive checks.",
2554
1500
                VG_(sanity_fast_count), 
2555
   if (filename != NULL)
1501
                VG_(sanity_slow_count) );
2556
      flags |= SF_FILE;
1502
   VG_(print_ccall_stats)();
2557
2558
   if (start >= VG_(valgrind_base) && (start+size) <= VG_(valgrind_end))
2559
      flags |= SF_VALGRIND;
2560
2561
   VG_(map_file_segment)(start, size, prot, flags, dev, ino, foffset, filename);
2562
2563
   if (VG_(is_client_addr)(start) && VG_(is_client_addr)(start+size-1))
2564
      VG_TRACK( new_mem_startup, start, size, rr=='r', ww=='w', xx=='x' );
2565
2566
   /* If this is the stack segment mark all below %esp as noaccess. */
2567
   r_esp = esp_at_startup___global_arg;
2568
   vg_assert(0 != r_esp);
2569
   if (is_stack_segment) {
2570
      if (0)
2571
         VG_(message)(Vg_DebugMsg, "invalidating stack area: %x .. %x",
2572
                      start,r_esp);
2573
      VG_TRACK( die_mem_stack, start, r_esp-start );
2574
   }
1503
}
2575
}
1504
2576
1505
2577
1506
/* ---------------------------------------------------------------------
2578
/*====================================================================*/
1507
   Main!
2579
/*=== Sanity check machinery (permanently engaged)                 ===*/
1508
   ------------------------------------------------------------------ */
2580
/*====================================================================*/
1509
2581
1510
/* Initialize the PID and PGRP of scheduler LWP; this is also called
2582
/* A fast sanity check -- suitable for calling circa once per
1511
   in any new children after fork. */
2583
   millisecond. */
1512
static void newpid(ThreadId unused)
2584
2585
void VG_(do_sanity_checks) ( Bool force_expensive )
1513
{
2586
{
1514
   /* PID of scheduler LWP */
2587
   VGP_PUSHCC(VgpCoreCheapSanity);
1515
   VG_(main_pid) = VG_(getpid)();
2588
1516
   VG_(main_pgrp) = VG_(getpgrp)();
2589
   if (VG_(sanity_level) < 1) return;
2590
2591
   /* --- First do all the tests that we can do quickly. ---*/
2592
2593
   VG_(sanity_fast_count)++;
2594
2595
   /* Check stuff pertaining to the memory check system. */
2596
2597
   /* Check that nobody has spuriously claimed that the first or
2598
      last 16 pages of memory have become accessible [...] */
2599
   if (VG_(needs).sanity_checks) {
2600
      VGP_PUSHCC(VgpSkinCheapSanity);
2601
      vg_assert(SK_(cheap_sanity_check)());
2602
      VGP_POPCC(VgpSkinCheapSanity);
2603
   }
2604
2605
   /* --- Now some more expensive checks. ---*/
2606
2607
   /* Once every 25 times, check some more expensive stuff. */
2608
   if ( force_expensive
2609
     || VG_(sanity_level) > 1
2610
     || (VG_(sanity_level) == 1 && (VG_(sanity_fast_count) % 25) == 0)) {
2611
2612
      VGP_PUSHCC(VgpCoreExpensiveSanity);
2613
      VG_(sanity_slow_count)++;
2614
2615
      VG_(proxy_sanity)();
2616
2617
#     if 0
2618
      { void zzzmemscan(void); zzzmemscan(); }
2619
#     endif
2620
2621
      if ((VG_(sanity_fast_count) % 250) == 0)
2622
         VG_(sanity_check_tc_tt)();
2623
2624
      if (VG_(needs).sanity_checks) {
2625
          VGP_PUSHCC(VgpSkinExpensiveSanity);
2626
          vg_assert(SK_(expensive_sanity_check)());
2627
          VGP_POPCC(VgpSkinExpensiveSanity);
2628
      }
2629
      /* 
2630
      if ((VG_(sanity_fast_count) % 500) == 0) VG_(mallocSanityCheckAll)(); 
2631
      */
2632
      VGP_POPCC(VgpCoreExpensiveSanity);
2633
   }
2634
2635
   if (VG_(sanity_level) > 1) {
2636
      VGP_PUSHCC(VgpCoreExpensiveSanity);
2637
      /* Check sanity of the low-level memory manager.  Note that bugs
2638
         in the client's code can cause this to fail, so we don't do
2639
         this check unless specially asked for.  And because it's
2640
         potentially very expensive. */
2641
      VG_(mallocSanityCheckAll)();
2642
      VGP_POPCC(VgpCoreExpensiveSanity);
2643
   }
2644
   VGP_POPCC(VgpCoreCheapSanity);
1517
}
2645
}
1518
2646
1519
/* Where we jump to once Valgrind has got control, and the real
1520
   machine's state has been copied to the m_state_static. */
1521
2647
1522
void VG_(main) ( void )
2648
/*====================================================================*/
1523
{
2649
/*=== main()                                                       ===*/
1524
   Int               i;
2650
/*====================================================================*/
2651
2652
int main(int argc, char **argv)
2653
{
2654
   char **cl_argv;
2655
   const char *tool = NULL;
2656
   const char *exec = NULL;
2657
   char *preload;          /* tool-specific LD_PRELOAD .so */
2658
   char **env;
2659
   Int need_help = 0;      // 0 = no, 1 = --help, 2 = --help-debug
2660
   struct exeinfo info;
2661
   ToolInfo *toolinfo = NULL;
2662
   void *tool_dlhandle;
2663
   Addr client_eip;
2664
   Addr esp_at_startup;    /* client's %esp at the point we gained control. */
2665
   UInt * client_auxv;
1525
   VgSchedReturnCode src;
2666
   VgSchedReturnCode src;
1526
2667
2668
   //============================================================
2669
   // Nb: startup is complex.  Prerequisites are shown at every step.
2670
   //
2671
   // *** Be very careful when messing with the order ***
2672
   //============================================================
2673
2674
   //--------------------------------------------------------------
2675
   // Check we were launched by stage1
2676
   //   p: n/a  [must be first step]
2677
   //--------------------------------------------------------------
2678
   scan_auxv();
2679
1527
   if (0) {
2680
   if (0) {
1528
      if (VG_(have_ssestate))
2681
      int prmap(void *start, void *end, const char *perm, off_t off, 
1529
         VG_(printf)("Looks like a SSE-capable CPU\n");
2682
                int maj, int min, int ino) {
1530
      else
2683
         printf("mapping %10p-%10p %s %02x:%02x %d\n",
1531
         VG_(printf)("Looks like a MMX-only CPU\n");
2684
                start, end, perm, maj, min, ino);
2685
         return True;
2686
      }
2687
      printf("========== main() ==========\n");
2688
      foreach_map(prmap);
1532
   }
2689
   }
1533
2690
1534
   /* Check skin and core versions are compatible */
2691
   //--------------------------------------------------------------
1535
   if (VG_CORE_INTERFACE_MAJOR_VERSION != VG_(skin_interface_major_version)) {
2692
   // Look for alternative libdir                                  
1536
      VG_(printf)("Error:\n"
2693
   //   p: n/a
1537
                  "  Tool and core interface versions do not match.\n"
2694
   //--------------------------------------------------------------
1538
                  "  Interface version used by core is: %d.%d\n"
2695
   {  char *cp = getenv(VALGRINDLIB);
1539
                  "  Interface version used by tool is: %d.%d\n"
2696
      if (cp != NULL)
1540
                  "  The major version numbers must match.\n",
2697
	 VG_(libdir) = cp;
1541
                  VG_CORE_INTERFACE_MAJOR_VERSION,
2698
   }
1542
                  VG_CORE_INTERFACE_MINOR_VERSION,
2699
1543
                  VG_(skin_interface_major_version),
2700
   //--------------------------------------------------------------
1544
                  VG_(skin_interface_minor_version));
2701
   // Begin working out address space layout
1545
      VG_(printf)("  You need to at least recompile, and possibly update,\n");
2702
   //   p: n/a
1546
      if (VG_CORE_INTERFACE_MAJOR_VERSION > VG_(skin_interface_major_version))
2703
   //--------------------------------------------------------------
1547
         VG_(printf)("  your skin to work with this version of Valgrind.\n");
2704
   layout_client_space( (Addr) & argc );
1548
      else
2705
1549
         VG_(printf)("  your version of Valgrind to work with this skin.\n");
2706
   //--------------------------------------------------------------
1550
      VG_(printf)("  Aborting, sorry.\n");
2707
   // Get valgrind args + client args (inc. from VALGRIND_OPTS/.valgrindrc).
1551
      VG_(exit)(1);
2708
   // Pre-process the command line.
1552
   }
2709
   //   p: n/a
2710
   //--------------------------------------------------------------
2711
   get_command_line(argc, argv, &VG_(vg_argc), &VG_(vg_argv), &cl_argv);
2712
   pre_process_cmd_line_options(&need_help, &tool, &exec);
2713
2714
   //==============================================================
2715
   // Nb: once a tool is specified, the tool.so must be loaded even if 
2716
   // they specified --help or didn't specify a client program.
2717
   //==============================================================
2718
2719
   //--------------------------------------------------------------
2720
   // With client padded out, map in tool
2721
   //   p: layout_client_space()          [for padding]
2722
   //   p: set-libdir                     [for VG_(libdir)]
2723
   //   p: pre_process_cmd_line_options() [for 'tool']
2724
   //--------------------------------------------------------------
2725
   load_tool(tool, &tool_dlhandle, &toolinfo, &preload);
2726
2727
   //==============================================================
2728
   // Can use VG_(malloc)() and VG_(arena_malloc)() only after load_tool()
2729
   // -- redzone size is now set.
2730
   //==============================================================
2731
   
2732
   //--------------------------------------------------------------
2733
   // Finalise address space layout
2734
   //   p: layout_client_space(), load_tool()           [for 'toolinfo']
2735
   //--------------------------------------------------------------
2736
   layout_remaining_space( toolinfo->shadow_ratio );
2737
2738
   //--------------------------------------------------------------
2739
   // Load client executable, finding in $PATH if necessary
2740
   //   p: layout_client_space()           [so there's space]
2741
   //   p: pre_process_cmd_line_options()  [for 'exec', 'need_help']
2742
   //   p: layout_remaining_space          [so there's space]
2743
   //--------------------------------------------------------------
2744
   load_client(cl_argv, exec, /*inout*/&need_help, &info, &client_eip);
2745
2746
   //--------------------------------------------------------------
2747
   // Everything in place, unpad us
2748
   //   p: layout_remaining_space()  [everything must be mapped in before now]  
2749
   //   p: load_client()             [ditto] 
2750
   //--------------------------------------------------------------
2751
   as_unpad((void *)VG_(shadow_end), (void *)~0);
2752
   as_closepadfile();		/* no more padding */
2753
2754
   //--------------------------------------------------------------
2755
   // Set up client's environment
2756
   //   p: set-libdir  [for VG_(libdir)]
2757
   //   p: load_tool() [for 'preload']
2758
   //--------------------------------------------------------------
2759
   env = fix_environment(environ, preload);
2760
2761
   //--------------------------------------------------------------
2762
   // Setup client stack and eip 
2763
   //   p: load_client()     [for 'info']
2764
   //   p: fix_environment() [for 'env']
2765
   //--------------------------------------------------------------
2766
   esp_at_startup = setup_client_stack(cl_argv, env, &info, &client_auxv);
2767
2768
   if (0)
2769
      printf("entry=%x client esp=%x vg_argc=%d brkbase=%x\n",
2770
	     client_eip, esp_at_startup, VG_(vg_argc), VG_(brk_base));
2771
2772
   //==============================================================
2773
   // Finished setting up operating environment.  Now initialise
2774
   // Valgrind.  (This is where the old VG_(main)() started.)
2775
   //==============================================================
2776
2777
   //--------------------------------------------------------------
2778
   // Read /proc/self/maps into a buffer
2779
   //   p: all memory layout, environment setup   [so memory maps are right]
2780
   //--------------------------------------------------------------
2781
   VG_(read_procselfmaps)();
1553
2782
2783
   //--------------------------------------------------------------
2784
   // atfork
2785
   //   p: n/a
2786
   //--------------------------------------------------------------
1554
   VG_(atfork)(NULL, NULL, newpid);
2787
   VG_(atfork)(NULL, NULL, newpid);
1555
   newpid(VG_INVALID_THREADID);
2788
   newpid(VG_INVALID_THREADID);
1556
2789
1557
   /* Set up our stack sanity-check words. */
2790
   //--------------------------------------------------------------
1558
   for (i = 0; i < 10; i++) {
2791
   // setup file descriptors
1559
      VG_(stack)[i] = (UInt)(&VG_(stack)[i])                   ^ 0xA4B3C2D1;
2792
   //   p: n/a
1560
      VG_(stack)[VG_STACK_SIZE_W-1-i] 
2793
   //--------------------------------------------------------------
1561
                    = (UInt)(&VG_(stack)[VG_STACK_SIZE_W-i-1]) ^ 0xABCD4321;
2794
   setup_file_descriptors();
1562
   }
2795
1563
2796
   //--------------------------------------------------------------
1564
   /* Read /proc/self/maps into a buffer.  Must be before:
2797
   // Setup tool
1565
      - SK_(pre_clo_init)(): so that if it calls VG_(malloc)(), any mmap'd
2798
   //   p: VG_(read_procselfmaps)()  [so if sk_pre_clo_init calls
1566
        superblocks are not erroneously identified as being owned by the
2799
   //        VG_(malloc), any mmap'd superblocks aren't erroneously
1567
        client, which would be bad.
2800
   //        identified later as being owned by the client]
1568
      - init_memory(): that's where the buffer is parsed
2801
   // XXX: is that necessary, now that we look for V's segments separately?
1569
      - init_tt_tc(): so the anonymous mmaps for the translation table and
2802
   // XXX: alternatively, if sk_pre_clo_init does use VG_(malloc)(), is it
1570
        translation cache aren't identified as part of the client, which would
2803
   //      wrong to ignore any segments that might add in parse_procselfmaps?
1571
        waste > 20M of virtual address space, and be bad.
2804
   //--------------------------------------------------------------
1572
   */
2805
   (*toolinfo->sk_pre_clo_init)();
1573
   VG_(read_procselfmaps)();
2806
   VG_(tool_init_dlsym)(tool_dlhandle);
1574
1575
   /* Setup stuff that depends on the skin.  Must be before:
1576
      - vg_init_baseBlock(): to register helpers
1577
      - process_cmd_line_options(): to register skin name and description,
1578
        and turn on/off 'command_line_options' need
1579
      - init_memory() (to setup memory event trackers).
1580
   */
1581
   SK_(pre_clo_init)();
1582
   VG_(sanity_check_needs)();
2807
   VG_(sanity_check_needs)();
1583
2808
1584
   /* Process Valgrind's command-line opts (from env var VG_ARGS). */
2809
   //--------------------------------------------------------------
1585
   process_cmd_line_options();
2810
   // Process Valgrind's + tool's command-line options
1586
2811
   //   p: load_tool()               [for 'tool']
2812
   //   p: load_client()             [for 'need_help']
2813
   //   p: setup_file_descriptors()  [for 'VG_(max_fd)']
2814
   //   p: sk_pre_clo_init           [to set 'command_line_options' need]
2815
   //--------------------------------------------------------------
2816
   process_cmd_line_options(client_auxv, esp_at_startup, tool, need_help);
2817
2818
   //--------------------------------------------------------------
2819
   // Allow GDB attach
2820
   //   p: process_cmd_line_options()  [for VG_(clo_wait_for_gdb)]
2821
   //--------------------------------------------------------------
1587
   /* Hook to delay things long enough so we can get the pid and
2822
   /* Hook to delay things long enough so we can get the pid and
1588
      attach GDB in another shell. */
2823
      attach GDB in another shell. */
1589
   if (VG_(clo_wait_for_gdb)) {
2824
   if (VG_(clo_wait_for_gdb)) {
Lines 1592-1664 Link Here
1592
      VG_(do_syscall)(__NR_pause);
2827
      VG_(do_syscall)(__NR_pause);
1593
   }
2828
   }
1594
2829
1595
   /* Do post command-line processing initialisation.  Must be before:
2830
   //--------------------------------------------------------------
1596
      - vg_init_baseBlock(): to register any more helpers
2831
   // Setup tool, post command-line processing
1597
   */
2832
   //   p: process_cmd_line_options  [tool assumes it]
2833
   //--------------------------------------------------------------
1598
   SK_(post_clo_init)();
2834
   SK_(post_clo_init)();
1599
2835
1600
   /* Set up baseBlock offsets and copy the saved machine's state into it. */
2836
   //--------------------------------------------------------------
1601
   vg_init_baseBlock();
2837
   // Set up baseBlock
1602
2838
   //   p: {pre,post}_clo_init()  [for tool helper registration]
1603
   /* Search for file descriptors that are inherited from our parent. */
2839
   //      load_client()          [for 'client_eip']
2840
   //      setup_client_stack()   [for 'esp_at_startup']
2841
   //--------------------------------------------------------------
2842
   init_baseBlock(client_eip, esp_at_startup);
2843
2844
   //--------------------------------------------------------------
2845
   // Search for file descriptors that are inherited from our parent
2846
   //   p: process_cmd_line_options  [for VG_(clo_track_fds)]
2847
   //--------------------------------------------------------------
1604
   if (VG_(clo_track_fds))
2848
   if (VG_(clo_track_fds))
1605
      VG_(init_preopened_fds)();
2849
      VG_(init_preopened_fds)();
1606
2850
1607
   /* Initialise the scheduler, and copy the client's state from
2851
   //--------------------------------------------------------------
1608
      baseBlock into VG_(threads)[1].  Must be before:
2852
   // Initialise the scheduler
1609
      - VG_(sigstartup_actions)()
2853
   //   p: init_baseBlock()  [baseBlock regs copied into VG_(threads)[1]]
1610
   */
2854
   //   p: setup_file_descriptors() [else VG_(safe_fd)() breaks]
2855
   //--------------------------------------------------------------
1611
   VG_(scheduler_init)();
2856
   VG_(scheduler_init)();
1612
2857
1613
   /* Set up the ProxyLWP machinery */
2858
   //--------------------------------------------------------------
2859
   // Set up the ProxyLWP machinery
2860
   //   p: VG_(scheduler_init)()?  [XXX: subtle dependency?]
2861
   // - subs: VG_(sigstartup_actions)()?
2862
   //--------------------------------------------------------------
1614
   VG_(proxy_init)();
2863
   VG_(proxy_init)();
1615
2864
1616
   /* Initialise the signal handling subsystem, temporarily parking
2865
   //--------------------------------------------------------------
1617
      the saved blocking-mask in saved_sigmask. */
2866
   // Initialise the signal handling subsystem
2867
   //   p: VG_(atfork)(NULL, NULL, newpid) [else problems with sigmasks]
2868
   //   p: VG_(proxy_init)()               [else breaks...]
2869
   //--------------------------------------------------------------
2870
   // Nb: temporarily parks the saved blocking-mask in saved_sigmask.
1618
   VG_(sigstartup_actions)();
2871
   VG_(sigstartup_actions)();
1619
2872
1620
   /* Perhaps we're profiling Valgrind? */
2873
   //--------------------------------------------------------------
2874
   // Perhaps we're profiling Valgrind?
2875
   //   p: process_cmd_line_options()  [for VG_(clo_profile)]
2876
   //   p: others?
2877
   //
2878
   // XXX: this seems to be broken?   It always says the tool wasn't built
2879
   // for profiling;  vg_profile.c's functions don't seem to be overriding
2880
   // vg_dummy_profile.c's?
2881
   //
2882
   // XXX: want this as early as possible.  Looking for --profile
2883
   // in pre_process_cmd_line_options() could get it earlier.
2884
   //--------------------------------------------------------------
1621
   if (VG_(clo_profile))
2885
   if (VG_(clo_profile))
1622
      VGP_(init_profiling)();
2886
      VGP_(init_profiling)();
1623
2887
1624
   /* Start calibration of our RDTSC-based clock. */
2888
   VGP_PUSHCC(VgpStartup);
1625
   VG_(start_rdtsc_calibration)();
1626
2889
1627
   /* Parse /proc/self/maps to learn about startup segments. */
2890
   //--------------------------------------------------------------
1628
   VGP_PUSHCC(VgpInitMem);
2891
   // Reserve Valgrind's kickstart, heap and stack
1629
   VG_(init_memory)();
2892
   //   p: XXX ???
1630
   VGP_POPCC(VgpInitMem);
2893
   //--------------------------------------------------------------
1631
2894
   VG_(map_segment)(VG_(valgrind_mmap_end),
1632
   /* Read the list of errors to suppress.  This should be found in
2895
                    VG_(valgrind_end)-VG_(valgrind_mmap_end),
1633
      the file specified by vg_clo_suppressions. */
2896
                    VKI_PROT_NONE, SF_VALGRIND|SF_FIXED);
2897
2898
   //--------------------------------------------------------------
2899
   // Identify Valgrind's segments
2900
   //   p: read proc/self/maps
2901
   //   p: VG_(map_segment)   [XXX ???]
2902
   //   p: sk_pre_clo_init()  [to setup new_mem_startup tracker]
2903
   //--------------------------------------------------------------
2904
   VG_(parse_procselfmaps) ( build_valgrind_map_callback );
2905
2906
   // XXX: I can't see why these two need to be separate;  could they be
2907
   // folded together?  If not, need a comment explaining why.
2908
   //
2909
   // XXX: can we merge reading and parsing of /proc/self/maps?
2910
   //
2911
   // XXX: can we dynamically allocate the /proc/self/maps buffer? (or mmap
2912
   //      it?)  Or does that disturb its contents...
2913
2914
   //--------------------------------------------------------------
2915
   // Build segment map (all segments)
2916
   //   p: setup_client_stack()  [for 'esp_at_startup']
2917
   //--------------------------------------------------------------
2918
   esp_at_startup___global_arg = esp_at_startup;
2919
   VG_(parse_procselfmaps) ( build_segment_map_callback );  /* everything */
2920
   esp_at_startup___global_arg = 0;
2921
   
2922
   //==============================================================
2923
   // Can only use VG_(map)() after VG_(map_segment)()  [XXX ???]
2924
   //==============================================================
2925
2926
   //--------------------------------------------------------------
2927
   // Build segment map (all segments)
2928
   //   p: setup_client_stack()  [for 'esp_at_startup']
2929
   //--------------------------------------------------------------
2930
   /* Initialize our trampoline page (which is also sysinfo stuff) */
2931
   VG_(memcpy)( (void *)VG_(client_trampoline_code),
2932
                &VG_(trampoline_code_start), VG_(trampoline_code_length) );
2933
   VG_(mprotect)( (void *)VG_(client_trampoline_code),
2934
                 VG_(trampoline_code_length), VKI_PROT_READ|VKI_PROT_EXEC );
2935
2936
   //--------------------------------------------------------------
2937
   // Read suppression file
2938
   //   p: process_cmd_line_options()  [for VG_(clo_suppressions)]
2939
   //--------------------------------------------------------------
1634
   if (VG_(needs).core_errors || VG_(needs).skin_errors)
2940
   if (VG_(needs).core_errors || VG_(needs).skin_errors)
1635
      VG_(load_suppressions)();
2941
      VG_(load_suppressions)();
1636
2942
1637
   /* End calibration of our RDTSC-based clock, leaving it as long as
2943
   //--------------------------------------------------------------
1638
      we can. */
2944
   // Initialise translation table and translation cache
1639
   VG_(end_rdtsc_calibration)();
2945
   //   p: read_procselfmaps  [so the anonymous mmaps for the TT/TC
1640
2946
   //         aren't identified as part of the client, which would waste
1641
   /* Initialise translation table and translation cache. */
2947
   //         > 20M of virtual address space.]
2948
   //--------------------------------------------------------------
1642
   VG_(init_tt_tc)();
2949
   VG_(init_tt_tc)();
1643
2950
1644
   if (VG_(clo_verbosity) == 1) {
2951
   //--------------------------------------------------------------
1645
      VG_(message)(Vg_UserMsg, 
2952
   // Read debug info to find glibc entry points to intercept
1646
                   "For more details, rerun with: -v");
2953
   //   p: parse_procselfmaps? [XXX for debug info?]
1647
   }
2954
   //   p: init_tt_tc?  [XXX ???]
1648
2955
   //--------------------------------------------------------------
1649
   /* Force a read of the debug info so that we can look for 
1650
      glibc entry points to intercept. */
1651
   VG_(setup_code_redirect_table)();
2956
   VG_(setup_code_redirect_table)();
1652
2957
1653
   /* Now it is safe for malloc et al in vg_clientmalloc.c to act
2958
   //--------------------------------------------------------------
1654
      instrumented-ly. */
2959
   // Verbosity message
2960
   //   p: end_rdtsc_calibration [so startup message is printed first]
2961
   //--------------------------------------------------------------
2962
   if (VG_(clo_verbosity) == 1)
2963
      VG_(message)(Vg_UserMsg, "For more details, rerun with: -v");
1655
   if (VG_(clo_verbosity) > 0)
2964
   if (VG_(clo_verbosity) > 0)
1656
      VG_(message)(Vg_UserMsg, "");
2965
      VG_(message)(Vg_UserMsg, "");
1657
2966
1658
   VG_(bbs_to_go) = VG_(clo_stop_after);
2967
   //--------------------------------------------------------------
2968
   // Setup pointercheck
2969
   //   p: process_cmd_line_options() [for VG_(clo_pointercheck)]
2970
   //--------------------------------------------------------------
2971
   setup_pointercheck();
1659
2972
1660
   /* Run! */
2973
2974
2975
   //--------------------------------------------------------------
2976
   // Run!
2977
   //--------------------------------------------------------------
1661
   VG_(running_on_simd_CPU) = True;
2978
   VG_(running_on_simd_CPU) = True;
2979
   VGP_POPCC(VgpStartup);
1662
   VGP_PUSHCC(VgpSched);
2980
   VGP_PUSHCC(VgpSched);
1663
2981
1664
   if (__builtin_setjmp(&VG_(fatal_signal_jmpbuf)) == 0) {
2982
   if (__builtin_setjmp(&VG_(fatal_signal_jmpbuf)) == 0) {
Lines 1670-1675 Link Here
1670
   VGP_POPCC(VgpSched);
2988
   VGP_POPCC(VgpSched);
1671
   VG_(running_on_simd_CPU) = False;
2989
   VG_(running_on_simd_CPU) = False;
1672
2990
2991
2992
2993
   //--------------------------------------------------------------
2994
   // Finalisation: cleanup, messages, etc.  Order no so important, only
2995
   // affects what order the messages come.
2996
   //--------------------------------------------------------------
1673
   if (VG_(clo_verbosity) > 0)
2997
   if (VG_(clo_verbosity) > 0)
1674
      VG_(message)(Vg_UserMsg, "");
2998
      VG_(message)(Vg_UserMsg, "");
1675
2999
Lines 1679-1685 Link Here
1679
   }
3003
   }
1680
3004
1681
   /* Print out file descriptor summary and stats. */
3005
   /* Print out file descriptor summary and stats. */
1682
   if(VG_(clo_track_fds))
3006
   if (VG_(clo_track_fds))
1683
      VG_(fd_stats)();
3007
      VG_(fd_stats)();
1684
3008
1685
   if (VG_(needs).core_errors || VG_(needs).skin_errors)
3009
   if (VG_(needs).core_errors || VG_(needs).skin_errors)
Lines 1690-1696 Link Here
1690
   VG_(do_sanity_checks)( True /*include expensive checks*/ );
3014
   VG_(do_sanity_checks)( True /*include expensive checks*/ );
1691
3015
1692
   if (VG_(clo_verbosity) > 1)
3016
   if (VG_(clo_verbosity) > 1)
1693
      vg_show_counts();
3017
      show_counts();
1694
3018
1695
   if (VG_(clo_verbosity) > 3)
3019
   if (VG_(clo_verbosity) > 3)
1696
      VG_(print_UInstr_histogram)();
3020
      VG_(print_UInstr_histogram)();
Lines 1709-1739 Link Here
1709
   if (VG_(clo_profile))
3033
   if (VG_(clo_profile))
1710
      VGP_(done_profiling)();
3034
      VGP_(done_profiling)();
1711
3035
3036
   /* Must be after all messages are done */
1712
   VG_(shutdown_logging)();
3037
   VG_(shutdown_logging)();
1713
3038
1714
   /* Remove valgrind.so from a LD_PRELOAD=... string so child
1715
      processes don't get traced into.  Also mess up $libdir/valgrind
1716
      so that our libpthread.so disappears from view. */
1717
   /* 26 Apr 03: doing this often causes trouble for no reason, and is
1718
      pointless when we are just about to VgSrc_ExitSyscall.  So don't
1719
      bother in that case. */
1720
   if ((!VG_(clo_trace_children))
1721
       && src != VgSrc_ExitSyscall) { 
1722
      VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH)(
1723
         VG_(getenv)("LD_PRELOAD"),
1724
         VG_(getenv)("LD_LIBRARY_PATH") 
1725
      );
1726
   }
1727
1728
   /* We're exiting, so nuke all the threads and clean up the proxy LWPs */
3039
   /* We're exiting, so nuke all the threads and clean up the proxy LWPs */
1729
   vg_assert(src == VgSrc_FatalSig ||
3040
   vg_assert(src == VgSrc_FatalSig ||
1730
	     VG_(threads)[VG_(last_run_tid)].status == VgTs_Runnable ||
3041
	     VG_(threads)[VG_(last_run_tid)].status == VgTs_Runnable ||
1731
	     VG_(threads)[VG_(last_run_tid)].status == VgTs_WaitJoiner);
3042
	     VG_(threads)[VG_(last_run_tid)].status == VgTs_WaitJoiner);
1732
   VG_(nuke_all_threads_except)(VG_INVALID_THREADID);
3043
   VG_(nuke_all_threads_except)(VG_INVALID_THREADID);
1733
3044
1734
   /* Decide how to exit.  This depends on what the scheduler
3045
   //--------------------------------------------------------------
1735
      returned. */
3046
   // Exit, according to the scheduler's return code
1736
  
3047
   //--------------------------------------------------------------
1737
   switch (src) {
3048
   switch (src) {
1738
      case VgSrc_ExitSyscall: /* the normal way out */
3049
      case VgSrc_ExitSyscall: /* the normal way out */
1739
         vg_assert(VG_(last_run_tid) > 0 
3050
         vg_assert(VG_(last_run_tid) > 0 
Lines 1745-2075 Link Here
1745
            that arg. */
3056
            that arg. */
1746
         VG_(exit)( VG_(exitcode) );
3057
         VG_(exit)( VG_(exitcode) );
1747
         /* NOT ALIVE HERE! */
3058
         /* NOT ALIVE HERE! */
1748
         VG_(core_panic)("entered the afterlife in vg_main() -- ExitSyscall");
3059
         VG_(core_panic)("entered the afterlife in main() -- ExitSyscall");
1749
         break; /* what the hell :) */
3060
         break; /* what the hell :) */
1750
3061
1751
      case VgSrc_Deadlock:
3062
      case VgSrc_Deadlock:
1752
         /* Just exit now.  No point in continuing. */
3063
         /* Just exit now.  No point in continuing. */
1753
	 VG_(proxy_shutdown)();
3064
	 VG_(proxy_shutdown)();
1754
         VG_(exit)(0);
3065
         VG_(exit)(0);
1755
         VG_(core_panic)("entered the afterlife in vg_main() -- Deadlock");
3066
         VG_(core_panic)("entered the afterlife in main() -- Deadlock");
1756
         break;
3067
         break;
1757
3068
1758
      case VgSrc_BbsDone: 
1759
         /* Tricky; we have to try and switch back to the real CPU.
1760
            This is all very dodgy and won't work at all in the
1761
            presence of threads, or if the client happened to be
1762
            running a signal handler. */
1763
         /* Prepare to restore state to the real CPU. */
1764
         VG_(sigshutdown_actions)();
1765
         VG_(load_thread_state)(1 /* root thread */ );
1766
         VG_(copy_baseBlock_to_m_state_static)();
1767
1768
	 VG_(proxy_shutdown)();
1769
1770
         /* This pushes a return address on the simulator's stack,
1771
            which is abandoned.  We call vg_sigshutdown_actions() at
1772
            the end of vg_switch_to_real_CPU(), so as to ensure that
1773
            the original stack and machine state is restored before
1774
            the real signal mechanism is restored.  */
1775
         VG_(switch_to_real_CPU)();
1776
1777
      case VgSrc_FatalSig:
3069
      case VgSrc_FatalSig:
1778
	 /* We were killed by a fatal signal, so replicate the effect */
3070
	 /* We were killed by a fatal signal, so replicate the effect */
1779
	 vg_assert(VG_(fatal_sigNo) != -1);
3071
	 vg_assert(VG_(fatal_sigNo) != -1);
1780
	 VG_(kill_self)(VG_(fatal_sigNo));
3072
	 VG_(kill_self)(VG_(fatal_sigNo));
1781
	 VG_(core_panic)("vg_main(): signal was supposed to be fatal");
3073
	 VG_(core_panic)("main(): signal was supposed to be fatal");
1782
	 break;
3074
	 break;
1783
3075
1784
      default:
3076
      default:
1785
         VG_(core_panic)("vg_main(): unexpected scheduler return code");
3077
         VG_(core_panic)("main(): unexpected scheduler return code");
1786
   }
1787
}
1788
1789
1790
/* Debugging thing .. can be called from assembly with OYNK macro. */
1791
void VG_(oynk) ( Int n )
1792
{
1793
   OINK(n);
1794
}
1795
1796
1797
/* Find "valgrind.so" in a LD_PRELOAD=... string, and convert it to
1798
   "valgrinq.so", which doesn't do anything.  This is used to avoid
1799
   tracing into child processes.  To make this work the build system
1800
   also supplies a dummy file, "valgrinq.so". 
1801
1802
   Also replace "vgskin_<foo>.so" with whitespace, for the same reason;
1803
   without it, child processes try to find valgrind.so symbols in the 
1804
   skin .so.
1805
1806
   Also look for $(libdir)/lib/valgrind in LD_LIBRARY_PATH and change
1807
   it to $(libdir)/lib/valgrinq, so as to make our libpthread.so
1808
   disappear.  
1809
*/
1810
static void slideleft ( Char* s )
1811
{
1812
   vg_assert(s && (*s == ' ' || *s == ':'));
1813
   while (True) {
1814
      s[0] = s[1];
1815
      if (s[0] == '\0') break;
1816
      s++;
1817
   }
1818
}
1819
1820
1821
void VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH) ( Char* ld_preload_str,
1822
                                                Char* ld_library_path_str )
1823
{
1824
   Char* vg_prel  = NULL;
1825
   Char* sk_prel  = NULL;
1826
   Char* coredir2 = NULL;
1827
   Char* p;
1828
   Char* coredir_first;
1829
   Char* coredir_last;
1830
   Int   coredir_len;
1831
   Int   i;
1832
   Int   what;
1833
1834
#define MUTANCY(n)   { what = n; goto mutancy; }
1835
1836
   if (ld_preload_str == NULL || ld_library_path_str == NULL) MUTANCY(0);
1837
1838
   /* VG_(printf)("pre:\n%s\n%s\n", ld_preload_str, ld_library_path_str); */
1839
1840
   /* LD_PRELOAD      = "<skindir>/vgskin_foo.so:<coredir>/valgrind.so:X"
1841
      LD_LIBRARY_PATH = "<coredir>:Y"  */
1842
1843
   /* Setting up, finding things */
1844
1845
   /* LD_PRELOAD: Search for "valgrind.so" */
1846
   vg_prel = VG_(strstr)(ld_preload_str, "valgrind.so");
1847
1848
   /* LD_PRELOAD: if "valgrind.so" not found, has been done before;
1849
      "valgrinq.so" should be there instead.  Then stop. */
1850
   if (NULL == vg_prel) {
1851
      if (VG_(strstr)(ld_preload_str, "valgrinq.so") == NULL) MUTANCY(1);
1852
      return;
1853
   }
1854
1855
   /* LD_PRELOAD: find start of <coredir> */
1856
   p = vg_prel;
1857
1858
   for (p = vg_prel;  *p != ':' && p > ld_preload_str;  p--) { }
1859
   if (*p != ':') MUTANCY(2);  /* skin.so entry must precede it */
1860
   coredir_first = p+1;
1861
   coredir_last  = vg_prel - 1;
1862
   coredir_len   = coredir_last - coredir_first;
1863
   
1864
   /* LD_PRELOAD: find "vgskin_foo.so" */
1865
   sk_prel = VG_(strstr)(ld_preload_str, "vgskin_");
1866
   if (sk_prel == NULL) MUTANCY(4);
1867
1868
   /* LD_LIBRARY_PATH: find <coredir> */
1869
   *coredir_last = '\0';      /* Temporarily zero-terminate coredir */
1870
   coredir2 = VG_(strstr)(ld_library_path_str, coredir_first);
1871
   if (coredir2 == NULL) MUTANCY(5);
1872
   *coredir_last = '/';       /* Undo zero-termination */
1873
1874
   /* Changing things */
1875
1876
   /* LD_PRELOAD: "valgrind.so" --> "valgrinq.so" */
1877
   if (vg_prel[7] != 'd') MUTANCY(6);
1878
   vg_prel[7] = 'q';
1879
1880
   /* LD_PRELOAD: "<skindir>/vgskin_foo.so:<coredir>/valgrinq.so:X" -->
1881
                  "          vgskin_foo.so:<coredir>/valgrinq.so:X" */
1882
   p = sk_prel-1;
1883
   while (*p != ':' && p >= ld_preload_str) { 
1884
      *p = ' ';
1885
      p--;
1886
   }
1887
   /* LD_PRELOAD: "          vgskin_foo.so:<coredir>/valgrinq.so:X" -->
1888
                  "                       :<coredir>/valgrinq.so:X" */
1889
   p = sk_prel;
1890
   while (*p != ':' && *p != '\0') { 
1891
      *p = ' ';
1892
      p++;
1893
   }
1894
   if (*p == '\0') MUTANCY(7);    /* valgrind.so has disappeared?! */
1895
1896
   /* LD_LIBRARY_PATH: "<coredir>:Y" --> "         :Y"  */
1897
   for (i = 0; i < coredir_len; i++)
1898
      coredir2[i] = ' ';
1899
   
1900
   /* Zap the leading spaces and : in both strings. */
1901
   while (ld_preload_str[0] == ' ') slideleft(ld_preload_str);
1902
   if    (ld_preload_str[0] == ':') slideleft(ld_preload_str);
1903
1904
   while (ld_library_path_str[0] == ' ') slideleft(ld_library_path_str);
1905
   if    (ld_library_path_str[0] == ':') slideleft(ld_library_path_str);
1906
1907
   /* VG_(printf)("post:\n%s\n%s\n", ld_preload_str, ld_library_path_str); */
1908
1909
   return;
1910
1911
1912
mutancy:
1913
   VG_(printf)(
1914
      "\nVG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH): internal error:\n"
1915
      "   what                = %d\n"
1916
      "   ld_preload_str      = `%s'\n"
1917
      "   ld_library_path_str = `%s'\n"
1918
      "   vg_prel             = `%s'\n"
1919
      "   sk_prel             = `%s'\n"
1920
      "   coredir2            = `%s'\n"
1921
      "   VG_LIBDIR           = `%s'\n",
1922
      what, ld_preload_str, ld_library_path_str, 
1923
      vg_prel, sk_prel, coredir2, VG_LIBDIR 
1924
   );
1925
   VG_(printf)(
1926
      "\n"
1927
      "Note that this is often caused by mis-installation of valgrind.\n"
1928
      "Correct installation procedure is:\n"
1929
      "   ./configure --prefix=/install/dir\n"
1930
      "   make install\n"
1931
      "And then use /install/dir/bin/valgrind\n"
1932
      "Moving the installation directory elsewhere after 'make install'\n"
1933
      "will cause the above error.  Hand-editing the paths in the shell\n"
1934
      "scripts is also likely to cause problems.\n"
1935
      "\n"
1936
   );
1937
   VG_(core_panic)("VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH) failed\n");
1938
}
1939
1940
1941
/* RUNS ON THE CLIENT'S STACK, but on the real CPU.  Start GDB and get
1942
   it to attach to this process.  Called if the user requests this
1943
   service after an error has been shown, so she can poke around and
1944
   look at parameters, memory, etc.  You can't meaningfully get GDB to
1945
   continue the program, though; to continue, quit GDB.  */
1946
extern void VG_(start_GDB_whilst_on_client_stack) ( void )
1947
{
1948
   Int   res;
1949
   UChar buf[100];
1950
1951
   VG_(sprintf)(buf, "%s -nw /proc/%d/exe %d",
1952
                VG_(clo_GDB_path), VG_(getpid)(), VG_(getpid)());
1953
   VG_(message)(Vg_UserMsg, "starting GDB with cmd: %s", buf);
1954
   res = VG_(system)(buf);
1955
   if (res == 0) {      
1956
      VG_(message)(Vg_UserMsg, "");
1957
      VG_(message)(Vg_UserMsg, 
1958
         "GDB has detached.  Valgrind regains control.  We continue.");
1959
   } else {
1960
      VG_(message)(Vg_UserMsg, "Apparently failed!");
1961
      VG_(message)(Vg_UserMsg, "");
1962
   }
3078
   }
1963
}
1964
1965
3079
1966
/* Print some helpful-ish text about unimplemented things, and give
3080
   abort();
1967
   up. */
1968
void VG_(unimplemented) ( Char* msg )
1969
{
1970
   VG_(message)(Vg_UserMsg, "");
1971
   VG_(message)(Vg_UserMsg, 
1972
      "Valgrind detected that your program requires");
1973
   VG_(message)(Vg_UserMsg, 
1974
      "the following unimplemented functionality:");
1975
   VG_(message)(Vg_UserMsg, "   %s", msg);
1976
   VG_(message)(Vg_UserMsg,
1977
      "This may be because the functionality is hard to implement,");
1978
   VG_(message)(Vg_UserMsg,
1979
      "or because no reasonable program would behave this way,");
1980
   VG_(message)(Vg_UserMsg,
1981
      "or because nobody has yet needed it.  In any case, let us know at");
1982
   VG_(message)(Vg_UserMsg,
1983
      "%s and/or try to work around the problem, if you can.", VG_BUGS_TO);
1984
   VG_(message)(Vg_UserMsg,
1985
      "");
1986
   VG_(message)(Vg_UserMsg,
1987
      "Valgrind has to exit now.  Sorry.  Bye!");
1988
   VG_(message)(Vg_UserMsg,
1989
      "");
1990
   VG_(pp_sched_status)();
1991
   VG_(exit)(1);
1992
}
3081
}
1993
3082
1994
3083
1995
/* ---------------------------------------------------------------------
1996
   Sanity check machinery (permanently engaged).
1997
   ------------------------------------------------------------------ */
1998
1999
/* A fast sanity check -- suitable for calling circa once per
2000
   millisecond. */
2001
2002
void VG_(do_sanity_checks) ( Bool force_expensive )
2003
{
2004
   Int          i;
2005
2006
   VGP_PUSHCC(VgpCoreCheapSanity);
2007
2008
   if (VG_(sanity_level) < 1) return;
2009
2010
   /* --- First do all the tests that we can do quickly. ---*/
2011
2012
   VG_(sanity_fast_count)++;
2013
2014
   /* Check that we haven't overrun our private stack. */
2015
   for (i = 0; i < 10; i++) {
2016
      vg_assert(VG_(stack)[i]
2017
                == ((UInt)(&VG_(stack)[i]) ^ 0xA4B3C2D1));
2018
      vg_assert(VG_(stack)[VG_STACK_SIZE_W-1-i] 
2019
                == ((UInt)(&VG_(stack)[VG_STACK_SIZE_W-i-1]) ^ 0xABCD4321));
2020
   }
2021
2022
   /* Check stuff pertaining to the memory check system. */
2023
2024
   /* Check that nobody has spuriously claimed that the first or
2025
      last 16 pages of memory have become accessible [...] */
2026
   if (VG_(needs).sanity_checks) {
2027
      VGP_PUSHCC(VgpSkinCheapSanity);
2028
      vg_assert(SK_(cheap_sanity_check)());
2029
      VGP_POPCC(VgpSkinCheapSanity);
2030
   }
2031
2032
   /* --- Now some more expensive checks. ---*/
2033
2034
   /* Once every 25 times, check some more expensive stuff. */
2035
   if ( force_expensive
2036
     || VG_(sanity_level) > 1
2037
     || (VG_(sanity_level) == 1 && (VG_(sanity_fast_count) % 25) == 0)) {
2038
2039
      VGP_PUSHCC(VgpCoreExpensiveSanity);
2040
      VG_(sanity_slow_count)++;
2041
2042
      VG_(proxy_sanity)();
2043
2044
#     if 0
2045
      { void zzzmemscan(void); zzzmemscan(); }
2046
#     endif
2047
2048
      if ((VG_(sanity_fast_count) % 250) == 0)
2049
         VG_(sanity_check_tc_tt)();
2050
2051
      if (VG_(needs).sanity_checks) {
2052
          VGP_PUSHCC(VgpSkinExpensiveSanity);
2053
          vg_assert(SK_(expensive_sanity_check)());
2054
          VGP_POPCC(VgpSkinExpensiveSanity);
2055
      }
2056
      /* 
2057
      if ((VG_(sanity_fast_count) % 500) == 0) VG_(mallocSanityCheckAll)(); 
2058
      */
2059
      VGP_POPCC(VgpCoreExpensiveSanity);
2060
   }
2061
2062
   if (VG_(sanity_level) > 1) {
2063
      VGP_PUSHCC(VgpCoreExpensiveSanity);
2064
      /* Check sanity of the low-level memory manager.  Note that bugs
2065
         in the client's code can cause this to fail, so we don't do
2066
         this check unless specially asked for.  And because it's
2067
         potentially very expensive. */
2068
      VG_(mallocSanityCheckAll)();
2069
      VGP_POPCC(VgpCoreExpensiveSanity);
2070
   }
2071
   VGP_POPCC(VgpCoreCheapSanity);
2072
}
2073
/*--------------------------------------------------------------------*/
3084
/*--------------------------------------------------------------------*/
2074
/*--- end                                                vg_main.c ---*/
3085
/*--- end                                                vg_main.c ---*/
2075
/*--------------------------------------------------------------------*/
3086
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/vg_malloc2.c (-23 / +92 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 35-40 Link Here
35
/* Define to turn on (heavyweight) debugging machinery. */
35
/* Define to turn on (heavyweight) debugging machinery. */
36
/* #define DEBUG_MALLOC */
36
/* #define DEBUG_MALLOC */
37
37
38
/*------------------------------------------------------------*/
39
/*--- Command line options                                 ---*/
40
/*------------------------------------------------------------*/
41
42
/* Round malloc sizes upwards to integral number of words? default: NO */
43
Bool VG_(clo_sloppy_malloc)  = False;
44
45
/* DEBUG: print malloc details?  default: NO */
46
Bool VG_(clo_trace_malloc)   = False;
47
48
/* Minimum alignment in functions that don't specify alignment explicitly.
49
   default: 0, i.e. use default of the machine (== 4) */
50
Int  VG_(clo_alignment) = 4;
51
52
53
Bool VG_(replacement_malloc_process_cmd_line_option)(Char* arg)
54
{
55
   if      (VG_CLO_STREQN(12, arg, "--alignment=")) {
56
      VG_(clo_alignment) = (Int)VG_(atoll)(&arg[12]);
57
58
      if (VG_(clo_alignment) < 4 
59
          || VG_(clo_alignment) > 4096
60
          || VG_(log2)( VG_(clo_alignment) ) == -1 /* not a power of 2 */) {
61
         VG_(message)(Vg_UserMsg, "");
62
         VG_(message)(Vg_UserMsg, 
63
            "Invalid --alignment= setting.  "
64
            "Should be a power of 2, >= 4, <= 4096.");
65
         VG_(bad_option)("--alignment");
66
      }
67
   }
68
69
   else if (VG_CLO_STREQ(arg, "--sloppy-malloc=yes"))
70
      VG_(clo_sloppy_malloc) = True;
71
   else if (VG_CLO_STREQ(arg, "--sloppy-malloc=no"))
72
      VG_(clo_sloppy_malloc) = False;
73
74
   else if (VG_CLO_STREQ(arg, "--trace-malloc=yes"))
75
      VG_(clo_trace_malloc) = True;
76
   else if (VG_CLO_STREQ(arg, "--trace-malloc=no"))
77
      VG_(clo_trace_malloc) = False;
78
79
   else 
80
      return False;
81
82
   return True;
83
}
84
85
void VG_(replacement_malloc_print_usage)(void)
86
{
87
   VG_(printf)(
88
"    --sloppy-malloc=no|yes    round malloc sizes to next word? [no]\n"
89
"    --alignment=<number>      set minimum alignment of allocations [4]\n"
90
   );
91
}
92
93
void VG_(replacement_malloc_print_debug_usage)(void)
94
{
95
   VG_(printf)(
96
"    --trace-malloc=no|yes     show client malloc details? [no]\n"
97
   );
98
}
99
38
100
39
/*------------------------------------------------------------*/
101
/*------------------------------------------------------------*/
40
/*--- Structs n stuff                                      ---*/
102
/*--- Structs n stuff                                      ---*/
Lines 66-74 Link Here
66
typedef 
128
typedef 
67
   struct {
129
   struct {
68
      Char*       name;
130
      Char*       name;
69
      Int         rz_szW; /* Red zone size in words */
131
      Bool	  clientmem;	/* allocates in the client address space */
70
      Bool        rz_check; /* Check red-zone on free? */
132
      Int         rz_szW;	/* Red zone size in words */
71
      Int         min_sblockW; /* Minimum superblock size */
133
      Bool        rz_check;	/* Check red-zone on free? */
134
      Int         min_sblockW;	/* Minimum superblock size */
72
      WordF*      freelist[VG_N_MALLOC_LISTS];
135
      WordF*      freelist[VG_N_MALLOC_LISTS];
73
      Superblock* sblocks;
136
      Superblock* sblocks;
74
      /* Stats only. */
137
      /* Stats only. */
Lines 143-153 Link Here
143
/* Initialise an arena. */
206
/* Initialise an arena. */
144
static
207
static
145
void arena_init ( Arena* a, Char* name, 
208
void arena_init ( Arena* a, Char* name, 
146
                  Int rz_szW, Bool rz_check, Int min_sblockW )
209
                  Int rz_szW, Bool rz_check, Int min_sblockW, Bool client )
147
{
210
{
148
   Int i;
211
   Int i;
149
   vg_assert((min_sblockW % VKI_WORDS_PER_PAGE) == 0);
212
   vg_assert((min_sblockW % VKI_WORDS_PER_PAGE) == 0);
150
   a->name = name;
213
   a->name = name;
214
   a->clientmem = client;
151
   a->rz_szW = rz_szW;
215
   a->rz_szW = rz_szW;
152
   a->rz_check = rz_check;
216
   a->rz_check = rz_check;
153
   a->min_sblockW = min_sblockW;
217
   a->min_sblockW = min_sblockW;
Lines 190-221 Link Here
190
254
191
   /* Use a checked red zone size of 1 word for our internal stuff,
255
   /* Use a checked red zone size of 1 word for our internal stuff,
192
      and an unchecked zone of arbitrary size for the client.  Of
256
      and an unchecked zone of arbitrary size for the client.  Of
193
      course the client's red zone can be checked by the skin, eg. 
257
      course the client's red zone can be checked by the tool, eg. 
194
      by using addressibility maps, but not by the mechanism implemented
258
      by using addressibility maps, but not by the mechanism implemented
195
      here, which merely checks at the time of freeing that the red 
259
      here, which merely checks at the time of freeing that the red 
196
      zone words are unchanged. */
260
      zone words are unchanged. */
197
261
198
   arena_init ( &vg_arena[VG_AR_CORE],      "core",     1, True, 262144 );
262
   arena_init ( &vg_arena[VG_AR_CORE],      "core",     1, True, 262144, False );
199
263
200
   arena_init ( &vg_arena[VG_AR_SKIN],      "skin",     1, True, 262144 );
264
   arena_init ( &vg_arena[VG_AR_TOOL],      "tool",     1, True, 262144, False );
201
265
202
   arena_init ( &vg_arena[VG_AR_SYMTAB],    "symtab",   1, True, 262144 );
266
   arena_init ( &vg_arena[VG_AR_SYMTAB],    "symtab",   1, True, 262144, False );
203
267
204
   arena_init ( &vg_arena[VG_AR_JITTER],    "JITter",   1, True, 8192 );
268
   arena_init ( &vg_arena[VG_AR_JITTER],    "JITter",   1, True, 8192,   False );
205
269
206
   /* No particular reason for this figure, it's just smallish */
270
   /* No particular reason for this figure, it's just smallish */
207
   sk_assert(VG_(vg_malloc_redzone_szB) < 128);
271
   sk_assert(VG_(vg_malloc_redzone_szB) < 128);
208
   arena_init ( &vg_arena[VG_AR_CLIENT],    "client",  
272
   arena_init ( &vg_arena[VG_AR_CLIENT],    "client",  
209
                VG_(vg_malloc_redzone_szB)/4, False, 262144 );
273
                VG_(vg_malloc_redzone_szB)/4, False, 262144, True );
210
274
211
   arena_init ( &vg_arena[VG_AR_DEMANGLE],  "demangle", 4 /*paranoid*/,
275
   arena_init ( &vg_arena[VG_AR_DEMANGLE],  "demangle", 4 /*paranoid*/,
212
                                                           True, 16384 );
276
                                                           True, 16384, False );
213
277
214
   arena_init ( &vg_arena[VG_AR_EXECTXT],   "exectxt",  1, True, 16384 );
278
   arena_init ( &vg_arena[VG_AR_EXECTXT],   "exectxt",  1, True, 16384, False );
215
279
216
   arena_init ( &vg_arena[VG_AR_ERRORS],    "errors",   1, True, 16384 );
280
   arena_init ( &vg_arena[VG_AR_ERRORS],    "errors",   1, True, 16384, False );
217
281
218
   arena_init ( &vg_arena[VG_AR_TRANSIENT], "transien", 2, True, 16384 );
282
   arena_init ( &vg_arena[VG_AR_TRANSIENT], "transien", 2, True, 16384, False );
219
283
220
   init_done = True;
284
   init_done = True;
221
#  ifdef DEBUG_MALLOC
285
#  ifdef DEBUG_MALLOC
Lines 257-264 Link Here
257
   cszW += 2; /* Take into account sb->next and sb->n_words fields */
321
   cszW += 2; /* Take into account sb->next and sb->n_words fields */
258
   if (cszW < a->min_sblockW) cszW = a->min_sblockW;
322
   if (cszW < a->min_sblockW) cszW = a->min_sblockW;
259
   while ((cszW % VKI_WORDS_PER_PAGE) > 0) cszW++;
323
   while ((cszW % VKI_WORDS_PER_PAGE) > 0) cszW++;
260
   sb = VG_(get_memory_from_mmap) ( cszW * sizeof(Word), 
324
261
                                    "newSuperblock" );
325
   if (a->clientmem) {
326
      sb = (Superblock *)VG_(client_alloc)(0, cszW * sizeof(Word), 
327
					   VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC, 0);
328
   } else
329
      sb = VG_(get_memory_from_mmap) ( cszW * sizeof(Word), 
330
				       "newSuperblock" );
262
   sb->n_payload_words = cszW - 2;
331
   sb->n_payload_words = cszW - 2;
263
   a->bytes_mmaped += cszW * sizeof(Word);
332
   a->bytes_mmaped += cszW * sizeof(Word);
264
   if (0)
333
   if (0)
Lines 1289-1319 Link Here
1289
/*--- Skin-visible functions.                              ---*/
1358
/*--- Skin-visible functions.                              ---*/
1290
/*------------------------------------------------------------*/
1359
/*------------------------------------------------------------*/
1291
1360
1292
/* All just wrappers to avoid exposing arenas to skins */
1361
/* All just wrappers to avoid exposing arenas to tools */
1293
1362
1294
void* VG_(malloc) ( Int nbytes )
1363
void* VG_(malloc) ( Int nbytes )
1295
{
1364
{
1296
   return VG_(arena_malloc) ( VG_AR_SKIN, nbytes );
1365
   return VG_(arena_malloc) ( VG_AR_TOOL, nbytes );
1297
}
1366
}
1298
1367
1299
void  VG_(free) ( void* ptr )
1368
void  VG_(free) ( void* ptr )
1300
{
1369
{
1301
   VG_(arena_free) ( VG_AR_SKIN, ptr );
1370
   VG_(arena_free) ( VG_AR_TOOL, ptr );
1302
}
1371
}
1303
1372
1304
void* VG_(calloc) ( Int nmemb, Int nbytes )
1373
void* VG_(calloc) ( Int nmemb, Int nbytes )
1305
{
1374
{
1306
   return VG_(arena_calloc) ( VG_AR_SKIN, /*alignment*/4, nmemb, nbytes );
1375
   return VG_(arena_calloc) ( VG_AR_TOOL, /*alignment*/4, nmemb, nbytes );
1307
}
1376
}
1308
1377
1309
void* VG_(realloc) ( void* ptr, Int size )
1378
void* VG_(realloc) ( void* ptr, Int size )
1310
{
1379
{
1311
   return VG_(arena_realloc) ( VG_AR_SKIN, ptr, /*alignment*/4, size );
1380
   return VG_(arena_realloc) ( VG_AR_TOOL, ptr, /*alignment*/4, size );
1312
}
1381
}
1313
1382
1314
void* VG_(malloc_aligned) ( Int req_alignB, Int req_pszB )
1383
void* VG_(malloc_aligned) ( Int req_alignB, Int req_pszB )
1315
{
1384
{
1316
   return VG_(arena_malloc_aligned) ( VG_AR_SKIN, req_alignB, req_pszB );
1385
   return VG_(arena_malloc_aligned) ( VG_AR_TOOL, req_alignB, req_pszB );
1317
}
1386
}
1318
1387
1319
1388
(-)valgrind-2.1.0/coregrind/vg_memory.c (-175 / +612 lines)
Lines 9-15 Link Here
9
   This file is part of Valgrind, an extensible x86 protected-mode
9
   This file is part of Valgrind, an extensible x86 protected-mode
10
   emulator for monitoring program execution on x86-Unixes.
10
   emulator for monitoring program execution on x86-Unixes.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 32-250 Link Here
32
32
33
#include "vg_include.h"
33
#include "vg_include.h"
34
34
35
#include <stddef.h>
36
35
/* Define to debug the memory-leak-detector. */
37
/* Define to debug the memory-leak-detector. */
36
/* #define VG_DEBUG_LEAKCHECK */
38
/* #define VG_DEBUG_LEAKCHECK */
37
39
40
static const Bool mem_debug = False;
41
42
static Int addrcmp(const void *ap, const void *bp)
43
{
44
   Addr a = *(Addr *)ap;
45
   Addr b = *(Addr *)bp;
46
   Int ret;
47
48
   if (a == b)
49
      ret = 0;
50
   else
51
      ret = (a < b) ? -1 : 1;
52
53
   return ret;
54
}
55
56
static Char *straddr(void *p)
57
{
58
   static Char buf[16];
59
60
   VG_(sprintf)(buf, "%p", *(Addr *)p);
61
62
   return buf;
63
}
64
65
static SkipList sk_segments = SKIPLIST_INIT(Segment, addr, addrcmp, straddr, VG_AR_CORE);
38
66
39
/*--------------------------------------------------------------*/
67
/*--------------------------------------------------------------*/
40
/*--- Initialise program data/text etc on program startup.   ---*/
68
/*--- Maintain an ordered list of all the client's mappings  ---*/
41
/*--------------------------------------------------------------*/
69
/*--------------------------------------------------------------*/
42
70
43
typedef
71
Bool VG_(seg_contains)(const Segment *s, Addr p, UInt len)
44
   struct _ExeSeg {
72
{
45
      Addr start;
73
   Addr se = s->addr+s->len;
46
      UInt size;
74
   Addr pe = p+len;
47
      struct _ExeSeg* next;
48
   }
49
   ExeSeg;
50
51
/* The list of current executable segments loaded.  Required so that when a
52
   segment is munmap'd, if it's executable we can recognise it as such and
53
   invalidate translations for it, and drop any basic-block specific
54
   information being stored.  If symbols are being used, this list will have
55
   the same segments recorded in it as the SegInfo symbols list (but much
56
   less information about each segment).
57
*/
58
static ExeSeg* exeSegsHead = NULL;
59
75
60
/* Prepend it -- mmaps/munmaps likely to follow a stack pattern(?) so this
76
   vg_assert(pe >= p);
61
   is good.
77
62
   Also check no segments overlap, which would be very bad.  Check is linear
78
   return (p >= s->addr && pe <= se);
63
   for each seg added (quadratic overall) but the total number should be
79
}
64
   small (konqueror has around 50 --njn). */
80
65
static void add_exe_segment_to_list( Addr a, UInt len ) 
81
Bool VG_(seg_overlaps)(const Segment *s, Addr p, UInt len)
66
{
82
{
67
   Addr lo = a;
83
   Addr se = s->addr+s->len;
68
   Addr hi = a + len - 1;
84
   Addr pe = p+len;
69
   ExeSeg* es;
85
70
   ExeSeg* es2;
86
   vg_assert(pe >= p);
71
   
87
72
   /* Prepend it */
88
   return (p < se && pe > s->addr);
73
   es        = (ExeSeg*)VG_(arena_malloc)(VG_AR_CORE, sizeof(ExeSeg));
89
}
74
   es->start = a;
90
75
   es->size  = len;
91
/* Prepare a Segment structure for recycling by freeing everything
76
   es->next  = exeSegsHead;
92
   hanging off it. */
77
   exeSegsHead = es;
93
static void recycleseg(Segment *s)
78
94
{
79
   /* Check there's no overlap with the rest of the list */
95
   if (s->flags & SF_CODE)
80
   for (es2 = es->next; es2 != NULL; es2 = es2->next) {
96
      VG_(invalidate_translations)(s->addr, s->len, False);
81
      Addr lo2 = es2->start;
97
82
      Addr hi2 = es2->start + es2->size - 1;
98
   if (s->filename != NULL)
83
      Bool overlap;
99
      VG_(arena_free)(VG_AR_CORE, (Char *)s->filename);
84
      vg_assert(lo < hi);
100
85
      vg_assert(lo2 < hi2);
101
   /* keep the SegInfo, if any - it probably still applies */
86
      /* the main assertion */
102
}
87
      overlap = (lo <= lo2 && lo2 <= hi)
103
88
                 || (lo <= hi2 && hi2 <= hi);
104
/* When freeing a Segment, also clean up every one else's ideas of
89
      if (overlap) {
105
   what was going on in that range of memory */
90
         VG_(printf)("\n\nOVERLAPPING EXE SEGMENTS\n"
106
static void freeseg(Segment *s)
91
                     "  new: start %p, size %d\n"
107
{
92
                     "  old: start %p, size %d\n\n",
108
   recycleseg(s);
93
                     es->start, es->size, es2->start, es2->size );
109
   if (s->symtab != NULL) {
94
         vg_assert(! overlap);
110
      VG_(symtab_decref)(s->symtab, s->addr, s->len);
95
      }
111
      s->symtab = NULL;
96
   }
112
   }
113
114
   VG_(SkipNode_Free)(&sk_segments, s);
97
}
115
}
98
116
99
static Bool remove_if_exeseg_from_list( Addr a )
117
/* Split a segment at address a, returning the new segment */
118
Segment *VG_(split_segment)(Addr a)
100
{
119
{
101
   ExeSeg **prev_next_ptr = & exeSegsHead, 
120
   Segment *s = VG_(SkipList_Find)(&sk_segments, &a);
102
          *curr = exeSegsHead;
121
   Segment *ns;
122
   Int delta;
123
124
   vg_assert((a & (VKI_BYTES_PER_PAGE-1)) == 0);
125
126
   /* missed */
127
   if (s == NULL)
128
      return NULL;
103
129
104
   while (True) {
130
   /* a at or beyond endpoint */
105
      if (curr == NULL) break;
131
   if (s->addr == a || a >= (s->addr+s->len))
106
      if (a == curr->start) break;
132
      return NULL;
107
      prev_next_ptr = &curr->next;
133
108
      curr = curr->next;
134
   vg_assert(a > s->addr && a < (s->addr+s->len));
135
136
   ns = VG_(SkipNode_Alloc)(&sk_segments);
137
138
   *ns = *s;
139
140
   delta = a - s->addr;
141
   ns->addr += delta;
142
   ns->offset += delta;
143
   ns->len -= delta;
144
   s->len = delta;
145
146
   if (s->filename != NULL)
147
      ns->filename = VG_(arena_strdup)(VG_AR_CORE, s->filename);
148
149
   if (ns->symtab != NULL)
150
      VG_(symtab_incref)(ns->symtab);
151
152
   VG_(SkipList_Insert)(&sk_segments, ns);
153
154
   return ns;
155
}
156
157
/* This unmaps all the segments in the range [addr, addr+len); any
158
   partial mappings at the ends are truncated. */
159
void VG_(unmap_range)(Addr addr, UInt len)
160
{
161
   Segment *s;
162
   Segment *next;
163
   static const Bool debug = False || mem_debug;
164
   Addr end;
165
166
   if (len == 0)
167
      return;
168
169
   len = PGROUNDUP(len);
170
   vg_assert(addr == PGROUNDDN(addr));
171
172
   if (debug)
173
      VG_(printf)("unmap_range(%p, %d)\n", addr, len);
174
175
   end = addr+len;
176
177
   /* Everything must be page-aligned */
178
   vg_assert((addr & (VKI_BYTES_PER_PAGE-1)) == 0);
179
   vg_assert((len  & (VKI_BYTES_PER_PAGE-1)) == 0);
180
181
   for(s = VG_(SkipList_Find)(&sk_segments, &addr); 
182
       s != NULL && s->addr < (addr+len); 
183
       s = next) {
184
      Addr seg_end = s->addr + s->len;
185
186
      /* fetch next now in case we end up deleting this segment */
187
      next = VG_(SkipNode_Next)(&sk_segments, s);
188
189
      if (debug)
190
	 VG_(printf)("unmap: addr=%p-%p s=%p ->addr=%p-%p len=%d\n",
191
		     addr, end, s, s->addr, seg_end, s->len);
192
193
      if (!VG_(seg_overlaps)(s, addr, len)) {
194
	 if (debug)
195
	    VG_(printf)("   (no overlap)\n");
196
	 continue;
197
      }
198
199
      /* 4 cases: */
200
      if (addr > s->addr &&
201
	  addr < seg_end &&
202
	  end >= seg_end) {
203
	 /* this segment's tail is truncated by [addr, addr+len)
204
	    -> truncate tail
205
	 */
206
	 s->len = addr - s->addr;
207
208
	 if (debug)
209
	    VG_(printf)("  case 1: s->len=%d\n", s->len);
210
      } else if (addr <= s->addr && end > s->addr && end < seg_end) {
211
	 /* this segment's head is truncated by [addr, addr+len)
212
	    -> truncate head
213
	 */
214
	 Int delta = end - s->addr;
215
216
	 if (debug)
217
	    VG_(printf)("  case 2: s->addr=%p s->len=%d delta=%d\n", s->addr, s->len, delta);
218
219
	 s->addr += delta;
220
	 s->offset += delta;
221
	 s->len -= delta;
222
223
	 vg_assert(s->len != 0);
224
      } else if (addr <= s->addr && end >= seg_end) {
225
	 /* this segment is completely contained within [addr, addr+len)
226
	    -> delete segment
227
	 */
228
	 Segment *rs = VG_(SkipList_Remove)(&sk_segments, &s->addr);
229
	 vg_assert(rs == s);
230
	 freeseg(s);
231
232
	 if (debug)
233
	    VG_(printf)("  case 3: s==%p deleted\n", s);
234
      } else if (addr > s->addr && end < seg_end) {
235
	 /* [addr, addr+len) is contained within a single segment
236
	    -> split segment into 3, delete middle portion
237
	  */
238
	 Segment *middle, *rs;
239
240
	 middle = VG_(split_segment)(addr);
241
	 VG_(split_segment)(addr+len);
242
243
	 vg_assert(middle->addr == addr);
244
	 rs = VG_(SkipList_Remove)(&sk_segments, &addr);
245
	 vg_assert(rs == middle);
246
247
	 freeseg(rs);
248
249
	 if (debug)
250
	    VG_(printf)("  case 4: subrange %p-%p deleted\n",
251
			addr, addr+len);
252
      }
109
   }
253
   }
110
   if (curr == NULL)
254
}
255
256
/* Return true if two segments are adjacent and mergable (s1 is
257
   assumed to have a lower ->addr than s2) */
258
static inline Bool neighbours(Segment *s1, Segment *s2)
259
{
260
   if (s1->addr+s1->len != s2->addr)
111
      return False;
261
      return False;
112
262
113
   vg_assert(*prev_next_ptr == curr);
263
   if (s1->flags != s2->flags)
264
      return False;
114
265
115
   *prev_next_ptr = curr->next;
266
   if (s1->prot != s2->prot)
267
      return False;
116
268
117
   VG_(arena_free)(VG_AR_CORE, curr);
269
   if (s1->symtab != s2->symtab)
118
   return True;
270
      return False;
119
}
120
271
121
/* Records the exe segment in the ExeSeg list (checking for overlaps), and
272
   if (s1->flags & SF_FILE){
122
   reads debug info if required.  Note the entire /proc/pid/maps file is 
273
      if ((s1->offset + s1->len) != s2->offset)
123
   read for the debug info, but it just reads symbols for newly added exe
274
	 return False;
124
   segments.  This is required to find out their names if they have one,
275
      if (s1->dev != s2->dev)
125
   because with mmap() we only have the file descriptor, not the name.  We
276
	 return False;
126
   don't use this at startup because we do have the names then. */
277
      if (s1->ino != s2->ino)
127
void VG_(new_exeseg_mmap) ( Addr a, UInt len )
278
	 return False;
128
{
129
   add_exe_segment_to_list( a, len );
130
   VG_(read_all_symbols)();
131
}
132
133
/* Like VG_(new_exeseg_mmap)(), but here we do have the name, so we don't
134
   need to grovel through /proc/self/maps to find it. */
135
void VG_(new_exeseg_startup) ( Addr a, UInt len, Char rr, Char ww, Char xx,
136
                               UInt foffset, UChar* filename )
137
{
138
   add_exe_segment_to_list( a, len );
139
   VG_(read_seg_symbols)( a, len, rr, ww, xx, foffset, filename);
140
}
141
142
/* Invalidate translations as necessary (also discarding any basic
143
   block-specific info retained by the skin) and unload any debug
144
   symbols. */
145
// Nb: remove_if_exeseg_from_list() and VG_(maybe_unload_symbols)()
146
// both ignore 'len', but that seems that's ok for most programs...  see
147
// comment above vg_syscalls.c:mmap_segment() et al for more details.
148
void VG_(remove_if_exeseg) ( Addr a, UInt len )
149
{
150
   if (remove_if_exeseg_from_list( a )) {
151
      VG_(invalidate_translations) ( a, len, False );
152
      VG_(unload_symbols)          ( a, len );
153
   }
279
   }
280
   
281
   return True;
154
}
282
}
155
283
284
/* If possible, merge segment with its neighbours - some segments,
285
   including s, may be destroyed in the process */
286
static void merge_segments(Addr a, UInt len)
287
{
288
   Segment *s;
289
   Segment *next;
156
290
157
static
291
   vg_assert((a & (VKI_BYTES_PER_PAGE-1)) == 0);
158
void startup_segment_callback ( Addr start, UInt size, 
292
   vg_assert((len & (VKI_BYTES_PER_PAGE-1)) == 0);
159
                                Char rr, Char ww, Char xx, 
293
160
                                UInt foffset, UChar* filename )
294
   a -= VKI_BYTES_PER_PAGE;
161
{
295
   len += VKI_BYTES_PER_PAGE;
162
   UInt r_esp;
296
163
   Bool is_stack_segment;
297
   for(s = VG_(SkipList_Find)(&sk_segments, &a);
164
   Bool verbose = False; /* set to True for debugging */
298
       s != NULL && s->addr < (a+len);) {
165
299
      next = VG_(SkipNode_Next)(&sk_segments, s);
166
   if (verbose)
300
167
      VG_(message)(Vg_DebugMsg,
301
      if (next && neighbours(s, next)) {
168
                   "initial map %8x-%8x %c%c%c? %8x (%d) (%s)",
302
	 Segment *rs;
169
                   start,start+size,rr,ww,xx,foffset,
303
170
                   size, filename?filename:(UChar*)"NULL");
304
	 if (0)
171
305
	    VG_(printf)("merge %p-%p with %p-%p\n",
172
   if (rr != 'r' && xx != 'x' && ww != 'w') {
306
			s->addr, s->addr+s->len,
173
      /* Implausible as it seems, R H 6.2 generates such segments:
307
			next->addr, next->addr+next->len);
174
      40067000-400ac000 r-xp 00000000 08:05 320686 /usr/X11R6/lib/libXt.so.6.0
308
	 s->len += next->len;
175
      400ac000-400ad000 ---p 00045000 08:05 320686 /usr/X11R6/lib/libXt.so.6.0
309
	 s = VG_(SkipNode_Next)(&sk_segments, next);
176
      400ad000-400b0000 rw-p 00045000 08:05 320686 /usr/X11R6/lib/libXt.so.6.0
310
177
      when running xedit. So just ignore them. */
311
	 rs = VG_(SkipList_Remove)(&sk_segments, &next->addr);
178
      if (0)
312
	 vg_assert(next == rs);
179
         VG_(printf)("No permissions on a segment mapped from %s\n", 
313
	 freeseg(next);
180
                     filename?filename:(UChar*)"NULL");
314
      } else
181
      return;
315
	 s = next;
182
   }
316
   }
317
}
183
318
184
   /* If this segment corresponds to something mmap'd /dev/zero by the
319
void VG_(map_file_segment)(Addr addr, UInt len, UInt prot, UInt flags, 
185
      low-level memory manager (vg_malloc2.c), skip it.  Clients
320
			   UInt dev, UInt ino, ULong off, const Char *filename)
186
      should never have access to the segments which hold valgrind
321
{
187
      internal data.  And access to client data in the VG_AR_CLIENT
322
   Segment *s;
188
      arena is mediated by the skin, so we don't want make it
323
   static const Bool debug = False || mem_debug;
189
      accessible at this stage. */
324
   Bool recycled;
190
   if (VG_(is_inside_segment_mmapd_by_low_level_MM)( start )) {
325
191
      if (verbose)
326
   if (debug)
192
         VG_(message)(Vg_DebugMsg,
327
      VG_(printf)("map_file_segment(%p, %d, %x, %x, %4x, %d, %ld, %s)\n",
193
                      "   skipping %8x-%8x (owned by our MM)", 
328
		  addr, len, prot, flags, dev, ino, off, filename);
194
                      start, start+size );
329
195
      /* Don't announce it to the skin. */
330
   /* Everything must be page-aligned */
196
      return;
331
   vg_assert((addr & (VKI_BYTES_PER_PAGE-1)) == 0);
332
   len = PGROUNDUP(len);
333
334
   /* First look to see what already exists around here */
335
   s = VG_(SkipList_Find)(&sk_segments, &addr);
336
337
   if (s != NULL && s->addr == addr && s->len == len) {
338
      /* This probably means we're just updating the flags */
339
      recycled = True;
340
      recycleseg(s);
341
342
      /* If we had a symtab, but the new mapping is incompatible, then
343
	 free up the old symtab in preparation for a new one. */
344
      if (s->symtab != NULL		&&
345
	  (!(s->flags & SF_FILE)	||
346
	   !(flags & SF_FILE)		||
347
	   s->dev != dev		||
348
	   s->ino != ino		||
349
	   s->offset != off)) {
350
	 VG_(symtab_decref)(s->symtab, s->addr, s->len);
351
	 s->symtab = NULL;
352
      }
353
   } else {
354
      recycled = False;
355
      VG_(unmap_range)(addr, len);
356
357
      s = VG_(SkipNode_Alloc)(&sk_segments);
358
359
      s->addr   = addr;
360
      s->len    = len;
361
      s->symtab = NULL;
197
   }
362
   }
363
364
   s->flags  = flags;
365
   s->prot   = prot;
366
   s->dev    = dev;
367
   s->ino    = ino;
368
   s->offset = off;
198
   
369
   
199
   /* This is similar to what happens when we mmap some new memory */
370
   if (filename != NULL)
200
   if (filename != NULL && xx == 'x') {
371
      s->filename = VG_(arena_strdup)(VG_AR_CORE, filename);
201
      VG_(new_exeseg_startup)( start, size, rr, ww, xx, foffset, filename );
372
   else
373
      s->filename = NULL;
374
375
   if (debug) {
376
      Segment *ts;
377
      for(ts = VG_(SkipNode_First)(&sk_segments);
378
	  ts != NULL;
379
	  ts = VG_(SkipNode_Next)(&sk_segments, ts))
380
	 VG_(printf)("list: %8p->%8p ->%d (0x%x) prot=%x flags=%x\n",
381
		     ts, ts->addr, ts->len, ts->len, ts->prot, ts->flags);
382
383
      VG_(printf)("inserting s=%p addr=%p len=%d\n",
384
		  s, s->addr, s->len);
202
   }
385
   }
203
386
204
   VG_TRACK( new_mem_startup, start, size, rr=='r', ww=='w', xx=='x' );
387
   if (!recycled)
388
      VG_(SkipList_Insert)(&sk_segments, s);
205
389
206
   /* If this is the stack segment mark all below %esp as noaccess. */
390
   /* If this mapping is of the beginning of a file, isn't part of
207
   r_esp = VG_(baseBlock)[VGOFF_(m_esp)];
391
      Valgrind, is at least readable and seems to contain an object
208
   is_stack_segment = start <= r_esp && r_esp < start+size;
392
      file, then try reading symbols from it. */
209
   if (is_stack_segment) {
393
   if ((flags & (SF_MMAP|SF_NOSYMS)) == SF_MMAP	&&
210
      if (0)
394
       s->symtab == NULL) {
211
         VG_(message)(Vg_DebugMsg, "invalidating stack area: %x .. %x",
395
      if (off == 0									&&
212
                      start,r_esp);
396
	  filename != NULL								&&
213
      VG_TRACK( die_mem_stack, start, r_esp-start );
397
	  (prot & (VKI_PROT_READ|VKI_PROT_EXEC)) == (VKI_PROT_READ|VKI_PROT_EXEC)	&&
398
	  len >= VKI_BYTES_PER_PAGE							&&
399
	  s->symtab == NULL								&&
400
	  VG_(is_object_file)((void *)addr)) 
401
      {
402
         s->symtab = VG_(read_seg_symbols)(s);
403
404
         if (s->symtab != NULL) {
405
            s->flags |= SF_DYNLIB;
406
         }
407
      } else if (flags & SF_MMAP) {
408
	 const SegInfo *info;
409
410
	 /* Otherwise see if an existing symtab applies to this Segment */
411
	 for(info = VG_(next_seginfo)(NULL);
412
	     info != NULL;
413
	     info = VG_(next_seginfo)(info)) {
414
	    if (VG_(seg_overlaps)(s, VG_(seg_start)(info), VG_(seg_size)(info)))
415
            {
416
	       s->symtab = (SegInfo *)info;
417
	       VG_(symtab_incref)((SegInfo *)info);
418
	    }
419
	 }
420
      }
214
   }
421
   }
422
423
   /* clean up */
424
   merge_segments(addr, len);
215
}
425
}
216
426
427
void VG_(map_fd_segment)(Addr addr, UInt len, UInt prot, UInt flags, 
428
			 Int fd, ULong off, const Char *filename)
429
{
430
   struct vki_stat st;
431
   Char *name = NULL;
217
432
218
/* 1. Records startup segments from /proc/pid/maps.  Takes special note
433
   st.st_dev = 0;
219
      of the executable ones, because if they're munmap()ed we need to
434
   st.st_ino = 0;
220
      discard translations.  Also checks there's no exe segment overlaps.
221
435
222
      Note that `read_from_file' is false;  we read /proc/self/maps into a
436
   if (fd != -1 && (flags & SF_FILE)) {
223
      buffer at the start of VG_(main) so that any superblocks mmap'd by
437
      vg_assert((off & (VKI_BYTES_PER_PAGE-1)) == 0);
224
      calls to VG_(malloc)() by SK_({pre,post}_clo_init) aren't erroneously
225
      thought of as being owned by the client.
226
438
227
   2. Sets up the end of the data segment so that vg_syscalls.c can make
439
      if (VG_(fstat)(fd, &st) < 0)
228
      sense of calls to brk().
440
	 flags &= ~SF_FILE;
229
 */
441
   }
230
void VG_(init_memory) ( void )
442
443
   if ((flags & SF_FILE) && filename == NULL && fd != -1)
444
      name = VG_(resolve_filename)(fd);
445
446
   if (filename == NULL)
447
      filename = name;
448
449
   VG_(map_file_segment)(addr, len, prot, flags, st.st_dev, st.st_ino, off, filename);
450
451
   if (name)
452
      VG_(arena_free)(VG_AR_CORE, name);
453
}
454
455
void VG_(map_segment)(Addr addr, UInt len, UInt prot, UInt flags)
456
{
457
   flags &= ~SF_FILE;
458
459
   VG_(map_file_segment)(addr, len, prot, flags, 0, 0, 0, 0);
460
}
461
462
/* set new protection flags on an address range */
463
void VG_(mprotect_range)(Addr a, UInt len, UInt prot)
231
{
464
{
232
   /* 1 */
465
   Segment *s, *next;
233
   VG_(parse_procselfmaps) ( startup_segment_callback );
466
   static const Bool debug = False || mem_debug;
467
468
   if (debug)
469
      VG_(printf)("mprotect_range(%p, %d, %x)\n", a, len, prot);
470
471
   /* Everything must be page-aligned */
472
   vg_assert((a & (VKI_BYTES_PER_PAGE-1)) == 0);
473
   len = PGROUNDUP(len);
474
475
   VG_(split_segment)(a);
476
   VG_(split_segment)(a+len);
477
478
   for(s = VG_(SkipList_Find)(&sk_segments, &a);
479
       s != NULL && s->addr < a+len;
480
       s = next)
481
   {
482
      next = VG_(SkipNode_Next)(&sk_segments, s);
483
      if (s->addr < a)
484
	 continue;
485
486
      s->prot = prot;
487
   }
488
489
   merge_segments(a, len);
490
}
491
492
Addr VG_(find_map_space)(Addr addr, UInt len, Bool for_client)
493
{
494
   static const Bool debug = False || mem_debug;
495
   Segment *s;
496
   Addr ret;
497
   Addr limit = (for_client ? VG_(client_end) : VG_(valgrind_mmap_end));
498
499
   if (addr == 0)
500
      addr = for_client ? VG_(client_mapbase) : VG_(valgrind_base);
501
   else {
502
      /* leave space for redzone and still try to get the exact
503
	 address asked for */
504
      addr -= VKI_BYTES_PER_PAGE;
505
   }
506
   ret = addr;
507
508
   /* Everything must be page-aligned */
509
   vg_assert((addr & (VKI_BYTES_PER_PAGE-1)) == 0);
510
   len = PGROUNDUP(len);
511
512
   len += VKI_BYTES_PER_PAGE * 2; /* leave redzone gaps before and after mapping */
513
514
   if (debug)
515
      VG_(printf)("find_map_space: ret starts as %p-%p client=%d\n",
516
		  ret, ret+len, for_client);
517
518
   for(s = VG_(SkipList_Find)(&sk_segments, &ret);
519
       s != NULL && s->addr < (ret+len);
520
       s = VG_(SkipNode_Next)(&sk_segments, s))
521
   {
522
      if (debug)
523
	 VG_(printf)("s->addr=%p len=%d (%p) ret=%p\n",
524
		     s->addr, s->len, s->addr+s->len, ret);
234
525
235
   /* 2 */
526
      if (s->addr < (ret + len) && (s->addr + s->len) > ret)
236
   VG_(init_dataseg_end_for_brk)();
527
	 ret = s->addr+s->len;
528
   }
529
530
   if (debug) {
531
      if (s)
532
	 VG_(printf)("  s->addr=%p ->len=%d\n", s->addr, s->len);
533
      else
534
	 VG_(printf)("  s == NULL\n");
535
   }
237
536
238
   /* kludge: some newer kernels place a "sysinfo" page up high, with
537
   if ((limit - len) < ret)
239
      vsyscalls in it, and possibly some other stuff in the future. */
538
      ret = 0;			/* no space */
240
   if (VG_(sysinfo_page_exists)) {
539
   else
241
      // 2003-Sep-25, njn: Jeremy thinks the sysinfo page probably doesn't
540
      ret += VKI_BYTES_PER_PAGE; /* skip leading redzone */
242
      // have any symbols that need to be loaded.  So just treat it like
541
243
      // a non-executable page.
542
   if (debug)
244
      //VG_(new_exeseg_mmap)( VG_(sysinfo_page_addr), 4096 );
543
      VG_(printf)("find_map_space(%p, %d, %d) -> %p\n",
245
      VG_TRACK( new_mem_startup, VG_(sysinfo_page_addr), 4096, 
544
		  addr, len, for_client, ret);
246
                True, True, True );
545
   
247
     }
546
   return ret;
547
}
548
549
Segment *VG_(find_segment)(Addr a)
550
{
551
   return VG_(SkipList_Find)(&sk_segments, &a);
552
}
553
554
Segment *VG_(next_segment)(Segment *s)
555
{
556
   return VG_(SkipNode_Next)(&sk_segments, s);
248
}
557
}
249
558
250
/*------------------------------------------------------------*/
559
/*------------------------------------------------------------*/
Lines 359-364 Link Here
359
}
668
}
360
669
361
/*--------------------------------------------------------------------*/
670
/*--------------------------------------------------------------------*/
671
/*--- manage allocation of memory on behalf of the client          ---*/
672
/*--------------------------------------------------------------------*/
673
674
Addr VG_(client_alloc)(Addr addr, UInt len, UInt prot, UInt flags)
675
{
676
   len = PGROUNDUP(len);
677
678
   if (!(flags & SF_FIXED))
679
      addr = VG_(find_map_space)(addr, len, True);
680
681
   flags |= SF_CORE;
682
683
   if (VG_(mmap)((void *)addr, len, prot,
684
		 VKI_MAP_FIXED | VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS | VKI_MAP_CLIENT,
685
		 -1, 0) == (void *)addr) {
686
      VG_(map_segment)(addr, len, prot, flags);
687
      return addr;
688
   }
689
690
   return 0;
691
}
692
693
void VG_(client_free)(Addr addr)
694
{
695
   Segment *s = VG_(find_segment)(addr);
696
697
   if (s == NULL || s->addr != addr || !(s->flags & SF_CORE)) {
698
      VG_(message)(Vg_DebugMsg, "VG_(client_free)(%p) - no CORE memory found there", addr);
699
      return;
700
   }
701
702
   VG_(munmap)((void *)s->addr, s->len);
703
}
704
705
Bool VG_(is_client_addr)(Addr a)
706
{
707
   return a >= VG_(client_base) && a < VG_(client_end);
708
}
709
710
Bool VG_(is_shadow_addr)(Addr a)
711
{
712
   return a >= VG_(shadow_base) && a < VG_(shadow_end);
713
}
714
715
Bool VG_(is_valgrind_addr)(Addr a)
716
{
717
   return a >= VG_(valgrind_base) && a < VG_(valgrind_end);
718
}
719
720
Addr VG_(get_client_base)(void)
721
{
722
   return VG_(client_base);
723
}
724
725
Addr VG_(get_client_end)(void)
726
{
727
   return VG_(client_end);
728
}
729
730
Addr VG_(get_client_size)(void)
731
{
732
   return VG_(client_end)-VG_(client_base);
733
}
734
735
Addr VG_(get_shadow_base)(void)
736
{
737
   return VG_(shadow_base);
738
}
739
740
Addr VG_(get_shadow_end)(void)
741
{
742
   return VG_(shadow_end);
743
}
744
745
Addr VG_(get_shadow_size)(void)
746
{
747
   return VG_(shadow_end)-VG_(shadow_base);
748
}
749
750
751
void VG_(init_shadow_range)(Addr p, UInt sz, Bool call_init)
752
{
753
   if (0)
754
      VG_(printf)("init_shadow_range(%p, %d)\n", p, sz);
755
756
   vg_assert(VG_(needs).shadow_memory);
757
   vg_assert(VG_(defined_init_shadow_page)());
758
759
   sz = PGROUNDUP(p+sz) - PGROUNDDN(p);
760
   p = PGROUNDDN(p);
761
762
   VG_(mprotect)((void *)p, sz, VKI_PROT_READ|VKI_PROT_WRITE);
763
   
764
   if (call_init) 
765
      while(sz) {
766
	 /* ask the skin to initialize each page */
767
	 VG_TRACK( init_shadow_page, PGROUNDDN(p) );
768
	 
769
	 p += VKI_BYTES_PER_PAGE;
770
	 sz -= VKI_BYTES_PER_PAGE;
771
      }
772
}
773
774
void *VG_(shadow_alloc)(UInt size)
775
{
776
   static Addr shadow_alloc = 0;
777
   void *ret;
778
779
   vg_assert(VG_(needs).shadow_memory);
780
   vg_assert(!VG_(defined_init_shadow_page)());
781
782
   size = PGROUNDUP(size);
783
784
   if (shadow_alloc == 0)
785
      shadow_alloc = VG_(shadow_base);
786
787
   if (shadow_alloc >= VG_(shadow_end))
788
       return 0;
789
790
   ret = (void *)shadow_alloc;
791
   VG_(mprotect)(ret, size, VKI_PROT_READ|VKI_PROT_WRITE);
792
793
   shadow_alloc += size;
794
795
   return ret;
796
}
797
798
/*--------------------------------------------------------------------*/
362
/*--- end                                              vg_memory.c ---*/
799
/*--- end                                              vg_memory.c ---*/
363
/*--------------------------------------------------------------------*/
800
/*--------------------------------------------------------------------*/
364
801
(-)valgrind-2.1.0/coregrind/vg_messages.c (-1 / +1 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/coregrind/vg_mylibc.c (-135 / +243 lines)
Lines 9-15 Link Here
9
   This file is part of Valgrind, an extensible x86 protected-mode
9
   This file is part of Valgrind, an extensible x86 protected-mode
10
   emulator for monitoring program execution on x86-Unixes.
10
   emulator for monitoring program execution on x86-Unixes.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 248-262 Link Here
248
void* VG_(mmap)( void* start, UInt length, 
248
void* VG_(mmap)( void* start, UInt length, 
249
                 UInt prot, UInt flags, UInt fd, UInt offset)
249
                 UInt prot, UInt flags, UInt fd, UInt offset)
250
{
250
{
251
   Int  res;
251
   Addr  res;
252
   UInt args[6];
252
   UInt args[6];
253
254
   if (!(flags & VKI_MAP_FIXED)) {
255
      start = (void *)VG_(find_map_space)((Addr)start, length, !!(flags & VKI_MAP_CLIENT));
256
      if (start == 0)
257
	 return (void *)-1;
258
259
      flags |= VKI_MAP_FIXED;
260
   }
261
253
   args[0] = (UInt)start;
262
   args[0] = (UInt)start;
254
   args[1] = length;
263
   args[1] = length;
255
   args[2] = prot;
264
   args[2] = prot;
256
   args[3] = flags;
265
   args[3] = flags & ~(VKI_MAP_NOSYMS|VKI_MAP_CLIENT);
257
   args[4] = fd;
266
   args[4] = fd;
258
   args[5] = offset;
267
   args[5] = offset;
259
   res = VG_(do_syscall)(__NR_mmap, (UInt)(&(args[0])) );
268
   res = VG_(do_syscall)(__NR_mmap, (UInt)(&(args[0])) );
269
270
   if (!VG_(is_kerror)(res)) {
271
      UInt sf_flags = SF_MMAP;
272
273
      if (flags & VKI_MAP_FIXED)
274
	 sf_flags |= SF_FIXED;
275
      if (flags & VKI_MAP_SHARED)
276
	 sf_flags |= SF_SHARED;
277
      if (!(flags & VKI_MAP_ANONYMOUS))
278
	 sf_flags |= SF_FILE;
279
      if (!(flags & VKI_MAP_CLIENT))
280
	 sf_flags |= SF_VALGRIND;
281
      if (flags & VKI_MAP_NOSYMS)
282
	 sf_flags |= SF_NOSYMS;
283
284
      /* placeholder - caller will update flags etc if they want */
285
      VG_(map_fd_segment)(res, length, prot, sf_flags, fd, offset, NULL);
286
287
      if (flags & VKI_MAP_CLIENT) {
288
	 if (res < VG_(client_base) || res >= VG_(client_end)) {
289
	    VG_(munmap)((void *)res, length);
290
	    res = -1;
291
	 }
292
      } else {
293
	 if (res < VG_(valgrind_base) || res >= VG_(valgrind_end)) {
294
	    VG_(munmap)((void *)res, length);
295
	    res = -1;
296
	 }
297
      }
298
   }
299
300
   
301
260
   return VG_(is_kerror)(res) ? ((void*)(-1)) : (void*)res;
302
   return VG_(is_kerror)(res) ? ((void*)(-1)) : (void*)res;
261
}
303
}
262
304
Lines 264-269 Link Here
264
Int VG_(munmap)( void* start, Int length )
306
Int VG_(munmap)( void* start, Int length )
265
{
307
{
266
   Int res = VG_(do_syscall)(__NR_munmap, (UInt)start, (UInt)length );
308
   Int res = VG_(do_syscall)(__NR_munmap, (UInt)start, (UInt)length );
309
   if (!VG_(is_kerror)(res))
310
      VG_(unmap_range)((Addr)start, length);
311
   return VG_(is_kerror)(res) ? -1 : 0;
312
}
313
314
Int VG_(mprotect)( void *start, Int length, UInt prot )
315
{
316
   Int res = VG_(do_syscall)(__NR_mprotect, (UInt)start, (UInt)length, prot );
317
   if (!VG_(is_kerror)(res))
318
      VG_(mprotect_range)((Addr)start, length, prot);
267
   return VG_(is_kerror)(res) ? -1 : 0;
319
   return VG_(is_kerror)(res) ? -1 : 0;
268
}
320
}
269
321
Lines 968-984 Link Here
968
__inline__ Char* VG_(arena_strdup) ( ArenaId aid, const Char* s )
1020
__inline__ Char* VG_(arena_strdup) ( ArenaId aid, const Char* s )
969
{
1021
{
970
   Int   i;
1022
   Int   i;
971
   Int   len = VG_(strlen)(s) + 1;
1023
   Int   len;
972
   Char* res = VG_(arena_malloc) (aid, len);
1024
   Char* res;
1025
1026
   if (s == NULL)
1027
      return NULL;
1028
1029
   len = VG_(strlen)(s) + 1;
1030
   res = VG_(arena_malloc) (aid, len);
1031
973
   for (i = 0; i < len; i++)
1032
   for (i = 0; i < len; i++)
974
      res[i] = s[i];
1033
      res[i] = s[i];
975
   return res;
1034
   return res;
976
}
1035
}
977
1036
978
/* Wrapper to avoid exposing skins to ArenaId's */
1037
/* Wrapper to avoid exposing tools to ArenaId's */
979
Char* VG_(strdup) ( const Char* s )
1038
Char* VG_(strdup) ( const Char* s )
980
{
1039
{
981
   return VG_(arena_strdup) ( VG_AR_SKIN, s ); 
1040
   return VG_(arena_strdup) ( VG_AR_TOOL, s ); 
982
}
1041
}
983
1042
984
/* ---------------------------------------------------------------------
1043
/* ---------------------------------------------------------------------
Lines 992-998 Link Here
992
/* Keep track of recursion depth. */
1051
/* Keep track of recursion depth. */
993
static Int recDepth;
1052
static Int recDepth;
994
1053
995
static Bool string_match_wrk ( Char* pat, Char* str )
1054
static Bool string_match_wrk ( const Char* pat, const Char* str )
996
{
1055
{
997
   vg_assert(recDepth >= 0 && recDepth < 500);
1056
   vg_assert(recDepth >= 0 && recDepth < 500);
998
   recDepth++;
1057
   recDepth++;
Lines 1027-1033 Link Here
1027
   }
1086
   }
1028
}
1087
}
1029
1088
1030
Bool VG_(string_match) ( Char* pat, Char* str )
1089
Bool VG_(string_match) ( const Char* pat, const Char* str )
1031
{
1090
{
1032
   Bool b;
1091
   Bool b;
1033
   recDepth = 0;
1092
   recDepth = 0;
Lines 1057-1063 Link Here
1057
   Addr stacktop;
1116
   Addr stacktop;
1058
1117
1059
   asm("movl %%ebp, %0; movl %%esp, %1" : "=r" (ebp), "=r" (esp));
1118
   asm("movl %%ebp, %0; movl %%esp, %1" : "=r" (ebp), "=r" (esp));
1060
   stacktop = (Addr)&VG_(stack)[VG_STACK_SIZE_W];
1119
   stacktop = VG_(valgrind_end);
1061
   if (esp >= (Addr)&VG_(sigstack)[0] && esp < (Addr)&VG_(sigstack)[VG_STACK_SIZE_W])
1120
   if (esp >= (Addr)&VG_(sigstack)[0] && esp < (Addr)&VG_(sigstack)[VG_STACK_SIZE_W])
1062
      stacktop = (Addr)&VG_(sigstack)[VG_STACK_SIZE_W];
1121
      stacktop = (Addr)&VG_(sigstack)[VG_STACK_SIZE_W];
1063
      
1122
      
Lines 1144-1156 Link Here
1144
{
1203
{
1145
   Int newfd;
1204
   Int newfd;
1146
1205
1147
   newfd = VG_(fcntl)(oldfd, VKI_F_DUPFD, VG_MAX_FD+1);
1206
   vg_assert(VG_(max_fd) != -1);
1207
1208
   newfd = VG_(fcntl)(oldfd, VKI_F_DUPFD, VG_(max_fd)+1);
1148
   if (newfd != -1)
1209
   if (newfd != -1)
1149
      VG_(close)(oldfd);
1210
      VG_(close)(oldfd);
1150
1211
1151
   VG_(fcntl)(newfd, VKI_F_SETFD, VKI_FD_CLOEXEC);
1212
   VG_(fcntl)(newfd, VKI_F_SETFD, VKI_FD_CLOEXEC);
1152
1213
1153
   vg_assert(newfd > VG_MAX_FD);
1214
   vg_assert(newfd > VG_(max_fd));
1154
   return newfd;
1215
   return newfd;
1155
}
1216
}
1156
1217
Lines 1282-1295 Link Here
1282
   Misc functions looking for a proper home.
1343
   Misc functions looking for a proper home.
1283
   ------------------------------------------------------------------ */
1344
   ------------------------------------------------------------------ */
1284
1345
1285
/* We do getenv without libc's help by snooping around in
1346
/* clone the environment */
1286
   VG_(client_envp) as determined at startup time. */
1347
Char **VG_(env_clone) ( Char **oldenv )
1287
Char* VG_(getenv) ( Char* varname )
1348
{
1349
   Char **oldenvp;
1350
   Char **newenvp;
1351
   Char **newenv;
1352
   Int  envlen;
1353
1354
   for (oldenvp = oldenv; oldenvp && *oldenvp; oldenvp++);
1355
1356
   envlen = oldenvp - oldenv + 1;
1357
   
1358
   newenv = VG_(arena_malloc)(VG_AR_CORE, envlen * sizeof(Char **));
1359
1360
   oldenvp = oldenv;
1361
   newenvp = newenv;
1362
   
1363
   while (oldenvp && *oldenvp) {
1364
      *newenvp++ = *oldenvp++;
1365
   }
1366
   
1367
   *newenvp = *oldenvp;
1368
1369
   return newenv;
1370
}
1371
1372
void  VG_(env_unsetenv) ( Char **env, const Char *varname )
1373
{
1374
   Char **from;
1375
   Char **to = NULL;
1376
   Int len = VG_(strlen)(varname);
1377
1378
   for(from = to = env; from && *from; from++) {
1379
      if (!(VG_(strncmp)(varname, *from, len) == 0 && (*from)[len] == '=')) {
1380
	 *to = *from;
1381
	 to++;
1382
      }
1383
   }
1384
   *to = *from;
1385
}
1386
1387
/* set the environment; returns the old env if a new one was allocated */
1388
Char **VG_(env_setenv) ( Char ***envp, const Char* varname, const Char *val )
1389
{
1390
   Char **env = (*envp);
1391
   Char **cpp;
1392
   Int len = VG_(strlen)(varname);
1393
   Char *valstr = VG_(arena_malloc)(VG_AR_CORE, len + VG_(strlen)(val) + 2);
1394
   Char **oldenv = NULL;
1395
1396
   VG_(sprintf)(valstr, "%s=%s", varname, val);
1397
1398
   for(cpp = env; cpp && *cpp; cpp++) {
1399
      if (VG_(strncmp)(varname, *cpp, len) == 0 && (*cpp)[len] == '=') {
1400
	 *cpp = valstr;
1401
	 return oldenv;
1402
      }
1403
   }
1404
1405
   if (env == NULL) {
1406
      env = VG_(arena_malloc)(VG_AR_CORE, sizeof(Char **) * 2);
1407
      env[0] = valstr;
1408
      env[1] = NULL;
1409
1410
      *envp = env;
1411
1412
   }  else {
1413
      Int envlen = (cpp-env) + 2;
1414
      Char **newenv = VG_(arena_malloc)(VG_AR_CORE, envlen * sizeof(Char **));
1415
1416
      for(cpp = newenv; *env; )
1417
	 *cpp++ = *env++;
1418
      *cpp++ = valstr;
1419
      *cpp++ = NULL;
1420
1421
      oldenv = *envp;
1422
1423
      *envp = newenv;
1424
   }
1425
1426
   return oldenv;
1427
}
1428
1429
Char* VG_(env_getenv) ( Char **env, Char* varname )
1288
{
1430
{
1289
   Int i, n;
1431
   Int i, n;
1290
   n = VG_(strlen)(varname);
1432
   n = VG_(strlen)(varname);
1291
   for (i = 0; VG_(client_envp)[i] != NULL; i++) {
1433
   for (i = 0; env[i] != NULL; i++) {
1292
      Char* s = VG_(client_envp)[i];
1434
      Char* s = env[i];
1293
      if (VG_(strncmp)(varname, s, n) == 0 && s[n] == '=') {
1435
      if (VG_(strncmp)(varname, s, n) == 0 && s[n] == '=') {
1294
         return & s[n+1];
1436
         return & s[n+1];
1295
      }
1437
      }
Lines 1297-1302 Link Here
1297
   return NULL;
1439
   return NULL;
1298
}
1440
}
1299
1441
1442
/* We do getenv without libc's help by snooping around in
1443
   VG_(client_envp) as determined at startup time. */
1444
Char *VG_(getenv)(Char *varname)
1445
{
1446
   return VG_(env_getenv)(VG_(client_envp), varname);
1447
}
1300
1448
1301
/* Support for getrlimit. */
1449
/* Support for getrlimit. */
1302
Int VG_(getrlimit) (Int resource, struct vki_rlimit *rlim)
1450
Int VG_(getrlimit) (Int resource, struct vki_rlimit *rlim)
Lines 1309-1314 Link Here
1309
}
1457
}
1310
1458
1311
1459
1460
/* Support for setrlimit. */
1461
Int VG_(setrlimit) (Int resource, struct vki_rlimit *rlim)
1462
{
1463
   Int res;
1464
   /* res = setrlimit( resource, rlim ); */
1465
   res = VG_(do_syscall)(__NR_setrlimit, (UInt)resource, (UInt)rlim);
1466
   if(VG_(is_kerror)(res)) res = -1;
1467
   return res;
1468
}
1469
1470
1312
/* Support for getdents. */
1471
/* Support for getdents. */
1313
Int VG_(getdents) (UInt fd, struct vki_dirent *dirp, UInt count)
1472
Int VG_(getdents) (UInt fd, struct vki_dirent *dirp, UInt count)
1314
{
1473
{
Lines 1363-1369 Link Here
1363
Int VG_(system) ( Char* cmd )
1522
Int VG_(system) ( Char* cmd )
1364
{
1523
{
1365
   Int pid, res;
1524
   Int pid, res;
1366
   void* environ[1] = { NULL };
1367
   if (cmd == NULL)
1525
   if (cmd == NULL)
1368
      return 1;
1526
      return 1;
1369
   pid = VG_(do_syscall)(__NR_fork);
1527
   pid = VG_(do_syscall)(__NR_fork);
Lines 1371-1383 Link Here
1371
      return -1;
1529
      return -1;
1372
   if (pid == 0) {
1530
   if (pid == 0) {
1373
      /* child */
1531
      /* child */
1532
      static Char** envp = NULL;
1374
      Char* argv[4];
1533
      Char* argv[4];
1534
1535
      if (envp == NULL) {
1536
         Int i;
1537
         Char* ld_preload_str = NULL;
1538
         Char* ld_library_path_str = NULL;
1539
         Char* buf;
1540
1541
         envp = VG_(env_clone)(VG_(client_envp));
1542
         
1543
         for (i = 0; envp[i] != NULL; i++) {
1544
            if (VG_(strncmp)(envp[i], "LD_PRELOAD=", 11) == 0)
1545
               ld_preload_str = &envp[i][11];
1546
            if (VG_(strncmp)(envp[i], "LD_LIBRARY_PATH=", 16) == 0)
1547
               ld_library_path_str = &envp[i][16];
1548
         }
1549
1550
         buf = VG_(arena_malloc)(VG_AR_CORE, VG_(strlen)(VG_(libdir)) + 20);
1551
1552
         VG_(sprintf)(buf, "%s*/vg_inject.so", VG_(libdir));
1553
         VG_(mash_colon_env)(ld_preload_str, buf);
1554
1555
         VG_(sprintf)(buf, "%s*/vgpreload_*.so", VG_(libdir));
1556
         VG_(mash_colon_env)(ld_preload_str, buf);
1557
1558
         VG_(sprintf)(buf, "%s*", VG_(libdir));
1559
         VG_(mash_colon_env)(ld_library_path_str, buf);
1560
1561
         VG_(env_unsetenv)(envp, VALGRINDCLO);
1562
1563
         VG_(arena_free)(VG_AR_CORE, buf);
1564
      }
1565
1375
      argv[0] = "/bin/sh";
1566
      argv[0] = "/bin/sh";
1376
      argv[1] = "-c";
1567
      argv[1] = "-c";
1377
      argv[2] = cmd;
1568
      argv[2] = cmd;
1378
      argv[3] = 0;
1569
      argv[3] = 0;
1570
1379
      (void)VG_(do_syscall)(__NR_execve, 
1571
      (void)VG_(do_syscall)(__NR_execve, 
1380
			    (UInt)"/bin/sh", (UInt)argv, (UInt)&environ);
1572
                            (UInt)"/bin/sh", (UInt)argv, (UInt)envp);
1573
1381
      /* If we're still alive here, execve failed. */
1574
      /* If we're still alive here, execve failed. */
1382
      return -1;
1575
      return -1;
1383
   } else {
1576
   } else {
Lines 1393-1522 Link Here
1393
1586
1394
1587
1395
/* ---------------------------------------------------------------------
1588
/* ---------------------------------------------------------------------
1396
   Support for a millisecond-granularity counter using RDTSC.
1589
   Support for a millisecond-granularity timer.
1397
   ------------------------------------------------------------------ */
1590
   ------------------------------------------------------------------ */
1398
1591
1399
static __inline__ ULong do_rdtsc_insn ( void )
1400
{
1401
   ULong x;
1402
   __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
1403
   return x;
1404
}
1405
1406
/* 0 = pre-calibration, 1 = calibration, 2 = running */
1407
static Int   rdtsc_calibration_state     = 0;
1408
static ULong rdtsc_ticks_per_millisecond = 0; /* invalid value */
1409
1410
static struct vki_timeval rdtsc_cal_start_timeval;
1411
static struct vki_timeval rdtsc_cal_end_timeval;
1412
1413
static ULong              rdtsc_cal_start_raw;
1414
static ULong              rdtsc_cal_end_raw;
1415
1416
UInt VG_(read_millisecond_timer) ( void )
1592
UInt VG_(read_millisecond_timer) ( void )
1417
{
1593
{
1418
   ULong rdtsc_now;
1594
   static ULong base = 0;
1419
   // If called before rdtsc setup completed (eg. from SK_(pre_clo_init)())
1595
   struct vki_timeval tv_now;
1420
   // just return 0.
1596
   ULong now;
1421
   if (rdtsc_calibration_state < 2) return 0;
1422
   rdtsc_now = do_rdtsc_insn();
1423
   vg_assert(rdtsc_now > rdtsc_cal_end_raw);
1424
   rdtsc_now -= rdtsc_cal_end_raw;
1425
   rdtsc_now /= rdtsc_ticks_per_millisecond;
1426
   return (UInt)rdtsc_now;
1427
}
1428
1429
1430
void VG_(start_rdtsc_calibration) ( void )
1431
{
1432
   Int res;
1597
   Int res;
1433
   vg_assert(rdtsc_calibration_state == 0);
1434
   rdtsc_calibration_state = 1;
1435
   rdtsc_cal_start_raw = do_rdtsc_insn();
1436
   res = VG_(do_syscall)(__NR_gettimeofday, (UInt)&rdtsc_cal_start_timeval, 
1437
			 (UInt)NULL);
1438
   vg_assert(!VG_(is_kerror)(res));
1439
}
1440
1441
void VG_(end_rdtsc_calibration) ( void )
1442
{
1443
   Int   res, loops;
1444
   ULong cpu_clock_MHZ;
1445
   ULong cal_clock_ticks;
1446
   ULong cal_wallclock_microseconds;
1447
   ULong wallclock_start_microseconds;
1448
   ULong wallclock_end_microseconds;
1449
   struct vki_timespec req;
1450
   struct vki_timespec rem;
1451
   
1452
   vg_assert(rdtsc_calibration_state == 1);
1453
   rdtsc_calibration_state = 2;
1454
1455
   /* Try and delay for 20 milliseconds, so that we can at least have
1456
      some minimum level of accuracy. */
1457
   req.tv_sec = 0;
1458
   req.tv_nsec = 20 * 1000 * 1000;
1459
   loops = 0;
1460
   while (True) {
1461
      res = VG_(nanosleep)(&req, &rem);
1462
      vg_assert(res == 0 /*ok*/ || res == 1 /*interrupted*/);
1463
      if (res == 0)
1464
         break;
1465
      if (rem.tv_sec == 0 && rem.tv_nsec == 0) 
1466
         break;
1467
      req = rem;
1468
      loops++;
1469
      if (loops > 100) 
1470
         VG_(core_panic)("calibration nanosleep loop failed?!");
1471
   }
1472
1598
1473
   /* Now read both timers, and do the Math. */
1599
   res = VG_(do_syscall)(__NR_gettimeofday, (UInt)&tv_now, 
1474
   rdtsc_cal_end_raw = do_rdtsc_insn();
1475
   res = VG_(do_syscall)(__NR_gettimeofday, (UInt)&rdtsc_cal_end_timeval, 
1476
			 (UInt)NULL);
1600
			 (UInt)NULL);
1601
   
1602
   now = tv_now.tv_sec * 1000000ULL + tv_now.tv_usec;
1603
   
1604
   if (base == 0)
1605
      base = now;
1477
1606
1478
   vg_assert(rdtsc_cal_end_raw > rdtsc_cal_start_raw);
1607
   return (now - base) / 1000;
1479
   cal_clock_ticks = rdtsc_cal_end_raw - rdtsc_cal_start_raw;
1480
1481
   wallclock_start_microseconds
1482
      = (1000000ULL * (ULong)(rdtsc_cal_start_timeval.tv_sec)) 
1483
         + (ULong)(rdtsc_cal_start_timeval.tv_usec);
1484
   wallclock_end_microseconds
1485
      = (1000000ULL * (ULong)(rdtsc_cal_end_timeval.tv_sec)) 
1486
         + (ULong)(rdtsc_cal_end_timeval.tv_usec);
1487
   vg_assert(wallclock_end_microseconds > wallclock_start_microseconds);
1488
   cal_wallclock_microseconds 
1489
      = wallclock_end_microseconds - wallclock_start_microseconds;
1490
1491
   /* Since we just nanoslept for 20 ms ... */
1492
   vg_assert(cal_wallclock_microseconds >= 20000);
1493
1494
   /* Now we know (roughly) that cal_clock_ticks on RDTSC take
1495
      cal_wallclock_microseconds elapsed time.  Calculate the RDTSC
1496
      ticks-per-millisecond value. */
1497
   if (0)
1498
      VG_(printf)("%lld ticks in %lld microseconds\n", 
1499
                  cal_clock_ticks,  cal_wallclock_microseconds );
1500
1501
   rdtsc_ticks_per_millisecond   
1502
      = cal_clock_ticks / (cal_wallclock_microseconds / 1000ULL);
1503
   cpu_clock_MHZ
1504
      = (1000ULL * rdtsc_ticks_per_millisecond) / 1000000ULL;
1505
   if (VG_(clo_verbosity) >= 1)
1506
      VG_(message)(Vg_UserMsg, "Estimated CPU clock rate is %d MHz",
1507
                               (UInt)cpu_clock_MHZ);
1508
   if (cpu_clock_MHZ < 50 || cpu_clock_MHZ > 10000)
1509
      VG_(core_panic)("end_rdtsc_calibration: "
1510
                 "estimated CPU MHz outside range 50 .. 10000");
1511
   /* Paranoia about division by zero later. */
1512
   vg_assert(rdtsc_ticks_per_millisecond != 0);
1513
   if (0)
1514
      VG_(printf)("ticks per millisecond %llu\n", 
1515
                  rdtsc_ticks_per_millisecond);
1516
}
1608
}
1517
1609
1518
1610
1519
1520
/* ---------------------------------------------------------------------
1611
/* ---------------------------------------------------------------------
1521
   Primitive support for bagging memory via mmap.
1612
   Primitive support for bagging memory via mmap.
1522
   ------------------------------------------------------------------ */
1613
   ------------------------------------------------------------------ */
Lines 1525-1534 Link Here
1525
{
1616
{
1526
   static UInt tot_alloc = 0;
1617
   static UInt tot_alloc = 0;
1527
   void* p;
1618
   void* p;
1528
   p = VG_(mmap)( 0, nBytes,
1619
1529
                     VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC, 
1620
#if 0
1530
                     VKI_MAP_PRIVATE|VKI_MAP_ANONYMOUS, -1, 0 );
1621
   p = VG_(mmap)( (void *)VG_(valgrind_base), nBytes,
1622
		  VKI_PROT_READ | VKI_PROT_WRITE | VKI_PROT_EXEC, 
1623
		  VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS, -1, 0 );
1624
#else
1625
   /* use brk, because it will definitely be in the valgrind address space */
1626
   {
1627
      Char *b = VG_(brk)(0);
1628
1629
      p = (void *)PGROUNDUP(b);
1630
      
1631
      b = VG_(brk)(p + PGROUNDUP(nBytes));
1632
1633
      if (b != (p + PGROUNDUP(nBytes)))
1634
	 p = (void *)-1;
1635
   }
1636
#endif
1637
1531
   if (p != ((void*)(-1))) {
1638
   if (p != ((void*)(-1))) {
1639
      vg_assert(p >= (void *)VG_(valgrind_mmap_end) && p < (void *)VG_(valgrind_end));
1532
      tot_alloc += (UInt)nBytes;
1640
      tot_alloc += (UInt)nBytes;
1533
      if (0)
1641
      if (0)
1534
         VG_(printf)(
1642
         VG_(printf)(
(-)valgrind-2.1.0/coregrind/vg_needs.c (-137 / +32 lines)
Lines 1-6 Link Here
1
1
2
/*--------------------------------------------------------------------*/
2
/*--------------------------------------------------------------------*/
3
/*--- Stuff relating to skin data structures.                      ---*/
3
/*--- Stuff relating to tool data structures.                      ---*/
4
/*---                                                   vg_needs.c ---*/
4
/*---                                                   vg_needs.c ---*/
5
/*--------------------------------------------------------------------*/
5
/*--------------------------------------------------------------------*/
6
6
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Nicholas Nethercote
11
   Copyright (C) 2000-2004 Nicholas Nethercote
12
      njn25@cam.ac.uk
12
      njn25@cam.ac.uk
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 33-39 Link Here
33
33
34
34
35
/* ---------------------------------------------------------------------
35
/* ---------------------------------------------------------------------
36
   Skin data structure initialisation
36
   Tool data structure initialisation
37
   ------------------------------------------------------------------ */
37
   ------------------------------------------------------------------ */
38
38
39
/* Init with default values. */
39
/* Init with default values. */
Lines 58-118 Link Here
58
   .syscall_wrapper      = False,
58
   .syscall_wrapper      = False,
59
   .sanity_checks        = False,
59
   .sanity_checks        = False,
60
   .data_syms	         = False,
60
   .data_syms	         = False,
61
};
61
   .shadow_memory        = False,
62
63
VgTrackEvents VG_(track_events) = {
64
   /* Memory events */
65
   .new_mem_startup              = NULL,
66
   .new_mem_stack_signal         = NULL,
67
   .new_mem_brk                  = NULL,
68
   .new_mem_mmap                 = NULL,
69
70
   .copy_mem_remap               = NULL,
71
   .change_mem_mprotect          = NULL,
72
73
   .die_mem_stack_signal         = NULL,
74
   .die_mem_brk                  = NULL,
75
   .die_mem_munmap               = NULL,
76
77
   .new_mem_stack_4              = NULL,
78
   .new_mem_stack_8              = NULL,
79
   .new_mem_stack_12             = NULL,
80
   .new_mem_stack_16             = NULL,
81
   .new_mem_stack_32             = NULL,
82
   .new_mem_stack                = NULL,
83
84
   .die_mem_stack_4              = NULL,
85
   .die_mem_stack_8              = NULL,
86
   .die_mem_stack_12             = NULL,
87
   .die_mem_stack_16             = NULL,
88
   .die_mem_stack_32             = NULL,
89
   .die_mem_stack                = NULL,
90
91
   .ban_mem_stack                = NULL,
92
93
   .pre_mem_read                 = NULL,
94
   .pre_mem_read_asciiz          = NULL,
95
   .pre_mem_write                = NULL,
96
   .post_mem_write               = NULL,
97
98
   /* Register events */
99
   .post_regs_write_init             = NULL,
100
   .post_reg_write_syscall_return    = NULL,
101
   .post_reg_write_deliver_signal    = NULL,
102
   .post_reg_write_pthread_return    = NULL,
103
   .post_reg_write_clientreq_return  = NULL,
104
   .post_reg_write_clientcall_return = NULL,
105
106
   /* Scheduler events */
107
   .thread_run                   = NULL,
108
109
   /* Mutex events */
110
   .post_mutex_lock              = NULL,
111
   .post_mutex_unlock            = NULL,
112
113
   /* Signal events */
114
   .pre_deliver_signal           = NULL,
115
   .post_deliver_signal          = NULL,
116
};
62
};
117
63
118
/* static */
64
/* static */
Lines 132-166 Link Here
132
   CHECK_NOT(VG_(details).copyright_author, NULL);
78
   CHECK_NOT(VG_(details).copyright_author, NULL);
133
   CHECK_NOT(VG_(details).bug_reports_to,   NULL);
79
   CHECK_NOT(VG_(details).bug_reports_to,   NULL);
134
80
135
   if ( (VG_(track_events).new_mem_stack_4  ||
81
   if ( (VG_(defined_new_mem_stack_4)()  ||
136
         VG_(track_events).new_mem_stack_8  ||
82
         VG_(defined_new_mem_stack_8)()  ||
137
         VG_(track_events).new_mem_stack_12 ||
83
         VG_(defined_new_mem_stack_12)() ||
138
         VG_(track_events).new_mem_stack_16 ||
84
         VG_(defined_new_mem_stack_16)() ||
139
         VG_(track_events).new_mem_stack_32) &&
85
         VG_(defined_new_mem_stack_32)()) &&
140
       ! VG_(track_events).new_mem_stack) 
86
       ! VG_(defined_new_mem_stack)()) 
141
   {
87
   {
142
      VG_(printf)("\nTool error: one of the specialised `new_mem_stack_n'\n"
88
      VG_(printf)("\nTool error: one of the specialised `new_mem_stack_n'\n"
143
                  "events tracked, but not the generic `new_mem_stack' one.\n");
89
                  "events tracked, but not the generic `new_mem_stack' one.\n");
144
      VG_(skin_panic)("`new_mem_stack' should be defined\n");
90
      VG_(skin_panic)("`new_mem_stack' should be defined\n");
145
   }
91
   }
146
92
147
   if ( (VG_(track_events).die_mem_stack_4  ||
93
   if ( (VG_(defined_die_mem_stack_4)()  ||
148
         VG_(track_events).die_mem_stack_8  ||
94
         VG_(defined_die_mem_stack_8)()  ||
149
         VG_(track_events).die_mem_stack_12 ||
95
         VG_(defined_die_mem_stack_12)() ||
150
         VG_(track_events).die_mem_stack_16 ||
96
         VG_(defined_die_mem_stack_16)() ||
151
         VG_(track_events).die_mem_stack_32) &&
97
         VG_(defined_die_mem_stack_32)()) &&
152
       ! VG_(track_events).die_mem_stack) 
98
       ! VG_(defined_die_mem_stack)()) 
153
   {
99
   {
154
      VG_(printf)("\nTool error: one of the specialised `die_mem_stack_n'\n"
100
      VG_(printf)("\nTool error: one of the specialised `die_mem_stack_n'\n"
155
                  "events tracked, but not the generic `die_mem_stack' one.\n");
101
                  "events tracked, but not the generic `die_mem_stack' one.\n");
156
      VG_(skin_panic)("`die_mem_stack' should be defined\n");
102
      VG_(skin_panic)("`die_mem_stack' should be defined\n");
157
   }
103
   }
158
104
159
   if ( (VG_(track_events).post_reg_write_syscall_return    ||
105
   if ( (VG_(defined_post_reg_write_syscall_return)()    ||
160
         VG_(track_events).post_reg_write_deliver_signal    ||
106
         VG_(defined_post_reg_write_deliver_signal)()    ||
161
         VG_(track_events).post_reg_write_pthread_return    ||
107
         VG_(defined_post_reg_write_pthread_return)()    ||
162
         VG_(track_events).post_reg_write_clientreq_return  ||
108
         VG_(defined_post_reg_write_clientreq_return)()  ||
163
         VG_(track_events).post_reg_write_clientcall_return) &&
109
         VG_(defined_post_reg_write_clientcall_return)()) &&
164
       ! VG_(needs).shadow_regs) 
110
       ! VG_(needs).shadow_regs) 
165
   {
111
   {
166
      VG_(printf)("\nTool error: one of the `post_reg_write'\n"
112
      VG_(printf)("\nTool error: one of the `post_reg_write'\n"
Lines 168-173 Link Here
168
      VG_(skin_panic)("`shadow_regs' should be set\n");
114
      VG_(skin_panic)("`shadow_regs' should be set\n");
169
   }
115
   }
170
116
117
   if (VG_(needs).shadow_memory != (VG_(get_shadow_size)() != 0)) {
118
      if (VG_(get_shadow_size)() != 0)
119
	 VG_(printf)("\nTool error: tool allocated shadow memory, but apparently doesn't "
120
		     "need it.\n");
121
      else
122
	 VG_(printf)("\nTool error: tool didn't allocated shadow memory, but apparently "
123
		     "needs it.\n");
124
      VG_(skin_panic)("VG_(needs).shadow_memory need should be set to match SK_(shadow_ratio)\n");
125
   }
126
171
#undef CHECK_NOT
127
#undef CHECK_NOT
172
#undef INVALID_Bool
128
#undef INVALID_Bool
173
}
129
}
Lines 210-277 Link Here
210
NEEDS(syscall_wrapper)
166
NEEDS(syscall_wrapper)
211
NEEDS(sanity_checks)
167
NEEDS(sanity_checks)
212
NEEDS(data_syms)
168
NEEDS(data_syms)
213
169
NEEDS(shadow_memory)
214
/*--------------------------------------------------------------------*/
215
#define TRACK(event, args...)  \
216
   void VG_(track_##event)(void (*f)(args)) \
217
   {                                      \
218
      VG_(track_events).event = f;        \
219
   }
220
221
/* Memory events */
222
TRACK(new_mem_startup,       Addr a, UInt len, Bool rr, Bool ww, Bool xx)
223
TRACK(new_mem_stack_signal,  Addr a, UInt len)
224
TRACK(new_mem_brk,           Addr a, UInt len)
225
TRACK(new_mem_mmap,          Addr a, UInt len, Bool rr, Bool ww, Bool xx)
226
227
TRACK(copy_mem_remap,      Addr from, Addr to, UInt len)
228
TRACK(change_mem_mprotect, Addr a, UInt len, Bool rr, Bool ww, Bool xx)
229
230
TRACK(die_mem_stack_signal,  Addr a, UInt len)
231
TRACK(die_mem_brk,           Addr a, UInt len)
232
TRACK(die_mem_munmap,        Addr a, UInt len)
233
234
TRACK(new_mem_stack_4,       Addr new_ESP)
235
TRACK(new_mem_stack_8,       Addr new_ESP)
236
TRACK(new_mem_stack_12,      Addr new_ESP)
237
TRACK(new_mem_stack_16,      Addr new_ESP)
238
TRACK(new_mem_stack_32,      Addr new_ESP)
239
TRACK(new_mem_stack,         Addr a, UInt len)
240
241
TRACK(die_mem_stack_4,       Addr new_ESP)
242
TRACK(die_mem_stack_8,       Addr new_ESP)
243
TRACK(die_mem_stack_12,      Addr new_ESP)
244
TRACK(die_mem_stack_16,      Addr new_ESP)
245
TRACK(die_mem_stack_32,      Addr new_ESP)
246
TRACK(die_mem_stack,         Addr a, UInt len)
247
248
TRACK(ban_mem_stack, Addr a, UInt len)
249
250
TRACK(pre_mem_read,        CorePart part, ThreadId tid, Char* s, Addr a,
251
                           UInt size)
252
TRACK(pre_mem_read_asciiz, CorePart part, ThreadId tid, Char* s, Addr a)
253
TRACK(pre_mem_write,       CorePart part, ThreadId tid, Char* s, Addr a,
254
                           UInt size)
255
TRACK(post_mem_write,      Addr a, UInt size)
256
257
TRACK(post_regs_write_init,             void );
258
TRACK(post_reg_write_syscall_return,    ThreadId tid, UInt reg );
259
TRACK(post_reg_write_deliver_signal,    ThreadId tid, UInt reg );
260
TRACK(post_reg_write_pthread_return,    ThreadId tid, UInt reg );
261
TRACK(post_reg_write_clientreq_return,  ThreadId tid, UInt reg );
262
TRACK(post_reg_write_clientcall_return, ThreadId tid, UInt reg, Addr f );
263
264
TRACK(thread_run, ThreadId tid)
265
266
TRACK(post_thread_create, ThreadId tid, ThreadId child)
267
TRACK(post_thread_join,   ThreadId joiner, ThreadId joinee)
268
269
TRACK( pre_mutex_lock,   ThreadId tid, void* /*pthread_mutex_t* */ mutex)
270
TRACK(post_mutex_lock,   ThreadId tid, void* /*pthread_mutex_t* */ mutex)
271
TRACK(post_mutex_unlock, ThreadId tid, void* /*pthread_mutex_t* */ mutex)
272
273
TRACK( pre_deliver_signal, ThreadId tid, Int sigNum, Bool alt_stack)
274
TRACK(post_deliver_signal, ThreadId tid, Int sigNum)
275
170
276
/*--------------------------------------------------------------------*/
171
/*--------------------------------------------------------------------*/
277
/* UCodeBlocks */
172
/* UCodeBlocks */
(-)valgrind-2.1.0/coregrind/vg_procselfmaps.c (-6 / +42 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 50-55 Link Here
50
   return -1;
50
   return -1;
51
}
51
}
52
52
53
static Int decdigit ( Char c )
54
{
55
   if (c >= '0' && c <= '9') return (Int)(c - '0');
56
   return -1;
57
}
58
53
static Int readchar ( Char* buf, Char* ch )
59
static Int readchar ( Char* buf, Char* ch )
54
{
60
{
55
   if (*buf == 0) return 0;
61
   if (*buf == 0) return 0;
Lines 68-73 Link Here
68
   return n;
74
   return n;
69
}
75
}
70
76
77
static Int readdec ( Char* buf, UInt* val )
78
{
79
   Int n = 0;
80
   *val = 0;
81
   while (hexdigit(*buf) >= 0) {
82
      *val = (*val * 10) + decdigit(*buf);
83
      n++; buf++;
84
   }
85
   return n;
86
}
87
71
88
72
/* Read /proc/self/maps, store the contents in a static buffer.  If there's
89
/* Read /proc/self/maps, store the contents in a static buffer.  If there's
73
   a syntax error or other failure, just abort. */
90
   a syntax error or other failure, just abort. */
Lines 124-136 Link Here
124
       procmap_buf!
141
       procmap_buf!
125
*/
142
*/
126
void VG_(parse_procselfmaps) (
143
void VG_(parse_procselfmaps) (
127
   void (*record_mapping)( Addr, UInt, Char, Char, Char, UInt, UChar* ) )
144
   void (*record_mapping)( Addr addr, UInt len, Char rr, Char ww, Char xx, 
145
			   UInt dev, UInt ino, ULong foff, const UChar* filename )
146
   )
128
{
147
{
129
   Int    i, j, i_eol;
148
   Int    i, j, i_eol;
130
   Addr   start, endPlusOne;
149
   Addr   start, endPlusOne;
131
   UChar* filename;
150
   UChar* filename;
132
   UInt   foffset;
151
   UInt   foffset;
133
   UChar  rr, ww, xx, pp, ch, tmp;
152
   UChar  rr, ww, xx, pp, ch, tmp;
153
   UInt	  maj, min, ino;
134
154
135
   sk_assert( '\0' != procmap_buf[0] && 0 != buf_n_tot);
155
   sk_assert( '\0' != procmap_buf[0] && 0 != buf_n_tot);
136
156
Lines 142-148 Link Here
142
   while (True) {
162
   while (True) {
143
      if (i >= buf_n_tot) break;
163
      if (i >= buf_n_tot) break;
144
164
145
      /* Read (without fscanf :) the pattern %8x-%8x %c%c%c%c %8x */
165
      /* Read (without fscanf :) the pattern %8x-%8x %c%c%c%c %8x %2x:%2x %d */
146
      j = readhex(&procmap_buf[i], &start);
166
      j = readhex(&procmap_buf[i], &start);
147
      if (j > 0) i += j; else goto syntaxerror;
167
      if (j > 0) i += j; else goto syntaxerror;
148
      j = readchar(&procmap_buf[i], &ch);
168
      j = readchar(&procmap_buf[i], &ch);
Lines 159-165 Link Here
159
      if (j == 1 && (ww == 'w' || ww == '-')) i += j; else goto syntaxerror;
179
      if (j == 1 && (ww == 'w' || ww == '-')) i += j; else goto syntaxerror;
160
      j = readchar(&procmap_buf[i], &xx);
180
      j = readchar(&procmap_buf[i], &xx);
161
      if (j == 1 && (xx == 'x' || xx == '-')) i += j; else goto syntaxerror;
181
      if (j == 1 && (xx == 'x' || xx == '-')) i += j; else goto syntaxerror;
162
      /* I haven't a clue what this last field means. */
182
      /* This field is the shared/private flag */
163
      j = readchar(&procmap_buf[i], &pp);
183
      j = readchar(&procmap_buf[i], &pp);
164
      if (j == 1 && (pp == 'p' || pp == '-' || pp == 's')) 
184
      if (j == 1 && (pp == 'p' || pp == '-' || pp == 's')) 
165
                                              i += j; else goto syntaxerror;
185
                                              i += j; else goto syntaxerror;
Lines 169-175 Link Here
169
189
170
      j = readhex(&procmap_buf[i], &foffset);
190
      j = readhex(&procmap_buf[i], &foffset);
171
      if (j > 0) i += j; else goto syntaxerror;
191
      if (j > 0) i += j; else goto syntaxerror;
172
      
192
193
      j = readchar(&procmap_buf[i], &ch);
194
      if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
195
196
      j = readhex(&procmap_buf[i], &maj);
197
      if (j > 0) i += j; else goto syntaxerror;
198
      j = readchar(&procmap_buf[i], &ch);
199
      if (j == 1 && ch == ':') i += j; else goto syntaxerror;
200
      j = readhex(&procmap_buf[i], &min);
201
      if (j > 0) i += j; else goto syntaxerror;
202
203
      j = readchar(&procmap_buf[i], &ch);
204
      if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
205
206
      j = readdec(&procmap_buf[i], &ino);
207
      if (j > 0) i += j; else goto syntaxerror;
208
 
173
      goto read_line_ok;
209
      goto read_line_ok;
174
210
175
    syntaxerror:
211
    syntaxerror:
Lines 203-209 Link Here
203
      }
239
      }
204
240
205
      (*record_mapping) ( start, endPlusOne-start, 
241
      (*record_mapping) ( start, endPlusOne-start, 
206
                          rr, ww, xx, 
242
                          rr, ww, xx, maj * 256 + min, ino,
207
                          foffset, filename );
243
                          foffset, filename );
208
244
209
      if ('\0' != tmp) {
245
      if ('\0' != tmp) {
(-)valgrind-2.1.0/coregrind/vg_proxylwp.c (-29 / +37 lines)
Lines 7-13 Link Here
7
   This file is part of Valgrind, an extensible x86 protected-mode
7
   This file is part of Valgrind, an extensible x86 protected-mode
8
   emulator for monitoring program execution on x86-Unixes.
8
   emulator for monitoring program execution on x86-Unixes.
9
9
10
   Copyright (C) 2000-2003 Julian Seward 
10
   Copyright (C) 2000-2004 Julian Seward 
11
      jseward@acm.org
11
      jseward@acm.org
12
12
13
   This program is free software; you can redistribute it and/or
13
   This program is free software; you can redistribute it and/or
Lines 180-186 Link Here
180
   jmp_buf		jumpbuf;
180
   jmp_buf		jumpbuf;
181
};
181
};
182
182
183
static void sys_wait_results(Bool block, ThreadId tid, enum RequestType reqtype);
183
static void sys_wait_results(Bool block, ThreadId tid, enum RequestType reqtype, Bool restart);
184
184
185
struct PX_Request {
185
struct PX_Request {
186
   enum RequestType	request;
186
   enum RequestType	request;
Lines 196-202 Link Here
196
   union {
196
   union {
197
      Int		syscallno;	/* system call completed */
197
      Int		syscallno;	/* system call completed */
198
      vki_ksiginfo_t	siginfo;	/* signal */
198
      vki_ksiginfo_t	siginfo;	/* signal */
199
   };
199
   } u;
200
};
200
};
201
201
202
/* results pipe */
202
/* results pipe */
Lines 257-263 Link Here
257
}
257
}
258
258
259
#define PROXYLWP_OFFSET	(VKI_BYTES_PER_PAGE - sizeof(ProxyLWP))
259
#define PROXYLWP_OFFSET	(VKI_BYTES_PER_PAGE - sizeof(ProxyLWP))
260
#define ROUNDDN(p)	((UChar *)((Addr)(p) & ~(VKI_BYTES_PER_PAGE-1)))
261
260
262
/* 
261
/* 
263
   Allocate a page for the ProxyLWP and its stack.
262
   Allocate a page for the ProxyLWP and its stack.
Lines 271-277 Link Here
271
{
270
{
272
   UChar *p = VG_(get_memory_from_mmap)(VKI_BYTES_PER_PAGE, "alloc_LWP");
271
   UChar *p = VG_(get_memory_from_mmap)(VKI_BYTES_PER_PAGE, "alloc_LWP");
273
   ProxyLWP *ret;
272
   ProxyLWP *ret;
274
   vg_assert(p == ROUNDDN(p)); /* px must be page aligned */
273
   vg_assert(p == (UChar *)PGROUNDDN(p)); /* px must be page aligned */
275
274
276
   ret = (ProxyLWP *)(p + PROXYLWP_OFFSET);
275
   ret = (ProxyLWP *)(p + PROXYLWP_OFFSET);
277
276
Lines 283-289 Link Here
283
/* Free a thread structure */
282
/* Free a thread structure */
284
static void LWP_free(ProxyLWP *px)
283
static void LWP_free(ProxyLWP *px)
285
{
284
{
286
   UChar *p = ROUNDDN(px);
285
   UChar *p = (UChar *)PGROUNDDN(px);
287
   
286
   
288
   vg_assert(px->magic == VG_PROXY_MAGIC);
287
   vg_assert(px->magic == VG_PROXY_MAGIC);
289
   px->magic = 0;
288
   px->magic = 0;
Lines 297-303 Link Here
297
   end). */
296
   end). */
298
static inline ProxyLWP *LWP_TSD(void *esp)
297
static inline ProxyLWP *LWP_TSD(void *esp)
299
{
298
{
300
   UChar *p = ROUNDDN(esp);
299
   UChar *p = (UChar *)PGROUNDDN(esp);
301
   ProxyLWP *ret;
300
   ProxyLWP *ret;
302
301
303
   ret = (ProxyLWP *)(p + PROXYLWP_OFFSET);
302
   ret = (ProxyLWP *)(p + PROXYLWP_OFFSET);
Lines 512-518 Link Here
512
	    /* First, send the signal info */
511
	    /* First, send the signal info */
513
	    sigreply.tid = px->tid;
512
	    sigreply.tid = px->tid;
514
	    sigreply.req = PX_Signal;
513
	    sigreply.req = PX_Signal;
515
	    sigreply.siginfo = px->siginfo;
514
	    sigreply.u.siginfo = px->siginfo;
516
515
517
	    if (!send_reply(&sigreply)) {
516
	    if (!send_reply(&sigreply)) {
518
	       ret = 44;		/* incomplete or failed write */
517
	       ret = 44;		/* incomplete or failed write */
Lines 554-560 Link Here
554
		  XXX how to distunguish between restartable and
553
		  XXX how to distunguish between restartable and
555
		  non-restartable syscalls?  Does it matter?
554
		  non-restartable syscalls?  Does it matter?
556
	       */
555
	       */
557
	       reply.syscallno = tst->syscallno;
556
	       reply.u.syscallno = tst->syscallno;
558
557
559
	       tst->m_eax = -VKI_ERESTARTSYS;
558
	       tst->m_eax = -VKI_ERESTARTSYS;
560
	       px->state = PXS_IntReply;
559
	       px->state = PXS_IntReply;
Lines 599-605 Link Here
599
	    /* We were actually running the syscall when interrupted.
598
	    /* We were actually running the syscall when interrupted.
600
	       reply should already be set up, including return in eax. */
599
	       reply should already be set up, including return in eax. */
601
	    vg_assert(reply.req == PX_RunSyscall);
600
	    vg_assert(reply.req == PX_RunSyscall);
602
	    vg_assert(reply.syscallno == tst->syscallno);
601
	    vg_assert(reply.u.syscallno == tst->syscallno);
603
	    vg_assert(tst->status == VgTs_WaitSys);
602
	    vg_assert(tst->status == VgTs_WaitSys);
604
	    px->state = PXS_IntReply;
603
	    px->state = PXS_IntReply;
605
	    break;
604
	    break;
Lines 608-614 Link Here
608
	    /* The syscall is done; we just need to send the results
607
	    /* The syscall is done; we just need to send the results
609
	       back. */
608
	       back. */
610
	    vg_assert(reply.req == PX_RunSyscall);
609
	    vg_assert(reply.req == PX_RunSyscall);
611
	    vg_assert(reply.syscallno == tst->syscallno);
610
	    vg_assert(reply.u.syscallno == tst->syscallno);
612
	    px->state = PXS_IntReply;
611
	    px->state = PXS_IntReply;
613
	    break;
612
	    break;
614
613
Lines 712-718 Link Here
712
	 case PX_RunSyscall:
711
	 case PX_RunSyscall:
713
	    /* Run a syscall for our thread; results will be poked
712
	    /* Run a syscall for our thread; results will be poked
714
	       back into tst */
713
	       back into tst */
715
	    reply.syscallno = tst->syscallno;
714
	    reply.u.syscallno = tst->syscallno;
716
715
717
	    vg_assert(px->state == PXS_WaitReq || 
716
	    vg_assert(px->state == PXS_WaitReq || 
718
		      px->state == PXS_SigACK);
717
		      px->state == PXS_SigACK);
Lines 723-729 Link Here
723
		  on the way to us as we got the signal.  
722
		  on the way to us as we got the signal.  
724
	       */
723
	       */
725
	       px_printf("RunSyscall in SigACK: rejecting syscall %d with ERESTARTSYS\n",
724
	       px_printf("RunSyscall in SigACK: rejecting syscall %d with ERESTARTSYS\n",
726
			 reply.syscallno);
725
			 reply.u.syscallno);
727
	       tst->m_eax = -VKI_ERESTARTSYS;
726
	       tst->m_eax = -VKI_ERESTARTSYS;
728
	    } else {
727
	    } else {
729
	       Int syscallno = tst->syscallno;
728
	       Int syscallno = tst->syscallno;
Lines 842-850 Link Here
842
	 it by the normal mechanism.  In this case, just wait for the
841
	 it by the normal mechanism.  In this case, just wait for the
843
	 syscall to dinish. */
842
	 syscall to dinish. */
844
      if (tst->status == VgTs_WaitSys && tst->syscallno == __NR_rt_sigtimedwait)
843
      if (tst->status == VgTs_WaitSys && tst->syscallno == __NR_rt_sigtimedwait)
845
	 sys_wait_results(True, tid, PX_RunSyscall);
844
	 sys_wait_results(True, tid, PX_RunSyscall, True);
846
      else
845
      else
847
	 sys_wait_results(True, tid, PX_Signal);
846
	 sys_wait_results(True, tid, PX_Signal, True);
848
   }
847
   }
849
}
848
}
850
849
Lines 867-873 Link Here
867
   if (lwp != 0)
866
   if (lwp != 0)
868
      VG_(ktkill)(lwp, VKI_SIGVGINT);
867
      VG_(ktkill)(lwp, VKI_SIGVGINT);
869
868
870
   sys_wait_results(True, tid, PX_RunSyscall);
869
   sys_wait_results(True, tid, PX_RunSyscall, False);
871
870
872
   vg_assert(tst->status == VgTs_Runnable);
871
   vg_assert(tst->status == VgTs_Runnable);
873
}
872
}
Lines 1064-1070 Link Here
1064
      proxy_wait, because if we don't read the results pipe, the proxy
1063
      proxy_wait, because if we don't read the results pipe, the proxy
1065
      may be blocked writing to it, causing a deadlock with us as we
1064
      may be blocked writing to it, causing a deadlock with us as we
1066
      wait for it to exit. */
1065
      wait for it to exit. */
1067
   sys_wait_results(True, tid, PX_Exiting);
1066
   sys_wait_results(True, tid, PX_Exiting, True);
1068
   res = proxy_wait(proxy, True, &status);
1067
   res = proxy_wait(proxy, True, &status);
1069
1068
1070
   if ((!res || status != 0) && VG_(clo_verbosity) > 1)
1069
   if ((!res || status != 0) && VG_(clo_verbosity) > 1)
Lines 1092-1098 Link Here
1092
   reply, otherwise it will block forever).  If tid != 0, then it will
1091
   reply, otherwise it will block forever).  If tid != 0, then it will
1093
   wait for a reply for that particular tid.
1092
   wait for a reply for that particular tid.
1094
 */
1093
 */
1095
static void sys_wait_results(Bool block, ThreadId tid, enum RequestType reqtype)
1094
static void sys_wait_results(Bool block, ThreadId tid, enum RequestType reqtype, Bool restart)
1096
{
1095
{
1097
   Bool found_reply = (reqtype == PX_BAD);
1096
   Bool found_reply = (reqtype == PX_BAD);
1098
   struct PX_Reply res;
1097
   struct PX_Reply res;
Lines 1151-1171 Link Here
1151
	       VG_(printf)("tid %d in status %d\n",
1150
	       VG_(printf)("tid %d in status %d\n",
1152
			   tst->tid, tst->status);
1151
			   tst->tid, tst->status);
1153
	 
1152
	 
1154
	    vg_assert(res.syscallno == tst->syscallno);
1153
	    vg_assert(res.u.syscallno == tst->syscallno);
1155
	    vg_assert(tst->status == VgTs_WaitSys);
1154
	    vg_assert(tst->status == VgTs_WaitSys);
1156
1155
1157
	    VG_(post_syscall)(res.tid);
1156
	    VG_(post_syscall)(res.tid, restart);
1158
	    break;
1157
	    break;
1159
1158
1160
	 case PX_Signal:
1159
	 case PX_Signal:
1161
	    if (VG_(clo_trace_signals) || VG_(clo_trace_syscalls))
1160
	    if (VG_(clo_trace_signals) || VG_(clo_trace_syscalls))
1162
	       VG_(message)(Vg_DebugMsg, "sys_wait_results: got PX_Signal for TID %d, signal %d",
1161
	       VG_(message)(Vg_DebugMsg, "sys_wait_results: got PX_Signal for TID %d, signal %d",
1163
			    res.tid, res.siginfo.si_signo);
1162
			    res.tid, res.u.siginfo.si_signo);
1164
1163
1165
	    vg_assert(res.siginfo.si_signo != 0);
1164
	    vg_assert(res.u.siginfo.si_signo != 0);
1166
	    if (VG_(threads)[res.tid].proxy && 
1165
	    if (VG_(threads)[res.tid].proxy && 
1167
		!VG_(threads)[res.tid].proxy->terminating)
1166
		!VG_(threads)[res.tid].proxy->terminating)
1168
	       VG_(deliver_signal)(res.tid, &res.siginfo, True);
1167
	       VG_(deliver_signal)(res.tid, &res.u.siginfo, True);
1169
	    break;
1168
	    break;
1170
1169
1171
	 case PX_Ping:
1170
	 case PX_Ping:
Lines 1188-1203 Link Here
1188
/* External version */
1187
/* External version */
1189
void VG_(proxy_results)(void)
1188
void VG_(proxy_results)(void)
1190
{
1189
{
1191
   sys_wait_results(False, 0, PX_BAD);
1190
   sys_wait_results(False, 0, PX_BAD, True);
1192
}
1191
}
1193
1192
1194
void VG_(proxy_wait_sys)(ThreadId tid)
1193
void VG_(proxy_wait_sys)(ThreadId tid, Bool restart)
1195
{
1194
{
1196
   ThreadState *tst = VG_(get_ThreadState)(tid);
1195
   ThreadState *tst = VG_(get_ThreadState)(tid);
1197
1196
1198
   vg_assert(tst->status == VgTs_WaitSys);
1197
   vg_assert(tst->status == VgTs_WaitSys);
1199
1198
1200
   sys_wait_results(True, tid, PX_RunSyscall);
1199
   sys_wait_results(True, tid, PX_RunSyscall, restart);
1201
}
1200
}
1202
1201
1203
/* Tell proxy about it's thread's updated signal mask */
1202
/* Tell proxy about it's thread's updated signal mask */
Lines 1227-1233 Link Here
1227
      with respect to each other (ie, if thread A then thread B
1226
      with respect to each other (ie, if thread A then thread B
1228
      updates their signal masks, A's update must be done before B's
1227
      updates their signal masks, A's update must be done before B's
1229
      is).  */
1228
      is).  */
1230
   sys_wait_results(True, tid, PX_SetSigmask);
1229
   sys_wait_results(True, tid, PX_SetSigmask, True);
1231
}
1230
}
1232
1231
1233
void VG_(proxy_sigack)(ThreadId tid, const vki_ksigset_t *mask)
1232
void VG_(proxy_sigack)(ThreadId tid, const vki_ksigset_t *mask)
Lines 1272-1278 Link Here
1272
   if (VG_(do_signal_routing))
1271
   if (VG_(do_signal_routing))
1273
      VG_(route_signals)();
1272
      VG_(route_signals)();
1274
   else
1273
   else
1275
      sys_wait_results(True, VG_INVALID_THREADID /* any */, PX_Signal);
1274
      sys_wait_results(True, VG_INVALID_THREADID /* any */, PX_Signal, True);
1276
}
1275
}
1277
1276
1278
/* Issue a syscall to the thread's ProxyLWP */
1277
/* Issue a syscall to the thread's ProxyLWP */
Lines 1365-1371 Link Here
1365
			 tid, px->lwp, ret);
1364
			 tid, px->lwp, ret);
1366
	    sane = False;
1365
	    sane = False;
1367
	 }
1366
	 }
1368
	 sys_wait_results(True, tid, PX_Ping);
1367
	 sys_wait_results(True, tid, PX_Ping, True);
1369
	 /* Can't make an assertion here, fortunately; this will
1368
	 /* Can't make an assertion here, fortunately; this will
1370
	    either come back or it won't. */
1369
	    either come back or it won't. */
1371
      }
1370
      }
Lines 1374-1379 Link Here
1374
   vg_assert(sane);
1373
   vg_assert(sane);
1375
}
1374
}
1376
1375
1376
/* Get the PID/TID of the ProxyLWP. */
1377
Int VG_(proxy_id)(ThreadId tid)
1378
{
1379
   ThreadState *tst = VG_(get_ThreadState)(tid);
1380
   ProxyLWP *proxy = tst->proxy;
1381
1382
   return proxy->lwp;
1383
}
1384
1377
/*--------------------------------------------------------------------*/
1385
/*--------------------------------------------------------------------*/
1378
/*--- Proxy LWP machinery.                           vg_proxylwp.c ---*/
1386
/*--- Proxy LWP machinery.                           vg_proxylwp.c ---*/
1379
/*--------------------------------------------------------------------*/
1387
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/vg_replace_malloc.c (-172 / +178 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 36-277 Link Here
36
   have no prototypes in vg_include.h, since they are not intended to
36
   have no prototypes in vg_include.h, since they are not intended to
37
   be called from within Valgrind.
37
   be called from within Valgrind.
38
38
39
   This file can be #included into a skin that wishes to know about
39
   This file can be #included into a tool that wishes to know about
40
   calls to malloc().  It should define functions SK_(malloc) et al
40
   calls to malloc().  It should define functions SK_(malloc) et al
41
   that will be called.
41
   that will be called.
42
   ------------------------------------------------------------------ */
42
   ------------------------------------------------------------------ */
43
43
44
#include "valgrind.h"            /* for VALGRIND_NON_SIMD_CALL[12] */
44
#include "valgrind.h"            /* for VALGRIND_NON_SIMD_CALL[12] */
45
#include "vg_include.h"
45
#include "vg_include.h"
46
#include "vg_skin.h"
46
47
47
/*------------------------------------------------------------*/
48
/* Create an alias */
48
/*--- Command line options                                 ---*/
49
#define ALIAS(ret, name, args, toname)					\
49
/*------------------------------------------------------------*/
50
   ret name args __attribute__((alias(#toname), visibility("protected")))
50
51
51
/* Round malloc sizes upwards to integral number of words? default: NO */
52
/* Declare a function, along with libc's various aliases */
52
Bool VG_(clo_sloppy_malloc)  = False;
53
#define LIBALIAS(ret, name, args)		\
53
54
	ALIAS(ret, __##name, args, name);	\
54
/* DEBUG: print malloc details?  default: NO */
55
	ALIAS(ret, __libc_##name, args, name);	\
55
Bool VG_(clo_trace_malloc)   = False;
56
	ret name args
56
57
/* Minimum alignment in functions that don't specify alignment explicitly.
58
   default: 0, i.e. use default of the machine (== 4) */
59
Int  VG_(clo_alignment) = 4;
60
61
62
Bool VG_(replacement_malloc_process_cmd_line_option)(Char* arg)
63
{
64
   if      (VG_CLO_STREQN(12, arg, "--alignment=")) {
65
      VG_(clo_alignment) = (Int)VG_(atoll)(&arg[12]);
66
67
      if (VG_(clo_alignment) < 4 
68
          || VG_(clo_alignment) > 4096
69
          || VG_(log2)( VG_(clo_alignment) ) == -1 /* not a power of 2 */) {
70
         VG_(message)(Vg_UserMsg, "");
71
         VG_(message)(Vg_UserMsg, 
72
            "Invalid --alignment= setting.  "
73
            "Should be a power of 2, >= 4, <= 4096.");
74
         VG_(bad_option)("--alignment");
75
      }
76
   }
77
78
   else if (VG_CLO_STREQ(arg, "--sloppy-malloc=yes"))
79
      VG_(clo_sloppy_malloc) = True;
80
   else if (VG_CLO_STREQ(arg, "--sloppy-malloc=no"))
81
      VG_(clo_sloppy_malloc) = False;
82
83
   else if (VG_CLO_STREQ(arg, "--trace-malloc=yes"))
84
      VG_(clo_trace_malloc) = True;
85
   else if (VG_CLO_STREQ(arg, "--trace-malloc=no"))
86
      VG_(clo_trace_malloc) = False;
87
88
   else 
89
      return False;
90
91
   return True;
92
}
93
94
void VG_(replacement_malloc_print_usage)(void)
95
{
96
   VG_(printf)(
97
"    --sloppy-malloc=no|yes    round malloc sizes to next word? [no]\n"
98
"    --alignment=<number>      set minimum alignment of allocations [4]\n"
99
   );
100
}
101
102
void VG_(replacement_malloc_print_debug_usage)(void)
103
{
104
   VG_(printf)(
105
"    --trace-malloc=no|yes     show client malloc details? [no]\n"
106
   );
107
}
108
109
57
110
/*------------------------------------------------------------*/
58
/*------------------------------------------------------------*/
111
/*--- Replacing malloc() et al                             ---*/
59
/*--- Replacing malloc() et al                             ---*/
112
/*------------------------------------------------------------*/
60
/*------------------------------------------------------------*/
113
61
62
static struct vg_mallocfunc_info info;
63
static int init_done;
64
65
/* Startup hook - called as init section */
66
static void init(void) __attribute__((constructor));
67
114
/* Below are new versions of malloc, __builtin_new, free, 
68
/* Below are new versions of malloc, __builtin_new, free, 
115
   __builtin_delete, calloc, realloc, memalign, and friends.
69
   __builtin_delete, calloc, realloc, memalign, and friends.
116
70
117
   malloc, __builtin_new, free, __builtin_delete, calloc and realloc
71
   None of these functions are called directly - they are not meant to
118
   can be entered either on the real CPU or the simulated one.  If on
72
   be found by the dynamic linker.  They get called because
119
   the real one, this is because the dynamic linker is running the
73
   vg_replace_malloc installs a bunch of code redirects which causes
120
   static initialisers for C++, before starting up Valgrind itself.
74
   Valgrind to use these functions rather than the ones they're
121
   In this case it is safe to route calls through to
75
   replacing.  That said, we certainly don't mind if the linker finds
122
   VG_(arena_malloc)/VG_(arena_free), since they are self-initialising.
76
   them, because it makes our life easier with respect to startup
123
77
   initialization order (we can't guarantee that our init routine will
124
   Once Valgrind is initialised, vg_running_on_simd_CPU becomes True.
78
   necessarily be called early enough to do the redirects before
125
   The call needs to be transferred from the simulated CPU back to the
79
   someone wants to allocate).
126
   real one and routed to the VG_(cli_malloc)() or VG_(cli_free)().  To do
127
   that, the client-request mechanism (in valgrind.h) is used to convey
128
   requests to the scheduler.
129
*/
80
*/
130
81
131
#define MALLOC_TRACE(format, args...)  \
82
#define MALLOC_TRACE(format, args...)  \
132
   if (VG_(clo_trace_malloc))          \
83
   if (info.clo_trace_malloc)          \
133
      VALGRIND_INTERNAL_PRINTF(format, ## args )
84
      VALGRIND_INTERNAL_PRINTF(format, ## args )
134
85
135
#define MAYBE_SLOPPIFY(n)           \
86
#define MAYBE_SLOPPIFY(n)           \
136
   if (VG_(clo_sloppy_malloc)) {    \
87
   if (info.clo_sloppy_malloc) {    \
137
      while ((n % 4) > 0) n++;      \
88
      n = (n+3) & ~3;		    \
138
   }
89
   }
139
90
140
/* ALL calls to malloc() and friends wind up here. */
91
/* ALL calls to malloc() and friends wind up here. */
141
#define ALLOC(fff, vgfff) \
92
#define ALLOC(fff, vgfff) \
142
void* fff ( Int n ) \
93
LIBALIAS(void *, fff, (Int n))			\
143
{ \
94
{ \
144
   void* v; \
95
   void* v; \
145
 \
96
 \
146
   MALLOC_TRACE(#fff "[simd=%d](%d)",  \
97
   MALLOC_TRACE(#fff "(%d)", n ); \
147
                (UInt)VG_(is_running_on_simd_CPU)(), n ); \
148
   MAYBE_SLOPPIFY(n); \
98
   MAYBE_SLOPPIFY(n); \
99
   if (!init_done) init(); \
149
 \
100
 \
150
   if (VG_(is_running_on_simd_CPU)()) { \
101
   v = (void*)VALGRIND_NON_SIMD_CALL1( info.sk_##vgfff, n ); \
151
      v = (void*)VALGRIND_NON_SIMD_CALL1( vgfff, n ); \
152
   } else if (VG_(clo_alignment) != 4) { \
153
      v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, VG_(clo_alignment), n); \
154
   } else { \
155
      v = VG_(arena_malloc)(VG_AR_CLIENT, n); \
156
   } \
157
   MALLOC_TRACE(" = %p", v ); \
102
   MALLOC_TRACE(" = %p", v ); \
158
   return v; \
103
   return v; \
159
}
104
}
160
ALLOC( malloc,              SK_(malloc)            );
105
ALLOC( malloc,              malloc            );
161
ALLOC( __builtin_new,       SK_(__builtin_new)     );
106
ALLOC( __builtin_new,       __builtin_new     );
162
ALLOC( _Znwj,               SK_(__builtin_new)     );
107
ALLOC( _Znwj,               __builtin_new     );
163
108
164
// operator new(unsigned, std::nothrow_t const&)
109
// operator new(unsigned, std::nothrow_t const&)
165
ALLOC( _ZnwjRKSt9nothrow_t, SK_(__builtin_new)     );
110
ALLOC( _ZnwjRKSt9nothrow_t, __builtin_new     );
166
111
167
ALLOC( __builtin_vec_new,   SK_(__builtin_vec_new) );
112
ALLOC( __builtin_vec_new,   __builtin_vec_new );
168
ALLOC( _Znaj,               SK_(__builtin_vec_new) );
113
ALLOC( _Znaj,               __builtin_vec_new );
169
114
170
// operator new[](unsigned, std::nothrow_t const&
115
// operator new[](unsigned, std::nothrow_t const&
171
ALLOC( _ZnajRKSt9nothrow_t, SK_(__builtin_vec_new) );
116
ALLOC( _ZnajRKSt9nothrow_t, __builtin_vec_new );
172
117
173
#define FREE(fff, vgfff) \
118
#define FREE(fff, vgfff) \
174
void fff ( void* p ) \
119
LIBALIAS(void, fff, (void *p))			\
175
{ \
120
{ \
176
   MALLOC_TRACE(#fff "[simd=%d](%p)",  \
121
   MALLOC_TRACE(#fff "(%p)", p ); \
177
                (UInt)VG_(is_running_on_simd_CPU)(), p ); \
178
   if (p == NULL)  \
122
   if (p == NULL)  \
179
      return; \
123
      return; \
180
   if (VG_(is_running_on_simd_CPU)()) { \
124
   if (!init_done) init(); \
181
      (void)VALGRIND_NON_SIMD_CALL1( vgfff, p ); \
125
   (void)VALGRIND_NON_SIMD_CALL1( info.sk_##vgfff, p ); \
182
   } else { \
126
}
183
      VG_(arena_free)(VG_AR_CLIENT, p);       \
127
FREE( free,                 free                 );
184
   } \
128
FREE( __builtin_delete,     __builtin_delete     );
185
}
129
FREE( _ZdlPv,               __builtin_delete     );
186
FREE( free,                 SK_(free)                 );
130
FREE( __builtin_vec_delete, __builtin_vec_delete );
187
FREE( __builtin_delete,     SK_(__builtin_delete)     );
131
FREE( _ZdaPv,               __builtin_vec_delete );
188
FREE( _ZdlPv,               SK_(__builtin_delete)     );
189
FREE( __builtin_vec_delete, SK_(__builtin_vec_delete) );
190
FREE( _ZdaPv,               SK_(__builtin_vec_delete) );
191
132
192
void* calloc ( UInt nmemb, UInt size )
133
LIBALIAS(void*, calloc, ( Int nmemb, Int size ))
193
{
134
{
194
   void* v;
135
   void* v;
195
136
196
   MALLOC_TRACE("calloc[simd=%d](%d,%d)", 
137
   MALLOC_TRACE("calloc(%d,%d)", nmemb, size );
197
                (UInt)VG_(is_running_on_simd_CPU)(), nmemb, size );
198
   MAYBE_SLOPPIFY(size);
138
   MAYBE_SLOPPIFY(size);
199
139
200
   if (VG_(is_running_on_simd_CPU)()) {
140
   if (!init_done) init();
201
      v = (void*)VALGRIND_NON_SIMD_CALL2( SK_(calloc), nmemb, size );
141
   v = (void*)VALGRIND_NON_SIMD_CALL2( info.sk_calloc, nmemb, size );
202
   } else {
203
      v = VG_(arena_calloc)(VG_AR_CLIENT, VG_(clo_alignment), nmemb, size);
204
   }
205
   MALLOC_TRACE(" = %p", v );
142
   MALLOC_TRACE(" = %p", v );
206
   return v;
143
   return v;
207
}
144
}
208
145
209
146
LIBALIAS(void*, realloc, ( void* ptrV, Int new_size ))
210
void* realloc ( void* ptrV, Int new_size )
211
{
147
{
212
   void* v;
148
   void* v;
213
149
214
   MALLOC_TRACE("realloc[simd=%d](%p,%d)", 
150
   MALLOC_TRACE("realloc(%p,%d)", ptrV, new_size );
215
                (UInt)VG_(is_running_on_simd_CPU)(), ptrV, new_size );
216
   MAYBE_SLOPPIFY(new_size);
151
   MAYBE_SLOPPIFY(new_size);
217
152
218
   if (ptrV == NULL)
153
   if (ptrV == NULL)
219
      return malloc(new_size);
154
      return malloc(new_size);
220
   if (new_size <= 0) {
155
   if (new_size <= 0) {
221
      free(ptrV);
156
      free(ptrV);
222
      if (VG_(clo_trace_malloc)) 
157
      if (info.clo_trace_malloc) 
223
         VG_(printf)(" = 0" );
158
         VALGRIND_INTERNAL_PRINTF(" = 0" );
224
      return NULL;
159
      return NULL;
225
   }   
160
   }   
226
   if (VG_(is_running_on_simd_CPU)()) {
161
   if (!init_done) init();
227
      v = (void*)VALGRIND_NON_SIMD_CALL2( SK_(realloc), ptrV, new_size );
162
   v = (void*)VALGRIND_NON_SIMD_CALL2( info.sk_realloc, ptrV, new_size );
228
   } else {
229
      v = VG_(arena_realloc)(VG_AR_CLIENT, ptrV, VG_(clo_alignment), new_size);
230
   }
231
   MALLOC_TRACE(" = %p", v );
163
   MALLOC_TRACE(" = %p", v );
232
   return v;
164
   return v;
233
}
165
}
234
166
235
167
236
void* memalign ( Int alignment, Int n )
168
LIBALIAS(void*, memalign, ( Int alignment, Int n ))
237
{
169
{
238
   void* v;
170
   void* v;
239
171
240
   MALLOC_TRACE("memalign[simd=%d](al %d, size %d)", 
172
   MALLOC_TRACE("memalign(al %d, size %d)", alignment, n );
241
                (UInt)VG_(is_running_on_simd_CPU)(), alignment, n );
242
   MAYBE_SLOPPIFY(n);
173
   MAYBE_SLOPPIFY(n);
243
174
244
   if (VG_(is_running_on_simd_CPU)()) {
175
   if (!init_done) init();
245
      v = (void*)VALGRIND_NON_SIMD_CALL2( SK_(memalign), alignment, n );
176
   v = (void*)VALGRIND_NON_SIMD_CALL2( info.sk_memalign, alignment, n );
246
   } else {
247
      v = VG_(arena_malloc_aligned)(VG_AR_CLIENT, alignment, n);
248
   }
249
   MALLOC_TRACE(" = %p", v );
177
   MALLOC_TRACE(" = %p", v );
250
   return v;
178
   return v;
251
}
179
}
252
180
253
181
254
void* valloc ( Int size )
182
LIBALIAS(void*, valloc, ( Int size ))
255
{
183
{
256
   return memalign(VKI_BYTES_PER_PAGE, size);
184
   return memalign(VKI_BYTES_PER_PAGE, size);
257
}
185
}
258
186
259
187
260
/* Various compatibility wrapper functions, for glibc and libstdc++. */
188
/* Various compatibility wrapper functions, for glibc and libstdc++. */
261
void cfree ( void* p )
189
190
/* Don't just alias free, otherwise people could get confused seeing
191
   cfree rather than free in error output */
192
LIBALIAS(void, cfree, ( void* p ) )
262
{
193
{
263
   free ( p );
194
   free(p);
264
}
195
}
265
196
266
197
LIBALIAS(int, mallopt, ( int cmd, int value ))
267
int mallopt ( int cmd, int value )
268
{
198
{
269
   /* In glibc-2.2.4, 1 denotes a successful return value for mallopt */
199
   /* In glibc-2.2.4, 1 denotes a successful return value for mallopt */
270
   return 1;
200
   return 1;
271
}
201
}
272
202
273
203
274
int __posix_memalign ( void **memptr, UInt alignment, UInt size )
204
LIBALIAS(int, posix_memalign, ( void **memptr, UInt alignment, UInt size ))
275
{
205
{
276
    void *mem;
206
    void *mem;
277
207
Lines 290-314 Link Here
290
    return VKI_ENOMEM /*12*/ /*ENOMEM*/;
220
    return VKI_ENOMEM /*12*/ /*ENOMEM*/;
291
}
221
}
292
222
293
# define weak_alias(name, aliasname) \
223
LIBALIAS(int, malloc_usable_size, ( void* p ))
294
  extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
295
weak_alias(__posix_memalign, posix_memalign);
296
297
Int malloc_usable_size ( void* p )
298
{ 
224
{ 
299
   Int pszB;
225
   Int pszB;
300
   
226
   
301
   MALLOC_TRACE("malloc_usable_size[simd=%d](%p)", 
227
   MALLOC_TRACE("malloc_usable_size(%p)", p );
302
                (UInt)VG_(is_running_on_simd_CPU)(), p );
303
   if (NULL == p)
228
   if (NULL == p)
304
      return 0;
229
      return 0;
305
230
306
   if (VG_(is_running_on_simd_CPU)()) {
231
   if (!init_done) init();
307
      pszB = (Int)VALGRIND_NON_SIMD_CALL2( VG_(arena_payload_szB), 
232
   pszB = (Int)VALGRIND_NON_SIMD_CALL2( info.arena_payload_szB, 
308
                                           VG_AR_CLIENT, p );
233
					VG_AR_CLIENT, p );
309
   } else {
310
      pszB = VG_(arena_payload_szB)(VG_AR_CLIENT, p);
311
   }
312
   MALLOC_TRACE(" = %d", pszB );
234
   MALLOC_TRACE(" = %d", pszB );
313
235
314
   return pszB;
236
   return pszB;
Lines 316-336 Link Here
316
238
317
239
318
/* Bomb out if we get any of these. */
240
/* Bomb out if we get any of these. */
319
/* HACK: We shouldn't call VG_(core_panic) or VG_(message) on the simulated
241
320
   CPU.  Really we should pass the request in the usual way, and
242
extern void _exit(int);
321
   Valgrind itself can do the panic.  Too tedious, however.  
243
322
*/
244
static void panic(const char *str)
323
void pvalloc ( void )
245
{
324
{ VG_(core_panic)("call to pvalloc\n"); }
246
   VALGRIND_PRINTF_BACKTRACE("Program aborting because of call to %s", str);
325
void malloc_stats ( void )
247
   
326
{ VG_(core_panic)("call to malloc_stats\n"); }
248
   _exit(99);
327
249
   *(int *)0 = 'x';
328
void malloc_trim ( void )
250
}
329
{ VG_(core_panic)("call to malloc_trim\n"); }
251
330
void malloc_get_state ( void )
252
#define PANIC(x)				\
331
{ VG_(core_panic)("call to malloc_get_state\n"); }
253
   void x(void)					\
332
void malloc_set_state ( void )
254
   {						\
333
{ VG_(core_panic)("call to malloc_set_state\n"); }
255
      panic(#x);				\
256
   }
257
258
PANIC(pvalloc);
259
PANIC(malloc_stats);
260
PANIC(malloc_trim);
261
PANIC(malloc_get_state);
262
PANIC(malloc_set_state);
334
263
335
264
336
/* Yet another ugly hack.  Cannot include <malloc.h> because we
265
/* Yet another ugly hack.  Cannot include <malloc.h> because we
Lines 351-357 Link Here
351
   int keepcost; /* top-most, releasable (via malloc_trim) space */
280
   int keepcost; /* top-most, releasable (via malloc_trim) space */
352
};
281
};
353
282
354
struct mallinfo mallinfo ( void )
283
LIBALIAS(struct mallinfo, mallinfo, ( void ))
355
{
284
{
356
   /* Should really try to return something a bit more meaningful */
285
   /* Should really try to return something a bit more meaningful */
357
   UInt            i;
286
   UInt            i;
Lines 362-367 Link Here
362
   return mi;
291
   return mi;
363
}
292
}
364
293
294
static const struct {
295
   const Char *libname;
296
   Addr		func;
297
} replacements[] =
298
{
299
#define E(pfx, x)	{ pfx #x, (Addr)x }
300
#define R(x)		E("", x), E("__libc_", x), E("__", x)
301
302
   /* alloc */
303
   R(malloc),
304
   R(__builtin_new),
305
   R(_Znwj),
306
   R(_ZnwjRKSt9nothrow_t),	/* operator new(unsigned, std::nothrow_t const&) */
307
   R(__builtin_vec_new),
308
   R(_Znaj),
309
   R(_ZnajRKSt9nothrow_t),	/* operator new[](unsigned, std::nothrow_t const& */
310
   R(calloc),
311
   R(realloc),
312
   R(memalign),
313
   R(valloc),
314
   R(cfree),
315
   R(posix_memalign),
316
317
   /* free */
318
   R(free),
319
   R(__builtin_delete),
320
   R(_ZdlPv),
321
   R(__builtin_vec_delete),
322
   R(_ZdaPv),
323
324
   /* misc */
325
   R(mallopt),
326
   R(malloc_usable_size),
327
   R(mallinfo),
328
329
   /* bad */
330
   R(pvalloc),
331
   R(malloc_stats),
332
   R(malloc_trim),
333
   R(malloc_get_state),
334
   R(malloc_set_state),   
335
#undef R
336
#undef S
337
#undef E
338
};
339
340
/* All the code in here is unused until this function is called */
341
342
static void init(void)
343
{
344
   int i;
345
   int res;
346
347
   if (init_done)
348
      return;
349
350
   init_done = 1;
351
352
   VALGRIND_MAGIC_SEQUENCE(res, -1, VG_USERREQ__GET_MALLOCFUNCS, &info, 0, 0, 0);
353
354
   for(i = 0; i < sizeof(replacements)/sizeof(*replacements); i++) {
355
#if 0
356
      /* doesn't seem much point - ld-linux.so will have already used
357
	 malloc/free before we run */
358
      VALGRIND_MAGIC_SEQUENCE(res, 0, VG_USERREQ__REGISTER_REDIRECT_ADDR, 
359
			      "soname:ld-linux.so.2", replacements[i].libname,
360
			      replacements[i].func, 0);
361
#endif
362
      VALGRIND_MAGIC_SEQUENCE(res, 0, VG_USERREQ__REGISTER_REDIRECT_ADDR, 
363
			      "soname:libc.so.6", replacements[i].libname,
364
			      replacements[i].func, 0);
365
      VALGRIND_MAGIC_SEQUENCE(res, 0, VG_USERREQ__REGISTER_REDIRECT_ADDR, 
366
			      "soname:libstdc++*", replacements[i].libname,
367
			      replacements[i].func, 0);
368
   }
369
}
370
365
/*--------------------------------------------------------------------*/
371
/*--------------------------------------------------------------------*/
366
/*--- end                                      vg_replace_malloc.c ---*/
372
/*--- end                                      vg_replace_malloc.c ---*/
367
/*--------------------------------------------------------------------*/
373
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/vg_scheduler.c (-53 / +134 lines)
Lines 7-13 Link Here
7
   This file is part of Valgrind, an extensible x86 protected-mode
7
   This file is part of Valgrind, an extensible x86 protected-mode
8
   emulator for monitoring program execution on x86-Unixes.
8
   emulator for monitoring program execution on x86-Unixes.
9
9
10
   Copyright (C) 2000-2003 Julian Seward 
10
   Copyright (C) 2000-2004 Julian Seward 
11
      jseward@acm.org
11
      jseward@acm.org
12
12
13
   This program is free software; you can redistribute it and/or
13
   This program is free software; you can redistribute it and/or
Lines 119-124 Link Here
119
119
120
typedef UInt ThreadKey;
120
typedef UInt ThreadKey;
121
121
122
/* The scheduler does need to know the address of it so it can be
123
   called at program exit. */
124
static Addr VG_(__libc_freeres_wrapper);
125
122
126
123
UInt VG_(syscall_altered_shadow_reg);
127
UInt VG_(syscall_altered_shadow_reg);
124
UInt VG_(signal_delivery_altered_shadow_reg);
128
UInt VG_(signal_delivery_altered_shadow_reg);
Lines 243-248 Link Here
243
   switch (event) {
247
   switch (event) {
244
      case VG_TRC_EBP_JMP_SYSCALL:    return "SYSCALL";
248
      case VG_TRC_EBP_JMP_SYSCALL:    return "SYSCALL";
245
      case VG_TRC_EBP_JMP_CLIENTREQ:  return "CLIENTREQ";
249
      case VG_TRC_EBP_JMP_CLIENTREQ:  return "CLIENTREQ";
250
      case VG_TRC_EBP_JMP_YIELD:      return "YIELD";
246
      case VG_TRC_INNER_COUNTERZERO:  return "COUNTERZERO";
251
      case VG_TRC_INNER_COUNTERZERO:  return "COUNTERZERO";
247
      case VG_TRC_INNER_FASTMISS:     return "FASTMISS";
252
      case VG_TRC_INNER_FASTMISS:     return "FASTMISS";
248
      case VG_TRC_UNRESUMABLE_SIGNAL: return "FATALSIGNAL";
253
      case VG_TRC_UNRESUMABLE_SIGNAL: return "FATALSIGNAL";
Lines 334-339 Link Here
334
   vg_assert(vg_tid_currently_in_baseBlock == VG_INVALID_THREADID);
339
   vg_assert(vg_tid_currently_in_baseBlock == VG_INVALID_THREADID);
335
340
336
   VG_(baseBlock)[VGOFF_(ldt)]  = (UInt)VG_(threads)[tid].ldt;
341
   VG_(baseBlock)[VGOFF_(ldt)]  = (UInt)VG_(threads)[tid].ldt;
342
   VG_(baseBlock)[VGOFF_(tls)]  = (UInt)VG_(threads)[tid].tls;
337
   VG_(baseBlock)[VGOFF_(m_cs)] = VG_(threads)[tid].m_cs;
343
   VG_(baseBlock)[VGOFF_(m_cs)] = VG_(threads)[tid].m_cs;
338
   VG_(baseBlock)[VGOFF_(m_ss)] = VG_(threads)[tid].m_ss;
344
   VG_(baseBlock)[VGOFF_(m_ss)] = VG_(threads)[tid].m_ss;
339
   VG_(baseBlock)[VGOFF_(m_ds)] = VG_(threads)[tid].m_ds;
345
   VG_(baseBlock)[VGOFF_(m_ds)] = VG_(threads)[tid].m_ds;
Lines 415-420 Link Here
415
   vg_assert((void*)VG_(threads)[tid].ldt 
421
   vg_assert((void*)VG_(threads)[tid].ldt 
416
             == (void*)VG_(baseBlock)[VGOFF_(ldt)]);
422
             == (void*)VG_(baseBlock)[VGOFF_(ldt)]);
417
423
424
   /* We don't copy out the TLS entry, because it can never be changed
425
      by the normal actions of the thread, only by the set_thread_area
426
      syscall, in which case we will correctly be updating
427
      VG_(threads)[tid].tls.  This printf happens iff the following
428
      assertion fails. */
429
   if ((void*)VG_(threads)[tid].tls != (void*)VG_(baseBlock)[VGOFF_(tls)])
430
      VG_(printf)("VG_(threads)[%d].tls=%p  VG_(baseBlock)[VGOFF_(tls)]=%p\n",
431
		  tid, (void*)VG_(threads)[tid].tls, 
432
                       (void*)VG_(baseBlock)[VGOFF_(tls)]);
433
434
   vg_assert((void*)VG_(threads)[tid].tls 
435
             == (void*)VG_(baseBlock)[VGOFF_(tls)]);
436
418
   VG_(threads)[tid].m_cs = VG_(baseBlock)[VGOFF_(m_cs)];
437
   VG_(threads)[tid].m_cs = VG_(baseBlock)[VGOFF_(m_cs)];
419
   VG_(threads)[tid].m_ss = VG_(baseBlock)[VGOFF_(m_ss)];
438
   VG_(threads)[tid].m_ss = VG_(baseBlock)[VGOFF_(m_ss)];
420
   VG_(threads)[tid].m_ds = VG_(baseBlock)[VGOFF_(m_ds)];
439
   VG_(threads)[tid].m_ds = VG_(baseBlock)[VGOFF_(m_ds)];
Lines 464-469 Link Here
464
483
465
   /* Fill it up with junk. */
484
   /* Fill it up with junk. */
466
   VG_(baseBlock)[VGOFF_(ldt)] = junk;
485
   VG_(baseBlock)[VGOFF_(ldt)] = junk;
486
   VG_(baseBlock)[VGOFF_(tls)] = junk;
467
   VG_(baseBlock)[VGOFF_(m_cs)] = junk;
487
   VG_(baseBlock)[VGOFF_(m_cs)] = junk;
468
   VG_(baseBlock)[VGOFF_(m_ss)] = junk;
488
   VG_(baseBlock)[VGOFF_(m_ss)] = junk;
469
   VG_(baseBlock)[VGOFF_(m_ds)] = junk;
489
   VG_(baseBlock)[VGOFF_(m_ds)] = junk;
Lines 497-503 Link Here
497
   volatile UInt trc = 0;
517
   volatile UInt trc = 0;
498
   vg_assert(VG_(is_valid_tid)(tid));
518
   vg_assert(VG_(is_valid_tid)(tid));
499
   vg_assert(VG_(threads)[tid].status == VgTs_Runnable);
519
   vg_assert(VG_(threads)[tid].status == VgTs_Runnable);
500
   vg_assert(VG_(bbs_to_go) > 0);
501
   vg_assert(!VG_(scheduler_jmpbuf_valid));
520
   vg_assert(!VG_(scheduler_jmpbuf_valid));
502
521
503
   VGP_PUSHCC(VgpRun);
522
   VGP_PUSHCC(VgpRun);
Lines 533-538 Link Here
533
{
552
{
534
   vg_assert(tid >= 0 && tid < VG_N_THREADS);
553
   vg_assert(tid >= 0 && tid < VG_N_THREADS);
535
   VG_(threads)[tid].ldt                  = NULL;
554
   VG_(threads)[tid].ldt                  = NULL;
555
   VG_(clear_TLS_for_thread)(VG_(threads)[tid].tls);
536
   VG_(threads)[tid].tid                  = tid;
556
   VG_(threads)[tid].tid                  = tid;
537
   VG_(threads)[tid].status               = VgTs_Empty;
557
   VG_(threads)[tid].status               = VgTs_Empty;
538
   VG_(threads)[tid].associated_mx        = NULL;
558
   VG_(threads)[tid].associated_mx        = NULL;
Lines 560-567 Link Here
560
580
561
/* Initialise the scheduler.  Create a single "main" thread ready to
581
/* Initialise the scheduler.  Create a single "main" thread ready to
562
   run, with special ThreadId of one.  This is called at startup; the
582
   run, with special ThreadId of one.  This is called at startup; the
563
   caller takes care to park the client's state is parked in
583
   caller takes care to park the client's state in VG_(baseBlock).  
564
   VG_(baseBlock).  
565
*/
584
*/
566
void VG_(scheduler_init) ( void )
585
void VG_(scheduler_init) ( void )
567
{
586
{
Lines 591-602 Link Here
591
   /* Copy VG_(baseBlock) state to tid_main's slot. */
610
   /* Copy VG_(baseBlock) state to tid_main's slot. */
592
   vg_tid_currently_in_baseBlock = tid_main;
611
   vg_tid_currently_in_baseBlock = tid_main;
593
   vg_tid_last_in_baseBlock = tid_main;
612
   vg_tid_last_in_baseBlock = tid_main;
613
   VG_(baseBlock)[VGOFF_(tls)] = (UInt)VG_(threads)[tid_main].tls;
594
   VG_(save_thread_state) ( tid_main );
614
   VG_(save_thread_state) ( tid_main );
595
615
596
   VG_(threads)[tid_main].stack_highest_word 
616
   VG_(threads)[tid_main].stack_highest_word 
597
      = VG_(foundstack_start) + VG_(foundstack_size) - 4;
617
      = VG_(clstk_end) - 4;
598
   VG_(threads)[tid_main].stack_base = VG_(foundstack_start);
618
   VG_(threads)[tid_main].stack_base = VG_(clstk_base);
599
   VG_(threads)[tid_main].stack_size = VG_(foundstack_size);
619
   VG_(threads)[tid_main].stack_size = VG_(clstk_end) - VG_(clstk_base);
600
620
601
   /* So now ... */
621
   /* So now ... */
602
   vg_assert(vg_tid_currently_in_baseBlock == VG_INVALID_THREADID);
622
   vg_assert(vg_tid_currently_in_baseBlock == VG_INVALID_THREADID);
Lines 694-700 Link Here
694
714
695
   /* If pre_syscall returns true, then we're done immediately */
715
   /* If pre_syscall returns true, then we're done immediately */
696
   if (VG_(pre_syscall)(tid)) {
716
   if (VG_(pre_syscall)(tid)) {
697
      VG_(post_syscall(tid));
717
      VG_(post_syscall(tid, True));
698
      vg_assert(VG_(threads)[tid].status == VgTs_Runnable);
718
      vg_assert(VG_(threads)[tid].status == VgTs_Runnable);
699
   } else {
719
   } else {
700
      vg_assert(VG_(threads)[tid].status == VgTs_WaitSys);
720
      vg_assert(VG_(threads)[tid].status == VgTs_WaitSys);
Lines 880-889 Link Here
880
         or declare deadlock, or sleep if there are no runnable
900
         or declare deadlock, or sleep if there are no runnable
881
         threads but some are blocked on I/O.  */
901
         threads but some are blocked on I/O.  */
882
902
883
      /* Was a debug-stop requested? */
884
      if (VG_(bbs_to_go) == 0) 
885
         goto debug_stop;
886
887
      /* Do the following loop until a runnable thread is found, or
903
      /* Do the following loop until a runnable thread is found, or
888
         deadlock is detected. */
904
         deadlock is detected. */
889
      while (True) {
905
      while (True) {
Lines 975-984 Link Here
975
         decrement is done before the bb is actually run, so you
991
         decrement is done before the bb is actually run, so you
976
         always get at least one decrement even if nothing happens.
992
         always get at least one decrement even if nothing happens.
977
      */
993
      */
978
      if (VG_(bbs_to_go) >= VG_SCHEDULING_QUANTUM)
994
      VG_(dispatch_ctr) = VG_SCHEDULING_QUANTUM + 1;
979
         VG_(dispatch_ctr) = VG_SCHEDULING_QUANTUM + 1;
980
      else
981
         VG_(dispatch_ctr) = (UInt)VG_(bbs_to_go) + 1;
982
995
983
      /* ... and remember what we asked for. */
996
      /* ... and remember what we asked for. */
984
      dispatch_ctr_SAVED = VG_(dispatch_ctr);
997
      dispatch_ctr_SAVED = VG_(dispatch_ctr);
Lines 1092-1110 Link Here
1092
               /* If __NR_exit, remember the supplied argument. */
1105
               /* If __NR_exit, remember the supplied argument. */
1093
               VG_(exitcode) = VG_(threads)[tid].m_ebx; /* syscall arg1 */
1106
               VG_(exitcode) = VG_(threads)[tid].m_ebx; /* syscall arg1 */
1094
1107
1095
               /* Only run __libc_freeres if the skin says it's ok and
1108
               /* Only run __libc_freeres if the tool says it's ok and
1096
                  it hasn't been overridden with --run-libc-freeres=no
1109
                  it hasn't been overridden with --run-libc-freeres=no
1097
                  on the command line. */
1110
                  on the command line. */
1098
1111
1099
               if (VG_(needs).libc_freeres && VG_(clo_run_libc_freeres)) {
1112
               if (VG_(needs).libc_freeres && 
1100
1113
		   VG_(clo_run_libc_freeres) &&
1114
		   VG_(__libc_freeres_wrapper) != 0) {
1101
                  if (VG_(clo_verbosity) > 2 
1115
                  if (VG_(clo_verbosity) > 2 
1102
                      || VG_(clo_trace_syscalls) || VG_(clo_trace_sched)) {
1116
                      || VG_(clo_trace_syscalls) || VG_(clo_trace_sched)) {
1103
                     VG_(message)(Vg_DebugMsg, 
1117
                     VG_(message)(Vg_DebugMsg, 
1104
                        "Caught __NR_exit; running __libc_freeres()");
1118
                        "Caught __NR_exit; running __libc_freeres()");
1105
                  }
1119
                  }
1106
                  VG_(nuke_all_threads_except) ( tid );
1120
                  VG_(nuke_all_threads_except) ( tid );
1107
                  VG_(threads)[tid].m_eip = (UInt)(&VG_(__libc_freeres_wrapper));
1121
                  VG_(threads)[tid].m_eip = (UInt)VG_(__libc_freeres_wrapper);
1108
                  vg_assert(VG_(threads)[tid].status == VgTs_Runnable);
1122
                  vg_assert(VG_(threads)[tid].status == VgTs_Runnable);
1109
                  goto stage1; /* party on, dudes (but not for much longer :) */
1123
                  goto stage1; /* party on, dudes (but not for much longer :) */
1110
1124
Lines 1164-1170 Link Here
1164
1178
1165
      done_this_time = (Int)dispatch_ctr_SAVED - (Int)VG_(dispatch_ctr) - 1;
1179
      done_this_time = (Int)dispatch_ctr_SAVED - (Int)VG_(dispatch_ctr) - 1;
1166
      vg_assert(done_this_time >= 0);
1180
      vg_assert(done_this_time >= 0);
1167
      VG_(bbs_to_go)   -= (ULong)done_this_time;
1168
      VG_(bbs_done)    += (ULong)done_this_time;
1181
      VG_(bbs_done)    += (ULong)done_this_time;
1169
1182
1170
      if (0 && trc != VG_TRC_INNER_FASTMISS)
1183
      if (0 && trc != VG_TRC_INNER_FASTMISS)
Lines 1181-1193 Link Here
1181
1194
1182
      switch (trc) {
1195
      switch (trc) {
1183
1196
1197
         case VG_TRC_EBP_JMP_YIELD:
1198
            /* Explicit yield.  Let a new thread be scheduled,
1199
               simply by doing nothing, causing us to arrive back at
1200
               Phase 1. */
1201
            break;
1202
1184
         case VG_TRC_INNER_COUNTERZERO:
1203
         case VG_TRC_INNER_COUNTERZERO:
1185
            /* Timeslice is out.  Let a new thread be scheduled,
1204
            /* Timeslice is out.  Let a new thread be scheduled,
1186
               simply by doing nothing, causing us to arrive back at
1205
               simply by doing nothing, causing us to arrive back at
1187
               Phase 1. */
1206
               Phase 1. */
1188
            if (VG_(bbs_to_go) == 0) {
1189
               goto debug_stop;
1190
            }
1191
            vg_assert(VG_(dispatch_ctr) == 0);
1207
            vg_assert(VG_(dispatch_ctr) == 0);
1192
            break;
1208
            break;
1193
1209
Lines 1225-1244 Link Here
1225
   /* NOTREACHED */
1241
   /* NOTREACHED */
1226
   VG_(core_panic)("scheduler: post-main-loop ?!");
1242
   VG_(core_panic)("scheduler: post-main-loop ?!");
1227
   /* NOTREACHED */
1243
   /* NOTREACHED */
1228
1229
  debug_stop:
1230
   /* If we exited because of a debug stop, print the translation 
1231
      of the last block executed -- by translating it again, and 
1232
      throwing away the result. */
1233
   VG_(printf)(
1234
      "======vvvvvvvv====== LAST TRANSLATION ======vvvvvvvv======\n");
1235
   VG_(translate)( tid, 
1236
                   VG_(threads)[tid].m_eip, NULL, NULL, NULL, NULL );
1237
   VG_(printf)("\n");
1238
   VG_(printf)(
1239
      "======^^^^^^^^====== LAST TRANSLATION ======^^^^^^^^======\n");
1240
1241
   return VgSrc_BbsDone;
1242
}
1244
}
1243
1245
1244
void VG_(need_resched) ( ThreadId prefer )
1246
void VG_(need_resched) ( ThreadId prefer )
Lines 1357-1362 Link Here
1357
   VG_(deallocate_LDT_for_thread)( VG_(threads)[tid].ldt );
1359
   VG_(deallocate_LDT_for_thread)( VG_(threads)[tid].ldt );
1358
   VG_(threads)[tid].ldt = NULL;
1360
   VG_(threads)[tid].ldt = NULL;
1359
1361
1362
   /* Clear its TLS array. */
1363
   VG_(clear_TLS_for_thread)( VG_(threads)[tid].tls );
1364
1360
   /* Not interested in the timeout anymore */
1365
   /* Not interested in the timeout anymore */
1361
   VG_(threads)[tid].awaken_at = 0xFFFFFFFF;
1366
   VG_(threads)[tid].awaken_at = 0xFFFFFFFF;
1362
1367
Lines 1843-1848 Link Here
1843
      VG_(baseBlock)[VGOFF_(ldt)] = (UInt)VG_(threads)[tid].ldt;
1848
      VG_(baseBlock)[VGOFF_(ldt)] = (UInt)VG_(threads)[tid].ldt;
1844
   }
1849
   }
1845
1850
1851
   /* Initialise the thread's TLS array */
1852
   VG_(clear_TLS_for_thread)( VG_(threads)[tid].tls );
1853
   VG_(baseBlock)[VGOFF_(tls)] = (UInt)VG_(threads)[tid].tls;
1854
1846
   VG_(save_thread_state)(tid);
1855
   VG_(save_thread_state)(tid);
1847
   vg_tid_last_in_baseBlock = tid;
1856
   vg_tid_last_in_baseBlock = tid;
1848
1857
Lines 1858-1865 Link Here
1858
         assigning it for the first time. */
1867
         assigning it for the first time. */
1859
      vg_assert(VG_(threads)[tid].stack_size == 0);
1868
      vg_assert(VG_(threads)[tid].stack_size == 0);
1860
      vg_assert(VG_(threads)[tid].stack_base == (Addr)NULL);
1869
      vg_assert(VG_(threads)[tid].stack_base == (Addr)NULL);
1861
      new_stack = (Addr)VG_(get_memory_from_mmap)( new_stk_szb, 
1870
      new_stack = VG_(client_alloc)(0, new_stk_szb, 
1862
                                                   "new thread stack" );
1871
				    VKI_PROT_READ | VKI_PROT_WRITE | VKI_PROT_EXEC, 
1872
				    SF_STACK);
1863
      VG_(threads)[tid].stack_base = new_stack;
1873
      VG_(threads)[tid].stack_base = new_stack;
1864
      VG_(threads)[tid].stack_size = new_stk_szb;
1874
      VG_(threads)[tid].stack_size = new_stk_szb;
1865
      VG_(threads)[tid].stack_highest_word
1875
      VG_(threads)[tid].stack_highest_word
Lines 2059-2066 Link Here
2059
   }
2069
   }
2060
2070
2061
   if (mutex->__m_count > 0) {
2071
   if (mutex->__m_count > 0) {
2062
2072
      if (!VG_(is_valid_tid)((ThreadId)mutex->__m_owner)) {
2063
      vg_assert(VG_(is_valid_tid)((ThreadId)mutex->__m_owner));
2073
         VG_(record_pthread_error)( tid, 
2074
            "pthread_mutex_lock/trylock: mutex has invalid owner");
2075
         SET_PTHREQ_RETVAL(tid, VKI_EINVAL);
2076
         return;
2077
      }	 
2064
2078
2065
      /* Someone has it already. */
2079
      /* Someone has it already. */
2066
      if ((ThreadId)mutex->__m_owner == tid) {
2080
      if ((ThreadId)mutex->__m_owner == tid) {
Lines 2880-2914 Link Here
2880
   UInt*        arg    = (UInt*)(VG_(threads)[tid].m_eax);
2894
   UInt*        arg    = (UInt*)(VG_(threads)[tid].m_eax);
2881
   UInt         req_no = arg[0];
2895
   UInt         req_no = arg[0];
2882
2896
2883
   /* VG_(printf)("req no = 0x%x\n", req_no); */
2897
   if (0)
2898
      VG_(printf)("req no = 0x%x\n", req_no);
2884
   switch (req_no) {
2899
   switch (req_no) {
2885
2900
2886
      case VG_USERREQ__CLIENT_CALL0: {
2901
      case VG_USERREQ__CLIENT_CALL0: {
2887
         UInt (*f)(void) = (void*)arg[1];
2902
         UInt (*f)(void) = (void*)arg[1];
2888
         SET_CLCALL_RETVAL(tid, f ( ), (Addr)f);
2903
	 if (f == NULL)
2904
	    VG_(message)(Vg_DebugMsg, "VG_USERREQ__CLIENT_CALL: func=%p\n", f);
2905
	 else
2906
	    SET_CLCALL_RETVAL(tid, f ( ), (Addr)f);
2889
         break;
2907
         break;
2890
      }
2908
      }
2891
      case VG_USERREQ__CLIENT_CALL1: {
2909
      case VG_USERREQ__CLIENT_CALL1: {
2892
         UInt (*f)(UInt) = (void*)arg[1];
2910
         UInt (*f)(UInt) = (void*)arg[1];
2893
         SET_CLCALL_RETVAL(tid, f ( arg[2] ), (Addr)f );
2911
	 if (f == NULL)
2912
	    VG_(message)(Vg_DebugMsg, "VG_USERREQ__CLIENT_CALL: func=%p\n", f);
2913
	 else
2914
	    SET_CLCALL_RETVAL(tid, f ( arg[2] ), (Addr)f );
2894
         break;
2915
         break;
2895
      }
2916
      }
2896
      case VG_USERREQ__CLIENT_CALL2: {
2917
      case VG_USERREQ__CLIENT_CALL2: {
2897
         UInt (*f)(UInt, UInt) = (void*)arg[1];
2918
         UInt (*f)(UInt, UInt) = (void*)arg[1];
2898
         SET_CLCALL_RETVAL(tid, f ( arg[2], arg[3] ), (Addr)f );
2919
	 if (f == NULL)
2920
	    VG_(message)(Vg_DebugMsg, "VG_USERREQ__CLIENT_CALL: func=%p\n", f);
2921
	 else
2922
	    SET_CLCALL_RETVAL(tid, f ( arg[2], arg[3] ), (Addr)f );
2899
         break;
2923
         break;
2900
      }
2924
      }
2901
      case VG_USERREQ__CLIENT_CALL3: {
2925
      case VG_USERREQ__CLIENT_CALL3: {
2902
         UInt (*f)(UInt, UInt, UInt) = (void*)arg[1];
2926
         UInt (*f)(UInt, UInt, UInt) = (void*)arg[1];
2903
         SET_CLCALL_RETVAL(tid, f ( arg[2], arg[3], arg[4] ), (Addr)f );
2927
	 if (f == NULL)
2928
	    VG_(message)(Vg_DebugMsg, "VG_USERREQ__CLIENT_CALL: func=%p\n", f);
2929
	 else
2930
	    SET_CLCALL_RETVAL(tid, f ( arg[2], arg[3], arg[4] ), (Addr)f );
2904
         break;
2931
         break;
2905
      }
2932
      }
2906
2933
2907
      /* Note:  for skins that replace malloc() et al, we want to call
2934
      /* Note:  for tools that replace malloc() et al, we want to call
2908
         the replacement versions.  For those that don't, we want to call
2935
         the replacement versions.  For those that don't, we want to call
2909
         VG_(cli_malloc)() et al.  We do this by calling SK_(malloc)(), which
2936
         VG_(cli_malloc)() et al.  We do this by calling SK_(malloc)(), which
2910
         malloc-replacing skins must replace, but have its default definition
2937
         malloc-replacing tools must replace, but have the default definition
2911
         call */
2938
         of SK_(malloc)() call VG_(cli_malloc)().  */
2912
2939
2913
      /* Note: for MALLOC and FREE, must set the appropriate "lock"... see
2940
      /* Note: for MALLOC and FREE, must set the appropriate "lock"... see
2914
         the comment in vg_defaults.c/SK_(malloc)() for why. */
2941
         the comment in vg_defaults.c/SK_(malloc)() for why. */
Lines 3109-3121 Link Here
3109
      case VG_USERREQ__SIGNAL_RETURNS: 
3136
      case VG_USERREQ__SIGNAL_RETURNS: 
3110
         handle_signal_return(tid);
3137
         handle_signal_return(tid);
3111
	 break;
3138
	 break;
3112
 
3139
3140
3141
      case VG_USERREQ__GET_SIGRT_MIN:
3142
	 SET_PTHREQ_RETVAL(tid, VG_(sig_rtmin));
3143
	 break;
3144
3145
      case VG_USERREQ__GET_SIGRT_MAX:
3146
	 SET_PTHREQ_RETVAL(tid, VG_(sig_rtmax));
3147
	 break;
3148
3149
      case VG_USERREQ__ALLOC_RTSIG:
3150
	 SET_PTHREQ_RETVAL(tid, VG_(sig_alloc_rtsig)((Int)arg[1]));
3151
	 break;
3152
3113
      case VG_USERREQ__PRINTF: {
3153
      case VG_USERREQ__PRINTF: {
3114
         int count = 
3154
         int count = 
3115
            VG_(vmessage)( Vg_ClientMsg, (char *)arg[1], (va_list)arg[2] );
3155
            VG_(vmessage)( Vg_ClientMsg, (char *)arg[1], (va_list)arg[2] );
3116
            SET_CLREQ_RETVAL( tid, count );
3156
            SET_CLREQ_RETVAL( tid, count );
3117
         break; }
3157
         break; }
3118
3158
3159
3119
      case VG_USERREQ__INTERNAL_PRINTF: {
3160
      case VG_USERREQ__INTERNAL_PRINTF: {
3120
         int count = 
3161
         int count = 
3121
            VG_(vmessage)( Vg_UserMsg, (char *)arg[1], (va_list)arg[2] );
3162
            VG_(vmessage)( Vg_UserMsg, (char *)arg[1], (va_list)arg[2] );
Lines 3138-3143 Link Here
3138
            SET_CLREQ_RETVAL( tid, count );
3179
            SET_CLREQ_RETVAL( tid, count );
3139
         break; }
3180
         break; }
3140
3181
3182
      case VG_USERREQ__REGISTER_LIBC_FREERES:
3183
	 VG_(__libc_freeres_wrapper)	= arg[1];
3184
         SET_CLREQ_RETVAL( tid, 0 );     /* return value is meaningless */
3185
	 break;
3186
3187
      case VG_USERREQ__GET_MALLOCFUNCS: {
3188
	 struct vg_mallocfunc_info *info = (struct vg_mallocfunc_info *)arg[1];
3189
3190
	 info->sk_malloc	= (Addr)SK_(malloc);
3191
	 info->sk_calloc	= (Addr)SK_(calloc);
3192
	 info->sk_realloc	= (Addr)SK_(realloc);
3193
	 info->sk_memalign	= (Addr)SK_(memalign);
3194
	 info->sk___builtin_new	= (Addr)SK_(__builtin_new);
3195
	 info->sk___builtin_vec_new	= (Addr)SK_(__builtin_vec_new);
3196
	 info->sk_free		= (Addr)SK_(free);
3197
	 info->sk___builtin_delete	= (Addr)SK_(__builtin_delete);
3198
	 info->sk___builtin_vec_delete	= (Addr)SK_(__builtin_vec_delete);
3199
3200
	 info->arena_payload_szB	= (Addr)VG_(arena_payload_szB);
3201
	 
3202
	 info->clo_sloppy_malloc	= VG_(clo_sloppy_malloc);
3203
	 info->clo_trace_malloc		= VG_(clo_trace_malloc);
3204
3205
         SET_CLREQ_RETVAL( tid, 0 );     /* return value is meaningless */
3206
3207
	 break;
3208
      }
3209
3210
      case VG_USERREQ__REGISTER_REDIRECT_SYM: {
3211
	 VG_(add_redirect_sym)((const Char *)arg[1], (const Char *)arg[2],
3212
			       (const Char *)arg[3], (const Char *)arg[4]);
3213
	 break;
3214
      }
3215
3216
      case VG_USERREQ__REGISTER_REDIRECT_ADDR: {
3217
	 VG_(add_redirect_addr)((const Char *)arg[1], (const Char *)arg[2],
3218
				(Addr)arg[3]);
3219
	 break;
3220
      }
3221
3141
      /* Requests from the client program */
3222
      /* Requests from the client program */
3142
3223
3143
      case VG_USERREQ__DISCARD_TRANSLATIONS:
3224
      case VG_USERREQ__DISCARD_TRANSLATIONS:
Lines 3160-3166 Link Here
3160
	    UInt ret;
3241
	    UInt ret;
3161
3242
3162
            if (VG_(clo_verbosity) > 2)
3243
            if (VG_(clo_verbosity) > 2)
3163
               VG_(printf)("client request: code %d,  addr %p,  len %d\n",
3244
               VG_(printf)("client request: code %x,  addr %p,  len %d\n",
3164
                           arg[0], (void*)arg[1], arg[2] );
3245
                           arg[0], (void*)arg[1], arg[2] );
3165
3246
3166
	    if (SK_(handle_client_request) ( tid, arg, &ret ))
3247
	    if (SK_(handle_client_request) ( tid, arg, &ret ))
Lines 3169-3175 Link Here
3169
	    static Bool whined = False;
3250
	    static Bool whined = False;
3170
3251
3171
	    if (!whined) {
3252
	    if (!whined) {
3172
               // Allow for requests in core, but defined by skins, which
3253
               // Allow for requests in core, but defined by tools, which
3173
               // have 0 and 0 in their two high bytes.
3254
               // have 0 and 0 in their two high bytes.
3174
               Char c1 = (arg[0] >> 24) & 0xff;
3255
               Char c1 = (arg[0] >> 24) & 0xff;
3175
               Char c2 = (arg[0] >> 16) & 0xff;
3256
               Char c2 = (arg[0] >> 16) & 0xff;
(-)valgrind-2.1.0/coregrind/vg_signals.c (-31 / +113 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 984-996 Link Here
984
            "delivering signal %d (%s) to thread %d: on ALT STACK", 
984
            "delivering signal %d (%s) to thread %d: on ALT STACK", 
985
            sigNo, signame(sigNo), tid );
985
            sigNo, signame(sigNo), tid );
986
986
987
      /* Signal delivery to skins */
987
      /* Signal delivery to tools */
988
      VG_TRACK( pre_deliver_signal, tid, sigNo, /*alt_stack*/False );
988
      VG_TRACK( pre_deliver_signal, tid, sigNo, /*alt_stack*/False );
989
      
989
      
990
   } else {
990
   } else {
991
      esp_top_of_frame = tst->m_esp;
991
      esp_top_of_frame = tst->m_esp;
992
992
993
      /* Signal delivery to skins */
993
      /* Signal delivery to tools */
994
      VG_TRACK( pre_deliver_signal, tid, sigNo, /*alt_stack*/True );
994
      VG_TRACK( pre_deliver_signal, tid, sigNo, /*alt_stack*/True );
995
   }
995
   }
996
996
Lines 1010-1016 Link Here
1010
   /* retaddr, sigNo, psigInfo, puContext fields are to be written */
1010
   /* retaddr, sigNo, psigInfo, puContext fields are to be written */
1011
   VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal handler frame", 
1011
   VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal handler frame", 
1012
                            (Addr)frame, offsetof(VgSigFrame, handlerArgs) );
1012
                            (Addr)frame, offsetof(VgSigFrame, handlerArgs) );
1013
   frame->retaddr    = (UInt)(&VG_(signalreturn_bogusRA));
1013
   frame->retaddr    = (UInt)VG_(client_trampoline_code)+VG_(tramp_sigreturn_offset);
1014
   frame->sigNo      = sigNo;
1014
   frame->sigNo      = sigNo;
1015
   frame->sigNo_private = sigNo;
1015
   frame->sigNo_private = sigNo;
1016
   VG_TRACK( post_mem_write, (Addr)frame, offsetof(VgSigFrame, handlerArgs) );
1016
   VG_TRACK( post_mem_write, (Addr)frame, offsetof(VgSigFrame, handlerArgs) );
Lines 1170-1176 Link Here
1170
   tst->sig_mask  = frame->mask;
1170
   tst->sig_mask  = frame->mask;
1171
   VG_(proxy_setsigmask)(tid);
1171
   VG_(proxy_setsigmask)(tid);
1172
1172
1173
   /* Notify skins */
1173
   /* Notify tools */
1174
   VG_TRACK( post_deliver_signal, tid, sigNo );
1174
   VG_TRACK( post_deliver_signal, tid, sigNo );
1175
1175
1176
   return sigNo;
1176
   return sigNo;
Lines 1323-1328 Link Here
1323
1323
1324
   vg_assert(!core || (core && terminate));
1324
   vg_assert(!core || (core && terminate));
1325
1325
1326
   if (VG_(clo_trace_signals))
1327
      VG_(message)(Vg_DebugMsg, "delivering %d to default handler %s%s",
1328
		   sigNo, terminate ? "terminate" : "", core ? "+core" : "");
1329
1326
   if (terminate) {
1330
   if (terminate) {
1327
      if (VG_(clo_verbosity) != 0 && (core || VG_(clo_verbosity) > 1)) {
1331
      if (VG_(clo_verbosity) != 0 && (core || VG_(clo_verbosity) > 1)) {
1328
	 VG_(message)(Vg_UserMsg, "");
1332
	 VG_(message)(Vg_UserMsg, "");
Lines 1336-1343 Link Here
1336
	    switch(sigNo) {
1340
	    switch(sigNo) {
1337
	    case VKI_SIGSEGV:
1341
	    case VKI_SIGSEGV:
1338
	       switch(info->si_code) {
1342
	       switch(info->si_code) {
1339
	       case 1: event = "Address not mapped to object"; break;
1343
	       case 1: event = "Access not within mapped region"; break;
1340
	       case 2: event = "Invalid permissions for mapped object"; break;
1344
	       case 2: event = "Bad permissions for mapped region"; break;
1341
	       }
1345
	       }
1342
	       break;
1346
	       break;
1343
1347
Lines 1387-1395 Link Here
1387
	 }
1391
	 }
1388
      }
1392
      }
1389
1393
1390
      if (VG_(is_action_requested)( "Attach to GDB", & VG_(clo_GDB_attach) )) {
1394
      if (VG_(is_action_requested)( "Attach to debugger", & VG_(clo_db_attach) )) {
1391
         ThreadState* tst = & VG_(threads)[ tid ];      
1395
         VG_(start_debugger)( tid );
1392
	 VG_(swizzle_esp_then_start_GDB)( tst->m_eip, tst->m_esp, tst->m_ebp );
1393
      }
1396
      }
1394
1397
1395
      if (VG_(fatal_signal_set)) {
1398
      if (VG_(fatal_signal_set)) {
Lines 1409-1414 Link Here
1409
   Int			sigNo = info->si_signo;
1412
   Int			sigNo = info->si_signo;
1410
   vki_ksigset_t	handlermask;
1413
   vki_ksigset_t	handlermask;
1411
   SCSS_Per_Signal	*handler = &vg_scss.scss_per_sig[sigNo];
1414
   SCSS_Per_Signal	*handler = &vg_scss.scss_per_sig[sigNo];
1415
   void			*handler_fn;
1412
   ThreadState		*tst = VG_(get_ThreadState)(tid);
1416
   ThreadState		*tst = VG_(get_ThreadState)(tid);
1413
1417
1414
   if (VG_(clo_trace_signals))
1418
   if (VG_(clo_trace_signals))
Lines 1443-1474 Link Here
1443
	 came.  Either way, it is going to give us some syscall
1447
	 came.  Either way, it is going to give us some syscall
1444
	 results right now, so wait for them to appear.  This makes
1448
	 results right now, so wait for them to appear.  This makes
1445
	 the thread runnable again, so we're in the right state to run
1449
	 the thread runnable again, so we're in the right state to run
1446
	 the handler, and resume the syscall when we're done. */
1450
	 the handler.  We ask post_syscall to restart based on the
1447
      VG_(proxy_wait_sys)(tid);
1451
	 client's sigaction flags. */
1448
1449
      if (0)
1452
      if (0)
1450
	 VG_(printf)("signal %d interrupting syscall %d\n",
1453
	 VG_(printf)("signal %d interrupted syscall %d; restart=%d\n",
1451
		     sigNo, tst->syscallno);
1454
		     sigNo, tst->syscallno, !!(handler->scss_flags & VKI_SA_RESTART));
1452
1455
      VG_(proxy_wait_sys)(tid, !!(handler->scss_flags & VKI_SA_RESTART));
1453
      if (tst->m_eax == -VKI_ERESTARTSYS) {
1454
	  if (handler->scss_flags & VKI_SA_RESTART) {
1455
	     VG_(restart_syscall)(tid);
1456
	  } else
1457
	     tst->m_eax = -VKI_EINTR;
1458
      } else {
1459
	 /* return value is already in eax - either EINTR or the
1460
	    normal return value */
1461
      }
1462
   }
1456
   }
1463
1457
1464
   vg_assert(handler->scss_handler != VKI_SIG_IGN);
1458
   /* If the client specifies SIG_IGN, treat it as SIG_DFL */
1459
   handler_fn = handler->scss_handler;
1460
   if (handler_fn == VKI_SIG_IGN)
1461
      handler_fn = VKI_SIG_DFL;
1462
1463
   vg_assert(handler_fn != VKI_SIG_IGN);
1465
1464
1466
   if (sigNo == VKI_SIGCHLD && (handler->scss_flags & VKI_SA_NOCLDWAIT)) {
1465
   if (sigNo == VKI_SIGCHLD && (handler->scss_flags & VKI_SA_NOCLDWAIT)) {
1467
      //VG_(printf)("sigNo==SIGCHLD and app asked for NOCLDWAIT\n");
1466
      //VG_(printf)("sigNo==SIGCHLD and app asked for NOCLDWAIT\n");
1468
      vg_babyeater(sigNo, NULL, NULL);
1467
      vg_babyeater(sigNo, NULL, NULL);
1469
   }
1468
   }
1470
1469
1471
   if (handler->scss_handler == VKI_SIG_DFL) {
1470
   if (handler_fn == VKI_SIG_DFL) {
1472
      handlermask = tst->sig_mask; /* no change to signal mask */
1471
      handlermask = tst->sig_mask; /* no change to signal mask */
1473
      vg_default_action(info, tid);
1472
      vg_default_action(info, tid);
1474
   } else {
1473
   } else {
Lines 1604-1611 Link Here
1604
   */
1603
   */
1605
1604
1606
   if (VG_(clo_trace_signals)) {
1605
   if (VG_(clo_trace_signals)) {
1607
      VG_(start_msg)(Vg_DebugMsg);
1606
      VG_(message)(Vg_DebugMsg, "signal %d arrived ... si_code=%d", sigNo, info->si_code );
1608
      VG_(add_to_msg)("signal %d arrived ... ", sigNo );
1609
   }
1607
   }
1610
   vg_assert(sigNo >= 1 && sigNo <= VKI_KNSIG);
1608
   vg_assert(sigNo >= 1 && sigNo <= VKI_KNSIG);
1611
1609
Lines 1631-1636 Link Here
1631
   vg_assert((Char*)(&(VG_(sigstack)[0])) <= (Char*)(&dummy_local));
1629
   vg_assert((Char*)(&(VG_(sigstack)[0])) <= (Char*)(&dummy_local));
1632
   vg_assert((Char*)(&dummy_local) < (Char*)(&(VG_(sigstack)[VG_SIGSTACK_SIZE_W])));
1630
   vg_assert((Char*)(&dummy_local) < (Char*)(&(VG_(sigstack)[VG_SIGSTACK_SIZE_W])));
1633
1631
1632
   /* Special fault-handling case. We can now get signals which can
1633
      act upon and immediately restart the faulting instruction.
1634
    */
1635
   if (info->si_signo == VKI_SIGSEGV) {
1636
      ThreadId tid = VG_(get_current_or_recent_tid)();
1637
      Addr fault = (Addr)info->_sifields._sigfault._addr;
1638
      Addr esp = VG_(is_running_thread)(tid) ?
1639
	 VG_(baseBlock)[VGOFF_(m_esp)] : VG_(threads)[tid].m_esp;
1640
      Segment *seg;
1641
1642
      seg = VG_(find_segment)(fault);
1643
      if (seg != NULL)
1644
	 seg = VG_(next_segment)(seg);
1645
1646
      if (VG_(clo_trace_signals)) {
1647
	 if (seg == NULL)
1648
	    VG_(message)(Vg_DebugMsg,
1649
			 "SIGSEGV: si_code=%d faultaddr=%p tid=%d esp=%p seg=NULL shad=%p-%p",
1650
			 info->si_code, fault, tid, esp,
1651
			 VG_(shadow_base), VG_(shadow_end));
1652
	 else
1653
	    VG_(message)(Vg_DebugMsg,
1654
			 "SIGSEGV: si_code=%d faultaddr=%p tid=%d esp=%p seg=%p-%p fl=%x shad=%p-%p",
1655
			 info->si_code, fault, tid, esp, seg->addr, seg->addr+seg->len, seg->flags,
1656
			 VG_(shadow_base), VG_(shadow_end));
1657
      }
1658
1659
      if (info->si_code == 1		&&	/* SEGV_MAPERR */
1660
	  seg != NULL                   &&
1661
	  fault >= esp			&&
1662
	  fault < seg->addr		&&
1663
	  (seg->flags & SF_GROWDOWN)) {
1664
	 /* If the fault address is above esp but below the current known
1665
	    stack segment base, and it was a fault because there was
1666
	    nothing mapped there (as opposed to a permissions fault),
1667
	    then extend the stack segment. 
1668
	 */
1669
	 Addr base = PGROUNDDN(esp);
1670
	 Char *ret = VG_(mmap)((Char *)base, seg->addr - base, 
1671
			       VKI_PROT_READ | VKI_PROT_WRITE | VKI_PROT_EXEC,
1672
			       VKI_MAP_PRIVATE | VKI_MAP_FIXED | VKI_MAP_ANONYMOUS | VKI_MAP_CLIENT,
1673
			       -1, 0);
1674
	 if ((Addr)ret == base) {
1675
	    VG_(map_segment)(base, seg->addr - base,
1676
			     VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC,
1677
			     SF_STACK|SF_GROWDOWN);
1678
	    return;		/* restart instruction */
1679
	 }
1680
	 /* Otherwise fall into normal signal handling */
1681
      } else if (info->si_code == 2 && /* SEGV_ACCERR */
1682
		 VG_(needs).shadow_memory &&
1683
		 VG_(is_shadow_addr)(fault)) {
1684
	 /* If there's a fault within the shadow memory range, and it
1685
	    is a permissions fault, then it means that the client is
1686
	    using some memory which had not previously been used.
1687
	    This catches those faults, makes the memory accessible,
1688
	    and calls the tool to initialize that page.
1689
	 */
1690
	 static Int recursion = 0;
1691
1692
	 if (recursion++ == 0) {
1693
	    VG_(init_shadow_range)(PGROUNDDN(fault), VKI_BYTES_PER_PAGE, True);
1694
	    recursion--;
1695
	    return;
1696
	 } else {
1697
	    /* otherwise fall into normal SEGV handling */	    
1698
	    recursion--;
1699
	 }
1700
      }
1701
   }
1702
1634
   if (VG_(scheduler_jmpbuf_valid)) {
1703
   if (VG_(scheduler_jmpbuf_valid)) {
1635
      /* Can't continue; must longjmp back to the scheduler and thus
1704
      /* Can't continue; must longjmp back to the scheduler and thus
1636
         enter the sighandler immediately. */
1705
         enter the sighandler immediately. */
Lines 1661-1673 Link Here
1661
	 it was actually generated by Valgrind internally.
1730
	 it was actually generated by Valgrind internally.
1662
       */
1731
       */
1663
      struct vki_sigcontext *sc = &uc->uc_mcontext;
1732
      struct vki_sigcontext *sc = &uc->uc_mcontext;
1733
      Char buf[1024];
1664
1734
1665
      VG_(message)(Vg_DebugMsg, 
1735
      VG_(message)(Vg_DebugMsg, 
1666
		   "INTERNAL ERROR: Valgrind received a signal %d (%s) - exiting",
1736
		   "INTERNAL ERROR: Valgrind received a signal %d (%s) - exiting",
1667
		   sigNo, signame(sigNo));
1737
		   sigNo, signame(sigNo));
1738
1739
      buf[0] = 0;
1740
      if (1 && !VG_(get_fnname)(sc->eip, buf+2, sizeof(buf)-5)) {
1741
	 Int len;
1742
1743
	 buf[0] = ' ';
1744
	 buf[1] = '(';
1745
	 len = VG_(strlen)(buf);
1746
	 buf[len] = ')';
1747
	 buf[len+1] = '\0';
1748
      }
1749
1668
      VG_(message)(Vg_DebugMsg, 
1750
      VG_(message)(Vg_DebugMsg, 
1669
		   "si_code=%x Fault EIP: %p; Faulting address: %p",
1751
		   "si_code=%x Fault EIP: %p%s; Faulting address: %p",
1670
		   info->si_code, sc->eip, info->_sifields._sigfault._addr);
1752
		   info->si_code, sc->eip, buf, info->_sifields._sigfault._addr);
1671
1753
1672
      if (0)
1754
      if (0)
1673
	 VG_(kill_self)(sigNo);		/* generate a core dump */
1755
	 VG_(kill_self)(sigNo);		/* generate a core dump */
(-)valgrind-2.1.0/coregrind/vg_skiplist.c (+343 lines)
Line 0 Link Here
1
2
/*
3
   This file is part of Valgrind, an extensible x86 protected-mode
4
   emulator for monitoring program execution on x86-Unixes.
5
6
   Copyright (C) 2002-2004 Nicholas Nethercote
7
      njn25@cam.ac.uk
8
9
   This program is free software; you can redistribute it and/or
10
   modify it under the terms of the GNU General Public License as
11
   published by the Free Software Foundation; either version 2 of the
12
   License, or (at your option) any later version.
13
14
   This program is distributed in the hope that it will be useful, but
15
   WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
   General Public License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program; if not, write to the Free Software
21
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
   02111-1307, USA.
23
24
   The GNU General Public License is contained in the file COPYING.
25
*/
26
27
#include "vg_include.h"
28
29
#include <stdlib.h>
30
31
#define SKIPLIST_DEBUG	0
32
33
#define SK_MAXHEIGHT	20	/* 2^20 elements */
34
#define SKIPLIST_MAGIC		0x5b1ff872
35
#define SKIPLIST_HEAD_MAGIC	(~SKIPLIST_MAGIC)
36
37
38
#if SKIPLIST_DEBUG
39
#define inline
40
#endif /* SKIPLIST_DEBUG */
41
42
struct _SkipNode {
43
   UInt		magic;
44
   UShort	level;		/* level is the max level (level == 0 means 1 next pointer) */
45
   SkipNode	*next[0];
46
};
47
48
49
50
static inline Int get_height(void)
51
{
52
   UInt ret = 0;
53
54
   while((ret < SK_MAXHEIGHT) && (random() & 1))
55
      ret++;
56
57
   return ret;
58
}
59
60
static inline void *key_of_data(const SkipList *l, void *d)
61
{
62
   return (void *)((Char *)d + l->keyoff);
63
}
64
65
static inline SkipNode *node_of_data(const SkipList *l, const void *d)
66
{
67
   SkipNode *n = (SkipNode *)((Char *)d + l->size);
68
69
   if (SKIPLIST_DEBUG && n->magic != SKIPLIST_MAGIC)
70
      VG_(printf)("bad magic on node %p = %x (not %x)\n",
71
		  n, n->magic, SKIPLIST_MAGIC);
72
73
   vg_assert(n->magic == SKIPLIST_MAGIC);
74
75
   return n; 
76
}
77
78
static inline void *data_of_node(const SkipList *l, const SkipNode *n)
79
{
80
   if (SKIPLIST_DEBUG && n->magic != SKIPLIST_MAGIC)
81
      VG_(printf)("bad magic on node %p = %x (not %x)\n",
82
		  n, n->magic, SKIPLIST_MAGIC);
83
84
   vg_assert(n->magic == SKIPLIST_MAGIC);
85
   return (void *)((Char *)n - l->size);
86
}
87
88
static inline void *key_of_node(const SkipList *l, const SkipNode *n)
89
{
90
   return key_of_data(l, data_of_node(l, n));
91
}
92
93
static inline void validate_skiplist(const SkipList *l, const Char *where)
94
{
95
#if SKIPLIST_DEBUG
96
   const SkipNode *prev[SK_MAXHEIGHT];
97
   Int i;
98
   const SkipNode *n, *next;
99
   
100
   VG_(printf)("---------------- %s ----------------\n", where);
101
102
   if (l->head == NULL)
103
      return;
104
105
   for(i = 0; i <= l->head->level; i++) {
106
      VG_(printf)("l->head->next[%d]=%p\n",
107
		  i, l->head->next[i]);
108
      prev[i] = l->head->next[i];
109
   }
110
111
   for(n = l->head->next[0]; n != NULL; n = next) {
112
      next = n->next[0];
113
114
      VG_(printf)("n=%p next=%p, n->level=%d k=%s\n",
115
		  n, next, n->level, (*l->strkey)(key_of_node(l, n)));
116
      for(i = 0; i <= n->level; i++) {
117
	 VG_(printf)("  n->next[%d] = %p\n",
118
		     i, n->next[i]);
119
	 VG_(printf)("  prev[%d] = %p\n",
120
		     i, prev[i]);
121
      }
122
      
123
      vg_assert(l->head->level >= n->level);
124
125
      for(i = 0; i <= n->level; i++)
126
	 vg_assert(prev[i] == n);
127
128
      for(i = 0; i <= n->level; i++)
129
	 prev[i] = n->next[i];
130
131
      vg_assert(next == NULL || (l->cmp)(key_of_node(l, n), key_of_node(l, next)) < 0);
132
   }
133
#endif	/* SKIPLIST_DEBUG */
134
}
135
136
void *VG_(SkipNode_Alloc)(const SkipList *l)
137
{
138
   UInt size = l->size;
139
   Int h = get_height();
140
   SkipNode *n;
141
   Char *ret;
142
143
   size += sizeof(SkipNode) + (h+1)*sizeof(SkipNode *);
144
145
   if (l->arena == -1)
146
      *(Short *)&l->arena = VG_AR_TOOL;
147
148
   ret = VG_(arena_malloc)(l->arena, size);
149
150
   if (ret == NULL)
151
      return NULL;
152
153
   n = (SkipNode *)(ret + l->size);
154
   n->level = h;
155
   n->magic = SKIPLIST_MAGIC;
156
157
   while(h-- >= 0)
158
      n->next[h] = NULL;
159
160
   return ret;
161
}
162
163
void VG_(SkipNode_Free)(const SkipList *l, void *p)
164
{
165
   if (SKIPLIST_DEBUG) {
166
      SkipNode *n = node_of_data(l, p);
167
168
      VG_(printf)("SkipNode_Free: freeing %p (node %p)\n",
169
		  p, n);
170
      n->magic = 0x55ffaabb;
171
   }
172
   VG_(arena_free)(l->arena, p);
173
}
174
175
void *VG_(SkipNode_First)(const SkipList *l)
176
{
177
   SkipNode *n = l->head ? l->head->next[0] : NULL;
178
179
   if (n == NULL)
180
      return NULL;
181
   else
182
      return data_of_node(l, n);
183
}
184
185
void *VG_(SkipNode_Next)(const SkipList *l, void *data)
186
{
187
   SkipNode *n = node_of_data(l, data);
188
   
189
   n = n->next[0];
190
191
   if (n == NULL)
192
      return NULL;
193
194
   return data_of_node(l, n);
195
}
196
197
198
199
static Int cmp(const SkipList *l, SkipNode *n, void *k2)
200
{
201
   void *k1 = key_of_node(l, n);
202
203
   if (k1 == k2)
204
      return 0;
205
206
   if (l->head == n)
207
      return -1;
208
209
   return (l->cmp)(k1, k2);
210
}
211
212
/* Search the list for k; it either returns the k if it exists, or the
213
   one before if not.  */
214
static SkipNode *SkipList__Find(const SkipList *l, void *k, SkipNode **prevs)
215
{
216
   SkipNode *n;
217
   Int lvl;
218
219
   if (SKIPLIST_DEBUG)
220
      VG_(printf)("SkipList__Find: finding %s\n", (*l->strkey)(k));
221
222
   validate_skiplist(l, "SkipList__Find");
223
224
   if (l->head == NULL)
225
      return NULL;
226
227
   for(lvl = l->head->level, n = l->head; lvl >= 0; lvl--) {
228
      while(n->next[lvl] != NULL && cmp(l, n->next[lvl], k) < 0) {
229
	 if (SKIPLIST_DEBUG)
230
	    VG_(printf)("SkipList__Find: n=%p n->next[%d]=%p\n",
231
			n, lvl, n->next[lvl]);
232
	 n = n->next[lvl];
233
      }
234
      if (prevs)
235
	 prevs[lvl] = n;
236
   }
237
238
   /* XXX Is there a cleaner way of getting this? 
239
      
240
      If we get an exact match, return it.
241
      If we get the head, return NULL.
242
      Otherwise return the one before where the hit would be.
243
    */
244
   if (n->next[0] != NULL && cmp(l, n->next[0], k) == 0)
245
      n =  n->next[0];
246
   if (n == l->head)
247
      n = NULL;
248
249
   if (SKIPLIST_DEBUG) {
250
251
      VG_(printf)("SkipList__Find returning node %p\n", n);
252
253
      if (n == NULL) {
254
	 SkipNode *nn;
255
256
	 for(nn = l->head->next[0]; nn != NULL; nn = nn->next[0])
257
	    vg_assert(cmp(l, nn, k) != 0);
258
      } else
259
	 vg_assert(cmp(l, n, k) <= 0);
260
   }
261
262
   return n;
263
}
264
265
void *VG_(SkipList_Find)(const SkipList *l, void *k)
266
{
267
   SkipNode *n = SkipList__Find(l, k, NULL);
268
269
   if (n != NULL)
270
      return data_of_node(l, n);
271
   return NULL;
272
}
273
274
void VG_(SkipList_Insert)(SkipList *l, void *data)
275
{
276
   SkipNode *update[SK_MAXHEIGHT];
277
   SkipNode *n;
278
   void *k = key_of_data(l, data);
279
   Int i;
280
281
   if (SKIPLIST_DEBUG)
282
      VG_(printf)("inserting node %p, key %s, height %d\n",
283
		  data, (*l->strkey)(key_of_data(l, data)), node_of_data(l, data)->level);
284
285
   validate_skiplist(l, "SkipList_Insert before");
286
287
   if (l->head == NULL) {
288
      Int size = sizeof(SkipNode) * sizeof(SkipNode *) * SK_MAXHEIGHT;
289
290
      if (l->arena == -1)
291
	 *(Short *)&l->arena = VG_AR_TOOL;
292
      
293
      l->head = VG_(arena_malloc)(l->arena, size);
294
      VG_(memset)(l->head, 0, size);
295
296
      l->head->magic = SKIPLIST_HEAD_MAGIC;
297
      l->head->level = 0;
298
   }
299
300
   n = SkipList__Find(l, k, update);
301
   
302
   vg_assert(n == NULL || (l->cmp)(key_of_node(l, n), k) != 0);
303
304
   n = node_of_data(l, data);
305
306
   vg_assert(l->head != NULL);
307
   if (l->head->level < n->level) {
308
      for(i = l->head->level+1; i <= n->level; i++)
309
	 l->head->next[i] = n;
310
      l->head->level = n->level;
311
   }
312
313
   for(i = 0; i <= n->level; i++) {
314
      n->next[i] = update[i]->next[i];
315
      update[i]->next[i] = n;
316
   }
317
318
   validate_skiplist(l, "SkipList_Insert after");
319
}
320
321
void *VG_(SkipList_Remove)(SkipList *l, void *k)
322
{
323
   SkipNode *update[SK_MAXHEIGHT];
324
   SkipNode *n;
325
   Int i;
326
   
327
   validate_skiplist(l, "SkipList_Remove before");
328
329
   n = SkipList__Find(l, k, update);
330
   if (n == NULL)
331
      return NULL;
332
333
   vg_assert((l->cmp)(k, key_of_node(l, n)) == 0);
334
335
   for(i = 0; i <= n->level; i++) {
336
      update[i]->next[i] = n->next[i];
337
      n->next[i] = NULL;
338
   }
339
340
   validate_skiplist(l, "SkipList_Remove after");
341
342
   return data_of_node(l, n);
343
}
(-)valgrind-2.1.0/coregrind/vg_stabs.c (-7 / +14 lines)
Lines 6-12 Link Here
6
   This file is part of Valgrind, an extensible x86 protected-mode
6
   This file is part of Valgrind, an extensible x86 protected-mode
7
   emulator for monitoring program execution on x86-Unixes.
7
   emulator for monitoring program execution on x86-Unixes.
8
8
9
   Copyright (C) 2000-2003 Julian Seward
9
   Copyright (C) 2000-2004 Julian Seward
10
      jseward@acm.org
10
      jseward@acm.org
11
11
12
   This program is free software; you can redistribute it and/or
12
   This program is free software; you can redistribute it and/or
Lines 300-306 Link Here
300
   return &sf->types[sym];
300
   return &sf->types[sym];
301
}
301
}
302
302
303
static inline Bool isdigit(Char c, Int base, Int *v)
303
static Bool isdigit(Char c, Int base, Int *v)
304
{
304
{
305
   switch(base) {
305
   switch(base) {
306
   case 10:
306
   case 10:
Lines 650-655 Link Here
650
      break;
650
      break;
651
   }
651
   }
652
652
653
   case 'k':                    /* const */
654
   case 'B': {                  /* volatile */
655
      /* 'k' TYPE */
656
      type = stabtype_parser(si, NULL, &p);
657
      break;
658
   }
659
653
   case 'x': {			/* reference to undefined type */
660
   case 'x': {			/* reference to undefined type */
654
      /* 'x' ('s' | 'u' | 'e') NAME ':' */
661
      /* 'x' ('s' | 'u' | 'e') NAME ':' */
655
      Int brac = 0;		/* < > brackets in type */
662
      Int brac = 0;		/* < > brackets in type */
Lines 1005-1016 Link Here
1005
   case N_STSYM:
1012
   case N_STSYM:
1006
   case N_LCSYM:
1013
   case N_LCSYM:
1007
      sym->kind = SyStatic;
1014
      sym->kind = SyStatic;
1008
      sym->addr = si->offset + (Addr)val;
1015
      sym->u.addr = si->offset + (Addr)val;
1009
      break;
1016
      break;
1010
1017
1011
   case N_PSYM:
1018
   case N_PSYM:
1012
      sym->kind = SyEBPrel;	/* +ve offset off EBP (erk, or ESP if no frame pointer) */
1019
      sym->kind = SyEBPrel;	/* +ve offset off EBP (erk, or ESP if no frame pointer) */
1013
      sym->offset = val;
1020
      sym->u.offset = val;
1014
      break;
1021
      break;
1015
1022
1016
   case N_LSYM:
1023
   case N_LSYM:
Lines 1018-1034 Link Here
1018
	 sym->kind = SyEBPrel;	/* -ve off EBP when there's a frame pointer */
1025
	 sym->kind = SyEBPrel;	/* -ve off EBP when there's a frame pointer */
1019
      else
1026
      else
1020
	 sym->kind = SyESPrel;	/* +ve off ESP when there's no frame pointer */
1027
	 sym->kind = SyESPrel;	/* +ve off ESP when there's no frame pointer */
1021
      sym->offset = val;
1028
      sym->u.offset = val;
1022
      break;
1029
      break;
1023
1030
1024
   case N_RSYM:
1031
   case N_RSYM:
1025
      sym->kind = SyReg;
1032
      sym->kind = SyReg;
1026
      sym->regno = val;
1033
      sym->u.regno = val;
1027
      break;
1034
      break;
1028
1035
1029
   case N_GSYM:
1036
   case N_GSYM:
1030
      sym->kind = SyGlobal;
1037
      sym->kind = SyGlobal;
1031
      sym->addr = 0;		/* XXX should really look up global address */
1038
      sym->u.addr = 0;		/* XXX should really look up global address */
1032
      break;
1039
      break;
1033
1040
1034
   default:
1041
   default:
(-)valgrind-2.1.0/coregrind/vg_startup.S (-297 lines)
Lines 1-297 Link Here
1
2
##--------------------------------------------------------------------##
3
##--- Startup and shutdown code for Valgrind.                      ---##
4
##---                                                 vg_startup.S ---##
5
##--------------------------------------------------------------------##
6
7
/*
8
  This file is part of Valgrind, an extensible x86 protected-mode
9
  emulator for monitoring program execution on x86-Unixes.
10
11
  Copyright (C) 2000-2003 Julian Seward 
12
     jseward@acm.org
13
14
  This program is free software; you can redistribute it and/or
15
  modify it under the terms of the GNU General Public License as
16
  published by the Free Software Foundation; either version 2 of the
17
  License, or (at your option) any later version.
18
19
  This program is distributed in the hope that it will be useful, but
20
  WITHOUT ANY WARRANTY; without even the implied warranty of
21
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22
  General Public License for more details.
23
24
  You should have received a copy of the GNU General Public License
25
  along with this program; if not, write to the Free Software
26
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27
  02111-1307, USA.
28
29
  The GNU General Public License is contained in the file COPYING.
30
*/
31
32
#include "vg_constants.h"
33
#include "config.h"
34
35
36
#---------------------------------------------------------------------
37
#
38
# Startup and shutdown code for Valgrind.  Particularly hairy.
39
#
40
# The dynamic linker, ld.so, will run the contents of the .init
41
# section, once it has located, mmap-d and and linked the shared
42
# libraries needed by the program.  Valgrind is itself a shared
43
# library.  ld.so then runs code in the .init sections of each
44
# library in turn, in order to give them a chance to initialise
45
# themselves.  We hijack this mechanism.  Our startup routine
46
# does return -- and execution continues -- except on the
47
# synthetic CPU, not the real one.  But ld.so, and the program
48
# it is starting, cant tell the difference.
49
#
50
# The management apologise for the lack of apostrophes in these
51
# comments.  GNU as seems to object to them, for some reason.
52
53
54
.section .init
55
	call VG_(startup)
56
.section .fini
57
	call VG_(shutdown)
58
59
.section .data
60
valgrind_already_initted:
61
	.word	0
62
	
63
.section .text
64
	
65
66
.global VG_(startup)
67
VG_(startup):
68
	pushfl
69
	cmpl	$0, valgrind_already_initted
70
	je	really_start_up
71
	popfl
72
	ret
73
74
really_start_up:
75
	popfl
76
	movl	$1, valgrind_already_initted
77
	
78
        # Record %esp as it was when we got here.  This is because argv/c
79
	# and envp[] are passed as args to this function, and we need to see
80
	# envp so we can get at the env var VG_ARGS without help from libc.
81
	# The stack layout at this point depends on the version of glibc in
82
	# use.  See process_cmd_line_options() in vg_main.c for details.
83
        movl    %esp, VG_(esp_at_startup)
84
        
85
	# We have control!  Save the state of the machine in
86
	# the simulators state, and switch stacks.
87
	# Except ... we cant copy the machines registers into their
88
	# final places in vg_baseBlock, because the offsets to them
89
	# have not yet been set up.  Instead, they are copied to a
90
	# temporary place (m_state_static).  In vg_main.c, once the
91
	# baseBlock offsets are set up, values are copied into baseBlock.
92
	movw	%cs, VG_(m_state_static)+0
93
	movw	%ss, VG_(m_state_static)+4
94
	movw	%ds, VG_(m_state_static)+8
95
	movw	%es, VG_(m_state_static)+12
96
	movw	%fs, VG_(m_state_static)+16
97
	movw	%gs, VG_(m_state_static)+20
98
	movl	%eax, VG_(m_state_static)+24
99
	movl	%ecx, VG_(m_state_static)+28
100
	movl	%edx, VG_(m_state_static)+32
101
	movl	%ebx, VG_(m_state_static)+36
102
	movl	%esp, VG_(m_state_static)+40
103
	movl	%ebp, VG_(m_state_static)+44
104
	movl	%esi, VG_(m_state_static)+48
105
	movl	%edi, VG_(m_state_static)+52
106
	pushfl
107
	popl	%eax
108
	movl	%eax, VG_(m_state_static)+56
109
110
	# now weve captured all the integer registers and
111
	# flags, figure out whether this is an sse-enabled
112
	# cpu or not.
113
	movb	$0, VG_(have_ssestate)	# assume sse-disabled
114
	movl	$0, %eax
115
	cpuid
116
	cmpl	$1, %eax
117
	jl	get_fpu		# we cant do cpuid(1) ?!
118
	movl	$1, %eax
119
	cpuid
120
	testl	$(1<<25), %edx
121
	jz	get_fpu		# edx bit 25 is set iff sse
122
	# well, it looks like were sse-enabled
123
	movb	$1, VG_(have_ssestate)
124
125
	# next, capture the FPU/SSE state
126
get_fpu:
127
	fwait
128
129
	pushfl
130
	cmpb	$0, VG_(have_ssestate)
131
	jz	qq3nosse
132
	fxsave	VG_(m_state_static)+64
133
	andl	$0x0000FFBF, VG_(m_state_static)+64+24
134
	fxrstor	VG_(m_state_static)+64
135
	jmp	qq3merge
136
qq3nosse:
137
	fnsave	VG_(m_state_static)+64
138
	frstor	VG_(m_state_static)+64
139
qq3merge:
140
	popfl
141
142
	# keep the first and last 10 words free to check for overruns	
143
	movl	$VG_(stack)+39996 -40, %esp
144
145
	# Now some real magic.  We need this procedure to return,
146
	# since thats what ld.so expects, but running on the
147
	# simulator.  So vg_main starts the simulator running at
148
	# the insn labelled first_insn_to_simulate.
149
150
	movl	$first_insn_to_simulate, VG_(m_state_static)+60
151
	jmp	VG_(main)
152
first_insn_to_simulate:
153
	# Nothing else to do -- just return in the "normal" way.
154
	ret
155
156
157
158
VG_(shutdown):
159
	# Just return, and ignore any attempt by ld.so to call
160
	# valgrind.sos exit function.  We just run the client all
161
	# the way to the final exit() syscall.  This sidesteps
162
	# problems caused by ld.so calling the finalisation code
163
	# of other .sos *after* it shuts down valgrind, which
164
	# was causing big problems with threads.
165
	ret
166
167
	
168
	
169
.global	VG_(switch_to_real_CPU)
170
VG_(switch_to_real_CPU):
171
	# Once Valgrind has decided it needs to exit,
172
	# because the specified number of insns have been completed
173
	# during a debugging run, it jumps here, which copies the
174
	# simulators state into the real machine state.  Execution
175
	# of the rest of the program continues on the real CPU,
176
	# and there is no way for the simulator to regain control
177
	# after this point.
178
179
	pushfl
180
	cmpb	$0, VG_(have_ssestate)
181
	jz	qq4nosse
182
	andl	$0x0000FFBF, VG_(m_state_static)+64+24
183
	fxrstor	VG_(m_state_static)+64
184
	jmp	qq4merge
185
qq4nosse:
186
	frstor	VG_(m_state_static)+64
187
qq4merge:
188
	popfl
189
	
190
	movl	VG_(m_state_static)+56, %eax
191
	pushl	%eax
192
	popfl
193
	/* some of these are apparently illegal */
194
	/* movw	VG_(m_state_static)+0, %cs */
195
	movw	VG_(m_state_static)+4, %ss
196
	movw	VG_(m_state_static)+8, %ds
197
	movw	VG_(m_state_static)+12, %es
198
	movw	VG_(m_state_static)+16, %fs
199
	movw	VG_(m_state_static)+20, %gs
200
	movl	VG_(m_state_static)+24, %eax
201
	movl	VG_(m_state_static)+28, %ecx
202
	movl	VG_(m_state_static)+32, %edx
203
	movl	VG_(m_state_static)+36, %ebx
204
	movl	VG_(m_state_static)+40, %esp
205
	movl	VG_(m_state_static)+44, %ebp
206
	movl	VG_(m_state_static)+48, %esi
207
	movl	VG_(m_state_static)+52, %edi
208
209
	jmp	*VG_(m_state_static)+60
210
211
212
213
/*------------------------------------------------------------*/
214
/*--- A function to temporarily copy %ESP/%EBP into        ---*/
215
/*--- %esp/%ebp and then start up GDB.                     ---*/
216
/*------------------------------------------------------------*/
217
218
/*
219
extern void VG_(swizzle_esp_then_start_GDB) ( Addr m_eip_at_error,
220
                                              Addr m_esp_at_error,
221
                                              Addr m_ebp_at_error );
222
*/
223
224
/*--- This is clearly not re-entrant! ---*/
225
.data
226
vg_ebp_saved_over_GDB_start:
227
	.long	0
228
vg_esp_saved_over_GDB_start:
229
	.long	0
230
.text
231
	
232
.type VG_(swizzle_esp_then_start_GDB),@function
233
.global VG_(swizzle_esp_then_start_GDB)	
234
VG_(swizzle_esp_then_start_GDB):
235
#ifdef HAVE_GAS_CFI
236
	.cfi_startproc
237
#endif
238
	pushal
239
240
	# remember the simulators current stack/frame pointers
241
	movl	%ebp, vg_ebp_saved_over_GDB_start
242
	movl	%esp, vg_esp_saved_over_GDB_start
243
244
	# get args into regs
245
	movl	44(%esp), %eax		# client %EBP
246
	movl	40(%esp), %ebx		# client %ESP
247
	movl	36(%esp), %ecx		# client %EIP
248
249
	# Now that we dont need to refer to simulators stack any more,
250
	# put %ESP into %esp
251
	movl	%ebx, %esp
252
253
	### %esp now refers to clients stack
254
	### mess with the clients stack to make it look as if it
255
	### called this procedure, since otherwise it will look to gdb
256
	### as if the top (currently executing) stack frame of the
257
	### client is missing.
258
	
259
	# push %EIP.  This is a faked-up return address.
260
	pushl	%ecx
261
262
	# push %EBP.  This is a faked %ebp-chain pointer.
263
	pushl	%eax
264
#ifdef HAVE_GAS_CFI
265
	.cfi_adjust_cfa_offset 0x4
266
#endif
267
268
	movl	%esp, %ebp
269
#ifdef HAVE_GAS_CFI
270
	.cfi_def_cfa_register ebp
271
#endif
272
	
273
	call	VG_(start_GDB_whilst_on_client_stack)
274
275
	# restore the simulators stack/frame pointer
276
	movl	vg_ebp_saved_over_GDB_start, %ebp
277
	movl	vg_esp_saved_over_GDB_start, %esp
278
#ifdef HAVE_GAS_CFI
279
	.cfi_adjust_cfa_offset -0x4
280
#endif
281
	
282
	popal
283
	ret
284
#ifdef HAVE_GAS_CFI
285
	.cfi_endproc
286
#endif
287
288
# gcc puts this construction at the end of every function.  I think it
289
# allows the linker to figure out the size of the function.  So we do
290
# the same, in the vague hope that it might help GDBs navigation.
291
.Lend_of_swizzle:
292
	.size	VG_(swizzle_esp_then_start_GDB), .Lend_of_swizzle-VG_(swizzle_esp_then_start_GDB)
293
294
295
##--------------------------------------------------------------------##
296
##--- end                                             vg_startup.S ---##
297
##--------------------------------------------------------------------##
(-)valgrind-2.1.0/coregrind/vg_symtab2.c (-168 / +486 lines)
Lines 7-13 Link Here
7
   This file is part of Valgrind, an extensible x86 protected-mode
7
   This file is part of Valgrind, an extensible x86 protected-mode
8
   emulator for monitoring program execution on x86-Unixes.
8
   emulator for monitoring program execution on x86-Unixes.
9
9
10
   Copyright (C) 2000-2003 Julian Seward 
10
   Copyright (C) 2000-2004 Julian Seward 
11
      jseward@acm.org
11
      jseward@acm.org
12
12
13
   This program is free software; you can redistribute it and/or
13
   This program is free software; you can redistribute it and/or
Lines 301-308 Link Here
301
   Int size = next - this;
301
   Int size = next - this;
302
   ScopeRange range;
302
   ScopeRange range;
303
303
304
   /* Ignore zero-sized scopes */
304
   /* Ignore zero-sized or negative scopes */
305
   if (this == next) {
305
   if (size <= 0) {
306
      if (debug)
306
      if (debug)
307
	 VG_(printf)("ignoring zero-sized range, scope %p at %p\n", scope, this);
307
	 VG_(printf)("ignoring zero-sized range, scope %p at %p\n", scope, this);
308
      return;
308
      return;
Lines 398-403 Link Here
398
   return a->addr - b->addr;
398
   return a->addr - b->addr;
399
}
399
}
400
400
401
/* Two symbols have the same address.  Which name do we prefer?
402
403
   In general we prefer the longer name, but if the choice is between
404
   __libc_X and X, then choose X (similarly with __GI__ and __
405
   prefixes).
406
 */
407
static RiSym *prefersym(RiSym *a, RiSym *b)
408
{
409
   Int pfx;
410
   Int lena, lenb;
411
   Int i;
412
   static const struct {
413
      const Char *prefix;
414
      Int len;
415
   } prefixes[] = {
416
#define PFX(x)	{ x, sizeof(x)-1 }
417
      /* order from longest to shortest */
418
      PFX("__GI___libc_"),
419
      PFX("__GI___"),
420
      PFX("__libc_"),
421
      PFX("__GI__"),
422
      PFX("__GI_"),
423
      PFX("__"),
424
#undef PFX
425
   };
426
427
   lena = VG_(strlen)(a->name);
428
   lenb = VG_(strlen)(b->name);
429
430
   /* rearrange so that a is the long one */
431
   if (lena < lenb) {
432
      RiSym *t;
433
      Int lt;
434
435
      t = a;
436
      a = b;
437
      b = t;
438
439
      lt = lena;
440
      lena = lenb;
441
      lenb = lt;
442
   }
443
444
   for(i = pfx = 0; i < sizeof(prefixes)/sizeof(*prefixes); i++) {
445
      Int pfxlen = prefixes[i].len;
446
447
      if (pfxlen < lena &&
448
	  VG_(memcmp)(a->name, prefixes[i].prefix, pfxlen) == 0) {
449
	 pfx = pfxlen;
450
	 break;
451
      }
452
   }
453
454
   if (pfx != 0 && VG_(strcmp)(a->name + pfx, b->name) == 0)
455
      return b;
456
457
   return a;
458
}
459
401
static 
460
static 
402
void canonicaliseSymtab ( SegInfo* si )
461
void canonicaliseSymtab ( SegInfo* si )
403
{
462
{
Lines 415-421 Link Here
415
  cleanup_more:
474
  cleanup_more:
416
 
475
 
417
   /* If two symbols have identical address ranges, favour the
476
   /* If two symbols have identical address ranges, favour the
418
      one with the longer name. 
477
      one with the longer name (unless the extra length is junk)
419
   */
478
   */
420
   do {
479
   do {
421
      n_merged = 0;
480
      n_merged = 0;
Lines 427-438 Link Here
427
             && si->symtab[i].size   == si->symtab[i+1].size) {
486
             && si->symtab[i].size   == si->symtab[i+1].size) {
428
            n_merged++;
487
            n_merged++;
429
            /* merge the two into one */
488
            /* merge the two into one */
430
            if (VG_(strlen)(si->symtab[i].name) 
489
	    si->symtab[si->symtab_used++] = *prefersym(&si->symtab[i], &si->symtab[i+1]);
431
                > VG_(strlen)(si->symtab[i+1].name)) {
432
               si->symtab[si->symtab_used++] = si->symtab[i];
433
            } else {
434
               si->symtab[si->symtab_used++] = si->symtab[i+1];
435
            }
436
            i++;
490
            i++;
437
         } else {
491
         } else {
438
            si->symtab[si->symtab_used++] = si->symtab[i];
492
            si->symtab[si->symtab_used++] = si->symtab[i];
Lines 663-668 Link Here
663
/*--- Read info from a .so/exe file.                       ---*/
717
/*--- Read info from a .so/exe file.                       ---*/
664
/*------------------------------------------------------------*/
718
/*------------------------------------------------------------*/
665
719
720
Bool VG_(is_object_file)(const void *buf)
721
{
722
   {
723
      Elf32_Ehdr *ehdr = (Elf32_Ehdr *)buf;
724
      Int ok = 1;
725
726
      ok &= (ehdr->e_ident[EI_MAG0] == 0x7F
727
             && ehdr->e_ident[EI_MAG1] == 'E'
728
             && ehdr->e_ident[EI_MAG2] == 'L'
729
             && ehdr->e_ident[EI_MAG3] == 'F');
730
      ok &= (ehdr->e_ident[EI_CLASS] == ELFCLASS32
731
             && ehdr->e_ident[EI_DATA] == ELFDATA2LSB
732
             && ehdr->e_ident[EI_VERSION] == EV_CURRENT);
733
      ok &= (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN);
734
      ok &= (ehdr->e_machine == EM_386);
735
      ok &= (ehdr->e_version == EV_CURRENT);
736
      ok &= (ehdr->e_shstrndx != SHN_UNDEF);
737
      ok &= (ehdr->e_shoff != 0 && ehdr->e_shnum != 0);
738
      ok &= (ehdr->e_phoff != 0 && ehdr->e_phnum != 0);
739
740
      if (ok)
741
	 return True;
742
   }
743
744
   /* other file formats here? */
745
746
   return False;
747
}
748
666
/* Read a symbol table (normal or dynamic) */
749
/* Read a symbol table (normal or dynamic) */
667
static
750
static
668
void read_symtab( SegInfo* si, Char* tab_name,
751
void read_symtab( SegInfo* si, Char* tab_name,
Lines 794-800 Link Here
794
      name = VG_(addStr) ( si, t0, -1 );
877
      name = VG_(addStr) ( si, t0, -1 );
795
      vg_assert(name != NULL
878
      vg_assert(name != NULL
796
                /* && 0==VG_(strcmp)(t0,&vg_strtab[nmoff]) */ );
879
                /* && 0==VG_(strcmp)(t0,&vg_strtab[nmoff]) */ );
797
      vg_assert( (Int)sym->st_value >= 0);
798
      /* VG_(printf)("%p + %d:   %p %s\n", si->start, 
880
      /* VG_(printf)("%p + %d:   %p %s\n", si->start, 
799
                  (Int)sym->st_value, sym_addr,  t0 ); */
881
                  (Int)sym->st_value, sym_addr,  t0 ); */
800
      risym.addr  = sym_addr;
882
      risym.addr  = sym_addr;
Lines 823-829 Link Here
823
905
824
   oimage = (Addr)NULL;
906
   oimage = (Addr)NULL;
825
   if (VG_(clo_verbosity) > 1)
907
   if (VG_(clo_verbosity) > 1)
826
      VG_(message)(Vg_UserMsg, "Reading syms from %s", si->filename );
908
      VG_(message)(Vg_UserMsg, "Reading syms from %s (%p)", si->filename, si->start );
827
909
828
   /* mmap the object image aboard, so that we can read symbols and
910
   /* mmap the object image aboard, so that we can read symbols and
829
      line number info out of it.  It will be munmapped immediately
911
      line number info out of it.  It will be munmapped immediately
Lines 843-849 Link Here
843
   }
925
   }
844
926
845
   oimage = (Addr)VG_(mmap)( NULL, n_oimage, 
927
   oimage = (Addr)VG_(mmap)( NULL, n_oimage, 
846
                             VKI_PROT_READ, VKI_MAP_PRIVATE, fd, 0 );
928
                             VKI_PROT_READ, VKI_MAP_PRIVATE|VKI_MAP_NOSYMS, fd, 0 );
929
847
   VG_(close)(fd);
930
   VG_(close)(fd);
848
931
849
   if (oimage == ((Addr)(-1))) {
932
   if (oimage == ((Addr)(-1))) {
Lines 859-879 Link Here
859
   ok = (n_oimage >= sizeof(Elf32_Ehdr));
942
   ok = (n_oimage >= sizeof(Elf32_Ehdr));
860
   ehdr = (Elf32_Ehdr*)oimage;
943
   ehdr = (Elf32_Ehdr*)oimage;
861
944
862
   if (ok) {
945
   if (ok)
863
      ok &= (ehdr->e_ident[EI_MAG0] == 0x7F
946
      ok &= VG_(is_object_file)(ehdr);
864
             && ehdr->e_ident[EI_MAG1] == 'E'
865
             && ehdr->e_ident[EI_MAG2] == 'L'
866
             && ehdr->e_ident[EI_MAG3] == 'F');
867
      ok &= (ehdr->e_ident[EI_CLASS] == ELFCLASS32
868
             && ehdr->e_ident[EI_DATA] == ELFDATA2LSB
869
             && ehdr->e_ident[EI_VERSION] == EV_CURRENT);
870
      ok &= (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN);
871
      ok &= (ehdr->e_machine == EM_386);
872
      ok &= (ehdr->e_version == EV_CURRENT);
873
      ok &= (ehdr->e_shstrndx != SHN_UNDEF);
874
      ok &= (ehdr->e_shoff != 0 && ehdr->e_shnum != 0);
875
      ok &= (ehdr->e_phoff != 0 && ehdr->e_phnum != 0);
876
   }
877
947
878
   if (!ok) {
948
   if (!ok) {
879
      VG_(symerr)("Invalid ELF header, or missing stringtab/sectiontab.");
949
      VG_(symerr)("Invalid ELF header, or missing stringtab/sectiontab.");
Lines 891-896 Link Here
891
   {
961
   {
892
      Bool offset_set = False;
962
      Bool offset_set = False;
893
      Elf32_Addr prev_addr = 0;
963
      Elf32_Addr prev_addr = 0;
964
      Addr baseaddr = 0;
894
965
895
      si->offset = 0;
966
      si->offset = 0;
896
967
Lines 900-911 Link Here
900
971
901
	 o_phdr = &((Elf32_Phdr *)(oimage + ehdr->e_phoff))[i];
972
	 o_phdr = &((Elf32_Phdr *)(oimage + ehdr->e_phoff))[i];
902
973
974
	 if (o_phdr->p_type == PT_DYNAMIC && si->soname == NULL) {
975
	    const Elf32_Dyn *dyn = (const Elf32_Dyn *)(oimage + o_phdr->p_offset);
976
	    Int stroff = -1;
977
	    Char *strtab = NULL;
978
	    Int j;
979
	    
980
	    for(j = 0; dyn[j].d_tag != DT_NULL; j++) {
981
	       switch(dyn[j].d_tag) {
982
	       case DT_SONAME:
983
		  stroff =  dyn[j].d_un.d_val;
984
		  break;
985
986
	       case DT_STRTAB:
987
		  strtab = (Char *)oimage + dyn[j].d_un.d_ptr - baseaddr;
988
		  break;
989
	       }
990
	    }
991
992
	    if (stroff != -1 && strtab != 0) {
993
	       TRACE_SYMTAB("soname=%s\n", strtab+stroff);
994
	       si->soname = VG_(arena_strdup)(VG_AR_SYMTAB, strtab+stroff);
995
	    }
996
	 }
997
903
	 if (o_phdr->p_type != PT_LOAD)
998
	 if (o_phdr->p_type != PT_LOAD)
904
	    continue;
999
	    continue;
905
1000
906
	 if (!offset_set) {
1001
	 if (!offset_set) {
907
	    offset_set = True;
1002
	    offset_set = True;
908
	    si->offset = si->start - o_phdr->p_vaddr;
1003
	    si->offset = si->start - o_phdr->p_vaddr;
1004
	    baseaddr = o_phdr->p_vaddr;
909
	 }
1005
	 }
910
1006
911
	 if (o_phdr->p_vaddr < prev_addr) {
1007
	 if (o_phdr->p_vaddr < prev_addr) {
Lines 936-945 Link Here
936
	     (mapped_end > (si->start+si->size))) {
1032
	     (mapped_end > (si->start+si->size))) {
937
	    UInt newsz = mapped_end - si->start;
1033
	    UInt newsz = mapped_end - si->start;
938
	    if (newsz > si->size) {
1034
	    if (newsz > si->size) {
1035
	       Segment *seg;
1036
939
	       if (0)
1037
	       if (0)
940
		  VG_(printf)("extending mapping %p..%p %d -> ..%p %d\n", 
1038
		  VG_(printf)("extending mapping %p..%p %d -> ..%p %d\n", 
941
			      si->start, si->start+si->size, si->size,
1039
			      si->start, si->start+si->size, si->size,
942
			      si->start+newsz, newsz);
1040
			      si->start+newsz, newsz);
1041
1042
	       for(seg = VG_(find_segment)(si->start);
1043
		   seg != NULL && VG_(seg_overlaps)(seg, si->start, si->size); 
1044
		   seg = VG_(next_segment)(seg)) {
1045
		  if (seg->symtab == si)
1046
		     continue;
1047
1048
		  if (seg->symtab != NULL)
1049
		     VG_(symtab_decref)(seg->symtab, seg->addr, seg->len);
1050
1051
		  VG_(symtab_incref)(si);
1052
		  seg->symtab = si;
1053
		  
1054
		  if (0)
1055
		     VG_(printf)("adding symtab %p (%p-%p) to segment %p (%p-%p)\n",
1056
				 si, si->start, si->start+newsz,
1057
				 seg, seg->addr, seg->addr+seg->len);
1058
	       }
1059
	       
943
	       si->size = newsz;
1060
	       si->size = newsz;
944
	    }
1061
	    }
945
	 }
1062
	 }
Lines 1074-1127 Link Here
1074
*/
1191
*/
1075
static SegInfo* segInfo = NULL;
1192
static SegInfo* segInfo = NULL;
1076
1193
1077
void VG_(read_seg_symbols) ( Addr start, UInt size, 
1194
static void resolve_seg_redirs(SegInfo *si);
1078
                             Char rr, Char ww, Char xx, 
1195
1079
                             UInt foffset, UChar* filename )
1196
SegInfo *VG_(read_seg_symbols) ( Segment *seg )
1080
{
1197
{
1081
   SegInfo* si;
1198
   SegInfo* si;
1082
1199
1083
   /* Stay sane ... */
1200
   vg_assert(seg->symtab == NULL);
1084
   if (size == 0)
1085
      return;
1086
1087
   /* We're only interested in collecting symbols in executable
1088
      segments which are associated with a real file.  Hence: */
1089
   if (filename == NULL || xx != 'x')
1090
      return;
1091
   if (0 == VG_(strcmp)(filename, "/dev/zero"))
1092
      return;
1093
   if (foffset != 0)
1094
      return;
1095
1201
1096
   VGP_PUSHCC(VgpReadSyms);
1202
   VGP_PUSHCC(VgpReadSyms);
1097
1203
1098
   /* Perhaps we already have this one?  If so, skip. */
1099
   for (si = segInfo; si != NULL; si = si->next) {
1100
      /*
1101
      if (0==VG_(strcmp)(si->filename, filename)) 
1102
         VG_(printf)("same fnames: %c%c%c (%p, %d) (%p, %d) %s\n", 
1103
                     rr,ww,xx,si->start,si->size,start,size,filename);
1104
      */
1105
      /* For some reason the observed size of a mapping can change, so
1106
         we don't use that to determine uniqueness. */
1107
      if (si->start == start
1108
          /* && si->size == size */
1109
          && 0==VG_(strcmp)(si->filename, filename)) 
1110
      {
1111
         VGP_POPCC(VgpReadSyms);
1112
         return;
1113
      }
1114
   }
1115
1116
   /* Get the record initialised right. */
1204
   /* Get the record initialised right. */
1117
   si = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof(SegInfo));
1205
   si = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof(SegInfo));
1118
1206
1119
   VG_(memset)(si, 0, sizeof(*si));
1207
   VG_(memset)(si, 0, sizeof(*si));
1120
   si->start    = start;
1208
   si->start    = seg->addr;
1121
   si->size     = size;
1209
   si->size     = seg->len;
1122
   si->foffset  = foffset;
1210
   si->foffset  = seg->offset;
1123
   si->filename = VG_(arena_malloc)(VG_AR_SYMTAB, 1 + VG_(strlen)(filename));
1211
   si->filename = VG_(arena_strdup)(VG_AR_SYMTAB, seg->filename);
1124
   VG_(strcpy)(si->filename, filename);
1212
1213
   si->ref = 1;
1125
1214
1126
   si->symtab = NULL;
1215
   si->symtab = NULL;
1127
   si->symtab_size = si->symtab_used = 0;
1216
   si->symtab_size = si->symtab_used = 0;
Lines 1131-1136 Link Here
1131
   si->scopetab = NULL;
1220
   si->scopetab = NULL;
1132
   si->scopetab_size = si->scopetab_used = 0;
1221
   si->scopetab_size = si->scopetab_used = 0;
1133
1222
1223
   si->seg = seg;
1224
1134
   si->stab_typetab = NULL;
1225
   si->stab_typetab = NULL;
1135
1226
1136
   si->plt_start  = si->plt_size  = 0;
1227
   si->plt_start  = si->plt_size  = 0;
Lines 1155-1182 Link Here
1155
      canonicaliseSymtab ( si );
1246
      canonicaliseSymtab ( si );
1156
      canonicaliseLoctab ( si );
1247
      canonicaliseLoctab ( si );
1157
      canonicaliseScopetab ( si );
1248
      canonicaliseScopetab ( si );
1249
1250
      /* do redirects */
1251
      resolve_seg_redirs( si );
1158
   }
1252
   }
1159
   VGP_POPCC(VgpReadSyms);
1253
   VGP_POPCC(VgpReadSyms);
1160
}
1161
1254
1162
1255
   return si;
1163
/* This one really is the Head Honcho.  Update the symbol tables to
1164
   reflect the current state of /proc/self/maps.  Rather than re-read
1165
   everything, just read the entries which are not already in segInfo.
1166
   So we can call here repeatedly, after every mmap of a non-anonymous
1167
   segment with execute permissions, for example, to pick up new
1168
   libraries as they are dlopen'd.  Conversely, when the client does
1169
   munmap(), vg_symtab_notify_munmap() throws away any symbol tables
1170
   which happen to correspond to the munmap()d area.  */
1171
void VG_(read_all_symbols) ( void )
1172
{
1173
   /* 9 July 2003: In order to work around PLT bypassing in
1174
      glibc-2.3.2 (see below VG_(setup_code_redirect_table)), we need
1175
      to load debug info regardless of the skin, unfortunately.  */
1176
   VG_(read_procselfmaps)  ( );
1177
   VG_(parse_procselfmaps) ( VG_(read_seg_symbols) );
1178
}
1256
}
1179
1257
1258
1180
/* When an munmap() call happens, check to see whether it corresponds
1259
/* When an munmap() call happens, check to see whether it corresponds
1181
   to a segment for a .so, and if so discard the relevant SegInfo.
1260
   to a segment for a .so, and if so discard the relevant SegInfo.
1182
   This might not be a very clever idea from the point of view of
1261
   This might not be a very clever idea from the point of view of
Lines 1202-1209 Link Here
1202
1281
1203
   if (VG_(clo_verbosity) > 1)
1282
   if (VG_(clo_verbosity) > 1)
1204
      VG_(message)(Vg_UserMsg, 
1283
      VG_(message)(Vg_UserMsg, 
1205
                   "discard syms in %s due to munmap()", 
1284
                   "discard syms at %p-%p in %s due to munmap()", 
1206
                   curr->filename ? curr->filename : (Char *)"???");
1285
                   start, start+length, curr->filename ? curr->filename : (Char *)"???");
1207
1286
1208
   vg_assert(prev == NULL || prev->next == curr);
1287
   vg_assert(prev == NULL || prev->next == curr);
1209
1288
Lines 1217-1222 Link Here
1217
   return;
1296
   return;
1218
}
1297
}
1219
1298
1299
void VG_(symtab_decref)(SegInfo *si, Addr start, UInt len)
1300
{
1301
   vg_assert(si->ref >= 1);
1302
   if (--si->ref == 0)
1303
      VG_(unload_symbols)(si->start, si->size);
1304
}
1305
1306
void VG_(symtab_incref)(SegInfo *si)
1307
{
1308
   vg_assert(si->ref > 0);
1309
   si->ref++;
1310
}
1220
1311
1221
/*------------------------------------------------------------*/
1312
/*------------------------------------------------------------*/
1222
/*--- Use of symbol table & location info to create        ---*/
1313
/*--- Use of symbol table & location info to create        ---*/
Lines 1256-1263 Link Here
1256
   table is designed we have no option but to do a complete linear
1347
   table is designed we have no option but to do a complete linear
1257
   scan of the table.  Returns NULL if not found. */
1348
   scan of the table.  Returns NULL if not found. */
1258
1349
1259
static Addr reverse_search_one_symtab ( SegInfo* si,
1350
static Addr reverse_search_one_symtab ( const SegInfo* si,
1260
                                        Char* name )
1351
                                        const Char* name )
1261
{
1352
{
1262
   UInt i;
1353
   UInt i;
1263
   for (i = 0; i < si->symtab_used; i++) {
1354
   for (i = 0; i < si->symtab_used; i++) {
Lines 1280-1298 Link Here
1280
{
1371
{
1281
   Int      sno;
1372
   Int      sno;
1282
   SegInfo* si;
1373
   SegInfo* si;
1374
   Segment *s;
1283
1375
1284
   VGP_PUSHCC(VgpSearchSyms);
1376
   VGP_PUSHCC(VgpSearchSyms);
1377
1378
   s = VG_(find_segment)(ptr);
1379
1380
   if (s == NULL || !VG_(seg_overlaps)(s, ptr, 0) || s->symtab == NULL)
1381
      goto not_found;
1285
   
1382
   
1286
   for (si = segInfo; si != NULL; si = si->next) {
1383
   si = s->symtab;
1287
      if (si->start <= ptr && ptr < si->start+si->size) {
1384
1288
         sno = search_one_symtab ( si, ptr, match_anywhere_in_fun );
1385
   sno = search_one_symtab ( si, ptr, match_anywhere_in_fun );
1289
         if (sno == -1) goto not_found;
1386
   if (sno == -1) goto not_found;
1290
         *symno = sno;
1387
   
1291
         *psi = si;
1388
   *symno = sno;
1292
         VGP_POPCC(VgpSearchSyms);
1389
   *psi = si;
1293
         return;
1390
   VGP_POPCC(VgpSearchSyms);
1294
      }
1391
   return;
1295
   }
1392
1296
  not_found:
1393
  not_found:
1297
   *psi = NULL;
1394
   *psi = NULL;
1298
   VGP_POPCC(VgpSearchSyms);
1395
   VGP_POPCC(VgpSearchSyms);
Lines 1447-1453 Link Here
1447
   return True;
1544
   return True;
1448
}
1545
}
1449
1546
1450
/* This is available to skins... always demangle C++ names,
1547
/* This is available to tools... always demangle C++ names,
1451
   match anywhere in function, but don't show offsets. */
1548
   match anywhere in function, but don't show offsets. */
1452
Bool VG_(get_fnname) ( Addr a, Char* buf, Int nbuf )
1549
Bool VG_(get_fnname) ( Addr a, Char* buf, Int nbuf )
1453
{
1550
{
Lines 1456-1462 Link Here
1456
                       /*show offset?*/False );
1553
                       /*show offset?*/False );
1457
}
1554
}
1458
1555
1459
/* This is available to skins... always demangle C++ names,
1556
/* This is available to tools... always demangle C++ names,
1460
   match anywhere in function, and show offset if nonzero. */
1557
   match anywhere in function, and show offset if nonzero. */
1461
Bool VG_(get_fnname_w_offset) ( Addr a, Char* buf, Int nbuf )
1558
Bool VG_(get_fnname_w_offset) ( Addr a, Char* buf, Int nbuf )
1462
{
1559
{
Lines 1465-1471 Link Here
1465
                       /*show offset?*/True );
1562
                       /*show offset?*/True );
1466
}
1563
}
1467
1564
1468
/* This is available to skins... always demangle C++ names,
1565
/* This is available to tools... always demangle C++ names,
1469
   only succeed if 'a' matches first instruction of function,
1566
   only succeed if 'a' matches first instruction of function,
1470
   and don't show offsets. */
1567
   and don't show offsets. */
1471
Bool VG_(get_fnname_if_entry) ( Addr a, Char* buf, Int nbuf )
1568
Bool VG_(get_fnname_if_entry) ( Addr a, Char* buf, Int nbuf )
Lines 1680-1707 Link Here
1680
	 v->size = VG_(st_sizeof)(sym->type);
1777
	 v->size = VG_(st_sizeof)(sym->type);
1681
1778
1682
	 if (debug && 0)
1779
	 if (debug && 0)
1683
	    VG_(printf)("sym->name=%s sym->kind=%d offset=%d\n", sym->name, sym->kind, sym->offset);
1780
	    VG_(printf)("sym->name=%s sym->kind=%d offset=%d\n", sym->name, sym->kind, sym->u.offset);
1684
	 switch(sym->kind) {
1781
	 switch(sym->kind) {
1685
	    UInt reg;
1782
	    UInt reg;
1686
1783
1687
	 case SyGlobal:
1784
	 case SyGlobal:
1688
	 case SyStatic:
1785
	 case SyStatic:
1689
	    if (sym->addr == 0) {
1786
	    if (sym->u.addr == 0) {
1690
	       /* XXX lookup value */
1787
	       /* XXX lookup value */
1691
	    }
1788
	    }
1692
	    v->valuep = sym->addr;
1789
	    v->valuep = sym->u.addr;
1693
	    break;
1790
	    break;
1694
1791
1695
	 case SyReg:
1792
	 case SyReg:
1696
	    v->valuep = (Addr)regaddr(tid, sym->regno);
1793
	    v->valuep = (Addr)regaddr(tid, sym->u.regno);
1697
	    break;
1794
	    break;
1698
1795
1699
	 case SyEBPrel:
1796
	 case SyEBPrel:
1700
	 case SyESPrel:
1797
	 case SyESPrel:
1701
	    reg = *regaddr(tid, sym->kind == SyESPrel ? R_ESP : R_EBP);
1798
	    reg = *regaddr(tid, sym->kind == SyESPrel ? R_ESP : R_EBP);
1702
	    if (debug)
1799
	    if (debug)
1703
	       VG_(printf)("reg=%p+%d=%p\n", reg, sym->offset, reg+sym->offset);
1800
	       VG_(printf)("reg=%p+%d=%p\n", reg, sym->u.offset, reg+sym->u.offset);
1704
	    v->valuep = (Addr)(reg + sym->offset);
1801
	    v->valuep = (Addr)(reg + sym->u.offset);
1705
	    break;
1802
	    break;
1706
1803
1707
	 case SyType:
1804
	 case SyType:
Lines 1810-1893 Link Here
1810
1907
1811
1908
1812
/*------------------------------------------------------------*/
1909
/*------------------------------------------------------------*/
1813
/*--- Find interesting glibc entry points.                 ---*/
1910
/*--- General purpose redirection.                         ---*/
1814
/*------------------------------------------------------------*/
1911
/*------------------------------------------------------------*/
1815
1912
1816
CodeRedirect VG_(code_redirect_table)[VG_N_CODE_REDIRECTS];
1913
/* Set to True for debug printing. */
1914
static const Bool verbose_redir = False;
1817
1915
1818
Int VG_(setup_code_redirect_table) ( void )
1916
1917
/* resolved redirections, indexed by from_addr */
1918
typedef struct _CodeRedirect {
1919
   const Char	*from_lib;	/* library qualifier pattern */
1920
   const Char	*from_sym;	/* symbol */
1921
   Addr		from_addr;	/* old addr */
1922
1923
   const Char	*to_lib;	/* library qualifier pattern */
1924
   const Char	*to_sym;	/* symbol */
1925
   Addr		to_addr;	/* new addr */
1926
1927
   struct _CodeRedirect *next;	/* next pointer on unresolved list */
1928
} CodeRedirect;
1929
1930
static Int addrcmp(const void *ap, const void *bp)
1819
{
1931
{
1820
#  define N_SUBSTS 6
1932
   Addr a = *(Addr *)ap;
1933
   Addr b = *(Addr *)bp;
1934
   Int ret;
1935
1936
   if (a == b)
1937
      ret = 0;
1938
   else
1939
      ret = (a < b) ? -1 : 1;
1821
1940
1822
   Int     i, j;
1941
   return ret;
1823
   Addr    a_libc, a_pth;
1942
}
1824
   SegInfo *si, *si_libc, *si_pth;
1825
1826
   /* Original entry points to look for in libc. */
1827
   static Char* libc_names[N_SUBSTS]
1828
     = { "__GI___errno_location"
1829
       , "__errno_location"
1830
       , "__GI___h_errno_location"
1831
       , "__h_errno_location"
1832
       , "__GI___res_state" 
1833
       , "__res_state"
1834
       };
1835
1836
   /* Corresponding substitute address in our pthread lib. */
1837
   static Char* pth_names[N_SUBSTS]
1838
     = { "__errno_location"
1839
       , "__errno_location"
1840
       , "__h_errno_location"
1841
       , "__h_errno_location"
1842
       , "__res_state" 
1843
       , "__res_state"
1844
       };
1845
1943
1846
   /* Look for the SegInfo for glibc and our pthread library. */
1944
static Char *straddr(void *p)
1945
{
1946
   static Char buf[16];
1847
1947
1848
   si_libc = si_pth = NULL;
1948
   VG_(sprintf)(buf, "%p", *(Addr *)p);
1849
1949
1850
   for (si = segInfo; si != NULL; si = si->next) {
1950
   return buf;
1851
      if (VG_(strstr)(si->filename, "/libc-2.2.93.so")
1951
}
1852
          || VG_(strstr)(si->filename, "/libc-2.3.1.so")
1952
1853
          || VG_(strstr)(si->filename, "/libc-2.3.2.so")
1953
static SkipList sk_resolved_redir = SKIPLIST_INIT(CodeRedirect, from_addr, 
1854
          || VG_(strstr)(si->filename, "/libc.so"))
1954
						  addrcmp, straddr, VG_AR_SYMTAB);
1855
         si_libc = si;
1955
static CodeRedirect *unresolved_redir = NULL;
1856
      if (VG_(strstr)(si->filename, "/libpthread.so"))
1956
1857
         si_pth = si;
1957
static Bool match_lib(const Char *pattern, const SegInfo *si)
1958
{
1959
   /* pattern == NULL matches everything, otherwise use globbing
1960
1961
      If the pattern starts with:
1962
	file:, then match filename
1963
	soname:, then match soname
1964
	something else, match filename
1965
   */
1966
   const Char *name = si->filename;
1967
1968
   if (pattern == NULL)
1969
      return True;
1970
1971
   if (VG_(strncmp)(pattern, "file:", 5) == 0) {
1972
      pattern += 5;
1973
      name = si->filename;
1858
   }
1974
   }
1975
   if (VG_(strncmp)(pattern, "soname:", 7) == 0) {
1976
      pattern += 7;
1977
      name = si->soname;
1978
   }
1979
1980
   if (name == NULL)
1981
      return False;
1982
   
1983
   return VG_(string_match)(pattern, name);
1984
}
1859
1985
1860
   if (si_libc == NULL || si_pth == NULL) 
1986
/* Resolve a redir using si if possible, and add it to the resolved
1861
      return 0;
1987
   list */
1988
static Bool resolve_redir(CodeRedirect *redir, const SegInfo *si)
1989
{
1990
   Bool resolved;
1862
1991
1863
   /* Build the substitution table. */
1992
   vg_assert(si != NULL);
1864
   vg_assert(N_SUBSTS <= VG_N_CODE_REDIRECTS-1);
1993
   vg_assert(si->seg != NULL);
1865
1994
1866
   j = 0;
1995
   /* no redirection from Valgrind segments */
1867
   VG_(code_redirect_table)[j].entry_pt_orig = 0; 
1996
   if (si->seg->flags & SF_VALGRIND)
1997
      return False;
1868
1998
1869
   for (i = 0; i < N_SUBSTS; i++) {
1999
   resolved = (redir->from_addr != 0) && (redir->to_addr != 0);
1870
      a_libc = reverse_search_one_symtab(si_libc, libc_names[i]);
2000
1871
      a_pth  = reverse_search_one_symtab(si_pth,  pth_names[i]);
2001
   if (0 && verbose_redir)
1872
      if (a_libc == 0 || a_pth == 0)
2002
      VG_(printf)("   consider FROM binding %s:%s -> %s:%s in %s(%s)\n",
1873
         continue;
2003
		  redir->from_lib, redir->from_sym,
1874
      /* We've found a substitution pair. */
2004
		  redir->to_lib, redir->to_sym,
1875
      VG_(code_redirect_table)[j].entry_pt_orig  = a_libc;
2005
		  si->filename, si->soname);
1876
      VG_(code_redirect_table)[j].entry_pt_subst = a_pth;
2006
1877
      j++;
2007
   vg_assert(!resolved);
1878
      vg_assert(j < VG_N_CODE_REDIRECTS);
2008
1879
      /* Set end marker. */
2009
   if (redir->from_addr == 0) {
1880
      VG_(code_redirect_table)[j].entry_pt_orig = 0; 
2010
      vg_assert(redir->from_sym != NULL);
1881
      if (VG_(clo_verbosity) >= 2)
2011
1882
         VG_(message)(Vg_UserMsg, 
2012
      if (match_lib(redir->from_lib, si)) {
1883
            "REPLACING libc(%s) with libpthread(%s)",
2013
	 redir->from_addr = reverse_search_one_symtab(si, redir->from_sym);
1884
            libc_names[i], pth_names[i]
2014
	 if (verbose_redir && redir->from_addr != 0)
1885
         );
2015
	    VG_(printf)("   bind FROM: %p = %s:%s\n", 
2016
                        redir->from_addr,redir->from_lib, redir->from_sym );
2017
      }
2018
   }
2019
2020
   if (redir->to_addr == 0) {
2021
      vg_assert(redir->to_sym != NULL);
2022
2023
      if (match_lib(redir->to_lib, si)) {
2024
	 redir->to_addr = reverse_search_one_symtab(si, redir->to_sym);
2025
	 if (verbose_redir && redir->to_addr != 0)
2026
	    VG_(printf)("   bind   TO: %p = %s:%s\n", 
2027
                        redir->to_addr,redir->to_lib, redir->to_sym );
2028
2029
      }
2030
   }
2031
2032
   resolved = (redir->from_addr != 0) && (redir->to_addr != 0);
2033
2034
   if (0 && verbose_redir)
2035
      VG_(printf)("resolve_redir: %s:%s from=%p %s:%s to=%p\n",
2036
		  redir->from_lib, redir->from_sym, redir->from_addr, 
2037
		  redir->to_lib, redir->to_sym, redir->to_addr);
2038
2039
   if (resolved) {
2040
      if (VG_(clo_verbosity) > 2 || verbose_redir) {
2041
	 VG_(message)(Vg_DebugMsg, "  redir resolved (%s:%s=%p -> ",
2042
		      redir->from_lib, redir->from_sym, redir->from_addr);
2043
	 VG_(message)(Vg_DebugMsg, "                  %s:%s=%p)",
2044
		      redir->to_lib, redir->to_sym, redir->to_addr);
2045
      }
2046
      
2047
      if (VG_(search_transtab)(redir->from_addr) != 0) {
2048
	/* For some given (from, to) redir, the "from" function got
2049
           called before the .so containing "to" became available.  We
2050
           know this because there is already a translation for the
2051
           entry point of the original "from".  So the redirect will
2052
           never actually take effect unless that translation is
2053
           discarded.  
2054
2055
           Note, we only really need to discard the first bb of the
2056
           old entry point, and so we avoid the problem of having to
2057
           figure out how big that bb was -- since it is at least 1
2058
           byte of original code, we can just pass 1 as the original
2059
           size to invalidate_translations() and it will indeed get
2060
           rid of the translation. 
2061
2062
           Note, this is potentially expensive -- discarding
2063
           translations causes complete unchaining.  
2064
         */
2065
         if (VG_(clo_verbosity) > 2) {
2066
            VG_(message)(Vg_UserMsg,   
2067
	       "Discarding translation due to redirect of already called function" );
2068
            VG_(message)(Vg_UserMsg,
2069
                "   %s (%p -> %p)",
2070
                redir->from_sym, redir->from_addr, redir->to_addr );
2071
         }
2072
	 VG_(invalidate_translations)(redir->from_addr, 1, True);
2073
      }
2074
2075
      VG_(SkipList_Insert)(&sk_resolved_redir, redir);
1886
   }
2076
   }
1887
2077
1888
   return j;
2078
   return resolved;
2079
}
2080
2081
/* Go through the complete redir list, resolving as much as possible with this SegInfo.
2082
2083
    This should be called when a new SegInfo symtab is loaded.
2084
 */
2085
static void resolve_seg_redirs(SegInfo *si)
2086
{
2087
   CodeRedirect **prevp = &unresolved_redir;
2088
   CodeRedirect *redir, *next;
2089
2090
   if (verbose_redir)
2091
      VG_(printf)("Considering redirs to/from %s(soname=%s)\n",
2092
                  si->filename, si->soname);
2093
2094
   /* visit each unresolved redir - if it becomes resolved, then
2095
      remove it from the unresolved list */
2096
   for(redir = unresolved_redir; redir != NULL; redir = next) {
2097
      next = redir->next;
2098
2099
      if (resolve_redir(redir, si)) {
2100
	 *prevp = next;
2101
	 redir->next = NULL;
2102
      } else
2103
	 prevp = &redir->next;
2104
   }
2105
}
2106
2107
static Bool resolve_redir_allsegs(CodeRedirect *redir)
2108
{
2109
   SegInfo *si;
2110
2111
   for(si = segInfo; si != NULL; si = si->next)
2112
      if (resolve_redir(redir, si))
2113
	 return True;
2114
2115
   return False;
2116
}
2117
2118
/* Redirect a lib/symbol reference to a function at lib/symbol */
2119
void VG_(add_redirect_sym)(const Char *from_lib, const Char *from_sym,
2120
			   const Char *to_lib, const Char *to_sym)
2121
{
2122
   CodeRedirect *redir = VG_(SkipNode_Alloc)(&sk_resolved_redir);
2123
2124
   redir->from_lib = VG_(arena_strdup)(VG_AR_SYMTAB, from_lib);
2125
   redir->from_sym = VG_(arena_strdup)(VG_AR_SYMTAB, from_sym);
2126
   redir->from_addr = 0;
2127
2128
   redir->to_lib = VG_(arena_strdup)(VG_AR_SYMTAB, to_lib);
2129
   redir->to_sym = VG_(arena_strdup)(VG_AR_SYMTAB, to_sym);
2130
   redir->to_addr = 0;
2131
2132
   if (VG_(clo_verbosity) >= 2)
2133
      VG_(message)(Vg_UserMsg, 
2134
                   "REDIRECT %s(%s) to %s(%s)",
2135
                   from_lib, from_sym, to_lib, to_sym);
2136
2137
   if (!resolve_redir_allsegs(redir)) {
2138
      /* can't resolve immediately; add to list */
2139
      redir->next = unresolved_redir;
2140
      unresolved_redir = redir;
2141
   }
2142
}
2143
2144
/* Redirect a lib/symbol reference to a function at lib/symbol */
2145
void VG_(add_redirect_addr)(const Char *from_lib, const Char *from_sym,
2146
			    Addr to_addr)
2147
{
2148
   CodeRedirect *redir = VG_(SkipNode_Alloc)(&sk_resolved_redir);
2149
2150
   redir->from_lib = VG_(arena_strdup)(VG_AR_SYMTAB, from_lib);
2151
   redir->from_sym = VG_(arena_strdup)(VG_AR_SYMTAB, from_sym);
2152
   redir->from_addr = 0;
2153
2154
   redir->to_lib = NULL;
2155
   redir->to_sym = NULL;
2156
   redir->to_addr = to_addr;
2157
2158
   if (!resolve_redir_allsegs(redir)) {
2159
      /* can't resolve immediately; add to list */
2160
      redir->next = unresolved_redir;
2161
      unresolved_redir = redir;
2162
   }
2163
}
2164
2165
Addr VG_(code_redirect)(Addr a)
2166
{
2167
   CodeRedirect *r = VG_(SkipList_Find)(&sk_resolved_redir, &a);
2168
2169
   if (r == NULL || r->from_addr != a)
2170
      return a;
2171
2172
   vg_assert(r->to_addr != 0);
2173
2174
   return r->to_addr;
2175
}
2176
2177
void VG_(setup_code_redirect_table) ( void )
2178
{
2179
   static const struct {
2180
      const Char *from, *to;
2181
   } redirects[] = {
2182
      { "__GI___errno_location",	"__errno_location"	},
2183
      { "__errno_location",		"__errno_location"	},
2184
      { "__GI___h_errno_location",	"__h_errno_location"	},
2185
      { "__h_errno_location",		"__h_errno_location"	},
2186
      { "__GI___res_state",		"__res_state"		},
2187
      { "__res_state",			"__res_state"		},
2188
   };
2189
   Int i;
1889
2190
1890
#  undef N_SUBSTS
2191
   for(i = 0; i < sizeof(redirects)/sizeof(*redirects); i++) {
2192
      VG_(add_redirect_sym)("soname:libc.so.6",		redirects[i].from,
2193
			    "soname:libpthread.so.0",	redirects[i].to);
2194
   }
2195
2196
   /* Overenthusiastic use of PLT bypassing by the glibc people also
2197
      means we need to patch the following functions to our own
2198
      implementations of said, in mac_replace_strmem.c.
2199
    */
2200
   VG_(add_redirect_sym)("soname:libc.so.6", "stpcpy",
2201
			 "*vgpreload_memcheck.so*", "stpcpy");
2202
   VG_(add_redirect_sym)("soname:libc.so.6", "strnlen",
2203
			 "*vgpreload_memcheck.so*", "strnlen");
2204
2205
   VG_(add_redirect_sym)("soname:ld-linux.so.2", "stpcpy",
2206
			 "*vgpreload_memcheck.so*", "stpcpy");
2207
   VG_(add_redirect_sym)("soname:ld-linux.so.2", "strchr",
2208
			 "*vgpreload_memcheck.so*", "strchr");
1891
}
2209
}
1892
2210
1893
/*------------------------------------------------------------*/
2211
/*------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/vg_symtab2.h (-3 / +9 lines)
Lines 6-12 Link Here
6
   This file is part of Valgrind, an extensible x86 protected-mode
6
   This file is part of Valgrind, an extensible x86 protected-mode
7
   emulator for monitoring program execution on x86-Unixes.
7
   emulator for monitoring program execution on x86-Unixes.
8
8
9
   Copyright (C) 2000-2003 Julian Seward
9
   Copyright (C) 2000-2004 Julian Seward
10
      jseward@acm.org
10
      jseward@acm.org
11
11
12
   This program is free software; you can redistribute it and/or
12
   This program is free software; you can redistribute it and/or
Lines 97-103 Link Here
97
      Int	offset;		/* offset on stack (-ve -> ebp; +ve -> esp) */
97
      Int	offset;		/* offset on stack (-ve -> ebp; +ve -> esp) */
98
      Int	regno;		/* register number */
98
      Int	regno;		/* register number */
99
      Addr	addr;		/* static or global address */
99
      Addr	addr;		/* static or global address */
100
   };
100
   } u;
101
};
101
};
102
102
103
struct _Scope {
103
struct _Scope {
Lines 120-131 Link Here
120
/* A structure which contains information pertaining to one mapped
120
/* A structure which contains information pertaining to one mapped
121
   text segment. (typedef in vg_skin.h) */
121
   text segment. (typedef in vg_skin.h) */
122
struct _SegInfo {
122
struct _SegInfo {
123
   struct _SegInfo* next;
123
   struct _SegInfo* next;	/* list of SegInfos */
124
125
   Segment	*seg;		/* first segment we're mapped out of */
126
   Int		ref;
127
124
   /* Description of the mapped segment. */
128
   /* Description of the mapped segment. */
125
   Addr   start;
129
   Addr   start;
126
   UInt   size;
130
   UInt   size;
127
   Char*  filename; /* in mallocville */
131
   Char*  filename; /* in mallocville */
128
   UInt   foffset;
132
   UInt   foffset;
133
   Char*  soname;
134
129
   /* An expandable array of symbols. */
135
   /* An expandable array of symbols. */
130
   RiSym* symtab;
136
   RiSym* symtab;
131
   UInt   symtab_used;
137
   UInt   symtab_used;
(-)valgrind-2.1.0/coregrind/vg_symtypes.c (-46 / +46 lines)
Lines 6-12 Link Here
6
   This file is part of Valgrind, an extensible x86 protected-mode
6
   This file is part of Valgrind, an extensible x86 protected-mode
7
   emulator for monitoring program execution on x86-Unixes.
7
   emulator for monitoring program execution on x86-Unixes.
8
8
9
   Copyright (C) 2000-2003 Julian Seward
9
   Copyright (C) 2000-2004 Julian Seward
10
      jseward@acm.org
10
      jseward@acm.org
11
11
12
   This program is free software; you can redistribute it and/or
12
   This program is free software; you can redistribute it and/or
Lines 151-157 Link Here
151
	 SymResolver	*resolver;	/* symtab reader's resolver */
151
	 SymResolver	*resolver;	/* symtab reader's resolver */
152
	 void		*data;		/* data for resolver */
152
	 void		*data;		/* data for resolver */
153
      } t_unresolved;
153
      } t_unresolved;
154
   };
154
   } u;
155
};
155
};
156
156
157
157
Lines 186-192 Link Here
186
   if (st->kind != TyUnresolved)
186
   if (st->kind != TyUnresolved)
187
      return;
187
      return;
188
188
189
   (*st->t_unresolved.resolver)(st, st->t_unresolved.data);
189
   (*st->u.t_unresolved.resolver)(st, st->u.t_unresolved.data);
190
190
191
   if (st->kind == TyUnresolved)
191
   if (st->kind == TyUnresolved)
192
      st->kind = TyError;
192
      st->kind = TyError;
Lines 200-207 Link Here
200
200
201
   st->kind = TyUnresolved;
201
   st->kind = TyUnresolved;
202
   st->size = 0;
202
   st->size = 0;
203
   st->t_unresolved.resolver = resolver;
203
   st->u.t_unresolved.resolver = resolver;
204
   st->t_unresolved.data = data;
204
   st->u.t_unresolved.data = data;
205
205
206
   return st;
206
   return st;
207
}
207
}
Lines 211-218 Link Here
211
   if (st->kind != TyUnresolved)
211
   if (st->kind != TyUnresolved)
212
      return;
212
      return;
213
213
214
   st->t_unresolved.resolver = resolver;
214
   st->u.t_unresolved.resolver = resolver;
215
   st->t_unresolved.data = data;
215
   st->u.t_unresolved.data = data;
216
}
216
}
217
217
218
Bool VG_(st_isresolved)(SymType *st)
218
Bool VG_(st_isresolved)(SymType *st)
Lines 246-252 Link Here
246
   
246
   
247
   st->kind = TyInt;
247
   st->kind = TyInt;
248
   st->size = size;
248
   st->size = size;
249
   st->t_scalar.issigned = isSigned;
249
   st->u.t_scalar.issigned = isSigned;
250
250
251
   return st;
251
   return st;
252
}
252
}
Lines 259-265 Link Here
259
   
259
   
260
   st->kind = TyFloat;
260
   st->kind = TyFloat;
261
   st->size = size;
261
   st->size = size;
262
   st->t_scalar.issigned = True;
262
   st->u.t_scalar.issigned = True;
263
263
264
   return st;
264
   return st;
265
}
265
}
Lines 285-291 Link Here
285
285
286
   st->kind = TyPointer;
286
   st->kind = TyPointer;
287
   st->size = sizeof(void *);
287
   st->size = sizeof(void *);
288
   st->t_pointer.type = ptr;
288
   st->u.t_pointer.type = ptr;
289
289
290
   return st;
290
   return st;
291
}
291
}
Lines 298-306 Link Here
298
298
299
   st->kind = TyRange;
299
   st->kind = TyRange;
300
   st->size = 0;		/* ? */
300
   st->size = 0;		/* ? */
301
   st->t_range.type = ty;
301
   st->u.t_range.type = ty;
302
   st->t_range.min = min;
302
   st->u.t_range.min = min;
303
   st->t_range.max = max;
303
   st->u.t_range.max = max;
304
304
305
   return st;
305
   return st;
306
}
306
}
Lines 311-326 Link Here
311
311
312
   vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown || st->kind == TyStruct);
312
   vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown || st->kind == TyStruct);
313
313
314
   vg_assert(st->kind != TyStruct || st->t_struct.nfield == 0);
314
   vg_assert(st->kind != TyStruct || st->u.t_struct.nfield == 0);
315
315
316
   st->kind = TyStruct;
316
   st->kind = TyStruct;
317
   st->size = size;
317
   st->size = size;
318
   st->t_struct.nfield = 0;
318
   st->u.t_struct.nfield = 0;
319
   st->t_struct.nfieldalloc = nfields;
319
   st->u.t_struct.nfieldalloc = nfields;
320
   if (nfields != 0)
320
   if (nfields != 0)
321
      st->t_struct.fields = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof(StField) * nfields);
321
      st->u.t_struct.fields = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof(StField) * nfields);
322
   else
322
   else
323
      st->t_struct.fields = NULL;
323
      st->u.t_struct.fields = NULL;
324
   
324
   
325
   return st;
325
   return st;
326
}
326
}
Lines 331-346 Link Here
331
331
332
   vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown || st->kind == TyUnion);
332
   vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown || st->kind == TyUnion);
333
333
334
   vg_assert(st->kind != TyUnion || st->t_struct.nfield == 0);
334
   vg_assert(st->kind != TyUnion || st->u.t_struct.nfield == 0);
335
335
336
   st->kind = TyUnion;
336
   st->kind = TyUnion;
337
   st->size = size;
337
   st->size = size;
338
   st->t_struct.nfield = 0;
338
   st->u.t_struct.nfield = 0;
339
   st->t_struct.nfieldalloc = nfields;
339
   st->u.t_struct.nfieldalloc = nfields;
340
   if (nfields != 0)
340
   if (nfields != 0)
341
      st->t_struct.fields = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof(StField) * nfields);
341
      st->u.t_struct.fields = VG_(arena_malloc)(VG_AR_SYMTAB, sizeof(StField) * nfields);
342
   else
342
   else
343
      st->t_struct.fields = NULL;
343
      st->u.t_struct.fields = NULL;
344
344
345
   return st;
345
   return st;
346
}
346
}
Lines 351-367 Link Here
351
351
352
   vg_assert(st->kind == TyStruct || st->kind == TyUnion);
352
   vg_assert(st->kind == TyStruct || st->kind == TyUnion);
353
353
354
   if (st->t_struct.nfieldalloc == st->t_struct.nfield) {
354
   if (st->u.t_struct.nfieldalloc == st->u.t_struct.nfield) {
355
      StField *n = VG_(arena_malloc)(VG_AR_SYMTAB, 
355
      StField *n = VG_(arena_malloc)(VG_AR_SYMTAB, 
356
				     sizeof(StField) * (st->t_struct.nfieldalloc + 2));
356
				     sizeof(StField) * (st->u.t_struct.nfieldalloc + 2));
357
      VG_(memcpy)(n, st->t_struct.fields, sizeof(*n) * st->t_struct.nfield);
357
      VG_(memcpy)(n, st->u.t_struct.fields, sizeof(*n) * st->u.t_struct.nfield);
358
      if (st->t_struct.fields != NULL)
358
      if (st->u.t_struct.fields != NULL)
359
	 VG_(arena_free)(VG_AR_SYMTAB, st->t_struct.fields);
359
	 VG_(arena_free)(VG_AR_SYMTAB, st->u.t_struct.fields);
360
      st->t_struct.nfieldalloc++;
360
      st->u.t_struct.nfieldalloc++;
361
      st->t_struct.fields = n;
361
      st->u.t_struct.fields = n;
362
   }
362
   }
363
363
364
   f = &st->t_struct.fields[st->t_struct.nfield++];
364
   f = &st->u.t_struct.fields[st->u.t_struct.nfield++];
365
   f->name = name;
365
   f->name = name;
366
   f->type = type;
366
   f->type = type;
367
   f->offset = off;
367
   f->offset = off;
Lines 376-383 Link Here
376
   vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown || st->kind == TyEnum);
376
   vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown || st->kind == TyEnum);
377
377
378
   st->kind = TyEnum;
378
   st->kind = TyEnum;
379
   st->t_enum.ntag = 0;
379
   st->u.t_enum.ntag = 0;
380
   st->t_enum.tags = NULL;
380
   st->u.t_enum.tags = NULL;
381
   
381
   
382
   return st;
382
   return st;
383
}
383
}
Lines 389-396 Link Here
389
   vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown);
389
   vg_assert(st->kind == TyUnresolved || st->kind == TyUnknown);
390
390
391
   st->kind = TyArray;
391
   st->kind = TyArray;
392
   st->t_array.type = type;
392
   st->u.t_array.type = type;
393
   st->t_array.idxtype = idxtype;
393
   st->u.t_array.idxtype = idxtype;
394
   
394
   
395
   return st;
395
   return st;
396
}
396
}
Lines 405-411 Link Here
405
   
405
   
406
   st->kind = TyTypedef;
406
   st->kind = TyTypedef;
407
   st->name = name;
407
   st->name = name;
408
   st->t_typedef.type = type;
408
   st->u.t_typedef.type = type;
409
409
410
   return st;
410
   return st;
411
}
411
}
Lines 418-424 Link Here
418
	 resolve(type);
418
	 resolve(type);
419
419
420
      if (type->kind == TyTypedef)
420
      if (type->kind == TyTypedef)
421
	 type = type->t_typedef.type;
421
	 type = type->u.t_typedef.type;
422
   }
422
   }
423
423
424
   return type;
424
   return type;
Lines 689-695 Link Here
689
	 else
689
	 else
690
	    bufsz *= 2;
690
	    bufsz *= 2;
691
691
692
	 /* use skin malloc so that the skin client can free it */
692
	 /* use tool malloc so that the skin client can free it */
693
	 n = VG_(malloc)(bufsz);
693
	 n = VG_(malloc)(bufsz);
694
	 if (buf != NULL && bufidx != 0)
694
	 if (buf != NULL && bufidx != 0)
695
	    VG_(memcpy)(n, buf, bufidx);
695
	    VG_(memcpy)(n, buf, bufidx);
Lines 825-833 Link Here
825
	    Int i;
825
	    Int i;
826
826
827
	    if (debug)
827
	    if (debug)
828
	       VG_(printf)("    %d fields\n", type->t_struct.nfield);
828
	       VG_(printf)("    %d fields\n", type->u.t_struct.nfield);
829
	    for(i = 0; i < type->t_struct.nfield; i++) {
829
	    for(i = 0; i < type->u.t_struct.nfield; i++) {
830
	       StField *f = &type->t_struct.fields[i];
830
	       StField *f = &type->u.t_struct.fields[i];
831
	       newvar(f->name, f->type, var->valuep + (f->offset / 8), (f->size + 7) / 8);
831
	       newvar(f->name, f->type, var->valuep + (f->offset / 8), (f->size + 7) / 8);
832
	    }
832
	    }
833
	    break;
833
	    break;
Lines 837-848 Link Here
837
	    Int i; 
837
	    Int i; 
838
	    Int offset;		/* offset of index for non-0-based arrays */
838
	    Int offset;		/* offset of index for non-0-based arrays */
839
	    Int min, max;	/* range of indicies we care about (0 based) */
839
	    Int min, max;	/* range of indicies we care about (0 based) */
840
	    SymType *ty = type->t_array.type;
840
	    SymType *ty = type->u.t_array.type;
841
	    vg_assert(type->t_array.idxtype->kind == TyRange);
841
	    vg_assert(type->u.t_array.idxtype->kind == TyRange);
842
842
843
	    offset = type->t_array.idxtype->t_range.min;
843
	    offset = type->u.t_array.idxtype->u.t_range.min;
844
	    min = 0;
844
	    min = 0;
845
	    max = type->t_array.idxtype->t_range.max - offset;
845
	    max = type->u.t_array.idxtype->u.t_range.max - offset;
846
846
847
	    if ((max-min+1) == 0) {
847
	    if ((max-min+1) == 0) {
848
#if SHADOWCHUNK
848
#if SHADOWCHUNK
Lines 893-899 Link Here
893
	    /* XXX work out a way of telling whether a pointer is
893
	    /* XXX work out a way of telling whether a pointer is
894
	       actually a decayed array, and treat it accordingly */
894
	       actually a decayed array, and treat it accordingly */
895
	    if (is_valid_addr(var->valuep))
895
	    if (is_valid_addr(var->valuep))
896
	       newvar(NULL, type->t_pointer.type, *(Addr *)var->valuep, -1);
896
	       newvar(NULL, type->u.t_pointer.type, *(Addr *)var->valuep, -1);
897
	    break;
897
	    break;
898
898
899
	 case TyUnresolved:
899
	 case TyUnresolved:
(-)valgrind-2.1.0/coregrind/vg_symtypes.h (-1 / +1 lines)
Lines 6-12 Link Here
6
   This file is part of Valgrind, an extensible x86 protected-mode
6
   This file is part of Valgrind, an extensible x86 protected-mode
7
   emulator for monitoring program execution on x86-Unixes.
7
   emulator for monitoring program execution on x86-Unixes.
8
8
9
   Copyright (C) 2000-2003 Julian Seward
9
   Copyright (C) 2000-2004 Julian Seward
10
      jseward@acm.org
10
      jseward@acm.org
11
11
12
   This program is free software; you can redistribute it and/or
12
   This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/coregrind/vg_syscall.S (-1 / +1 lines)
Lines 8-14 Link Here
8
  This file is part of Valgrind, an extensible x86 protected-mode
8
  This file is part of Valgrind, an extensible x86 protected-mode
9
  emulator for monitoring program execution on x86-Unixes.
9
  emulator for monitoring program execution on x86-Unixes.
10
10
11
  Copyright (C) 2000-2003 Julian Seward 
11
  Copyright (C) 2000-2004 Julian Seward 
12
     jseward@acm.org
12
     jseward@acm.org
13
13
14
  This program is free software; you can redistribute it and/or
14
  This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/coregrind/vg_syscalls.c (-175 / +760 lines)
Lines 7-13 Link Here
7
   This file is part of Valgrind, an extensible x86 protected-mode
7
   This file is part of Valgrind, an extensible x86 protected-mode
8
   emulator for monitoring program execution on x86-Unixes.
8
   emulator for monitoring program execution on x86-Unixes.
9
9
10
   Copyright (C) 2000-2003 Julian Seward 
10
   Copyright (C) 2000-2004 Julian Seward 
11
      jseward@acm.org
11
      jseward@acm.org
12
12
13
   This program is free software; you can redistribute it and/or
13
   This program is free software; you can redistribute it and/or
Lines 117-122 Link Here
117
	 (*atforks[i].child)(tid);
117
	 (*atforks[i].child)(tid);
118
}
118
}
119
119
120
/* return true if address range entirely contained within client
121
   address space */
122
static Bool valid_client_addr(Addr start, UInt size, ThreadId tid, const Char *syscall)
123
{
124
   Addr end = start+size;
125
   Addr cl_base = VG_(client_base);
126
   Bool ret;
127
128
   if (size == 0)
129
      return True;
130
131
   if (cl_base < 0x10000)
132
      cl_base = 0x10000;
133
134
   ret =
135
      (end >= start) && 
136
      start >= cl_base && start < VG_(client_end) &&
137
      (end <= VG_(client_end));
138
139
   if (0)
140
      VG_(printf)("%s: test=%p-%p client=%p-%p ret=%d\n",
141
		  syscall, start, end, cl_base, VG_(client_end), ret);
142
143
   if (!ret && syscall != NULL) {
144
      VG_(message)(Vg_UserMsg, "Warning: client syscall %s tried to modify addresses %p-%p",
145
		   syscall, start, end);
146
147
      if (VG_(clo_verbosity) > 1) {
148
	 ExeContext *ec = VG_(get_ExeContext)(tid);
149
	 VG_(pp_ExeContext)(ec);
150
      }
151
   }
152
153
   return ret;
154
}
155
156
/* Walk through a colon-separated environment variable, and remove the
157
   entries which matches file_pattern.  It slides everything down over
158
   the removed entries, and pads the remaining space with '\0'.  It
159
   modifies the entries in place (in the client address space), but it
160
   shouldn't matter too much, since we only do this just before an
161
   execve().
162
163
   This is also careful to mop up any excess ':'s, since empty strings
164
   delimited by ':' are considered to be '.' in a path.
165
*/
166
void VG_(mash_colon_env)(Char *varp, const Char *remove_pattern)
167
{
168
   Char *const start = varp;
169
   Char *entry_start = varp;
170
   Char *output = varp;
171
172
   if (varp == NULL)
173
      return;
174
175
   while(*varp) {
176
      if (*varp == ':') {
177
	 Char prev;
178
	 Bool match;
179
180
	 /* This is a bit subtle: we want to match against the entry
181
	    we just copied, because it may have overlapped with
182
	    itself, junking the original. */
183
184
	 prev = *output;
185
	 *output = '\0';
186
187
	 match = VG_(string_match)(remove_pattern, entry_start);
188
189
	 *output = prev;
190
	 
191
	 if (match) {
192
	    output = entry_start;
193
	    varp++;			/* skip ':' after removed entry */
194
	 } else
195
	    entry_start = output+1;	/* entry starts after ':' */
196
      }
197
198
      *output++ = *varp++;
199
   }
200
201
   /* match against the last entry */
202
   if (VG_(string_match)(remove_pattern, entry_start)) {
203
      output = entry_start;
204
      if (output > start) {
205
	 /* remove trailing ':' */
206
	 output--;
207
	 vg_assert(*output == ':');
208
      }
209
   }	 
210
211
   /* pad out the left-overs with '\0' */
212
   while(output < varp)
213
      *output++ = '\0';
214
}
215
216
120
/* ---------------------------------------------------------------------
217
/* ---------------------------------------------------------------------
121
   Doing mmap, munmap, mremap, mprotect
218
   Doing mmap, munmap, mremap, mprotect
122
   ------------------------------------------------------------------ */
219
   ------------------------------------------------------------------ */
Lines 137-158 Link Here
137
static 
234
static 
138
void mash_addr_and_len( Addr* a, UInt* len)
235
void mash_addr_and_len( Addr* a, UInt* len)
139
{
236
{
140
   while (( *a         % VKI_BYTES_PER_PAGE) > 0) { (*a)--; (*len)++; }
237
   Addr ra;
141
   while (((*a + *len) % VKI_BYTES_PER_PAGE) > 0) {         (*len)++; }
238
   
239
   ra = PGROUNDDN(*a);
240
   *len = PGROUNDUP(*a + *len) - ra;
241
   *a = ra;
142
}
242
}
143
243
144
static
244
static
145
void mmap_segment ( Addr a, UInt len, UInt prot, Int fd )
245
void mmap_segment ( Addr a, UInt len, UInt prot, UInt mm_flags, Int fd, ULong offset )
146
{
246
{
147
   Bool rr, ww, xx;
247
   Bool rr, ww, xx;
248
   UInt flags;
148
249
149
   /* Records segment, reads debug symbols if necessary */
250
   flags = SF_MMAP;
150
   if ((prot & PROT_EXEC) && fd != -1)
251
   
151
      VG_(new_exeseg_mmap) ( a, len );
252
   if (mm_flags & VKI_MAP_FIXED)
152
253
      flags |= SF_FIXED;
153
   rr = prot & PROT_READ;
254
   if (!(mm_flags & VKI_MAP_PRIVATE))
154
   ww = prot & PROT_WRITE;
255
      flags |= SF_SHARED;
155
   xx = prot & PROT_EXEC;
256
257
   if (fd != -1)
258
      flags |= SF_FILE;
259
260
   VG_(map_fd_segment)(a, len, prot, flags, fd, offset, NULL);
261
262
   rr = prot & VKI_PROT_READ;
263
   ww = prot & VKI_PROT_WRITE;
264
   xx = prot & VKI_PROT_EXEC;
156
265
157
   VG_TRACK( new_mem_mmap, a, len, rr, ww, xx );
266
   VG_TRACK( new_mem_mmap, a, len, rr, ww, xx );
158
}
267
}
Lines 164-182 Link Here
164
      Addr orig_len = len; */
273
      Addr orig_len = len; */
165
274
166
   mash_addr_and_len(&a, &len);
275
   mash_addr_and_len(&a, &len);
276
277
   VG_(unmap_range)(a, len);
278
167
   /*
279
   /*
168
   VG_(printf)("MUNMAP: correct (%p for %d) to (%p for %d) %s\n", 
280
   VG_(printf)("MUNMAP: correct (%p for %d) to (%p for %d) %s\n", 
169
      orig_a, orig_len, a, len, (orig_a!=start || orig_len!=length) 
281
      orig_a, orig_len, a, len, (orig_a!=start || orig_len!=length) 
170
                                    ? "CHANGE" : "");
282
                                    ? "CHANGE" : "");
171
   */
283
   */
172
284
173
   /* Invalidate translations as necessary (also discarding any basic
174
      block-specific info retained by the skin) and unload any debug
175
      symbols. */
176
   // This doesn't handle partial unmapping of exe segs correctly, if that
177
   // ever happens...
178
   VG_(remove_if_exeseg) ( a, len );
179
180
   VG_TRACK( die_mem_munmap, a, len );
285
   VG_TRACK( die_mem_munmap, a, len );
181
}
286
}
182
287
Lines 185-193 Link Here
185
{
290
{
186
   Bool rr, ww, xx;
291
   Bool rr, ww, xx;
187
292
188
   rr = prot & PROT_READ;
293
   VG_(mprotect_range)(a, len, prot);
189
   ww = prot & PROT_WRITE;
294
190
   xx = prot & PROT_EXEC;
295
   rr = prot & VKI_PROT_READ;
296
   ww = prot & VKI_PROT_WRITE;
297
   xx = prot & VKI_PROT_EXEC;
191
298
192
   // if removing exe permission, should check and remove from exe_seg list
299
   // if removing exe permission, should check and remove from exe_seg list
193
   // if adding, should check and add to exe_seg list
300
   // if adding, should check and add to exe_seg list
Lines 197-230 Link Here
197
}
304
}
198
305
199
static 
306
static 
200
void mremap_segment ( Addr old_addr, UInt old_size, Addr new_addr,
307
Addr mremap_segment ( Addr old_addr, UInt old_size,
201
                      UInt new_size )
308
		      Addr new_addr, UInt new_size,
309
		      UInt flags, ThreadId tid)
202
{
310
{
203
   /* If the block moves, assume new and old blocks can't overlap; seems to
311
   Addr ret;
204
    * be valid judging from Linux kernel code in mm/mremap.c */
312
   Segment *seg, *next;
205
   vg_assert(old_addr == new_addr         ||
313
206
             old_addr+old_size < new_addr ||
314
   old_size = PGROUNDUP(old_size);
207
             new_addr+new_size < old_addr);
315
   new_size = PGROUNDUP(new_size);
208
316
209
   if (new_size < old_size) {
317
   if (PGROUNDDN(old_addr) != old_addr)
210
      // if exe_seg
318
      return -VKI_EINVAL;
211
      //    unmap old symbols from old_addr+new_size..old_addr+new_size
319
212
      //    update exe_seg size = new_size
320
   if (!valid_client_addr(old_addr, old_size, tid, "mremap(old_addr)"))
213
      //    update exe_seg addr = new_addr...
321
      return -VKI_EFAULT;
214
      VG_TRACK( copy_mem_remap, old_addr, new_addr, new_size );
322
215
      VG_TRACK( die_mem_munmap, old_addr+new_size, old_size-new_size );
323
   /* fixed at the current address means we don't move it */
324
   if ((flags & VKI_MREMAP_FIXED) && (old_addr == new_addr))
325
      flags &= ~(VKI_MREMAP_FIXED|VKI_MREMAP_MAYMOVE);
326
327
   if (flags & VKI_MREMAP_FIXED) {
328
      if (PGROUNDDN(new_addr) != new_addr)
329
	 return -VKI_EINVAL;
330
331
      if (!valid_client_addr(new_addr, new_size, tid, "mremap(new_addr)"))
332
	 return -VKI_ENOMEM;
333
334
      /* check for overlaps */
335
      if ((old_addr < (new_addr+new_size) &&
336
	   (old_addr+old_size) > new_addr) ||
337
	  (new_addr < (old_addr+new_size) &&
338
	   (new_addr+new_size) > old_addr))
339
	 return -VKI_EINVAL;
340
   }
341
342
   /* Do nothing */
343
   if (!(flags & VKI_MREMAP_FIXED) && new_size == old_size)
344
      return old_addr;
345
346
   seg = VG_(find_segment)(old_addr);
347
348
   /* range must be contained within segment */
349
   if (seg == NULL || !VG_(seg_contains)(seg, old_addr, old_size))
350
      return -VKI_EINVAL;
351
352
   next = VG_(next_segment)(seg);
353
354
   if (0)
355
      VG_(printf)("mremap: old_addr+new_size=%p next->addr=%p flags=%d\n",
356
		  old_addr+new_size, next->addr, flags);
357
   
358
   if ((flags & VKI_MREMAP_FIXED) ||
359
       (next != NULL && (old_addr+new_size) > next->addr)) {
360
      /* we're moving the block */
361
      Addr a;
362
      
363
      if ((flags & (VKI_MREMAP_FIXED|VKI_MREMAP_MAYMOVE)) == 0)
364
	 return -VKI_ENOMEM;	/* not allowed to move */
216
365
366
      if ((flags & VKI_MREMAP_FIXED) == 0)
367
	  new_addr = 0;
368
369
      a = VG_(find_map_space)(new_addr, new_size, True);
370
371
      if ((flags & VKI_MREMAP_FIXED) && a != new_addr)
372
	 return -VKI_ENOMEM;	/* didn't find the place we wanted */
373
374
      new_addr = a;
375
      ret = a;
376
377
      /* we've nailed down the location */
378
      flags |=  VKI_MREMAP_FIXED|VKI_MREMAP_MAYMOVE;
379
380
      ret = VG_(do_syscall)(__NR_mremap, old_addr, old_size, new_size, 
381
			    flags, new_addr);
382
383
      if (ret != new_addr) {
384
	 vg_assert(VG_(is_kerror)(ret));
385
	 return ret;
386
      }
387
388
      VG_TRACK(copy_mem_remap, old_addr, new_addr, 
389
	       (old_size < new_size) ? old_size : new_size);
390
391
      if (new_size > old_size)
392
	 VG_TRACK(new_mem_mmap, new_addr+old_size, new_size-old_size,
393
		  seg->prot & VKI_PROT_READ, 
394
		  seg->prot & VKI_PROT_WRITE, 
395
		  seg->prot & VKI_PROT_EXEC);
396
      VG_TRACK(die_mem_munmap, old_addr, old_size);
397
398
      VG_(map_file_segment)(new_addr, new_size,
399
			    seg->prot, 
400
			    seg->flags,
401
			    seg->dev, seg->ino,
402
			    seg->offset, seg->filename);
403
404
      VG_(munmap)((void *)old_addr, old_size);
217
   } else {
405
   } else {
218
      // if exe_seg
406
      /* staying in place */
219
      //    map new symbols from new_addr+old_size..new_addr+new_size
407
      ret = old_addr;
220
      //    update exe_seg size = new_size
408
221
      //    update exe_seg addr = new_addr...
409
      if (new_size < old_size) {
222
      VG_TRACK( copy_mem_remap, old_addr, new_addr, old_size );
410
	 VG_TRACK(die_mem_munmap, old_addr+new_size, old_size-new_size);
223
      // what should the permissions on the new extended part be??
411
	 VG_(munmap)((void *)(old_addr+new_size), old_size-new_size);
224
      // using 'rwx'
412
      } else {
225
      VG_TRACK( new_mem_mmap,   new_addr+old_size, new_size-old_size,
413
	 /* we've nailed down the location */
226
                                True, True, True );
414
	 flags &= ~VKI_MREMAP_MAYMOVE;
415
416
	 if (0)
417
	    VG_(printf)("mremap: old_addr=%p old_size=%d new_size=%d flags=%d\n",
418
			old_addr, old_size, new_size, flags);
419
420
	 ret = VG_(do_syscall)(__NR_mremap, old_addr, old_size, new_size, 
421
			       flags, 0);
422
423
	 if (ret != old_addr)
424
	    return ret;
425
426
	 VG_TRACK(new_mem_mmap, old_addr+old_size, new_size-old_size,
427
		  seg->prot & VKI_PROT_READ, 
428
		  seg->prot & VKI_PROT_WRITE, 
429
		  seg->prot & VKI_PROT_EXEC);
430
431
	 VG_(map_file_segment)(old_addr+old_size, new_size-old_size,
432
			       seg->prot, 
433
			       seg->flags,
434
			       seg->dev, seg->ino,
435
			       seg->offset, seg->filename);	 
436
      }
227
   }
437
   }
438
439
   return ret;
228
}
440
}
229
441
230
442
Lines 280-287 Link Here
280
   doesn't exist, we just return NULL.  Otherwise, we return a pointer
492
   doesn't exist, we just return NULL.  Otherwise, we return a pointer
281
   to the file name, which the caller is responsible for freeing. */
493
   to the file name, which the caller is responsible for freeing. */
282
494
283
static
495
Char *VG_(resolve_filename)(Int fd)
284
Char *resolve_fname(Int fd)
285
{
496
{
286
   char tmp[28], buf[PATH_MAX];
497
   char tmp[28], buf[PATH_MAX];
287
498
Lines 291-297 Link Here
291
   if(VG_(readlink)(tmp, buf, PATH_MAX) == -1)
502
   if(VG_(readlink)(tmp, buf, PATH_MAX) == -1)
292
      return NULL;
503
      return NULL;
293
504
294
   return ((buf[0] == '/') ? VG_(strdup)(buf) : NULL);
505
   return ((buf[0] == '/') ? VG_(arena_strdup)(VG_AR_CORE, buf) : NULL);
295
}
506
}
296
507
297
508
Lines 302-307 Link Here
302
{
513
{
303
   OpenFd *i = allocated_fds;
514
   OpenFd *i = allocated_fds;
304
515
516
   if (fd > VG_(max_fd))
517
      return;			/* Valgrind internal */
518
305
   while(i) {
519
   while(i) {
306
      if(i->fd == fd) {
520
      if(i->fd == fd) {
307
         if(i->prev)
521
         if(i->prev)
Lines 311-318 Link Here
311
         if(i->next)
525
         if(i->next)
312
            i->next->prev = i->prev;
526
            i->next->prev = i->prev;
313
         if(i->pathname) 
527
         if(i->pathname) 
314
            VG_(free) (i->pathname);
528
            VG_(arena_free) (VG_AR_CORE, i->pathname);
315
         VG_(free) (i);
529
         VG_(arena_free) (VG_AR_CORE, i);
316
         fd_count--;
530
         fd_count--;
317
         break;
531
         break;
318
      }
532
      }
Lines 332-345 Link Here
332
{
546
{
333
   OpenFd *i;
547
   OpenFd *i;
334
548
335
   if (fd > VG_MAX_FD)
549
   if (fd > VG_(max_fd))
336
      return;			/* Valgrind internal */
550
      return;			/* Valgrind internal */
337
551
338
   /* Check to see if this fd is already open. */
552
   /* Check to see if this fd is already open. */
339
   i = allocated_fds;
553
   i = allocated_fds;
340
   while (i) {
554
   while (i) {
341
      if (i->fd == fd) {
555
      if (i->fd == fd) {
342
         if (i->pathname) VG_(free)(i->pathname);
556
         if (i->pathname) VG_(arena_free)(VG_AR_CORE, i->pathname);
343
         break;
557
         break;
344
      }
558
      }
345
      i = i->next;
559
      i = i->next;
Lines 347-353 Link Here
347
561
348
   /* Not already one: allocate an OpenFd */
562
   /* Not already one: allocate an OpenFd */
349
   if (i == NULL) {
563
   if (i == NULL) {
350
      i = VG_(malloc)(sizeof(OpenFd));
564
      i = VG_(arena_malloc)(VG_AR_CORE, sizeof(OpenFd));
351
565
352
      i->prev = NULL;
566
      i->prev = NULL;
353
      i->next = allocated_fds;
567
      i->next = allocated_fds;
Lines 387-393 Link Here
387
         VG_(sprintf)(name, "%u.%u.%u.%u:%u",
601
         VG_(sprintf)(name, "%u.%u.%u.%u:%u",
388
                      addr & 0xFF, (addr>>8) & 0xFF,
602
                      addr & 0xFF, (addr>>8) & 0xFF,
389
                      (addr>>16) & 0xFF, (addr>>24) & 0xFF,
603
                      (addr>>16) & 0xFF, (addr>>24) & 0xFF,
390
                      sa->sin_port);
604
                      ntohs(sa->sin_port));
391
      }
605
      }
392
   }
606
   }
393
607
Lines 535-541 Link Here
535
749
536
         if(fno != f)
750
         if(fno != f)
537
            if(VG_(clo_track_fds))
751
            if(VG_(clo_track_fds))
538
               record_fd_open(-1, fno, resolve_fname(fno));
752
               record_fd_open(-1, fno, VG_(resolve_filename)(fno));
539
      }
753
      }
540
754
541
      VG_(lseek)(f, d.d_off, VKI_SEEK_SET);
755
      VG_(lseek)(f, d.d_off, VKI_SEEK_SET);
Lines 643-649 Link Here
643
857
644
         for (i = 0; i < fdc; i++)
858
         for (i = 0; i < fdc; i++)
645
            if(VG_(clo_track_fds))
859
            if(VG_(clo_track_fds))
646
               record_fd_open (tid, fds[i], resolve_fname(fds[i]));
860
               record_fd_open (tid, fds[i], VG_(resolve_filename)(fds[i]));
647
      }
861
      }
648
862
649
      cm = CMSG_NXTHDR(msg, cm);
863
      cm = CMSG_NXTHDR(msg, cm);
Lines 739-749 Link Here
739
void buf_and_len_pre_check( ThreadId tid, Addr buf_p, Addr buflen_p,
953
void buf_and_len_pre_check( ThreadId tid, Addr buf_p, Addr buflen_p,
740
                            Char* buf_s, Char* buflen_s )
954
                            Char* buf_s, Char* buflen_s )
741
{
955
{
742
   if (VG_(track_events).pre_mem_write) {
956
   if (VG_(defined_pre_mem_write)()) {
743
      UInt buflen_in = deref_UInt( tid, buflen_p, buflen_s);
957
      UInt buflen_in = deref_UInt( tid, buflen_p, buflen_s);
744
      if (buflen_in > 0) {
958
      if (buflen_in > 0) {
745
         VG_(track_events).pre_mem_write ( Vg_CoreSysCall,
959
         SK_(pre_mem_write) ( Vg_CoreSysCall,
746
					   tid, buf_s, buf_p, buflen_in );
960
			      tid, buf_s, buf_p, buflen_in );
747
      }
961
      }
748
   }
962
   }
749
}
963
}
Lines 752-761 Link Here
752
void buf_and_len_post_check( ThreadId tid, Int res,
966
void buf_and_len_post_check( ThreadId tid, Int res,
753
                             Addr buf_p, Addr buflen_p, Char* s )
967
                             Addr buf_p, Addr buflen_p, Char* s )
754
{
968
{
755
   if (!VG_(is_kerror)(res) && VG_(track_events).post_mem_write) {
969
   if (!VG_(is_kerror)(res) && VG_(defined_post_mem_write)()) {
756
      UInt buflen_out = deref_UInt( tid, buflen_p, s);
970
      UInt buflen_out = deref_UInt( tid, buflen_p, s);
757
      if (buflen_out > 0 && buf_p != (Addr)NULL) {
971
      if (buflen_out > 0 && buf_p != (Addr)NULL) {
758
         VG_(track_events).post_mem_write ( buf_p, buflen_out );
972
         SK_(post_mem_write) ( buf_p, buflen_out );
759
      }
973
      }
760
   }
974
   }
761
}
975
}
Lines 764-783 Link Here
764
   Data seg end, for brk()
978
   Data seg end, for brk()
765
   ------------------------------------------------------------------ */
979
   ------------------------------------------------------------------ */
766
980
767
/* Records the current end of the data segment so we can make sense of
981
static Addr do_brk(Addr newbrk)
768
   calls to brk(). */
769
static
770
Addr curr_dataseg_end;
771
772
void VG_(init_dataseg_end_for_brk) ( void )
773
{
982
{
774
   curr_dataseg_end = (Addr)VG_(brk)(0);
983
   Addr ret = VG_(brk_limit);
775
   if (curr_dataseg_end == (Addr)(-1))
984
   static const Bool debug = False;
776
      VG_(core_panic)("can't determine data-seg end for brk()");
985
   Segment *seg;
986
987
   if (debug)
988
      VG_(printf)("do_brk: brk_base=%p brk_limit=%p newbrk=%p\n",
989
		  VG_(brk_base), VG_(brk_limit), newbrk);
990
991
   if (newbrk < VG_(brk_base) || newbrk >= VG_(client_end))
992
      return VG_(brk_limit);
993
994
   /* brk isn't allowed to grow over anything else */
995
   seg = VG_(find_segment)(VG_(brk_limit));
996
997
   vg_assert(seg != NULL);
998
777
   if (0)
999
   if (0)
778
      VG_(printf)("DS END is %p\n", (void*)curr_dataseg_end);
1000
      VG_(printf)("brk_limit=%p seg->addr=%p seg->end=%p\n", 
1001
		  VG_(brk_limit), seg->addr, seg->addr+seg->len);
1002
   vg_assert(VG_(brk_limit) >= seg->addr && VG_(brk_limit) <= (seg->addr + seg->len));
1003
1004
   seg = VG_(next_segment)(seg);
1005
   if (seg != NULL && newbrk > seg->addr)
1006
      return VG_(brk_limit);
1007
1008
   if (PGROUNDDN(newbrk) != PGROUNDDN(VG_(brk_limit))) {
1009
      Addr current = PGROUNDUP(VG_(brk_limit));
1010
      Addr newaddr = PGROUNDUP(newbrk);
1011
1012
      /* new brk in a new page - fix the mappings */
1013
      if (newbrk > VG_(brk_limit)) {
1014
	 
1015
	 if (debug)
1016
	    VG_(printf)("  extending brk: current=%p newaddr=%p delta=%d\n",
1017
			current, newaddr, newaddr-current);
1018
1019
	 if (newaddr == current) {
1020
	    ret = newbrk;
1021
	 } else if (VG_(mmap)((void *)current , newaddr-current,
1022
			      VKI_PROT_READ | VKI_PROT_WRITE | VKI_PROT_EXEC,
1023
			      VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS | VKI_MAP_FIXED | VKI_MAP_CLIENT,
1024
			      -1, 0) >= 0) {
1025
	    VG_(map_segment)(current, newaddr-current, VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC,
1026
			     SF_FIXED|SF_BRK);
1027
	    ret = newbrk;
1028
	 }
1029
      } else {
1030
	 vg_assert(newbrk < VG_(brk_limit));
1031
1032
	 if (debug)
1033
	    VG_(printf)("  shrinking brk: current=%p newaddr=%p delta=%d\n",
1034
			current, newaddr, current-newaddr);
1035
1036
	 if (newaddr != current) {
1037
	    VG_(munmap)((void *)newaddr, current - newaddr);
1038
	    VG_(unmap_range)(newaddr, current-newaddr);
1039
	 }
1040
	 ret = newbrk;
1041
      }
1042
   } else
1043
      ret = newbrk;
1044
1045
   VG_(brk_limit) = ret;
1046
1047
   return ret;
779
}
1048
}
780
1049
1050
781
/* ---------------------------------------------------------------------
1051
/* ---------------------------------------------------------------------
782
   Vet file descriptors for sanity
1052
   Vet file descriptors for sanity
783
   ------------------------------------------------------------------ */
1053
   ------------------------------------------------------------------ */
Lines 785-791 Link Here
785
/* Return true if we're allowed to use or create this fd */
1055
/* Return true if we're allowed to use or create this fd */
786
static Bool fd_allowed(Int fd, const Char *syscall, ThreadId tid)
1056
static Bool fd_allowed(Int fd, const Char *syscall, ThreadId tid)
787
{
1057
{
788
   if (fd < 0 || fd > VG_MAX_FD || fd == VG_(clo_logfile_fd)) {
1058
   if (fd < 0 || fd > VG_(max_fd) || fd == VG_(clo_logfile_fd)) {
789
      VG_(message)(Vg_UserMsg, 
1059
      VG_(message)(Vg_UserMsg, 
790
         "Warning: invalid file descriptor %d in syscall %s()",
1060
         "Warning: invalid file descriptor %d in syscall %s()",
791
         fd, syscall);
1061
         fd, syscall);
Lines 813-819 Link Here
813
#define POST(x)	\
1083
#define POST(x)	\
814
	static void after_##x(ThreadId tid, ThreadState *tst)
1084
	static void after_##x(ThreadId tid, ThreadState *tst)
815
1085
816
#define STR(x)	#x
817
#define PREALIAS(new, old)	\
1086
#define PREALIAS(new, old)	\
818
	PRE(new) __attribute__((alias(STR(before_##old))))
1087
	PRE(new) __attribute__((alias(STR(before_##old))))
819
#define POSTALIAS(new, old)	\
1088
#define POSTALIAS(new, old)	\
Lines 838-852 Link Here
838
   VG_(core_panic)("syscall exit() not caught by the scheduler?!");
1107
   VG_(core_panic)("syscall exit() not caught by the scheduler?!");
839
}
1108
}
840
1109
841
PRE(clone)
842
{
843
   VG_(unimplemented)
844
      ("clone(): not supported by Valgrind.\n   "
845
       "We do now support programs linked against\n   "
846
       "libpthread.so, though.  Re-run with -v and ensure that\n   "
847
       "you are picking up Valgrind's implementation of libpthread.so.");
848
}
849
850
PRE(ptrace)
1110
PRE(ptrace)
851
{
1111
{
852
   /* long ptrace (enum __ptrace_request request, pid_t pid, 
1112
   /* long ptrace (enum __ptrace_request request, pid_t pid, 
Lines 976-981 Link Here
976
   }
1236
   }
977
}
1237
}
978
1238
1239
PRE(set_thread_area)
1240
{
1241
   MAYBE_PRINTF("set_thread_area ( %p )\n", arg1);
1242
1243
   SYSCALL_TRACK( pre_mem_read, tid, 
1244
		  "set_thread_area(ptr)", arg1, 
1245
		  sizeof(struct vki_modify_ldt_ldt_s) );
1246
1247
   /* "do" the syscall ourselves; the kernel never sees it */
1248
   res = VG_(sys_set_thread_area)( tid, (void *)arg1 );
1249
}
1250
1251
PRE(get_thread_area)
1252
{
1253
   MAYBE_PRINTF("get_thread_area ( %p )\n", arg1);
1254
   SYSCALL_TRACK( pre_mem_write, tid, 
1255
		  "get_thread_area(ptr)", arg1, 
1256
		  sizeof(struct vki_modify_ldt_ldt_s) );
1257
1258
   /* "do" the syscall ourselves; the kernel never sees it */
1259
   res = VG_(sys_get_thread_area)( tid, (void *)arg1 );
1260
1261
   if (!VG_(is_kerror)(res)) {
1262
      VG_TRACK( post_mem_write, arg1, sizeof(struct vki_modify_ldt_ldt_s) );
1263
   }
1264
}
1265
979
PRE(setresgid)
1266
PRE(setresgid)
980
{
1267
{
981
   /* int setresgid(gid_t rgid, gid_t egid, gid_t sgid); */
1268
   /* int setresgid(gid_t rgid, gid_t egid, gid_t sgid); */
Lines 1261-1275 Link Here
1261
PRE(mremap)
1548
PRE(mremap)
1262
{
1549
{
1263
   /* void* mremap(void * old_address, size_t old_size, 
1550
   /* void* mremap(void * old_address, size_t old_size, 
1264
      size_t new_size, unsigned long flags); */
1551
      size_t new_size, unsigned long flags, void * new_address); */
1265
   MAYBE_PRINTF("mremap ( %p, %d, %d, 0x%x )\n", 
1552
   MAYBE_PRINTF("mremap ( %p, %d, %d, 0x%x, %p )\n", 
1266
		arg1, arg2, arg3, arg4);
1553
		arg1, arg2, arg3, arg4, arg5);
1267
   SYSCALL_TRACK( pre_mem_write, tid, "mremap(old_address)", arg1, arg2 );
1554
   
1268
}
1555
   res = mremap_segment((Addr)arg1, arg2, (Addr)arg5, arg3, arg4, tid);
1269
1270
POST(mremap)
1271
{
1272
   mremap_segment( arg1, arg2, (Addr)res, arg3 );
1273
}
1556
}
1274
1557
1275
PRE(nice)
1558
PRE(nice)
Lines 1563-1583 Link Here
1563
      its own new thread.) */
1846
      its own new thread.) */
1564
   VG_(nuke_all_threads_except)( VG_INVALID_THREADID );
1847
   VG_(nuke_all_threads_except)( VG_INVALID_THREADID );
1565
1848
1566
   /* Make any binding for LD_PRELOAD disappear, so that child
1849
   {
1567
      processes don't get traced into. */
1850
      /* Make the LD_LIBRARY_PATH/LD_PRELOAD disappear so that the
1568
   if (!VG_(clo_trace_children)) {
1851
	 child doesn't get our libpthread and other stuff.  This is
1852
	 done unconditionally, since if we are tracing the child,
1853
	 stage1/2 will set up the appropriate client environment. */
1569
      Int i;
1854
      Int i;
1570
      Char** envp = (Char**)arg3;
1855
      Char** envp = (Char**)arg3;
1571
      Char*  ld_preload_str = NULL;
1856
      Char*  ld_preload_str = NULL;
1572
      Char*  ld_library_path_str = NULL;
1857
      Char*  ld_library_path_str = NULL;
1573
      for (i = 0; envp[i] != NULL; i++) {
1858
1574
	 if (VG_(strncmp)(envp[i], "LD_PRELOAD=", 11) == 0)
1859
      if (envp != NULL) {
1575
	    ld_preload_str = &envp[i][11];
1860
	 Char *buf;
1576
	 if (VG_(strncmp)(envp[i], "LD_LIBRARY_PATH=", 16) == 0)
1861
1577
	    ld_library_path_str = &envp[i][16];
1862
	 for (i = 0; envp[i] != NULL; i++) {
1863
	    if (VG_(strncmp)(envp[i], "LD_PRELOAD=", 11) == 0)
1864
	       ld_preload_str = &envp[i][11];
1865
	    if (VG_(strncmp)(envp[i], "LD_LIBRARY_PATH=", 16) == 0)
1866
	       ld_library_path_str = &envp[i][16];
1867
	 }
1868
1869
	 buf = VG_(arena_malloc)(VG_AR_CORE, VG_(strlen)(VG_(libdir)) + 20);
1870
1871
         VG_(sprintf)(buf, "%s*/vg_inject.so", VG_(libdir));
1872
         VG_(mash_colon_env)(ld_preload_str, buf);
1873
1874
         VG_(sprintf)(buf, "%s*/vgpreload_*.so", VG_(libdir));
1875
         VG_(mash_colon_env)(ld_preload_str, buf);
1876
1877
         VG_(sprintf)(buf, "%s*", VG_(libdir));
1878
         VG_(mash_colon_env)(ld_library_path_str, buf);
1879
1880
         VG_(env_unsetenv)(envp, VALGRINDCLO);
1881
1882
	 /* XXX if variable becomes empty, remove it completely? */
1578
      }
1883
      }
1579
      VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH)(
1884
   }
1580
	 ld_preload_str, ld_library_path_str );
1885
1886
   if (VG_(clo_trace_children)) {
1887
      /* If we're tracing the children, then we need to start it
1888
	 with our starter+arguments.
1889
      */
1890
      Int i;
1891
      Char *exec = (Char *)arg1;
1892
      Char **env = (Char **)arg3;
1893
      Char *cp;
1894
      Char *exename;
1895
      Bool sawexec = False;
1896
      Char *optvar;
1897
      Int  optlen;
1898
1899
      optlen = 1;
1900
      for(i = 0; i < VG_(vg_argc); i++)
1901
	 optlen += VG_(strlen)(VG_(vg_argv)[i]) + 1;
1902
1903
      /* All these are leaked - we're either going to exec, or panic
1904
	 when we fail. */
1905
      exename  = VG_(arena_malloc)(VG_AR_CORE, 64);
1906
      exec = VG_(arena_malloc)(VG_AR_CORE, VG_(strlen)(exec) + 7 /* --exec= */ + 1 /* \0 */);
1907
1908
      VG_(sprintf)(exec, "--exec=%s", (Char *)arg1);
1909
      VG_(sprintf)(exename, "/proc/self/fd/%d", VG_(vgexecfd));
1910
1911
      optlen += VG_(strlen)(exec)+1;
1912
1913
      optvar = VG_(arena_malloc)(VG_AR_CORE, optlen);
1914
1915
      /* valgrind arguments */
1916
      cp = optvar;
1917
      
1918
      for(i = 1; i < VG_(vg_argc); i++) {
1919
	 Char *arg = VG_(vg_argv)[i];
1920
	 Int len;
1921
	 
1922
	 if (VG_(memcmp)(arg, "--exec=", 7) == 0) {
1923
	    /* replace existing --exec= arg */
1924
	    sawexec = True;
1925
	    arg = exec;
1926
	 } else if (VG_(strcmp)(VG_(vg_argv)[i], "--") == 0)
1927
	    break;
1928
1929
	 len = VG_(strlen)(arg);
1930
	 VG_(memcpy)(cp, arg, len);
1931
	 cp += len;
1932
	 *cp++ = '\01';
1933
      }
1934
1935
      if (!sawexec) {
1936
	 Int execlen = VG_(strlen)(exec);
1937
	 VG_(memcpy)(cp, exec, execlen);
1938
	 cp += execlen;
1939
	 *cp++ = '\01';
1940
      }
1941
      *cp = '\0';
1942
1943
      VG_(env_setenv)(&env, VALGRINDCLO, optvar);
1944
1945
      arg1 = (UInt)exename;
1946
      arg3 = (UInt)env;
1947
   }
1948
1949
   if (0) {
1950
      Char **cpp;
1951
1952
      VG_(printf)("exec: %s\n", (Char *)arg1);
1953
      for(cpp = (Char **)arg2; cpp && *cpp; cpp++)
1954
	 VG_(printf)("argv: %s\n", *cpp);
1955
      for(cpp = (Char **)arg3; cpp && *cpp; cpp++)
1956
	 VG_(printf)("env: %s\n", *cpp);
1957
   }
1958
1959
   /* Set our real sigmask to match the client's sigmask so that the
1960
      exec'd child will get the right mask.  First we need to clear
1961
      out any pending signals so they they don't get delivered, which
1962
      would confuse things.
1963
1964
      XXX This is a bug - the signals should remain pending, and be
1965
      delivered to the new process after exec.  There's also a
1966
      race-condition, since if someone delivers us a signal between
1967
      the sigprocmask and the execve, we'll still get the signal. Oh
1968
      well.
1969
   */
1970
   {
1971
      vki_ksigset_t allsigs;
1972
      vki_ksiginfo_t info;
1973
      static const struct vki_timespec zero = { 0, 0 };
1974
    
1975
      VG_(ksigfillset)(&allsigs);
1976
      while(VG_(ksigtimedwait)(&allsigs, &info, &zero) > 0)
1977
	 ;
1978
1979
      VG_(ksigprocmask)(VKI_SIG_SETMASK, &tst->sig_mask, NULL);
1581
   }
1980
   }
1582
1981
1583
   res = VG_(do_syscall)(__NR_execve, arg1, arg2, arg3);
1982
   res = VG_(do_syscall)(__NR_execve, arg1, arg2, arg3);
Lines 1605-1610 Link Here
1605
2004
1606
PRE(brk)
2005
PRE(brk)
1607
{
2006
{
2007
   Addr brk_limit = VG_(brk_limit);
2008
1608
   /* libc   says: int   brk(void *end_data_segment);
2009
   /* libc   says: int   brk(void *end_data_segment);
1609
      kernel says: void* brk(void* end_data_segment);  (more or less)
2010
      kernel says: void* brk(void* end_data_segment);  (more or less)
1610
2011
Lines 1621-1648 Link Here
1621
      Both will seg fault if you shrink it back into a text segment.
2022
      Both will seg fault if you shrink it back into a text segment.
1622
   */
2023
   */
1623
   MAYBE_PRINTF("brk ( %p ) --> ",arg1);
2024
   MAYBE_PRINTF("brk ( %p ) --> ",arg1);
1624
}
1625
2025
1626
POST(brk)
2026
   res = do_brk(arg1);
1627
{
2027
1628
   MAYBE_PRINTF("0x%x\n", res);
2028
   MAYBE_PRINTF("0x%x\n", res);
1629
2029
1630
   if (res == arg1) {
2030
   if (res == arg1) {
1631
      /* brk() succeeded */
2031
      /* brk() succeeded */
1632
      if (res < curr_dataseg_end) {
2032
      if (res < brk_limit) {
1633
         /* successfully shrunk the data segment. */
2033
         /* successfully shrunk the data segment. */
1634
         VG_TRACK( die_mem_brk, (Addr)arg1,
2034
         VG_TRACK( die_mem_brk, (Addr)arg1,
1635
		   curr_dataseg_end-arg1 );
2035
		   brk_limit-arg1 );
1636
      } else
2036
      } else
1637
      if (res > curr_dataseg_end && res != 0) {
2037
      if (res > brk_limit) {
1638
         /* successfully grew the data segment */
2038
         /* successfully grew the data segment */
1639
         VG_TRACK( new_mem_brk, curr_dataseg_end,
2039
         VG_TRACK( new_mem_brk, brk_limit,
1640
                                arg1-curr_dataseg_end );
2040
                                arg1-brk_limit );
1641
      }
2041
      }
1642
      curr_dataseg_end = res;
1643
   } else {
2042
   } else {
1644
      /* brk() failed */
2043
      /* brk() failed */
1645
      vg_assert(curr_dataseg_end == res);
2044
      vg_assert(brk_limit == res);
1646
   }
2045
   }
1647
}
2046
}
1648
2047
Lines 1699-1705 Link Here
1699
      res = -VKI_EMFILE;
2098
      res = -VKI_EMFILE;
1700
   } else {
2099
   } else {
1701
      if(VG_(clo_track_fds))
2100
      if(VG_(clo_track_fds))
1702
         record_fd_open(tid, res, resolve_fname(res));
2101
         record_fd_open(tid, res, VG_(resolve_filename)(res));
1703
   }
2102
   }
1704
}
2103
}
1705
2104
Lines 1717-1723 Link Here
1717
		VG_(getpid)(), 
2116
		VG_(getpid)(), 
1718
		arg1, arg2, res);
2117
		arg1, arg2, res);
1719
   if(VG_(clo_track_fds))
2118
   if(VG_(clo_track_fds))
1720
      record_fd_open(tid, res, resolve_fname(res));
2119
      record_fd_open(tid, res, VG_(resolve_filename)(res));
1721
}
2120
}
1722
2121
1723
PRE(fcntl)
2122
PRE(fcntl)
Lines 1729-1736 Link Here
1729
POST(fcntl)
2128
POST(fcntl)
1730
{
2129
{
1731
   if (arg2 == VKI_F_DUPFD)
2130
   if (arg2 == VKI_F_DUPFD)
1732
      if(VG_(clo_track_fds))
2131
      if (VG_(clo_track_fds))
1733
         record_fd_open(tid, res, resolve_fname(res));
2132
         record_fd_open(tid, res, VG_(resolve_filename)(res));
1734
}
2133
}
1735
2134
1736
PRE(fchdir)
2135
PRE(fchdir)
Lines 1763-1769 Link Here
1763
{
2162
{
1764
   if (arg2 == VKI_F_DUPFD)
2163
   if (arg2 == VKI_F_DUPFD)
1765
      if(VG_(clo_track_fds))
2164
      if(VG_(clo_track_fds))
1766
         record_fd_open(tid, res, resolve_fname(res));
2165
         record_fd_open(tid, res, VG_(resolve_filename)(res));
1767
}
2166
}
1768
2167
1769
PRE(fstat)
2168
PRE(fstat)
Lines 1821-1826 Link Here
1821
   }
2220
   }
1822
}
2221
}
1823
2222
2223
PRE(clone)
2224
{
2225
   MAYBE_PRINTF("clone ( %d, %p, %p, %p, %p )\n",arg1,arg2,arg3,arg4,arg5);
2226
2227
   if (arg2 == 0 &&
2228
       arg1 == (VKI_CLONE_CHILD_CLEARTID|VKI_CLONE_CHILD_SETTID|VKI_SIGCHLD)) {
2229
      before_fork(tid, tst);
2230
      res = VG_(do_syscall)(SYSNO, arg1, arg2, arg3, arg4, arg5);
2231
      after_fork(tid, tst);
2232
   } else {
2233
      VG_(unimplemented)
2234
         ("clone(): not supported by Valgrind.\n   "
2235
          "We do now support programs linked against\n   "
2236
          "libpthread.so, though.  Re-run with -v and ensure that\n   "
2237
          "you are picking up Valgrind's implementation of libpthread.so.");
2238
   }
2239
}
2240
1824
PRE(fsync)
2241
PRE(fsync)
1825
{
2242
{
1826
   /* int fsync(int fd); */
2243
   /* int fsync(int fd); */
Lines 2176-2184 Link Here
2176
   }
2593
   }
2177
   case 21: /* IPCOP_shmat */
2594
   case 21: /* IPCOP_shmat */
2178
   {
2595
   {
2596
      UInt shmid = arg2;
2597
      UInt segmentSize = get_shm_size ( shmid );
2598
      
2599
      /* If they didn't ask for a particular address, then place it
2600
	 like an mmap. */
2601
      if (arg5 == 0)
2602
	 arg5 = VG_(find_map_space)(0, segmentSize, True);
2603
      else if (!valid_client_addr(arg5, segmentSize, tid, "shmat"))
2604
	 res = -VKI_EINVAL;
2179
      break;
2605
      break;
2180
   }
2606
   }
2181
   case 22: /* IPCOP_shmdt */
2607
   case 22: /* IPCOP_shmdt */
2608
      if (!valid_client_addr(arg1, 1, tid, "shmdt"))
2609
	 res = -VKI_EINVAL;
2182
      break;
2610
      break;
2183
   case 23: /* IPCOP_shmget */
2611
   case 23: /* IPCOP_shmget */
2184
      break;
2612
      break;
Lines 2287-2296 Link Here
2287
   case 21: /* IPCOP_shmat */
2715
   case 21: /* IPCOP_shmat */
2288
   {
2716
   {
2289
      Int shmid = arg2;
2717
      Int shmid = arg2;
2290
      /*Int shmflag = arg3;*/
2718
      Int shmflag = arg3;
2291
      Addr addr;
2719
      Addr addr;
2292
2720
2293
                  
2294
      /* force readability. before the syscall it is
2721
      /* force readability. before the syscall it is
2295
       * indeed uninitialized, as can be seen in
2722
       * indeed uninitialized, as can be seen in
2296
       * glibc/sysdeps/unix/sysv/linux/shmat.c */
2723
       * glibc/sysdeps/unix/sysv/linux/shmat.c */
Lines 2300-2320 Link Here
2300
      if ( addr > 0 ) { 
2727
      if ( addr > 0 ) { 
2301
	 UInt segmentSize = get_shm_size ( shmid );
2728
	 UInt segmentSize = get_shm_size ( shmid );
2302
	 if ( segmentSize > 0 ) {
2729
	 if ( segmentSize > 0 ) {
2730
	    UInt prot;
2303
	    /* we don't distinguish whether it's read-only or
2731
	    /* we don't distinguish whether it's read-only or
2304
	     * read-write -- it doesn't matter really. */
2732
	     * read-write -- it doesn't matter really. */
2305
	    VG_TRACK( new_mem_mmap, addr, segmentSize, 
2733
	    VG_TRACK( new_mem_mmap, addr, segmentSize, 
2306
		      True, True, False );
2734
		      True, True, False );
2735
2736
	    prot = VKI_PROT_READ|VKI_PROT_WRITE;
2737
	    if (!(shmflag & 010000)) /* = SHM_RDONLY */
2738
	       prot &= ~VKI_PROT_WRITE;
2739
	    VG_(map_segment)(addr, segmentSize, prot,
2740
			     SF_SHARED | SF_SHM);
2307
	 }
2741
	 }
2308
      }
2742
      }
2309
      break;
2743
      break;
2310
   }
2744
   }
2311
   case 22: /* IPCOP_shmdt */
2745
   case 22: /* IPCOP_shmdt */
2312
      /* ### FIXME: this should call make_noaccess on the
2746
   {
2313
       * area passed to shmdt. But there's no way to
2747
      Segment *s = VG_(find_segment)(arg1);
2314
       * figure out the size of the shared memory segment
2748
2315
       * just from the address...  Maybe we want to keep a
2749
      if (s != NULL && (s->flags & SF_SHM) && VG_(seg_contains)(s, arg1, 1)) {
2316
       * copy of the exiting mappings inside valgrind? */
2750
	 VG_TRACK( die_mem_munmap, s->addr, s->len );
2751
	 VG_(unmap_range)(s->addr, s->len);
2752
      }
2317
      break;
2753
      break;
2754
   }
2318
   case 23: /* IPCOP_shmget */
2755
   case 23: /* IPCOP_shmget */
2319
      break;
2756
      break;
2320
   case 24: /* IPCOP_shmctl */
2757
   case 24: /* IPCOP_shmctl */
Lines 3173-3179 Link Here
3173
PRE(lstat)
3610
PRE(lstat)
3174
{
3611
{
3175
   /* int lstat(const char *file_name, struct stat *buf); */
3612
   /* int lstat(const char *file_name, struct stat *buf); */
3176
   MAYBE_PRINTF("lstat ( %p, %p )\n",arg1,arg2);
3613
   MAYBE_PRINTF("lstat ( %p \"%s\", %p )\n",arg1,arg1,arg2);
3177
   SYSCALL_TRACK( pre_mem_read_asciiz, tid, "lstat(file_name)", arg1 );
3614
   SYSCALL_TRACK( pre_mem_read_asciiz, tid, "lstat(file_name)", arg1 );
3178
   SYSCALL_TRACK( pre_mem_write, tid, "lstat(buf)", arg2, 
3615
   SYSCALL_TRACK( pre_mem_write, tid, "lstat(buf)", arg2, 
3179
		  sizeof(struct stat) );
3616
		  sizeof(struct stat) );
Lines 3189-3195 Link Here
3189
PRE(lstat64)
3626
PRE(lstat64)
3190
{
3627
{
3191
   /* int lstat64(const char *file_name, struct stat64 *buf); */
3628
   /* int lstat64(const char *file_name, struct stat64 *buf); */
3192
   MAYBE_PRINTF("lstat64 ( %p, %p )\n",arg1,arg2);
3629
   MAYBE_PRINTF("lstat64 ( %p \"%s\", %p )\n",arg1,arg1,arg2);
3193
   SYSCALL_TRACK( pre_mem_read_asciiz, tid, "lstat64(file_name)", arg1 );
3630
   SYSCALL_TRACK( pre_mem_read_asciiz, tid, "lstat64(file_name)", arg1 );
3194
   SYSCALL_TRACK( pre_mem_write, tid, "lstat64(buf)", arg2, 
3631
   SYSCALL_TRACK( pre_mem_write, tid, "lstat64(buf)", arg2, 
3195
		  sizeof(struct stat64) );
3632
		  sizeof(struct stat64) );
Lines 3209-3239 Link Here
3209
   SYSCALL_TRACK( pre_mem_read_asciiz, tid, "mkdir(pathname)", arg1 );
3646
   SYSCALL_TRACK( pre_mem_read_asciiz, tid, "mkdir(pathname)", arg1 );
3210
}
3647
}
3211
3648
3212
void check_mmap_start(ThreadState* tst, Addr start, Int flags)
3213
{
3214
   /* Refuse to mmap the first 64KB of memory, so that the cheap sanity test 
3215
      for tools using shadow memory works. */
3216
   if (start < 65536 && (flags & VKI_MAP_FIXED))
3217
      tst->m_eax = -VKI_EINVAL;
3218
}
3219
3220
PRE(mmap2)
3649
PRE(mmap2)
3221
{
3650
{
3222
   /* My impression is that this is exactly like __NR_mmap 
3651
   /* My impression is that this is exactly like __NR_mmap 
3223
      except that all 6 args are passed in regs, rather than in 
3652
      except that all 6 args are passed in regs, rather than in 
3224
      a memory-block. */
3653
      a memory-block.
3654
      
3655
      Almost.  The big difference is that the file offset is specified
3656
      in pagesize units rather than bytes, so that it can be used for
3657
      files bigger than 2^32 bytes. - JSGF
3658
   */
3225
   /* void* mmap(void *start, size_t length, int prot, 
3659
   /* void* mmap(void *start, size_t length, int prot, 
3226
      int flags, int fd, off_t offset); 
3660
      int flags, int fd, off_t offset); 
3227
   */
3661
   */
3228
   MAYBE_PRINTF("mmap2 ( %p, %d, %d, %d, %d, %d )\n",
3662
   MAYBE_PRINTF("mmap2 ( %p, %d, %d, %d, %d, %d )\n",
3229
		arg1, arg2, arg3, arg4, arg5, arg6 );
3663
		arg1, arg2, arg3, arg4, arg5, arg6 );
3230
3664
3231
   check_mmap_start(tst, arg1, arg4);
3665
   if (arg4 & VKI_MAP_FIXED) {
3666
      if (!valid_client_addr(arg1, arg2, tid, "mmap2"))
3667
	 res = -VKI_ENOMEM;
3668
   } else {
3669
      arg1 = VG_(find_map_space)(arg1, arg2, True);
3670
      arg4 |= VKI_MAP_FIXED;
3671
      if (arg1 == 0)
3672
	 res = -VKI_ENOMEM;
3673
   }
3232
}
3674
}
3233
3675
3234
POST(mmap2)
3676
POST(mmap2)
3235
{
3677
{
3236
   mmap_segment( (Addr)res, arg2, arg3, arg5 );
3678
   if (!VG_(is_kerror)(res)) {
3679
      if (!valid_client_addr(res, arg2, tid, "mmap2")) {
3680
         VG_(munmap)((void *)res, arg2);
3681
         res = -VKI_ENOMEM;
3682
      } else
3683
         mmap_segment( (Addr)res, arg2, arg3, arg4, arg5, arg6 * (ULong)VKI_BYTES_PER_PAGE );
3684
   }
3237
}
3685
}
3238
3686
3239
PRE(mmap)
3687
PRE(mmap)
Lines 3256-3274 Link Here
3256
   MAYBE_PRINTF("mmap ( %p, %d, %d, %d, %d, %d )\n",
3704
   MAYBE_PRINTF("mmap ( %p, %d, %d, %d, %d, %d )\n",
3257
		a1, a2, a3, a4, a5, a6 );
3705
		a1, a2, a3, a4, a5, a6 );
3258
3706
3259
   check_mmap_start(tst, a1, a4);
3707
   if (a4 & VKI_MAP_FIXED) {
3260
}
3708
      if (!valid_client_addr(a1, a2, tid, "mmap")) {
3261
3709
	 MAYBE_PRINTF("mmap failing: %p-%p\n", a1, a1+a2);
3262
POST(mmap)
3710
	 res = -VKI_ENOMEM;
3263
{
3711
      }
3264
   UInt* arg_block = (UInt*)arg1;
3712
   } else {
3265
   UInt a2, a3, a5;
3713
      a1 = VG_(find_map_space)(arg_block[0], arg_block[1], True);
3266
3714
      if (a1 == 0)
3267
   a2 = arg_block[1];
3715
	 res = -VKI_ENOMEM;
3268
   a3 = arg_block[2];
3716
      else
3269
   a5 = arg_block[4];
3717
	 a4 |= VKI_MAP_FIXED;
3718
   }
3719
3720
   if (res != -VKI_ENOMEM) {
3721
      UInt new_arg_block[6];
3722
3723
      new_arg_block[0] = a1;
3724
      new_arg_block[1] = a2;
3725
      new_arg_block[2] = a3;
3726
      new_arg_block[3] = a4;
3727
      new_arg_block[4] = a5;
3728
      new_arg_block[5] = a6;
3729
      
3730
      res = VG_(do_syscall)(__NR_mmap, new_arg_block);
3270
3731
3271
   mmap_segment( (Addr)res, a2, a3, a5 );
3732
      if (!VG_(is_kerror)(res)) {
3733
         if (!valid_client_addr(res, a2, tid, "mmap")) {
3734
	    VG_(munmap)((void *)res, a2);
3735
	    res = -VKI_ENOMEM;
3736
         } else
3737
	    mmap_segment( (Addr)res, a2, a3, a4, a5, a6 );
3738
      }
3739
   }
3272
}
3740
}
3273
3741
3274
PRE(mprotect)
3742
PRE(mprotect)
Lines 3276-3281 Link Here
3276
   /* int mprotect(const void *addr, size_t len, int prot); */
3744
   /* int mprotect(const void *addr, size_t len, int prot); */
3277
   /* should addr .. addr+len-1 be checked before the call? */
3745
   /* should addr .. addr+len-1 be checked before the call? */
3278
   MAYBE_PRINTF("mprotect ( %p, %d, %d )\n", arg1,arg2,arg3);
3746
   MAYBE_PRINTF("mprotect ( %p, %d, %d )\n", arg1,arg2,arg3);
3747
3748
   if (!valid_client_addr(arg1, arg2, tid, "mprotect"))
3749
      res = -VKI_ENOMEM;
3279
}
3750
}
3280
3751
3281
POST(mprotect)
3752
POST(mprotect)
Lines 3288-3293 Link Here
3288
   /* int munmap(void *start, size_t length); */
3759
   /* int munmap(void *start, size_t length); */
3289
   /* should start .. start+length-1 be checked before the call? */
3760
   /* should start .. start+length-1 be checked before the call? */
3290
   MAYBE_PRINTF("munmap ( %p, %d )\n", arg1,arg2);
3761
   MAYBE_PRINTF("munmap ( %p, %d )\n", arg1,arg2);
3762
3763
   if (!valid_client_addr(arg1, arg2, tid, "munmap"))
3764
      res = -VKI_EINVAL;
3291
}
3765
}
3292
3766
3293
POST(munmap)
3767
POST(munmap)
Lines 3295-3300 Link Here
3295
   munmap_segment( arg1, arg2 );
3769
   munmap_segment( arg1, arg2 );
3296
}
3770
}
3297
3771
3772
PRE(mincore)
3773
{
3774
   /* int mincore(void *start, size_t length, unsigned char *vec); */
3775
   MAYBE_PRINTF("mincore ( %p, %d, %p )\n", arg1,arg2,arg3);
3776
   SYSCALL_TRACK(pre_mem_write, tid, "mincore(vec)",
3777
                 arg3, (arg2 + 4096 - 1) / 4096);
3778
}
3779
3780
POST(mincore)
3781
{
3782
   if (!VG_(is_kerror)(res))
3783
      VG_TRACK( post_mem_write, arg3, (arg2 + 4096 - 1) / 4096 );  
3784
}
3785
3298
PRE(nanosleep)
3786
PRE(nanosleep)
3299
{
3787
{
3300
         /* int nanosleep(const struct timespec *req, struct timespec *rem); */
3788
         /* int nanosleep(const struct timespec *req, struct timespec *rem); */
Lines 3350-3356 Link Here
3350
      res = -VKI_EMFILE;
3838
      res = -VKI_EMFILE;
3351
   } else {
3839
   } else {
3352
      if(VG_(clo_track_fds))
3840
      if(VG_(clo_track_fds))
3353
         record_fd_open(tid, res, VG_(strdup)((Char*)arg1));
3841
         record_fd_open(tid, res, VG_(arena_strdup)(VG_AR_CORE, (Char*)arg1));
3354
   }
3842
   }
3355
   MAYBE_PRINTF("%d\n",res);
3843
   MAYBE_PRINTF("%d\n",res);
3356
}
3844
}
Lines 3394-3400 Link Here
3394
      res = -VKI_EMFILE;
3882
      res = -VKI_EMFILE;
3395
   } else {
3883
   } else {
3396
      if(VG_(clo_track_fds))
3884
      if(VG_(clo_track_fds))
3397
         record_fd_open(tid, res, VG_(strdup)((Char*)arg1));
3885
         record_fd_open(tid, res, VG_(arena_strdup)(VG_AR_CORE, (Char*)arg1));
3398
   }
3886
   }
3399
   MAYBE_PRINTF("%d\n",res);
3887
   MAYBE_PRINTF("%d\n",res);
3400
}
3888
}
Lines 3457-3462 Link Here
3457
   }
3945
   }
3458
}
3946
}
3459
3947
3948
PRE(epoll_create)
3949
{
3950
   /* int epoll_create(int size) */
3951
   MAYBE_PRINTF("epoll_create ( %d )\n", arg1);
3952
}
3953
3954
POST(epoll_create)
3955
{
3956
   if (!fd_allowed(res, "open", tid)) {
3957
      VG_(close)(res);
3958
      res = -VKI_EMFILE;
3959
   } else {
3960
      if (VG_(clo_track_fds))
3961
         record_fd_open (tid, res, NULL);
3962
   }
3963
}
3964
3965
PRE(epoll_ctl)
3966
{
3967
   /* int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) */
3968
   static const char* epoll_ctl_s[3] = {
3969
      "EPOLL_CTL_ADD",
3970
      "EPOLL_CTL_DEL",
3971
      "EPOLL_CTL_MOD"
3972
   };
3973
   MAYBE_PRINTF("epoll_ctl ( %d, %s, %d, %p )\n", 
3974
                arg1, ( arg2<3 ? epoll_ctl_s[arg2] : "?" ), arg3, arg4);
3975
   SYSCALL_TRACK( pre_mem_read, tid, "epoll_ctl(event)",
3976
                  arg4, sizeof(struct vki_epoll_event) );
3977
}
3978
3979
PRE(epoll_wait)
3980
{
3981
   /* int epoll_wait(int epfd, struct epoll_event * events, 
3982
                     int maxevents, int timeout) */
3983
   MAYBE_PRINTF("epoll_wait ( %d, %p, %d, %d )\n", arg1, arg2, arg3, arg4);
3984
   SYSCALL_TRACK( pre_mem_write, tid, "epoll_wait(events)",
3985
                  arg2, sizeof(struct vki_epoll_event)*arg3);
3986
}
3987
3988
POST(epoll_wait)
3989
{
3990
   if (res > 0)
3991
      VG_TRACK( post_mem_write, arg2, sizeof(struct vki_epoll_event)*res ) ;
3992
}
3993
3460
PRE(readlink)
3994
PRE(readlink)
3461
{
3995
{
3462
   /* int readlink(const char *path, char *buf, size_t bufsiz); */
3996
   /* int readlink(const char *path, char *buf, size_t bufsiz); */
Lines 3917-3923 Link Here
3917
   switch (arg1 /* request */) {
4451
   switch (arg1 /* request */) {
3918
4452
3919
   case SYS_SOCKETPAIR:
4453
   case SYS_SOCKETPAIR:
3920
      /* XXX TODO: check return fd against VG_MAX_FD */
4454
      /* XXX TODO: check return fd against VG_(max_fd) */
3921
      VG_TRACK( post_mem_write, ((UInt*)arg2)[3], 2*sizeof(int) );
4455
      VG_TRACK( post_mem_write, ((UInt*)arg2)[3], 2*sizeof(int) );
3922
      if(VG_(clo_track_fds)) {
4456
      if(VG_(clo_track_fds)) {
3923
         record_fd_open(tid, ((UInt*)((UInt*)arg2)[3])[0], NULL);
4457
         record_fd_open(tid, ((UInt*)((UInt*)arg2)[3])[0], NULL);
Lines 4174-4180 Link Here
4174
PRE(truncate)
4708
PRE(truncate)
4175
{
4709
{
4176
   /* int truncate(const char *path, size_t length); */
4710
   /* int truncate(const char *path, size_t length); */
4177
   MAYBE_PRINTF("truncate ( %p, %d )\n", arg1,arg2);
4711
   MAYBE_PRINTF("truncate ( %p \"%s\", %d )\n", arg1,arg1,arg2);
4178
   SYSCALL_TRACK( pre_mem_read_asciiz, tid, "truncate(path)", arg1 );
4712
   SYSCALL_TRACK( pre_mem_read_asciiz, tid, "truncate(path)", arg1 );
4179
}
4713
}
4180
4714
Lines 4187-4193 Link Here
4187
PRE(unlink)
4721
PRE(unlink)
4188
{
4722
{
4189
   /* int unlink(const char *pathname) */
4723
   /* int unlink(const char *pathname) */
4190
   MAYBE_PRINTF("ulink ( %p )\n",arg1);
4724
   MAYBE_PRINTF("unlink ( %p \"%s\" )\n",arg1, arg1);
4191
   SYSCALL_TRACK( pre_mem_read_asciiz, tid, "unlink(pathname)", arg1 );
4725
   SYSCALL_TRACK( pre_mem_read_asciiz, tid, "unlink(pathname)", arg1 );
4192
}
4726
}
4193
4727
Lines 4336-4341 Link Here
4336
                       sizeof(struct timeval) );
4870
                       sizeof(struct timeval) );
4337
}
4871
}
4338
4872
4873
PRE(futex)
4874
{
4875
    /* int futex(void *futex, int op, int val, const struct timespec *timeout); */
4876
    MAYBE_PRINTF("futex ( %p, %d, %d, %p, %p )\n", arg1,arg2,arg3,arg4,arg5);
4877
    SYSCALL_TRACK( pre_mem_read, tid, "futex(futex)", arg1, sizeof(int) );
4878
    if (arg2 == VKI_FUTEX_WAIT && arg4 != (UInt)NULL)
4879
       SYSCALL_TRACK( pre_mem_read, tid, "futex(timeout)", arg4,
4880
                      sizeof(struct timespec) );
4881
    if (arg2 == VKI_FUTEX_REQUEUE)
4882
       SYSCALL_TRACK( pre_mem_read, tid, "futex(futex2)", arg4, sizeof(int) );
4883
}
4884
4885
POST(futex)
4886
{
4887
   if (!VG_(is_kerror)(res)) {
4888
      VG_TRACK( post_mem_write, arg1, sizeof(int) );
4889
      if (arg2 == VKI_FUTEX_FD && VG_(clo_track_fds))
4890
         record_fd_open(tid, res, NULL);
4891
   }
4892
}
4893
4339
#define SIGNAL_SIMULATION	1
4894
#define SIGNAL_SIMULATION	1
4340
4895
4341
PRE(pause)
4896
PRE(pause)
Lines 4511-4516 Link Here
4511
{
5066
{
4512
   VG_(message)
5067
   VG_(message)
4513
      (Vg_DebugMsg,"WARNING: unhandled syscall: %d", tst->m_eax);
5068
      (Vg_DebugMsg,"WARNING: unhandled syscall: %d", tst->m_eax);
5069
   if (VG_(clo_verbosity) > 1) {
5070
      ExeContext *ec = VG_(get_ExeContext)(tid);
5071
      VG_(pp_ExeContext)(ec);
5072
   }
4514
   VG_(message)
5073
   VG_(message)
4515
      (Vg_DebugMsg,"Do not panic.  You may be able to fix this easily.");
5074
      (Vg_DebugMsg,"Do not panic.  You may be able to fix this easily.");
4516
   VG_(message)
5075
   VG_(message)
Lines 4532-4539 Link Here
4532
   SYSB_(clone,			False),
5091
   SYSB_(clone,			False),
4533
5092
4534
   SYSB_(modify_ldt,		False),
5093
   SYSB_(modify_ldt,		False),
5094
   SYSB_(set_thread_area,	False),
5095
   SYSB_(get_thread_area,	False),
4535
5096
4536
   SYSB_(execve,		False),
5097
   SYSB_(execve,		False),
5098
   SYSB_(brk,			False),
5099
   SYSB_(mmap,			False),
5100
   SYSB_(mremap,		False),
4537
5101
4538
#if SIGNAL_SIMULATION
5102
#if SIGNAL_SIMULATION
4539
   SYSBA(sigaltstack,		False),
5103
   SYSBA(sigaltstack,		False),
Lines 4581-4587 Link Here
4581
   SYSB_(personality,		False),
5145
   SYSB_(personality,		False),
4582
   SYSB_(chroot,		False),
5146
   SYSB_(chroot,		False),
4583
   SYSB_(madvise,		True),
5147
   SYSB_(madvise,		True),
4584
   SYSBA(mremap,		False),
4585
   SYSB_(nice,			False),
5148
   SYSB_(nice,			False),
4586
   SYSB_(setresgid32,		False),
5149
   SYSB_(setresgid32,		False),
4587
   SYSB_(setfsuid32,		False),
5150
   SYSB_(setfsuid32,		False),
Lines 4620-4626 Link Here
4620
   SYSBA(capget,		False),
5183
   SYSBA(capget,		False),
4621
   SYSB_(capset,		False),
5184
   SYSB_(capset,		False),
4622
   SYSB_(access,		False),
5185
   SYSB_(access,		False),
4623
   SYSBA(brk,			False),
4624
   SYSB_(chdir,			False),
5186
   SYSB_(chdir,			False),
4625
   SYSB_(chmod,			False),
5187
   SYSB_(chmod,			False),
4626
   SYSB_(chown32,		False),
5188
   SYSB_(chown32,		False),
Lines 4674-4683 Link Here
4674
   SYSBA(lstat,			False),
5236
   SYSBA(lstat,			False),
4675
   SYSBA(lstat64,		False),
5237
   SYSBA(lstat64,		False),
4676
   SYSB_(mkdir,			True),
5238
   SYSB_(mkdir,			True),
4677
   SYSBA(mmap2,			False),
4678
   SYSBA(mmap,			False),
4679
   SYSBA(mprotect,		False),
5239
   SYSBA(mprotect,		False),
4680
   SYSBA(munmap,		False),
5240
   SYSBA(munmap,		False),
5241
   SYSBA(mincore,		False),
4681
   SYSBA(nanosleep,		True),
5242
   SYSBA(nanosleep,		True),
4682
   SYSB_(_newselect,		True),
5243
   SYSB_(_newselect,		True),
4683
   SYSBA(open,			True),
5244
   SYSBA(open,			True),
Lines 4686-4691 Link Here
4686
   SYSBA(creat,			True),
5247
   SYSBA(creat,			True),
4687
   SYSBA(pipe,			False),
5248
   SYSBA(pipe,			False),
4688
   SYSBA(poll,			True),
5249
   SYSBA(poll,			True),
5250
   SYSBA(epoll_create,          False),
5251
   SYSB_(epoll_ctl,             False),
5252
   SYSBA(epoll_wait,		True),
4689
   SYSBA(readlink,		False),
5253
   SYSBA(readlink,		False),
4690
   SYSBA(readv,			True),
5254
   SYSBA(readv,			True),
4691
   SYSB_(rename,		False),
5255
   SYSB_(rename,		False),
Lines 4729-4735 Link Here
4729
   SYSB_(writev,		True),
5293
   SYSB_(writev,		True),
4730
   SYSB_(prctl,			True),
5294
   SYSB_(prctl,			True),
4731
   SYSBA(adjtimex,		False),
5295
   SYSBA(adjtimex,		False),
5296
   SYSBA(mmap2,			False),
4732
   SYSBA(clock_gettime,         False),
5297
   SYSBA(clock_gettime,         False),
5298
   SYSBA(futex,                 True),
4733
5299
4734
   /* new signal handling makes these normal blocking syscalls */
5300
   /* new signal handling makes these normal blocking syscalls */
4735
   SYSB_(pause,			True),
5301
   SYSB_(pause,			True),
Lines 4869-4880 Link Here
4869
}
5435
}
4870
5436
4871
5437
4872
void VG_(post_syscall) ( ThreadId tid )
5438
void VG_(post_syscall) ( ThreadId tid, Bool restart )
4873
{
5439
{
4874
   ThreadState* tst;
5440
   ThreadState* tst;
4875
   UInt syscallno;
5441
   UInt syscallno;
4876
   const struct sys_info *sys;
5442
   const struct sys_info *sys;
4877
   Bool special = False;
5443
   Bool special = False;
5444
   Bool restarted = False;
4878
   void *pre_res;
5445
   void *pre_res;
4879
5446
4880
   VGP_PUSHCC(VgpCoreSysWrap);
5447
   VGP_PUSHCC(VgpCoreSysWrap);
Lines 4899-4925 Link Here
4899
      special = True;
5466
      special = True;
4900
   }
5467
   }
4901
5468
4902
   if (!VG_(is_kerror)(tst->m_eax) && sys->after != NULL)
4903
      (sys->after)(tst->tid, tst);
4904
4905
   /* Do any post-syscall actions */
4906
   if (VG_(needs).syscall_wrapper) {
4907
      VGP_PUSHCC(VgpSkinSysWrap);
4908
      SK_(post_syscall)(tid, syscallno, pre_res, tst->m_eax, /*isBlocking*/True); // did block
4909
      VGP_POPCC(VgpSkinSysWrap);
4910
   }
4911
4912
   if (tst->m_eax == -VKI_ERESTARTSYS) {
5469
   if (tst->m_eax == -VKI_ERESTARTSYS) {
4913
      /* Applications never expect to see this, so we should actually
5470
      /* Applications never expect to see this, so we should either
4914
	 restart the syscall (it means the signal happened before the
5471
	 restart the syscall or fail it with EINTR, depending on what
4915
	 syscall made any progress, so we can safely restart it and
5472
	 our caller wants.  Generally they'll want to restart, but if
4916
	 pretend the signal happened before the syscall even
5473
	 client set the signal state to not restart, then we fail with
4917
	 started)  */
5474
	 EINTR.  Either way, ERESTARTSYS means the syscall made no
4918
      VG_(restart_syscall)(tid);
5475
	 progress, and so can be failed or restarted without
5476
	 consequence. */
5477
      if (0)
5478
	 VG_(printf)("syscall %d returned ERESTARTSYS; restart=%d\n",
5479
		     syscallno, restart);
5480
5481
      if (restart) {
5482
	 restarted = True;
5483
	 VG_(restart_syscall)(tid);
5484
      } else
5485
	 tst->m_eax = -VKI_EINTR;
5486
   } 
5487
5488
   if (!restarted) {
5489
      if (!VG_(is_kerror)(tst->m_eax) && sys->after != NULL)
5490
	 (sys->after)(tst->tid, tst);
5491
5492
      /* Do any post-syscall actions
5493
5494
	 NOTE: this is only called if the syscall completed.  If the
5495
	 syscall was restarted, then it will call the Tool's
5496
	 pre_syscall again, without calling post_syscall (ie, more
5497
	 pre's than post's)
5498
       */
5499
      if (VG_(needs).syscall_wrapper) {
5500
	 VGP_PUSHCC(VgpSkinSysWrap);
5501
	 SK_(post_syscall)(tid, syscallno, pre_res, tst->m_eax, /*isBlocking*/True); // did block
5502
	 VGP_POPCC(VgpSkinSysWrap);
5503
      }
4919
   }
5504
   }
4920
5505
4921
   tst->status = VgTs_Runnable;	/* runnable again */
5506
   tst->status = VgTs_Runnable;	/* runnable again */
4922
   tst->syscallno = -1;
5507
   tst->syscallno = -1;		/* no current syscall */
4923
5508
4924
   VGP_POPCC(VgpCoreSysWrap);
5509
   VGP_POPCC(VgpCoreSysWrap);
4925
}
5510
}
(-)valgrind-2.1.0/coregrind/vg_to_ucode.c (-789 / +1548 lines)
Lines 1-4 Link Here
1
/* -*- c-basic-offset: 3 -*- */
1
2
/*--------------------------------------------------------------------*/
2
/*--------------------------------------------------------------------*/
3
/*--- The JITter: translate x86 code to ucode.                     ---*/
3
/*--- The JITter: translate x86 code to ucode.                     ---*/
4
/*---                                                vg_to_ucode.c ---*/
4
/*---                                                vg_to_ucode.c ---*/
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 33-42 Link Here
33
33
34
34
35
/*------------------------------------------------------------*/
35
/*------------------------------------------------------------*/
36
/*--- Renamings of frequently-used global functions.       ---*/
36
/*--- Debugging output                                     ---*/
37
/*------------------------------------------------------------*/
38
39
#define DIP(format, args...)  \
40
   if (VG_(print_codegen))        \
41
      VG_(printf)(format, ## args)
42
43
#define DIS(buf, format, args...)  \
44
   if (VG_(print_codegen))        \
45
      VG_(sprintf)(buf, format, ## args)
46
47
/*------------------------------------------------------------*/
48
/*--- CPU feature set stuff                                ---*/
49
/*--- This is a little out of place here, but it will do   ---*/
50
/*--- for now.                                             ---*/
37
/*------------------------------------------------------------*/
51
/*------------------------------------------------------------*/
38
52
39
#define dis       VG_(print_codegen)
53
#define VG_CPU_VENDOR_GENERIC	0
54
#define VG_CPU_VENDOR_INTEL	1
55
#define VG_CPU_VENDOR_AMD	2
56
57
static Int cpu_vendor = VG_CPU_VENDOR_GENERIC;
58
59
static const struct cpu_vendor {
60
	const Char *vendorstr;
61
	Int	    vendorid;
62
} cpu_vendors[] = {
63
	{ "GenuineIntel", VG_CPU_VENDOR_INTEL },
64
	{ "AuthenticAMD", VG_CPU_VENDOR_AMD },
65
};
66
67
static Int cpuid_level = -2;	/* -2 -> not initialized */
68
static UInt cpu_features[VG_N_FEATURE_WORDS];
69
70
/* Standard macro to see if a specific flag is changeable */
71
static inline Bool flag_is_changeable(UInt flag)
72
{
73
   UInt f1, f2;
74
75
   asm("pushfl\n\t"
76
       "pushfl\n\t"
77
       "popl %0\n\t"
78
       "movl %0,%1\n\t"
79
       "xorl %2,%0\n\t"
80
       "pushl %0\n\t"
81
       "popfl\n\t"
82
       "pushfl\n\t"
83
       "popl %0\n\t"
84
       "popfl\n\t"
85
       : "=&r" (f1), "=&r" (f2)
86
       : "ir" (flag));
87
88
   return ((f1^f2) & flag) != 0;
89
}
90
91
92
/* Probe for the CPUID instruction */
93
static Bool has_cpuid(void)
94
{
95
   return flag_is_changeable(EFlagID);
96
}
97
98
static inline UInt cpuid_eax(UInt eax)
99
{
100
   asm("cpuid" : "=a" (eax) : "0" (eax) : "bx", "cx", "dx");
101
   return eax;
102
}
103
104
static inline void cpuid(UInt eax, 
105
			 UInt *eax_ret, UInt *ebx_ret, UInt *ecx_ret, UInt *edx_ret)
106
{
107
   UInt ebx, ecx, edx;
108
109
   asm("cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : "0" (eax));
110
111
   if (eax_ret)
112
      *eax_ret = eax;
113
   if (ebx_ret)
114
      *ebx_ret = ebx;
115
   if (ecx_ret)
116
      *ecx_ret = ecx;
117
   if (edx_ret)
118
      *edx_ret = edx;
119
}
120
121
static void get_cpu_features(void)
122
{
123
   Char vendorstr[13];
124
   Int i;
125
126
   if (!has_cpuid()) {
127
      cpuid_level = -1;
128
      return;
129
   }
130
131
   cpu_features[VG_INT_FEAT] |= (1 << (VG_X86_FEAT_CPUID%32));
132
133
   cpuid(0, &cpuid_level, (UInt *)&vendorstr[0], (UInt *)&vendorstr[8], (UInt *)&vendorstr[4]);
134
   vendorstr[12] = '\0';
135
136
   for(i = 0; i < sizeof(cpu_vendors)/sizeof(*cpu_vendors); i++)
137
      if (VG_(memcmp)(vendorstr, cpu_vendors[i].vendorstr, 12) == 0) {
138
	 cpu_vendor = cpu_vendors[i].vendorid;
139
	 break;
140
      }
141
142
   if (cpuid_level >= 1)
143
      cpuid(1, NULL, NULL, &cpu_features[VG_EXT_FEAT], &cpu_features[VG_X86_FEAT]);
144
145
   switch(cpu_vendor) {
146
   case VG_CPU_VENDOR_AMD:
147
      /* get AMD-specific flags */
148
      cpuid(0x80000001, NULL, NULL, NULL, &cpu_features[VG_AMD_FEAT]);
149
      break;
150
151
   default:
152
      break;
153
   }
154
}
155
156
Bool VG_(cpu_has_feature)(UInt feature)
157
{
158
   UInt word = feature / 32;
159
   UInt bit  = feature % 32;
160
161
   if (cpuid_level == -2)
162
      get_cpu_features();
163
164
   vg_assert(word >= 0 && word < VG_N_FEATURE_WORDS);
165
166
   return !!(cpu_features[word] & (1 << bit));
167
}
168
169
/* The set of features we're willing to support for the client
170
   
171
   This includes supported instruction set extensions, plus any
172
   extensions which don't have any user-mode visible effect (but the
173
   client may find interesting).
174
 */
175
#define VG_X86_SUPPORTED_FEATURES		\
176
	 ((1 << VG_X86_FEAT_FPU)	|	\
177
	  (1 << VG_X86_FEAT_VME)	|	\
178
	  (1 << VG_X86_FEAT_DE)		|	\
179
	  (1 << VG_X86_FEAT_PSE)	|	\
180
	  (1 << VG_X86_FEAT_TSC)	|	\
181
	  (0 << VG_X86_FEAT_MSR)	|	\
182
	  (1 << VG_X86_FEAT_PAE)	|	\
183
	  (1 << VG_X86_FEAT_MCE)	|	\
184
	  (1 << VG_X86_FEAT_CX8)	|	\
185
	  (1 << VG_X86_FEAT_APIC)	|	\
186
	  (0 << VG_X86_FEAT_SEP)	|	\
187
	  (1 << VG_X86_FEAT_MTRR)	|	\
188
	  (1 << VG_X86_FEAT_PGE)	|	\
189
	  (1 << VG_X86_FEAT_MCA)	|	\
190
	  (1 << VG_X86_FEAT_CMOV)	|	\
191
	  (1 << VG_X86_FEAT_PAT)	|	\
192
	  (1 << VG_X86_FEAT_PSE36)	|	\
193
	  (0 << VG_X86_FEAT_CLFSH)	|	\
194
	  (1 << VG_X86_FEAT_DS)		|	\
195
	  (1 << VG_X86_FEAT_ACPI)	|	\
196
	  (1 << VG_X86_FEAT_MMX)	|	\
197
	  (1 << VG_X86_FEAT_FXSR)	|	\
198
	  (1 << VG_X86_FEAT_SSE)	|	\
199
	  (1 << VG_X86_FEAT_SSE2)	|	\
200
	  (1 << VG_X86_FEAT_SS)		|	\
201
	  (1 << VG_X86_FEAT_HT)		|	\
202
	  (1 << VG_X86_FEAT_TM)		|	\
203
	  (0 << VG_X86_FEAT_IA64)	|	\
204
	  (1 << VG_X86_FEAT_PBE))
205
206
#define VG_AMD_SUPPORTED_FEATURES					\
207
	((0 << (VG_AMD_FEAT_SYSCALL % 32))	|			\
208
	 (0 << (VG_AMD_FEAT_NXP % 32))		|			\
209
	 (1 << (VG_AMD_FEAT_MMXEXT % 32))	|			\
210
	 (0 << (VG_AMD_FEAT_FFXSR % 32))	|			\
211
	 (0 << (VG_AMD_FEAT_LONGMODE % 32))	|			\
212
	 (0 << (VG_AMD_FEAT_3DNOWEXT % 32))	|			\
213
	 (0 << (VG_AMD_FEAT_3DNOW % 32))	|			\
214
	 /* Common bits between standard features and AMD features */	\
215
	 (1 << VG_X86_FEAT_FPU)		|				\
216
	 (1 << VG_X86_FEAT_VME)		|				\
217
	 (1 << VG_X86_FEAT_DE)		|				\
218
	 (1 << VG_X86_FEAT_PSE)		|				\
219
	 (1 << VG_X86_FEAT_TSC)		|				\
220
	 (0 << VG_X86_FEAT_MSR)		|				\
221
	 (1 << VG_X86_FEAT_PAE)		|				\
222
	 (1 << VG_X86_FEAT_MCE)		|				\
223
	 (1 << VG_X86_FEAT_CX8)		|				\
224
	 (1 << VG_X86_FEAT_APIC)	|				\
225
	 (1 << VG_X86_FEAT_MTRR)	|				\
226
	 (1 << VG_X86_FEAT_PGE)		|				\
227
	 (1 << VG_X86_FEAT_MCA)		|				\
228
	 (1 << VG_X86_FEAT_CMOV)	|				\
229
	 (1 << VG_X86_FEAT_PAT)		|				\
230
	 (1 << VG_X86_FEAT_PSE36)	|				\
231
	 (1 << VG_X86_FEAT_MMX)		|				\
232
	 (1 << VG_X86_FEAT_FXSR))
233
234
235
/*	
236
   For simulating the cpuid instruction, we will
237
   issue a "real" cpuid instruction and then mask out
238
   the bits of the features we do not support currently (3dnow mostly).
239
   We also claim to not support most CPUID operations.
240
	
241
   Dirk Mueller <mueller@kde.org>
242
243
   http://www.sandpile.org/ia32/cpuid.htm
244
245
   references: 
246
247
   pre-MMX pentium:
248
249
   <werner> cpuid words (0): 0x1 0x756e6547 0x6c65746e 0x49656e69
250
   <werner> cpuid words (1): 0x52b 0x0 0x0 0x1bf
251
252
   Updated to be more extensible about future vendor extensions and
253
   vendor-specific parts of CPUID.
254
*/
255
void VG_(helperc_CPUID)(UInt op, UInt *eax_ret, UInt *ebx_ret, UInt *ecx_ret, UInt *edx_ret)
256
{
257
   UInt eax, ebx, ecx, edx;
258
259
   if (cpuid_level == -2)
260
      get_cpu_features();	/* for cpu_vendor */
261
262
   cpuid(op, &eax, &ebx, &ecx, &edx);
263
264
   /* Common mangling */
265
   switch(op) {
266
   case 1:
267
      edx &= VG_X86_SUPPORTED_FEATURES;
268
      break;
269
270
   case 0xd8000000: {
271
      /* Implement some private information at 0xd8000000 */
272
      static const Char valgrind_vendor[] = "ValgrindVCPU";
273
274
      eax = 0xd8000000;		/* max request */
275
      ebx = *(UInt *)&valgrind_vendor[0];
276
      ecx = *(UInt *)&valgrind_vendor[8];
277
      edx = *(UInt *)&valgrind_vendor[4];
278
   }
279
      break;
280
   }
281
282
   /* Vendor-specific mangling of the results */
283
   switch(cpu_vendor) {
284
   case VG_CPU_VENDOR_INTEL:
285
      switch(op) {
286
      case 1:
287
	 ecx = 0;		/* mask out all extended features for now */
288
	 break;
289
290
      case 0x80000001:
291
	 ebx = ecx = edx = 0;
292
	 break;
293
      }
294
      break;
295
296
   case VG_CPU_VENDOR_AMD:
297
      switch(op) {
298
      case 0x80000001:
299
	 edx &= VG_AMD_SUPPORTED_FEATURES;
300
	 break;
301
      }
302
      break;
303
   }
304
305
   *eax_ret = eax;
306
   *ebx_ret = ebx;
307
   *ecx_ret = ecx;
308
   *edx_ret = edx;
309
}
40
310
41
311
42
/*------------------------------------------------------------*/
312
/*------------------------------------------------------------*/
Lines 259-265 Link Here
259
  return 0; /*notreached*/
529
  return 0; /*notreached*/
260
}
530
}
261
531
262
263
/*------------------------------------------------------------*/
532
/*------------------------------------------------------------*/
264
/*--- Flag-related helpers.                                ---*/
533
/*--- Flag-related helpers.                                ---*/
265
/*------------------------------------------------------------*/
534
/*------------------------------------------------------------*/
Lines 298-303 Link Here
298
   LAST_UINSTR(cb).cond = cond;
567
   LAST_UINSTR(cb).cond = cond;
299
}
568
}
300
569
570
/*------------------------------------------------------------*/
571
/*--- JMP helpers                                          ---*/
572
/*------------------------------------------------------------*/
573
574
static __inline__
575
void jmp_lit( UCodeBlock* cb, Addr d32 )
576
{
577
   uInstr1 (cb, JMP,   0, Literal, 0);
578
   uLiteral(cb, d32);
579
   uCond   (cb, CondAlways);
580
}
581
582
static __inline__
583
void jmp_treg( UCodeBlock* cb, Int t )
584
{
585
   uInstr1 (cb, JMP,   0, TempReg, t);
586
   uCond   (cb, CondAlways);
587
}
588
589
static __inline__
590
void jcc_lit( UCodeBlock* cb, Addr d32, Condcode cond )
591
{
592
   uInstr1  (cb, JMP, 0, Literal, 0);
593
   uLiteral (cb, d32);
594
   uCond    (cb, cond);
595
   uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
596
}
597
301
598
302
/*------------------------------------------------------------*/
599
/*------------------------------------------------------------*/
303
/*--- Disassembling addressing modes                       ---*/
600
/*--- Disassembling addressing modes                       ---*/
Lines 352-359 Link Here
352
   temporary, and the number of bytes in the address mode, are
649
   temporary, and the number of bytes in the address mode, are
353
   returned, as a pair (length << 24) | temp.  Note that this fn should
650
   returned, as a pair (length << 24) | temp.  Note that this fn should
354
   not be called if the R/M part of the address denotes a register
651
   not be called if the R/M part of the address denotes a register
355
   instead of memory.  If buf is non-NULL, text of the addressing mode
652
   instead of memory.  If VG_(print_codegen) is true, text of the addressing
356
   is placed therein. */
653
   mode is placed therein. */
357
654
358
static 
655
static 
359
UInt disAMode ( UCodeBlock* cb, UChar sorb, Addr eip0, UChar* buf )
656
UInt disAMode ( UCodeBlock* cb, UChar sorb, Addr eip0, UChar* buf )
Lines 378-385 Link Here
378
         { UChar rm  = mod_reg_rm;
675
         { UChar rm  = mod_reg_rm;
379
           uInstr2(cb, GET, 4, ArchReg, rm,  TempReg, tmp);
676
           uInstr2(cb, GET, 4, ArchReg, rm,  TempReg, tmp);
380
           handleSegOverride(cb, sorb, tmp);
677
           handleSegOverride(cb, sorb, tmp);
381
           if (buf) VG_(sprintf)(buf,"%s(%s)", sorbTxt(sorb), 
678
           DIS(buf, "%s(%s)", sorbTxt(sorb), nameIReg(4,rm));
382
                                               nameIReg(4,rm));
383
           return (1<<24 | tmp);
679
           return (1<<24 | tmp);
384
         }
680
         }
385
681
Lines 393-402 Link Here
393
           UInt  d   = getSDisp8((Addr)eip); eip++;
689
           UInt  d   = getSDisp8((Addr)eip); eip++;
394
           uInstr2(cb, GET,  4, ArchReg, rm,  TempReg, tmq);
690
           uInstr2(cb, GET,  4, ArchReg, rm,  TempReg, tmq);
395
           uInstr2(cb, LEA1, 4, TempReg, tmq, TempReg, tmp);
691
           uInstr2(cb, LEA1, 4, TempReg, tmq, TempReg, tmp);
396
           LAST_UINSTR(cb).lit32 = d;
692
           uLiteral(cb, d);
397
           handleSegOverride(cb, sorb, tmp);
693
           handleSegOverride(cb, sorb, tmp);
398
           if (buf) VG_(sprintf)(buf,"%s%d(%s)", sorbTxt(sorb), 
694
           DIS(buf, "%s%d(%s)", sorbTxt(sorb), d, nameIReg(4,rm));
399
                                                 d, nameIReg(4,rm));
400
           return (2<<24 | tmp);
695
           return (2<<24 | tmp);
401
         }
696
         }
402
697
Lines 410-419 Link Here
410
           UInt  d   = getUDisp32((Addr)eip); eip += 4;
705
           UInt  d   = getUDisp32((Addr)eip); eip += 4;
411
           uInstr2(cb, GET,  4, ArchReg, rm,  TempReg, tmq);
706
           uInstr2(cb, GET,  4, ArchReg, rm,  TempReg, tmq);
412
           uInstr2(cb, LEA1, 4, TempReg, tmq, TempReg, tmp);
707
           uInstr2(cb, LEA1, 4, TempReg, tmq, TempReg, tmp);
413
           LAST_UINSTR(cb).lit32 = d;
708
           uLiteral(cb, d);
414
           handleSegOverride(cb, sorb, tmp);
709
           handleSegOverride(cb, sorb, tmp);
415
           if (buf) VG_(sprintf)(buf,"%s0x%x(%s)", sorbTxt(sorb), 
710
           DIS(buf, "%s0x%x(%s)", sorbTxt(sorb), d, nameIReg(4,rm));
416
                                                   d, nameIReg(4,rm));
417
           return (5<<24 | tmp);
711
           return (5<<24 | tmp);
418
         }
712
         }
419
713
Lines 430-436 Link Here
430
           uInstr2(cb, MOV, 4, Literal, 0, TempReg, tmp);
724
           uInstr2(cb, MOV, 4, Literal, 0, TempReg, tmp);
431
           uLiteral(cb, d);
725
           uLiteral(cb, d);
432
           handleSegOverride(cb, sorb, tmp);
726
           handleSegOverride(cb, sorb, tmp);
433
           if (buf) VG_(sprintf)(buf,"%s(0x%x)", sorbTxt(sorb), d);
727
           DIS(buf, "%s(0x%x)", sorbTxt(sorb), d);
434
           return (5<<24 | tmp);
728
           return (5<<24 | tmp);
435
         }
729
         }
436
730
Lines 466-477 Link Here
466
            uInstr2(cb, GET,  4, ArchReg, base_r,   TempReg, base_tmp);
760
            uInstr2(cb, GET,  4, ArchReg, base_r,   TempReg, base_tmp);
467
            uInstr3(cb, LEA2, 4, TempReg, base_tmp, TempReg, index_tmp, 
761
            uInstr3(cb, LEA2, 4, TempReg, base_tmp, TempReg, index_tmp, 
468
                                 TempReg, tmp);
762
                                 TempReg, tmp);
469
            LAST_UINSTR(cb).lit32   = 0;
763
            uLiteral(cb, 0);
470
            LAST_UINSTR(cb).extra4b = 1 << scale;
764
            LAST_UINSTR(cb).extra4b = 1 << scale;
471
            handleSegOverride(cb, sorb, tmp);
765
            handleSegOverride(cb, sorb, tmp);
472
            if (buf) VG_(sprintf)(buf,"%s(%s,%s,%d)", sorbTxt(sorb), 
766
            DIS(buf, "%s(%s,%s,%d)", sorbTxt(sorb), 
473
                                  nameIReg(4,base_r),
767
                      nameIReg(4,base_r), nameIReg(4,index_r), 1<<scale);
474
                                  nameIReg(4,index_r),1<<scale);
475
            return (2<<24 | tmp);
768
            return (2<<24 | tmp);
476
         }
769
         }
477
770
Lines 483-501 Link Here
483
            uLiteral(cb, 0);
776
            uLiteral(cb, 0);
484
            uInstr3(cb, LEA2, 4, TempReg, tmp,      TempReg, index_tmp, 
777
            uInstr3(cb, LEA2, 4, TempReg, tmp,      TempReg, index_tmp, 
485
                                 TempReg, tmp);
778
                                 TempReg, tmp);
486
            LAST_UINSTR(cb).lit32   = d;
779
            uLiteral(cb, d);
487
            LAST_UINSTR(cb).extra4b = 1 << scale;
780
            LAST_UINSTR(cb).extra4b = 1 << scale;
488
            handleSegOverride(cb, sorb, tmp);
781
            handleSegOverride(cb, sorb, tmp);
489
            if (buf) VG_(sprintf)(buf,"%s0x%x(,%s,%d)", sorbTxt(sorb), d, 
782
            DIS(buf, "%s0x%x(,%s,%d)", sorbTxt(sorb), d, 
490
                                  nameIReg(4,index_r),1<<scale);
783
                      nameIReg(4,index_r), 1<<scale);
491
            return (6<<24 | tmp);
784
            return (6<<24 | tmp);
492
         }
785
         }
493
786
494
         if (index_r == R_ESP && base_r != R_EBP) {
787
         if (index_r == R_ESP && base_r != R_EBP) {
495
            uInstr2(cb, GET, 4, ArchReg, base_r, TempReg, tmp);
788
            uInstr2(cb, GET, 4, ArchReg, base_r, TempReg, tmp);
496
            handleSegOverride(cb, sorb, tmp);
789
            handleSegOverride(cb, sorb, tmp);
497
            if (buf) VG_(sprintf)(buf,"%s(%s,,)", 
790
            DIS(buf, "%s(%s,,)", sorbTxt(sorb), nameIReg(4,base_r));
498
                                      sorbTxt(sorb), nameIReg(4,base_r));
499
            return (2<<24 | tmp);
791
            return (2<<24 | tmp);
500
         }
792
         }
501
793
Lines 504-510 Link Here
504
            uInstr2(cb, MOV, 4, Literal, 0, TempReg, tmp);
796
            uInstr2(cb, MOV, 4, Literal, 0, TempReg, tmp);
505
	    uLiteral(cb, d);
797
	    uLiteral(cb, d);
506
            handleSegOverride(cb, sorb, tmp);
798
            handleSegOverride(cb, sorb, tmp);
507
            if (buf) VG_(sprintf)(buf,"%s0x%x()", sorbTxt(sorb), d);
799
            DIS(buf, "%s0x%x()", sorbTxt(sorb), d);
508
            return (6<<24 | tmp);
800
            return (6<<24 | tmp);
509
         }
801
         }
510
802
Lines 531-540 Link Here
531
            Int tmq = newTemp(cb);
823
            Int tmq = newTemp(cb);
532
            uInstr2(cb, GET,  4, ArchReg, base_r,  TempReg, tmq);
824
            uInstr2(cb, GET,  4, ArchReg, base_r,  TempReg, tmq);
533
            uInstr2(cb, LEA1, 4, TempReg, tmq, TempReg, tmp);
825
            uInstr2(cb, LEA1, 4, TempReg, tmq, TempReg, tmp);
534
            LAST_UINSTR(cb).lit32 = d;
826
            uLiteral(cb, d);
535
            handleSegOverride(cb, sorb, tmp);
827
            handleSegOverride(cb, sorb, tmp);
536
            if (buf) VG_(sprintf)(buf,"%s%d(%s,,)", sorbTxt(sorb), 
828
            DIS(buf, "%s%d(%s,,)", sorbTxt(sorb), d, nameIReg(4,base_r));
537
                                  d, nameIReg(4,base_r));
538
            return (3<<24 | tmp);
829
            return (3<<24 | tmp);
539
         } else {
830
         } else {
540
            Int index_tmp = newTemp(cb);
831
            Int index_tmp = newTemp(cb);
Lines 543-554 Link Here
543
            uInstr2(cb, GET, 4,  ArchReg, base_r,   TempReg, base_tmp);
834
            uInstr2(cb, GET, 4,  ArchReg, base_r,   TempReg, base_tmp);
544
            uInstr3(cb, LEA2, 4, TempReg, base_tmp, TempReg, index_tmp, 
835
            uInstr3(cb, LEA2, 4, TempReg, base_tmp, TempReg, index_tmp, 
545
                                 TempReg, tmp);
836
                                 TempReg, tmp);
546
            LAST_UINSTR(cb).lit32   = d;
837
            uLiteral(cb, d);
547
            LAST_UINSTR(cb).extra4b = 1 << scale;
838
            LAST_UINSTR(cb).extra4b = 1 << scale;
548
            handleSegOverride(cb, sorb, tmp);
839
            handleSegOverride(cb, sorb, tmp);
549
            if (buf) VG_(sprintf)(buf,"%s%d(%s,%s,%d)", 
840
            DIS(buf, "%s%d(%s,%s,%d)", sorbTxt(sorb), d, 
550
                                  sorbTxt(sorb), d, nameIReg(4,base_r), 
841
                     nameIReg(4,base_r), nameIReg(4,index_r), 1<<scale);
551
                                  nameIReg(4,index_r), 1<<scale);
552
            return (3<<24 | tmp);
842
            return (3<<24 | tmp);
553
         }
843
         }
554
         vg_assert(0);
844
         vg_assert(0);
Lines 574-583 Link Here
574
            Int tmq = newTemp(cb);
864
            Int tmq = newTemp(cb);
575
            uInstr2(cb, GET,  4, ArchReg, base_r,  TempReg, tmq);
865
            uInstr2(cb, GET,  4, ArchReg, base_r,  TempReg, tmq);
576
            uInstr2(cb, LEA1, 4, TempReg, tmq, TempReg, tmp);
866
            uInstr2(cb, LEA1, 4, TempReg, tmq, TempReg, tmp);
577
            LAST_UINSTR(cb).lit32 = d;
867
            uLiteral(cb, d);
578
            handleSegOverride(cb, sorb, tmp);
868
            handleSegOverride(cb, sorb, tmp);
579
            if (buf) VG_(sprintf)(buf,"%s%d(%s,,)", 
869
            DIS(buf, "%s%d(%s,,)", sorbTxt(sorb), d, nameIReg(4,base_r));
580
                                  sorbTxt(sorb), d, nameIReg(4,base_r));
581
            return (6<<24 | tmp);
870
            return (6<<24 | tmp);
582
         } else {
871
         } else {
583
            Int index_tmp = newTemp(cb);
872
            Int index_tmp = newTemp(cb);
Lines 586-597 Link Here
586
            uInstr2(cb, GET,  4, ArchReg, base_r, TempReg, base_tmp);
875
            uInstr2(cb, GET,  4, ArchReg, base_r, TempReg, base_tmp);
587
            uInstr3(cb, LEA2, 4, TempReg, base_tmp, TempReg, index_tmp, 
876
            uInstr3(cb, LEA2, 4, TempReg, base_tmp, TempReg, index_tmp, 
588
                                 TempReg, tmp);
877
                                 TempReg, tmp);
589
            LAST_UINSTR(cb).lit32   = d;
878
            uLiteral(cb, d);
590
            LAST_UINSTR(cb).extra4b = 1 << scale;
879
            LAST_UINSTR(cb).extra4b = 1 << scale;
591
            handleSegOverride(cb, sorb, tmp);
880
            handleSegOverride(cb, sorb, tmp);
592
            if (buf) VG_(sprintf)(buf,"%s%d(%s,%s,%d)", 
881
            DIS(buf, "%s%d(%s,%s,%d)", sorbTxt(sorb), d, 
593
                                  sorbTxt(sorb), d, nameIReg(4,base_r), 
882
                      nameIReg(4,base_r), nameIReg(4,index_r), 1<<scale);
594
                                  nameIReg(4,index_r), 1<<scale);
595
            return (6<<24 | tmp);
883
            return (6<<24 | tmp);
596
         }
884
         }
597
         vg_assert(0);
885
         vg_assert(0);
Lines 692-700 Link Here
692
void codegen_XOR_reg_with_itself ( UCodeBlock* cb, Int size, 
980
void codegen_XOR_reg_with_itself ( UCodeBlock* cb, Int size, 
693
                                   Int ge_reg, Int tmp )
981
                                   Int ge_reg, Int tmp )
694
{
982
{
695
   if (dis) 
983
   DIP("xor%c %s, %s\n", nameISize(size),
696
      VG_(printf)("xor%c %s, %s\n", nameISize(size),
984
                         nameIReg(size,ge_reg), nameIReg(size,ge_reg) );
697
                  nameIReg(size,ge_reg), nameIReg(size,ge_reg) );
698
   uInstr2(cb, MOV, size, Literal, 0, TempReg, tmp);
985
   uInstr2(cb, MOV, size, Literal, 0, TempReg, tmp);
699
   uLiteral(cb, 0);
986
   uLiteral(cb, 0);
700
   uInstr2(cb, XOR, size, TempReg, tmp, TempReg, tmp);
987
   uInstr2(cb, XOR, size, TempReg, tmp, TempReg, tmp);
Lines 766-774 Link Here
766
      }
1053
      }
767
      if (keep)
1054
      if (keep)
768
         uInstr2(cb, PUT, size, TempReg, tmp, ArchReg, gregOfRM(rm));
1055
         uInstr2(cb, PUT, size, TempReg, tmp, ArchReg, gregOfRM(rm));
769
      if (dis) VG_(printf)("%s%c %s,%s\n", t_x86opc, nameISize(size), 
1056
      DIP("%s%c %s,%s\n", t_x86opc, nameISize(size), 
770
                           nameIReg(size,eregOfRM(rm)),
1057
                          nameIReg(size,eregOfRM(rm)),
771
                           nameIReg(size,gregOfRM(rm)));
1058
                          nameIReg(size,gregOfRM(rm)));
772
      return 1+eip0;
1059
      return 1+eip0;
773
   }
1060
   }
774
1061
Lines 777-783 Link Here
777
      = (opc == ADD || opc == OR || opc == AND || opc == XOR || opc == ADC)
1064
      = (opc == ADD || opc == OR || opc == AND || opc == XOR || opc == ADC)
778
           ? True : False;
1065
           ? True : False;
779
   if (reversible) {
1066
   if (reversible) {
780
      UInt pair = disAMode ( cb, sorb, eip0, dis?dis_buf:NULL);
1067
      UInt pair = disAMode ( cb, sorb, eip0, dis_buf);
781
      Int  tmpa = LOW24(pair);
1068
      Int  tmpa = LOW24(pair);
782
      uInstr2(cb, LOAD, size, TempReg, tmpa, TempReg, tmpa);
1069
      uInstr2(cb, LOAD, size, TempReg, tmpa, TempReg, tmpa);
783
1070
Lines 792-802 Link Here
792
      }
1079
      }
793
      if (keep)
1080
      if (keep)
794
         uInstr2(cb, PUT,  size, TempReg, tmpa, ArchReg, gregOfRM(rm));
1081
         uInstr2(cb, PUT,  size, TempReg, tmpa, ArchReg, gregOfRM(rm));
795
      if (dis) VG_(printf)("%s%c %s,%s\n", t_x86opc, nameISize(size), 
1082
      DIP("%s%c %s,%s\n", t_x86opc, nameISize(size), 
796
                           dis_buf,nameIReg(size,gregOfRM(rm)));
1083
                          dis_buf,nameIReg(size,gregOfRM(rm)));
797
      return HI8(pair)+eip0;
1084
      return HI8(pair)+eip0;
798
   } else {
1085
   } else {
799
      UInt pair = disAMode ( cb, sorb, eip0, dis?dis_buf:NULL);
1086
      UInt pair = disAMode ( cb, sorb, eip0, dis_buf);
800
      Int  tmpa = LOW24(pair);
1087
      Int  tmpa = LOW24(pair);
801
      Int  tmp2 = newTemp(cb);
1088
      Int  tmp2 = newTemp(cb);
802
      uInstr2(cb, LOAD, size, TempReg, tmpa, TempReg, tmpa);
1089
      uInstr2(cb, LOAD, size, TempReg, tmpa, TempReg, tmpa);
Lines 805-812 Link Here
805
      setFlagsFromUOpcode(cb, opc);
1092
      setFlagsFromUOpcode(cb, opc);
806
      if (keep)
1093
      if (keep)
807
         uInstr2(cb, PUT,  size, TempReg, tmp2, ArchReg, gregOfRM(rm));
1094
         uInstr2(cb, PUT,  size, TempReg, tmp2, ArchReg, gregOfRM(rm));
808
      if (dis) VG_(printf)("%s%c %s,%s\n", t_x86opc, nameISize(size), 
1095
      DIP("%s%c %s,%s\n", t_x86opc, nameISize(size), 
809
                           dis_buf,nameIReg(size,gregOfRM(rm)));
1096
                          dis_buf,nameIReg(size,gregOfRM(rm)));
810
      return HI8(pair)+eip0;
1097
      return HI8(pair)+eip0;
811
   }
1098
   }
812
}
1099
}
Lines 869-883 Link Here
869
      }
1156
      }
870
      if (keep)
1157
      if (keep)
871
         uInstr2(cb, PUT, size, TempReg, tmp, ArchReg, eregOfRM(rm));
1158
         uInstr2(cb, PUT, size, TempReg, tmp, ArchReg, eregOfRM(rm));
872
      if (dis) VG_(printf)("%s%c %s,%s\n", t_x86opc, nameISize(size), 
1159
      DIP("%s%c %s,%s\n", t_x86opc, nameISize(size), 
873
                           nameIReg(size,gregOfRM(rm)),
1160
                          nameIReg(size,gregOfRM(rm)),
874
                           nameIReg(size,eregOfRM(rm)));
1161
                          nameIReg(size,eregOfRM(rm)));
875
      return 1+eip0;
1162
      return 1+eip0;
876
   }
1163
   }
877
1164
878
   /* E refers to memory */    
1165
   /* E refers to memory */    
879
   {
1166
   {
880
      UInt pair = disAMode ( cb, sorb, eip0, dis?dis_buf:NULL);
1167
      UInt pair = disAMode ( cb, sorb, eip0, dis_buf);
881
      Int  tmpa = LOW24(pair);
1168
      Int  tmpa = LOW24(pair);
882
      Int  tmpv = newTemp(cb);
1169
      Int  tmpv = newTemp(cb);
883
      uInstr2(cb, LOAD,  size, TempReg, tmpa, TempReg, tmpv);
1170
      uInstr2(cb, LOAD,  size, TempReg, tmpa, TempReg, tmpv);
Lines 894-901 Link Here
894
      if (keep) {
1181
      if (keep) {
895
         uInstr2(cb, STORE, size, TempReg, tmpv, TempReg, tmpa);
1182
         uInstr2(cb, STORE, size, TempReg, tmpv, TempReg, tmpa);
896
      }
1183
      }
897
      if (dis) VG_(printf)("%s%c %s,%s\n", t_x86opc, nameISize(size), 
1184
      DIP("%s%c %s,%s\n", t_x86opc, nameISize(size), 
898
                           nameIReg(size,gregOfRM(rm)), dis_buf);
1185
                          nameIReg(size,gregOfRM(rm)), dis_buf);
899
      return HI8(pair)+eip0;
1186
      return HI8(pair)+eip0;
900
   }
1187
   }
901
}
1188
}
Lines 930-936 Link Here
930
      Int tmpv = newTemp(cb);
1217
      Int tmpv = newTemp(cb);
931
      uInstr2(cb, GET, size, ArchReg, eregOfRM(rm), TempReg, tmpv);
1218
      uInstr2(cb, GET, size, ArchReg, eregOfRM(rm), TempReg, tmpv);
932
      uInstr2(cb, PUT, size, TempReg, tmpv, ArchReg, gregOfRM(rm));
1219
      uInstr2(cb, PUT, size, TempReg, tmpv, ArchReg, gregOfRM(rm));
933
      if (dis) VG_(printf)("mov%c %s,%s\n", nameISize(size), 
1220
      DIP("mov%c %s,%s\n", nameISize(size), 
934
                           nameIReg(size,eregOfRM(rm)),
1221
                           nameIReg(size,eregOfRM(rm)),
935
                           nameIReg(size,gregOfRM(rm)));
1222
                           nameIReg(size,gregOfRM(rm)));
936
      return 1+eip0;
1223
      return 1+eip0;
Lines 938-949 Link Here
938
1225
939
   /* E refers to memory */    
1226
   /* E refers to memory */    
940
   {
1227
   {
941
      UInt pair = disAMode ( cb, sorb, eip0, dis?dis_buf:NULL);
1228
      UInt pair = disAMode ( cb, sorb, eip0, dis_buf);
942
      Int  tmpa = LOW24(pair);
1229
      Int  tmpa = LOW24(pair);
943
      Int  tmpb = newTemp(cb);
1230
      Int  tmpb = newTemp(cb);
944
      uInstr2(cb, LOAD, size, TempReg, tmpa, TempReg, tmpb);
1231
      uInstr2(cb, LOAD, size, TempReg, tmpa, TempReg, tmpb);
945
      uInstr2(cb, PUT,  size, TempReg, tmpb, ArchReg, gregOfRM(rm));
1232
      uInstr2(cb, PUT,  size, TempReg, tmpb, ArchReg, gregOfRM(rm));
946
      if (dis) VG_(printf)("mov%c %s,%s\n", nameISize(size), 
1233
      DIP("mov%c %s,%s\n", nameISize(size), 
947
                           dis_buf,nameIReg(size,gregOfRM(rm)));
1234
                           dis_buf,nameIReg(size,gregOfRM(rm)));
948
      return HI8(pair)+eip0;
1235
      return HI8(pair)+eip0;
949
   }
1236
   }
Lines 979-985 Link Here
979
      Int tmpv = newTemp(cb);
1266
      Int tmpv = newTemp(cb);
980
      uInstr2(cb, GET, size, ArchReg, gregOfRM(rm), TempReg, tmpv);
1267
      uInstr2(cb, GET, size, ArchReg, gregOfRM(rm), TempReg, tmpv);
981
      uInstr2(cb, PUT, size, TempReg, tmpv, ArchReg, eregOfRM(rm));
1268
      uInstr2(cb, PUT, size, TempReg, tmpv, ArchReg, eregOfRM(rm));
982
      if (dis) VG_(printf)("mov%c %s,%s\n", nameISize(size), 
1269
      DIP("mov%c %s,%s\n", nameISize(size), 
983
                           nameIReg(size,gregOfRM(rm)),
1270
                           nameIReg(size,gregOfRM(rm)),
984
                           nameIReg(size,eregOfRM(rm)));
1271
                           nameIReg(size,eregOfRM(rm)));
985
      return 1+eip0;
1272
      return 1+eip0;
Lines 987-998 Link Here
987
1274
988
   /* E refers to memory */    
1275
   /* E refers to memory */    
989
   {
1276
   {
990
      UInt pair = disAMode ( cb, sorb, eip0, dis?dis_buf:NULL);
1277
      UInt pair = disAMode ( cb, sorb, eip0, dis_buf);
991
      Int  tmpa = LOW24(pair);
1278
      Int  tmpa = LOW24(pair);
992
      Int  tmpv = newTemp(cb);
1279
      Int  tmpv = newTemp(cb);
993
      uInstr2(cb, GET,   size, ArchReg, gregOfRM(rm), TempReg, tmpv);
1280
      uInstr2(cb, GET,   size, ArchReg, gregOfRM(rm), TempReg, tmpv);
994
      uInstr2(cb, STORE, size, TempReg, tmpv, TempReg, tmpa);
1281
      uInstr2(cb, STORE, size, TempReg, tmpv, TempReg, tmpa);
995
      if (dis) VG_(printf)("mov%c %s,%s\n", nameISize(size), 
1282
      DIP("mov%c %s,%s\n", nameISize(size), 
996
                           nameIReg(size,gregOfRM(rm)), dis_buf);
1283
                           nameIReg(size,gregOfRM(rm)), dis_buf);
997
      return HI8(pair)+eip0;
1284
      return HI8(pair)+eip0;
998
   }
1285
   }
Lines 1024-1031 Link Here
1024
   }
1311
   }
1025
   if (keep)
1312
   if (keep)
1026
      uInstr2(cb, PUT, size, TempReg, tmp, ArchReg, R_EAX);
1313
      uInstr2(cb, PUT, size, TempReg, tmp, ArchReg, R_EAX);
1027
   if (dis) VG_(printf)("%s%c $0x%x, %s\n", t_x86opc, nameISize(size), 
1314
   DIP("%s%c $0x%x, %s\n", t_x86opc, nameISize(size), 
1028
                        lit, nameIReg(size,R_EAX));
1315
                           lit, nameIReg(size,R_EAX));
1029
   return eip+size;
1316
   return eip+size;
1030
}
1317
}
1031
1318
Lines 1045-1072 Link Here
1045
      LAST_UINSTR(cb).extra4b = szs;
1332
      LAST_UINSTR(cb).extra4b = szs;
1046
      LAST_UINSTR(cb).signed_widen = sign_extend;
1333
      LAST_UINSTR(cb).signed_widen = sign_extend;
1047
      uInstr2(cb, PUT, szd, TempReg, tmpv, ArchReg, gregOfRM(rm));
1334
      uInstr2(cb, PUT, szd, TempReg, tmpv, ArchReg, gregOfRM(rm));
1048
      if (dis) VG_(printf)("mov%c%c%c %s,%s\n", 
1335
      DIP("mov%c%c%c %s,%s\n", sign_extend ? 's' : 'z',
1049
                           sign_extend ? 's' : 'z',
1336
                               nameISize(szs), nameISize(szd),
1050
                           nameISize(szs), nameISize(szd),
1337
                               nameIReg(szs,eregOfRM(rm)),
1051
                           nameIReg(szs,eregOfRM(rm)),
1338
                               nameIReg(szd,gregOfRM(rm)));
1052
                           nameIReg(szd,gregOfRM(rm)));
1053
      return 1+eip;
1339
      return 1+eip;
1054
   }
1340
   }
1055
1341
1056
   /* E refers to memory */    
1342
   /* E refers to memory */    
1057
   {
1343
   {
1058
      UInt pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL);
1344
      UInt pair = disAMode ( cb, sorb, eip, dis_buf);
1059
      Int  tmpa = LOW24(pair);
1345
      Int  tmpa = LOW24(pair);
1060
      uInstr2(cb, LOAD, szs, TempReg, tmpa, TempReg, tmpa);
1346
      uInstr2(cb, LOAD, szs, TempReg, tmpa, TempReg, tmpa);
1061
      uInstr1(cb, WIDEN, szd, TempReg, tmpa);
1347
      uInstr1(cb, WIDEN, szd, TempReg, tmpa);
1062
      LAST_UINSTR(cb).extra4b = szs;
1348
      LAST_UINSTR(cb).extra4b = szs;
1063
      LAST_UINSTR(cb).signed_widen = sign_extend;
1349
      LAST_UINSTR(cb).signed_widen = sign_extend;
1064
      uInstr2(cb, PUT, szd, TempReg, tmpa, ArchReg, gregOfRM(rm));
1350
      uInstr2(cb, PUT, szd, TempReg, tmpa, ArchReg, gregOfRM(rm));
1065
      if (dis) VG_(printf)("mov%c%c%c %s,%s\n", 
1351
      DIP("mov%c%c%c %s,%s\n", sign_extend ? 's' : 'z',
1066
                           sign_extend ? 's' : 'z',
1352
                               nameISize(szs), nameISize(szd),
1067
                           nameISize(szs), nameISize(szd),
1353
                               dis_buf, nameIReg(szd,gregOfRM(rm)));
1068
                           dis_buf,
1069
                           nameIReg(szd,gregOfRM(rm)));
1070
      return HI8(pair)+eip;
1354
      return HI8(pair)+eip;
1071
   }
1355
   }
1072
}
1356
}
Lines 1160-1171 Link Here
1160
      if (gregOfRM(modrm) < 7)
1444
      if (gregOfRM(modrm) < 7)
1161
         uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, eregOfRM(modrm));
1445
         uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, eregOfRM(modrm));
1162
      eip += (am_sz + d_sz);
1446
      eip += (am_sz + d_sz);
1163
      if (dis)
1447
      DIP("%s%c $0x%x, %s\n", nameGrp1(gregOfRM(modrm)), nameISize(sz), d32, 
1164
         VG_(printf)("%s%c $0x%x, %s\n",
1448
                              nameIReg(sz,eregOfRM(modrm)));
1165
                     nameGrp1(gregOfRM(modrm)), nameISize(sz), d32, 
1166
                     nameIReg(sz,eregOfRM(modrm)));
1167
   } else {
1449
   } else {
1168
      pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL);
1450
      pair = disAMode ( cb, sorb, eip, dis_buf);
1169
      t1   = LOW24(pair);
1451
      t1   = LOW24(pair);
1170
      t2   = newTemp(cb);
1452
      t2   = newTemp(cb);
1171
      eip  += HI8(pair);
1453
      eip  += HI8(pair);
Lines 1192-1201 Link Here
1192
      if (gregOfRM(modrm) < 7) {
1474
      if (gregOfRM(modrm) < 7) {
1193
         uInstr2(cb, STORE, sz, TempReg, t2, TempReg, t1);
1475
         uInstr2(cb, STORE, sz, TempReg, t2, TempReg, t1);
1194
      }
1476
      }
1195
      if (dis)
1477
      DIP("%s%c $0x%x, %s\n", nameGrp1(gregOfRM(modrm)), nameISize(sz),
1196
         VG_(printf)("%s%c $0x%x, %s\n",
1478
                              d32, dis_buf);
1197
                     nameGrp1(gregOfRM(modrm)), nameISize(sz), d32, 
1198
                     dis_buf);
1199
   }
1479
   }
1200
   return eip;
1480
   return eip;
1201
}
1481
}
Lines 1247-1253 Link Here
1247
      setFlagsFromUOpcode(cb, uopc);
1527
      setFlagsFromUOpcode(cb, uopc);
1248
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, eregOfRM(modrm));
1528
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, eregOfRM(modrm));
1249
      eip += (am_sz + d_sz);
1529
      eip += (am_sz + d_sz);
1250
      if (dis) {
1530
      if (VG_(print_codegen)) {
1251
         if (orig_src_tag == Literal)
1531
         if (orig_src_tag == Literal)
1252
            VG_(printf)("%s%c $0x%x, %s\n",
1532
            VG_(printf)("%s%c $0x%x, %s\n",
1253
                        nameGrp2(gregOfRM(modrm)), nameISize(sz), 
1533
                        nameGrp2(gregOfRM(modrm)), nameISize(sz), 
Lines 1259-1265 Link Here
1259
                        nameIReg(sz,eregOfRM(modrm)));
1539
                        nameIReg(sz,eregOfRM(modrm)));
1260
      }
1540
      }
1261
   } else {
1541
   } else {
1262
      pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL);
1542
      pair = disAMode ( cb, sorb, eip, dis_buf);
1263
      t1   = LOW24(pair);
1543
      t1   = LOW24(pair);
1264
      t2   = newTemp(cb);
1544
      t2   = newTemp(cb);
1265
      eip  += HI8(pair);
1545
      eip  += HI8(pair);
Lines 1280-1286 Link Here
1280
      }
1560
      }
1281
      setFlagsFromUOpcode(cb, uopc);
1561
      setFlagsFromUOpcode(cb, uopc);
1282
      uInstr2(cb, STORE, sz, TempReg, t2, TempReg, t1);
1562
      uInstr2(cb, STORE, sz, TempReg, t2, TempReg, t1);
1283
      if (dis) {
1563
      if (VG_(print_codegen)) {
1284
         if (orig_src_tag == Literal)
1564
         if (orig_src_tag == Literal)
1285
            VG_(printf)("%s%c $0x%x, %s\n",
1565
            VG_(printf)("%s%c $0x%x, %s\n",
1286
                        nameGrp2(gregOfRM(modrm)), nameISize(sz), 
1566
                        nameGrp2(gregOfRM(modrm)), nameISize(sz), 
Lines 1333-1339 Link Here
1333
      And eip on entry points at the modrm byte. */
1613
      And eip on entry points at the modrm byte. */
1334
   Int   t1, t2, t_fetched, t_mask;
1614
   Int   t1, t2, t_fetched, t_mask;
1335
   UInt  pair;
1615
   UInt  pair;
1336
   UChar dis_buf[50];
1616
   Char  dis_buf[50];
1337
   UInt  v_mask;
1617
   UInt  v_mask;
1338
1618
1339
   /* There is no 1-byte form of this instruction, AFAICS. */
1619
   /* There is no 1-byte form of this instruction, AFAICS. */
Lines 1382-1394 Link Here
1382
         uInstr2(cb, PUT, sz, TempReg, t2, ArchReg, eregOfRM(modrm));
1662
         uInstr2(cb, PUT, sz, TempReg, t2, ArchReg, eregOfRM(modrm));
1383
1663
1384
      eip += (am_sz + 1);
1664
      eip += (am_sz + 1);
1385
      if (dis)
1665
      DIP("%s%c $0x%x, %s\n", nameGrp8(gregOfRM(modrm)), nameISize(sz),
1386
         VG_(printf)("%s%c $0x%x, %s\n",
1666
                              src_val, nameIReg(sz,eregOfRM(modrm)));
1387
                     nameGrp8(gregOfRM(modrm)), nameISize(sz),
1388
                     src_val,
1389
                     nameIReg(sz,eregOfRM(modrm)));
1390
   } else {
1667
   } else {
1391
      pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL);
1668
      pair = disAMode ( cb, sorb, eip, dis_buf);
1392
      t1   = LOW24(pair);
1669
      t1   = LOW24(pair);
1393
      t2   = newTemp(cb);
1670
      t2   = newTemp(cb);
1394
      eip  += HI8(pair);
1671
      eip  += HI8(pair);
Lines 1402-1411 Link Here
1402
      if (gregOfRM(modrm) != 4 /* BT */) {
1679
      if (gregOfRM(modrm) != 4 /* BT */) {
1403
         uInstr2(cb, STORE, sz, TempReg, t2, TempReg, t1);
1680
         uInstr2(cb, STORE, sz, TempReg, t2, TempReg, t1);
1404
      }
1681
      }
1405
      if (dis)
1682
      DIP("%s%c $0x%x, %s\n", nameGrp8(gregOfRM(modrm)), nameISize(sz),
1406
            VG_(printf)("%s%c $0x%x, %s\n",
1683
                              src_val, dis_buf);
1407
                        nameGrp8(gregOfRM(modrm)), nameISize(sz), src_val, 
1408
                        dis_buf);
1409
   }
1684
   }
1410
   return eip;
1685
   return eip;
1411
1686
Lines 1449-1456 Link Here
1449
      uInstr2(cb, PUT,   2, TempReg, t1, ArchReg, R_EAX);
1724
      uInstr2(cb, PUT,   2, TempReg, t1, ArchReg, R_EAX);
1450
   }
1725
   }
1451
   uInstr0(cb, CALLM_E, 0);
1726
   uInstr0(cb, CALLM_E, 0);
1452
   if (dis) VG_(printf)("%s%c %s\n", signed_multiply ? "imul" : "mul",
1727
   DIP("%s%c %s\n", signed_multiply ? "imul" : "mul",
1453
                        nameISize(sz), nameIReg(sz, eregOfRM(modrm)));
1728
                    nameISize(sz), nameIReg(sz, eregOfRM(modrm)));
1454
1729
1455
}
1730
}
1456
1731
Lines 1488-1495 Link Here
1488
      uInstr2(cb, PUT,   2, TempReg, t1, ArchReg, R_EAX);
1763
      uInstr2(cb, PUT,   2, TempReg, t1, ArchReg, R_EAX);
1489
   }
1764
   }
1490
   uInstr0(cb, CALLM_E, 0);
1765
   uInstr0(cb, CALLM_E, 0);
1491
   if (dis) VG_(printf)("%s%c %s\n", signed_multiply ? "imul" : "mul",
1766
   DIP("%s%c %s\n", signed_multiply ? "imul" : "mul",
1492
                        nameISize(sz), dis_buf);
1767
                    nameISize(sz), dis_buf);
1493
}
1768
}
1494
1769
1495
1770
Lines 1516-1524 Link Here
1516
	    uLiteral(cb, d32);
1791
	    uLiteral(cb, d32);
1517
            uInstr2(cb, AND, sz, TempReg, tao, TempReg, t1);
1792
            uInstr2(cb, AND, sz, TempReg, tao, TempReg, t1);
1518
            setFlagsFromUOpcode(cb, AND);
1793
            setFlagsFromUOpcode(cb, AND);
1519
            if (dis)
1794
            DIP("test%c $0x%x, %s\n",
1520
               VG_(printf)("test%c $0x%x, %s\n",
1795
                nameISize(sz), d32, nameIReg(sz, eregOfRM(modrm)));
1521
                   nameISize(sz), d32, nameIReg(sz, eregOfRM(modrm)));
1522
            break;
1796
            break;
1523
         }
1797
         }
1524
         case 2: /* NOT */
1798
         case 2: /* NOT */
Lines 1527-1535 Link Here
1527
            uInstr1(cb, NOT, sz, TempReg, t1);
1801
            uInstr1(cb, NOT, sz, TempReg, t1);
1528
            setFlagsFromUOpcode(cb, NOT);
1802
            setFlagsFromUOpcode(cb, NOT);
1529
            uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, eregOfRM(modrm));
1803
            uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, eregOfRM(modrm));
1530
            if (dis)
1804
            DIP("not%c %s\n", nameISize(sz), nameIReg(sz, eregOfRM(modrm)));
1531
               VG_(printf)("not%c %s\n",
1532
                   nameISize(sz), nameIReg(sz, eregOfRM(modrm)));
1533
            break;
1805
            break;
1534
         case 3: /* NEG */
1806
         case 3: /* NEG */
1535
            eip++;
1807
            eip++;
Lines 1537-1545 Link Here
1537
            uInstr1(cb, NEG, sz, TempReg, t1);
1809
            uInstr1(cb, NEG, sz, TempReg, t1);
1538
            setFlagsFromUOpcode(cb, NEG);
1810
            setFlagsFromUOpcode(cb, NEG);
1539
            uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, eregOfRM(modrm));
1811
            uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, eregOfRM(modrm));
1540
            if (dis)
1812
            DIP("neg%c %s\n", nameISize(sz), nameIReg(sz, eregOfRM(modrm)));
1541
               VG_(printf)("neg%c %s\n",
1542
                   nameISize(sz), nameIReg(sz, eregOfRM(modrm)));
1543
            break;
1813
            break;
1544
         case 4: /* MUL */
1814
         case 4: /* MUL */
1545
            eip++;
1815
            eip++;
Lines 1553-1569 Link Here
1553
            eip++;
1823
            eip++;
1554
            uInstr2(cb, GET, sz, ArchReg, eregOfRM(modrm), TempReg, t1);
1824
            uInstr2(cb, GET, sz, ArchReg, eregOfRM(modrm), TempReg, t1);
1555
            codegen_div ( cb, sz, t1, False );
1825
            codegen_div ( cb, sz, t1, False );
1556
            if (dis)
1826
            DIP("div%c %s\n", nameISize(sz), nameIReg(sz, eregOfRM(modrm)));
1557
               VG_(printf)("div%c %s\n", nameISize(sz), 
1558
                           nameIReg(sz, eregOfRM(modrm)));
1559
            break;
1827
            break;
1560
         case 7: /* IDIV */
1828
         case 7: /* IDIV */
1561
            eip++;
1829
            eip++;
1562
            uInstr2(cb, GET, sz, ArchReg, eregOfRM(modrm), TempReg, t1);
1830
            uInstr2(cb, GET, sz, ArchReg, eregOfRM(modrm), TempReg, t1);
1563
            codegen_div ( cb, sz, t1, True );
1831
            codegen_div ( cb, sz, t1, True );
1564
            if (dis)
1832
            DIP("idiv%c %s\n", nameISize(sz), nameIReg(sz, eregOfRM(modrm)));
1565
               VG_(printf)("idiv%c %s\n", nameISize(sz), 
1566
                           nameIReg(sz, eregOfRM(modrm)));
1567
            break;
1833
            break;
1568
         default: 
1834
         default: 
1569
            VG_(printf)(
1835
            VG_(printf)(
Lines 1571-1577 Link Here
1571
            VG_(core_panic)("Grp3");
1837
            VG_(core_panic)("Grp3");
1572
      }
1838
      }
1573
   } else {
1839
   } else {
1574
      pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
1840
      pair = disAMode ( cb, sorb, eip, dis_buf );
1575
      t2   = LOW24(pair);
1841
      t2   = LOW24(pair);
1576
      t1   = newTemp(cb);
1842
      t1   = newTemp(cb);
1577
      eip  += HI8(pair);
1843
      eip  += HI8(pair);
Lines 1584-1624 Link Here
1584
            uLiteral(cb, d32);
1850
            uLiteral(cb, d32);
1585
            uInstr2(cb, AND, sz, TempReg, tao, TempReg, t1);
1851
            uInstr2(cb, AND, sz, TempReg, tao, TempReg, t1);
1586
            setFlagsFromUOpcode(cb, AND);
1852
            setFlagsFromUOpcode(cb, AND);
1587
            if (dis)
1853
            DIP("test%c $0x%x, %s\n", nameISize(sz), d32, dis_buf);
1588
               VG_(printf)("test%c $0x%x, %s\n", 
1589
                           nameISize(sz), d32, dis_buf);
1590
            break;
1854
            break;
1591
         }
1855
         }
1592
         case 2: /* NOT */
1856
         case 2: /* NOT */
1593
            uInstr1(cb, NOT, sz, TempReg, t1);
1857
            uInstr1(cb, NOT, sz, TempReg, t1);
1594
            setFlagsFromUOpcode(cb, NOT);
1858
            setFlagsFromUOpcode(cb, NOT);
1595
            uInstr2(cb, STORE, sz, TempReg, t1, TempReg, t2);
1859
            uInstr2(cb, STORE, sz, TempReg, t1, TempReg, t2);
1596
            if (dis)
1860
            DIP("not%c %s\n", nameISize(sz), dis_buf);
1597
               VG_(printf)("not%c %s\n", nameISize(sz), dis_buf);
1598
            break;
1861
            break;
1599
         case 3: /* NEG */
1862
         case 3: /* NEG */
1600
            uInstr1(cb, NEG, sz, TempReg, t1);
1863
            uInstr1(cb, NEG, sz, TempReg, t1);
1601
            setFlagsFromUOpcode(cb, NEG);
1864
            setFlagsFromUOpcode(cb, NEG);
1602
            uInstr2(cb, STORE, sz, TempReg, t1, TempReg, t2);
1865
            uInstr2(cb, STORE, sz, TempReg, t1, TempReg, t2);
1603
            if (dis)
1866
            DIP("neg%c %s\n", nameISize(sz), dis_buf);
1604
               VG_(printf)("neg%c %s\n", nameISize(sz), dis_buf);
1605
            break;
1867
            break;
1606
         case 4: /* MUL */
1868
         case 4: /* MUL */
1607
            codegen_mul_A_D_Temp ( cb, sz, t1, False, 
1869
            codegen_mul_A_D_Temp ( cb, sz, t1, False, 
1608
                                   dis?dis_buf:NULL );
1870
                                   dis_buf );
1609
            break;
1871
            break;
1610
         case 5: /* IMUL */
1872
         case 5: /* IMUL */
1611
            codegen_mul_A_D_Temp ( cb, sz, t1, True, dis?dis_buf:NULL );
1873
            codegen_mul_A_D_Temp ( cb, sz, t1, True, dis_buf );
1612
            break;
1874
            break;
1613
         case 6: /* DIV */
1875
         case 6: /* DIV */
1614
            codegen_div ( cb, sz, t1, False );
1876
            codegen_div ( cb, sz, t1, False );
1615
            if (dis)
1877
            DIP("div%c %s\n", nameISize(sz), dis_buf);
1616
               VG_(printf)("div%c %s\n", nameISize(sz), dis_buf);
1617
            break;
1878
            break;
1618
         case 7: /* IDIV */
1879
         case 7: /* IDIV */
1619
            codegen_div ( cb, sz, t1, True );
1880
            codegen_div ( cb, sz, t1, True );
1620
            if (dis)
1881
            DIP("idiv%c %s\n", nameISize(sz), dis_buf);
1621
               VG_(printf)("idiv%c %s\n", nameISize(sz), dis_buf);
1622
            break;
1882
            break;
1623
         default: 
1883
         default: 
1624
            VG_(printf)(
1884
            VG_(printf)(
Lines 1663-1673 Link Here
1663
            VG_(core_panic)("Grp4");
1923
            VG_(core_panic)("Grp4");
1664
      }
1924
      }
1665
      eip++;
1925
      eip++;
1666
      if (dis)
1926
      DIP("%sb %s\n", nameGrp4(gregOfRM(modrm)),
1667
         VG_(printf)("%sb %s\n", nameGrp4(gregOfRM(modrm)),
1927
                      nameIReg(1, eregOfRM(modrm)));
1668
                     nameIReg(1, eregOfRM(modrm)));
1669
   } else {
1928
   } else {
1670
      pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
1929
      pair = disAMode ( cb, sorb, eip, dis_buf );
1671
      t2   = LOW24(pair);
1930
      t2   = LOW24(pair);
1672
      t1   = newTemp(cb);
1931
      t1   = newTemp(cb);
1673
      uInstr2(cb, LOAD, 1, TempReg, t2, TempReg, t1);
1932
      uInstr2(cb, LOAD, 1, TempReg, t2, TempReg, t1);
Lines 1688-1695 Link Here
1688
            VG_(core_panic)("Grp4");
1947
            VG_(core_panic)("Grp4");
1689
      }
1948
      }
1690
      eip += HI8(pair);
1949
      eip += HI8(pair);
1691
      if (dis)
1950
      DIP("%sb %s\n", nameGrp4(gregOfRM(modrm)), dis_buf);
1692
         VG_(printf)("%sb %s\n", nameGrp4(gregOfRM(modrm)), dis_buf);
1693
   }
1951
   }
1694
   return eip;
1952
   return eip;
1695
}
1953
}
Lines 1731-1744 Link Here
1731
            uInstr2(cb, MOV,   4, Literal, 0,     TempReg, t4);
1989
            uInstr2(cb, MOV,   4, Literal, 0,     TempReg, t4);
1732
	    uLiteral(cb, eip+1);
1990
	    uLiteral(cb, eip+1);
1733
            uInstr2(cb, STORE, 4, TempReg, t4,    TempReg, t3);
1991
            uInstr2(cb, STORE, 4, TempReg, t4,    TempReg, t3);
1734
            uInstr1(cb, JMP,   0, TempReg, t1);
1992
            jmp_treg(cb, t1);
1735
            uCond(cb, CondAlways);
1736
            LAST_UINSTR(cb).jmpkind = JmpCall;
1993
            LAST_UINSTR(cb).jmpkind = JmpCall;
1737
            *isEnd = True;
1994
            *isEnd = True;
1738
            break;
1995
            break;
1739
         case 4: /* jmp Ev */
1996
         case 4: /* jmp Ev */
1740
            uInstr1(cb, JMP, 0, TempReg, t1);
1997
            jmp_treg(cb, t1);
1741
            uCond(cb, CondAlways);
1742
            *isEnd = True;
1998
            *isEnd = True;
1743
            break;
1999
            break;
1744
         default: 
2000
         default: 
Lines 1747-1757 Link Here
1747
            VG_(core_panic)("Grp5");
2003
            VG_(core_panic)("Grp5");
1748
      }
2004
      }
1749
      eip++;
2005
      eip++;
1750
      if (dis)
2006
      DIP("%s%c %s\n", nameGrp5(gregOfRM(modrm)),
1751
         VG_(printf)("%s%c %s\n", nameGrp5(gregOfRM(modrm)),
2007
                       nameISize(sz), nameIReg(sz, eregOfRM(modrm)));
1752
                     nameISize(sz), nameIReg(sz, eregOfRM(modrm)));
1753
   } else {
2008
   } else {
1754
      pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
2009
      pair = disAMode ( cb, sorb, eip, dis_buf );
1755
      t2   = LOW24(pair);
2010
      t2   = LOW24(pair);
1756
      t1   = newTemp(cb);
2011
      t1   = newTemp(cb);
1757
      uInstr2(cb, LOAD, sz, TempReg, t2, TempReg, t1);
2012
      uInstr2(cb, LOAD, sz, TempReg, t2, TempReg, t1);
Lines 1775-1788 Link Here
1775
            uInstr2(cb, MOV,   4, Literal, 0,     TempReg, t4);
2030
            uInstr2(cb, MOV,   4, Literal, 0,     TempReg, t4);
1776
	         uLiteral(cb, eip+HI8(pair));
2031
	         uLiteral(cb, eip+HI8(pair));
1777
            uInstr2(cb, STORE, 4, TempReg, t4,    TempReg, t3);
2032
            uInstr2(cb, STORE, 4, TempReg, t4,    TempReg, t3);
1778
            uInstr1(cb, JMP,   0, TempReg, t1);
2033
            jmp_treg(cb, t1);
1779
            uCond(cb, CondAlways);
1780
            LAST_UINSTR(cb).jmpkind = JmpCall;
2034
            LAST_UINSTR(cb).jmpkind = JmpCall;
1781
            *isEnd = True;
2035
            *isEnd = True;
1782
            break;
2036
            break;
1783
         case 4: /* JMP Ev */
2037
         case 4: /* JMP Ev */
1784
            uInstr1(cb, JMP, 0, TempReg, t1);
2038
            jmp_treg(cb, t1);
1785
            uCond(cb, CondAlways);
1786
            *isEnd = True;
2039
            *isEnd = True;
1787
            break;
2040
            break;
1788
         case 6: /* PUSH Ev */
2041
         case 6: /* PUSH Ev */
Lines 1799-1819 Link Here
1799
            VG_(core_panic)("Grp5");
2052
            VG_(core_panic)("Grp5");
1800
      }
2053
      }
1801
      eip += HI8(pair);
2054
      eip += HI8(pair);
1802
      if (dis)
2055
      DIP("%s%c %s\n", nameGrp5(gregOfRM(modrm)),
1803
         VG_(printf)("%s%c %s\n", nameGrp5(gregOfRM(modrm)),
2056
                       nameISize(sz), dis_buf);
1804
                     nameISize(sz), dis_buf);
1805
   }
2057
   }
1806
   return eip;
2058
   return eip;
1807
}
2059
}
1808
2060
1809
static __inline__
1810
void dis_JMP_d32( UCodeBlock* cb, Addr d32 )
1811
{
1812
   uInstr1(cb, JMP,   0, Literal, 0);
1813
   uLiteral(cb, d32);
1814
   uCond(cb, CondAlways);
1815
}
1816
1817
/*------------------------------------------------------------*/
2061
/*------------------------------------------------------------*/
1818
/*--- Disassembling string ops (including REP prefixes)    ---*/
2062
/*--- Disassembling string ops (including REP prefixes)    ---*/
1819
/*------------------------------------------------------------*/
2063
/*------------------------------------------------------------*/
Lines 1847-1853 Link Here
1847
   vg_assert(sorb == 0);
2091
   vg_assert(sorb == 0);
1848
   dis_string_op_increment(cb, sz, t_inc);
2092
   dis_string_op_increment(cb, sz, t_inc);
1849
   dis_OP( cb, sz, t_inc );
2093
   dis_OP( cb, sz, t_inc );
1850
   if (dis) VG_(printf)("%s%c\n", name, nameISize(sz));
2094
   DIP("%s%c\n", name, nameISize(sz));
1851
}
2095
}
1852
2096
1853
2097
Lines 1964-1979 Link Here
1964
   dis_OP  (cb, sz, t_inc);
2208
   dis_OP  (cb, sz, t_inc);
1965
2209
1966
   if (cond == CondAlways) {
2210
   if (cond == CondAlways) {
1967
      dis_JMP_d32  (cb, eip);
2211
      jmp_lit(cb, eip);
1968
   } else {
2212
   } else {
1969
      uInstr1      (cb, JMP,   0, Literal, 0);
2213
      jcc_lit(cb, eip, cond);
1970
      uLiteral     (cb, eip);
2214
      jmp_lit(cb, eip_next);
1971
      uCond        (cb, cond);
1972
      uFlagsRWU    (cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
1973
1974
      dis_JMP_d32  (cb, eip_next);
1975
   }
2215
   }
1976
   if (dis) VG_(printf)("%s%c\n", name, nameISize(sz));
2216
   DIP("%s%c\n", name, nameISize(sz));
1977
}
2217
}
1978
2218
1979
/*------------------------------------------------------------*/
2219
/*------------------------------------------------------------*/
Lines 2001-2016 Link Here
2001
      uInstr2(cb, MUL,	size, ArchReg, eregOfRM(rm), TempReg, tg);
2241
      uInstr2(cb, MUL,	size, ArchReg, eregOfRM(rm), TempReg, tg);
2002
      setFlagsFromUOpcode(cb, MUL);
2242
      setFlagsFromUOpcode(cb, MUL);
2003
      uInstr2(cb, PUT,  size, TempReg, tg, ArchReg, gregOfRM(rm));
2243
      uInstr2(cb, PUT,  size, TempReg, tg, ArchReg, gregOfRM(rm));
2004
      if (dis) VG_(printf)("%smul%c %s, %s\n",
2244
      DIP("%smul%c %s, %s\n", signed_multiply ? "i" : "",
2005
                           signed_multiply ? "i" : "",
2245
                              nameISize(size), 
2006
                           nameISize(size), 
2246
                              nameIReg(size,eregOfRM(rm)),
2007
                           nameIReg(size,eregOfRM(rm)),
2247
                              nameIReg(size,gregOfRM(rm)));
2008
                           nameIReg(size,gregOfRM(rm)));
2009
      return 1+eip0;
2248
      return 1+eip0;
2010
   } else {
2249
   } else {
2011
      UInt pair;
2250
      UInt pair;
2012
      vg_assert(signed_multiply);
2251
      vg_assert(signed_multiply);
2013
      pair = disAMode ( cb, sorb, eip0, dis?dis_buf:NULL);
2252
      pair = disAMode ( cb, sorb, eip0, dis_buf );
2014
      ta = LOW24(pair);
2253
      ta = LOW24(pair);
2015
      uInstr2(cb, LOAD,  size, TempReg, ta, TempReg, te);
2254
      uInstr2(cb, LOAD,  size, TempReg, ta, TempReg, te);
2016
      uInstr2(cb, GET,   size, ArchReg, gregOfRM(rm), TempReg, tg);
2255
      uInstr2(cb, GET,   size, ArchReg, gregOfRM(rm), TempReg, tg);
Lines 2018-2027 Link Here
2018
      setFlagsFromUOpcode(cb, MUL);
2257
      setFlagsFromUOpcode(cb, MUL);
2019
      uInstr2(cb, PUT,  size, TempReg, tg,    ArchReg, gregOfRM(rm));
2258
      uInstr2(cb, PUT,  size, TempReg, tg,    ArchReg, gregOfRM(rm));
2020
2259
2021
      if (dis) VG_(printf)("%smul%c %s, %s\n",
2260
      DIP("%smul%c %s, %s\n", signed_multiply ? "i" : "",
2022
                           signed_multiply ? "i" : "",
2261
                              nameISize(size), 
2023
                           nameISize(size), 
2262
                              dis_buf, nameIReg(size,gregOfRM(rm)));
2024
                           dis_buf,nameIReg(size,gregOfRM(rm)));
2025
      return HI8(pair)+eip0;
2263
      return HI8(pair)+eip0;
2026
   }
2264
   }
2027
}
2265
}
Lines 2036-2042 Link Here
2036
                      Int         litsize )
2274
                      Int         litsize )
2037
{
2275
{
2038
   Int ta, te, tl, d32;
2276
   Int ta, te, tl, d32;
2039
   UChar dis_buf[50];
2277
    Char dis_buf[50];
2040
   UChar rm = getUChar(eip);
2278
   UChar rm = getUChar(eip);
2041
   ta = INVALID_TEMPREG;
2279
   ta = INVALID_TEMPREG;
2042
   te = newTemp(cb);
2280
   te = newTemp(cb);
Lines 2046-2052 Link Here
2046
      uInstr2(cb, GET,   size, ArchReg, eregOfRM(rm), TempReg, te);
2284
      uInstr2(cb, GET,   size, ArchReg, eregOfRM(rm), TempReg, te);
2047
      eip++;
2285
      eip++;
2048
   } else {
2286
   } else {
2049
      UInt pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL);
2287
      UInt pair = disAMode ( cb, sorb, eip, dis_buf );
2050
      ta = LOW24(pair);
2288
      ta = LOW24(pair);
2051
      uInstr2(cb, LOAD,  size, TempReg, ta, TempReg, te);
2289
      uInstr2(cb, LOAD,  size, TempReg, ta, TempReg, te);
2052
      eip += HI8(pair);
2290
      eip += HI8(pair);
Lines 2061-2075 Link Here
2061
   setFlagsFromUOpcode(cb, MUL);
2299
   setFlagsFromUOpcode(cb, MUL);
2062
   uInstr2(cb, PUT,   size, TempReg, te,   ArchReg, gregOfRM(rm));
2300
   uInstr2(cb, PUT,   size, TempReg, te,   ArchReg, gregOfRM(rm));
2063
2301
2064
   if (dis) {
2302
   DIP("imul %d, %s, %s\n", d32, 
2065
      if (epartIsReg(rm)) {
2303
       ( epartIsReg(rm) ? nameIReg(size,eregOfRM(rm)) : dis_buf ),
2066
         VG_(printf)("imul %d, %s, %s\n", d32, nameIReg(size,eregOfRM(rm)),
2304
       nameIReg(size,gregOfRM(rm)) );
2067
                                          nameIReg(size,gregOfRM(rm)));
2068
      } else {
2069
         VG_(printf)("imul %d, %s, %s\n", d32, dis_buf,
2070
                                          nameIReg(size,gregOfRM(rm)));
2071
      }
2072
   }
2073
2305
2074
   return eip;
2306
   return eip;
2075
}   
2307
}   
Lines 2089-2111 Link Here
2089
   UChar second_byte = getUChar(eip);
2321
   UChar second_byte = getUChar(eip);
2090
   vg_assert(second_byte < 0xC0);
2322
   vg_assert(second_byte < 0xC0);
2091
   second_byte &= 0x38;
2323
   second_byte &= 0x38;
2092
   pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
2324
   pair = disAMode ( cb, sorb, eip, dis_buf );
2093
   ta   = LOW24(pair);
2325
   ta   = LOW24(pair);
2094
   eip  += HI8(pair);
2326
   eip  += HI8(pair);
2095
   uInstr2(cb, is_write ? FPU_W : FPU_R, size,
2327
   uInstr2(cb, is_write ? FPU_W : FPU_R, size,
2096
               Lit16, 
2328
               Lit16, 
2097
               (((UShort)first_byte) << 8) | ((UShort)second_byte),
2329
               (((UShort)first_byte) << 8) | ((UShort)second_byte),
2098
               TempReg, ta);
2330
               TempReg, ta);
2099
   if (dis) {
2331
   if (is_write) {
2100
      if (is_write)
2332
      DIP("fpu_w_%d 0x%x:0x%x, %s\n",
2101
         VG_(printf)("fpu_w_%d 0x%x:0x%x, %s\n",
2333
          size, (UInt)first_byte, (UInt)second_byte, dis_buf );
2102
                     size, (UInt)first_byte, 
2334
   } else {
2103
                           (UInt)second_byte, dis_buf );
2335
      DIP("fpu_r_%d %s, 0x%x:0x%x\n",
2104
      else
2336
          size, dis_buf, (UInt)first_byte, (UInt)second_byte );
2105
         VG_(printf)("fpu_r_%d %s, 0x%x:0x%x\n",
2106
                     size, dis_buf,
2107
                     (UInt)first_byte, 
2108
                     (UInt)second_byte );
2109
   }
2337
   }
2110
   return eip;
2338
   return eip;
2111
}
2339
}
Lines 2174-2183 Link Here
2174
      vg_assert(!uses_ZCP);
2402
      vg_assert(!uses_ZCP);
2175
   }
2403
   }
2176
2404
2177
   if (dis) VG_(printf)("fpu 0x%x:0x%x%s%s\n",
2405
   DIP("fpu 0x%x:0x%x%s%s\n", (UInt)first_byte, (UInt)second_byte,
2178
                        (UInt)first_byte, (UInt)second_byte,
2406
                              uses_ZCP ? " -rZCP" : "",
2179
                        uses_ZCP ? " -rZCP" : "",
2407
                              sets_ZCP ? " -wZCP" : "" );
2180
                        sets_ZCP ? " -wZCP" : "" );
2181
   return eip;
2408
   return eip;
2182
}
2409
}
2183
2410
Lines 2205-2211 Link Here
2205
      uInstr1(cb, POP,   2,  TempReg, t1);
2432
      uInstr1(cb, POP,   2,  TempReg, t1);
2206
      uInstr2(cb, PUT,   2,  TempReg, t1, ArchReg, R_EAX);
2433
      uInstr2(cb, PUT,   2,  TempReg, t1, ArchReg, R_EAX);
2207
      uInstr0(cb, CALLM_E, 0);
2434
      uInstr0(cb, CALLM_E, 0);
2208
      if (dis) VG_(printf)("fstsw %%ax\n");
2435
      DIP("fstsw %%ax\n");
2209
      eip++;
2436
      eip++;
2210
      return eip;
2437
      return eip;
2211
   }
2438
   }
Lines 2407-2419 Link Here
2407
      uFlagsRWU(cb, FlagsEmpty, FlagsOSZACP, FlagsEmpty);
2634
      uFlagsRWU(cb, FlagsEmpty, FlagsOSZACP, FlagsEmpty);
2408
      uInstr1(cb, POP,   sz, TempReg, t);
2635
      uInstr1(cb, POP,   sz, TempReg, t);
2409
      uInstr2(cb, PUT,   sz, TempReg, t, ArchReg, eregOfRM(modrm));
2636
      uInstr2(cb, PUT,   sz, TempReg, t, ArchReg, eregOfRM(modrm));
2410
      if (dis)
2637
      DIP("sh%cd%c %%cl, %s, %s\n",
2411
         VG_(printf)("sh%cd%c %%cl, %s, %s\n",
2638
          ( left_shift ? 'l' : 'r' ), nameISize(sz), 
2412
                     ( left_shift ? 'l' : 'r' ),
2639
          nameIReg(sz, gregOfRM(modrm)), nameIReg(sz, eregOfRM(modrm)));
2413
                     nameISize(sz), nameIReg(sz, gregOfRM(modrm)), 
2414
                     nameIReg(sz, eregOfRM(modrm)));
2415
   } else {
2640
   } else {
2416
      pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
2641
      pair = disAMode ( cb, sorb, eip, dis_buf );
2417
      ta   = LOW24(pair);
2642
      ta   = LOW24(pair);
2418
      eip  += HI8(pair);
2643
      eip  += HI8(pair);
2419
      uInstr2(cb, LOAD,  sz, TempReg, ta,     TempReg, t2);
2644
      uInstr2(cb, LOAD,  sz, TempReg, ta,     TempReg, t2);
Lines 2422-2432 Link Here
2422
      uFlagsRWU(cb, FlagsEmpty, FlagsOSZACP, FlagsEmpty);
2647
      uFlagsRWU(cb, FlagsEmpty, FlagsOSZACP, FlagsEmpty);
2423
      uInstr1(cb, POP,   sz, TempReg, t);
2648
      uInstr1(cb, POP,   sz, TempReg, t);
2424
      uInstr2(cb, STORE, sz, TempReg, t,      TempReg, ta);
2649
      uInstr2(cb, STORE, sz, TempReg, t,      TempReg, ta);
2425
      if (dis)
2650
      DIP("sh%cd%c %%cl, %s, %s\n", ( left_shift ? 'l' : 'r' ),
2426
         VG_(printf)("sh%cd%c %%cl, %s, %s\n",
2651
          nameISize(sz), nameIReg(sz, gregOfRM(modrm)), dis_buf);
2427
                     ( left_shift ? 'l' : 'r' ),
2428
                     nameISize(sz), nameIReg(sz, gregOfRM(modrm)), 
2429
                     dis_buf);
2430
   }
2652
   }
2431
  
2653
  
2432
   if (amt_tag == Literal) eip++;
2654
   if (amt_tag == Literal) eip++;
Lines 2460-2474 Link Here
2460
                  Int sz, Addr eip, BtOp op )
2682
                  Int sz, Addr eip, BtOp op )
2461
{
2683
{
2462
   UInt  pair;
2684
   UInt  pair;
2463
   UChar dis_buf[50];
2685
    Char dis_buf[50];
2464
   UChar modrm;
2686
   UChar modrm;
2465
2687
2466
   Int t_addr, t_bitno, t_mask, t_fetched, t_esp, temp, lit;
2688
   Int t_addr, t_bitno, t_mask, t_fetched, t_esp, temp, lit;
2467
2689
2468
   /* 2 and 4 are actually possible. */
2469
   vg_assert(sz == 2 || sz == 4);
2690
   vg_assert(sz == 2 || sz == 4);
2470
   /* We only handle 4. */
2471
   vg_assert(sz == 4);
2472
2691
2473
   t_addr = t_bitno = t_mask 
2692
   t_addr = t_bitno = t_mask 
2474
          = t_fetched = t_esp = temp = INVALID_TEMPREG;
2693
          = t_fetched = t_esp = temp = INVALID_TEMPREG;
Lines 2482-2499 Link Here
2482
2701
2483
   uInstr2(cb, GET,  sz, ArchReg, gregOfRM(modrm), TempReg, t_bitno);
2702
   uInstr2(cb, GET,  sz, ArchReg, gregOfRM(modrm), TempReg, t_bitno);
2484
2703
2704
   if (sz == 2) {
2705
      uInstr1(cb, WIDEN, 4, TempReg, t_bitno);
2706
      LAST_UINSTR(cb).extra4b = 2;
2707
      LAST_UINSTR(cb).signed_widen = False;
2708
   }
2709
   
2485
   if (epartIsReg(modrm)) {
2710
   if (epartIsReg(modrm)) {
2486
      eip++;
2711
      eip++;
2487
      /* Get it onto the client's stack. */
2712
      /* Get it onto the client's stack. */
2488
      t_esp = newTemp(cb);
2713
      t_esp = newTemp(cb);
2489
      t_addr = newTemp(cb);
2714
      t_addr = newTemp(cb);
2490
      uInstr2(cb, GET,   4, ArchReg,  R_ESP, TempReg, t_esp);
2715
      uInstr2(cb, GET,   4, ArchReg,  R_ESP, TempReg, t_esp);
2491
      uInstr2(cb, SUB,  sz, Literal,  0,     TempReg, t_esp);
2716
      uInstr2(cb, SUB,   4, Literal,  0,     TempReg, t_esp);
2492
      uLiteral(cb, sz);
2717
      uLiteral(cb, sz);
2493
      uInstr2(cb, PUT,   4, TempReg,  t_esp, ArchReg, R_ESP);
2718
      uInstr2(cb, PUT,   4, TempReg,  t_esp, ArchReg, R_ESP);
2494
      uInstr2(cb, GET,   sz, ArchReg, eregOfRM(modrm), TempReg, temp);
2719
      uInstr2(cb, GET,   sz, ArchReg, eregOfRM(modrm), TempReg, temp);
2495
      uInstr2(cb, STORE, sz, TempReg, temp, TempReg, t_esp);
2720
      uInstr2(cb, STORE, sz, TempReg, temp, TempReg, t_esp);
2496
      /* Make ta point at it. */
2721
      /* Make t_addr point at it. */
2497
      uInstr2(cb, MOV,   4,  TempReg, t_esp, TempReg, t_addr);
2722
      uInstr2(cb, MOV,   4,  TempReg, t_esp, TempReg, t_addr);
2498
      /* Mask out upper bits of the shift amount, since we're doing a
2723
      /* Mask out upper bits of the shift amount, since we're doing a
2499
         reg. */
2724
         reg. */
Lines 2501-2512 Link Here
2501
      uLiteral(cb, sz == 4 ? 31 : 15);
2726
      uLiteral(cb, sz == 4 ? 31 : 15);
2502
      uInstr2(cb, AND, 4, TempReg, lit, TempReg, t_bitno);
2727
      uInstr2(cb, AND, 4, TempReg, lit, TempReg, t_bitno);
2503
   } else {
2728
   } else {
2504
      pair   = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
2729
      pair   = disAMode ( cb, sorb, eip, dis_buf );
2505
      t_addr = LOW24(pair);
2730
      t_addr = LOW24(pair);
2506
      eip   += HI8(pair);
2731
      eip   += HI8(pair);
2507
   }
2732
   }
2508
  
2733
  
2509
   /* At this point: ta points to the address being operated on.  If
2734
   /* At this point: t_addr points to the address being operated on.  If
2510
      it was a reg, we will have pushed it onto the client's stack.
2735
      it was a reg, we will have pushed it onto the client's stack.
2511
      t_bitno is the bit number, suitable masked in the case of a reg.  */
2736
      t_bitno is the bit number, suitable masked in the case of a reg.  */
2512
   
2737
   
Lines 2516-2527 Link Here
2516
   uInstr2(cb, SAR, 4, Literal, 0, TempReg, temp);
2741
   uInstr2(cb, SAR, 4, Literal, 0, TempReg, temp);
2517
   uLiteral(cb, 3);
2742
   uLiteral(cb, 3);
2518
   uInstr2(cb, ADD, 4, TempReg, temp, TempReg, t_addr);
2743
   uInstr2(cb, ADD, 4, TempReg, temp, TempReg, t_addr);
2519
   /* ta now holds effective address */
2744
   /* t_addr now holds effective address */
2520
2745
2521
   uInstr2(cb, MOV, 4, Literal, 0, TempReg, lit);
2746
   uInstr2(cb, MOV, 4, Literal, 0, TempReg, lit);
2522
   uLiteral(cb, 7);
2747
   uLiteral(cb, 7);
2523
   uInstr2(cb, AND, 4, TempReg, lit, TempReg, t_bitno);
2748
   uInstr2(cb, AND, 4, TempReg, lit, TempReg, t_bitno);
2524
   /* bitno contains offset of bit within byte */
2749
   /* t_bitno contains offset of bit within byte */
2525
2750
2526
   if (op != BtOpNone) {
2751
   if (op != BtOpNone) {
2527
      t_mask = newTemp(cb);
2752
      t_mask = newTemp(cb);
Lines 2529-2535 Link Here
2529
      uLiteral(cb, 1);
2754
      uLiteral(cb, 1);
2530
      uInstr2(cb, SHL, 4, TempReg, t_bitno, TempReg, t_mask);
2755
      uInstr2(cb, SHL, 4, TempReg, t_bitno, TempReg, t_mask);
2531
   }
2756
   }
2532
   /* mask is now a suitable byte mask */
2757
   /* t_mask is now a suitable byte mask */
2533
2758
2534
   uInstr2(cb, LOAD, 1, TempReg, t_addr, TempReg, t_fetched);
2759
   uInstr2(cb, LOAD, 1, TempReg, t_addr, TempReg, t_fetched);
2535
   if (op != BtOpNone) {
2760
   if (op != BtOpNone) {
Lines 2559-2602 Link Here
2559
   uInstr2(cb, MOV, 4, Literal, 0, TempReg, lit);
2784
   uInstr2(cb, MOV, 4, Literal, 0, TempReg, lit);
2560
   uLiteral(cb, 1);
2785
   uLiteral(cb, 1);
2561
   uInstr2(cb, AND, 4, TempReg, lit, TempReg, t_fetched);
2786
   uInstr2(cb, AND, 4, TempReg, lit, TempReg, t_fetched);
2562
   /* fetched is now 1 or 0 */
2787
   /* t_fetched is now 1 or 0 */
2563
2788
2564
   /* NEG is a handy way to convert zero/nonzero into the carry
2789
   /* NEG is a handy way to convert zero/nonzero into the carry
2565
      flag. */
2790
      flag. */
2566
   uInstr1(cb, NEG, 4, TempReg, t_fetched);
2791
   uInstr1(cb, NEG, 4, TempReg, t_fetched);
2567
   setFlagsFromUOpcode(cb, NEG);
2792
   setFlagsFromUOpcode(cb, NEG);
2568
   /* fetched is now in carry flag */
2793
   /* t_fetched is now in carry flag */
2569
2794
2570
   /* Move reg operand from stack back to reg */
2795
   /* Move reg operand from stack back to reg */
2571
   if (epartIsReg(modrm)) {
2796
   if (epartIsReg(modrm)) {
2572
      /* t_esp still points at it. */
2797
      /* t_esp still points at it. */
2573
      uInstr2(cb, LOAD, sz, TempReg, t_esp, TempReg, temp);
2798
      uInstr2(cb, LOAD, sz, TempReg, t_esp, TempReg, temp);
2574
      uInstr2(cb, PUT,  sz, TempReg, temp, ArchReg, eregOfRM(modrm));
2799
      uInstr2(cb, PUT,  sz, TempReg, temp, ArchReg, eregOfRM(modrm));
2575
      uInstr2(cb, ADD,  sz, Literal, 0, TempReg, t_esp);
2800
      uInstr2(cb, ADD,  4,  Literal, 0, TempReg, t_esp);
2576
      uLiteral(cb, sz);
2801
      uLiteral(cb, sz);
2577
      uInstr2(cb, PUT,  4,  TempReg, t_esp, ArchReg, R_ESP);
2802
      uInstr2(cb, PUT,  4,  TempReg, t_esp, ArchReg, R_ESP);
2578
   }
2803
   }
2579
2804
2580
   if (epartIsReg(modrm)) {
2805
   DIP("bt%s%c %s, %s\n",
2581
      if (dis)
2806
       nameBtOp(op), nameISize(sz), nameIReg(sz, gregOfRM(modrm)), 
2582
         VG_(printf)("bt%s%c %s, %s\n",
2807
       ( epartIsReg(modrm) ? nameIReg(sz, eregOfRM(modrm)) : dis_buf ) );
2583
                     nameBtOp(op),
2584
                     nameISize(sz), nameIReg(sz, gregOfRM(modrm)), 
2585
                     nameIReg(sz, eregOfRM(modrm)));
2586
   } else {
2587
      if (dis)
2588
         VG_(printf)("bt%s%c %s, %s\n",
2589
                     nameBtOp(op),
2590
                     nameISize(sz), nameIReg(sz, gregOfRM(modrm)), 
2591
                     dis_buf);
2592
   }
2593
 
2808
 
2594
   return eip;
2809
   return eip;
2595
}
2810
}
2596
2811
2597
2812
2598
2813
2599
2600
/* Handle BSF/BSR.  Only v-size seems necessary. */
2814
/* Handle BSF/BSR.  Only v-size seems necessary. */
2601
static
2815
static
2602
Addr dis_bs_E_G ( UCodeBlock* cb, 
2816
Addr dis_bs_E_G ( UCodeBlock* cb, 
Lines 2605-2617 Link Here
2605
{
2819
{
2606
   Int   t, t1, ta, helper;
2820
   Int   t, t1, ta, helper;
2607
   UInt  pair;
2821
   UInt  pair;
2608
   UChar dis_buf[50];
2822
    Char dis_buf[50];
2609
   UChar modrm;
2823
   UChar modrm;
2824
   Bool  isReg;
2610
2825
2611
   vg_assert(sz == 2 || sz == 4);
2826
   vg_assert(sz == 2 || sz == 4);
2612
   vg_assert(sz==4);
2613
2827
2614
   helper = fwds ? VGOFF_(helper_bsf) : VGOFF_(helper_bsr);
2828
   if (fwds)
2829
      helper = sz == 2 ? VGOFF_(helper_bsfw) : VGOFF_(helper_bsfl);
2830
   else
2831
      helper = sz == 2 ? VGOFF_(helper_bsrw) : VGOFF_(helper_bsrl);
2832
   
2615
   modrm  = getUChar(eip);
2833
   modrm  = getUChar(eip);
2616
   t1     = newTemp(cb);
2834
   t1     = newTemp(cb);
2617
   t      = newTemp(cb);
2835
   t      = newTemp(cb);
Lines 2620-2644 Link Here
2620
   uInstr2(cb, GET,  sz, ArchReg, gregOfRM(modrm), TempReg, t1);
2838
   uInstr2(cb, GET,  sz, ArchReg, gregOfRM(modrm), TempReg, t1);
2621
   uInstr1(cb, PUSH, sz, TempReg, t1);
2839
   uInstr1(cb, PUSH, sz, TempReg, t1);
2622
2840
2623
   if (epartIsReg(modrm)) {
2841
   isReg = epartIsReg(modrm);
2842
   if (isReg) {
2624
      eip++;
2843
      eip++;
2625
      uInstr2(cb, GET, sz, ArchReg, eregOfRM(modrm), TempReg, t);
2844
      uInstr2(cb, GET, sz, ArchReg, eregOfRM(modrm), TempReg, t);
2626
      if (dis)
2627
         VG_(printf)("bs%c%c %s, %s\n",
2628
                     fwds ? 'f' : 'r',
2629
                     nameISize(sz), nameIReg(sz, eregOfRM(modrm)), 
2630
                     nameIReg(sz, gregOfRM(modrm)));
2631
   } else {
2845
   } else {
2632
      pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
2846
      pair = disAMode ( cb, sorb, eip, dis_buf );
2633
      ta   = LOW24(pair);
2847
      ta   = LOW24(pair);
2634
      eip  += HI8(pair);
2848
      eip  += HI8(pair);
2635
      uInstr2(cb, LOAD, sz, TempReg, ta, TempReg, t);
2849
      uInstr2(cb, LOAD, sz, TempReg, ta, TempReg, t);
2636
      if (dis)
2637
         VG_(printf)("bs%c%c %s, %s\n",
2638
                     fwds ? 'f' : 'r',
2639
                     nameISize(sz), dis_buf,
2640
                     nameIReg(sz, gregOfRM(modrm)));
2641
   }
2850
   }
2851
   DIP("bs%c%c %s, %s\n",
2852
       fwds ? 'f' : 'r', nameISize(sz), 
2853
       ( isReg ? nameIReg(sz, eregOfRM(modrm)) : dis_buf ), 
2854
       nameIReg(sz, gregOfRM(modrm)));
2642
2855
2643
   uInstr1(cb, PUSH,  sz,  TempReg, t);
2856
   uInstr1(cb, PUSH,  sz,  TempReg, t);
2644
   uInstr1(cb, CALLM, 0,   Lit16, helper);
2857
   uInstr1(cb, CALLM, 0,   Lit16, helper);
Lines 2663-2671 Link Here
2663
   uInstr2(cb, GET, sz, ArchReg, reg,   TempReg, t2);
2876
   uInstr2(cb, GET, sz, ArchReg, reg,   TempReg, t2);
2664
   uInstr2(cb, PUT, sz, TempReg, t2,    ArchReg, R_EAX);
2877
   uInstr2(cb, PUT, sz, TempReg, t2,    ArchReg, R_EAX);
2665
   uInstr2(cb, PUT, sz, TempReg, t1,    ArchReg, reg);
2878
   uInstr2(cb, PUT, sz, TempReg, t1,    ArchReg, reg);
2666
   if (dis)
2879
   DIP("xchg%c %s, %s\n", 
2667
      VG_(printf)("xchg%c %s, %s\n", nameISize(sz),
2880
       nameISize(sz), nameIReg(sz, R_EAX), nameIReg(sz, reg));
2668
                  nameIReg(sz, R_EAX), nameIReg(sz, reg));
2669
}
2881
}
2670
2882
2671
2883
Lines 2739-2760 Link Here
2739
   if (epartIsReg(rm)) {
2951
   if (epartIsReg(rm)) {
2740
     uInstr2(cb, GET, size, ArchReg, eregOfRM(rm), TempReg, dest);
2952
     uInstr2(cb, GET, size, ArchReg, eregOfRM(rm), TempReg, dest);
2741
     eip0++;
2953
     eip0++;
2742
     if (dis) VG_(printf)("cmpxchg%c %s,%s\n", 
2954
     DIP("cmpxchg%c %s,%s\n", nameISize(size),
2743
                          nameISize(size),
2955
                              nameIReg(size,gregOfRM(rm)),
2744
                          nameIReg(size,gregOfRM(rm)),
2956
                              nameIReg(size,eregOfRM(rm)) );
2745
                          nameIReg(size,eregOfRM(rm)) );
2746
   } else {
2957
   } else {
2747
      UInt pair = disAMode ( cb, sorb, eip0, dis?dis_buf:NULL );
2958
      UInt pair = disAMode ( cb, sorb, eip0, dis_buf );
2748
      ta        = LOW24(pair);
2959
      ta        = LOW24(pair);
2749
      uInstr2(cb, LOAD, size, TempReg, ta, TempReg, dest);
2960
      uInstr2(cb, LOAD, size, TempReg, ta, TempReg, dest);
2750
      eip0 += HI8(pair);
2961
      eip0 += HI8(pair);
2751
      if (dis) VG_(printf)("cmpxchg%c %s,%s\n",  nameISize(size), 
2962
      DIP("cmpxchg%c %s,%s\n", nameISize(size), 
2752
                           nameIReg(size,gregOfRM(rm)), dis_buf);
2963
                               nameIReg(size,gregOfRM(rm)), dis_buf);
2753
   }
2964
   }
2754
2965
2755
   uInstr2(cb, GET, size, ArchReg, gregOfRM(rm), TempReg, src);
2966
   uInstr2(cb, GET, size, ArchReg, gregOfRM(rm), TempReg, src);
2756
   uInstr2(cb, GET, size, ArchReg, R_EAX,        TempReg, acc);
2967
   uInstr2(cb, GET, size, ArchReg, R_EAX,        TempReg, acc);
2757
   uInstr2(cb, MOV, size, TempReg, acc,          TempReg, junk);
2968
   uInstr2(cb, MOV, 4,    TempReg, acc,          TempReg, junk);
2758
   uInstr2(cb, SUB, size, TempReg, dest,         TempReg, junk);
2969
   uInstr2(cb, SUB, size, TempReg, dest,         TempReg, junk);
2759
   setFlagsFromUOpcode(cb, SUB);
2970
   setFlagsFromUOpcode(cb, SUB);
2760
2971
Lines 2776-2781 Link Here
2776
}
2987
}
2777
2988
2778
2989
2990
static
2991
Addr dis_cmpxchg8b ( UCodeBlock* cb, 
2992
                     UChar       sorb,
2993
                     Addr        eip0 )
2994
{
2995
   Int   tal, tah, junkl, junkh, destl, desth, srcl, srch, accl, acch;
2996
   UChar dis_buf[50];
2997
   UChar rm;
2998
   UInt  pair;
2999
3000
   rm    = getUChar(eip0);
3001
   accl  = newTemp(cb);
3002
   acch  = newTemp(cb);
3003
   srcl  = newTemp(cb);
3004
   srch  = newTemp(cb);
3005
   destl = newTemp(cb);
3006
   desth = newTemp(cb);
3007
   junkl = newTemp(cb);
3008
   junkh = newTemp(cb);
3009
3010
   vg_assert(!epartIsReg(rm));
3011
3012
   pair = disAMode ( cb, sorb, eip0, dis_buf );
3013
   tal = LOW24(pair);
3014
   tah = newTemp(cb);
3015
   uInstr2(cb, MOV, 4, TempReg, tal, TempReg, tah);
3016
   uInstr2(cb, ADD, 4, Literal, 0, TempReg, tah);
3017
   uLiteral(cb, 4);
3018
   eip0 += HI8(pair);
3019
   DIP("cmpxchg8b %s\n", dis_buf);
3020
   
3021
   uInstr0(cb, CALLM_S, 0);
3022
3023
   uInstr2(cb, LOAD,  4, TempReg, tah, TempReg, desth);
3024
   uInstr1(cb, PUSH,  4, TempReg, desth);
3025
   uInstr2(cb, LOAD,  4, TempReg, tal, TempReg, destl);
3026
   uInstr1(cb, PUSH,  4, TempReg, destl);
3027
   uInstr2(cb, GET,   4, ArchReg, R_ECX, TempReg, srch);
3028
   uInstr1(cb, PUSH,  4, TempReg, srch);
3029
   uInstr2(cb, GET,   4, ArchReg, R_EBX, TempReg, srcl);
3030
   uInstr1(cb, PUSH,  4, TempReg, srcl);
3031
   uInstr2(cb, GET,   4, ArchReg, R_EDX, TempReg, acch);
3032
   uInstr1(cb, PUSH,  4, TempReg, acch);
3033
   uInstr2(cb, GET,   4, ArchReg, R_EAX, TempReg, accl);
3034
   uInstr1(cb, PUSH,  4, TempReg, accl);
3035
   
3036
   uInstr1(cb, CALLM, 0, Lit16,   VGOFF_(helper_cmpxchg8b));
3037
   uFlagsRWU(cb, FlagsEmpty, FlagZ, FlagsEmpty);
3038
   
3039
   uInstr1(cb, POP,   4, TempReg, accl);
3040
   uInstr2(cb, PUT,   4, TempReg, accl, ArchReg, R_EAX);
3041
   uInstr1(cb, POP,   4, TempReg, acch);
3042
   uInstr2(cb, PUT,   4, TempReg, acch, ArchReg, R_EDX);
3043
   uInstr1(cb, POP,   4, TempReg, srcl);
3044
   uInstr2(cb, PUT,   4, TempReg, srcl, ArchReg, R_EBX);
3045
   uInstr1(cb, POP,   4, TempReg, srch);
3046
   uInstr2(cb, PUT,   4, TempReg, srch, ArchReg, R_ECX);
3047
   uInstr1(cb, POP,   4, TempReg, destl);
3048
   uInstr2(cb, STORE, 4, TempReg, destl, TempReg, tal);
3049
   uInstr1(cb, POP,   4, TempReg, desth);
3050
   uInstr2(cb, STORE, 4, TempReg, desth, TempReg, tah);
3051
3052
   uInstr0(cb, CALLM_E, 0);
3053
   
3054
   return eip0;
3055
}
3056
3057
2779
/* Handle conditional move instructions of the form
3058
/* Handle conditional move instructions of the form
2780
      cmovcc E(reg-or-mem), G(reg)
3059
      cmovcc E(reg-or-mem), G(reg)
2781
3060
Lines 2813-2829 Link Here
2813
      uCond(cb, cond);
3092
      uCond(cb, cond);
2814
      uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
3093
      uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
2815
      uInstr2(cb, PUT, size, TempReg, tmpd, ArchReg, gregOfRM(rm));
3094
      uInstr2(cb, PUT, size, TempReg, tmpd, ArchReg, gregOfRM(rm));
2816
      if (dis) VG_(printf)("cmov%c%s %s,%s\n", 
3095
      DIP("cmov%c%s %s,%s\n", nameISize(size), 
2817
                           nameISize(size), 
3096
                              VG_(name_UCondcode)(cond),
2818
                           VG_(name_UCondcode)(cond),
3097
                              nameIReg(size,eregOfRM(rm)),
2819
                           nameIReg(size,eregOfRM(rm)),
3098
                              nameIReg(size,gregOfRM(rm)));
2820
                           nameIReg(size,gregOfRM(rm)));
2821
      return 1+eip0;
3099
      return 1+eip0;
2822
   }
3100
   }
2823
3101
2824
   /* E refers to memory */    
3102
   /* E refers to memory */    
2825
   {
3103
   {
2826
      UInt pair = disAMode ( cb, sorb, eip0, dis?dis_buf:NULL);
3104
      UInt pair = disAMode ( cb, sorb, eip0, dis_buf );
2827
      Int  tmpa = LOW24(pair);
3105
      Int  tmpa = LOW24(pair);
2828
      uInstr2(cb, LOAD, size, TempReg, tmpa, TempReg, tmps);
3106
      uInstr2(cb, LOAD, size, TempReg, tmpa, TempReg, tmps);
2829
      uInstr2(cb, GET,  size, ArchReg, gregOfRM(rm), TempReg, tmpd);
3107
      uInstr2(cb, GET,  size, ArchReg, gregOfRM(rm), TempReg, tmpd);
Lines 2831-2841 Link Here
2831
      uCond(cb, cond);
3109
      uCond(cb, cond);
2832
      uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
3110
      uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
2833
      uInstr2(cb, PUT, size, TempReg, tmpd, ArchReg, gregOfRM(rm));
3111
      uInstr2(cb, PUT, size, TempReg, tmpd, ArchReg, gregOfRM(rm));
2834
      if (dis) VG_(printf)("cmov%c%s %s,%s\n", 
3112
      DIP("cmov%c%s %s,%s\n", nameISize(size), 
2835
                           nameISize(size), 
3113
                              VG_(name_UCondcode)(cond),
2836
                           VG_(name_UCondcode)(cond),
3114
                              dis_buf,
2837
                           dis_buf,
3115
                              nameIReg(size,gregOfRM(rm)));
2838
                           nameIReg(size,gregOfRM(rm)));
2839
      return HI8(pair)+eip0;
3116
      return HI8(pair)+eip0;
2840
   }
3117
   }
2841
}
3118
}
Lines 2860-2872 Link Here
2860
      setFlagsFromUOpcode(cb, ADD);
3137
      setFlagsFromUOpcode(cb, ADD);
2861
      uInstr2(cb, PUT, sz, TempReg, tmpt, ArchReg, eregOfRM(rm));
3138
      uInstr2(cb, PUT, sz, TempReg, tmpt, ArchReg, eregOfRM(rm));
2862
      uInstr2(cb, PUT, sz, TempReg, tmpd, ArchReg, gregOfRM(rm));
3139
      uInstr2(cb, PUT, sz, TempReg, tmpd, ArchReg, gregOfRM(rm));
2863
      if (dis)
3140
      DIP("xadd%c %s, %s\n", 
2864
         VG_(printf)("xadd%c %s, %s\n", nameISize(sz), 
3141
          nameISize(sz), nameIReg(sz,gregOfRM(rm)), nameIReg(sz,eregOfRM(rm)));
2865
                     nameIReg(sz,gregOfRM(rm)), 
2866
                     nameIReg(sz,eregOfRM(rm)));
2867
      return 1+eip0;
3142
      return 1+eip0;
2868
   } else {
3143
   } else {
2869
      UInt pair = disAMode ( cb, sorb, eip0, dis?dis_buf:NULL);
3144
      UInt pair = disAMode ( cb, sorb, eip0, dis_buf );
2870
      Int  tmpa  = LOW24(pair);
3145
      Int  tmpa  = LOW24(pair);
2871
      uInstr2(cb, LOAD, sz, TempReg, tmpa,          TempReg, tmpd);
3146
      uInstr2(cb, LOAD, sz, TempReg, tmpa,          TempReg, tmpd);
2872
      uInstr2(cb, GET,  sz, ArchReg, gregOfRM(rm),  TempReg, tmpt);
3147
      uInstr2(cb, GET,  sz, ArchReg, gregOfRM(rm),  TempReg, tmpt);
Lines 2874-2883 Link Here
2874
      setFlagsFromUOpcode(cb, ADD);
3149
      setFlagsFromUOpcode(cb, ADD);
2875
      uInstr2(cb, STORE, sz, TempReg, tmpt, TempReg, tmpa);
3150
      uInstr2(cb, STORE, sz, TempReg, tmpt, TempReg, tmpa);
2876
      uInstr2(cb, PUT, sz, TempReg, tmpd, ArchReg, gregOfRM(rm));
3151
      uInstr2(cb, PUT, sz, TempReg, tmpd, ArchReg, gregOfRM(rm));
2877
      if (dis)
3152
      DIP("xadd%c %s, %s\n", 
2878
         VG_(printf)("xadd%c %s, %s\n", nameISize(sz), 
3153
          nameISize(sz), nameIReg(sz,gregOfRM(rm)), dis_buf);
2879
                     nameIReg(sz,gregOfRM(rm)), 
2880
                     dis_buf);
2881
      return HI8(pair)+eip0;
3154
      return HI8(pair)+eip0;
2882
   }
3155
   }
2883
}
3156
}
Lines 2911-2931 Link Here
2911
      Int tmpv = newTemp(cb);
3184
      Int tmpv = newTemp(cb);
2912
      uInstr2(cb, GET,    2, ArchReg, eregOfRM(rm), TempReg, tmpv);
3185
      uInstr2(cb, GET,    2, ArchReg, eregOfRM(rm), TempReg, tmpv);
2913
      uInstr2(cb, PUTSEG, 2, TempReg, tmpv, ArchRegS, gregOfRM(rm));
3186
      uInstr2(cb, PUTSEG, 2, TempReg, tmpv, ArchRegS, gregOfRM(rm));
2914
      if (dis) VG_(printf)("movw %s,%s\n",
3187
      DIP("movw %s,%s\n", nameIReg(2,eregOfRM(rm)), nameSReg(gregOfRM(rm)));
2915
                           nameIReg(2,eregOfRM(rm)),
2916
                           nameSReg(gregOfRM(rm)));
2917
      return 1+eip0;
3188
      return 1+eip0;
2918
   }
3189
   }
2919
3190
2920
   /* E refers to memory */    
3191
   /* E refers to memory */    
2921
   {
3192
   {
2922
      UInt pair = disAMode ( cb, sorb, eip0, dis?dis_buf:NULL);
3193
      UInt pair = disAMode ( cb, sorb, eip0, dis_buf );
2923
      Int  tmpa = LOW24(pair);
3194
      Int  tmpa = LOW24(pair);
2924
      Int  tmpb = newTemp(cb);
3195
      Int  tmpb = newTemp(cb);
2925
      uInstr2(cb, LOAD,   2, TempReg, tmpa, TempReg, tmpb);
3196
      uInstr2(cb, LOAD,   2, TempReg, tmpa, TempReg, tmpb);
2926
      uInstr2(cb, PUTSEG, 2, TempReg, tmpb, ArchRegS, gregOfRM(rm));
3197
      uInstr2(cb, PUTSEG, 2, TempReg, tmpb, ArchRegS, gregOfRM(rm));
2927
      if (dis) VG_(printf)("movw %s,%s\n",
3198
      DIP("movw %s,%s\n", dis_buf,nameSReg(gregOfRM(rm)));
2928
                           dis_buf,nameSReg(gregOfRM(rm)));
2929
      return HI8(pair)+eip0;
3199
      return HI8(pair)+eip0;
2930
   }
3200
   }
2931
}
3201
}
Lines 2959-2979 Link Here
2959
      Int tmpv = newTemp(cb);
3229
      Int tmpv = newTemp(cb);
2960
      uInstr2(cb, GETSEG, 2, ArchRegS, gregOfRM(rm), TempReg, tmpv);
3230
      uInstr2(cb, GETSEG, 2, ArchRegS, gregOfRM(rm), TempReg, tmpv);
2961
      uInstr2(cb, PUT,    2, TempReg, tmpv, ArchReg, eregOfRM(rm));
3231
      uInstr2(cb, PUT,    2, TempReg, tmpv, ArchReg, eregOfRM(rm));
2962
      if (dis) VG_(printf)("movw %s,%s\n",
3232
      DIP("movw %s,%s\n", nameSReg(gregOfRM(rm)), nameIReg(2,eregOfRM(rm)));
2963
                           nameSReg(gregOfRM(rm)),
2964
                           nameIReg(2,eregOfRM(rm)));
2965
      return 1+eip0;
3233
      return 1+eip0;
2966
   }
3234
   }
2967
3235
2968
   /* E refers to memory */    
3236
   /* E refers to memory */    
2969
   {
3237
   {
2970
      UInt pair = disAMode ( cb, sorb, eip0, dis?dis_buf:NULL);
3238
      UInt pair = disAMode ( cb, sorb, eip0, dis_buf );
2971
      Int  tmpa = LOW24(pair);
3239
      Int  tmpa = LOW24(pair);
2972
      Int  tmpv = newTemp(cb);
3240
      Int  tmpv = newTemp(cb);
2973
      uInstr2(cb, GETSEG, 2, ArchRegS, gregOfRM(rm), TempReg, tmpv);
3241
      uInstr2(cb, GETSEG, 2, ArchRegS, gregOfRM(rm), TempReg, tmpv);
2974
      uInstr2(cb, STORE,  2, TempReg, tmpv, TempReg, tmpa);
3242
      uInstr2(cb, STORE,  2, TempReg, tmpv, TempReg, tmpa);
2975
      if (dis) VG_(printf)("mov %s,%s\n",
3243
      DIP("mov %s,%s\n", nameSReg(gregOfRM(rm)), dis_buf);
2976
                           nameSReg(gregOfRM(rm)), dis_buf);
2977
      return HI8(pair)+eip0;
3244
      return HI8(pair)+eip0;
2978
   }
3245
   }
2979
}
3246
}
Lines 2994-3028 Link Here
2994
                               Char* name,
3261
                               Char* name,
2995
                               Bool show_granularity )
3262
                               Bool show_granularity )
2996
{
3263
{
2997
   UChar dis_buf[50];
3264
    Char dis_buf[50];
2998
   UChar modrm;
3265
   UChar modrm = getUChar(eip);
2999
   modrm = getUChar(eip);
3266
   Bool  isReg = epartIsReg(modrm);
3000
   if (epartIsReg(modrm)) {
3267
3268
   if (isReg) {
3001
      eip++;
3269
      eip++;
3002
      uInstr1(cb, MMX2, 0, 
3270
      uInstr1(cb, MMX2, 0, 
3003
                  Lit16, 
3271
                  Lit16, 
3004
                  (((UShort)(opc)) << 8) | ((UShort)modrm) );
3272
                  (((UShort)(opc)) << 8) | ((UShort)modrm) );
3005
      if (dis)
3006
         VG_(printf)("%s%s %s, %s\n", 
3007
                     name,
3008
                     show_granularity ? nameMMXGran(opc & 3) : (Char*)"",
3009
                     nameMMXReg(eregOfRM(modrm)),
3010
                     nameMMXReg(gregOfRM(modrm)));
3011
   } else {
3273
   } else {
3012
      UInt pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
3274
      UInt pair = disAMode ( cb, sorb, eip, dis_buf );
3013
      Int  tmpa = LOW24(pair);
3275
      Int  tmpa = LOW24(pair);
3014
      eip += HI8(pair);
3276
      eip += HI8(pair);
3015
      uInstr2(cb, MMX2_MemRd, 8, 
3277
      uInstr2(cb, MMX2_MemRd, 8, 
3016
                  Lit16, 
3278
                  Lit16, 
3017
                  (((UShort)(opc)) << 8) | ((UShort)modrm),
3279
                  (((UShort)(opc)) << 8) | ((UShort)modrm),
3018
                  TempReg, tmpa);
3280
                  TempReg, tmpa);
3019
      if (dis)
3020
         VG_(printf)("%s%s %s, %s\n", 
3021
                     name,
3022
                     show_granularity ? nameMMXGran(opc & 3) : (Char*)"",
3023
                     dis_buf,
3024
                     nameMMXReg(gregOfRM(modrm)));
3025
   }
3281
   }
3282
3283
   DIP("%s%s %s, %s\n", 
3284
       name, show_granularity ? nameMMXGran(opc & 3) : (Char*)"",
3285
       ( isReg ? nameMMXReg(eregOfRM(modrm)) : dis_buf ),
3286
       nameMMXReg(gregOfRM(modrm)) );
3287
3026
   return eip;
3288
   return eip;
3027
}
3289
}
3028
3290
Lines 3045-3076 Link Here
3045
                           UChar opc2, 
3307
                           UChar opc2, 
3046
                           UChar opc3 )
3308
                           UChar opc3 )
3047
{
3309
{
3048
   UChar dis_buf[50];
3310
    Char dis_buf[50];
3049
   UChar modrm = getUChar(eip);
3311
   UChar modrm = getUChar(eip);
3050
   if (epartIsReg(modrm)) {
3312
   Bool  isReg = epartIsReg(modrm);
3313
3314
   if (isReg) {
3051
      /* Completely internal SSE insn. */
3315
      /* Completely internal SSE insn. */
3052
      uInstr2(cb, SSE4, 0,  /* ignore sz for internal ops */
3316
      uInstr2(cb, SSE4, 0,  /* ignore sz for internal ops */
3053
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3317
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3054
                  Lit16, (((UShort)opc3) << 8) | (UShort)modrm );
3318
                  Lit16, (((UShort)opc3) << 8) | (UShort)modrm );
3055
      if (dis)
3056
         VG_(printf)("%s %s, %s\n", name, 
3057
                     nameXMMReg(eregOfRM(modrm)), 
3058
                     nameXMMReg(gregOfRM(modrm)) );
3059
      eip++;
3319
      eip++;
3060
   } else {
3320
   } else {
3061
      UInt pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
3321
      UInt pair = disAMode ( cb, sorb, eip, dis_buf );
3062
      Int  tmpa = LOW24(pair);
3322
      Int  tmpa = LOW24(pair);
3063
      eip += HI8(pair);
3323
      eip += HI8(pair);
3064
      uInstr3(cb, SSE3a_MemRd, sz,
3324
      uInstr3(cb, SSE3a_MemRd, sz,
3065
                  Lit16, (((UShort)(opc1)) << 8) | ((UShort)opc2),
3325
                  Lit16, (((UShort)(opc1)) << 8) | ((UShort)opc2),
3066
                  Lit16, (((UShort)(opc3)) << 8) | ((UShort)modrm),
3326
                  Lit16, (((UShort)(opc3)) << 8) | ((UShort)modrm),
3067
                  TempReg, tmpa);
3327
                  TempReg, tmpa);
3068
      if (dis)
3069
         VG_(printf)("%s %s, %s\n", 
3070
                     name,
3071
                     dis_buf,
3072
                     nameXMMReg(gregOfRM(modrm)));
3073
   }
3328
   }
3329
3330
   DIP("%s %s, %s\n", 
3331
       name, 
3332
       ( isReg ? nameXMMReg(eregOfRM(modrm)) : dis_buf ),
3333
       nameXMMReg(gregOfRM(modrm)) );
3334
3074
   return eip;
3335
   return eip;
3075
}
3336
}
3076
3337
Lines 3091-3122 Link Here
3091
                           UChar opc1, 
3352
                           UChar opc1, 
3092
                           UChar opc2 )
3353
                           UChar opc2 )
3093
{
3354
{
3094
   UChar dis_buf[50];
3355
    Char dis_buf[50];
3095
   UChar modrm = getUChar(eip);
3356
   UChar modrm = getUChar(eip);
3096
   if (epartIsReg(modrm)) {
3357
   Bool  isReg = epartIsReg(modrm);
3358
3359
   if (isReg) {
3097
      /* Completely internal SSE insn. */
3360
      /* Completely internal SSE insn. */
3098
      uInstr2(cb, SSE3, 0,  /* ignore sz for internal ops */
3361
      uInstr2(cb, SSE3, 0,  /* ignore sz for internal ops */
3099
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3362
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3100
                  Lit16, (UShort)modrm );
3363
                  Lit16, (UShort)modrm );
3101
      if (dis)
3102
         VG_(printf)("%s %s, %s\n", name, 
3103
                     nameXMMReg(eregOfRM(modrm)), 
3104
                     nameXMMReg(gregOfRM(modrm)) );
3105
      eip++;
3364
      eip++;
3106
   } else {
3365
   } else {
3107
      UInt pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
3366
      UInt pair = disAMode ( cb, sorb, eip, dis_buf );
3108
      Int  tmpa = LOW24(pair);
3367
      Int  tmpa = LOW24(pair);
3109
      eip += HI8(pair);
3368
      eip += HI8(pair);
3110
      uInstr3(cb, SSE2a_MemRd, sz,
3369
      uInstr3(cb, SSE2a_MemRd, sz,
3111
                  Lit16, (((UShort)(opc1)) << 8) | ((UShort)opc2),
3370
                  Lit16, (((UShort)(opc1)) << 8) | ((UShort)opc2),
3112
                  Lit16, (UShort)modrm,
3371
                  Lit16, (UShort)modrm,
3113
                  TempReg, tmpa);
3372
                  TempReg, tmpa);
3114
      if (dis)
3115
         VG_(printf)("%s %s, %s\n", 
3116
                     name,
3117
                     dis_buf,
3118
                     nameXMMReg(gregOfRM(modrm)));
3119
   }
3373
   }
3374
   DIP("%s %s, %s\n", 
3375
       name, 
3376
       ( isReg ? nameXMMReg(eregOfRM(modrm)) : dis_buf ), 
3377
       nameXMMReg(gregOfRM(modrm)) );
3378
3120
   return eip;
3379
   return eip;
3121
}
3380
}
3122
3381
Lines 3137-3159 Link Here
3137
				UChar opc1, 
3396
				UChar opc1, 
3138
				UChar opc2 )
3397
				UChar opc2 )
3139
{
3398
{
3140
   UChar dis_buf[50];
3399
    Char dis_buf[50];
3141
   UChar modrm = getUChar(eip);
3400
   UChar modrm = getUChar(eip);
3142
   UChar imm8;
3401
   UChar imm8;
3143
   if (epartIsReg(modrm)) {
3402
   Bool  isReg = epartIsReg(modrm);
3403
3404
   if (isReg) {
3144
      /* Completely internal SSE insn. */
3405
      /* Completely internal SSE insn. */
3145
      eip++;
3406
      eip++;
3146
      imm8 = getUChar(eip);
3407
      imm8 = getUChar(eip);
3147
      uInstr2(cb, SSE4, 0,  /* ignore sz for internal ops */
3408
      uInstr2(cb, SSE4, 0,  /* ignore sz for internal ops */
3148
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3409
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3149
                  Lit16, (((UShort)modrm) << 8) | (UShort)imm8 );
3410
                  Lit16, (((UShort)modrm) << 8) | (UShort)imm8 );
3150
      if (dis)
3151
         VG_(printf)("%s %s, %s, $%d\n", name, 
3152
                     nameXMMReg(eregOfRM(modrm)), 
3153
                     nameXMMReg(gregOfRM(modrm)), (Int)imm8 );
3154
      eip++;
3411
      eip++;
3155
   } else {
3412
   } else {
3156
      UInt pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
3413
      UInt pair = disAMode ( cb, sorb, eip, dis_buf );
3157
      Int  tmpa = LOW24(pair);
3414
      Int  tmpa = LOW24(pair);
3158
      eip += HI8(pair);
3415
      eip += HI8(pair);
3159
      imm8 = getUChar(eip);
3416
      imm8 = getUChar(eip);
Lines 3162-3173 Link Here
3162
                  Lit16, (((UShort)(opc1)) << 8) | ((UShort)opc2),
3419
                  Lit16, (((UShort)(opc1)) << 8) | ((UShort)opc2),
3163
                  Lit16, (((UShort)(modrm)) << 8) | ((UShort)imm8),
3420
                  Lit16, (((UShort)(modrm)) << 8) | ((UShort)imm8),
3164
                  TempReg, tmpa);
3421
                  TempReg, tmpa);
3165
      if (dis)
3166
         VG_(printf)("%s %s, %s, $%d\n", 
3167
                     name,
3168
                     dis_buf,
3169
                     nameXMMReg(gregOfRM(modrm)), (Int)imm8 );
3170
   }
3422
   }
3423
   DIP("%s %s, %s, $%d\n", 
3424
       name, ( isReg ? nameXMMReg(eregOfRM(modrm)) : dis_buf ), 
3425
       nameXMMReg(gregOfRM(modrm)), (Int)imm8 );
3171
   return eip;
3426
   return eip;
3172
}
3427
}
3173
3428
Lines 3189-3198 Link Here
3189
				UChar opc2,
3444
				UChar opc2,
3190
                                UChar opc3 )
3445
                                UChar opc3 )
3191
{
3446
{
3192
   UChar dis_buf[50];
3447
    Char dis_buf[50];
3193
   UChar modrm = getUChar(eip);
3448
   UChar modrm = getUChar(eip);
3194
   UChar imm8;
3449
   UChar imm8;
3195
   if (epartIsReg(modrm)) {
3450
   Bool  isReg = epartIsReg(modrm);
3451
3452
   if (isReg) {
3196
      /* Completely internal SSE insn. */
3453
      /* Completely internal SSE insn. */
3197
      eip++;
3454
      eip++;
3198
      imm8 = getUChar(eip);
3455
      imm8 = getUChar(eip);
Lines 3200-3212 Link Here
3200
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3457
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3201
                  Lit16, (((UShort)opc3) << 8) | (UShort)modrm,
3458
                  Lit16, (((UShort)opc3) << 8) | (UShort)modrm,
3202
                  Lit16, (UShort)imm8 );
3459
                  Lit16, (UShort)imm8 );
3203
      if (dis)
3204
         VG_(printf)("%s %s, %s, $%d\n", name, 
3205
                     nameXMMReg(eregOfRM(modrm)), 
3206
                     nameXMMReg(gregOfRM(modrm)), (Int)imm8 );
3207
      eip++;
3460
      eip++;
3208
   } else {
3461
   } else {
3209
      UInt pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
3462
      UInt pair = disAMode ( cb, sorb, eip, dis_buf );
3210
      Int  tmpa = LOW24(pair);
3463
      Int  tmpa = LOW24(pair);
3211
      eip += HI8(pair);
3464
      eip += HI8(pair);
3212
      imm8 = getUChar(eip);
3465
      imm8 = getUChar(eip);
Lines 3216-3227 Link Here
3216
                  Lit16, (((UShort)(opc3)) << 8) | ((UShort)modrm),
3469
                  Lit16, (((UShort)(opc3)) << 8) | ((UShort)modrm),
3217
                  TempReg, tmpa);
3470
                  TempReg, tmpa);
3218
      uLiteral(cb, imm8);
3471
      uLiteral(cb, imm8);
3219
      if (dis)
3220
         VG_(printf)("%s %s, %s, $%d\n", 
3221
                     name,
3222
                     dis_buf,
3223
                     nameXMMReg(gregOfRM(modrm)), (Int)imm8 );
3224
   }
3472
   }
3473
   DIP("%s %s, %s, $%d\n", 
3474
       name, ( isReg ? nameXMMReg(eregOfRM(modrm)) : dis_buf ), 
3475
       nameXMMReg(gregOfRM(modrm)), (Int)imm8 );
3225
   return eip;
3476
   return eip;
3226
}
3477
}
3227
3478
Lines 3241-3279 Link Here
3241
                                  UChar insn1, 
3492
                                  UChar insn1, 
3242
                                  UChar insn2 )
3493
                                  UChar insn2 )
3243
{
3494
{
3244
   UChar dis_buf[50];
3495
    Char dis_buf[50];
3245
   UChar modrm; 
3496
   UChar modrm = getUChar(eip);
3497
   Bool  isReg = epartIsReg(modrm);
3246
   UInt  pair;
3498
   UInt  pair;
3247
   Int   t1;
3499
   Int   t1;
3248
   modrm = getUChar(eip);
3500
3249
   if (epartIsReg(modrm)) {
3501
   if (isReg) {
3250
      /* Completely internal; we can issue SSE4. */
3502
      /* Completely internal; we can issue SSE4. */
3251
      eip++;
3503
      eip++;
3252
      uInstr2(cb, SSE4, 0, /* ignore sz for internal ops */
3504
      uInstr2(cb, SSE4, 0, /* ignore sz for internal ops */
3253
                  Lit16, (((UShort)insn0) << 8) | (UShort)insn1,
3505
                  Lit16, (((UShort)insn0) << 8) | (UShort)insn1,
3254
                  Lit16, (((UShort)insn2) << 8) | (UShort)modrm );
3506
                  Lit16, (((UShort)insn2) << 8) | (UShort)modrm );
3255
      if (dis && is_store)
3256
         VG_(printf)("%s %s, %s\n", name,
3257
                     nameXMMReg(gregOfRM(modrm)),
3258
                     nameXMMReg(eregOfRM(modrm)) );
3259
      if (dis && !is_store)
3260
         VG_(printf)("%s %s, %s\n", name,
3261
                      nameXMMReg(eregOfRM(modrm)), 
3262
                      nameXMMReg(gregOfRM(modrm)) );
3263
   } else {
3507
   } else {
3264
      pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
3508
      pair = disAMode ( cb, sorb, eip, dis_buf );
3265
      t1   = LOW24(pair);
3509
      t1   = LOW24(pair);
3266
      eip += HI8(pair);
3510
      eip += HI8(pair);
3267
      uInstr3(cb, is_store ? SSE3a_MemWr : SSE3a_MemRd, sz,
3511
      uInstr3(cb, is_store ? SSE3a_MemWr : SSE3a_MemRd, sz,
3268
                  Lit16, (((UShort)insn0) << 8) | (UShort)insn1,
3512
                  Lit16, (((UShort)insn0) << 8) | (UShort)insn1,
3269
                  Lit16, (((UShort)insn2) << 8) | (UShort)modrm,
3513
                  Lit16, (((UShort)insn2) << 8) | (UShort)modrm,
3270
                  TempReg, t1 );
3514
                  TempReg, t1 );
3271
      if (dis && is_store)
3515
   }
3272
         VG_(printf)("%s %s, %s\n", name,
3516
3273
                     nameXMMReg(gregOfRM(modrm)), dis_buf );
3517
   if (is_store) {
3274
      if (dis && !is_store)
3518
      DIP("%s %s, %s\n", 
3275
         VG_(printf)("%s %s, %s\n", name,
3519
          name,
3276
                     dis_buf, nameXMMReg(gregOfRM(modrm)) );
3520
          nameXMMReg(gregOfRM(modrm)),
3521
          ( isReg ? nameXMMReg(eregOfRM(modrm)) : dis_buf ) );
3522
   } else {
3523
      DIP("%s %s, %s\n", 
3524
          name,
3525
          ( isReg ? nameXMMReg(eregOfRM(modrm)) : dis_buf ),
3526
          nameXMMReg(gregOfRM(modrm)) );
3277
   }
3527
   }
3278
   return eip;
3528
   return eip;
3279
}
3529
}
Lines 3292-3373 Link Here
3292
                                  UChar insn0, 
3542
                                  UChar insn0, 
3293
                                  UChar insn1 )
3543
                                  UChar insn1 )
3294
{
3544
{
3295
   UChar dis_buf[50];
3545
    Char dis_buf[50];
3296
   UChar modrm; 
3546
   UChar modrm = getUChar(eip);
3547
   Bool  isReg = epartIsReg(modrm);
3297
   UInt  pair;
3548
   UInt  pair;
3298
   Int   t1;
3549
   Int   t1;
3299
   modrm = getUChar(eip);
3550
3300
   if (epartIsReg(modrm)) {
3551
   if (isReg) {
3301
      /* Completely internal; we can issue SSE3. */
3552
      /* Completely internal; we can issue SSE3. */
3302
      eip++;
3553
      eip++;
3303
      uInstr2(cb, SSE3, 0, /* ignore sz for internal ops */
3554
      uInstr2(cb, SSE3, 0, /* ignore sz for internal ops */
3304
                  Lit16, (((UShort)insn0) << 8) | (UShort)insn1,
3555
                  Lit16, (((UShort)insn0) << 8) | (UShort)insn1,
3305
                  Lit16, (UShort)modrm );
3556
                  Lit16, (UShort)modrm );
3306
      if (dis && is_store)
3307
         VG_(printf)("%s %s, %s\n", name,
3308
                     nameXMMReg(gregOfRM(modrm)),
3309
                     nameXMMReg(eregOfRM(modrm)) );
3310
      if (dis && !is_store)
3311
         VG_(printf)("%s %s, %s\n", name,
3312
                      nameXMMReg(eregOfRM(modrm)), 
3313
                      nameXMMReg(gregOfRM(modrm)) );
3314
   } else {
3557
   } else {
3315
      pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
3558
      pair = disAMode ( cb, sorb, eip, dis_buf );
3316
      t1   = LOW24(pair);
3559
      t1   = LOW24(pair);
3317
      eip += HI8(pair);
3560
      eip += HI8(pair);
3318
      uInstr3(cb, is_store ? SSE2a_MemWr : SSE2a_MemRd, sz,
3561
      uInstr3(cb, is_store ? SSE2a_MemWr : SSE2a_MemRd, sz,
3319
                  Lit16, (((UShort)insn0) << 8) | (UShort)insn1,
3562
                  Lit16, (((UShort)insn0) << 8) | (UShort)insn1,
3320
                  Lit16, (UShort)modrm,
3563
                  Lit16, (UShort)modrm,
3321
                  TempReg, t1 );
3564
                  TempReg, t1 );
3322
      if (dis && is_store)
3565
   }
3323
         VG_(printf)("%s %s, %s\n", name,
3566
3324
                     nameXMMReg(gregOfRM(modrm)), dis_buf );
3567
   if (is_store) {
3325
      if (dis && !is_store)
3568
      DIP("%s %s, %s\n",
3326
         VG_(printf)("%s %s, %s\n", name,
3569
          name,
3327
                     dis_buf, nameXMMReg(gregOfRM(modrm)) );
3570
          nameXMMReg(gregOfRM(modrm)),
3571
          ( isReg ? nameXMMReg(eregOfRM(modrm)) : dis_buf ) );
3572
   } else {
3573
      DIP("%s %s, %s\n",
3574
          name,
3575
          ( isReg ? nameXMMReg(eregOfRM(modrm)) : dis_buf ),
3576
          nameXMMReg(gregOfRM(modrm)) );
3328
   }
3577
   }
3329
   return eip;
3578
   return eip;
3330
}
3579
}
3331
3580
3332
static 
3333
void dis_push_segreg ( UCodeBlock* cb, UInt sreg, Int sz )
3334
{
3335
    Int t1 = newTemp(cb), t2 = newTemp(cb);
3336
    vg_assert(sz == 4);
3337
    uInstr2(cb, GETSEG, 2, ArchRegS, sreg,  TempReg, t1);
3338
    uInstr2(cb, GET,    4, ArchReg,  R_ESP, TempReg, t2);
3339
    uInstr2(cb, SUB,    4, Literal,  0,     TempReg, t2);
3340
    uLiteral(cb, 4);
3341
    uInstr2(cb, PUT,    4, TempReg,  t2,    ArchReg, R_ESP);
3342
    uInstr2(cb, STORE,  2, TempReg,  t1,    TempReg, t2);
3343
    if (dis)
3344
       VG_(printf)("push %s\n", VG_(name_of_seg_reg)(sreg));
3345
}
3346
3581
3582
/* Simple SSE operations, either 
3583
       op   (src)xmmreg, (dst)mmxreg
3584
   or
3585
       op   (src)address, (dst)mmxreg
3586
   2 opcode bytes.
3587
   Supplied eip points to the first address mode byte.
3588
*/
3347
static
3589
static
3348
void dis_pop_segreg ( UCodeBlock* cb, UInt sreg, Int sz )
3590
Addr dis_SSE2_to_MMX ( UCodeBlock *cb,
3591
                       UChar sorb,
3592
                       Addr eip,
3593
                       Int sz, 
3594
                       Char* name, 
3595
                       UChar opc1, 
3596
                       UChar opc2 )
3349
{
3597
{
3350
   Int t1 = newTemp(cb), t2 = newTemp(cb);
3598
   UChar dis_buf[50];
3351
   vg_assert(sz == 4);
3599
   UChar modrm = getUChar(eip);
3352
   uInstr2(cb, GET,    4, ArchReg, R_ESP,    TempReg,  t2);
3600
   if (epartIsReg(modrm)) {
3353
   uInstr2(cb, LOAD,   2, TempReg, t2,       TempReg,  t1);
3601
      /* Completely internal SSE insn. */
3354
   uInstr2(cb, ADD,    4, Literal, 0,        TempReg,  t2);
3602
      uInstr2(cb, SSE3, 0,  /* ignore sz for internal ops */
3355
   uLiteral(cb, sz);
3603
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3356
   uInstr2(cb, PUT,    4, TempReg, t2,       ArchReg,  R_ESP);
3604
                  Lit16, (UShort)modrm );
3357
   uInstr2(cb, PUTSEG, 2, TempReg, t1,       ArchRegS, sreg);
3605
      DIP("%s %s, %s\n",
3358
   if (dis) 
3606
          name, nameXMMReg(eregOfRM(modrm)), nameMMXReg(gregOfRM(modrm)) );
3359
      VG_(printf)("pop %s\n", VG_(name_of_seg_reg)(sreg));
3607
      eip++;
3608
   } else {
3609
      UInt pair = disAMode ( cb, sorb, eip, dis_buf );
3610
      Int  tmpa = LOW24(pair);
3611
      eip += HI8(pair);
3612
      uInstr3(cb, SSE2a_MemRd, sz,
3613
                  Lit16, (((UShort)(opc1)) << 8) | ((UShort)opc2),
3614
                  Lit16, ((UShort)modrm),
3615
                  TempReg, tmpa);
3616
      DIP("%s %s, %s\n", name, dis_buf, nameMMXReg(gregOfRM(modrm)));
3617
   }
3618
   return eip;
3360
}
3619
}
3361
3620
3362
/*------------------------------------------------------------*/
3363
/*--- Disassembling entire basic blocks                    ---*/
3364
/*------------------------------------------------------------*/
3365
3366
/* Disassemble a single instruction into ucode, returning the updated
3367
   eip, and setting *isEnd to True if this is the last insn in a basic
3368
   block.  Also do debug printing if (dis). */
3369
3621
3370
static Addr disInstr ( UCodeBlock* cb, Addr eip, Bool* isEnd )
3622
/* Simple SSE operations, either 
3623
       op   (src)mmxreg, (dst)xmmreg
3624
   or
3625
       op   (src)address, (dst)xmmreg
3626
   2 opcode bytes.
3627
   Supplied eip points to the first address mode byte.
3628
*/
3629
static
3630
Addr dis_SSE2_from_MMX ( UCodeBlock *cb,
3631
                         UChar sorb,
3632
                         Addr eip,
3633
                         Int sz, 
3634
                         Char* name, 
3635
                         UChar opc1, 
3636
                         UChar opc2 )
3637
{
3638
   UChar dis_buf[50];
3639
   UChar modrm = getUChar(eip);
3640
   if (epartIsReg(modrm)) {
3641
      /* Completely internal SSE insn. */
3642
      uInstr2(cb, SSE3, 0,  /* ignore sz for internal ops */
3643
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3644
                  Lit16, (UShort)modrm );
3645
      DIP("%s %s, %s\n",
3646
          name, nameMMXReg(eregOfRM(modrm)), nameXMMReg(gregOfRM(modrm)) );
3647
      eip++;
3648
   } else {
3649
      UInt pair = disAMode ( cb, sorb, eip, dis_buf );
3650
      Int  tmpa = LOW24(pair);
3651
      eip += HI8(pair);
3652
      uInstr3(cb, SSE2a_MemRd, sz,
3653
                  Lit16, (((UShort)(opc1)) << 8) | ((UShort)opc2),
3654
                  Lit16, ((UShort)modrm),
3655
                  TempReg, tmpa);
3656
      DIP("%s %s, %s\n", name, dis_buf, nameXMMReg(gregOfRM(modrm)));
3657
   }
3658
   return eip;
3659
}
3660
3661
3662
/* Simple SSE operations, either 
3663
       op   (src)xmmreg, (dst)mmxreg
3664
   or
3665
       op   (src)address, (dst)mmxreg
3666
   3 opcode bytes.
3667
   Supplied eip points to the first address mode byte.
3668
*/
3669
static
3670
Addr dis_SSE3_to_MMX ( UCodeBlock *cb,
3671
                       UChar sorb,
3672
                       Addr eip,
3673
                       Int sz,
3674
                       Char* name, 
3675
                       UChar opc1, 
3676
                       UChar opc2, 
3677
                       UChar opc3 )
3678
{
3679
   UChar dis_buf[50];
3680
   UChar modrm = getUChar(eip);
3681
   if (epartIsReg(modrm)) {
3682
      /* Completely internal SSE insn. */
3683
      uInstr2(cb, SSE4, 0,  /* ignore sz for internal ops */
3684
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3685
                  Lit16, (((UShort)opc3) << 8) | (UShort)modrm );
3686
      DIP("%s %s, %s\n",
3687
          name, nameXMMReg(eregOfRM(modrm)), nameMMXReg(gregOfRM(modrm)) );
3688
      eip++;
3689
   } else {
3690
      UInt pair = disAMode ( cb, sorb, eip, dis_buf );
3691
      Int  tmpa = LOW24(pair);
3692
      eip += HI8(pair);
3693
      uInstr3(cb, SSE3a_MemRd, sz,
3694
                  Lit16, (((UShort)(opc1)) << 8) | ((UShort)opc2),
3695
                  Lit16, (((UShort)(opc3)) << 8) | ((UShort)modrm),
3696
                  TempReg, tmpa);
3697
      DIP("%s %s, %s\n", name, dis_buf, nameMMXReg(gregOfRM(modrm)));
3698
   }
3699
   return eip;
3700
}
3701
3702
3703
/* Simple SSE operations, either 
3704
       op   (src)mmxreg, (dst)xmmreg
3705
   or
3706
       op   (src)address, (dst)xmmreg
3707
   3 opcode bytes.
3708
   Supplied eip points to the first address mode byte.
3709
*/
3710
static
3711
Addr dis_SSE3_from_MMX ( UCodeBlock *cb,
3712
                         UChar sorb,
3713
                         Addr eip,
3714
                         Int sz,
3715
                         Char* name, 
3716
                         UChar opc1, 
3717
                         UChar opc2, 
3718
                         UChar opc3 )
3719
{
3720
   UChar dis_buf[50];
3721
   UChar modrm = getUChar(eip);
3722
   if (epartIsReg(modrm)) {
3723
      /* Completely internal SSE insn. */
3724
      uInstr2(cb, SSE4, 0,  /* ignore sz for internal ops */
3725
                  Lit16, (((UShort)opc1) << 8) | (UShort)opc2,
3726
                  Lit16, (((UShort)opc3) << 8) | (UShort)modrm );
3727
      DIP("%s %s, %s\n",
3728
          name, nameMMXReg(eregOfRM(modrm)), nameXMMReg(gregOfRM(modrm)) );
3729
      eip++;
3730
   } else {
3731
      UInt pair = disAMode ( cb, sorb, eip, dis_buf );
3732
      Int  tmpa = LOW24(pair);
3733
      eip += HI8(pair);
3734
      uInstr3(cb, SSE3a_MemRd, sz,
3735
                  Lit16, (((UShort)(opc1)) << 8) | ((UShort)opc2),
3736
                  Lit16, (((UShort)(opc3)) << 8) | ((UShort)modrm),
3737
                  TempReg, tmpa);
3738
      DIP("%s %s, %s\n", name, dis_buf, nameXMMReg(gregOfRM(modrm)));
3739
   }
3740
   return eip;
3741
}
3742
3743
3744
static 
3745
void dis_push_segreg ( UCodeBlock* cb, UInt sreg, Int sz )
3746
{
3747
    Int t1 = newTemp(cb), t2 = newTemp(cb);
3748
    vg_assert(sz == 4);
3749
    uInstr2(cb, GETSEG, 2, ArchRegS, sreg,  TempReg, t1);
3750
    uInstr2(cb, GET,    4, ArchReg,  R_ESP, TempReg, t2);
3751
    uInstr2(cb, SUB,    4, Literal,  0,     TempReg, t2);
3752
    uLiteral(cb, 4);
3753
    uInstr2(cb, PUT,    4, TempReg,  t2,    ArchReg, R_ESP);
3754
    uInstr2(cb, STORE,  2, TempReg,  t1,    TempReg, t2);
3755
    DIP("push %s\n", VG_(name_of_seg_reg)(sreg));
3756
}
3757
3758
static
3759
void dis_pop_segreg ( UCodeBlock* cb, UInt sreg, Int sz )
3760
{
3761
   Int t1 = newTemp(cb), t2 = newTemp(cb);
3762
   vg_assert(sz == 4);
3763
   uInstr2(cb, GET,    4, ArchReg, R_ESP,    TempReg,  t2);
3764
   uInstr2(cb, LOAD,   2, TempReg, t2,       TempReg,  t1);
3765
   uInstr2(cb, ADD,    4, Literal, 0,        TempReg,  t2);
3766
   uLiteral(cb, sz);
3767
   uInstr2(cb, PUT,    4, TempReg, t2,       ArchReg,  R_ESP);
3768
   uInstr2(cb, PUTSEG, 2, TempReg, t1,       ArchRegS, sreg);
3769
   DIP("pop %s\n", VG_(name_of_seg_reg)(sreg));
3770
}
3771
3772
/*------------------------------------------------------------*/
3773
/*--- Disassembling entire basic blocks                    ---*/
3774
/*------------------------------------------------------------*/
3775
3776
/* Disassemble a single instruction into ucode, returning the updated
3777
   eip, and setting *isEnd to True if this is the last insn in a basic
3778
   block.  Also do debug printing if necessary. */
3779
3780
static Addr disInstr ( UCodeBlock* cb, Addr eip, Bool* isEnd )
3371
{
3781
{
3372
   UChar opc, modrm, abyte;
3782
   UChar opc, modrm, abyte;
3373
   UInt  d32, pair;
3783
   UInt  d32, pair;
Lines 3393-3399 Link Here
3393
   *isEnd = False;
3803
   *isEnd = False;
3394
   t1 = t2 = t3 = t4 = INVALID_TEMPREG;
3804
   t1 = t2 = t3 = t4 = INVALID_TEMPREG;
3395
3805
3396
   if (dis) VG_(printf)("\t0x%x:  ", eip);
3806
   DIP("\t0x%x:  ", eip);
3397
3807
3398
   /* Spot the client-request magic sequence. */
3808
   /* Spot the client-request magic sequence. */
3399
   {
3809
   {
Lines 3414-3426 Link Here
3414
          myeip[15] == 0xC1 && myeip[16] == 0xC0 && myeip[17] == 0x13
3824
          myeip[15] == 0xC1 && myeip[16] == 0xC0 && myeip[17] == 0x13
3415
         ) {
3825
         ) {
3416
         eip += 18;
3826
         eip += 18;
3417
         uInstr1(cb, JMP,  0, Literal, 0);
3827
         jmp_lit(cb, eip);
3418
         uLiteral(cb, eip);
3419
         uCond(cb, CondAlways);
3420
         LAST_UINSTR(cb).jmpkind = JmpClientReq;
3828
         LAST_UINSTR(cb).jmpkind = JmpClientReq;
3421
         *isEnd = True;
3829
         *isEnd = True;
3422
         if (dis) 
3830
         DIP("%%edx = client_request ( %%eax )\n");
3423
            VG_(printf)("%%edx = client_request ( %%eax )\n");
3424
         return eip;
3831
         return eip;
3425
      }
3832
      }
3426
   }
3833
   }
Lines 3477-3496 Link Here
3477
   if (VG_(have_ssestate)) {
3884
   if (VG_(have_ssestate)) {
3478
   UChar* insn = (UChar*)eip;
3885
   UChar* insn = (UChar*)eip;
3479
3886
3887
   /* FXSAVE/FXRSTOR m32 -- load/store the FPU/MMX/SSE state. */
3888
   if (insn[0] == 0x0F && insn[1] == 0xAE 
3889
       && (!epartIsReg(insn[2]))
3890
       && (gregOfRM(insn[2]) == 1 || gregOfRM(insn[2]) == 0) ) {
3891
      Bool store = gregOfRM(insn[2]) == 0;
3892
      vg_assert(sz == 4);
3893
      pair = disAMode ( cb, sorb, eip+2, dis_buf );
3894
      t1   = LOW24(pair);
3895
      eip += 2+HI8(pair);
3896
      uInstr3(cb, store ? SSE2a_MemWr : SSE2a_MemRd, 512,
3897
                  Lit16, (((UShort)insn[0]) << 8) | (UShort)insn[1],
3898
                  Lit16, (UShort)insn[2],
3899
                  TempReg, t1 );
3900
      DIP("fx%s %s\n", store ? "save" : "rstor", dis_buf );
3901
      goto decode_success;
3902
   }
3903
3480
   /* STMXCSR/LDMXCSR m32 -- load/store the MXCSR register. */
3904
   /* STMXCSR/LDMXCSR m32 -- load/store the MXCSR register. */
3481
   if (insn[0] == 0x0F && insn[1] == 0xAE 
3905
   if (insn[0] == 0x0F && insn[1] == 0xAE 
3906
       && (!epartIsReg(insn[2]))
3482
       && (gregOfRM(insn[2]) == 3 || gregOfRM(insn[2]) == 2) ) {
3907
       && (gregOfRM(insn[2]) == 3 || gregOfRM(insn[2]) == 2) ) {
3483
      Bool store = gregOfRM(insn[2]) == 3;
3908
      Bool store = gregOfRM(insn[2]) == 3;
3484
      vg_assert(sz == 4);
3909
      vg_assert(sz == 4);
3485
      pair = disAMode ( cb, sorb, eip+2, dis?dis_buf:NULL );
3910
      pair = disAMode ( cb, sorb, eip+2, dis_buf );
3486
      t1   = LOW24(pair);
3911
      t1   = LOW24(pair);
3487
      eip += 2+HI8(pair);
3912
      eip += 2+HI8(pair);
3488
      uInstr3(cb, store ? SSE2a_MemWr : SSE2a_MemRd, 4,
3913
      uInstr3(cb, store ? SSE2a_MemWr : SSE2a_MemRd, 4,
3489
                  Lit16, (((UShort)insn[0]) << 8) | (UShort)insn[1],
3914
                  Lit16, (((UShort)insn[0]) << 8) | (UShort)insn[1],
3490
                  Lit16, (UShort)insn[2],
3915
                  Lit16, (UShort)insn[2],
3491
                  TempReg, t1 );
3916
                  TempReg, t1 );
3492
      if (dis)
3917
      DIP("%smxcsr %s\n", store ? "st" : "ld", dis_buf );
3493
         VG_(printf)("%smxcsr %s\n", store ? "st" : "ld", dis_buf );
3494
      goto decode_success;
3918
      goto decode_success;
3495
   }
3919
   }
3496
3920
Lines 3504-3511 Link Here
3504
      uInstr2(cb, SSE3, 0,  /* ignore sz for internal ops */
3928
      uInstr2(cb, SSE3, 0,  /* ignore sz for internal ops */
3505
                  Lit16, (((UShort)0x0F) << 8) | (UShort)0xAE,
3929
                  Lit16, (((UShort)0x0F) << 8) | (UShort)0xAE,
3506
                  Lit16, (UShort)insn[2] );
3930
                  Lit16, (UShort)insn[2] );
3507
      if (dis)
3931
      DIP("sfence\n");
3508
         VG_(printf)("sfence\n");
3932
      goto decode_success;
3933
   }
3934
3935
   /* CLFLUSH -- flush cache line */
3936
   if (insn[0] == 0x0F && insn[1] == 0xAE
3937
       && (!epartIsReg(insn[2]))
3938
       && (gregOfRM(insn[2]) == 7))
3939
   {
3940
      vg_assert(sz == 4);
3941
      pair = disAMode ( cb, sorb, eip+2, dis_buf );
3942
      t1   = LOW24(pair);
3943
      eip += 2+HI8(pair);
3944
      uInstr3(cb, SSE2a_MemRd, 0,  /* ignore sz for internal ops */
3945
                  Lit16, (((UShort)0x0F) << 8) | (UShort)0xAE,
3946
                  Lit16, (UShort)insn[2],
3947
                  TempReg, t1 );
3948
      DIP("clflush %s\n", dis_buf);
3949
      goto decode_success;
3950
   }
3951
3952
   /* CVTPI2PS (0x0F,0x2A) -- mm/m64, xmm */
3953
   /* CVTPI2PD (0x66,0x0F,0x2A) -- mm/m64, xmm */
3954
   if (insn[0] == 0x0F && insn[1] == 0x2A) {
3955
      if (sz == 4) {
3956
         eip = dis_SSE2_from_MMX
3957
                  ( cb, sorb, eip+2, 8, "cvtpi2ps",
3958
                        insn[0], insn[1] );
3959
      } else {
3960
         eip = dis_SSE3_from_MMX
3961
                  ( cb, sorb, eip+2, 8, "cvtpi2pd",
3962
                        0x66, insn[0], insn[1] );
3963
      }
3964
      goto decode_success;
3965
   }
3966
3967
   /* CVTTPS2PI (0x0F,0x2C) -- xmm/m64, mm */
3968
   /* CVTPS2PI (0x0F,0x2D) -- xmm/m64, mm */
3969
   /* CVTTPD2PI (0x66,0x0F,0x2C) -- xmm/m128, mm */
3970
   /* CVTPD2PI (0x66,0x0F,0x2D) -- xmm/m128, mm */
3971
   if (insn[0] == 0x0F
3972
       && (insn[1] == 0x2C || insn[1] == 0x2D)) {
3973
      if (sz == 4) {
3974
         eip = dis_SSE2_to_MMX
3975
                  ( cb, sorb, eip+2, 8, "cvt{t}ps2pi",
3976
                        insn[0], insn[1] );
3977
      } else {
3978
         eip = dis_SSE3_to_MMX
3979
                  ( cb, sorb, eip+2, 16, "cvt{t}pd2pi",
3980
                        0x66, insn[0], insn[1] );
3981
      }
3509
      goto decode_success;
3982
      goto decode_success;
3510
   }
3983
   }
3511
3984
Lines 3537-3546 Link Here
3537
                     Lit16, (((UShort)insn[2]) << 8) | (UShort)modrm,
4010
                     Lit16, (((UShort)insn[2]) << 8) | (UShort)modrm,
3538
                     TempReg, t1 );
4011
                     TempReg, t1 );
3539
         uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
4012
         uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
3540
	 if (dis)
4013
         DIP("cvt{t}s{s,d}2si %s, %s\n", 
3541
            VG_(printf)("cvt{t}s{s,d}2si %s, %s\n", 
4014
             nameXMMReg(eregOfRM(modrm)), nameIReg(4,gregOfRM(modrm)) );
3542
                        nameXMMReg(eregOfRM(modrm)),
3543
                        nameIReg(4,gregOfRM(modrm)) );
3544
      } else {
4015
      } else {
3545
         /* So, we're reading memory and writing an ireg.  This calls
4016
         /* So, we're reading memory and writing an ireg.  This calls
3546
            for the ultra-horrible SSE3ag_MemRd_RegWr uinstr.  We
4017
            for the ultra-horrible SSE3ag_MemRd_RegWr uinstr.  We
Lines 3551-3557 Link Here
3551
 	 /* Destination ireg is GREG.  Address goes as EREG as
4022
 	 /* Destination ireg is GREG.  Address goes as EREG as
3552
	    usual. */
4023
	    usual. */
3553
         t1 = newTemp(cb); /* t1 holds value on its way to ireg */
4024
         t1 = newTemp(cb); /* t1 holds value on its way to ireg */
3554
         pair = disAMode ( cb, sorb, eip+3, dis?dis_buf:NULL );
4025
         pair = disAMode ( cb, sorb, eip+3, dis_buf );
3555
         t2   = LOW24(pair); /* t2 holds addr */
4026
         t2   = LOW24(pair); /* t2 holds addr */
3556
         eip += 3+HI8(pair);
4027
         eip += 3+HI8(pair);
3557
         uInstr2(cb, SSE3ag_MemRd_RegWr, insn[0]==0xF2 ? 8 : 4,
4028
         uInstr2(cb, SSE3ag_MemRd_RegWr, insn[0]==0xF2 ? 8 : 4,
Lines 3562-3571 Link Here
3562
                      | (((UInt)insn[2]) << 8) 
4033
                      | (((UInt)insn[2]) << 8) 
3563
                      | ((UInt)modrm) );
4034
                      | ((UInt)modrm) );
3564
         uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
4035
         uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
3565
	 if (dis)
4036
         DIP("cvt{t}s{s,d}2si %s, %s\n", 
3566
            VG_(printf)("cvt{t}s{s,d}2si %s, %s\n", 
4037
             dis_buf, nameIReg(4,gregOfRM(modrm)) );
3567
                        dis_buf,
3568
                        nameIReg(4,gregOfRM(modrm)) );
3569
      }
4038
      }
3570
      goto decode_success;
4039
      goto decode_success;
3571
   }
4040
   }
Lines 3588-3609 Link Here
3588
                     Lit16, (((UShort)insn[2]) << 8) | (UShort)modrm,
4057
                     Lit16, (((UShort)insn[2]) << 8) | (UShort)modrm,
3589
                     TempReg, t1 );
4058
                     TempReg, t1 );
3590
         eip += 4;
4059
         eip += 4;
3591
	 if (dis)
4060
         DIP("cvtsi2s%s %s, %s\n", s_or_d,
3592
            VG_(printf)("cvtsi2s%s %s, %s\n", s_or_d,
4061
             nameIReg(4,eregOfRM(modrm)), nameXMMReg(gregOfRM(modrm)));
3593
                        nameIReg(4,eregOfRM(modrm)), 
3594
                        nameXMMReg(gregOfRM(modrm)));
3595
      } else {
4062
      } else {
3596
         pair = disAMode ( cb, sorb, eip+3, dis?dis_buf:NULL );
4063
         pair = disAMode ( cb, sorb, eip+3, dis_buf );
3597
         t2   = LOW24(pair);
4064
         t2   = LOW24(pair);
3598
         eip += 3+HI8(pair);
4065
         eip += 3+HI8(pair);
3599
	 uInstr3(cb, SSE3a_MemRd, 4,
4066
	 uInstr3(cb, SSE3a_MemRd, 4,
3600
                     Lit16, (((UShort)insn[0]) << 8) | (UShort)insn[1],
4067
                     Lit16, (((UShort)insn[0]) << 8) | (UShort)insn[1],
3601
                     Lit16, (((UShort)insn[2]) << 8) | (UShort)modrm,
4068
                     Lit16, (((UShort)insn[2]) << 8) | (UShort)modrm,
3602
                     TempReg, t2 );
4069
                     TempReg, t2 );
3603
	 if (dis)
4070
         DIP("cvtsi2s%s %s, %s\n",
3604
            VG_(printf)("cvtsi2s%s %s, %s\n", s_or_d,
4071
             s_or_d, dis_buf, nameXMMReg(gregOfRM(modrm)));
3605
                        dis_buf,
4072
      }
3606
                        nameXMMReg(gregOfRM(modrm)));
4073
      goto decode_success;
4074
   }
4075
4076
   /* CVTPS2PD -- convert two packed floats to two packed doubles. */
4077
   /* 0x66: CVTPD2PS -- convert two packed doubles to two packed floats. */
4078
   if (insn[0] == 0x0F && insn[1] == 0x5A) {
4079
      vg_assert(sz == 2 || sz == 4);
4080
      if (sz == 4) {
4081
         eip = dis_SSE2_reg_or_mem ( cb, sorb, eip+2, 8, "cvtps2pd",
4082
                                         insn[0], insn[1] );
4083
      } else {
4084
         eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, "cvtpd2ps",
4085
                                     0x66, insn[0], insn[1] );
3607
      }
4086
      }
3608
      goto decode_success;
4087
      goto decode_success;
3609
   }
4088
   }
Lines 3624-3629 Link Here
3624
      goto decode_success;
4103
      goto decode_success;
3625
   }
4104
   }
3626
4105
4106
   /* CVTDQ2PS -- convert four ints to four packed floats. */
4107
   /* 0x66: CVTPS2DQ -- convert four packed floats to four ints. */
4108
   if (insn[0] == 0x0F && insn[1] == 0x5B) {
4109
      vg_assert(sz == 2 || sz == 4);
4110
      if (sz == 4) {
4111
         eip = dis_SSE2_reg_or_mem ( cb, sorb, eip+2, 16, "cvtdq2ps",
4112
                                         insn[0], insn[1] );
4113
      } else {
4114
         eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, "cvtps2dq",
4115
                                         0x66, insn[0], insn[1] );
4116
      }
4117
      goto decode_success;
4118
   }
4119
4120
   /* CVTPD2DQ -- convert two packed doubles to two ints. */
4121
   if (sz == 2
4122
       && insn[0] == 0x0F && insn[1] == 0xE6) {
4123
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 8, "cvtpd2dq",
4124
                                      0x66, insn[0], insn[1] );
4125
      goto decode_success;
4126
   }
4127
4128
   /* CVTTPD2DQ -- convert two packed doubles to two ints with truncation. */
4129
   if (insn[0] == 0xF2 && insn[1] == 0x0F && insn[2] == 0xE6) {
4130
      vg_assert(sz == 4);
4131
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+3, 8, "cvttpd2dq",
4132
                                      insn[0], insn[1], insn[2] );
4133
      goto decode_success;
4134
   }
4135
4136
   /* CVTDQ2PD -- convert two ints to two packed doubles. */
4137
   if (insn[0] == 0xF3 && insn[1] == 0x0F && insn[2] == 0xE6) {
4138
      vg_assert(sz == 4);
4139
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+3, 8, "cvtdq2pd",
4140
                                      insn[0], insn[1], insn[2] );
4141
      goto decode_success;
4142
   }
4143
4144
   /* CVTTPS2DQ -- convert four packed floats to four ints with truncation. */
4145
   if (insn[0] == 0xF3 && insn[1] == 0x0F && insn[2] == 0x5B) {
4146
      vg_assert(sz == 4);
4147
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+3, 16, "cvttps2dq",
4148
                                      insn[0], insn[1], insn[2] );
4149
      goto decode_success;
4150
   }
4151
4152
   /* CMPSS -- compare scalar floats. */
4153
   if (insn[0] == 0xF3 && insn[1] == 0x0F && insn[2] == 0xC2) {
4154
      vg_assert(sz == 4);
4155
      eip = dis_SSE3_reg_or_mem_Imm8 ( cb, sorb, eip+3, 8, "cmpss",
4156
                                       insn[0], insn[1], insn[2] );
4157
      goto decode_success;
4158
   }
4159
3627
   /* CMPSD -- compare scalar doubles. */
4160
   /* CMPSD -- compare scalar doubles. */
3628
   if (insn[0] == 0xF2 && insn[1] == 0x0F && insn[2] == 0xC2) {
4161
   if (insn[0] == 0xF2 && insn[1] == 0x0F && insn[2] == 0xC2) {
3629
      vg_assert(sz == 4);
4162
      vg_assert(sz == 4);
Lines 3655-3664 Link Here
3655
      goto decode_success;
4188
      goto decode_success;
3656
   }
4189
   }
3657
4190
4191
   /* PSHUFLW */
4192
   if (insn[0] == 0xF2 && insn[1] == 0x0F && insn[2] == 0x70) {
4193
      eip = dis_SSE3_reg_or_mem_Imm8 ( cb, sorb, eip+3, 16, 
4194
                                           "pshuflw",
4195
                                           insn[0], insn[1], insn[2] );
4196
      goto decode_success;
4197
   }
4198
4199
   /* PSHUFHW */
4200
   if (insn[0] == 0xF3 && insn[1] == 0x0F && insn[2] == 0x70) {
4201
      eip = dis_SSE3_reg_or_mem_Imm8 ( cb, sorb, eip+3, 16, 
4202
                                           "pshufhw",
4203
                                           insn[0], insn[1], insn[2] );
4204
      goto decode_success;
4205
   }
4206
3658
   /* PSHUFW */
4207
   /* PSHUFW */
3659
   if (sz == 4
4208
   if (sz == 4
3660
       && insn[0] == 0x0F && insn[1] == 0x70) {
4209
       && insn[0] == 0x0F && insn[1] == 0x70) {
3661
      eip = dis_SSE2_reg_or_mem_Imm8 ( cb, sorb, eip+2, 16, 
4210
      eip = dis_SSE2_reg_or_mem_Imm8 ( cb, sorb, eip+2, 8, 
3662
                                           "pshufw",
4211
                                           "pshufw",
3663
                                           insn[0], insn[1] );
4212
                                           insn[0], insn[1] );
3664
      goto decode_success;
4213
      goto decode_success;
Lines 3795-3800 Link Here
3795
      goto decode_success;
4344
      goto decode_success;
3796
   }
4345
   }
3797
4346
4347
   /* MINPS */
4348
   /* 0x66: MINPD */
4349
   if (insn[0] == 0x0F && insn[1] == 0x5D) {
4350
      vg_assert(sz == 4 || sz == 2);
4351
      if (sz == 4) {
4352
         eip = dis_SSE2_reg_or_mem ( cb, sorb, eip+2, 16, "minps",
4353
                                         insn[0], insn[1] );
4354
      } else {
4355
         eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, "minpd",
4356
                                         0x66, insn[0], insn[1] );
4357
      }
4358
      goto decode_success;
4359
   }
4360
3798
   /* 0xF3: MAXSD */
4361
   /* 0xF3: MAXSD */
3799
   /* 0xF3: MAXSS */
4362
   /* 0xF3: MAXSS */
3800
   if ((insn[0] == 0xF2 || insn[0] == 0xF3) 
4363
   if ((insn[0] == 0xF2 || insn[0] == 0xF3) 
Lines 3857-3867 Link Here
3857
      goto decode_success;
4420
      goto decode_success;
3858
   }
4421
   }
3859
4422
3860
   /* ORPD (src)xmmreg-or-mem, (dst)xmmreg */
4423
   /* ORPS */
3861
   if (sz == 2
4424
   /* 0x66: ORPD (src)xmmreg-or-mem, (dst)xmmreg */
3862
       && insn[0] == 0x0F && insn[1] == 0x56) {
4425
   if (insn[0] == 0x0F && insn[1] == 0x56) {
4426
      vg_assert(sz == 4 || sz == 2);
4427
      if (sz == 4) {
4428
         eip = dis_SSE2_reg_or_mem ( cb, sorb, eip+2, 16, "orps",
4429
                                         insn[0], insn[1] );
4430
      } else {
3863
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, "orpd",
4431
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, "orpd",
3864
                                      0x66, insn[0], insn[1] );
4432
                                      0x66, insn[0], insn[1] );
4433
      }
3865
      goto decode_success;
4434
      goto decode_success;
3866
   }
4435
   }
3867
4436
Lines 3926-3948 Link Here
3926
                                      0x66, insn[0], insn[1] );
4495
                                      0x66, insn[0], insn[1] );
3927
      goto decode_success;
4496
      goto decode_success;
3928
   }
4497
   }
3929
   /* 0xE0: PAVGB(src)xmmreg-or-mem, (dst)xmmreg, size 4 */
4498
 
3930
   if (sz == 4
4499
   /* 0xF6: PSADBW(src)xmmreg-or-mem, (dst)xmmreg */
3931
       && insn[0] == 0x0F 
4500
   if (sz == 2
3932
       && insn[1] == 0xE0 ) {
4501
       && insn[0] == 0x0F && insn[1] == 0xF6) {
3933
      eip = dis_SSE2_reg_or_mem ( cb, sorb, eip+2, 16, "pavg{b,w}",
4502
     eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, "psadbw",
3934
                                      insn[0], insn[1] );
4503
                                      0x66, insn[0], insn[1] );
3935
      goto decode_success;
4504
      goto decode_success;
3936
   }
4505
   }
3937
 
4506
 
3938
   /* 0x60: PUNPCKLBW (src)xmmreg-or-mem, (dst)xmmreg */
4507
   /* 0x60: PUNPCKLBW (src)xmmreg-or-mem, (dst)xmmreg */
3939
   /* 0x61: PUNPCKLWD (src)xmmreg-or-mem, (dst)xmmreg */
4508
   /* 0x61: PUNPCKLWD (src)xmmreg-or-mem, (dst)xmmreg */
3940
   /* 0x62: PUNPCKLDQ (src)xmmreg-or-mem, (dst)xmmreg */
4509
   /* 0x62: PUNPCKLDQ (src)xmmreg-or-mem, (dst)xmmreg */
4510
   /* 0x6C: PUNPCKQLQDQ (src)xmmreg-or-mem, (dst)xmmreg */
3941
   if (sz == 2
4511
   if (sz == 2
3942
       && insn[0] == 0x0F 
4512
       && insn[0] == 0x0F 
3943
       && (insn[1] == 0x60 || insn[1] == 0x61 || insn[1] == 0x62)) {
4513
       && (insn[1] == 0x60 || insn[1] == 0x61
4514
           || insn[1] == 0x62 || insn[1] == 0x6C)) {
3944
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, 
4515
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, 
3945
                                      "punpckl{bw,wd,dq}",
4516
                                      "punpckl{bw,wd,dq,qdq}",
3946
                                      0x66, insn[0], insn[1] );
4517
                                      0x66, insn[0], insn[1] );
3947
      goto decode_success;
4518
      goto decode_success;
3948
   }
4519
   }
Lines 3950-3960 Link Here
3950
   /* 0x68: PUNPCKHBW (src)xmmreg-or-mem, (dst)xmmreg */
4521
   /* 0x68: PUNPCKHBW (src)xmmreg-or-mem, (dst)xmmreg */
3951
   /* 0x69: PUNPCKHWD (src)xmmreg-or-mem, (dst)xmmreg */
4522
   /* 0x69: PUNPCKHWD (src)xmmreg-or-mem, (dst)xmmreg */
3952
   /* 0x6A: PUNPCKHDQ (src)xmmreg-or-mem, (dst)xmmreg */
4523
   /* 0x6A: PUNPCKHDQ (src)xmmreg-or-mem, (dst)xmmreg */
4524
   /* 0x6D: PUNPCKHQDQ (src)xmmreg-or-mem, (dst)xmmreg */
3953
   if (sz == 2
4525
   if (sz == 2
3954
       && insn[0] == 0x0F 
4526
       && insn[0] == 0x0F 
3955
       && (insn[1] == 0x68 || insn[1] == 0x69 || insn[1] == 0x6A)) {
4527
       && (insn[1] == 0x68 || insn[1] == 0x69
4528
           || insn[1] == 0x6A || insn[1] == 0x6D)) {
3956
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, 
4529
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, 
3957
                                      "punpckh{bw,wd,dq}",
4530
                                      "punpckh{bw,wd,dq,qdq}",
3958
                                      0x66, insn[0], insn[1] );
4531
                                      0x66, insn[0], insn[1] );
3959
      goto decode_success;
4532
      goto decode_success;
3960
   }
4533
   }
Lines 4055-4066 Link Here
4055
      goto decode_success;
4628
      goto decode_success;
4056
   }
4629
   }
4057
4630
4631
   /* 0xE4: PMULHUW(src)xmmreg-or-mem, (dst)xmmreg */
4058
   /* 0xE5: PMULHW(src)xmmreg-or-mem, (dst)xmmreg */
4632
   /* 0xE5: PMULHW(src)xmmreg-or-mem, (dst)xmmreg */
4059
   /* 0xD5: PMULLW(src)xmmreg-or-mem, (dst)xmmreg */
4633
   /* 0xD5: PMULLW(src)xmmreg-or-mem, (dst)xmmreg */
4060
   if (sz == 2
4634
   if (sz == 2
4061
       && insn[0] == 0x0F 
4635
       && insn[0] == 0x0F 
4062
       && (insn[1] == 0xE5 || insn[1] == 0xD5)) {
4636
       && (insn[1] == 0xE4 || insn[1] == 0xE5 || insn[1] == 0xD5)) {
4063
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, "pmul{h,l}w",
4637
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, "pmul{hu,h,l}w",
4638
                                      0x66, insn[0], insn[1] );
4639
      goto decode_success;
4640
   }
4641
4642
   /* 0xD5: PMULUDQ(src)xmmreg-or-mem, (dst)xmmreg */
4643
   if (sz == 2
4644
       && insn[0] == 0x0F && insn[1] == 0xF4) {
4645
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, "pmuludq",
4064
                                      0x66, insn[0], insn[1] );
4646
                                      0x66, insn[0], insn[1] );
4065
      goto decode_success;
4647
      goto decode_success;
4066
   }
4648
   }
Lines 4204-4209 Link Here
4204
      goto decode_success;
4786
      goto decode_success;
4205
   }
4787
   }
4206
4788
4789
   /* MOVDQ2Q -- move low 4 bytes of XMM reg to MMX reg. */
4790
   if (insn[0] == 0xF2
4791
       && insn[1] == 0x0F
4792
       && insn[2] == 0xD6) {
4793
      eip = dis_SSE3_to_MMX
4794
               ( cb, sorb, eip+3, 8, "movdq2q",
4795
                     insn[0], insn[1], insn[2] );
4796
      goto decode_success;
4797
   }
4798
4799
   /* MOVQ2DQ -- move MMX reg to low 4 bytes of XMM reg. */
4800
   if (insn[0] == 0xF3
4801
       && insn[1] == 0x0F
4802
       && insn[2] == 0xD6) {
4803
      eip = dis_SSE3_from_MMX
4804
               ( cb, sorb, eip+3, 8, "movq2dq",
4805
                     insn[0], insn[1], insn[2] );
4806
      goto decode_success;
4807
   }
4808
4207
   /* MOVSS -- move 4 bytes of XMM reg to/from XMM reg or mem. */
4809
   /* MOVSS -- move 4 bytes of XMM reg to/from XMM reg or mem. */
4208
   if (insn[0] == 0xF3
4810
   if (insn[0] == 0xF3
4209
       && insn[1] == 0x0F 
4811
       && insn[1] == 0x0F 
Lines 4269-4287 Link Here
4269
      goto decode_success;
4871
      goto decode_success;
4270
   }
4872
   }
4271
4873
4272
   /* MOVLPD -- 8-byte load/store. */
4273
   if (sz == 2 
4274
       && insn[0] == 0x0F 
4275
       && (insn[1] == 0x12 || insn[1] == 0x13)) {
4276
      Bool is_store = insn[1]==0x13;
4277
      /* Cannot be used for reg-reg moves, according to Intel docs. */
4278
      vg_assert(!epartIsReg(insn[2]));
4279
      eip = dis_SSE3_load_store_or_mov
4280
               (cb, sorb, eip+2, 8, is_store, "movlpd", 
4281
                    0x66, insn[0], insn[1] );
4282
      goto decode_success;
4283
   }
4284
4285
   /* MOVDQU -- unaligned 16-byte load/store. */
4874
   /* MOVDQU -- unaligned 16-byte load/store. */
4286
   if (insn[0] == 0xF3
4875
   if (insn[0] == 0xF3
4287
       && insn[1] == 0x0F 
4876
       && insn[1] == 0x0F 
Lines 4304-4309 Link Here
4304
      goto decode_success;
4893
      goto decode_success;
4305
   }
4894
   }
4306
4895
4896
   /* MOVNTPS -- 16-byte store with temporal hint (which we
4897
      ignore). */
4898
   if (insn[0] == 0x0F
4899
       && insn[1] == 0x2B) {
4900
      eip = dis_SSE2_load_store_or_mov 
4901
               (cb, sorb, eip+2, 16, True /* is_store */, "movntps",
4902
                    insn[0], insn[1] );
4903
      goto decode_success;
4904
   }
4905
4906
   /* MOVNTPD -- 16-byte store with temporal hint (which we
4907
      ignore). */
4908
   if (sz == 2
4909
       && insn[0] == 0x0F
4910
       && insn[1] == 0x2B) {
4911
      eip = dis_SSE3_load_store_or_mov 
4912
               (cb, sorb, eip+2, 16, True /* is_store */, "movntpd",
4913
                    0x66, insn[0], insn[1] );
4914
      goto decode_success;
4915
   }
4916
4307
   /* MOVD -- 4-byte move between xmmregs and (ireg or memory). */
4917
   /* MOVD -- 4-byte move between xmmregs and (ireg or memory). */
4308
   if (sz == 2 
4918
   if (sz == 2 
4309
       && insn[0] == 0x0F 
4919
       && insn[0] == 0x0F 
Lines 4317-4326 Link Here
4317
                     Lit16, (((UShort)insn[1]) << 8) | (UShort)modrm,
4927
                     Lit16, (((UShort)insn[1]) << 8) | (UShort)modrm,
4318
                     TempReg, t1 );
4928
                     TempReg, t1 );
4319
	 uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, eregOfRM(modrm));
4929
	 uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, eregOfRM(modrm));
4320
	 if (dis)
4930
	 DIP("movd %s, %s\n", 
4321
	    VG_(printf)("movd %s, %s\n", 
4931
             nameXMMReg(gregOfRM(modrm)), nameIReg(4,eregOfRM(modrm)));
4322
		        nameXMMReg(gregOfRM(modrm)),
4323
		        nameIReg(4,eregOfRM(modrm)));
4324
         eip += 3;
4932
         eip += 3;
4325
      } else
4933
      } else
4326
      if (epartIsReg(modrm) && !is_store) {
4934
      if (epartIsReg(modrm) && !is_store) {
Lines 4330-4339 Link Here
4330
                     Lit16, (((UShort)0x66) << 8) | (UShort)insn[0],
4938
                     Lit16, (((UShort)0x66) << 8) | (UShort)insn[0],
4331
                     Lit16, (((UShort)insn[1]) << 8) | (UShort)modrm,
4939
                     Lit16, (((UShort)insn[1]) << 8) | (UShort)modrm,
4332
                     TempReg, t1 );
4940
                     TempReg, t1 );
4333
	 if (dis)
4941
	 DIP("movd %s, %s\n", 
4334
	    VG_(printf)("movd %s, %s\n", 
4942
             nameIReg(4,eregOfRM(modrm)), nameXMMReg(gregOfRM(modrm)));
4335
		        nameIReg(4,eregOfRM(modrm)),
4336
		        nameXMMReg(gregOfRM(modrm)));
4337
         eip += 3;
4943
         eip += 3;
4338
      } else {
4944
      } else {
4339
         eip = dis_SSE3_load_store_or_mov
4945
         eip = dis_SSE3_load_store_or_mov
Lines 4355-4364 Link Here
4355
                  TempReg, t1 );
4961
                  TempReg, t1 );
4356
      uLiteral(cb, insn[3]);
4962
      uLiteral(cb, insn[3]);
4357
      uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
4963
      uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
4358
      if (dis)
4964
      DIP("pextrw %s, %d, %s\n",
4359
         VG_(printf)("pextrw %s, %d, %s\n",
4965
          nameXMMReg(eregOfRM(modrm)), (Int)insn[3], 
4360
                     nameXMMReg(eregOfRM(modrm)), (Int)insn[3], 
4966
          nameIReg(4, gregOfRM(modrm)));
4361
                                nameIReg(4, gregOfRM(modrm)));
4362
      eip += 4;
4967
      eip += 4;
4363
      goto decode_success;
4968
      goto decode_success;
4364
   }
4969
   }
Lines 4375-4385 Link Here
4375
                     Lit16, (((UShort)insn[1]) << 8) | (UShort)modrm,
4980
                     Lit16, (((UShort)insn[1]) << 8) | (UShort)modrm,
4376
                     TempReg, t1 );
4981
                     TempReg, t1 );
4377
         uLiteral(cb, insn[3]);
4982
         uLiteral(cb, insn[3]);
4378
         if (dis)
4983
         DIP("pinsrw %s, %d, %s\n",
4379
            VG_(printf)("pinsrw %s, %d, %s\n",
4984
             nameIReg(2, eregOfRM(modrm)), (Int)insn[3],
4380
                        nameIReg(2, eregOfRM(modrm)),
4985
             nameXMMReg(gregOfRM(modrm)));
4381
                        (Int)insn[3], 
4382
                        nameXMMReg(gregOfRM(modrm)));
4383
         eip += 4;
4986
         eip += 4;
4384
      } else {
4987
      } else {
4385
	 VG_(core_panic)("PINSRW mem");
4988
	 VG_(core_panic)("PINSRW mem");
Lines 4405-4421 Link Here
4405
      goto decode_success;
5008
      goto decode_success;
4406
   }
5009
   }
4407
5010
4408
   /* MOVLPS -- 8-byte load/store.  How is this different from MOVLPS
5011
   /* RSQRTSS: square root reciprocal of scalar float. */
4409
      ? */
5012
   if (insn[0] == 0xF3 && insn[1] == 0x0F && insn[2] == 0x52) {
4410
   if (insn[0] == 0x0F 
4411
       && (insn[1] == 0x12 || insn[1] == 0x13)) {
4412
      Bool is_store = insn[1]==0x13;
4413
      vg_assert(sz == 4);
5013
      vg_assert(sz == 4);
4414
      /* Cannot be used for reg-reg moves, according to Intel docs. */
5014
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+3, 4,
4415
      //      vg_assert(!epartIsReg(insn[2]));
5015
                                      "sqrtss",
4416
      eip = dis_SSE2_load_store_or_mov
5016
                                      insn[0], insn[1], insn[2] );
4417
               (cb, sorb, eip+2, 8, is_store, "movlps", 
4418
                    insn[0], insn[1] );
4419
      goto decode_success;
5017
      goto decode_success;
4420
   }
5018
   }
4421
5019
Lines 4430-4450 Link Here
4430
5028
4431
   /* MOVMSKPD -- extract 2 sign bits from a xmm reg and copy them to 
5029
   /* MOVMSKPD -- extract 2 sign bits from a xmm reg and copy them to 
4432
      an ireg.  Top 30 bits of ireg are set to zero. */
5030
      an ireg.  Top 30 bits of ireg are set to zero. */
4433
   if (sz == 2 && insn[0] == 0x0F && insn[1] == 0x50) {
5031
   /* MOVMSKPS -- extract 4 sign bits from a xmm reg and copy them to 
5032
      an ireg.  Top 28 bits of ireg are set to zero. */
5033
   if (insn[0] == 0x0F && insn[1] == 0x50) {
5034
      vg_assert(sz == 4 || sz == 2);
4434
      modrm = insn[2];
5035
      modrm = insn[2];
4435
      /* Intel docs don't say anything about a memory source being
5036
      /* Intel docs don't say anything about a memory source being
4436
	 allowed here. */
5037
	 allowed here. */
4437
      vg_assert(epartIsReg(modrm));
5038
      vg_assert(epartIsReg(modrm));
4438
      t1 = newTemp(cb);
5039
      t1 = newTemp(cb);
4439
      uInstr3(cb, SSE3g_RegWr, 4,
5040
      if (sz == 4) {
4440
                  Lit16, (((UShort)0x66) << 8) | (UShort)insn[0],
5041
         uInstr3(cb, SSE2g_RegWr, 4,
4441
                  Lit16, (((UShort)insn[1]) << 8) | (UShort)modrm,
5042
                     Lit16, (((UShort)insn[0]) << 8) | (UShort)insn[1],
4442
                  TempReg, t1 );
5043
                     Lit16, (UShort)modrm,
4443
      uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
5044
                     TempReg, t1 );
4444
      if (dis)
5045
         uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
4445
         VG_(printf)("movmskpd %s, %s\n", 
5046
      } else {
4446
                      nameXMMReg(eregOfRM(modrm)),
5047
         uInstr3(cb, SSE3g_RegWr, 4,
4447
                      nameIReg(4,gregOfRM(modrm)));
5048
                     Lit16, (((UShort)0x66) << 8) | (UShort)insn[0],
5049
                     Lit16, (((UShort)insn[1]) << 8) | (UShort)modrm,
5050
                     TempReg, t1 );
5051
         uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
5052
      }
5053
      DIP("movmskp%c %s, %s\n", sz == 4 ? 's' : 'd',
5054
          nameXMMReg(eregOfRM(modrm)), nameIReg(4,gregOfRM(modrm)));
4448
      eip += 3;
5055
      eip += 3;
4449
      goto decode_success;
5056
      goto decode_success;
4450
   }
5057
   }
Lines 4463-4478 Link Here
4463
      goto decode_success;
5070
      goto decode_success;
4464
   }
5071
   }
4465
5072
4466
   /* MOVHPD -- 8-byte load/store. */
5073
   /* MOVHLPS -- move two packed floats from high quadword to low quadword */
4467
   if (sz == 2 
5074
   /* MOVLPS -- load/store two packed floats to/from low quadword. */
4468
       && insn[0] == 0x0F 
5075
   /* MOVLPD -- load/store packed double to/from low quadword. */
5076
   if (insn[0] == 0x0F 
5077
       && (insn[1] == 0x12 || insn[1] == 0x13)) {
5078
      Bool is_store = insn[1]==0x13;
5079
      vg_assert(sz == 4 || sz == 2);
5080
      if (sz == 4) {
5081
         if (epartIsReg(insn[2])) {
5082
            vg_assert(insn[1]==0x12);
5083
            eip = dis_SSE2_reg_or_mem ( cb, sorb, eip+2, 16, "movhlps",
5084
                                            insn[0], insn[1] );
5085
         } else {
5086
            eip = dis_SSE2_load_store_or_mov
5087
                     (cb, sorb, eip+2, 8, is_store, "movlps", 
5088
                          insn[0], insn[1] );
5089
         }
5090
      } else {
5091
         vg_assert(!epartIsReg(insn[2]));
5092
         eip = dis_SSE3_load_store_or_mov
5093
                  (cb, sorb, eip+2, 8, is_store, "movlpd", 
5094
                       0x66, insn[0], insn[1] );
5095
      }
5096
      goto decode_success;
5097
   }
5098
5099
   /* MOVLHPS -- move two packed floats from low quadword to high quadword */
5100
   /* MOVHPS -- load/store two packed floats to/from high quadword. */
5101
   /* MOVHPD -- load/store packed double to/from high quadword. */
5102
   if (insn[0] == 0x0F 
4469
       && (insn[1] == 0x16 || insn[1] == 0x17)) {
5103
       && (insn[1] == 0x16 || insn[1] == 0x17)) {
4470
      Bool is_store = insn[1]==0x17;
5104
      Bool is_store = insn[1]==0x17;
4471
      /* Cannot be used for reg-reg moves, according to Intel docs. */
5105
      vg_assert(sz == 4 || sz == 2);
5106
      if (sz == 4) {
5107
         if (epartIsReg(insn[2])) {
5108
            vg_assert(insn[1]==0x16);
5109
            eip = dis_SSE2_reg_or_mem ( cb, sorb, eip+2, 16, "movlhps",
5110
                                            insn[0], insn[1] );
5111
         } else {
5112
            eip = dis_SSE2_load_store_or_mov
5113
                     (cb, sorb, eip+2, 8, is_store, "movhps", 
5114
                          insn[0], insn[1] );
5115
         }
5116
      } else {
4472
      vg_assert(!epartIsReg(insn[2]));
5117
      vg_assert(!epartIsReg(insn[2]));
4473
      eip = dis_SSE3_load_store_or_mov
5118
      eip = dis_SSE3_load_store_or_mov
4474
               (cb, sorb, eip+2, 8, is_store, "movhpd", 
5119
               (cb, sorb, eip+2, 8, is_store, "movhpd", 
4475
                    0x66, insn[0], insn[1] );
5120
                    0x66, insn[0], insn[1] );
5121
      }
4476
      goto decode_success;
5122
      goto decode_success;
4477
   }
5123
   }
4478
5124
Lines 4489-4524 Link Here
4489
                  Lit16, (((UShort)insn[1]) << 8) | (UShort)modrm,
5135
                  Lit16, (((UShort)insn[1]) << 8) | (UShort)modrm,
4490
                  TempReg, t1 );
5136
                  TempReg, t1 );
4491
      uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
5137
      uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
4492
      if (dis)
5138
      DIP("pmovmskb %s, %s\n", 
4493
         VG_(printf)("pmovmskb %s, %s\n", 
5139
          nameXMMReg(eregOfRM(modrm)), nameIReg(4,gregOfRM(modrm)));
4494
                      nameXMMReg(eregOfRM(modrm)),
4495
                      nameIReg(4,gregOfRM(modrm)));
4496
      eip += 3;
5140
      eip += 3;
4497
      goto decode_success;
5141
      goto decode_success;
4498
   }
5142
   }
4499
5143
4500
   /* CVTDQ2PD -- convert one single double. to float. */
5144
   /* sz==4: SQRTPS: square root of packed float. */
4501
   if (insn[0] == 0xF3 && insn[1] == 0x0F && insn[2] == 0xE6) {
5145
   /* sz==2: SQRTPD: square root of packed double. */
4502
      vg_assert(sz == 4);
5146
   if (insn[0] == 0x0F && insn[1] == 0x51) {
4503
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+3, 8, "cvtdq2pd",
5147
      vg_assert(sz == 2 || sz == 4);
4504
                                      insn[0], insn[1], insn[2] );
5148
      if (sz == 4) {
4505
      goto decode_success;
5149
         eip = dis_SSE2_reg_or_mem ( cb, sorb, eip+2, 16, 
4506
   }
5150
                                         "sqrtps",
4507
5151
                                         insn[0], insn[1] );
4508
   /* CVTPD2PS -- convert two doubles to two floats. */
5152
      } else {
4509
   if (sz == 2 &&
5153
         eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, 
4510
       insn[0] == 0x0F && insn[1] == 0x5A) {
5154
                                         "sqrtpd",
4511
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, "cvtpd2ps",
4512
                                 0x66, insn[0], insn[1] );
5155
                                 0x66, insn[0], insn[1] );
5156
      }
4513
      goto decode_success;
5157
      goto decode_success;
4514
   }
5158
   }
4515
5159
4516
   /* SQRTPD: square root of packed double. */
5160
   /* RSQRTPS: square root reciprocal of packed float. */
4517
   if (sz == 2
5161
   if (insn[0] == 0x0F && insn[1] == 0x52) {
4518
       && insn[0] == 0x0F && insn[1] == 0x51) {
5162
      vg_assert(sz == 4);
4519
      eip = dis_SSE3_reg_or_mem ( cb, sorb, eip+2, 16, 
5163
      eip = dis_SSE2_reg_or_mem ( cb, sorb, eip+2, 16, 
4520
                                      "sqrtpd",
5164
                                      "rsqrtps",
4521
                                      0x66, insn[0], insn[1] );
5165
                                      insn[0], insn[1] );
4522
      goto decode_success;
5166
      goto decode_success;
4523
   }
5167
   }
4524
5168
Lines 4554-4568 Link Here
4554
      uInstr2(cb, ADD,  4, Literal, 0,     TempReg, t1);
5198
      uInstr2(cb, ADD,  4, Literal, 0,     TempReg, t1);
4555
      uLiteral(cb, 4+d32);
5199
      uLiteral(cb, 4+d32);
4556
      uInstr2(cb, PUT,  4, TempReg, t1,    ArchReg, R_ESP);
5200
      uInstr2(cb, PUT,  4, TempReg, t1,    ArchReg, R_ESP);
4557
      uInstr1(cb, JMP,  0, TempReg, t2);
5201
      jmp_treg(cb, t2);
4558
      uCond(cb, CondAlways);
4559
      LAST_UINSTR(cb).jmpkind = JmpRet;
5202
      LAST_UINSTR(cb).jmpkind = JmpRet;
4560
5203
4561
      *isEnd = True;
5204
      *isEnd = True;
4562
      if (dis) {
5205
      if (d32 == 0) { DIP("ret\n"); }
4563
         if (d32 == 0) VG_(printf)("ret\n"); 
5206
      else          { DIP("ret %d\n", d32); }
4564
                  else VG_(printf)("ret %d\n", d32);
5207
4565
      }
4566
      break;
5208
      break;
4567
      
5209
      
4568
   case 0xE8: /* CALL J4 */
5210
   case 0xE8: /* CALL J4 */
Lines 4583-4590 Link Here
4583
         uLiteral(cb, eip);
5225
         uLiteral(cb, eip);
4584
         uInstr2(cb, PUT, 4, TempReg, t1,  ArchReg, archReg);
5226
         uInstr2(cb, PUT, 4, TempReg, t1,  ArchReg, archReg);
4585
         eip++; /* Step over the POP */
5227
         eip++; /* Step over the POP */
4586
         if (dis) 
5228
         DIP("call 0x%x ; popl %s\n",d32,nameIReg(4,archReg));
4587
            VG_(printf)("call 0x%x ; popl %s\n",d32,nameIReg(4,archReg));
4588
      } else {
5229
      } else {
4589
         /* The normal sequence for a call. */
5230
         /* The normal sequence for a call. */
4590
         t1 = newTemp(cb); t2 = newTemp(cb); t3 = newTemp(cb);
5231
         t1 = newTemp(cb); t2 = newTemp(cb); t3 = newTemp(cb);
Lines 4596-4607 Link Here
4596
         uInstr2(cb, MOV,   4, Literal, 0,     TempReg, t2);
5237
         uInstr2(cb, MOV,   4, Literal, 0,     TempReg, t2);
4597
	 uLiteral(cb, eip);
5238
	 uLiteral(cb, eip);
4598
         uInstr2(cb, STORE, 4, TempReg, t2,    TempReg, t1);
5239
         uInstr2(cb, STORE, 4, TempReg, t2,    TempReg, t1);
4599
         uInstr1(cb, JMP,   0, Literal, 0);
5240
         jmp_lit(cb, d32);
4600
	 uLiteral(cb, d32);
4601
         uCond(cb, CondAlways);
4602
         LAST_UINSTR(cb).jmpkind = JmpCall;
5241
         LAST_UINSTR(cb).jmpkind = JmpCall;
4603
         *isEnd = True;
5242
         *isEnd = True;
4604
         if (dis) VG_(printf)("call 0x%x\n",d32);
5243
         DIP("call 0x%x\n",d32);
4605
      }
5244
      }
4606
      break;
5245
      break;
4607
5246
Lines 4625-4631 Link Here
4625
	 uLiteral(cb, d32);
5264
	 uLiteral(cb, d32);
4626
	 uInstr2(cb, PUT,    4, TempReg, t2,    ArchReg, R_ESP);
5265
	 uInstr2(cb, PUT,    4, TempReg, t2,    ArchReg, R_ESP);
4627
      }
5266
      }
4628
      if (dis) VG_(printf)("enter 0x%x, 0x%x", d32, abyte);
5267
      DIP("enter 0x%x, 0x%x", d32, abyte);
4629
      break;
5268
      break;
4630
5269
4631
   case 0xC9: /* LEAVE */
5270
   case 0xC9: /* LEAVE */
Lines 4639-4645 Link Here
4639
      uInstr2(cb, ADD,  4, Literal, 0, TempReg, t1);
5278
      uInstr2(cb, ADD,  4, Literal, 0, TempReg, t1);
4640
      uLiteral(cb, 4);
5279
      uLiteral(cb, 4);
4641
      uInstr2(cb, PUT,  4, TempReg, t1, ArchReg, R_ESP);
5280
      uInstr2(cb, PUT,  4, TempReg, t1, ArchReg, R_ESP);
4642
      if (dis) VG_(printf)("leave");
5281
      DIP("leave");
4643
      break;
5282
      break;
4644
5283
4645
   /* ---------------- Misc weird-ass insns --------------- */
5284
   /* ---------------- Misc weird-ass insns --------------- */
Lines 4656-4666 Link Here
4656
      uInstr1(cb, PUSH, 4, TempReg, t1);
5295
      uInstr1(cb, PUSH, 4, TempReg, t1);
4657
      uInstr1(cb, CALLM, 0, Lit16, 
5296
      uInstr1(cb, CALLM, 0, Lit16, 
4658
                  opc == 0x27 ? VGOFF_(helper_DAA) : VGOFF_(helper_DAS) );
5297
                  opc == 0x27 ? VGOFF_(helper_DAA) : VGOFF_(helper_DAS) );
4659
      uFlagsRWU(cb, FlagsAC, FlagsOSZACP, FlagsEmpty);
5298
      uFlagsRWU(cb, FlagsAC, FlagsSZACP, FlagO);
4660
      uInstr1(cb, POP, 4, TempReg, t1);
5299
      uInstr1(cb, POP, 4, TempReg, t1);
4661
      uInstr0(cb, CALLM_E, 0);
5300
      uInstr0(cb, CALLM_E, 0);
4662
      uInstr2(cb, PUT, 1, TempReg, t1, ArchReg, R_AL);
5301
      uInstr2(cb, PUT, 1, TempReg, t1, ArchReg, R_AL);
4663
      if (dis) VG_(printf)(opc == 0x27 ? "daa\n" : "das\n");
5302
      DIP(opc == 0x27 ? "daa\n" : "das\n");
5303
      break;
5304
5305
   case 0x37: /* AAA */
5306
   case 0x3F: /* AAS */
5307
      t1 = newTemp(cb);
5308
      uInstr2(cb, GET, 2, ArchReg, R_EAX, TempReg, t1);
5309
      /* Widen %AL to 32 bits, so it's all defined when we push it. */
5310
      uInstr1(cb, WIDEN, 4, TempReg, t1);
5311
      LAST_UINSTR(cb).extra4b = 2;
5312
      LAST_UINSTR(cb).signed_widen = False;
5313
      uInstr0(cb, CALLM_S, 0);
5314
      uInstr1(cb, PUSH, 4, TempReg, t1);
5315
      uInstr1(cb, CALLM, 0, Lit16, 
5316
                  opc == 0x37 ? VGOFF_(helper_AAA) : VGOFF_(helper_AAS) );
5317
      uFlagsRWU(cb, FlagA, FlagsAC, FlagsEmpty);
5318
      uInstr1(cb, POP, 4, TempReg, t1);
5319
      uInstr0(cb, CALLM_E, 0);
5320
      uInstr2(cb, PUT, 2, TempReg, t1, ArchReg, R_EAX);
5321
      DIP(opc == 0x37 ? "aaa\n" : "aas\n");
5322
      break;
5323
5324
   case 0xD4: /* AAM */
5325
   case 0xD5: /* AAD */
5326
      d32 = getUChar(eip); eip++;
5327
      if (d32 != 10) VG_(core_panic)("disInstr: AAM/AAD but base not 10 !");
5328
      t1 = newTemp(cb);
5329
      uInstr2(cb, GET, 2, ArchReg, R_EAX, TempReg, t1);
5330
      /* Widen %AX to 32 bits, so it's all defined when we push it. */
5331
      uInstr1(cb, WIDEN, 4, TempReg, t1);
5332
      LAST_UINSTR(cb).extra4b = 2;
5333
      LAST_UINSTR(cb).signed_widen = False;
5334
      uInstr0(cb, CALLM_S, 0);
5335
      uInstr1(cb, PUSH, 4, TempReg, t1);
5336
      uInstr1(cb, CALLM, 0, Lit16, 
5337
                  opc == 0xD4 ? VGOFF_(helper_AAM) : VGOFF_(helper_AAD) );
5338
      uFlagsRWU(cb, FlagsEmpty, FlagsSZP, FlagsEmpty);
5339
      uInstr1(cb, POP, 4, TempReg, t1);
5340
      uInstr0(cb, CALLM_E, 0);
5341
      uInstr2(cb, PUT, 2, TempReg, t1, ArchReg, R_EAX);
5342
      DIP(opc == 0xD4 ? "aam\n" : "aad\n");
4664
      break;
5343
      break;
4665
5344
4666
   /* ------------------------ CWD/CDQ -------------------- */
5345
   /* ------------------------ CWD/CDQ -------------------- */
Lines 4673-4679 Link Here
4673
         LAST_UINSTR(cb).extra4b = 2; /* the source size */
5352
         LAST_UINSTR(cb).extra4b = 2; /* the source size */
4674
         LAST_UINSTR(cb).signed_widen = True;
5353
         LAST_UINSTR(cb).signed_widen = True;
4675
         uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, R_EAX);
5354
         uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, R_EAX);
4676
         if (dis) VG_(printf)("cwd\n");
5355
         DIP("cwd\n");
4677
      } else {
5356
      } else {
4678
         vg_assert(sz == 2);
5357
         vg_assert(sz == 2);
4679
         uInstr2(cb, GET,   1, ArchReg, R_EAX, TempReg, t1);
5358
         uInstr2(cb, GET,   1, ArchReg, R_EAX, TempReg, t1);
Lines 4681-4687 Link Here
4681
         LAST_UINSTR(cb).extra4b = 1; /* the source size */
5360
         LAST_UINSTR(cb).extra4b = 1; /* the source size */
4682
         LAST_UINSTR(cb).signed_widen = True;
5361
         LAST_UINSTR(cb).signed_widen = True;
4683
         uInstr2(cb, PUT, 2, TempReg, t1, ArchReg, R_EAX);
5362
         uInstr2(cb, PUT, 2, TempReg, t1, ArchReg, R_EAX);
4684
         if (dis) VG_(printf)("cbw\n");
5363
         DIP("cbw\n");
4685
      }
5364
      }
4686
      break;
5365
      break;
4687
5366
Lines 4691-4714 Link Here
4691
      uInstr2(cb, SAR, sz, Literal, 0,     TempReg, t1);
5370
      uInstr2(cb, SAR, sz, Literal, 0,     TempReg, t1);
4692
      uLiteral(cb, sz == 2 ? 15  : 31);
5371
      uLiteral(cb, sz == 2 ? 15  : 31);
4693
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, R_EDX);
5372
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, R_EDX);
4694
      if (dis) VG_(printf)(sz == 2 ? "cwdq\n" : "cdqq\n");
5373
      DIP(sz == 2 ? "cwdq\n" : "cdqq\n");
4695
      break;
5374
      break;
4696
5375
4697
   /* ------------------------ FPU ops -------------------- */
5376
   /* ------------------------ FPU ops -------------------- */
4698
5377
4699
   case 0x9E: /* SAHF */
5378
   case 0x9E: /* SAHF */
4700
      codegen_SAHF ( cb );
5379
      codegen_SAHF ( cb );
4701
      if (dis) VG_(printf)("sahf\n");
5380
      DIP("sahf\n");
4702
      break;
5381
      break;
4703
5382
4704
   case 0x9F: /* LAHF */
5383
   case 0x9F: /* LAHF */
4705
      codegen_LAHF ( cb );
5384
      codegen_LAHF ( cb );
4706
      if (dis) VG_(printf)("lahf\n");
5385
      DIP("lahf\n");
4707
      break;
5386
      break;
4708
5387
4709
   case 0x9B: /* FWAIT */
5388
   case 0x9B: /* FWAIT */
4710
      /* ignore? */
5389
      /* ignore? */
4711
      if (dis) VG_(printf)("fwait\n");
5390
      DIP("fwait\n");
4712
      break;
5391
      break;
4713
5392
4714
   case 0xD8:
5393
   case 0xD8:
Lines 4739-4746 Link Here
4739
      setFlagsFromUOpcode(cb, INC);
5418
      setFlagsFromUOpcode(cb, INC);
4740
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg,
5419
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg,
4741
                             (UInt)(opc - 0x40));
5420
                             (UInt)(opc - 0x40));
4742
      if (dis)
5421
      DIP("inc%c %s\n", nameISize(sz), nameIReg(sz,opc-0x40));
4743
         VG_(printf)("inc%c %s\n", nameISize(sz), nameIReg(sz,opc-0x40));
4744
      break;
5422
      break;
4745
5423
4746
   case 0x48: /* DEC eAX */
5424
   case 0x48: /* DEC eAX */
Lines 4758-4765 Link Here
4758
      setFlagsFromUOpcode(cb, DEC);
5436
      setFlagsFromUOpcode(cb, DEC);
4759
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg,
5437
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg,
4760
                             (UInt)(opc - 0x48));
5438
                             (UInt)(opc - 0x48));
4761
      if (dis)
5439
      DIP("dec%c %s\n", nameISize(sz), nameIReg(sz,opc-0x48));
4762
         VG_(printf)("dec%c %s\n", nameISize(sz), nameIReg(sz,opc-0x48));
4763
      break;
5440
      break;
4764
5441
4765
   /* ------------------------ INT ------------------------ */
5442
   /* ------------------------ INT ------------------------ */
Lines 4770-4803 Link Here
4770
      /* It's important that all ArchRegs carry their up-to-date value
5447
      /* It's important that all ArchRegs carry their up-to-date value
4771
         at this point.  So we declare an end-of-block here, which
5448
         at this point.  So we declare an end-of-block here, which
4772
         forces any TempRegs caching ArchRegs to be flushed. */
5449
         forces any TempRegs caching ArchRegs to be flushed. */
4773
      uInstr1(cb, JMP,  0, Literal, 0);
5450
      jmp_lit(cb, eip);
4774
      uLiteral(cb, eip);
4775
      uCond(cb, CondAlways);
4776
      LAST_UINSTR(cb).jmpkind = JmpSyscall;
5451
      LAST_UINSTR(cb).jmpkind = JmpSyscall;
4777
      *isEnd = True;
5452
      *isEnd = True;
4778
      if (dis) VG_(printf)("int $0x80\n");
5453
      DIP("int $0x80\n");
4779
      break;
5454
      break;
4780
5455
4781
   /* ------------------------ Jcond, byte offset --------- */
5456
   /* ------------------------ Jcond, byte offset --------- */
4782
5457
4783
   case 0xEB: /* Jb (jump, byte offset) */
5458
   case 0xEB: /* Jb (jump, byte offset) */
4784
      d32 = (eip+1) + getSDisp8(eip); eip++;
5459
      d32 = (eip+1) + getSDisp8(eip); eip++;
4785
      uInstr1(cb, JMP, 0, Literal, 0);
5460
      jmp_lit(cb, d32);
4786
      uLiteral(cb, d32);
4787
      uCond(cb, CondAlways);
4788
      *isEnd = True;
5461
      *isEnd = True;
4789
      if (dis)
5462
      DIP("jmp-8 0x%x\n", d32);
4790
         VG_(printf)("jmp-8 0x%x\n", d32);
4791
      break;
5463
      break;
4792
5464
4793
   case 0xE9: /* Jv (jump, 16/32 offset) */
5465
   case 0xE9: /* Jv (jump, 16/32 offset) */
4794
      d32 = (eip+sz) + getSDisp(sz,eip); eip += sz;
5466
      d32 = (eip+sz) + getSDisp(sz,eip); eip += sz;
4795
      uInstr1(cb, JMP, 0, Literal, 0);
5467
      jmp_lit(cb, d32);
4796
      uLiteral(cb, d32);
4797
      uCond(cb, CondAlways);
4798
      *isEnd = True;
5468
      *isEnd = True;
4799
      if (dis)
5469
      DIP("jmp 0x%x\n", d32);
4800
        VG_(printf)("jmp 0x%x\n", d32);
4801
      break;
5470
      break;
4802
5471
4803
   case 0x70:
5472
   case 0x70:
Lines 4817-4839 Link Here
4817
   case 0x7E: /* JLEb/JNGb (jump less or equal) */
5486
   case 0x7E: /* JLEb/JNGb (jump less or equal) */
4818
   case 0x7F: /* JGb/JNLEb (jump greater) */
5487
   case 0x7F: /* JGb/JNLEb (jump greater) */
4819
      d32 = (eip+1) + getSDisp8(eip); eip++;
5488
      d32 = (eip+1) + getSDisp8(eip); eip++;
4820
      uInstr1(cb, JMP, 0, Literal, 0);
5489
      jcc_lit(cb, d32, (Condcode)(opc - 0x70));
4821
      uLiteral(cb, d32);
4822
      uCond(cb, (Condcode)(opc - 0x70));
4823
      uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
4824
      /* It's actually acceptable not to end this basic block at a
5490
      /* It's actually acceptable not to end this basic block at a
4825
         control transfer, reducing the number of jumps through
5491
         control transfer, reducing the number of jumps through
4826
         vg_dispatch, at the expense of possibly translating the insns
5492
         vg_dispatch, at the expense of possibly translating the insns
4827
         following this jump twice.  This does give faster code, but
5493
         following this jump twice.  This does give faster code, but
4828
         on the whole I don't think the effort is worth it. */
5494
         on the whole I don't think the effort is worth it. */
4829
      uInstr1(cb, JMP, 0, Literal, 0);
5495
      jmp_lit(cb, eip);
4830
      uLiteral(cb, eip);
4831
      uCond(cb, CondAlways);
4832
      *isEnd = True;
5496
      *isEnd = True;
4833
      /* The above 3 lines would be removed if the bb was not to end
5497
      /* The above 3 lines would be removed if the bb was not to end
4834
         here. */
5498
         here. */
4835
      if (dis)
5499
      DIP("j%s-8 0x%x\n", VG_(name_UCondcode)(opc - 0x70), d32);
4836
         VG_(printf)("j%s-8 0x%x\n", VG_(name_UCondcode)(opc - 0x70), d32);
4837
      break;
5500
      break;
4838
5501
4839
   case 0xE3: /* JECXZ or perhaps JCXZ, depending on OSO ?  Intel
5502
   case 0xE3: /* JECXZ or perhaps JCXZ, depending on OSO ?  Intel
Lines 4844-4851 Link Here
4844
      uInstr2(cb, GET,  4,  ArchReg, R_ECX, TempReg, t1);
5507
      uInstr2(cb, GET,  4,  ArchReg, R_ECX, TempReg, t1);
4845
      uInstr2(cb, JIFZ, 4,  TempReg, t1,    Literal, 0);
5508
      uInstr2(cb, JIFZ, 4,  TempReg, t1,    Literal, 0);
4846
      uLiteral(cb, d32);
5509
      uLiteral(cb, d32);
4847
      if (dis)
5510
      DIP("j%sz 0x%x\n", nameIReg(sz, R_ECX), d32);
4848
         VG_(printf)("j%sz 0x%x\n", nameIReg(sz, R_ECX), d32);
4849
      break;
5511
      break;
4850
5512
4851
   case 0xE0: /* LOOPNE disp8 */
5513
   case 0xE0: /* LOOPNE disp8 */
Lines 4863-4879 Link Here
4863
      uInstr2(cb, JIFZ, 4, TempReg, t1,    Literal, 0);
5525
      uInstr2(cb, JIFZ, 4, TempReg, t1,    Literal, 0);
4864
      uLiteral(cb, eip);
5526
      uLiteral(cb, eip);
4865
      if (opc == 0xE0 || opc == 0xE1) {   /* LOOPE/LOOPNE */
5527
      if (opc == 0xE0 || opc == 0xE1) {   /* LOOPE/LOOPNE */
4866
         uInstr1(cb, JMP,  0, Literal, 0);
5528
         jcc_lit(cb, eip, (opc == 0xE1 ? CondNZ : CondZ));
4867
         uLiteral(cb, eip);
4868
         uCond(cb, (opc == 0xE1 ? CondNZ : CondZ));
4869
         uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
4870
      }
5529
      }
4871
      uInstr1(cb, JMP,  0, Literal, 0);
5530
      jmp_lit(cb, d32);
4872
      uLiteral(cb, d32);
4873
      uCond(cb, CondAlways);
4874
      *isEnd = True;
5531
      *isEnd = True;
4875
      if (dis)
5532
      DIP("loop 0x%x\n", d32);
4876
         VG_(printf)("loop 0x%x\n", d32);
4877
      break;
5533
      break;
4878
5534
4879
   /* ------------------------ IMUL ----------------------- */
5535
   /* ------------------------ IMUL ----------------------- */
Lines 4910-4922 Link Here
4910
      /* NOTE!  this is the one place where a segment override prefix
5566
      /* NOTE!  this is the one place where a segment override prefix
4911
         has no effect on the address calculation.  Therefore we pass
5567
         has no effect on the address calculation.  Therefore we pass
4912
         zero instead of sorb here. */
5568
         zero instead of sorb here. */
4913
      pair = disAMode ( cb, /*sorb*/ 0, eip, dis?dis_buf:NULL );
5569
      pair = disAMode ( cb, /*sorb*/ 0, eip, dis_buf );
4914
      eip  += HI8(pair);
5570
      eip  += HI8(pair);
4915
      t1   = LOW24(pair);
5571
      t1   = LOW24(pair);
4916
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, gregOfRM(modrm));
5572
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, gregOfRM(modrm));
4917
      if (dis)
5573
      DIP("lea%c %s, %s\n", nameISize(sz), dis_buf, 
4918
         VG_(printf)("lea%c %s, %s\n", nameISize(sz), dis_buf, 
5574
                            nameIReg(sz,gregOfRM(modrm)));
4919
                                       nameIReg(sz,gregOfRM(modrm)));
4920
      break;
5575
      break;
4921
5576
4922
   case 0x8C: /* MOV Sw,Ew -- MOV from a SEGMENT REGISTER */
5577
   case 0x8C: /* MOV Sw,Ew -- MOV from a SEGMENT REGISTER */
Lines 4938-4946 Link Here
4938
      handleSegOverride(cb, sorb, t2);
5593
      handleSegOverride(cb, sorb, t2);
4939
      uInstr2(cb, LOAD, sz, TempReg, t2,  TempReg, t1);
5594
      uInstr2(cb, LOAD, sz, TempReg, t2,  TempReg, t1);
4940
      uInstr2(cb, PUT,  sz, TempReg, t1,  ArchReg, R_EAX);
5595
      uInstr2(cb, PUT,  sz, TempReg, t1,  ArchReg, R_EAX);
4941
      if (dis) VG_(printf)("mov%c %s0x%x, %s\n", nameISize(sz), 
5596
      DIP("mov%c %s0x%x, %s\n", nameISize(sz), sorbTxt(sorb),
4942
                           sorbTxt(sorb),
5597
                                d32, nameIReg(sz,R_EAX));
4943
                           d32, nameIReg(sz,R_EAX));
4944
      break;
5598
      break;
4945
5599
4946
   case 0xA2: /* MOV AL,Ob */
5600
   case 0xA2: /* MOV AL,Ob */
Lines 4954-4962 Link Here
4954
      uLiteral(cb, d32);
5608
      uLiteral(cb, d32);
4955
      handleSegOverride(cb, sorb, t2);
5609
      handleSegOverride(cb, sorb, t2);
4956
      uInstr2(cb, STORE, sz, TempReg, t1,    TempReg, t2);
5610
      uInstr2(cb, STORE, sz, TempReg, t1,    TempReg, t2);
4957
      if (dis) VG_(printf)("mov%c %s, %s0x%x\n", nameISize(sz), 
5611
      DIP("mov%c %s, %s0x%x\n", nameISize(sz), nameIReg(sz,R_EAX),
4958
                           nameIReg(sz,R_EAX),
5612
                                sorbTxt(sorb), d32);
4959
                           sorbTxt(sorb), d32);
4960
      break;
5613
      break;
4961
5614
4962
   case 0xB0: /* MOV imm,AL */
5615
   case 0xB0: /* MOV imm,AL */
Lines 4972-4979 Link Here
4972
      uInstr2(cb, MOV, 1, Literal, 0,  TempReg, t1);
5625
      uInstr2(cb, MOV, 1, Literal, 0,  TempReg, t1);
4973
      uLiteral(cb, d32);
5626
      uLiteral(cb, d32);
4974
      uInstr2(cb, PUT, 1, TempReg, t1, ArchReg, opc-0xB0);
5627
      uInstr2(cb, PUT, 1, TempReg, t1, ArchReg, opc-0xB0);
4975
      if (dis) VG_(printf)("movb $0x%x,%s\n", d32,
5628
      DIP("movb $0x%x,%s\n", d32, nameIReg(1,opc-0xB0));
4976
                           nameIReg(1,opc-0xB0));
4977
      break;
5629
      break;
4978
5630
4979
   case 0xB8: /* MOV imm,eAX */
5631
   case 0xB8: /* MOV imm,eAX */
Lines 4989-4996 Link Here
4989
      uInstr2(cb, MOV, sz, Literal, 0,  TempReg, t1);
5641
      uInstr2(cb, MOV, sz, Literal, 0,  TempReg, t1);
4990
      uLiteral(cb, d32);
5642
      uLiteral(cb, d32);
4991
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, opc-0xB8);
5643
      uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, opc-0xB8);
4992
      if (dis) VG_(printf)("mov%c $0x%x,%s\n", nameISize(sz), d32,
5644
      DIP("mov%c $0x%x,%s\n", nameISize(sz), d32, nameIReg(sz,opc-0xB8));
4993
                           nameIReg(sz,opc-0xB8));
4994
      break;
5645
      break;
4995
5646
4996
   case 0xC6: /* MOV Ib,Eb */
5647
   case 0xC6: /* MOV Ib,Eb */
Lines 5008-5017 Link Here
5008
         uInstr2(cb, MOV, sz, Literal, 0,  TempReg, t1);
5659
         uInstr2(cb, MOV, sz, Literal, 0,  TempReg, t1);
5009
	 uLiteral(cb, d32);
5660
	 uLiteral(cb, d32);
5010
         uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, eregOfRM(modrm));
5661
         uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, eregOfRM(modrm));
5011
         if (dis) VG_(printf)("mov%c $0x%x, %s\n", nameISize(sz), d32, 
5662
         DIP("mov%c $0x%x, %s\n", nameISize(sz), d32, 
5012
                              nameIReg(sz,eregOfRM(modrm)));
5663
                                  nameIReg(sz,eregOfRM(modrm)));
5013
      } else {
5664
      } else {
5014
         pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
5665
         pair = disAMode ( cb, sorb, eip, dis_buf );
5015
         eip += HI8(pair);
5666
         eip += HI8(pair);
5016
         d32 = getUDisp(sz,eip); eip += sz;
5667
         d32 = getUDisp(sz,eip); eip += sz;
5017
         t1 = newTemp(cb);
5668
         t1 = newTemp(cb);
Lines 5019-5025 Link Here
5019
         uInstr2(cb, MOV, sz, Literal, 0, TempReg, t1);
5670
         uInstr2(cb, MOV, sz, Literal, 0, TempReg, t1);
5020
	 uLiteral(cb, d32);
5671
	 uLiteral(cb, d32);
5021
         uInstr2(cb, STORE, sz, TempReg, t1, TempReg, t2);
5672
         uInstr2(cb, STORE, sz, TempReg, t1, TempReg, t2);
5022
         if (dis) VG_(printf)("mov%c $0x%x, %s\n", nameISize(sz), d32, dis_buf);
5673
         DIP("mov%c $0x%x, %s\n", nameISize(sz), d32, dis_buf);
5023
      }
5674
      }
5024
      break;
5675
      break;
5025
5676
Lines 5049-5054 Link Here
5049
   case 0x1C: /* SBB Ib, AL */
5700
   case 0x1C: /* SBB Ib, AL */
5050
      eip = dis_op_imm_A(cb, 1, SBB, True, eip, "sbb" );
5701
      eip = dis_op_imm_A(cb, 1, SBB, True, eip, "sbb" );
5051
      break;
5702
      break;
5703
   case 0x1D: /* SBB Iv, eAX */
5704
      eip = dis_op_imm_A(cb, sz, SBB, True, eip, "sbb" );
5705
      break;
5052
5706
5053
   case 0x24: /* AND Ib, AL */
5707
   case 0x24: /* AND Ib, AL */
5054
      eip = dis_op_imm_A(cb, 1, AND, True, eip, "and" );
5708
      eip = dis_op_imm_A(cb, 1, AND, True, eip, "and" );
Lines 5173-5178 Link Here
5173
      eip = dis_op2_G_E ( cb, sorb, ADC, True, sz, eip, "adc" );
5827
      eip = dis_op2_G_E ( cb, sorb, ADC, True, sz, eip, "adc" );
5174
      break;
5828
      break;
5175
5829
5830
   case 0x18: /* SBB Gb,Eb */
5831
      eip = dis_op2_G_E ( cb, sorb, SBB, True, 1, eip, "sbb" );
5832
      break;
5176
   case 0x19: /* SBB Gv,Ev */
5833
   case 0x19: /* SBB Gv,Ev */
5177
      eip = dis_op2_G_E ( cb, sorb, SBB, True, sz, eip, "sbb" );
5834
      eip = dis_op2_G_E ( cb, sorb, SBB, True, sz, eip, "sbb" );
5178
      break;
5835
      break;
Lines 5222-5229 Link Here
5222
      uLiteral(cb, sz);
5879
      uLiteral(cb, sz);
5223
      uInstr2(cb, PUT,    4, TempReg, t2,       ArchReg, R_ESP);
5880
      uInstr2(cb, PUT,    4, TempReg, t2,       ArchReg, R_ESP);
5224
      uInstr2(cb, PUT,   sz, TempReg, t1,       ArchReg, opc-0x58);
5881
      uInstr2(cb, PUT,   sz, TempReg, t1,       ArchReg, opc-0x58);
5225
      if (dis) 
5882
      DIP("pop%c %s\n", nameISize(sz), nameIReg(sz,opc-0x58));
5226
         VG_(printf)("pop%c %s\n", nameISize(sz), nameIReg(sz,opc-0x58));
5227
      break;
5883
      break;
5228
5884
5229
   case 0x9D: /* POPF */
5885
   case 0x9D: /* POPF */
Lines 5237-5244 Link Here
5237
      uInstr1(cb, PUTF,  sz, TempReg, t1);
5893
      uInstr1(cb, PUTF,  sz, TempReg, t1);
5238
      /* PUTF writes all the flags we are interested in */
5894
      /* PUTF writes all the flags we are interested in */
5239
      uFlagsRWU(cb, FlagsEmpty, FlagsALL, FlagsEmpty);
5895
      uFlagsRWU(cb, FlagsEmpty, FlagsALL, FlagsEmpty);
5240
      if (dis) 
5896
      DIP("popf%c\n", nameISize(sz));
5241
         VG_(printf)("popf%c\n", nameISize(sz));
5242
      break;
5897
      break;
5243
5898
5244
   case 0x61: /* POPA */
5899
   case 0x61: /* POPA */
Lines 5277-5284 Link Here
5277
      uInstr2(cb, ADD,    4, Literal, 0,  TempReg, t3);
5932
      uInstr2(cb, ADD,    4, Literal, 0,  TempReg, t3);
5278
      uLiteral(cb, sz * 8);             /* One 'sz' per register */
5933
      uLiteral(cb, sz * 8);             /* One 'sz' per register */
5279
      uInstr2(cb, PUT,    4, TempReg, t3, ArchReg, R_ESP);
5934
      uInstr2(cb, PUT,    4, TempReg, t3, ArchReg, R_ESP);
5280
      if (dis)
5935
      DIP("popa%c\n", nameISize(sz));
5281
         VG_(printf)("popa%c\n", nameISize(sz));
5282
      break;
5936
      break;
5283
    }
5937
    }
5284
5938
Lines 5309-5323 Link Here
5309
       uInstr2(cb, PUT,    4, TempReg, t1,       ArchReg, R_ESP);
5963
       uInstr2(cb, PUT,    4, TempReg, t1,       ArchReg, R_ESP);
5310
5964
5311
       /* resolve MODR/M */
5965
       /* resolve MODR/M */
5312
       pair1 = disAMode ( cb, sorb, eip, dis?dis_buf:NULL);              
5966
       pair1 = disAMode ( cb, sorb, eip, dis_buf );              
5313
       
5967
       
5314
       tmpa = LOW24(pair1);
5968
       tmpa = LOW24(pair1);
5315
       /*  uInstr2(cb, LOAD, sz, TempReg, tmpa, TempReg, tmpa); */
5969
       /*  uInstr2(cb, LOAD, sz, TempReg, tmpa, TempReg, tmpa); */
5316
       /* store value from stack in memory, M[m32] = t3 */       
5970
       /* store value from stack in memory, M[m32] = t3 */       
5317
       uInstr2(cb, STORE, 4, TempReg, t3, TempReg, tmpa);
5971
       uInstr2(cb, STORE, 4, TempReg, t3, TempReg, tmpa);
5318
5972
5319
       if (dis) 
5973
       DIP("popl %s\n", dis_buf);
5320
          VG_(printf)("popl %s\n", dis_buf);
5321
5974
5322
       eip += HI8(pair1);
5975
       eip += HI8(pair1);
5323
       break;
5976
       break;
Lines 5351-5358 Link Here
5351
      uLiteral(cb, sz);
6004
      uLiteral(cb, sz);
5352
      uInstr2(cb, PUT,    4, TempReg, t2,       ArchReg, R_ESP);
6005
      uInstr2(cb, PUT,    4, TempReg, t2,       ArchReg, R_ESP);
5353
      uInstr2(cb, STORE, sz, TempReg, t1,       TempReg, t2);
6006
      uInstr2(cb, STORE, sz, TempReg, t1,       TempReg, t2);
5354
      if (dis) 
6007
      DIP("push%c %s\n", nameISize(sz), nameIReg(sz,opc-0x50));
5355
         VG_(printf)("push%c %s\n", nameISize(sz), nameIReg(sz,opc-0x50));
5356
      break;
6008
      break;
5357
6009
5358
   case 0x68: /* PUSH Iv */
6010
   case 0x68: /* PUSH Iv */
Lines 5370-5377 Link Here
5370
      uInstr2(cb, MOV,   sz, Literal, 0,     TempReg, t2);
6022
      uInstr2(cb, MOV,   sz, Literal, 0,     TempReg, t2);
5371
      uLiteral(cb, d32);
6023
      uLiteral(cb, d32);
5372
      uInstr2(cb, STORE, sz, TempReg, t2,    TempReg, t1);
6024
      uInstr2(cb, STORE, sz, TempReg, t2,    TempReg, t1);
5373
      if (dis) 
6025
      DIP("push%c $0x%x\n", nameISize(sz), d32);
5374
         VG_(printf)("push%c $0x%x\n", nameISize(sz), d32);
5375
      break;
6026
      break;
5376
6027
5377
   case 0x9C: /* PUSHF */
6028
   case 0x9C: /* PUSHF */
Lines 5386-5393 Link Here
5386
      uLiteral(cb, sz);
6037
      uLiteral(cb, sz);
5387
      uInstr2(cb, PUT,    4, TempReg, t2,       ArchReg, R_ESP);
6038
      uInstr2(cb, PUT,    4, TempReg, t2,       ArchReg, R_ESP);
5388
      uInstr2(cb, STORE, sz, TempReg, t1,       TempReg, t2);
6039
      uInstr2(cb, STORE, sz, TempReg, t1,       TempReg, t2);
5389
      if (dis) 
6040
      DIP("pushf%c\n", nameISize(sz));
5390
         VG_(printf)("pushf%c\n", nameISize(sz));
5391
      break;
6041
      break;
5392
6042
5393
   case 0x60: /* PUSHA */
6043
   case 0x60: /* PUSHA */
Lines 5429-5436 Link Here
5429
         uLiteral(cb, sz);
6079
         uLiteral(cb, sz);
5430
         uInstr2(cb, STORE, sz, TempReg,  t1, TempReg, t2);
6080
         uInstr2(cb, STORE, sz, TempReg,  t1, TempReg, t2);
5431
      }
6081
      }
5432
      if (dis)
6082
      DIP("pusha%c\n", nameISize(sz));
5433
         VG_(printf)("pusha%c\n", nameISize(sz));
5434
      break;
6083
      break;
5435
   }
6084
   }
5436
6085
Lines 5476-5482 Link Here
5476
      uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_CLD));
6125
      uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_CLD));
5477
      uFlagsRWU(cb, FlagsEmpty, FlagD, FlagsEmpty);
6126
      uFlagsRWU(cb, FlagsEmpty, FlagD, FlagsEmpty);
5478
      uInstr0(cb, CALLM_E, 0);
6127
      uInstr0(cb, CALLM_E, 0);
5479
      if (dis) VG_(printf)("cld\n");
6128
      DIP("cld\n");
5480
      break;
6129
      break;
5481
6130
5482
   case 0xFD: /* STD */
6131
   case 0xFD: /* STD */
Lines 5484-5490 Link Here
5484
      uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_STD));
6133
      uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_STD));
5485
      uFlagsRWU(cb, FlagsEmpty, FlagD, FlagsEmpty);
6134
      uFlagsRWU(cb, FlagsEmpty, FlagD, FlagsEmpty);
5486
      uInstr0(cb, CALLM_E, 0);
6135
      uInstr0(cb, CALLM_E, 0);
5487
      if (dis) VG_(printf)("std\n");
6136
      DIP("std\n");
5488
      break;
6137
      break;
5489
6138
5490
   case 0xF8: /* CLC */
6139
   case 0xF8: /* CLC */
Lines 5492-5506 Link Here
5492
      uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_CLC));
6141
      uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_CLC));
5493
      uFlagsRWU(cb, FlagsEmpty, FlagC, FlagsOSZAP);
6142
      uFlagsRWU(cb, FlagsEmpty, FlagC, FlagsOSZAP);
5494
      uInstr0(cb, CALLM_E, 0);
6143
      uInstr0(cb, CALLM_E, 0);
5495
      if (dis) VG_(printf)("clc\n");
6144
      DIP("clc\n");
5496
      break;
6145
      break;
5497
6146
5498
   case 0xF9: /* STC */
6147
   case 0xF9: /* STC */
5499
      uInstr0(cb, CALLM_S, 0);
6148
      uInstr0(cb, CALLM_S, 0);
5500
      uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_STC));
6149
      uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_STC));
5501
      uFlagsRWU(cb, FlagsEmpty, FlagC, FlagsOSZCP);
6150
      uFlagsRWU(cb, FlagsEmpty, FlagC, FlagsOSZAP);
6151
      uInstr0(cb, CALLM_E, 0);
6152
      DIP("stc\n");
6153
      break;
6154
6155
   case 0xF5: /* CMC */
6156
      uInstr0(cb, CALLM_S, 0);
6157
      uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_CMC));
6158
      uFlagsRWU(cb, FlagC, FlagC, FlagsOSZAP);
5502
      uInstr0(cb, CALLM_E, 0);
6159
      uInstr0(cb, CALLM_E, 0);
5503
      if (dis) VG_(printf)("stc\n");
6160
      DIP("cmc\n");
5504
      break;
6161
      break;
5505
6162
5506
   case 0xF2: { /* REPNE prefix insn */
6163
   case 0xF2: { /* REPNE prefix insn */
Lines 5554-5561 Link Here
5554
      }
6211
      }
5555
      else
6212
      else
5556
      if (abyte == 0x90) { /* REP NOP (PAUSE) */
6213
      if (abyte == 0x90) { /* REP NOP (PAUSE) */
5557
         if (dis) VG_(printf)("rep nop (P4 pause)\n");
6214
         /* a hint to the P4 re spin-wait loop */
5558
         /* do nothing; apparently a hint to the P4 re spin-wait loop */
6215
         DIP("rep nop (P4 pause)\n");
6216
         jmp_lit(cb, eip);
6217
         LAST_UINSTR(cb).jmpkind = JmpYield;
6218
         *isEnd = True;
5559
      } 
6219
      } 
5560
      else {
6220
      else {
5561
         goto decode_failure;
6221
         goto decode_failure;
Lines 5577-5603 Link Here
5577
         uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, gregOfRM(modrm));
6237
         uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, gregOfRM(modrm));
5578
         uInstr2(cb, PUT, sz, TempReg, t2, ArchReg, eregOfRM(modrm));
6238
         uInstr2(cb, PUT, sz, TempReg, t2, ArchReg, eregOfRM(modrm));
5579
         eip++;
6239
         eip++;
5580
         if (dis)
6240
         DIP("xchg%c %s, %s\n", 
5581
            VG_(printf)("xchg%c %s, %s\n", nameISize(sz), 
6241
             nameISize(sz), nameIReg(sz,gregOfRM(modrm)), 
5582
                        nameIReg(sz,gregOfRM(modrm)), 
6242
                            nameIReg(sz,eregOfRM(modrm)));
5583
                        nameIReg(sz,eregOfRM(modrm)));
5584
      } else {
6243
      } else {
5585
         pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL);
6244
         pair = disAMode ( cb, sorb, eip, dis_buf );
5586
         t3   = LOW24(pair);
6245
         t3   = LOW24(pair);
5587
         uInstr2(cb, LOAD, sz, TempReg, t3, TempReg, t1);
6246
         uInstr2(cb, LOAD, sz, TempReg, t3, TempReg, t1);
5588
         uInstr2(cb, GET, sz, ArchReg, gregOfRM(modrm), TempReg, t2);
6247
         uInstr2(cb, GET, sz, ArchReg, gregOfRM(modrm), TempReg, t2);
5589
         uInstr2(cb, STORE, sz, TempReg, t2, TempReg, t3);
6248
         uInstr2(cb, STORE, sz, TempReg, t2, TempReg, t3);
5590
         uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, gregOfRM(modrm));
6249
         uInstr2(cb, PUT, sz, TempReg, t1, ArchReg, gregOfRM(modrm));
5591
         eip += HI8(pair);
6250
         eip += HI8(pair);
5592
         if (dis)
6251
         DIP("xchg%c %s, %s\n", nameISize(sz), 
5593
            VG_(printf)("xchg%c %s, %s\n", nameISize(sz), 
6252
                                nameIReg(sz,gregOfRM(modrm)), dis_buf);
5594
                        nameIReg(sz,gregOfRM(modrm)), 
5595
                        dis_buf);
5596
      }
6253
      }
5597
      break;
6254
      break;
5598
6255
5599
   case 0x90: /* XCHG eAX,eAX */
6256
   case 0x90: /* XCHG eAX,eAX */
5600
      if (dis) VG_(printf)("nop\n");
6257
      DIP("nop\n");
5601
      break;
6258
      break;
5602
   case 0x91: /* XCHG eAX,eCX */
6259
   case 0x91: /* XCHG eAX,eCX */
5603
   case 0x92: /* XCHG eAX,eDX */
6260
   case 0x92: /* XCHG eAX,eDX */
Lines 5624-5631 Link Here
5624
      uInstr2(cb, LOAD, 1, TempReg, t1,  TempReg, t2); /* get byte at t1 into t2 */
6281
      uInstr2(cb, LOAD, 1, TempReg, t1,  TempReg, t2); /* get byte at t1 into t2 */
5625
      uInstr2(cb, PUT, 1, TempReg, t2, ArchReg, R_AL); /* put byte into AL */
6282
      uInstr2(cb, PUT, 1, TempReg, t2, ArchReg, R_AL); /* put byte into AL */
5626
6283
5627
      if (dis)
6284
      DIP("xlat%c [ebx]\n", nameISize(sz));
5628
         VG_(printf)("xlat%c [ebx]\n", nameISize(sz));
5629
      break;
6285
      break;
5630
6286
5631
   /* ------------------------ IN / OUT ----------------------- */
6287
   /* ------------------------ IN / OUT ----------------------- */
Lines 5659-5669 Link Here
5659
      uInstr1(cb, CLEAR, 0, Lit16,   4);
6315
      uInstr1(cb, CLEAR, 0, Lit16,   4);
5660
      uInstr0(cb, CALLM_E, 0);
6316
      uInstr0(cb, CALLM_E, 0);
5661
      uInstr2(cb, PUT,   4, TempReg, t2, ArchReg, R_EAX);
6317
      uInstr2(cb, PUT,   4, TempReg, t2, ArchReg, R_EAX);
5662
      if (dis) {
6318
      if ( opc == 0xE4 || opc == 0xE5 ) {
5663
         if ( opc == 0xE4 || opc == 0xE5 )
6319
         DIP("in 0x%x, %%eax/%%ax/%%al\n", getUChar(eip-1) );
5664
            VG_(printf)("in 0x%x, %%eax/%%ax/%%al\n", getUChar(eip-1) );
6320
      } else {
5665
         else
6321
         DIP("in (%%dx), %%eax/%%ax/%%al\n");
5666
            VG_(printf)("in (%%dx), %%eax/%%ax/%%al\n");
5667
      }
6322
      }
5668
      break;
6323
      break;
5669
   case 0xE6: /* OUT %al,ib       */
6324
   case 0xE6: /* OUT %al,ib       */
Lines 5694-5704 Link Here
5694
      uFlagsRWU(cb, FlagsEmpty, FlagsEmpty, FlagsEmpty);
6349
      uFlagsRWU(cb, FlagsEmpty, FlagsEmpty, FlagsEmpty);
5695
      uInstr1(cb, CLEAR,  0, Lit16,  12);
6350
      uInstr1(cb, CLEAR,  0, Lit16,  12);
5696
      uInstr0(cb, CALLM_E, 0);
6351
      uInstr0(cb, CALLM_E, 0);
5697
      if (dis) {
6352
      if ( opc == 0xE4 || opc == 0xE5 ) {
5698
         if ( opc == 0xE4 || opc == 0xE5 )
6353
         DIP("out %%eax/%%ax/%%al, 0x%x\n", getUChar(eip-1) );
5699
            VG_(printf)("out %%eax/%%ax/%%al, 0x%x\n", getUChar(eip-1) );
6354
      } else {
5700
         else
6355
         DIP("out %%eax/%%ax/%%al, (%%dx)\n");
5701
            VG_(printf)("out %%eax/%%ax/%%al, (%%dx)\n");
5702
      }
6356
      }
5703
      break;
6357
      break;
5704
6358
Lines 5841-5847 Link Here
5841
         uInstr2(cb, GET,   4, ArchReg, opc-0xC8, TempReg, t1);
6495
         uInstr2(cb, GET,   4, ArchReg, opc-0xC8, TempReg, t1);
5842
	 uInstr1(cb, BSWAP, 4, TempReg, t1);
6496
	 uInstr1(cb, BSWAP, 4, TempReg, t1);
5843
         uInstr2(cb, PUT,   4, TempReg, t1, ArchReg, opc-0xC8);
6497
         uInstr2(cb, PUT,   4, TempReg, t1, ArchReg, opc-0xC8);
5844
         if (dis) VG_(printf)("bswapl %s\n", nameIReg(4, opc-0xC8));
6498
         DIP("bswapl %s\n", nameIReg(4, opc-0xC8));
5845
         break;
6499
         break;
5846
6500
5847
      /* =-=-=-=-=-=-=-=-=- BT/BTS/BTR/BTC =-=-=-=-=-=-= */
6501
      /* =-=-=-=-=-=-=-=-=- BT/BTS/BTR/BTC =-=-=-=-=-=-= */
Lines 5882-5894 Link Here
5882
6536
5883
      /* =-=-=-=-=-=-=-=-=- CMPXCHG -=-=-=-=-=-=-=-=-=-= */
6537
      /* =-=-=-=-=-=-=-=-=- CMPXCHG -=-=-=-=-=-=-=-=-=-= */
5884
6538
6539
      case 0xB0: /* CMPXCHG Gv,Ev */
6540
         eip = dis_cmpxchg_G_E ( cb, sorb, 1, eip );
6541
         break;
5885
      case 0xB1: /* CMPXCHG Gv,Ev */
6542
      case 0xB1: /* CMPXCHG Gv,Ev */
5886
         eip = dis_cmpxchg_G_E ( cb, sorb, sz, eip );
6543
         eip = dis_cmpxchg_G_E ( cb, sorb, sz, eip );
5887
         break;
6544
         break;
6545
      case 0xC7: /* CMPXCHG8B Gv */
6546
         eip = dis_cmpxchg8b ( cb, sorb, eip );
6547
         break;
5888
6548
5889
      /* =-=-=-=-=-=-=-=-=- CPUID -=-=-=-=-=-=-=-=-=-=-= */
6549
      /* =-=-=-=-=-=-=-=-=- CPUID -=-=-=-=-=-=-=-=-=-=-= */
5890
6550
5891
      case 0xA2: /* CPUID */
6551
      case 0xA2: /* CPUID */
6552
	 if (!VG_(cpu_has_feature)(VG_X86_FEAT_CPUID))
6553
	    goto decode_failure;
6554
5892
         t1 = newTemp(cb);
6555
         t1 = newTemp(cb);
5893
         t2 = newTemp(cb);
6556
         t2 = newTemp(cb);
5894
         t3 = newTemp(cb);
6557
         t3 = newTemp(cb);
Lines 5926-5932 Link Here
5926
         uInstr2(cb, PUT,   4, TempReg, t1, ArchReg, R_EAX);
6589
         uInstr2(cb, PUT,   4, TempReg, t1, ArchReg, R_EAX);
5927
6590
5928
         uInstr0(cb, CALLM_E, 0);
6591
         uInstr0(cb, CALLM_E, 0);
5929
         if (dis) VG_(printf)("cpuid\n");
6592
         DIP("cpuid\n");
5930
         break;
6593
         break;
5931
6594
5932
      /* =-=-=-=-=-=-=-=-=- MOVZX, MOVSX =-=-=-=-=-=-=-= */
6595
      /* =-=-=-=-=-=-=-=-=- MOVZX, MOVSX =-=-=-=-=-=-=-= */
Lines 5945-5950 Link Here
5945
         eip = dis_movx_E_G ( cb, sorb, eip, 2, 4, True );
6608
         eip = dis_movx_E_G ( cb, sorb, eip, 2, 4, True );
5946
         break;
6609
         break;
5947
6610
6611
      /* =-=-=-=-=-=-=-=-=-=-= MOVNTI -=-=-=-=-=-=-=-=-= */
6612
6613
      case 0xC3: /* MOVNTI Gv,Ev */
6614
         vg_assert(sz == 4);
6615
         modrm = getUChar(eip);
6616
         vg_assert(!epartIsReg(modrm));
6617
         t1 = newTemp(cb);
6618
         uInstr2(cb, GET, 4, ArchReg, gregOfRM(modrm), TempReg, t1);
6619
         pair = disAMode ( cb, sorb, eip, dis_buf );
6620
         t2 = LOW24(pair);
6621
         eip += HI8(pair);
6622
         uInstr2(cb, STORE, 4, TempReg, t1, TempReg, t2);
6623
         DIP("movnti %s,%s\n", nameIReg(4,gregOfRM(modrm)), dis_buf);
6624
         break;
6625
5948
      /* =-=-=-=-=-=-=-=-=- MUL/IMUL =-=-=-=-=-=-=-=-=-= */
6626
      /* =-=-=-=-=-=-=-=-=- MUL/IMUL =-=-=-=-=-=-=-=-=-= */
5949
6627
5950
      case 0xAF: /* IMUL Ev, Gv */
6628
      case 0xAF: /* IMUL Ev, Gv */
Lines 5969-5985 Link Here
5969
      case 0x8E: /* JLEb/JNGb (jump less or equal) */
6647
      case 0x8E: /* JLEb/JNGb (jump less or equal) */
5970
      case 0x8F: /* JGb/JNLEb (jump greater) */
6648
      case 0x8F: /* JGb/JNLEb (jump greater) */
5971
         d32 = (eip+4) + getUDisp32(eip); eip += 4;
6649
         d32 = (eip+4) + getUDisp32(eip); eip += 4;
5972
         uInstr1(cb, JMP, 0, Literal, 0);
6650
         jcc_lit(cb, d32, (Condcode)(opc - 0x80));
5973
	 uLiteral(cb, d32);
6651
         jmp_lit(cb, eip);
5974
         uCond(cb, (Condcode)(opc - 0x80));
5975
         uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
5976
         uInstr1(cb, JMP, 0, Literal, 0);
5977
	 uLiteral(cb, eip);
5978
         uCond(cb, CondAlways);
5979
         *isEnd = True;
6652
         *isEnd = True;
5980
         if (dis)
6653
         DIP("j%s-32 0x%x\n", VG_(name_UCondcode)(opc - 0x80), d32);
5981
            VG_(printf)("j%s-32 0x%x\n", 
5982
                        VG_(name_UCondcode)(opc - 0x80), d32);
5983
         break;
6654
         break;
5984
6655
5985
      /* =-=-=-=-=-=-=-=-=- RDTSC -=-=-=-=-=-=-=-=-=-=-= */
6656
      /* =-=-=-=-=-=-=-=-=- RDTSC -=-=-=-=-=-=-=-=-=-=-= */
Lines 6002-6008 Link Here
6002
         uInstr1(cb, POP,   4, TempReg, t3);
6673
         uInstr1(cb, POP,   4, TempReg, t3);
6003
         uInstr2(cb, PUT,   4, TempReg, t3, ArchReg, R_EAX);
6674
         uInstr2(cb, PUT,   4, TempReg, t3, ArchReg, R_EAX);
6004
         uInstr0(cb, CALLM_E, 0);
6675
         uInstr0(cb, CALLM_E, 0);
6005
         if (dis) VG_(printf)("rdtsc\n");
6676
         DIP("rdtsc\n");
6006
         break;
6677
         break;
6007
6678
6008
      /* =-=-=-=-=-=-=-=-=- SETcc Eb =-=-=-=-=-=-=-=-=-= */
6679
      /* =-=-=-=-=-=-=-=-=- SETcc Eb =-=-=-=-=-=-=-=-=-= */
Lines 6030-6049 Link Here
6030
            uCond(cb, (Condcode)(opc-0x90));
6701
            uCond(cb, (Condcode)(opc-0x90));
6031
            uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
6702
            uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
6032
            uInstr2(cb, PUT, 1, TempReg, t1, ArchReg, eregOfRM(modrm));
6703
            uInstr2(cb, PUT, 1, TempReg, t1, ArchReg, eregOfRM(modrm));
6033
            if (dis) VG_(printf)("set%s %s\n", 
6704
            DIP("set%s %s\n", VG_(name_UCondcode)(opc-0x90), 
6034
                                 VG_(name_UCondcode)(opc-0x90), 
6705
                              nameIReg(1,eregOfRM(modrm)));
6035
                                 nameIReg(1,eregOfRM(modrm)));
6036
         } else {
6706
         } else {
6037
            pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
6707
            pair = disAMode ( cb, sorb, eip, dis_buf );
6038
            t2 = LOW24(pair);
6708
            t2 = LOW24(pair);
6039
            eip += HI8(pair);
6709
            eip += HI8(pair);
6040
            uInstr1(cb, CC2VAL, 1, TempReg, t1);
6710
            uInstr1(cb, CC2VAL, 1, TempReg, t1);
6041
            uCond(cb, (Condcode)(opc-0x90));
6711
            uCond(cb, (Condcode)(opc-0x90));
6042
            uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
6712
            uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
6043
            uInstr2(cb, STORE, 1, TempReg, t1, TempReg, t2);
6713
            uInstr2(cb, STORE, 1, TempReg, t1, TempReg, t2);
6044
            if (dis) VG_(printf)("set%s %s\n", 
6714
            DIP("set%s %s\n", VG_(name_UCondcode)(opc-0x90), dis_buf);
6045
                                 VG_(name_UCondcode)(opc-0x90), 
6046
                                 dis_buf);
6047
         }
6715
         }
6048
         break;
6716
         break;
6049
6717
Lines 6077-6082 Link Here
6077
6745
6078
      /* =-=-=-=-=-=-=-=-=- CMPXCHG -=-=-=-=-=-=-=-=-=-= */
6746
      /* =-=-=-=-=-=-=-=-=- CMPXCHG -=-=-=-=-=-=-=-=-=-= */
6079
6747
6748
      case 0xC0: /* XADD Gb,Eb */
6749
         eip = dis_xadd_G_E ( cb, sorb, 1, eip );
6750
         break;
6080
      case 0xC1: /* XADD Gv,Ev */
6751
      case 0xC1: /* XADD Gv,Ev */
6081
         eip = dis_xadd_G_E ( cb, sorb, sz, eip );
6752
         eip = dis_xadd_G_E ( cb, sorb, sz, eip );
6082
         break;
6753
         break;
Lines 6095-6103 Link Here
6095
            goto decode_failure;
6766
            goto decode_failure;
6096
         }
6767
         }
6097
         eip += lengthAMode(eip);
6768
         eip += lengthAMode(eip);
6098
         if (dis) {
6769
         if (VG_(print_codegen)) {
6099
            UChar* hintstr;
6770
            UChar* hintstr;
6100
            if(opc == 0x0D) {
6771
            if (opc == 0x0D) {
6101
               switch (gregOfRM(modrm)) {
6772
               switch (gregOfRM(modrm)) {
6102
                  case 0: hintstr = ""; break;
6773
                  case 0: hintstr = ""; break;
6103
                  case 1: hintstr = "w"; break;
6774
                  case 1: hintstr = "w"; break;
Lines 6117-6126 Link Here
6117
         }
6788
         }
6118
         break;
6789
         break;
6119
6790
6120
      case 0x71: case 0x72: case 0x73: 
6791
      case 0x71: case 0x72: case 0x73: {
6121
         /* (sz==4): PSLL/PSRA/PSRL mmxreg by imm8 */
6792
         /* (sz==4): PSLL/PSRA/PSRL mmxreg by imm8 */
6122
         /* (sz==2): PSLL/PSRA/PSRL xmmreg by imm8 */
6793
         /* (sz==2): PSLL/PSRA/PSRL xmmreg by imm8 */
6123
         {
6124
         UChar byte1, byte2, byte3, subopc, mmreg;
6794
         UChar byte1, byte2, byte3, subopc, mmreg;
6125
         vg_assert(sz == 4 || sz == 2);
6795
         vg_assert(sz == 4 || sz == 2);
6126
         byte1 = opc;                   /* 0x71/72/73 */
6796
         byte1 = opc;                   /* 0x71/72/73 */
Lines 6146-6186 Link Here
6146
            uInstr2(cb, MMX3, 0, 
6816
            uInstr2(cb, MMX3, 0, 
6147
                        Lit16, (((UShort)byte1) << 8) | ((UShort)byte2),
6817
                        Lit16, (((UShort)byte1) << 8) | ((UShort)byte2),
6148
                        Lit16, ((UShort)byte3) );
6818
                        Lit16, ((UShort)byte3) );
6149
            if (dis)
6819
            DIP("ps%s%s $%d, %s\n",
6150
               VG_(printf)("ps%s%s $%d, %s\n",
6820
                ( subopc == 2 ? "rl" 
6151
                           (subopc == 2 ? "rl" 
6821
                : subopc == 6 ? "ll" 
6152
                            : subopc == 6 ? "ll" 
6822
                : subopc == 4 ? "ra"
6153
                            : subopc == 4 ? "ra"
6823
                : "??"),
6154
                            : "??"),
6824
                nameMMXGran(opc & 3), (Int)byte3, nameMMXReg(mmreg) );
6155
                           nameMMXGran(opc & 3),
6156
                           (Int)byte3,
6157
                           nameMMXReg(mmreg) );
6158
	 } else {
6825
	 } else {
6159
            /* Whereas we have to include it for SSE. */
6826
            /* Whereas we have to include it for SSE. */
6160
            uInstr3(cb, SSE5, 0, 
6827
            uInstr3(cb, SSE5, 0, 
6161
                        Lit16, (((UShort)0x66) << 8) | ((UShort)0x0F),
6828
                        Lit16, (((UShort)0x66) << 8) | ((UShort)0x0F),
6162
                        Lit16, (((UShort)byte1) << 8) | ((UShort)byte2),
6829
                        Lit16, (((UShort)byte1) << 8) | ((UShort)byte2),
6163
                        Lit16, ((UShort)byte3) );
6830
                        Lit16, ((UShort)byte3) );
6164
            if (dis)
6831
            DIP("ps%s%s $%d, %s\n",
6165
               VG_(printf)("ps%s%s $%d, %s\n",
6832
                ( subopc == 2 ? "rl" 
6166
                           (subopc == 2 ? "rl" 
6833
                : subopc == 6 ? "ll" 
6167
                            : subopc == 6 ? "ll" 
6834
                : subopc == 4 ? "ra"
6168
                            : subopc == 4 ? "ra"
6835
                : subopc == 3 ? "(PSRLDQ)"
6169
                            : subopc == 3 ? "(PSRLDQ)"
6836
                : subopc == 7 ? "(PSLLDQ)"
6170
                            : subopc == 7 ? "(PSLLDQ)"
6837
                : "??"),
6171
                            : "??"),
6838
                nameMMXGran(opc & 3), (Int)byte3, nameXMMReg(mmreg) );
6172
                           nameMMXGran(opc & 3),
6173
                           (Int)byte3,
6174
                           nameXMMReg(mmreg) );
6175
	 }
6176
	 }
6839
	 }
6177
         break;
6840
         break;
6841
      }
6178
6842
6179
      case 0x77: /* EMMS */
6843
      case 0x77: /* EMMS */
6180
         vg_assert(sz == 4);
6844
         vg_assert(sz == 4);
6181
         uInstr1(cb, MMX1, 0, Lit16, ((UShort)(opc)) );
6845
         uInstr1(cb, MMX1, 0, Lit16, ((UShort)(opc)) );
6182
         if (dis)
6846
         DIP("emms\n");
6183
            VG_(printf)("emms\n");
6184
         break;
6847
         break;
6185
6848
6186
      case 0x7E: /* MOVD (src)mmxreg, (dst)ireg-or-mem */
6849
      case 0x7E: /* MOVD (src)mmxreg, (dst)ireg-or-mem */
Lines 6194-6216 Link Here
6194
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6857
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6195
                        TempReg, t1 );
6858
                        TempReg, t1 );
6196
            uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, eregOfRM(modrm));
6859
            uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, eregOfRM(modrm));
6197
            if (dis)
6860
            DIP("movd %s, %s\n", 
6198
               VG_(printf)("movd %s, %s\n", 
6861
                nameMMXReg(gregOfRM(modrm)), nameIReg(4,eregOfRM(modrm)));
6199
                           nameMMXReg(gregOfRM(modrm)),
6200
                           nameIReg(4,eregOfRM(modrm)));
6201
         } else {
6862
         } else {
6202
            Int tmpa;
6863
            Int tmpa;
6203
            pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
6864
            pair = disAMode ( cb, sorb, eip, dis_buf );
6204
            tmpa = LOW24(pair);
6865
            tmpa = LOW24(pair);
6205
            eip += HI8(pair);
6866
            eip += HI8(pair);
6206
            uInstr2(cb, MMX2_MemWr, 4, 
6867
            uInstr2(cb, MMX2_MemWr, 4, 
6207
                        Lit16, 
6868
                        Lit16, 
6208
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6869
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6209
                        TempReg, tmpa);
6870
                        TempReg, tmpa);
6210
            if (dis)
6871
            DIP("movd %s, %s\n", nameMMXReg(gregOfRM(modrm)), dis_buf);
6211
               VG_(printf)("movd %s, %s\n", 
6212
                           nameMMXReg(gregOfRM(modrm)),
6213
                           dis_buf);
6214
         }
6872
         }
6215
         break;
6873
         break;
6216
6874
Lines 6225-6247 Link Here
6225
                        Lit16, 
6883
                        Lit16, 
6226
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6884
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6227
                        TempReg, t1 );
6885
                        TempReg, t1 );
6228
            if (dis)
6886
            DIP("movd %s, %s\n", 
6229
               VG_(printf)("movd %s, %s\n", 
6887
                nameIReg(4,eregOfRM(modrm)), nameMMXReg(gregOfRM(modrm)));
6230
                           nameIReg(4,eregOfRM(modrm)),
6231
                           nameMMXReg(gregOfRM(modrm)));
6232
         } else {
6888
         } else {
6233
            Int tmpa;
6889
            Int tmpa;
6234
            pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
6890
            pair = disAMode ( cb, sorb, eip, dis_buf );
6235
            tmpa = LOW24(pair);
6891
            tmpa = LOW24(pair);
6236
            eip += HI8(pair);
6892
            eip += HI8(pair);
6237
            uInstr2(cb, MMX2_MemRd, 4, 
6893
            uInstr2(cb, MMX2_MemRd, 4, 
6238
                        Lit16, 
6894
                        Lit16, 
6239
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6895
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6240
                        TempReg, tmpa);
6896
                        TempReg, tmpa);
6241
            if (dis)
6897
            DIP("movd %s, %s\n", dis_buf, nameMMXReg(gregOfRM(modrm)));
6242
               VG_(printf)("movd %s, %s\n", 
6243
                           dis_buf,
6244
                           nameMMXReg(gregOfRM(modrm)));
6245
         }
6898
         }
6246
         break;
6899
         break;
6247
6900
Lines 6253-6275 Link Here
6253
            uInstr1(cb, MMX2, 0, 
6906
            uInstr1(cb, MMX2, 0, 
6254
                        Lit16, 
6907
                        Lit16, 
6255
                        (((UShort)(opc)) << 8) | ((UShort)modrm) );
6908
                        (((UShort)(opc)) << 8) | ((UShort)modrm) );
6256
            if (dis)
6909
            DIP("movq %s, %s\n", 
6257
               VG_(printf)("movq %s, %s\n", 
6910
                nameMMXReg(eregOfRM(modrm)), nameMMXReg(gregOfRM(modrm)));
6258
                           nameMMXReg(eregOfRM(modrm)),
6259
                           nameMMXReg(gregOfRM(modrm)));
6260
         } else {
6911
         } else {
6261
            Int tmpa;
6912
            Int tmpa;
6262
            pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
6913
            pair = disAMode ( cb, sorb, eip, dis_buf );
6263
            tmpa = LOW24(pair);
6914
            tmpa = LOW24(pair);
6264
            eip += HI8(pair);
6915
            eip += HI8(pair);
6265
            uInstr2(cb, MMX2_MemRd, 8, 
6916
            uInstr2(cb, MMX2_MemRd, 8, 
6266
                        Lit16, 
6917
                        Lit16, 
6267
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6918
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6268
                        TempReg, tmpa);
6919
                        TempReg, tmpa);
6269
            if (dis)
6920
            DIP("movq %s, %s\n", 
6270
               VG_(printf)("movq %s, %s\n", 
6921
                dis_buf, nameMMXReg(gregOfRM(modrm)));
6271
                           dis_buf,
6272
                           nameMMXReg(gregOfRM(modrm)));
6273
         }
6922
         }
6274
         break;
6923
         break;
6275
6924
Lines 6278-6297 Link Here
6278
         vg_assert(sz == 4);
6927
         vg_assert(sz == 4);
6279
         modrm = getUChar(eip);
6928
         modrm = getUChar(eip);
6280
         if (epartIsReg(modrm)) {
6929
         if (epartIsReg(modrm)) {
6281
            goto decode_failure;
6930
            eip++;
6931
            uInstr1(cb, MMX2, 0, 
6932
                        Lit16, 
6933
                        (((UShort)(opc)) << 8) | ((UShort)modrm) );
6934
            DIP("movq %s, %s\n", 
6935
                nameMMXReg(gregOfRM(modrm)), nameMMXReg(eregOfRM(modrm)));
6282
         } else {
6936
         } else {
6283
            Int tmpa;
6937
            Int tmpa;
6284
            pair = disAMode ( cb, sorb, eip, dis?dis_buf:NULL );
6938
            pair = disAMode ( cb, sorb, eip, dis_buf );
6285
            tmpa = LOW24(pair);
6939
            tmpa = LOW24(pair);
6286
            eip += HI8(pair);
6940
            eip += HI8(pair);
6287
            uInstr2(cb, MMX2_MemWr, 8, 
6941
            uInstr2(cb, MMX2_MemWr, 8, 
6288
                        Lit16, 
6942
                        Lit16, 
6289
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6943
                        (((UShort)(opc)) << 8) | ((UShort)modrm),
6290
                        TempReg, tmpa);
6944
                        TempReg, tmpa);
6291
            if (dis)
6945
            DIP("mov(nt)q %s, %s\n", 
6292
               VG_(printf)("mov(nt)q %s, %s\n", 
6946
                nameMMXReg(gregOfRM(modrm)), dis_buf);
6293
                           nameMMXReg(gregOfRM(modrm)),
6294
                           dis_buf);
6295
         }
6947
         }
6296
         break;
6948
         break;
6297
6949
Lines 6301-6306 Link Here
6301
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "padd", True );
6953
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "padd", True );
6302
         break;
6954
         break;
6303
6955
6956
      case 0xD4: 
6957
         /* PADDQ (src)mmxreg-or-mem, (dst)mmxreg */
6958
         vg_assert(sz == 4);
6959
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "paddq", False );
6960
         break;
6961
6304
      case 0xEC: case 0xED:
6962
      case 0xEC: case 0xED:
6305
         /* PADDSgg (src)mmxreg-or-mem, (dst)mmxreg */
6963
         /* PADDSgg (src)mmxreg-or-mem, (dst)mmxreg */
6306
         vg_assert(sz == 4);
6964
         vg_assert(sz == 4);
Lines 6313-6319 Link Here
6313
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "paddus", True );
6971
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "paddus", True );
6314
         break;
6972
         break;
6315
6973
6316
      case 0xF8: case 0xF9: case 0xFA:
6974
      case 0xF8: case 0xF9: case 0xFA: case 0xFB:
6317
         /* PSUBgg (src)mmxreg-or-mem, (dst)mmxreg */
6975
         /* PSUBgg (src)mmxreg-or-mem, (dst)mmxreg */
6318
         vg_assert(sz == 4);
6976
         vg_assert(sz == 4);
6319
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "psub", True );
6977
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "psub", True );
Lines 6331-6336 Link Here
6331
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "psubus", True );
6989
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "psubus", True );
6332
         break;
6990
         break;
6333
6991
6992
      case 0xE4: /* PMULHUW (src)mmxreg-or-mem, (dst)mmxreg */
6993
         vg_assert(sz == 4);
6994
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pmulhuw", False );
6995
         break;
6996
6334
      case 0xE5: /* PMULHW (src)mmxreg-or-mem, (dst)mmxreg */
6997
      case 0xE5: /* PMULHW (src)mmxreg-or-mem, (dst)mmxreg */
6335
         vg_assert(sz == 4);
6998
         vg_assert(sz == 4);
6336
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pmulhw", False );
6999
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pmulhw", False );
Lines 6341-6346 Link Here
6341
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pmullw", False );
7004
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pmullw", False );
6342
         break;
7005
         break;
6343
7006
7007
      case 0xF4: /* PMULUDQ (src)mmxreg-or-mem, (dst)mmxreg */
7008
         vg_assert(sz == 4);
7009
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pmuludq", False );
7010
         break;
7011
6344
      case 0xF5: /* PMADDWD (src)mmxreg-or-mem, (dst)mmxreg */
7012
      case 0xF5: /* PMADDWD (src)mmxreg-or-mem, (dst)mmxreg */
6345
         vg_assert(sz == 4);
7013
         vg_assert(sz == 4);
6346
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pmaddwd", False );
7014
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pmaddwd", False );
Lines 6423-6428 Link Here
6423
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "psra", True );
7091
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "psra", True );
6424
         break;
7092
         break;
6425
7093
7094
      case 0xDA:
7095
         /* PMINUB (src)mmxreg-or-mem, (dst)mmxreg */
7096
         vg_assert(sz == 4);
7097
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pminub", False );
7098
         break;
7099
7100
      case 0xDE:
7101
         /* PMAXUB (src)mmxreg-or-mem, (dst)mmxreg */
7102
         vg_assert(sz == 4);
7103
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pmaxub", False );
7104
         break;
7105
7106
      case 0xEA:
7107
         /* PMINSW (src)mmxreg-or-mem, (dst)mmxreg */
7108
         vg_assert(sz == 4);
7109
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pminsw", False );
7110
         break;
7111
7112
      case 0xEE:
7113
         /* PMAXSW (src)mmxreg-or-mem, (dst)mmxreg */
7114
         vg_assert(sz == 4);
7115
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pmaxsw", False );
7116
         break;
7117
7118
      case 0xE0:
7119
         /* PAVGB (src)mmxreg-or-mem, (dst)mmxreg */
7120
         vg_assert(sz == 4);
7121
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pavgb", False );
7122
         break;
7123
7124
      case 0xE3:
7125
         /* PAVGW (src)mmxreg-or-mem, (dst)mmxreg */
7126
         vg_assert(sz == 4);
7127
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "pavgw", False );
7128
         break;
7129
7130
      case 0xF6:
7131
         /* PSADBW (src)mmxreg-or-mem, (dst)mmxreg */
7132
         vg_assert(sz == 4);
7133
         eip = dis_MMXop_regmem_to_reg ( cb, sorb, eip, opc, "psadbw", False );
7134
         break;
7135
7136
      case 0xD7:
7137
         /* PMOVMSKB (src)mmxreg, (dst)ireg */
7138
         vg_assert(sz == 4);
7139
         modrm = getUChar(eip);
7140
         vg_assert(epartIsReg(modrm));
7141
         t1 = newTemp(cb);
7142
         uInstr3(cb, SSE2g_RegWr, 4,
7143
                     Lit16, (((UShort)(0x0F)) << 8) | (UShort)(opc),
7144
                     Lit16, (UShort)modrm,
7145
                     TempReg, t1 );
7146
         uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
7147
         DIP("pmovmskb %s, %s\n", 
7148
             nameMMXReg(eregOfRM(modrm)), nameIReg(4,gregOfRM(modrm)));
7149
         eip++;         
7150
         break;
7151
7152
      case 0xC5:
7153
         /* PEXTRW (src)mmxreg, (dst)ireg */
7154
         vg_assert(sz == 4);
7155
         t1 = newTemp(cb);
7156
         modrm = getUChar(eip); eip++;
7157
         abyte = getUChar(eip); eip++;
7158
         vg_assert(epartIsReg(modrm));
7159
         uInstr3(cb, SSE2g1_RegWr, 4,
7160
                     Lit16, (((UShort)(0x0F)) << 8) | (UShort)(opc),
7161
                     Lit16, (UShort)modrm,
7162
                     TempReg, t1 );
7163
         uLiteral(cb, abyte);
7164
         uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, gregOfRM(modrm));
7165
         DIP("pextrw %s, %d, %s\n",
7166
             nameMMXReg(eregOfRM(modrm)), (Int)abyte, 
7167
             nameIReg(4, gregOfRM(modrm)));
7168
         break;
7169
7170
      case 0xC4:
7171
         /* PINSRW (src)ireg, (dst)mmxreg */
7172
         vg_assert(sz == 4);
7173
         t1 = newTemp(cb);
7174
         modrm = getUChar(eip); eip++;
7175
         abyte = getUChar(eip); eip++;
7176
         vg_assert(epartIsReg(modrm));
7177
         uInstr2(cb, GET, 2, ArchReg, eregOfRM(modrm), TempReg, t1);
7178
         uInstr3(cb, SSE2e1_RegRd, 2,
7179
                     Lit16, (((UShort)(0x0F)) << 8) | (UShort)(opc),
7180
                     Lit16, (UShort)modrm,
7181
                     TempReg, t1 );
7182
         uLiteral(cb, abyte);
7183
         DIP("pinsrw %s, %d, %s\n", nameIReg(2, eregOfRM(modrm)),
7184
                        (Int)abyte, nameMMXReg(gregOfRM(modrm)));
7185
         break;
7186
6426
      case 0xA1: /* POP %FS */
7187
      case 0xA1: /* POP %FS */
6427
         dis_pop_segreg( cb, R_FS, sz ); break;
7188
         dis_pop_segreg( cb, R_FS, sz ); break;
6428
      case 0xA9: /* POP %GS */
7189
      case 0xA9: /* POP %GS */
Lines 6464-6472 Link Here
6464
7225
6465
   /* just because everything else insists the last instruction of
7226
   /* just because everything else insists the last instruction of
6466
      a BB is a jmp */
7227
      a BB is a jmp */
6467
   uInstr1(cb, JMP,     0, Literal, 0);
7228
   jmp_lit(cb, eip);
6468
   uCond(cb, CondAlways);
6469
   uLiteral(cb, eip);
6470
   *isEnd = True;
7229
   *isEnd = True;
6471
   break;
7230
   break;
6472
   return eip;
7231
   return eip;
Lines 6475-6485 Link Here
6475
7234
6476
  decode_success:
7235
  decode_success:
6477
   /* All decode successes end up here. */
7236
   /* All decode successes end up here. */
6478
   if (dis)
7237
   DIP("\n");
6479
      VG_(printf)("\n");
6480
   for (; first_uinstr < cb->used; first_uinstr++) {
7238
   for (; first_uinstr < cb->used; first_uinstr++) {
6481
      Bool sane = VG_(saneUInstr)(True, True, &cb->instrs[first_uinstr]);
7239
      Bool sane = VG_(saneUInstr)(True, True, &cb->instrs[first_uinstr]);
6482
      if (dis) 
7240
      if (VG_(print_codegen)) 
6483
         VG_(pp_UInstr)(first_uinstr, &cb->instrs[first_uinstr]);
7241
         VG_(pp_UInstr)(first_uinstr, &cb->instrs[first_uinstr]);
6484
      else if (!sane)
7242
      else if (!sane)
6485
         VG_(up_UInstr)(-1, &cb->instrs[first_uinstr]);
7243
         VG_(up_UInstr)(-1, &cb->instrs[first_uinstr]);
Lines 6500-6513 Link Here
6500
   Bool block_sane;
7258
   Bool block_sane;
6501
   Int delta = 0;
7259
   Int delta = 0;
6502
7260
6503
   if (dis) VG_(printf)("Original x86 code to UCode:\n\n");
7261
   DIP("Original x86 code to UCode:\n\n");
6504
7262
6505
   /* After every x86 instruction do an INCEIP, except for the final one
7263
   /* After every x86 instruction do an INCEIP, except for the final one
6506
    * in the basic block.  For them we patch in the x86 instruction size 
7264
    * in the basic block.  For them we patch in the x86 instruction size 
6507
    * into the `extra4b' field of the basic-block-ending JMP. 
7265
    * into the `extra4b' field of the basic-block-ending JMP. 
6508
    *
7266
    *
6509
    * The INCEIPs and JMP.extra4b fields allows a skin to track x86
7267
    * The INCEIPs and JMP.extra4b fields allows a tool to track x86
6510
    * instruction sizes, important for some skins (eg. cache simulation).
7268
    * instruction sizes, important for some tools (eg. Cachegrind).
6511
    */
7269
    */
6512
   if (VG_(clo_single_step)) {
7270
   if (VG_(clo_single_step)) {
6513
      eip = disInstr ( cb, eip, &isEnd );
7271
      eip = disInstr ( cb, eip, &isEnd );
Lines 6516-6528 Link Here
6516
       * already end with a JMP instr. We also need to check for no UCode,
7274
       * already end with a JMP instr. We also need to check for no UCode,
6517
       * which occurs if the x86 instr was a nop */
7275
       * which occurs if the x86 instr was a nop */
6518
      if (cb->used == 0 || LAST_UINSTR(cb).opcode != JMP) {
7276
      if (cb->used == 0 || LAST_UINSTR(cb).opcode != JMP) {
6519
         uInstr1(cb, JMP, 0, Literal, 0);
7277
         jmp_lit(cb, eip);
6520
         uLiteral(cb, eip);
6521
         uCond(cb, CondAlways);
6522
         /* Print added JMP */
7278
         /* Print added JMP */
6523
         if (dis) VG_(pp_UInstr)(cb->used-1, &cb->instrs[cb->used-1]);
7279
         if (VG_(print_codegen)) 
7280
            VG_(pp_UInstr)(cb->used-1, &cb->instrs[cb->used-1]);
6524
      }
7281
      }
6525
      if (dis) VG_(printf)("\n");
7282
      DIP("\n");
6526
      delta = eip - eip0;
7283
      delta = eip - eip0;
6527
7284
6528
   } else {
7285
   } else {
Lines 6536-6555 Link Here
6536
         if (eip - eip0 > 2000 && !isEnd) {
7293
         if (eip - eip0 > 2000 && !isEnd) {
6537
            if (VG_(clo_verbosity) > 2)
7294
            if (VG_(clo_verbosity) > 2)
6538
               VG_(message)(Vg_DebugMsg,
7295
               VG_(message)(Vg_DebugMsg,
6539
                  "Warning: splitting giant basic block into pieces");
7296
			    "Warning: splitting giant basic block into pieces at %p %(y",
6540
            uInstr1(cb, JMP, 0, Literal, 0);
7297
			    eip, eip);
6541
            uLiteral(cb, eip);
7298
            jmp_lit(cb, eip);
6542
            uCond(cb, CondAlways);
6543
            /* Print added JMP */
7299
            /* Print added JMP */
6544
            if (dis) VG_(pp_UInstr)(cb->used-1, &cb->instrs[cb->used-1]);
7300
            if (VG_(print_codegen))
7301
               VG_(pp_UInstr)(cb->used-1, &cb->instrs[cb->used-1]);
6545
            isEnd = True;
7302
            isEnd = True;
6546
7303
6547
         } else if (!isEnd) {
7304
         } else if (!isEnd) {
6548
            uInstr1(cb, INCEIP, 0, Lit16, delta);
7305
            uInstr1(cb, INCEIP, 0, Lit16, delta);
6549
            /* Print added INCEIP */
7306
            /* Print added INCEIP */
6550
            if (dis) VG_(pp_UInstr)(cb->used-1, &cb->instrs[cb->used-1]);
7307
            if (VG_(print_codegen)) 
7308
               VG_(pp_UInstr)(cb->used-1, &cb->instrs[cb->used-1]);
6551
         }
7309
         }
6552
         if (dis) VG_(printf)("\n");
7310
         DIP("\n");
6553
      }
7311
      }
6554
   }
7312
   }
6555
7313
Lines 6565-6571 Link Here
6565
   return eip - eip0;
7323
   return eip - eip0;
6566
}
7324
}
6567
7325
6568
#undef dis
7326
#undef DIP
7327
#undef DIS
6569
7328
6570
/*--------------------------------------------------------------------*/
7329
/*--------------------------------------------------------------------*/
6571
/*--- end                                            vg_to_ucode.c ---*/
7330
/*--- end                                            vg_to_ucode.c ---*/
(-)valgrind-2.1.0/coregrind/vg_translate.c (-71 / +77 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 414-420 Link Here
414
#  define SZ42 (u->size == 4 || u->size == 2)
414
#  define SZ42 (u->size == 4 || u->size == 2)
415
#  define SZ48 (u->size == 4 || u->size == 8)
415
#  define SZ48 (u->size == 4 || u->size == 8)
416
#  define SZ416 (u->size == 4 || u->size == 16)
416
#  define SZ416 (u->size == 4 || u->size == 16)
417
#  define SZsse (u->size == 4 || u->size == 8 || u->size == 16)
417
#  define SZ816 (u->size == 8 || u->size == 16)
418
#  define SZsse2 (u->size == 4 || u->size == 8 || u->size == 16 || u->size == 512)
419
#  define SZsse3 (u->size == 4 || u->size == 8 || u->size == 16)
418
#  define SZi  (u->size == 4 || u->size == 2 || u->size == 1)
420
#  define SZi  (u->size == 4 || u->size == 2 || u->size == 1)
419
#  define SZf  (  u->size ==  4 || u->size ==  8 || u->size ==   2     \
421
#  define SZf  (  u->size ==  4 || u->size ==  8 || u->size ==   2     \
420
               || u->size == 10 || u->size == 28 || u->size == 108)
422
               || u->size == 10 || u->size == 28 || u->size == 108)
Lines 563-584 Link Here
563
   case MMX2_ERegWr: return LIT0 && SZ4  && CC0 &&  Ls1 && TR2 &&  N3 && XOTHER;
565
   case MMX2_ERegWr: return LIT0 && SZ4  && CC0 &&  Ls1 && TR2 &&  N3 && XOTHER;
564
566
565
   /* Fields checked:        lit32   size  flags_r/w tag1   tag2   tag3    (rest) */
567
   /* Fields checked:        lit32   size  flags_r/w tag1   tag2   tag3    (rest) */
566
   case SSE2a_MemWr:  return LIT0 && SZ416 && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
568
   case SSE2a_MemWr:  return LIT0 && SZsse2 && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
567
   case SSE2a_MemRd:  return LIT0 && SZ416 && CCa  && Ls1 && Ls2 && TR3 && XOTHER;
569
   case SSE2a_MemRd:  return LIT0 && SZsse2 && CCa  && Ls1 && Ls2 && TR3 && XOTHER;
568
   case SSE2a1_MemRd: return LIT0 && SZ416 && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
570
   case SSE2a1_MemRd: return LIT0 && SZsse3 && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
569
   case SSE3a_MemWr:  return LIT0 && SZsse && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
571
   case SSE2g_RegWr:  return LIT0 && SZ4    && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
570
   case SSE3a_MemRd:  return LIT0 && SZsse && CCa  && Ls1 && Ls2 && TR3 && XOTHER;
572
   case SSE2g1_RegWr: return LIT8 && SZ4    && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
571
   case SSE3e_RegRd:  return LIT0 && SZ4   && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
573
   case SSE2e1_RegRd: return LIT8 && SZ2    && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
572
   case SSE3e_RegWr:  return LIT0 && SZ4   && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
574
   case SSE3a_MemWr:  return LIT0 && SZsse3 && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
573
   case SSE3a1_MemRd: return LIT8 && SZ16  && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
575
   case SSE3a_MemRd:  return LIT0 && SZsse3 && CCa  && Ls1 && Ls2 && TR3 && XOTHER;
574
   case SSE3g_RegWr:  return LIT0 && SZ4   && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
576
   case SSE3e_RegRd:  return LIT0 && SZ4    && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
575
   case SSE3g1_RegWr: return LIT8 && SZ4   && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
577
   case SSE3e_RegWr:  return LIT0 && SZ4    && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
576
   case SSE3e1_RegRd: return LIT8 && SZ2   && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
578
   case SSE3a1_MemRd: return LIT8 && SZ816  && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
577
   case SSE3:         return LIT0 && SZ0   && CCa  && Ls1 && Ls2 && N3  && XOTHER;
579
   case SSE3g_RegWr:  return LIT0 && SZ4    && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
578
   case SSE4:         return LIT0 && SZ0   && CCa  && Ls1 && Ls2 && N3  && XOTHER;
580
   case SSE3g1_RegWr: return LIT8 && SZ4    && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
579
   case SSE5:         return LIT0 && SZ0   && CC0  && Ls1 && Ls2 && Ls3 && XOTHER;
581
   case SSE3e1_RegRd: return LIT8 && SZ2    && CC0  && Ls1 && Ls2 && TR3 && XOTHER;
582
   case SSE3:         return LIT0 && SZ0    && CCa  && Ls1 && Ls2 && N3  && XOTHER;
583
   case SSE4:         return LIT0 && SZ0    && CCa  && Ls1 && Ls2 && N3  && XOTHER;
584
   case SSE5:         return LIT0 && SZ0    && CC0  && Ls1 && Ls2 && Ls3 && XOTHER;
580
   case SSE3ag_MemRd_RegWr:
585
   case SSE3ag_MemRd_RegWr:
581
                      return         SZ48  && CC0  && TR1 && TR2 && N3  && XOTHER;
586
                      return         SZ48   && CC0  && TR1 && TR2 && N3  && XOTHER;
582
   default: 
587
   default: 
583
      if (VG_(needs).extended_UCode)
588
      if (VG_(needs).extended_UCode)
584
         return SK_(sane_XUInstr)(beforeRA, beforeLiveness, u);
589
         return SK_(sane_XUInstr)(beforeRA, beforeLiveness, u);
Lines 602-608 Link Here
602
#  undef SZ42
607
#  undef SZ42
603
#  undef SZ48
608
#  undef SZ48
604
#  undef SZ416
609
#  undef SZ416
605
#  undef SZsse
610
#  undef SZsse2
611
#  undef SZsse3
606
#  undef SZi
612
#  undef SZi
607
#  undef SZf
613
#  undef SZf
608
#  undef SZ4m
614
#  undef SZ4m
Lines 895-901 Link Here
895
      case MMX2_ERegWr: return "MMX2_eRWr" ;
901
      case MMX2_ERegWr: return "MMX2_eRWr" ;
896
      case SSE2a_MemWr: return "SSE2a_MWr";
902
      case SSE2a_MemWr: return "SSE2a_MWr";
897
      case SSE2a_MemRd: return "SSE2a_MRd";
903
      case SSE2a_MemRd: return "SSE2a_MRd";
904
      case SSE2g_RegWr: return "SSE2g_RWr";
898
      case SSE2a1_MemRd: return "SSE2a1_MRd";
905
      case SSE2a1_MemRd: return "SSE2a1_MRd";
906
      case SSE2g1_RegWr: return "SSE2g1_RWr";
907
      case SSE2e1_RegRd: return "SSE2e1_RRd";
899
      case SSE3e_RegRd: return "SSE3e_RRd";
908
      case SSE3e_RegRd: return "SSE3e_RRd";
900
      case SSE3e_RegWr: return "SSE3e_RWr";
909
      case SSE3e_RegWr: return "SSE3e_RWr";
901
      case SSE3g_RegWr: return "SSE3g_RWr";
910
      case SSE3g_RegWr: return "SSE3g_RWr";
Lines 1060-1065 Link Here
1060
1069
1061
      case SSE2a_MemWr:
1070
      case SSE2a_MemWr:
1062
      case SSE2a_MemRd:
1071
      case SSE2a_MemRd:
1072
      case SSE2g_RegWr:
1073
      case SSE2g1_RegWr:
1074
      case SSE2e1_RegRd:
1063
         VG_(printf)("0x%x:0x%x:0x%x",
1075
         VG_(printf)("0x%x:0x%x:0x%x",
1064
                     (u->val1 >> 8) & 0xFF, u->val1 & 0xFF, u->val2 & 0xFF );
1076
                     (u->val1 >> 8) & 0xFF, u->val1 & 0xFF, u->val2 & 0xFF );
1065
         VG_(pp_UOperand)(u, 3, 4, True);
1077
         VG_(pp_UOperand)(u, 3, 4, True);
Lines 1133-1138 Link Here
1133
            case JmpRet:       VG_(printf)("-r"); break;
1145
            case JmpRet:       VG_(printf)("-r"); break;
1134
            case JmpSyscall:   VG_(printf)("-sys"); break;
1146
            case JmpSyscall:   VG_(printf)("-sys"); break;
1135
            case JmpClientReq: VG_(printf)("-cli"); break;
1147
            case JmpClientReq: VG_(printf)("-cli"); break;
1148
            case JmpYield:     VG_(printf)("-yld"); break;
1136
            default: break;
1149
            default: break;
1137
         }
1150
         }
1138
         VG_(pp_UOperand)(u, 1, u->size, False);
1151
         VG_(pp_UOperand)(u, 1, u->size, False);
Lines 1267-1272 Link Here
1267
1280
1268
      case SSE3a1_MemRd:
1281
      case SSE3a1_MemRd:
1269
      case SSE2a1_MemRd:
1282
      case SSE2a1_MemRd:
1283
      case SSE2e1_RegRd:
1270
      case SSE3e_RegRd:
1284
      case SSE3e_RegRd:
1271
      case SSE3a_MemWr:
1285
      case SSE3a_MemWr:
1272
      case SSE3a_MemRd:
1286
      case SSE3a_MemRd:
Lines 1274-1279 Link Here
1274
      case SSE3e1_RegRd:
1288
      case SSE3e1_RegRd:
1275
      case SSE2a_MemRd: RD(3); break;
1289
      case SSE2a_MemRd: RD(3); break;
1276
1290
1291
      case SSE2g_RegWr:
1292
      case SSE2g1_RegWr:
1277
      case SSE3e_RegWr:
1293
      case SSE3e_RegWr:
1278
      case SSE3g1_RegWr:
1294
      case SSE3g1_RegWr:
1279
      case SSE3g_RegWr: WR(3); break;
1295
      case SSE3g_RegWr: WR(3); break;
Lines 1438-1443 Link Here
1438
      case MMX2_MemRd: case MMX2_MemWr:
1454
      case MMX2_MemRd: case MMX2_MemWr:
1439
      case MMX2_ERegRd: case MMX2_ERegWr:
1455
      case MMX2_ERegRd: case MMX2_ERegWr:
1440
      case SSE2a_MemWr: case SSE2a_MemRd: case SSE2a1_MemRd:
1456
      case SSE2a_MemWr: case SSE2a_MemRd: case SSE2a1_MemRd:
1457
      case SSE2g_RegWr: case SSE2g1_RegWr: case SSE2e1_RegRd:
1441
      case SSE3a_MemWr: case SSE3a_MemRd: case SSE3a1_MemRd:
1458
      case SSE3a_MemWr: case SSE3a_MemRd: case SSE3a1_MemRd:
1442
      case SSE3e_RegRd: case SSE3g_RegWr: case SSE3e_RegWr:
1459
      case SSE3e_RegRd: case SSE3g_RegWr: case SSE3e_RegWr:
1443
      case SSE3g1_RegWr: case SSE3e1_RegRd:
1460
      case SSE3g1_RegWr: case SSE3e1_RegRd:
Lines 1492-1519 Link Here
1492
   Int*    last_live_before;
1509
   Int*    last_live_before;
1493
   FlagSet future_dead_flags;
1510
   FlagSet future_dead_flags;
1494
1511
1495
#  if 0
1496
   /* DEBUGGING HOOK */
1497
   {
1498
   static int n_done=0;
1499
   if (VG_(clo_stop_after) > 1000000000) {
1500
      if (n_done > (VG_(clo_stop_after) - 1000000000)) {
1501
         dis=False;
1502
         VG_(clo_trace_codegen)  = 0;
1503
         return;
1504
       }
1505
       if (n_done == (VG_(clo_stop_after) - 1000000000)) {
1506
         VG_(printf)("\n");
1507
         VG_(pp_UCodeBlock) ( cb, "Incoming:" );
1508
         dis = True;
1509
         VG_(clo_trace_codegen)  = 31;
1510
       }
1511
       n_done++;
1512
     }
1513
   }
1514
   /* end DEBUGGING HOOK */
1515
#  endif /* 0 */
1516
1517
   if (dis) 
1512
   if (dis) 
1518
      VG_(printf) ("Improvements:\n");
1513
      VG_(printf) ("Improvements:\n");
1519
1514
Lines 1842-1863 Link Here
1842
1837
1843
      } else if (PUT == u->opcode && R_ESP == u->val2 && 4 == u->size) {
1838
      } else if (PUT == u->opcode && R_ESP == u->val2 && 4 == u->size) {
1844
1839
1845
#           define DO_GENERIC                                                 \
1840
#           define DO_GENERIC					\
1846
               if (VG_(track_events).new_mem_stack ||                         \
1841
               if (VG_(defined_new_mem_stack)() ||		\
1847
                   VG_(track_events).die_mem_stack) {                         \
1842
                   VG_(defined_die_mem_stack)()) {		\
1848
                  uInstr1(cb, CCALL, 0, TempReg, u->val1);                    \
1843
                  uInstr1(cb, CCALL, 0, TempReg, u->val1);	\
1849
                  uCCall(cb, (Addr) VG_(unknown_esp_update),                  \
1844
                  uCCall(cb, (Addr) VG_(unknown_esp_update),	\
1850
                         1, 1, False);                                        \
1845
                         1, 1, False);				\
1851
               } 
1846
               } 
1852
1847
1853
#           define DO(kind, size)                                             \
1848
#           define DO(kind, size)								\
1854
               if (VG_(track_events).kind##_mem_stack_##size) {               \
1849
               if (VG_(defined_##kind##_mem_stack_##size)()) {					\
1855
                  uInstr1(cb, CCALL, 0, TempReg, u->val1);                    \
1850
                  uInstr1(cb, CCALL, 0, TempReg, u->val1);					\
1856
                  uCCall(cb, (Addr) VG_(track_events).kind##_mem_stack_##size,\
1851
                  uCCall(cb, (Addr) VG_(tool_interface).track_##kind##_mem_stack_##size,	\
1857
                         1, 1, False);                                        \
1852
                         1, 1, False);								\
1858
                                                                              \
1853
												\
1859
               } else                                                         \
1854
               } else										\
1860
                  DO_GENERIC                                                  \
1855
                  DO_GENERIC									\
1861
               break
1856
               break
1862
1857
1863
         if (u->val1 == t_ESP) {
1858
         if (u->val1 == t_ESP) {
Lines 2354-2365 Link Here
2354
                      /*OUT*/ UInt* trans_size,
2349
                      /*OUT*/ UInt* trans_size,
2355
		      /*OUT*/ UShort jumps[VG_MAX_JUMPS])
2350
		      /*OUT*/ UShort jumps[VG_MAX_JUMPS])
2356
{
2351
{
2357
   Int         n_disassembled_bytes, final_code_size, i;
2352
   Int         n_disassembled_bytes, final_code_size;
2358
   Bool        debugging_translation;
2353
   Bool        debugging_translation;
2359
   UChar*      final_code;
2354
   UChar*      final_code;
2360
   UCodeBlock* cb;
2355
   UCodeBlock* cb;
2361
   Bool        notrace_until_done;
2356
   Bool        notrace_until_done;
2362
   UInt        notrace_until_limit = 0;
2357
   UInt        notrace_until_limit = 0;
2358
   Segment     *seg;
2359
   Addr		redir;
2363
2360
2364
   VGP_PUSHCC(VgpTranslate);
2361
   VGP_PUSHCC(VgpTranslate);
2365
   debugging_translation
2362
   debugging_translation
Lines 2367-2383 Link Here
2367
2364
2368
   /* Look in the code redirect table to see if we should
2365
   /* Look in the code redirect table to see if we should
2369
      translate an alternative address for orig_addr. */
2366
      translate an alternative address for orig_addr. */
2370
   for (i = 0; VG_(code_redirect_table)[i].entry_pt_orig != 0; i++) {
2367
   redir = VG_(code_redirect)(orig_addr);
2371
      if (orig_addr == VG_(code_redirect_table)[i].entry_pt_orig) {
2368
2372
         if (VG_(clo_verbosity) >= 2)
2369
   if (redir != orig_addr && VG_(clo_verbosity) >= 2)
2373
            VG_(message)(Vg_UserMsg, 
2370
      VG_(message)(Vg_UserMsg, 
2374
               "TRANSLATE: %p redirected to %p",
2371
		   "TRANSLATE: %p redirected to %p",
2375
               orig_addr, 
2372
		   orig_addr, 
2376
               VG_(code_redirect_table)[i].entry_pt_subst );
2373
		   redir );
2377
         orig_addr = VG_(code_redirect_table)[i].entry_pt_subst;
2374
   orig_addr = redir;
2378
         break;
2379
      }
2380
   }
2381
2375
2382
   /* If codegen tracing, don't start tracing until
2376
   /* If codegen tracing, don't start tracing until
2383
      notrace_until_limit blocks have gone by.  This avoids printing
2377
      notrace_until_limit blocks have gone by.  This avoids printing
Lines 2386-2407 Link Here
2386
      notrace_until_limit to be the number of translations to be made
2380
      notrace_until_limit to be the number of translations to be made
2387
      before --trace-codegen= style printing takes effect. */
2381
      before --trace-codegen= style printing takes effect. */
2388
   notrace_until_done
2382
   notrace_until_done
2389
      = VG_(overall_in_count) > notrace_until_limit;
2383
      = VG_(overall_in_count) >= notrace_until_limit;
2384
2385
   seg = VG_(find_segment)(orig_addr);
2390
2386
2391
   if (!debugging_translation)
2387
   if (!debugging_translation)
2392
      VG_TRACK( pre_mem_read, Vg_CoreTranslate, tid, "", orig_addr, 1 );
2388
      VG_TRACK( pre_mem_read, Vg_CoreTranslate, tid, "", orig_addr, 1 );
2393
2389
2394
   if (!VG_(is_addressable)(orig_addr, 1)) {
2390
   if (seg == NULL ||
2395
      /* Code address is bad - deliver a signal instead */
2391
       !VG_(seg_contains)(seg, orig_addr, 1) || 
2392
       (seg->prot & (VKI_PROT_READ|VKI_PROT_EXEC)) == 0) {
2396
      vki_ksiginfo_t info;
2393
      vki_ksiginfo_t info;
2397
2394
2395
      /* Code address is bad - deliver a signal instead */
2396
      vg_assert(!VG_(is_addressable)(orig_addr, 1));
2397
2398
      info.si_signo = VKI_SIGSEGV;
2398
      info.si_signo = VKI_SIGSEGV;
2399
      info.si_code = 1;		/* address not mapped to object */
2399
2400
      if (seg != NULL && VG_(seg_contains)(seg, orig_addr, 1)) {
2401
	 vg_assert((seg->prot & VKI_PROT_EXEC) == 0);
2402
	 info.si_code = 2;	/* invalid permissions for mapped object */
2403
      } else
2404
	 info.si_code = 1;	/* address not mapped to object */
2400
      info._sifields._sigfault._addr = (void*)orig_addr;
2405
      info._sifields._sigfault._addr = (void*)orig_addr;
2401
2406
2402
      VG_(deliver_signal)(tid, &info, False);
2407
      VG_(deliver_signal)(tid, &info, False);
2403
      return;
2408
      return;
2404
   }
2409
   } else
2410
      seg->flags |= SF_CODE;	/* contains cached code */
2405
2411
2406
   cb = VG_(alloc_UCodeBlock)();
2412
   cb = VG_(alloc_UCodeBlock)();
2407
   cb->orig_eip = orig_addr;
2413
   cb->orig_eip = orig_addr;
(-)valgrind-2.1.0/coregrind/vg_transtab.c (-1 / +15 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 378-385 Link Here
378
   }
378
   }
379
   for (s = 0; s < VG_TC_N_SECTORS; s++) {
379
   for (s = 0; s < VG_TC_N_SECTORS; s++) {
380
      if (vg_tc[s] == NULL) {
380
      if (vg_tc[s] == NULL) {
381
#if 1
381
         vg_tc[s] = VG_(get_memory_from_mmap) 
382
         vg_tc[s] = VG_(get_memory_from_mmap) 
382
                       ( vg_tc_sector_szB, "trans-cache(sector)" );
383
                       ( vg_tc_sector_szB, "trans-cache(sector)" );
384
#else
385
	 Char buf[20];
386
	 static Int count = 0;
387
	 Int fd;
388
	 
389
	 VG_(sprintf)(buf, ".transtab.%d", count++);
390
391
	 fd = VG_(open)(buf, VKI_O_RDWR|VKI_O_CREAT|VKI_O_TRUNC, 0700);
392
	 //VG_(unlink)(buf);
393
	 VG_(do_syscall)(__NR_ftruncate, fd, PGROUNDUP(vg_tc_sector_szB));
394
	 vg_tc[s] = VG_(mmap)(0, PGROUNDUP(vg_tc_sector_szB), VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC, VKI_MAP_SHARED, fd, 0);
395
	 VG_(close)(fd);
396
#endif
383
         vg_tc_used[s] = 0;
397
         vg_tc_used[s] = 0;
384
         VG_(sprintf)(msg, "after  allocation of sector %d "
398
         VG_(sprintf)(msg, "after  allocation of sector %d "
385
                           "(size %d)", 
399
                           "(size %d)", 
(-)valgrind-2.1.0/coregrind/vg_unistd.h (+26 lines)
Lines 1-3 Link Here
1
2
/*
3
   This file is part of Valgrind, an extensible x86 protected-mode
4
   emulator for monitoring program execution on x86-Unixes.
5
6
   Copyright (C) 2000-2004 Julian Seward 
7
      jseward@acm.org
8
9
   This program is free software; you can redistribute it and/or
10
   modify it under the terms of the GNU General Public License as
11
   published by the Free Software Foundation; either version 2 of the
12
   License, or (at your option) any later version.
13
14
   This program is distributed in the hope that it will be useful, but
15
   WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
   General Public License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program; if not, write to the Free Software
21
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
   02111-1307, USA.
23
24
   The GNU General Public License is contained in the file COPYING.
25
*/
26
1
#ifndef _VG_ASM_I386_UNISTD_H_
27
#ifndef _VG_ASM_I386_UNISTD_H_
2
#define _VG_ASM_I386_UNISTD_H_
28
#define _VG_ASM_I386_UNISTD_H_
3
/* Taken from Linux 2.6.0-test1 include/asm-i386/unistd.h */
29
/* Taken from Linux 2.6.0-test1 include/asm-i386/unistd.h */
(-)valgrind-2.1.0/coregrind/vg_unsafe.h (-2 / +1 lines)
Lines 9-15 Link Here
9
   This file is part of Valgrind, an extensible x86 protected-mode
9
   This file is part of Valgrind, an extensible x86 protected-mode
10
   emulator for monitoring program execution on x86-Unixes.
10
   emulator for monitoring program execution on x86-Unixes.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 93-99 Link Here
93
93
94
#include <sys/poll.h>
94
#include <sys/poll.h>
95
95
96
97
/*--------------------------------------------------------------------*/
96
/*--------------------------------------------------------------------*/
98
/*--- end                                              vg_unsafe.h ---*/
97
/*--- end                                              vg_unsafe.h ---*/
99
/*--------------------------------------------------------------------*/
98
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/vg_valgrinq_dummy.c (-43 lines)
Lines 1-43 Link Here
1
2
/*--------------------------------------------------------------------*/
3
/*--- Used to make a dummy valgrinq.so, which does nothing at all. ---*/
4
/*---                                          vg_valgrinq_dummy.c ---*/
5
/*--------------------------------------------------------------------*/
6
7
/*
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
10
11
   Copyright (C) 2000-2003 Julian Seward 
12
      jseward@acm.org
13
14
   This program is free software; you can redistribute it and/or
15
   modify it under the terms of the GNU General Public License as
16
   published by the Free Software Foundation; either version 2 of the
17
   License, or (at your option) any later version.
18
19
   This program is distributed in the hope that it will be useful, but
20
   WITHOUT ANY WARRANTY; without even the implied warranty of
21
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22
   General Public License for more details.
23
24
   You should have received a copy of the GNU General Public License
25
   along with this program; if not, write to the Free Software
26
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27
   02111-1307, USA.
28
29
   The GNU General Public License is contained in the file COPYING.
30
*/
31
32
/* For the rationale behind this file, look at
33
   VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH) in vg_main.c. */
34
35
/* Remember not to use a variable of this name in any program you want
36
   to debug :-) */
37
int dont_mess_with_the_RSCDS = 0;
38
39
/* If you are bored, perhaps have a look at http://www.rscds.org. */
40
41
/*--------------------------------------------------------------------*/
42
/*--- end                                      vg_valgrinq_dummy.c ---*/
43
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/coregrind/x86/.cvsignore (+3 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
3
stage2.lds
(-)valgrind-2.1.0/coregrind/x86/CVS/Entries (+7 lines)
Line 0 Link Here
1
/.cvsignore/1.2/Wed Dec 17 13:28:12 2003//
2
/Makefile.am/1.5/Thu Feb  5 14:27:36 2004//
3
/ume_archdefs.c/1.2/Sun Jan  4 03:46:11 2004//
4
/ume_archdefs.h/1.2/Sun Jan  4 03:46:11 2004//
5
/ume_entry.S/1.2/Sun Jan  4 03:46:11 2004//
6
/ume_go.c/1.3/Mon Jan 19 21:47:25 2004//
7
D
(-)valgrind-2.1.0/coregrind/x86/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/coregrind/x86
(-)valgrind-2.1.0/coregrind/x86/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/coregrind/x86/Makefile.am (+19 lines)
Line 0 Link Here
1
noinst_HEADERS = \
2
	ume_archdefs.h
3
4
EXTRA_DIST =		\
5
	ume_archdefs.c	\
6
	ume_archdefs.h	\
7
	ume_entry.S	\
8
	ume_go.c
9
10
BUILT_SOURCES = stage2.lds
11
CLEANFILES = stage2.lds
12
13
# Extract ld's default linker script and hack it to our needs
14
stage2.lds: Makefile
15
	$(CC) -Wl,--verbose -nostdlib 2>&1 | sed \
16
		-e '1,/^=====\+$$/d' \
17
		-e '/^=====\+$$/d' \
18
		-e 's/ENTRY(_start)/ENTRY(_ume_entry)/' \
19
		-e 's/0x08048000/kickstart_base/g' > $@ || rm -f $@
(-)valgrind-2.1.0/coregrind/x86/Makefile.in (+366 lines)
Line 0 Link Here
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
3
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
9
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
12
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
# PARTICULAR PURPOSE.
14
15
@SET_MAKE@
16
17
srcdir = @srcdir@
18
top_srcdir = @top_srcdir@
19
VPATH = @srcdir@
20
pkgdatadir = $(datadir)/@PACKAGE@
21
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
24
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
25
INSTALL = @INSTALL@
26
install_sh_DATA = $(install_sh) -c -m 644
27
install_sh_PROGRAM = $(install_sh) -c
28
install_sh_SCRIPT = $(install_sh) -c
29
INSTALL_HEADER = $(INSTALL_DATA)
30
transform = $(program_transform_name)
31
NORMAL_INSTALL = :
32
PRE_INSTALL = :
33
POST_INSTALL = :
34
NORMAL_UNINSTALL = :
35
PRE_UNINSTALL = :
36
POST_UNINSTALL = :
37
host_triplet = @host@
38
subdir = coregrind/x86
39
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
40
	$(srcdir)/Makefile.in
41
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
42
am__aclocal_m4_deps = $(top_srcdir)/configure.in
43
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
44
	$(ACLOCAL_M4)
45
mkinstalldirs = $(mkdir_p)
46
CONFIG_HEADER = $(top_builddir)/config.h
47
CONFIG_CLEAN_FILES =
48
SOURCES =
49
DIST_SOURCES =
50
HEADERS = $(noinst_HEADERS)
51
ETAGS = etags
52
CTAGS = ctags
53
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
54
ACLOCAL = @ACLOCAL@
55
AMDEP_FALSE = @AMDEP_FALSE@
56
AMDEP_TRUE = @AMDEP_TRUE@
57
AMTAR = @AMTAR@
58
AUTOCONF = @AUTOCONF@
59
AUTOHEADER = @AUTOHEADER@
60
AUTOMAKE = @AUTOMAKE@
61
AWK = @AWK@
62
CC = @CC@
63
CCAS = @CCAS@
64
CCASFLAGS = @CCASFLAGS@
65
CCDEPMODE = @CCDEPMODE@
66
CFLAGS = @CFLAGS@
67
CPP = @CPP@
68
CPPFLAGS = @CPPFLAGS@
69
CXX = @CXX@
70
CXXDEPMODE = @CXXDEPMODE@
71
CXXFLAGS = @CXXFLAGS@
72
CYGPATH_W = @CYGPATH_W@
73
DEFAULT_SUPP = @DEFAULT_SUPP@
74
DEFS = @DEFS@
75
DEPDIR = @DEPDIR@
76
ECHO_C = @ECHO_C@
77
ECHO_N = @ECHO_N@
78
ECHO_T = @ECHO_T@
79
EGREP = @EGREP@
80
EXEEXT = @EXEEXT@
81
GDB = @GDB@
82
INSTALL_DATA = @INSTALL_DATA@
83
INSTALL_PROGRAM = @INSTALL_PROGRAM@
84
INSTALL_SCRIPT = @INSTALL_SCRIPT@
85
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
86
LDFLAGS = @LDFLAGS@
87
LIBOBJS = @LIBOBJS@
88
LIBS = @LIBS@
89
LN_S = @LN_S@
90
LTLIBOBJS = @LTLIBOBJS@
91
MAINT = @MAINT@
92
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
93
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
94
MAKEINFO = @MAKEINFO@
95
OBJEXT = @OBJEXT@
96
PACKAGE = @PACKAGE@
97
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
98
PACKAGE_NAME = @PACKAGE_NAME@
99
PACKAGE_STRING = @PACKAGE_STRING@
100
PACKAGE_TARNAME = @PACKAGE_TARNAME@
101
PACKAGE_VERSION = @PACKAGE_VERSION@
102
PATH_SEPARATOR = @PATH_SEPARATOR@
103
PERL = @PERL@
104
PREFERRED_STACK_BOUNDARY = @PREFERRED_STACK_BOUNDARY@
105
RANLIB = @RANLIB@
106
SET_MAKE = @SET_MAKE@
107
SHELL = @SHELL@
108
STRIP = @STRIP@
109
VERSION = @VERSION@
110
VG_PLATFORM = @VG_PLATFORM@
111
ac_ct_CC = @ac_ct_CC@
112
ac_ct_CXX = @ac_ct_CXX@
113
ac_ct_RANLIB = @ac_ct_RANLIB@
114
ac_ct_STRIP = @ac_ct_STRIP@
115
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
116
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
117
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
118
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
119
am__include = @am__include@
120
am__leading_dot = @am__leading_dot@
121
am__quote = @am__quote@
122
bindir = @bindir@
123
build = @build@
124
build_alias = @build_alias@
125
build_cpu = @build_cpu@
126
build_os = @build_os@
127
build_vendor = @build_vendor@
128
datadir = @datadir@
129
exec_prefix = @exec_prefix@
130
host = @host@
131
host_alias = @host_alias@
132
host_cpu = @host_cpu@
133
host_os = @host_os@
134
host_vendor = @host_vendor@
135
includedir = @includedir@
136
infodir = @infodir@
137
install_sh = @install_sh@
138
libdir = @libdir@
139
libexecdir = @libexecdir@
140
localstatedir = @localstatedir@
141
mandir = @mandir@
142
mkdir_p = @mkdir_p@
143
oldincludedir = @oldincludedir@
144
prefix = @prefix@
145
program_transform_name = @program_transform_name@
146
sbindir = @sbindir@
147
sharedstatedir = @sharedstatedir@
148
sysconfdir = @sysconfdir@
149
target_alias = @target_alias@
150
noinst_HEADERS = \
151
	ume_archdefs.h
152
153
EXTRA_DIST = \
154
	ume_archdefs.c	\
155
	ume_archdefs.h	\
156
	ume_entry.S	\
157
	ume_go.c
158
159
BUILT_SOURCES = stage2.lds
160
CLEANFILES = stage2.lds
161
all: $(BUILT_SOURCES)
162
	$(MAKE) $(AM_MAKEFLAGS) all-am
163
164
.SUFFIXES:
165
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
166
	@for dep in $?; do \
167
	  case '$(am__configure_deps)' in \
168
	    *$$dep*) \
169
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
170
		&& exit 0; \
171
	      exit 1;; \
172
	  esac; \
173
	done; \
174
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  coregrind/x86/Makefile'; \
175
	cd $(top_srcdir) && \
176
	  $(AUTOMAKE) --gnu  coregrind/x86/Makefile
177
.PRECIOUS: Makefile
178
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
179
	@case '$?' in \
180
	  *config.status*) \
181
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
182
	  *) \
183
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
184
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
185
	esac;
186
187
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
188
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
189
190
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
191
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
192
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
193
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
194
uninstall-info-am:
195
196
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
197
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
198
	unique=`for i in $$list; do \
199
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
200
	  done | \
201
	  $(AWK) '    { files[$$0] = 1; } \
202
	       END { for (i in files) print i; }'`; \
203
	mkid -fID $$unique
204
tags: TAGS
205
206
TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
207
		$(TAGS_FILES) $(LISP)
208
	tags=; \
209
	here=`pwd`; \
210
	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
211
	unique=`for i in $$list; do \
212
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
213
	  done | \
214
	  $(AWK) '    { files[$$0] = 1; } \
215
	       END { for (i in files) print i; }'`; \
216
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
217
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
218
	     $$tags $$unique
219
ctags: CTAGS
220
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
221
		$(TAGS_FILES) $(LISP)
222
	tags=; \
223
	here=`pwd`; \
224
	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
225
	unique=`for i in $$list; do \
226
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
227
	  done | \
228
	  $(AWK) '    { files[$$0] = 1; } \
229
	       END { for (i in files) print i; }'`; \
230
	test -z "$(CTAGS_ARGS)$$tags$$unique" \
231
	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
232
	     $$tags $$unique
233
234
GTAGS:
235
	here=`$(am__cd) $(top_builddir) && pwd` \
236
	  && cd $(top_srcdir) \
237
	  && gtags -i $(GTAGS_ARGS) $$here
238
239
distclean-tags:
240
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
241
242
distdir: $(DISTFILES)
243
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
244
	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
245
	list='$(DISTFILES)'; for file in $$list; do \
246
	  case $$file in \
247
	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
248
	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
249
	  esac; \
250
	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
251
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
252
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
253
	    dir="/$$dir"; \
254
	    $(mkdir_p) "$(distdir)$$dir"; \
255
	  else \
256
	    dir=''; \
257
	  fi; \
258
	  if test -d $$d/$$file; then \
259
	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
260
	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
261
	    fi; \
262
	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
263
	  else \
264
	    test -f $(distdir)/$$file \
265
	    || cp -p $$d/$$file $(distdir)/$$file \
266
	    || exit 1; \
267
	  fi; \
268
	done
269
check-am: all-am
270
check: $(BUILT_SOURCES)
271
	$(MAKE) $(AM_MAKEFLAGS) check-am
272
all-am: Makefile $(HEADERS)
273
installdirs:
274
install: $(BUILT_SOURCES)
275
	$(MAKE) $(AM_MAKEFLAGS) install-am
276
install-exec: install-exec-am
277
install-data: install-data-am
278
uninstall: uninstall-am
279
280
install-am: all-am
281
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
282
283
installcheck: installcheck-am
284
install-strip:
285
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
286
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
287
	  `test -z '$(STRIP)' || \
288
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
289
mostlyclean-generic:
290
291
clean-generic:
292
	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
293
294
distclean-generic:
295
	-rm -f $(CONFIG_CLEAN_FILES)
296
297
maintainer-clean-generic:
298
	@echo "This command is intended for maintainers to use"
299
	@echo "it deletes files that may require special tools to rebuild."
300
	-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
301
clean: clean-am
302
303
clean-am: clean-generic mostlyclean-am
304
305
distclean: distclean-am
306
	-rm -f Makefile
307
distclean-am: clean-am distclean-generic distclean-tags
308
309
dvi: dvi-am
310
311
dvi-am:
312
313
html: html-am
314
315
info: info-am
316
317
info-am:
318
319
install-data-am:
320
321
install-exec-am:
322
323
install-info: install-info-am
324
325
install-man:
326
327
installcheck-am:
328
329
maintainer-clean: maintainer-clean-am
330
	-rm -f Makefile
331
maintainer-clean-am: distclean-am maintainer-clean-generic
332
333
mostlyclean: mostlyclean-am
334
335
mostlyclean-am: mostlyclean-generic
336
337
pdf: pdf-am
338
339
pdf-am:
340
341
ps: ps-am
342
343
ps-am:
344
345
uninstall-am: uninstall-info-am
346
347
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
348
	ctags distclean distclean-generic distclean-tags distdir dvi \
349
	dvi-am html html-am info info-am install install-am \
350
	install-data install-data-am install-exec install-exec-am \
351
	install-info install-info-am install-man install-strip \
352
	installcheck installcheck-am installdirs maintainer-clean \
353
	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
354
	pdf-am ps ps-am tags uninstall uninstall-am uninstall-info-am
355
356
357
# Extract ld's default linker script and hack it to our needs
358
stage2.lds: Makefile
359
	$(CC) -Wl,--verbose -nostdlib 2>&1 | sed \
360
		-e '1,/^=====\+$$/d' \
361
		-e '/^=====\+$$/d' \
362
		-e 's/ENTRY(_start)/ENTRY(_ume_entry)/' \
363
		-e 's/0x08048000/kickstart_base/g' > $@ || rm -f $@
364
# Tell versions [3.59,3.63) of GNU make to not export all variables.
365
# Otherwise a system limit (for SysV at least) may be exceeded.
366
.NOEXPORT:
(-)valgrind-2.1.0/coregrind/x86/ume_archdefs.c (+29 lines)
Line 0 Link Here
1
2
/*
3
   This file is part of Valgrind, an extensible x86 protected-mode
4
   emulator for monitoring program execution on x86-Unixes.
5
6
   Copyright (C) 2000-2004 Julian Seward 
7
      jseward@acm.org
8
9
   This program is free software; you can redistribute it and/or
10
   modify it under the terms of the GNU General Public License as
11
   published by the Free Software Foundation; either version 2 of the
12
   License, or (at your option) any later version.
13
14
   This program is distributed in the hope that it will be useful, but
15
   WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
   General Public License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program; if not, write to the Free Software
21
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
   02111-1307, USA.
23
24
   The GNU General Public License is contained in the file COPYING.
25
*/
26
27
#include "ume_archdefs.h"
28
29
const unsigned long CLIENT_START = 0;
(-)valgrind-2.1.0/coregrind/x86/ume_archdefs.h (+32 lines)
Line 0 Link Here
1
2
/*
3
   This file is part of Valgrind, an extensible x86 protected-mode
4
   emulator for monitoring program execution on x86-Unixes.
5
6
   Copyright (C) 2000-2004 Julian Seward 
7
      jseward@acm.org
8
9
   This program is free software; you can redistribute it and/or
10
   modify it under the terms of the GNU General Public License as
11
   published by the Free Software Foundation; either version 2 of the
12
   License, or (at your option) any later version.
13
14
   This program is distributed in the hope that it will be useful, but
15
   WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
   General Public License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program; if not, write to the Free Software
21
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
   02111-1307, USA.
23
24
   The GNU General Public License is contained in the file COPYING.
25
*/
26
27
#ifndef UME_ARCHDEFS_H
28
#define UME_ARCHDEFS_H
29
30
#define CLIENT_BASE	0x00000000ul			/* base address of client address space */
31
32
#endif /* UME_ARCHDEFS_H */
(-)valgrind-2.1.0/coregrind/x86/ume_entry.S (+38 lines)
Line 0 Link Here
1
2
/*
3
   This file is part of Valgrind, an extensible x86 protected-mode
4
   emulator for monitoring program execution on x86-Unixes.
5
6
   Copyright (C) 2000-2004 Julian Seward 
7
      jseward@acm.org
8
9
   This program is free software; you can redistribute it and/or
10
   modify it under the terms of the GNU General Public License as
11
   published by the Free Software Foundation; either version 2 of the
12
   License, or (at your option) any later version.
13
14
   This program is distributed in the hope that it will be useful, but
15
   WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
   General Public License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program; if not, write to the Free Software
21
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
   02111-1307, USA.
23
24
   The GNU General Public License is contained in the file COPYING.
25
*/
26
27
	.text
28
	.globl _ume_entry
29
30
	/* Record the very initial value of %esp before starting the
31
	   rest of the executable */
32
_ume_entry:
33
	movl	%esp, ume_exec_esp
34
	jmp	_start
35
36
	.data
37
	.globl ume_exec_esp
38
ume_exec_esp:	.long 0
(-)valgrind-2.1.0/coregrind/x86/ume_go.c (+51 lines)
Line 0 Link Here
1
2
/*
3
   This file is part of Valgrind, an extensible x86 protected-mode
4
   emulator for monitoring program execution on x86-Unixes.
5
6
   Copyright (C) 2000-2004 Julian Seward 
7
      jseward@acm.org
8
9
   This program is free software; you can redistribute it and/or
10
   modify it under the terms of the GNU General Public License as
11
   published by the Free Software Foundation; either version 2 of the
12
   License, or (at your option) any later version.
13
14
   This program is distributed in the hope that it will be useful, but
15
   WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
   General Public License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program; if not, write to the Free Software
21
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
   02111-1307, USA.
23
24
   The GNU General Public License is contained in the file COPYING.
25
*/
26
27
#include "ume_arch.h"
28
29
/* 
30
   Jump to a particular EIP with a particular ESP.  This is intended
31
   to simulate the initial CPU state when the kernel starts an program
32
   after exec; it therefore also clears all the other registers.
33
 */
34
void ume_go(addr_t eip, addr_t esp)
35
{
36
   asm volatile ("movl %1, %%esp;"	/* set esp */
37
		 "pushl %%eax;"		/* push esp */
38
		 "xorl	%%eax,%%eax;"	/* clear registers */
39
		 "xorl	%%ebx,%%ebx;"
40
		 "xorl	%%ecx,%%ecx;"
41
		 "xorl	%%edx,%%edx;"
42
		 "xorl	%%esi,%%esi;"
43
		 "xorl	%%edi,%%edi;"
44
		 "xorl	%%ebp,%%ebp;"
45
46
		 "ret"			/* return into entry */
47
		 : : "a" (eip), "r" (esp));
48
   /* we should never get here */
49
   for(;;)
50
	   asm volatile("ud2");
51
} 
(-)valgrind-2.1.0/default.supp (-451 lines)
Lines 1-451 Link Here
1
# This is a generated file, composed of the following suppression rules:
2
#
3
#       glibc-2.3.supp xfree-4.supp xfree-3.supp
4
#
5
6
7
##----------------------------------------------------------------------##
8
9
# Errors to suppress by default with glibc 2.3.x
10
11
# Format of this file is:
12
# {
13
#     name_of_suppression
14
#     tool_name:supp_kind
15
#     (optional extra info for some suppression types)
16
#     caller0 name, or /name/of/so/file.so
17
#     caller1 name, or ditto
18
#     (optionally: caller2 name)
19
#     (optionally: caller3 name)
20
#  }
21
#
22
# For Memcheck, the supp_kinds are:
23
#
24
#     Param Value1 Value2 Value4 Value8 Value16
25
#     Free Addr1 Addr2 Addr4 Addr8 Addr16
26
#     Cond (previously known as Value0)
27
#
28
# and the optional extra info is:
29
#     if Param: name of system call param
30
#     if Free: name of free-ing fn)
31
32
{
33
   __GI___stpcpy/*
34
   Memcheck:Cond
35
   fun:__GI___stpcpy
36
   fun:*
37
}
38
{
39
   strlen/__GI__dl_open/dlopen_doit
40
   Memcheck:Cond
41
   fun:strlen
42
   fun:__GI__dl_open
43
   fun:dlopen_doit
44
}
45
{
46
   strlen/_dl_signal_cerror/_dl_lookup_symbol_internal/do_dlsym
47
   Memcheck:Cond
48
   fun:_dl_signal_cerror
49
   fun:_dl_lookup_symbol_internal
50
   fun:do_dlsym
51
}
52
{
53
   strlen/*dl_map_object*(Cond)
54
   Memcheck:Cond
55
   fun:strlen
56
   fun:*dl_map_object*
57
}
58
59
{
60
   strlen/*dl_open_worker*(Cond)
61
   Memcheck:Cond
62
   fun:strlen
63
   fun:*dl_open_worker*
64
}
65
{
66
   strlen/_dl_sym/dlsym_doit
67
   Memcheck:Cond
68
   fun:strlen
69
   fun:_dl_sym
70
   fun:dlsym_doit
71
}
72
{
73
   realpath is inefficiently coded
74
   Addrcheck,Memcheck:Overlap
75
   fun:memcpy
76
   fun:realpath*
77
}
78
79
{
80
   realpath stupidity part II
81
   Addrcheck,Memcheck:Overlap
82
   fun:strcpy
83
   fun:realpath*
84
}
85
{
86
   strlen/decompose_rpath/_dl_map_object
87
   Memcheck:Cond
88
   fun:strlen
89
   fun:decompose_rpath
90
   fun:*dl_map_object*
91
}
92
{
93
   stpcpy/_dl_sym*
94
   Memcheck:Cond
95
   fun:__stpcpy
96
   fun:_dl_*
97
}
98
99
#-------- For R H 8.0
100
{
101
   elf_dynamic_do_rel.7/_dl_relocate_object_internal/dl_open_worker(Cond)
102
   Memcheck:Cond
103
   fun:elf_dynamic_do_rel.7
104
   fun:_dl_relocate_object_internal
105
   fun:dl_open_worker
106
}
107
{
108
   dl_relocate/dl_open_worker
109
   Memcheck:Cond
110
   fun:_dl_relocate_object_internal
111
   fun:dl_open_worker
112
}
113
114
115
#-------- Threading bugs?
116
# glibc 'knows' that destroying a locked mutex will unlock it
117
{
118
   pthread_error/__pthread_mutex_destroy/__closedir
119
   core:PThread
120
   fun:pthread_error
121
   fun:__pthread_mutex_destroy
122
   fun:__closedir
123
}
124
125
{
126
   pthread_error/__pthread_mutex_destroy/_IO_default_finish
127
   core:PThread
128
   fun:pthread_error
129
   fun:__pthread_mutex_destroy
130
   fun:_IO_default_finish*
131
}
132
133
{
134
   __pthread_mutex_unlock/_IO_funlockfile
135
   core:PThread
136
   fun:__pthread_mutex_unlock
137
   fun:_IO_funlockfile
138
}
139
140
##----------------------------------------------------------------------##
141
## For a leak in Valgrind's own libpthread.so :(
142
{
143
   my_malloc/get_or_allocate_specifics_ptr/__pthread_key_create(Leak)
144
   Memcheck:Leak
145
   fun:my_malloc
146
   fun:get_or_allocate_specifics_ptr
147
   fun:__pthread_key_create
148
}
149
150
##----------------------------------------------------------------------##
151
## Bugs in helper library supplied with Intel Icc 7.0 (65)
152
## in /opt/intel/compiler70/ia32/lib/libcxa.so.3
153
{
154
   Intel compiler70/ia32/lib/libcxa.so.3 below-esp accesses
155
   Addrcheck,Memcheck:Addr4
156
   obj:/opt/intel/compiler70/ia32/lib/libcxa.so.3
157
}
158
159
##----------------------------------------------------------------------##
160
161
# Errors to suppress by default with XFree86 4.1.0)
162
163
# Format of this file is:
164
# {
165
#     name_of_suppression
166
#     tool_name:supp_kind
167
#     (optional extra info for some suppression types)
168
#     caller0 name, or /name/of/so/file.so
169
#     caller1 name, or ditto
170
#     (optionally: caller2 name)
171
#     (optionally: caller3 name)
172
#  }
173
#
174
# For memcheck, the supp_kinds are:
175
#
176
#     Param Value1 Value2 Value4 Value8 Value16
177
#     Free Addr1 Addr2 Addr4 Addr8 Addr16
178
#     Cond (previously known as Value0)
179
#
180
# and the optional extra info is:
181
#     if Param: name of system call param
182
#     if Free: name of free-ing fn)
183
184
# Resulting from R H 8.0
185
{
186
   *libc_write/libX11.so.6.2/*X11TransWrite(Param)
187
   Addrcheck,Memcheck:Param
188
   write(buf)
189
   fun:*libc_write
190
   obj:/usr/X11R6/lib/libX11.so.6.2
191
   fun:*X11TransWrite
192
}
193
194
{
195
   libX11.so.6.2/libX11.so.6.2/libX11.so.6.2(Cond)
196
   Memcheck:Cond
197
   obj:/usr/X11R6/lib/libX11.so.6.2
198
   obj:/usr/X11R6/lib/libX11.so.6.2
199
   obj:/usr/X11R6/lib/libX11.so.6.2
200
}
201
202
{
203
   libXt.so.6.2/libXt.so.6.2/libXt.so.6.2(Cond)
204
   Memcheck:Cond
205
   obj:/usr/X11R6/lib/libXt.so.6.0
206
   obj:/usr/X11R6/lib/libXt.so.6.0
207
   obj:/usr/X11R6/lib/libXt.so.6.0
208
}
209
210
211
{
212
   libXaw.so.7.0/libXaw.so.7.0/libXaw.so.7.0(Cond)
213
   Memcheck:Cond
214
   obj:/usr/X11R6/lib/libXaw.so.7.0
215
   obj:/usr/X11R6/lib/libXaw.so.7.0
216
   obj:/usr/X11R6/lib/libXaw.so.7.0
217
}
218
219
{
220
   libXmu.so.6.2/libXmu.so.6.2/libXmu.so.6.2(Cond)
221
   Memcheck:Cond
222
   obj:/usr/X11R6/lib/libXmu.so.6.2
223
   obj:/usr/X11R6/lib/libXmu.so.6.2
224
   obj:/usr/X11R6/lib/libXmu.so.6.2
225
}
226
227
{
228
   libXt.so.6.0/libXt.so.6.0/libXaw.so.7.0(Cond)
229
   Memcheck:Cond
230
   obj:/usr/X11R6/lib/libXt.so.6.0
231
   obj:/usr/X11R6/lib/libXt.so.6.0
232
   obj:/usr/X11R6/lib/libXaw.so.7.0
233
}
234
235
{
236
   libXaw.so.7.0/libXaw.so.7.0/libXt.so.6.0(Value4)
237
   Memcheck:Value4
238
   obj:/usr/X11R6/lib/libXaw.so.7.0
239
   obj:/usr/X11R6/lib/libXaw.so.7.0
240
   obj:/usr/X11R6/lib/libXt.so.6.0
241
}
242
243
{
244
   libXaw.so.7.0/libXaw.so.7.0/libXt.so.6.0(Cond)
245
   Memcheck:Cond
246
   obj:/usr/X11R6/lib/libXaw.so.7.0
247
   obj:/usr/X11R6/lib/libXaw.so.7.0
248
   obj:/usr/X11R6/lib/libXt.so.6.0
249
}
250
251
{
252
   libX11.so.6.2/libX11.so.6.2/libXaw.so.7.0(Cond)
253
   Memcheck:Cond
254
   obj:/usr/X11R6/lib/libX11.so.6.2
255
   obj:/usr/X11R6/lib/libX11.so.6.2
256
   obj:/usr/X11R6/lib/libXaw.so.7.0
257
}
258
259
{
260
   libX11.so.6.2/libXaw.so.7.0/libXaw.so.7.0(Cond)
261
   Memcheck:Cond
262
   obj:/usr/X11R6/lib/libX11.so.6.2
263
   obj:/usr/X11R6/lib/libXaw.so.7.0
264
   obj:/usr/X11R6/lib/libXaw.so.7.0
265
}
266
267
{
268
   libXpm.so.4.11/libXpm.so.4.11/libXpm.so.4.11
269
   Memcheck:Cond
270
   obj:/usr/X11R6/lib/libXpm.so.4.11
271
   obj:/usr/X11R6/lib/libXpm.so.4.11
272
   obj:/usr/X11R6/lib/libXpm.so.4.11
273
}
274
275
{
276
   struct with uninitialized paddings
277
   Memcheck:Param
278
   writev(vector[...])
279
   fun:vgAllRoadsLeadToRome_writev
280
   fun:__writev
281
   fun:_X11TransSocketWritev
282
   fun:_X11TransWritev
283
}
284
285
{
286
   another struct with uninitialized paddings
287
   Memcheck:Param
288
   write(buf)
289
   fun:*
290
   fun:_IceTransSocketWrite
291
   fun:_IceTransWrite
292
   fun:_IceWrite
293
}
294
295
296
##----------------------------------------------------------------------##
297
298
299
##----------------------------------------------------------------------##
300
301
# Errors to suppress by default with XFree86 3.3.6)
302
303
# Format of this file is:
304
# {
305
#     name_of_suppression
306
#     tool_name:supp_kind
307
#     (optional extra info for some suppression types)
308
#     caller0 name, or /name/of/so/file.so
309
#     caller1 name, or ditto
310
#     (optionally: caller2 name)
311
#     (optionally: caller3 name)
312
#  }
313
#
314
# For Memcheck, the supp_kinds are:
315
#
316
#     Param Value1 Value2 Value4 Value8 Value16
317
#     Free Addr1 Addr2 Addr4 Addr8 Addr16
318
#     Cond (previously known as Value0)
319
#
320
# and the optional extra info is:
321
#     if Param: name of system call param
322
#     if Free: name of free-ing fn)
323
324
##----------------------------------------------------------------------##
325
326
{
327
   X11-Cond-0
328
   Memcheck:Cond
329
   obj:*libXt.so.6.0
330
   obj:*libXt.so.6.0
331
   obj:*libXt.so.6.0
332
}
333
{
334
   X11-Cond-1
335
   Memcheck:Cond
336
   fun:__rawmemchr
337
   obj:*libXt.so.6.0
338
   obj:*libXt.so.6.0
339
}
340
341
342
# Suppressions for XFree86-3.3.X
343
344
{
345
   X11-Addr4-1
346
   Addrcheck,Memcheck:Addr4
347
   obj:/usr/X11R6/lib/libX11.so.6.1
348
   obj:/usr/X11R6/lib/libX11.so.6.1
349
   obj:/usr/X11R6/lib/libX11.so.6.1
350
}
351
352
{
353
   X11-Addr4-2
354
   Addrcheck,Memcheck:Addr4
355
   obj:/usr/X11R6/lib/libX11.so.6.1
356
   obj:/usr/X11R6/lib/libX11.so.6.1
357
   obj:/usr/X11R6/lib/libXt.so.6.0
358
}
359
360
{
361
   X11-Addr4-3
362
   Addrcheck,Memcheck:Addr4
363
   obj:/usr/X11R6/lib/libXt.so.6.0
364
   obj:/usr/X11R6/lib/libXt.so.6.0
365
   obj:/usr/X11R6/lib/libXt.so.6.0
366
}
367
368
{
369
   X11-Addr4-4
370
   Addrcheck,Memcheck:Addr4
371
   obj:/usr/X11R6/lib/libX11.so.6.1
372
   obj:/usr/X11R6/lib/libXt.so.6.0
373
   obj:/usr/X11R6/lib/libXt.so.6.0
374
}
375
376
{
377
   X11-Addr4-5
378
   Addrcheck,Memcheck:Addr4
379
   fun:__rawmemchr
380
   obj:/usr/X11R6/lib/libXt.so.6.0
381
   obj:/usr/X11R6/lib/libXt.so.6.0
382
}
383
384
{
385
   X11-Addr4-6
386
   Addrcheck,Memcheck:Addr4
387
   obj:/usr/X11R6/lib/libXmu.so.6.0
388
   obj:/usr/X11R6/lib/libXmu.so.6.0
389
   obj:/usr/X11R6/lib/libXt.so.6.0
390
}
391
392
{
393
   X11-Addr4-7
394
   Addrcheck,Memcheck:Addr4
395
   obj:/usr/X11R6/lib/libXt.so.6.0
396
   obj:/usr/X11R6/lib/libXt.so.6.0
397
   obj:/usr/X11R6/lib/libXawXpm_posing_as_Xaw.so.6.1
398
}
399
400
{
401
   X11-Param-1
402
   Addrcheck,Memcheck:Param
403
   write(buf)
404
   fun:__libc_write
405
   obj:/usr/X11R6/lib/libX11.so.6.1
406
   obj:/usr/X11R6/lib/libX11.so.6.1
407
}
408
409
{
410
   X11-Addr4-8
411
   Addrcheck,Memcheck:Addr4
412
   obj:/usr/X11R6/lib/libX11.so.6.1
413
   obj:/usr/X11R6/lib/libXpm.so.4.11
414
   obj:/usr/X11R6/lib/libXpm.so.4.11
415
}
416
417
{
418
   X11-Addr4-8
419
   Addrcheck,Memcheck:Addr4
420
   obj:/usr/X11R6/lib/libXt.so.6.0
421
   obj:/usr/X11R6/lib/libXawXpm_posing_as_Xaw.so.6.1
422
   obj:/usr/X11R6/lib/libXt.so.6.0
423
}
424
425
{
426
   X11-Addr4-9
427
   Addrcheck,Memcheck:Addr4
428
   obj:/usr/X11R6/lib/libXaw.so.6.1
429
   obj:/usr/X11R6/lib/libXt.so.6.0
430
   obj:/usr/X11R6/lib/libXt.so.6.0
431
}
432
433
{
434
   X11-Addr4-10
435
   Addrcheck,Memcheck:Addr4
436
   obj:/usr/X11R6/lib/libXaw.so.6.1
437
   obj:/usr/X11R6/lib/libXaw.so.6.1
438
   obj:/usr/X11R6/lib/libXt.so.6.0
439
}
440
441
{
442
   X11-Addr4-11
443
   Addrcheck,Memcheck:Addr4
444
   obj:/usr/X11R6/lib/libXt.so.6.0
445
   obj:/usr/X11R6/lib/libXt.so.6.0
446
   obj:/usr/X11R6/lib/libXaw.so.6.1
447
}
448
449
450
451
##----------------------------------------------------------------------##
(-)valgrind-2.1.0/demangle/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)valgrind-2.1.0/demangle/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/demangle
(-)valgrind-2.1.0/demangle/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/depcomp (-13 / +61 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
3
# depcomp - compile a program generating dependencies as side-effects
2
# depcomp - compile a program generating dependencies as side-effects
4
# Copyright 1999, 2000 Free Software Foundation, Inc.
3
4
scriptversion=2003-11-08.23
5
6
# Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
5
7
6
# This program is free software; you can redistribute it and/or modify
8
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
9
# it under the terms of the GNU General Public License as published by
Lines 25-30 Link Here
25
27
26
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
28
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
27
29
30
case $1 in
31
  '')
32
     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
33
     exit 1;
34
     ;;
35
  -h | --h*)
36
    cat <<\EOF
37
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
38
39
Run PROGRAMS ARGS to compile a file, generating dependencies
40
as side-effects.
41
42
Environment variables:
43
  depmode     Dependency tracking mode.
44
  source      Source file read by `PROGRAMS ARGS'.
45
  object      Object file output by `PROGRAMS ARGS'.
46
  depfile     Dependency file to output.
47
  tmpdepfile  Temporary file to use when outputing dependencies.
48
  libtool     Whether libtool is used (yes/no).
49
50
Report bugs to <bug-automake@gnu.org>.
51
EOF
52
    exit 0
53
    ;;
54
  -v | --v*)
55
    echo "depcomp $scriptversion"
56
    exit 0
57
    ;;
58
esac
59
28
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
60
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
29
  echo "depcomp: Variables source, object and depmode must be set" 1>&2
61
  echo "depcomp: Variables source, object and depmode must be set" 1>&2
30
  exit 1
62
  exit 1
Lines 172-190 Link Here
172
204
173
aix)
205
aix)
174
  # The C for AIX Compiler uses -M and outputs the dependencies
206
  # The C for AIX Compiler uses -M and outputs the dependencies
175
  # in a .u file.  This file always lives in the current directory.
207
  # in a .u file.  In older versions, this file always lives in the
176
  # Also, the AIX compiler puts `$object:' at the start of each line;
208
  # current directory.  Also, the AIX compiler puts `$object:' at the
177
  # $object doesn't have directory information.
209
  # start of each line; $object doesn't have directory information.
178
  stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
210
  # Version 6 uses the directory in both cases.
211
  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
179
  tmpdepfile="$stripped.u"
212
  tmpdepfile="$stripped.u"
180
  outname="$stripped.o"
181
  if test "$libtool" = yes; then
213
  if test "$libtool" = yes; then
182
    "$@" -Wc,-M
214
    "$@" -Wc,-M
183
  else
215
  else
184
    "$@" -M
216
    "$@" -M
185
  fi
217
  fi
186
187
  stat=$?
218
  stat=$?
219
220
  if test -f "$tmpdepfile"; then :
221
  else
222
    stripped=`echo "$stripped" | sed 's,^.*/,,'`
223
    tmpdepfile="$stripped.u"
224
  fi
225
188
  if test $stat -eq 0; then :
226
  if test $stat -eq 0; then :
189
  else
227
  else
190
    rm -f "$tmpdepfile"
228
    rm -f "$tmpdepfile"
Lines 192-197 Link Here
192
  fi
230
  fi
193
231
194
  if test -f "$tmpdepfile"; then
232
  if test -f "$tmpdepfile"; then
233
    outname="$stripped.o"
195
    # Each line is of the form `foo.o: dependent.h'.
234
    # Each line is of the form `foo.o: dependent.h'.
196
    # Do two passes, one to just change these to
235
    # Do two passes, one to just change these to
197
    # `$object: dependent.h' and one to simply `dependent.h:'.
236
    # `$object: dependent.h' and one to simply `dependent.h:'.
Lines 278-285 Link Here
278
   fi
317
   fi
279
   if test -f "$tmpdepfile"; then
318
   if test -f "$tmpdepfile"; then
280
      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
319
      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
281
      # That's a space and a tab in the [].
320
      # That's a tab and a space in the [].
282
      sed -e 's,^.*\.[a-z]*:[ 	]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
321
      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
283
   else
322
   else
284
      echo "#dummy" > "$depfile"
323
      echo "#dummy" > "$depfile"
285
   fi
324
   fi
Lines 292-298 Link Here
292
331
293
dashmstdout)
332
dashmstdout)
294
  # Important note: in order to support this mode, a compiler *must*
333
  # Important note: in order to support this mode, a compiler *must*
295
  # always write the proprocessed file to stdout, regardless of -o.
334
  # always write the preprocessed file to stdout, regardless of -o.
296
  "$@" || exit $?
335
  "$@" || exit $?
297
336
298
  # Remove the call to Libtool.
337
  # Remove the call to Libtool.
Lines 388-394 Link Here
388
427
389
cpp)
428
cpp)
390
  # Important note: in order to support this mode, a compiler *must*
429
  # Important note: in order to support this mode, a compiler *must*
391
  # always write the proprocessed file to stdout.
430
  # always write the preprocessed file to stdout.
392
  "$@" || exit $?
431
  "$@" || exit $?
393
432
394
  # Remove the call to Libtool.
433
  # Remove the call to Libtool.
Lines 430-436 Link Here
430
469
431
msvisualcpp)
470
msvisualcpp)
432
  # Important note: in order to support this mode, a compiler *must*
471
  # Important note: in order to support this mode, a compiler *must*
433
  # always write the proprocessed file to stdout, regardless of -o,
472
  # always write the preprocessed file to stdout, regardless of -o,
434
  # because we must use -o when running libtool.
473
  # because we must use -o when running libtool.
435
  "$@" || exit $?
474
  "$@" || exit $?
436
  IFS=" "
475
  IFS=" "
Lines 470-472 Link Here
470
esac
509
esac
471
510
472
exit 0
511
exit 0
512
513
# Local Variables:
514
# mode: shell-script
515
# sh-indentation: 2
516
# eval: (add-hook 'write-file-hooks 'time-stamp)
517
# time-stamp-start: "scriptversion="
518
# time-stamp-format: "%:y-%02m-%02d.%02H"
519
# time-stamp-end: "$"
520
# End:
(-)valgrind-2.1.0/docs/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile
2
Makefile.in
(-)valgrind-2.1.0/docs/CVS/Entries (+5 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Tue Apr 16 10:52:04 2002//
2
/Makefile.am/1.3/Wed Nov 13 21:24:55 2002//
3
/manual.html/1.47/Wed Jan 21 13:59:22 2004//
4
/proxylwp.sxw/1.2/Fri Nov  7 23:09:48 2003//
5
D
(-)valgrind-2.1.0/docs/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/docs
(-)valgrind-2.1.0/docs/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/docs/Makefile.in (-38 / +64 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
21
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ..
23
top_builddir = ..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
25
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
26
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
35
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
36
POST_UNINSTALL = :
38
host_triplet = @host@
37
host_triplet = @host@
38
subdir = docs
39
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
40
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
41
am__aclocal_m4_deps = $(top_srcdir)/configure.in
42
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
43
	$(ACLOCAL_M4)
44
mkinstalldirs = $(mkdir_p)
45
CONFIG_HEADER = $(top_builddir)/config.h
46
CONFIG_CLEAN_FILES =
47
SOURCES =
48
DIST_SOURCES =
49
am__installdirs = $(DESTDIR)$(docdir)
50
docDATA_INSTALL = $(INSTALL_DATA)
51
DATA = $(doc_DATA)
52
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
53
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
54
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
55
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
106
SHELL = @SHELL@
93
STRIP = @STRIP@
107
STRIP = @STRIP@
94
VERSION = @VERSION@
108
VERSION = @VERSION@
109
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
110
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
111
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
112
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
138
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
139
localstatedir = @localstatedir@
125
mandir = @mandir@
140
mandir = @mandir@
141
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
142
oldincludedir = @oldincludedir@
127
prefix = @prefix@
143
prefix = @prefix@
128
program_transform_name = @program_transform_name@
144
program_transform_name = @program_transform_name@
Lines 131-162 Link Here
131
sysconfdir = @sysconfdir@
147
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
148
target_alias = @target_alias@
133
docdir = $(datadir)/doc/valgrind
149
docdir = $(datadir)/doc/valgrind
134
135
doc_DATA = manual.html
150
doc_DATA = manual.html
136
137
EXTRA_DIST = $(doc_DATA)
151
EXTRA_DIST = $(doc_DATA)
138
subdir = docs
139
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
140
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
141
CONFIG_HEADER = $(top_builddir)/config.h
142
CONFIG_CLEAN_FILES =
143
DIST_SOURCES =
144
DATA = $(doc_DATA)
145
146
DIST_COMMON = Makefile.am Makefile.in
147
all: all-am
152
all: all-am
148
153
149
.SUFFIXES:
154
.SUFFIXES:
150
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
155
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
156
	@for dep in $?; do \
157
	  case '$(am__configure_deps)' in \
158
	    *$$dep*) \
159
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
160
		&& exit 0; \
161
	      exit 1;; \
162
	  esac; \
163
	done; \
164
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  docs/Makefile'; \
151
	cd $(top_srcdir) && \
165
	cd $(top_srcdir) && \
152
	  $(AUTOMAKE) --gnu  docs/Makefile
166
	  $(AUTOMAKE) --gnu  docs/Makefile
153
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
167
.PRECIOUS: Makefile
154
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
168
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
169
	@case '$?' in \
170
	  *config.status*) \
171
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
172
	  *) \
173
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
174
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
175
	esac;
176
177
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
178
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
179
180
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
181
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
182
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
183
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
155
uninstall-info-am:
184
uninstall-info-am:
156
docDATA_INSTALL = $(INSTALL_DATA)
157
install-docDATA: $(doc_DATA)
185
install-docDATA: $(doc_DATA)
158
	@$(NORMAL_INSTALL)
186
	@$(NORMAL_INSTALL)
159
	$(mkinstalldirs) $(DESTDIR)$(docdir)
187
	$(mkdir_p) $(DESTDIR)$(docdir)
160
	@list='$(doc_DATA)'; for p in $$list; do \
188
	@list='$(doc_DATA)'; for p in $$list; do \
161
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
189
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
162
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
190
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
Lines 177-186 Link Here
177
ctags: CTAGS
205
ctags: CTAGS
178
CTAGS:
206
CTAGS:
179
207
180
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
181
182
top_distdir = ..
183
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
184
208
185
distdir: $(DISTFILES)
209
distdir: $(DISTFILES)
186
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
210
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 194-200 Link Here
194
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
218
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
195
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
219
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
196
	    dir="/$$dir"; \
220
	    dir="/$$dir"; \
197
	    $(mkinstalldirs) "$(distdir)$$dir"; \
221
	    $(mkdir_p) "$(distdir)$$dir"; \
198
	  else \
222
	  else \
199
	    dir=''; \
223
	    dir=''; \
200
	  fi; \
224
	  fi; \
Lines 212-220 Link Here
212
check-am: all-am
236
check-am: all-am
213
check: check-am
237
check: check-am
214
all-am: Makefile $(DATA)
238
all-am: Makefile $(DATA)
215
216
installdirs:
239
installdirs:
217
	$(mkinstalldirs) $(DESTDIR)$(docdir)
240
	$(mkdir_p) $(DESTDIR)$(docdir)
218
install: install-am
241
install: install-am
219
install-exec: install-exec-am
242
install-exec: install-exec-am
220
install-data: install-data-am
243
install-data: install-data-am
Lines 226-232 Link Here
226
installcheck: installcheck-am
249
installcheck: installcheck-am
227
install-strip:
250
install-strip:
228
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
251
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
229
	  INSTALL_STRIP_FLAG=-s \
252
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
230
	  `test -z '$(STRIP)' || \
253
	  `test -z '$(STRIP)' || \
231
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
254
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
232
mostlyclean-generic:
255
mostlyclean-generic:
Lines 234-240 Link Here
234
clean-generic:
257
clean-generic:
235
258
236
distclean-generic:
259
distclean-generic:
237
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
260
	-rm -f $(CONFIG_CLEAN_FILES)
238
261
239
maintainer-clean-generic:
262
maintainer-clean-generic:
240
	@echo "This command is intended for maintainers to use"
263
	@echo "This command is intended for maintainers to use"
Lines 244-256 Link Here
244
clean-am: clean-generic mostlyclean-am
267
clean-am: clean-generic mostlyclean-am
245
268
246
distclean: distclean-am
269
distclean: distclean-am
247
270
	-rm -f Makefile
248
distclean-am: clean-am distclean-generic
271
distclean-am: clean-am distclean-generic
249
272
250
dvi: dvi-am
273
dvi: dvi-am
251
274
252
dvi-am:
275
dvi-am:
253
276
277
html: html-am
278
254
info: info-am
279
info: info-am
255
280
256
info-am:
281
info-am:
Lines 266-272 Link Here
266
installcheck-am:
291
installcheck-am:
267
292
268
maintainer-clean: maintainer-clean-am
293
maintainer-clean: maintainer-clean-am
269
294
	-rm -f Makefile
270
maintainer-clean-am: distclean-am maintainer-clean-generic
295
maintainer-clean-am: distclean-am maintainer-clean-generic
271
296
272
mostlyclean: mostlyclean-am
297
mostlyclean: mostlyclean-am
Lines 284-296 Link Here
284
uninstall-am: uninstall-docDATA uninstall-info-am
309
uninstall-am: uninstall-docDATA uninstall-info-am
285
310
286
.PHONY: all all-am check check-am clean clean-generic distclean \
311
.PHONY: all all-am check check-am clean clean-generic distclean \
287
	distclean-generic distdir dvi dvi-am info info-am install \
312
	distclean-generic distdir dvi dvi-am html html-am info info-am \
288
	install-am install-data install-data-am install-docDATA \
313
	install install-am install-data install-data-am \
289
	install-exec install-exec-am install-info install-info-am \
314
	install-docDATA install-exec install-exec-am install-info \
290
	install-man install-strip installcheck installcheck-am \
315
	install-info-am install-man install-strip installcheck \
291
	installdirs maintainer-clean maintainer-clean-generic \
316
	installcheck-am installdirs maintainer-clean \
292
	mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
317
	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
293
	uninstall-am uninstall-docDATA uninstall-info-am
318
	pdf-am ps ps-am uninstall uninstall-am uninstall-docDATA \
319
	uninstall-info-am
294
320
295
# Tell versions [3.59,3.63) of GNU make to not export all variables.
321
# Tell versions [3.59,3.63) of GNU make to not export all variables.
296
# Otherwise a system limit (for SysV at least) may be exceeded.
322
# Otherwise a system limit (for SysV at least) may be exceeded.
(-)valgrind-2.1.0/docs/manual.html (-7 / +5 lines)
Lines 26-32 Link Here
26
26
27
<a name="title">&nbsp;</a>
27
<a name="title">&nbsp;</a>
28
<h1 align=center>Valgrind, version 2.1.0</h1>
28
<h1 align=center>Valgrind, version 2.1.0</h1>
29
<center>This manual was last updated on 14 December 2003</center>
29
<center>This manual was last updated on 21 January 2004</center>
30
<p>
30
<p>
31
31
32
<center>
32
<center>
Lines 52-64 Link Here
52
              An overview of Valgrind</a><br>
52
              An overview of Valgrind</a><br>
53
    1.2&nbsp; <a href="coregrind_intro.html#intro-navigation">
53
    1.2&nbsp; <a href="coregrind_intro.html#intro-navigation">
54
              How to navigate this manual</a>
54
              How to navigate this manual</a>
55
              <br>
56
    1.2.1&nbsp; <a href="coregrind_intro.html#intro-migrating">
57
                For users migrating from valgrind-1.0.X</a>
58
55
59
<h4>2&nbsp; <a href="coregrind_core.html#core">
56
<h4>2&nbsp; <a href="coregrind_core.html#core">
60
            Using and understanding the Valgrind core services
57
            Using and understanding the Valgrind core</a></h4>
61
            </a></h4>
62
    2.1&nbsp; <a href="coregrind_core.html#core-whatdoes">
58
    2.1&nbsp; <a href="coregrind_core.html#core-whatdoes">
63
                      What it does with your program</a><br>
59
                      What it does with your program</a><br>
64
    2.2&nbsp; <a href="coregrind_core.html#started">
60
    2.2&nbsp; <a href="coregrind_core.html#started">
Lines 87-92 Link Here
87
                       How it works -- a rough overview</a><br>
83
                       How it works -- a rough overview</a><br>
88
    2.14&nbsp; <a href="coregrind_core.html#example">
84
    2.14&nbsp; <a href="coregrind_core.html#example">
89
                       An example run</a><br>
85
                       An example run</a><br>
86
    2.15&nbsp; <a href="coregrind_core.html#warnings">
87
                       Warning messages you might see</a><br>
90
88
91
<h4>3&nbsp; <a href="mc_main.html#mc-top">
89
<h4>3&nbsp; <a href="mc_main.html#mc-top">
92
            Memcheck: a heavyweight memory checker</a></h4>
90
            Memcheck: a heavyweight memory checker</a></h4>
Lines 110-116 Link Here
110
108
111
<p>
109
<p>
112
The following are not part of the user manual.  They describe internal
110
The following are not part of the user manual.  They describe internal
113
details of how Valgrind works.  Reading them may rot your mind.  You
111
details of how Valgrind works.  Reading them may rot your brain.  You
114
have been warned.
112
have been warned.
115
113
116
<h4>8&nbsp; <a href="mc_techdocs.html#mc-techdocs">
114
<h4>8&nbsp; <a href="mc_techdocs.html#mc-techdocs">
(-)valgrind-2.1.0/example/CVS/Entries (+3 lines)
Line 0 Link Here
1
/Makefile.am/1.5/Mon Jan 19 15:45:27 2004//
2
/ex_main.c/1.16/Sun Jan  4 16:43:21 2004//
3
D
(-)valgrind-2.1.0/example/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/example
(-)valgrind-2.1.0/example/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/example/Makefile.am (+20 lines)
Line 0 Link Here
1
2
SUBDIRS = .
3
4
AM_CPPFLAGS = -I$(top_srcdir)/include -DVG_LIBDIR="\"$(libdir)"\"
5
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer \
6
		@PREFERRED_STACK_BOUNDARY@ -g
7
8
valdir = $(libdir)/valgrind
9
inplacedir = $(top_srcdir)/.in_place
10
11
val_PROGRAMS = vgskin_example.so
12
13
vgskin_example_so_SOURCES = ex_main.c
14
vgskin_example_so_LDFLAGS = -shared
15
16
all-local:
17
	mkdir -p $(inplacedir)
18
	-rm -f $(addprefix $(inplacedir)/,$(val_PROGRAMS))
19
	ln -f -s $(addprefix $(top_srcdir)/$(subdir)/,$(val_PROGRAMS)) $(inplacedir)
20
(-)valgrind-2.1.0/example/ex_main.c (+63 lines)
Line 0 Link Here
1
2
/*--------------------------------------------------------------------*/
3
/*--- An example tool.                                   ex_main.c ---*/
4
/*--------------------------------------------------------------------*/
5
6
/*
7
   This file is part of Valgrind, an extensible x86 protected-mode
8
   emulator for monitoring program execution on x86-Unixes.
9
10
   Copyright (C) 2002-2004 Nicholas Nethercote
11
      njn25@cam.ac.uk
12
13
   This program is free software; you can redistribute it and/or
14
   modify it under the terms of the GNU General Public License as
15
   published by the Free Software Foundation; either version 2 of the
16
   License, or (at your option) any later version.
17
18
   This program is distributed in the hope that it will be useful, but
19
   WITHOUT ANY WARRANTY; without even the implied warranty of
20
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21
   General Public License for more details.
22
23
   You should have received a copy of the GNU General Public License
24
   along with this program; if not, write to the Free Software
25
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26
   02111-1307, USA.
27
28
   The GNU General Public License is contained in the file COPYING.
29
*/
30
31
#include "vg_skin.h"
32
33
static void SK_(pre_clo_init)()
34
{
35
   VG_(details_name)            ("Example");
36
   VG_(details_version)         ("0.0.1");
37
   VG_(details_description)     ("an example Valgrind tool");
38
   VG_(details_copyright_author)(
39
      "Copyright (C) 2002-2004, and put in the public domain, by Santa Claus.");
40
   VG_(details_bug_reports_to)  ("santa.claus@northpole.org");
41
42
   /* No needs, no core events to track */
43
}
44
45
void SK_(post_clo_init)(void)
46
{
47
}
48
49
UCodeBlock* SK_(instrument)(UCodeBlock* cb, Addr a)
50
{
51
    return cb;
52
}
53
54
void SK_(fini)(exitcode)
55
{
56
}
57
58
/* Does not use shadow memory */
59
VG_DETERMINE_INTERFACE_VERSION(SK_(pre_clo_init), 0)
60
61
/*--------------------------------------------------------------------*/
62
/*--- end                                                ex_main.c ---*/
63
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/glibc-2.1.supp (-9 / +9 lines)
Lines 37-53 Link Here
37
##----------------------------------------------------------------------##
37
##----------------------------------------------------------------------##
38
38
39
{
39
{
40
   __pthread_mutex_unlock/__register_frame_info_bases
40
   pthread_mutex_unlock/__register_frame_info_bases
41
   core:PThread
41
   core:PThread
42
   fun:__pthread_mutex_unlock
42
   fun:pthread_mutex_unlock
43
   fun:__register_frame_info_bases
43
   fun:__register_frame_info_bases
44
}
44
}
45
45
46
{
46
{
47
   socketcall.connect(serv_addr)/__libc_connect/*(Param)
47
   socketcall.connect(serv_addr)/connect/*(Param)
48
   Addrcheck,Memcheck:Param
48
   Addrcheck,Memcheck:Param
49
   socketcall.connect(serv_addr)
49
   socketcall.connect(serv_addr)
50
   fun:__libc_connect
50
   fun:connect
51
   fun:*
51
   fun:*
52
}
52
}
53
53
Lines 68-77 Link Here
68
}
68
}
69
69
70
{
70
{
71
   llseek(result)/__libc_lseek64/_IO_file_seek(Param)
71
   llseek(result)/lseek64/_IO_file_seek(Param)
72
   Addrcheck,Memcheck:Param
72
   Addrcheck,Memcheck:Param
73
   llseek(result)
73
   llseek(result)
74
   fun:__libc_lseek64
74
   fun:lseek64
75
   fun:_IO_file_seek
75
   fun:_IO_file_seek
76
}
76
}
77
77
Lines 164-170 Link Here
164
}
164
}
165
165
166
{
166
{
167
   socketcall.connect(serv_addr)/__libc_connect/*(Param)
167
   socketcall.connect(serv_addr)/connect/*(Param)
168
   Addrcheck,Memcheck:Param
168
   Addrcheck,Memcheck:Param
169
   socketcall.connect(serv_addr)
169
   socketcall.connect(serv_addr)
170
   obj:*libc-2.1.3.so
170
   obj:*libc-2.1.3.so
Lines 174-183 Link Here
174
##----------------------------------------------------------------------##
174
##----------------------------------------------------------------------##
175
## For a leak in Valgrind's own libpthread.so :(
175
## For a leak in Valgrind's own libpthread.so :(
176
{
176
{
177
   my_malloc/get_or_allocate_specifics_ptr/__pthread_key_create(Leak)
177
   my_malloc/get_or_allocate_specifics_ptr/pthread_key_create(Leak)
178
   Memcheck:Leak
178
   Memcheck:Leak
179
   fun:my_malloc
179
   fun:my_malloc
180
   fun:get_or_allocate_specifics_ptr
180
   fun:get_or_allocate_specifics_ptr
181
   fun:__pthread_key_create
181
   fun:pthread_key_create
182
}
182
}
183
183
(-)valgrind-2.1.0/glibc-2.2.supp (-14 / +14 lines)
Lines 173-197 Link Here
173
#-------- Threading bugs?
173
#-------- Threading bugs?
174
# glibc 'knows' that destroying a locked mutex will unlock it
174
# glibc 'knows' that destroying a locked mutex will unlock it
175
{
175
{
176
   pthread_error/__pthread_mutex_destroy/__closedir
176
   pthread_error/pthread_mutex_destroy/__closedir
177
   core:PThread
177
   core:PThread
178
   fun:pthread_error
178
   fun:pthread_error
179
   fun:__pthread_mutex_destroy
179
   fun:pthread_mutex_destroy
180
   fun:__closedir
180
   fun:__closedir
181
}
181
}
182
182
183
{
183
{
184
   pthread_error/__pthread_mutex_destroy/_IO_default_finish
184
   pthread_error/pthread_mutex_destroy/_IO_default_finish
185
   core:PThread
185
   core:PThread
186
   fun:pthread_error
186
   fun:pthread_error
187
   fun:__pthread_mutex_destroy
187
   fun:pthread_mutex_destroy
188
   fun:_IO_default_finish*
188
   fun:_IO_default_finish*
189
}
189
}
190
190
191
{
191
{
192
   __pthread_mutex_unlock/_IO_funlockfile
192
   pthread_mutex_unlock/_IO_funlockfile
193
   core:PThread
193
   core:PThread
194
   fun:__pthread_mutex_unlock
194
   fun:pthread_mutex_unlock
195
   fun:_IO_funlockfile
195
   fun:_IO_funlockfile
196
}
196
}
197
197
Lines 345-354 Link Here
345
345
346
#-------------------
346
#-------------------
347
{
347
{
348
   socketcall.connect(serv_addr)/__libc_connect/*
348
   socketcall.connect(serv_addr)/connect/*
349
   Addrcheck,Memcheck:Param
349
   Addrcheck,Memcheck:Param
350
   socketcall.connect(serv_addr)
350
   socketcall.connect(serv_addr)
351
   fun:__libc_connect
351
   fun:connect
352
   fun:*
352
   fun:*
353
}
353
}
354
{
354
{
Lines 361-370 Link Here
361
361
362
#----------------------
362
#----------------------
363
{
363
{
364
   write(buf)/__libc_write/libX11.so.6.2/libX11.so.6.2(Param)
364
   write(buf)/write/libX11.so.6.2/libX11.so.6.2(Param)
365
   Addrcheck,Memcheck:Param
365
   Addrcheck,Memcheck:Param
366
   write(buf)
366
   write(buf)
367
   fun:__libc_write
367
   fun:write
368
   obj:/usr/X11R6/lib/libX11.so.6.2
368
   obj:/usr/X11R6/lib/libX11.so.6.2
369
   obj:/usr/X11R6/lib/libX11.so.6.2
369
   obj:/usr/X11R6/lib/libX11.so.6.2
370
}
370
}
Lines 378-387 Link Here
378
}
378
}
379
379
380
#{
380
#{
381
#   llseek(result)/__libc_lseek64/_IO_file_seek(Param)
381
#   llseek(result)/lseek64/_IO_file_seek(Param)
382
#   Param
382
#   Param
383
#   llseek(result)
383
#   llseek(result)
384
#   fun:__libc_lseek64
384
#   fun:lseek64
385
#   fun:_IO_file_seek
385
#   fun:_IO_file_seek
386
#}
386
#}
387
387
Lines 413-423 Link Here
413
##----------------------------------------------------------------------##
413
##----------------------------------------------------------------------##
414
## For a leak in Valgrind's own libpthread.so :(
414
## For a leak in Valgrind's own libpthread.so :(
415
{
415
{
416
   my_malloc/get_or_allocate_specifics_ptr/__pthread_key_create(Leak)
416
   my_malloc/get_or_allocate_specifics_ptr/pthread_key_create(Leak)
417
   Memcheck:Leak
417
   Memcheck:Leak
418
   fun:my_malloc
418
   fun:my_malloc
419
   fun:get_or_allocate_specifics_ptr
419
   fun:get_or_allocate_specifics_ptr
420
   fun:__pthread_key_create
420
   fun:pthread_key_create
421
}
421
}
422
422
423
423
(-)valgrind-2.1.0/glibc-2.3.supp (-8 / +72 lines)
Lines 106-145 Link Here
106
   fun:dl_open_worker
106
   fun:dl_open_worker
107
}
107
}
108
108
109
#-------- glibc 2.3.2/ Fedora Core 1
110
{
111
   dl_relocate/dl_main
112
   Memcheck:Cond
113
   fun:_dl_relocate_object_internal
114
   fun:dl_main
115
}
116
117
#-------- Data races
118
{
119
   _dl_lookup_symbol_internal/fixup/_dl_runtime_resolve
120
   Helgrind:Eraser
121
   fun:_dl_lookup_symbol_internal
122
   fun:fixup
123
   fun:_dl_runtime_resolve
124
}
125
{
126
   _dl_lookup_versioned_symbol_internal/fixup/_dl_runtime_resolve
127
   Helgrind:Eraser
128
   fun:_dl_lookup_versioned_symbol_internal
129
   fun:fixup
130
   fun:_dl_runtime_resolve
131
}
132
{
133
   _dl_fini
134
   Helgrind:Eraser
135
   fun:_dl_fini
136
}
109
137
110
#-------- Threading bugs?
138
#-------- Threading bugs?
111
# glibc 'knows' that destroying a locked mutex will unlock it
139
# glibc 'knows' that destroying a locked mutex will unlock it
112
{
140
{
113
   pthread_error/__pthread_mutex_destroy/__closedir
141
   pthread_error/pthread_mutex_destroy/__closedir
114
   core:PThread
142
   core:PThread
115
   fun:pthread_error
143
   fun:pthread_error
116
   fun:__pthread_mutex_destroy
144
   fun:pthread_mutex_destroy
117
   fun:__closedir
145
   fun:__closedir
118
}
146
}
119
147
120
{
148
{
121
   pthread_error/__pthread_mutex_destroy/_IO_default_finish
149
   pthread_error/pthread_mutex_destroy/_IO_default_finish
122
   core:PThread
150
   core:PThread
123
   fun:pthread_error
151
   fun:pthread_error
124
   fun:__pthread_mutex_destroy
152
   fun:pthread_mutex_destroy
125
   fun:_IO_default_finish*
153
   fun:_IO_default_finish*
126
}
154
}
127
155
128
{
156
{
129
   __pthread_mutex_unlock/_IO_funlockfile
157
   pthread_mutex_unlock/_IO_funlockfile
130
   core:PThread
158
   core:PThread
131
   fun:__pthread_mutex_unlock
159
   fun:pthread_mutex_unlock
132
   fun:_IO_funlockfile
160
   fun:_IO_funlockfile
133
}
161
}
134
162
135
##----------------------------------------------------------------------##
163
##----------------------------------------------------------------------##
136
## For a leak in Valgrind's own libpthread.so :(
164
## For a leak in Valgrind's own libpthread.so :(
137
{
165
{
138
   my_malloc/get_or_allocate_specifics_ptr/__pthread_key_create(Leak)
166
   my_malloc/get_or_allocate_specifics_ptr/pthread_key_create(Leak)
139
   Memcheck:Leak
167
   Memcheck:Leak
140
   fun:my_malloc
168
   fun:my_malloc
141
   fun:get_or_allocate_specifics_ptr
169
   fun:get_or_allocate_specifics_ptr
142
   fun:__pthread_key_create
170
   fun:pthread_key_create
143
}
171
}
144
172
145
##----------------------------------------------------------------------##
173
##----------------------------------------------------------------------##
Lines 150-152 Link Here
150
   Addrcheck,Memcheck:Addr4
178
   Addrcheck,Memcheck:Addr4
151
   obj:/opt/intel/compiler70/ia32/lib/libcxa.so.3
179
   obj:/opt/intel/compiler70/ia32/lib/libcxa.so.3
152
}
180
}
181
182
##----------------------------------------------------------------------##
183
## SuSE 9 after FV changes (post 2.1.0)
184
185
{
186
   strlen/_dl_init_paths/dl_main/_dl_sysdep_start(Cond)
187
   Memcheck:Cond
188
   fun:strlen
189
   fun:_dl_init_paths
190
   fun:dl_main
191
   fun:_dl_sysdep_start
192
}
193
194
{
195
   Ugly strchr error in /lib/ld-2.3.2.so
196
   Memcheck:Cond
197
   obj:/lib/ld-2.3.2.so
198
}
199
200
##----------------------------------------------------------------------##
201
## SuSE 9 after FV changes (post 2.1.0)
202
203
{
204
   strlen/_dl_init_paths/dl_main/_dl_sysdep_start(Cond)
205
   Memcheck:Cond
206
   fun:strlen
207
   fun:_dl_init_paths
208
   fun:dl_main
209
   fun:_dl_sysdep_start
210
}
211
212
{
213
   Ugly strchr error in /lib/ld-2.3.2.so
214
   Memcheck:Cond
215
   obj:/lib/ld-2.3.2.so
216
}
(-)valgrind-2.1.0/helgrind/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/helgrind/CVS/Entries (+5 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Mon Sep 23 11:36:32 2002//
2
/Makefile.am/1.45/Mon Jan 19 21:35:52 2004//
3
/helgrind.h/1.7/Sun Jan  4 16:43:22 2004//
4
/hg_main.c/1.71/Sun Jan  4 23:08:03 2004//
5
D
(-)valgrind-2.1.0/helgrind/CVS/Entries.Log (+2 lines)
Line 0 Link Here
1
A D/docs////
2
A D/tests////
(-)valgrind-2.1.0/helgrind/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/helgrind
(-)valgrind-2.1.0/helgrind/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/helgrind/Makefile.am (-2 / +12 lines)
Lines 6-18 Link Here
6
		@PREFERRED_STACK_BOUNDARY@ -g
6
		@PREFERRED_STACK_BOUNDARY@ -g
7
7
8
valdir = $(libdir)/valgrind
8
valdir = $(libdir)/valgrind
9
inplacedir = $(top_srcdir)/.in_place
9
10
10
val_PROGRAMS = vgskin_helgrind.so
11
val_PROGRAMS = vgskin_helgrind.so vgpreload_helgrind.so
11
12
12
vgskin_helgrind_so_SOURCES = hg_main.c
13
vgskin_helgrind_so_SOURCES = hg_main.c
13
vgskin_helgrind_so_LDFLAGS = -shared
14
vgskin_helgrind_so_LDFLAGS = -shared
14
vgskin_helgrind_so_LDADD = ../coregrind/vg_replace_malloc.o
15
16
vgpreload_helgrind_so_SOURCES = 
17
vgpreload_helgrind_so_LDADD = $(top_srcdir)/coregrind/vg_replace_malloc.o
18
vgpreload_helgrind_so_DEPENDENCIES = $(top_srcdir)/coregrind/vg_replace_malloc.o
19
vgpreload_helgrind_so_LDFLAGS = -shared -Wl,-z,interpose,-z,initfirst
15
20
16
hgincludedir = $(includedir)/valgrind
21
hgincludedir = $(includedir)/valgrind
17
22
18
hginclude_HEADERS = helgrind.h
23
hginclude_HEADERS = helgrind.h
24
25
all-local:
26
	mkdir -p $(inplacedir)
27
	-rm -f $(addprefix $(inplacedir)/,$(val_PROGRAMS))
28
	ln -f -s $(addprefix $(top_srcdir)/$(subdir)/,$(val_PROGRAMS)) $(inplacedir)
(-)valgrind-2.1.0/helgrind/Makefile.in (-111 / +130 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 14-19 Link Here
14
14
15
@SET_MAKE@
15
@SET_MAKE@
16
16
17
18
SOURCES = $(vgpreload_helgrind_so_SOURCES) $(vgskin_helgrind_so_SOURCES)
19
17
srcdir = @srcdir@
20
srcdir = @srcdir@
18
top_srcdir = @top_srcdir@
21
top_srcdir = @top_srcdir@
19
VPATH = @srcdir@
22
VPATH = @srcdir@
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
24
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
25
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ..
26
top_builddir = ..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
27
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
28
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
29
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
38
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
39
POST_UNINSTALL = :
38
host_triplet = @host@
40
host_triplet = @host@
41
val_PROGRAMS = vgskin_helgrind.so$(EXEEXT) \
42
	vgpreload_helgrind.so$(EXEEXT)
43
subdir = helgrind
44
DIST_COMMON = $(hginclude_HEADERS) $(srcdir)/Makefile.am \
45
	$(srcdir)/Makefile.in
46
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
47
am__aclocal_m4_deps = $(top_srcdir)/configure.in
48
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
49
	$(ACLOCAL_M4)
50
mkinstalldirs = $(mkdir_p)
51
CONFIG_HEADER = $(top_builddir)/config.h
52
CONFIG_CLEAN_FILES =
53
am__installdirs = $(DESTDIR)$(valdir) $(DESTDIR)$(hgincludedir)
54
valPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
55
PROGRAMS = $(val_PROGRAMS)
56
am_vgpreload_helgrind_so_OBJECTS =
57
vgpreload_helgrind_so_OBJECTS = $(am_vgpreload_helgrind_so_OBJECTS)
58
am_vgskin_helgrind_so_OBJECTS = hg_main.$(OBJEXT)
59
vgskin_helgrind_so_OBJECTS = $(am_vgskin_helgrind_so_OBJECTS)
60
vgskin_helgrind_so_LDADD = $(LDADD)
61
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
62
depcomp = $(SHELL) $(top_srcdir)/depcomp
63
am__depfiles_maybe = depfiles
64
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/hg_main.Po
65
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
66
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
67
CCLD = $(CC)
68
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
69
SOURCES = $(vgpreload_helgrind_so_SOURCES) \
70
	$(vgskin_helgrind_so_SOURCES)
71
DIST_SOURCES = $(vgpreload_helgrind_so_SOURCES) \
72
	$(vgskin_helgrind_so_SOURCES)
73
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
74
	html-recursive info-recursive install-data-recursive \
75
	install-exec-recursive install-info-recursive \
76
	install-recursive installcheck-recursive installdirs-recursive \
77
	pdf-recursive ps-recursive uninstall-info-recursive \
78
	uninstall-recursive
79
hgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
80
HEADERS = $(hginclude_HEADERS)
81
ETAGS = etags
82
CTAGS = ctags
83
DIST_SUBDIRS = $(SUBDIRS)
84
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
85
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
86
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
87
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
138
SHELL = @SHELL@
93
STRIP = @STRIP@
139
STRIP = @STRIP@
94
VERSION = @VERSION@
140
VERSION = @VERSION@
141
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
142
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
143
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
144
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
170
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
171
localstatedir = @localstatedir@
125
mandir = @mandir@
172
mandir = @mandir@
173
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
174
oldincludedir = @oldincludedir@
127
prefix = @prefix@
175
prefix = @prefix@
128
program_transform_name = @program_transform_name@
176
program_transform_name = @program_transform_name@
Lines 130-200 Link Here
130
sharedstatedir = @sharedstatedir@
178
sharedstatedir = @sharedstatedir@
131
sysconfdir = @sysconfdir@
179
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
180
target_alias = @target_alias@
133
134
SUBDIRS = . docs tests
181
SUBDIRS = . docs tests
135
136
AM_CPPFLAGS = -I$(top_srcdir)/include -DVG_LIBDIR="\"$(libdir)"\"
182
AM_CPPFLAGS = -I$(top_srcdir)/include -DVG_LIBDIR="\"$(libdir)"\"
137
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer \
183
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer \
138
		@PREFERRED_STACK_BOUNDARY@ -g
184
		@PREFERRED_STACK_BOUNDARY@ -g
139
185
140
141
valdir = $(libdir)/valgrind
186
valdir = $(libdir)/valgrind
142
187
inplacedir = $(top_srcdir)/.in_place
143
val_PROGRAMS = vgskin_helgrind.so
144
145
vgskin_helgrind_so_SOURCES = hg_main.c
188
vgskin_helgrind_so_SOURCES = hg_main.c
146
vgskin_helgrind_so_LDFLAGS = -shared
189
vgskin_helgrind_so_LDFLAGS = -shared
147
vgskin_helgrind_so_LDADD = ../coregrind/vg_replace_malloc.o
190
vgpreload_helgrind_so_SOURCES = 
148
191
vgpreload_helgrind_so_LDADD = $(top_srcdir)/coregrind/vg_replace_malloc.o
192
vgpreload_helgrind_so_DEPENDENCIES = $(top_srcdir)/coregrind/vg_replace_malloc.o
193
vgpreload_helgrind_so_LDFLAGS = -shared -Wl,-z,interpose,-z,initfirst
149
hgincludedir = $(includedir)/valgrind
194
hgincludedir = $(includedir)/valgrind
150
151
hginclude_HEADERS = helgrind.h
195
hginclude_HEADERS = helgrind.h
152
subdir = helgrind
153
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
154
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
155
CONFIG_HEADER = $(top_builddir)/config.h
156
CONFIG_CLEAN_FILES =
157
val_PROGRAMS = vgskin_helgrind.so$(EXEEXT)
158
PROGRAMS = $(val_PROGRAMS)
159
160
am_vgskin_helgrind_so_OBJECTS = hg_main.$(OBJEXT)
161
vgskin_helgrind_so_OBJECTS = $(am_vgskin_helgrind_so_OBJECTS)
162
vgskin_helgrind_so_DEPENDENCIES = ../coregrind/vg_replace_malloc.o
163
164
DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
165
depcomp = $(SHELL) $(top_srcdir)/depcomp
166
am__depfiles_maybe = depfiles
167
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/hg_main.Po
168
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
169
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
170
CCLD = $(CC)
171
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
172
DIST_SOURCES = $(vgskin_helgrind_so_SOURCES)
173
HEADERS = $(hginclude_HEADERS)
174
175
176
RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
177
	ps-recursive install-info-recursive uninstall-info-recursive \
178
	all-recursive install-data-recursive install-exec-recursive \
179
	installdirs-recursive install-recursive uninstall-recursive \
180
	check-recursive installcheck-recursive
181
DIST_COMMON = $(hginclude_HEADERS) Makefile.am Makefile.in
182
DIST_SUBDIRS = $(SUBDIRS)
183
SOURCES = $(vgskin_helgrind_so_SOURCES)
184
185
all: all-recursive
196
all: all-recursive
186
197
187
.SUFFIXES:
198
.SUFFIXES:
188
.SUFFIXES: .c .o .obj
199
.SUFFIXES: .c .o .obj
189
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
200
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
201
	@for dep in $?; do \
202
	  case '$(am__configure_deps)' in \
203
	    *$$dep*) \
204
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
205
		&& exit 0; \
206
	      exit 1;; \
207
	  esac; \
208
	done; \
209
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  helgrind/Makefile'; \
190
	cd $(top_srcdir) && \
210
	cd $(top_srcdir) && \
191
	  $(AUTOMAKE) --gnu  helgrind/Makefile
211
	  $(AUTOMAKE) --gnu  helgrind/Makefile
192
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
212
.PRECIOUS: Makefile
193
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
213
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
194
valPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
214
	@case '$?' in \
215
	  *config.status*) \
216
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
217
	  *) \
218
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
219
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
220
	esac;
221
222
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
223
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
224
225
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
226
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
227
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
228
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
195
install-valPROGRAMS: $(val_PROGRAMS)
229
install-valPROGRAMS: $(val_PROGRAMS)
196
	@$(NORMAL_INSTALL)
230
	@$(NORMAL_INSTALL)
197
	$(mkinstalldirs) $(DESTDIR)$(valdir)
231
	$(mkdir_p) $(DESTDIR)$(valdir)
198
	@list='$(val_PROGRAMS)'; for p in $$list; do \
232
	@list='$(val_PROGRAMS)'; for p in $$list; do \
199
	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
233
	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
200
	  if test -f $$p \
234
	  if test -f $$p \
Lines 215-261 Link Here
215
249
216
clean-valPROGRAMS:
250
clean-valPROGRAMS:
217
	-test -z "$(val_PROGRAMS)" || rm -f $(val_PROGRAMS)
251
	-test -z "$(val_PROGRAMS)" || rm -f $(val_PROGRAMS)
252
vgpreload_helgrind.so$(EXEEXT): $(vgpreload_helgrind_so_OBJECTS) $(vgpreload_helgrind_so_DEPENDENCIES) 
253
	@rm -f vgpreload_helgrind.so$(EXEEXT)
254
	$(LINK) $(vgpreload_helgrind_so_LDFLAGS) $(vgpreload_helgrind_so_OBJECTS) $(vgpreload_helgrind_so_LDADD) $(LIBS)
218
vgskin_helgrind.so$(EXEEXT): $(vgskin_helgrind_so_OBJECTS) $(vgskin_helgrind_so_DEPENDENCIES) 
255
vgskin_helgrind.so$(EXEEXT): $(vgskin_helgrind_so_OBJECTS) $(vgskin_helgrind_so_DEPENDENCIES) 
219
	@rm -f vgskin_helgrind.so$(EXEEXT)
256
	@rm -f vgskin_helgrind.so$(EXEEXT)
220
	$(LINK) $(vgskin_helgrind_so_LDFLAGS) $(vgskin_helgrind_so_OBJECTS) $(vgskin_helgrind_so_LDADD) $(LIBS)
257
	$(LINK) $(vgskin_helgrind_so_LDFLAGS) $(vgskin_helgrind_so_OBJECTS) $(vgskin_helgrind_so_LDADD) $(LIBS)
221
258
222
mostlyclean-compile:
259
mostlyclean-compile:
223
	-rm -f *.$(OBJEXT) core *.core
260
	-rm -f *.$(OBJEXT)
224
261
225
distclean-compile:
262
distclean-compile:
226
	-rm -f *.tab.c
263
	-rm -f *.tab.c
227
264
228
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hg_main.Po@am__quote@
265
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hg_main.Po@am__quote@
229
266
230
distclean-depend:
231
	-rm -rf ./$(DEPDIR)
232
233
.c.o:
267
.c.o:
234
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
268
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
235
@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
269
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
236
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
237
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
238
@am__fastdepCC_TRUE@	fi
239
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
270
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
240
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
271
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
241
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
272
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
242
@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
273
@am__fastdepCC_FALSE@	$(COMPILE) -c $<
243
274
244
.c.obj:
275
.c.obj:
245
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
276
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
246
@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
277
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
247
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
248
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
249
@am__fastdepCC_TRUE@	fi
250
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
278
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
251
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
279
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
252
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
280
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
253
@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
281
@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
254
uninstall-info-am:
282
uninstall-info-am:
255
hgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
256
install-hgincludeHEADERS: $(hginclude_HEADERS)
283
install-hgincludeHEADERS: $(hginclude_HEADERS)
257
	@$(NORMAL_INSTALL)
284
	@$(NORMAL_INSTALL)
258
	$(mkinstalldirs) $(DESTDIR)$(hgincludedir)
285
	$(mkdir_p) $(DESTDIR)$(hgincludedir)
259
	@list='$(hginclude_HEADERS)'; for p in $$list; do \
286
	@list='$(hginclude_HEADERS)'; for p in $$list; do \
260
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
287
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
261
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
288
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
Lines 330-343 Link Here
330
	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
357
	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
331
	done
358
	done
332
359
333
ETAGS = etags
334
ETAGSFLAGS =
335
336
CTAGS = ctags
337
CTAGSFLAGS =
338
339
tags: TAGS
340
341
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
360
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
342
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
361
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
343
	unique=`for i in $$list; do \
362
	unique=`for i in $$list; do \
Lines 346-351 Link Here
346
	  $(AWK) '    { files[$$0] = 1; } \
365
	  $(AWK) '    { files[$$0] = 1; } \
347
	       END { for (i in files) print i; }'`; \
366
	       END { for (i in files) print i; }'`; \
348
	mkid -fID $$unique
367
	mkid -fID $$unique
368
tags: TAGS
349
369
350
TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
370
TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
351
		$(TAGS_FILES) $(LISP)
371
		$(TAGS_FILES) $(LISP)
Lines 371-377 Link Here
371
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
391
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
372
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
392
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
373
	     $$tags $$unique
393
	     $$tags $$unique
374
375
ctags: CTAGS
394
ctags: CTAGS
376
CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
395
CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
377
		$(TAGS_FILES) $(LISP)
396
		$(TAGS_FILES) $(LISP)
Lines 394-403 Link Here
394
413
395
distclean-tags:
414
distclean-tags:
396
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
415
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
397
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
398
399
top_distdir = ..
400
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
401
416
402
distdir: $(DISTFILES)
417
distdir: $(DISTFILES)
403
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
418
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 411-417 Link Here
411
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
426
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
412
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
427
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
413
	    dir="/$$dir"; \
428
	    dir="/$$dir"; \
414
	    $(mkinstalldirs) "$(distdir)$$dir"; \
429
	    $(mkdir_p) "$(distdir)$$dir"; \
415
	  else \
430
	  else \
416
	    dir=''; \
431
	    dir=''; \
417
	  fi; \
432
	  fi; \
Lines 428-451 Link Here
428
	done
443
	done
429
	list='$(SUBDIRS)'; for subdir in $$list; do \
444
	list='$(SUBDIRS)'; for subdir in $$list; do \
430
	  if test "$$subdir" = .; then :; else \
445
	  if test "$$subdir" = .; then :; else \
431
	    test -d $(distdir)/$$subdir \
446
	    test -d "$(distdir)/$$subdir" \
432
	    || mkdir $(distdir)/$$subdir \
447
	    || mkdir "$(distdir)/$$subdir" \
433
	    || exit 1; \
448
	    || exit 1; \
434
	    (cd $$subdir && \
449
	    (cd $$subdir && \
435
	      $(MAKE) $(AM_MAKEFLAGS) \
450
	      $(MAKE) $(AM_MAKEFLAGS) \
436
	        top_distdir="$(top_distdir)" \
451
	        top_distdir="../$(top_distdir)" \
437
	        distdir=../$(distdir)/$$subdir \
452
	        distdir="../$(distdir)/$$subdir" \
438
	        distdir) \
453
	        distdir) \
439
	      || exit 1; \
454
	      || exit 1; \
440
	  fi; \
455
	  fi; \
441
	done
456
	done
442
check-am: all-am
457
check-am: all-am
443
check: check-recursive
458
check: check-recursive
444
all-am: Makefile $(PROGRAMS) $(HEADERS)
459
all-am: Makefile $(PROGRAMS) $(HEADERS) all-local
445
installdirs: installdirs-recursive
460
installdirs: installdirs-recursive
446
installdirs-am:
461
installdirs-am:
447
	$(mkinstalldirs) $(DESTDIR)$(valdir) $(DESTDIR)$(hgincludedir)
462
	$(mkdir_p) $(DESTDIR)$(valdir) $(DESTDIR)$(hgincludedir)
448
449
install: install-recursive
463
install: install-recursive
450
install-exec: install-exec-recursive
464
install-exec: install-exec-recursive
451
install-data: install-data-recursive
465
install-data: install-data-recursive
Lines 457-463 Link Here
457
installcheck: installcheck-recursive
471
installcheck: installcheck-recursive
458
install-strip:
472
install-strip:
459
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
473
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
460
	  INSTALL_STRIP_FLAG=-s \
474
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
461
	  `test -z '$(STRIP)' || \
475
	  `test -z '$(STRIP)' || \
462
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
476
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
463
mostlyclean-generic:
477
mostlyclean-generic:
Lines 465-471 Link Here
465
clean-generic:
479
clean-generic:
466
480
467
distclean-generic:
481
distclean-generic:
468
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
482
	-rm -f $(CONFIG_CLEAN_FILES)
469
483
470
maintainer-clean-generic:
484
maintainer-clean-generic:
471
	@echo "This command is intended for maintainers to use"
485
	@echo "This command is intended for maintainers to use"
Lines 475-488 Link Here
475
clean-am: clean-generic clean-valPROGRAMS mostlyclean-am
489
clean-am: clean-generic clean-valPROGRAMS mostlyclean-am
476
490
477
distclean: distclean-recursive
491
distclean: distclean-recursive
478
492
	-rm -rf ./$(DEPDIR)
479
distclean-am: clean-am distclean-compile distclean-depend \
493
	-rm -f Makefile
480
	distclean-generic distclean-tags
494
distclean-am: clean-am distclean-compile distclean-generic \
495
	distclean-tags
481
496
482
dvi: dvi-recursive
497
dvi: dvi-recursive
483
498
484
dvi-am:
499
dvi-am:
485
500
501
html: html-recursive
502
486
info: info-recursive
503
info: info-recursive
487
504
488
info-am:
505
info-am:
Lines 498-504 Link Here
498
installcheck-am:
515
installcheck-am:
499
516
500
maintainer-clean: maintainer-clean-recursive
517
maintainer-clean: maintainer-clean-recursive
501
518
	-rm -rf ./$(DEPDIR)
519
	-rm -f Makefile
502
maintainer-clean-am: distclean-am maintainer-clean-generic
520
maintainer-clean-am: distclean-am maintainer-clean-generic
503
521
504
mostlyclean: mostlyclean-recursive
522
mostlyclean: mostlyclean-recursive
Lines 518-542 Link Here
518
536
519
uninstall-info: uninstall-info-recursive
537
uninstall-info: uninstall-info-recursive
520
538
521
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
539
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am all-local check \
522
	clean-generic clean-recursive clean-valPROGRAMS ctags \
540
	check-am clean clean-generic clean-recursive clean-valPROGRAMS \
523
	ctags-recursive distclean distclean-compile distclean-depend \
541
	ctags ctags-recursive distclean distclean-compile \
524
	distclean-generic distclean-recursive distclean-tags distdir \
542
	distclean-generic distclean-recursive distclean-tags distdir \
525
	dvi dvi-am dvi-recursive info info-am info-recursive install \
543
	dvi dvi-am html html-am info info-am install install-am \
526
	install-am install-data install-data-am install-data-recursive \
544
	install-data install-data-am install-exec install-exec-am \
527
	install-exec install-exec-am install-exec-recursive \
528
	install-hgincludeHEADERS install-info install-info-am \
545
	install-hgincludeHEADERS install-info install-info-am \
529
	install-info-recursive install-man install-recursive \
546
	install-man install-strip install-valPROGRAMS installcheck \
530
	install-strip install-valPROGRAMS installcheck installcheck-am \
547
	installcheck-am installdirs installdirs-am maintainer-clean \
531
	installdirs installdirs-am installdirs-recursive \
548
	maintainer-clean-generic maintainer-clean-recursive \
532
	maintainer-clean maintainer-clean-generic \
549
	mostlyclean mostlyclean-compile mostlyclean-generic \
533
	maintainer-clean-recursive mostlyclean mostlyclean-compile \
550
	mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
534
	mostlyclean-generic mostlyclean-recursive pdf pdf-am \
535
	pdf-recursive ps ps-am ps-recursive tags tags-recursive \
536
	uninstall uninstall-am uninstall-hgincludeHEADERS \
551
	uninstall uninstall-am uninstall-hgincludeHEADERS \
537
	uninstall-info-am uninstall-info-recursive uninstall-recursive \
552
	uninstall-info-am uninstall-valPROGRAMS
538
	uninstall-valPROGRAMS
553
539
554
555
all-local:
556
	mkdir -p $(inplacedir)
557
	-rm -f $(addprefix $(inplacedir)/,$(val_PROGRAMS))
558
	ln -f -s $(addprefix $(top_srcdir)/$(subdir)/,$(val_PROGRAMS)) $(inplacedir)
540
# Tell versions [3.59,3.63) of GNU make to not export all variables.
559
# Tell versions [3.59,3.63) of GNU make to not export all variables.
541
# Otherwise a system limit (for SysV at least) may be exceeded.
560
# Otherwise a system limit (for SysV at least) may be exceeded.
542
.NOEXPORT:
561
.NOEXPORT:
(-)valgrind-2.1.0/helgrind/docs/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/helgrind/docs/CVS/Entries (+4 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Thu Oct  3 10:07:33 2002//
2
/Makefile.am/1.2/Wed Nov 13 21:24:55 2002//
3
/hg_main.html/1.4/Fri Nov 14 17:47:53 2003//
4
D
(-)valgrind-2.1.0/helgrind/docs/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/helgrind/docs
(-)valgrind-2.1.0/helgrind/docs/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/helgrind/docs/Makefile.in (-38 / +64 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
21
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
23
top_builddir = ../..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
25
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
26
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
35
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
36
POST_UNINSTALL = :
38
host_triplet = @host@
37
host_triplet = @host@
38
subdir = helgrind/docs
39
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
40
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
41
am__aclocal_m4_deps = $(top_srcdir)/configure.in
42
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
43
	$(ACLOCAL_M4)
44
mkinstalldirs = $(mkdir_p)
45
CONFIG_HEADER = $(top_builddir)/config.h
46
CONFIG_CLEAN_FILES =
47
SOURCES =
48
DIST_SOURCES =
49
am__installdirs = $(DESTDIR)$(docdir)
50
docDATA_INSTALL = $(INSTALL_DATA)
51
DATA = $(doc_DATA)
52
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
53
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
54
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
55
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
106
SHELL = @SHELL@
93
STRIP = @STRIP@
107
STRIP = @STRIP@
94
VERSION = @VERSION@
108
VERSION = @VERSION@
109
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
110
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
111
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
112
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
138
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
139
localstatedir = @localstatedir@
125
mandir = @mandir@
140
mandir = @mandir@
141
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
142
oldincludedir = @oldincludedir@
127
prefix = @prefix@
143
prefix = @prefix@
128
program_transform_name = @program_transform_name@
144
program_transform_name = @program_transform_name@
Lines 131-162 Link Here
131
sysconfdir = @sysconfdir@
147
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
148
target_alias = @target_alias@
133
docdir = $(datadir)/doc/valgrind
149
docdir = $(datadir)/doc/valgrind
134
135
doc_DATA = hg_main.html
150
doc_DATA = hg_main.html
136
137
EXTRA_DIST = $(doc_DATA)
151
EXTRA_DIST = $(doc_DATA)
138
subdir = helgrind/docs
139
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
140
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
141
CONFIG_HEADER = $(top_builddir)/config.h
142
CONFIG_CLEAN_FILES =
143
DIST_SOURCES =
144
DATA = $(doc_DATA)
145
146
DIST_COMMON = Makefile.am Makefile.in
147
all: all-am
152
all: all-am
148
153
149
.SUFFIXES:
154
.SUFFIXES:
150
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
155
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
156
	@for dep in $?; do \
157
	  case '$(am__configure_deps)' in \
158
	    *$$dep*) \
159
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
160
		&& exit 0; \
161
	      exit 1;; \
162
	  esac; \
163
	done; \
164
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  helgrind/docs/Makefile'; \
151
	cd $(top_srcdir) && \
165
	cd $(top_srcdir) && \
152
	  $(AUTOMAKE) --gnu  helgrind/docs/Makefile
166
	  $(AUTOMAKE) --gnu  helgrind/docs/Makefile
153
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
167
.PRECIOUS: Makefile
154
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
168
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
169
	@case '$?' in \
170
	  *config.status*) \
171
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
172
	  *) \
173
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
174
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
175
	esac;
176
177
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
178
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
179
180
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
181
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
182
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
183
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
155
uninstall-info-am:
184
uninstall-info-am:
156
docDATA_INSTALL = $(INSTALL_DATA)
157
install-docDATA: $(doc_DATA)
185
install-docDATA: $(doc_DATA)
158
	@$(NORMAL_INSTALL)
186
	@$(NORMAL_INSTALL)
159
	$(mkinstalldirs) $(DESTDIR)$(docdir)
187
	$(mkdir_p) $(DESTDIR)$(docdir)
160
	@list='$(doc_DATA)'; for p in $$list; do \
188
	@list='$(doc_DATA)'; for p in $$list; do \
161
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
189
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
162
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
190
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
Lines 177-186 Link Here
177
ctags: CTAGS
205
ctags: CTAGS
178
CTAGS:
206
CTAGS:
179
207
180
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
181
182
top_distdir = ../..
183
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
184
208
185
distdir: $(DISTFILES)
209
distdir: $(DISTFILES)
186
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
210
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 194-200 Link Here
194
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
218
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
195
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
219
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
196
	    dir="/$$dir"; \
220
	    dir="/$$dir"; \
197
	    $(mkinstalldirs) "$(distdir)$$dir"; \
221
	    $(mkdir_p) "$(distdir)$$dir"; \
198
	  else \
222
	  else \
199
	    dir=''; \
223
	    dir=''; \
200
	  fi; \
224
	  fi; \
Lines 212-220 Link Here
212
check-am: all-am
236
check-am: all-am
213
check: check-am
237
check: check-am
214
all-am: Makefile $(DATA)
238
all-am: Makefile $(DATA)
215
216
installdirs:
239
installdirs:
217
	$(mkinstalldirs) $(DESTDIR)$(docdir)
240
	$(mkdir_p) $(DESTDIR)$(docdir)
218
install: install-am
241
install: install-am
219
install-exec: install-exec-am
242
install-exec: install-exec-am
220
install-data: install-data-am
243
install-data: install-data-am
Lines 226-232 Link Here
226
installcheck: installcheck-am
249
installcheck: installcheck-am
227
install-strip:
250
install-strip:
228
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
251
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
229
	  INSTALL_STRIP_FLAG=-s \
252
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
230
	  `test -z '$(STRIP)' || \
253
	  `test -z '$(STRIP)' || \
231
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
254
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
232
mostlyclean-generic:
255
mostlyclean-generic:
Lines 234-240 Link Here
234
clean-generic:
257
clean-generic:
235
258
236
distclean-generic:
259
distclean-generic:
237
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
260
	-rm -f $(CONFIG_CLEAN_FILES)
238
261
239
maintainer-clean-generic:
262
maintainer-clean-generic:
240
	@echo "This command is intended for maintainers to use"
263
	@echo "This command is intended for maintainers to use"
Lines 244-256 Link Here
244
clean-am: clean-generic mostlyclean-am
267
clean-am: clean-generic mostlyclean-am
245
268
246
distclean: distclean-am
269
distclean: distclean-am
247
270
	-rm -f Makefile
248
distclean-am: clean-am distclean-generic
271
distclean-am: clean-am distclean-generic
249
272
250
dvi: dvi-am
273
dvi: dvi-am
251
274
252
dvi-am:
275
dvi-am:
253
276
277
html: html-am
278
254
info: info-am
279
info: info-am
255
280
256
info-am:
281
info-am:
Lines 266-272 Link Here
266
installcheck-am:
291
installcheck-am:
267
292
268
maintainer-clean: maintainer-clean-am
293
maintainer-clean: maintainer-clean-am
269
294
	-rm -f Makefile
270
maintainer-clean-am: distclean-am maintainer-clean-generic
295
maintainer-clean-am: distclean-am maintainer-clean-generic
271
296
272
mostlyclean: mostlyclean-am
297
mostlyclean: mostlyclean-am
Lines 284-296 Link Here
284
uninstall-am: uninstall-docDATA uninstall-info-am
309
uninstall-am: uninstall-docDATA uninstall-info-am
285
310
286
.PHONY: all all-am check check-am clean clean-generic distclean \
311
.PHONY: all all-am check check-am clean clean-generic distclean \
287
	distclean-generic distdir dvi dvi-am info info-am install \
312
	distclean-generic distdir dvi dvi-am html html-am info info-am \
288
	install-am install-data install-data-am install-docDATA \
313
	install install-am install-data install-data-am \
289
	install-exec install-exec-am install-info install-info-am \
314
	install-docDATA install-exec install-exec-am install-info \
290
	install-man install-strip installcheck installcheck-am \
315
	install-info-am install-man install-strip installcheck \
291
	installdirs maintainer-clean maintainer-clean-generic \
316
	installcheck-am installdirs maintainer-clean \
292
	mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
317
	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
293
	uninstall-am uninstall-docDATA uninstall-info-am
318
	pdf-am ps ps-am uninstall uninstall-am uninstall-docDATA \
319
	uninstall-info-am
294
320
295
# Tell versions [3.59,3.63) of GNU make to not export all variables.
321
# Tell versions [3.59,3.63) of GNU make to not export all variables.
296
# Otherwise a system limit (for SysV at least) may be exceeded.
322
# Otherwise a system limit (for SysV at least) may be exceeded.
(-)valgrind-2.1.0/helgrind/helgrind.h (-1 / +1 lines)
Lines 11-17 Link Here
11
   This file is part of helgrind, a Valgrind tool for detecting
11
   This file is part of helgrind, a Valgrind tool for detecting
12
   data races in threaded programs.
12
   data races in threaded programs.
13
13
14
   Copyright (C) 2002-2003 Nicholas Nethercote.  All rights reserved.
14
   Copyright (C) 2002-2004 Nicholas Nethercote.  All rights reserved.
15
15
16
   Redistribution and use in source and binary forms, with or without
16
   Redistribution and use in source and binary forms, with or without
17
   modification, are permitted provided that the following conditions
17
   modification, are permitted provided that the following conditions
(-)valgrind-2.1.0/helgrind/hg_main.c (-41 / +29 lines)
Lines 8-14 Link Here
8
   This file is part of Helgrind, a Valgrind tool for detecting
8
   This file is part of Helgrind, a Valgrind tool for detecting
9
   data races in threaded programs.
9
   data races in threaded programs.
10
10
11
   Copyright (C) 2002-2003 Nicholas Nethercote
11
   Copyright (C) 2002-2004 Nicholas Nethercote
12
      njn25@cam.ac.uk
12
      njn25@cam.ac.uk
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 32-39 Link Here
32
#include "vg_skin.h"
32
#include "vg_skin.h"
33
#include "helgrind.h"
33
#include "helgrind.h"
34
34
35
VG_DETERMINE_INTERFACE_VERSION
36
37
static UInt n_eraser_warnings = 0;
35
static UInt n_eraser_warnings = 0;
38
static UInt n_lockorder_warnings = 0;
36
static UInt n_lockorder_warnings = 0;
39
37
Lines 498-504 Link Here
498
      although this isn't important, so the following assert is
496
      although this isn't important, so the following assert is
499
      spurious. (SSS: not true for ESecMaps -- they're 16 pages) */
497
      spurious. (SSS: not true for ESecMaps -- they're 16 pages) */
500
   sk_assert(0 == (sizeof(ESecMap) % VKI_BYTES_PER_PAGE));
498
   sk_assert(0 == (sizeof(ESecMap) % VKI_BYTES_PER_PAGE));
501
   map = VG_(get_memory_from_mmap)( sizeof(ESecMap), caller );
499
   map = (ESecMap *)VG_(shadow_alloc)(sizeof(ESecMap));
502
500
503
   for (i = 0; i < ESEC_MAP_WORDS; i++)
501
   for (i = 0; i < ESEC_MAP_WORDS; i++)
504
      map->swords[i] = virgin_sword;
502
      map->swords[i] = virgin_sword;
Lines 2002-2027 Link Here
2002
/*--- Machinery to support sanity checking                   ---*/
2000
/*--- Machinery to support sanity checking                   ---*/
2003
/*--------------------------------------------------------------*/
2001
/*--------------------------------------------------------------*/
2004
2002
2005
/* Check that nobody has spuriously claimed that the first or last 16
2006
   pages (64 KB) of address space have become accessible.  Failure of
2007
   the following do not per se indicate an internal consistency
2008
   problem, but they are so likely to that we really want to know
2009
   about it if so. */
2010
2011
Bool SK_(cheap_sanity_check) ( void )
2003
Bool SK_(cheap_sanity_check) ( void )
2012
{
2004
{
2013
   if (VGE_IS_DISTINGUISHED_SM(primary_map[0])
2005
   /* nothing useful we can rapidly check */
2014
       /* kludge: kernel drops a page up at top of address range for
2006
   return True;
2015
          magic "optimized syscalls", so we can no longer check the
2016
          highest page */
2017
       /* && VGE_IS_DISTINGUISHED_SM(primary_map[65535]) */
2018
      )
2019
      return True;
2020
   else
2021
      return False;
2022
}
2007
}
2023
2008
2024
2025
Bool SK_(expensive_sanity_check)(void)
2009
Bool SK_(expensive_sanity_check)(void)
2026
{
2010
{
2027
   Int i;
2011
   Int i;
Lines 3237-3243 Link Here
3237
   VG_(details_version)         (NULL);
3221
   VG_(details_version)         (NULL);
3238
   VG_(details_description)     ("a data race detector");
3222
   VG_(details_description)     ("a data race detector");
3239
   VG_(details_copyright_author)(
3223
   VG_(details_copyright_author)(
3240
      "Copyright (C) 2002-2003, and GNU GPL'd, by Nicholas Nethercote.");
3224
      "Copyright (C) 2002-2004, and GNU GPL'd, by Nicholas Nethercote.");
3241
   VG_(details_bug_reports_to)  (VG_BUGS_TO);
3225
   VG_(details_bug_reports_to)  (VG_BUGS_TO);
3242
   VG_(details_avg_translation_sizeB) ( 115 );
3226
   VG_(details_avg_translation_sizeB) ( 115 );
3243
3227
Lines 3246-3279 Link Here
3246
   VG_(needs_data_syms)();
3230
   VG_(needs_data_syms)();
3247
   VG_(needs_client_requests)();
3231
   VG_(needs_client_requests)();
3248
   VG_(needs_command_line_options)();
3232
   VG_(needs_command_line_options)();
3233
   VG_(needs_shadow_memory)();
3249
3234
3250
   VG_(track_new_mem_startup)      (& eraser_new_mem_startup);
3235
   VG_(init_new_mem_startup)      (& eraser_new_mem_startup);
3251
3236
3252
   /* stack ones not decided until VG_(post_clo_init)() */
3237
   /* stack ones not decided until VG_(post_clo_init)() */
3253
3238
3254
   VG_(track_new_mem_brk)          (& make_writable);
3239
   VG_(init_new_mem_brk)          (& make_writable);
3255
   VG_(track_new_mem_mmap)         (& eraser_new_mem_startup);
3240
   VG_(init_new_mem_mmap)         (& eraser_new_mem_startup);
3256
3241
3257
   VG_(track_change_mem_mprotect)  (& eraser_set_perms);
3242
   VG_(init_change_mem_mprotect)  (& eraser_set_perms);
3258
3243
3259
   VG_(track_ban_mem_stack)        (NULL);
3244
   VG_(init_ban_mem_stack)        (NULL);
3260
3245
3261
   VG_(track_die_mem_stack)        (NULL);
3246
   VG_(init_die_mem_stack)        (NULL);
3262
   VG_(track_die_mem_stack_signal) (NULL);
3247
   VG_(init_die_mem_stack_signal) (NULL);
3263
   VG_(track_die_mem_brk)          (NULL);
3248
   VG_(init_die_mem_brk)          (NULL);
3264
   VG_(track_die_mem_munmap)       (NULL);
3249
   VG_(init_die_mem_munmap)       (NULL);
3265
3250
3266
   VG_(track_pre_mem_read)         (& eraser_pre_mem_read);
3251
   VG_(init_pre_mem_read)         (& eraser_pre_mem_read);
3267
   VG_(track_pre_mem_read_asciiz)  (& eraser_pre_mem_read_asciiz);
3252
   VG_(init_pre_mem_read_asciiz)  (& eraser_pre_mem_read_asciiz);
3268
   VG_(track_pre_mem_write)        (& eraser_pre_mem_write);
3253
   VG_(init_pre_mem_write)        (& eraser_pre_mem_write);
3269
   VG_(track_post_mem_write)       (NULL);
3254
   VG_(init_post_mem_write)       (NULL);
3270
3255
3271
   VG_(track_post_thread_create)   (& hg_thread_create);
3256
   VG_(init_post_thread_create)   (& hg_thread_create);
3272
   VG_(track_post_thread_join)     (& hg_thread_join);
3257
   VG_(init_post_thread_join)     (& hg_thread_join);
3273
3258
3274
   VG_(track_pre_mutex_lock)       (& eraser_pre_mutex_lock);
3259
   VG_(init_pre_mutex_lock)       (& eraser_pre_mutex_lock);
3275
   VG_(track_post_mutex_lock)      (& eraser_post_mutex_lock);
3260
   VG_(init_post_mutex_lock)      (& eraser_post_mutex_lock);
3276
   VG_(track_post_mutex_unlock)    (& eraser_post_mutex_unlock);
3261
   VG_(init_post_mutex_unlock)    (& eraser_post_mutex_unlock);
3277
3262
3278
   VG_(register_compact_helper)((Addr) & eraser_mem_help_read_1);
3263
   VG_(register_compact_helper)((Addr) & eraser_mem_help_read_1);
3279
   VG_(register_compact_helper)((Addr) & eraser_mem_help_read_2);
3264
   VG_(register_compact_helper)((Addr) & eraser_mem_help_read_2);
Lines 3392-3399 Link Here
3392
   else
3377
   else
3393
      stack_tracker = & eraser_new_mem_stack;
3378
      stack_tracker = & eraser_new_mem_stack;
3394
3379
3395
   VG_(track_new_mem_stack)        (stack_tracker);
3380
   VG_(init_new_mem_stack)        (stack_tracker);
3396
   VG_(track_new_mem_stack_signal) (stack_tracker);
3381
   VG_(init_new_mem_stack_signal) (stack_tracker);
3397
}
3382
}
3398
3383
3399
3384
Lines 3417-3422 Link Here
3417
		  ((stk_ld+stk_st)*100) / (stk_ld + stk_st + nonstk_ld + nonstk_st));
3402
		  ((stk_ld+stk_st)*100) / (stk_ld + stk_st + nonstk_ld + nonstk_st));
3418
}
3403
}
3419
3404
3405
/* Uses a 1:1 mapping */
3406
VG_DETERMINE_INTERFACE_VERSION(SK_(pre_clo_init), 1.0)
3407
3420
/*--------------------------------------------------------------------*/
3408
/*--------------------------------------------------------------------*/
3421
/*--- end                                                hg_main.c ---*/
3409
/*--- end                                                hg_main.c ---*/
3422
/*--------------------------------------------------------------------*/
3410
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/helgrind/tests/.cvsignore (+14 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
3
allok
4
allok.stderr.diff
5
allok.stderr.out
6
deadlock
7
deadlock.stderr.out
8
deadlock.stdout.out
9
inherit
10
race
11
race2
12
readshared
13
inherit.stderr.diff
14
inherit.stderr.out
(-)valgrind-2.1.0/helgrind/tests/CVS/Entries (+22 lines)
Line 0 Link Here
1
/.cvsignore/1.3/Thu Nov 27 11:44:48 2003//
2
/Makefile.am/1.4/Wed Oct 15 22:15:37 2003//
3
/allok.c/1.1/Thu Oct 16 06:09:41 2003//
4
/allok.stderr.exp/1.1/Wed Oct 15 22:15:37 2003//
5
/allok.vgtest/1.1/Wed Oct 15 22:15:37 2003//
6
/deadlock.c/1.1/Thu Oct 16 06:09:41 2003//
7
/deadlock.stderr.exp/1.5/Mon Dec 15 09:00:21 2003//
8
/deadlock.vgtest/1.1/Wed Oct 15 22:15:37 2003//
9
/filter_stderr/1.4/Thu Nov  6 11:34:52 2003//
10
/inherit.c/1.1/Thu Oct 16 06:09:41 2003//
11
/inherit.stderr.exp/1.3/Sat Oct 18 22:27:10 2003//
12
/inherit.vgtest/1.1/Wed Oct 15 22:15:37 2003//
13
/race.c/1.1/Thu Oct 16 06:09:41 2003//
14
/race.stderr.exp/1.4/Thu Nov 13 17:53:43 2003//
15
/race.vgtest/1.1/Wed Oct 15 22:15:37 2003//
16
/race2.c/1.1/Thu Oct 16 06:09:41 2003//
17
/race2.stderr.exp/1.4/Thu Nov 13 17:53:43 2003//
18
/race2.vgtest/1.1/Wed Oct 15 22:15:37 2003//
19
/readshared.c/1.1/Thu Oct 16 06:09:41 2003//
20
/readshared.stderr.exp/1.1/Wed Oct 15 22:15:37 2003//
21
/readshared.vgtest/1.1/Wed Oct 15 22:15:37 2003//
22
D
(-)valgrind-2.1.0/helgrind/tests/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/helgrind/tests
(-)valgrind-2.1.0/helgrind/tests/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/helgrind/tests/Makefile.in (-112 / +113 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 14-19 Link Here
14
14
15
@SET_MAKE@
15
@SET_MAKE@
16
16
17
SOURCES = $(allok_SOURCES) $(deadlock_SOURCES) $(inherit_SOURCES) $(race_SOURCES) $(race2_SOURCES) $(readshared_SOURCES)
18
17
srcdir = @srcdir@
19
srcdir = @srcdir@
18
top_srcdir = @top_srcdir@
20
top_srcdir = @top_srcdir@
19
VPATH = @srcdir@
21
VPATH = @srcdir@
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
23
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
24
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
25
top_builddir = ../..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
27
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
28
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
37
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
38
POST_UNINSTALL = :
38
host_triplet = @host@
39
host_triplet = @host@
40
check_PROGRAMS = allok$(EXEEXT) deadlock$(EXEEXT) inherit$(EXEEXT) \
41
	race$(EXEEXT) race2$(EXEEXT) readshared$(EXEEXT)
42
subdir = helgrind/tests
43
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
44
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
45
am__aclocal_m4_deps = $(top_srcdir)/configure.in
46
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
47
	$(ACLOCAL_M4)
48
mkinstalldirs = $(mkdir_p)
49
CONFIG_HEADER = $(top_builddir)/config.h
50
CONFIG_CLEAN_FILES =
51
am_allok_OBJECTS = allok.$(OBJEXT)
52
allok_OBJECTS = $(am_allok_OBJECTS)
53
allok_LDADD = $(LDADD)
54
allok_DEPENDENCIES =
55
am_deadlock_OBJECTS = deadlock.$(OBJEXT)
56
deadlock_OBJECTS = $(am_deadlock_OBJECTS)
57
deadlock_LDADD = $(LDADD)
58
deadlock_DEPENDENCIES =
59
am_inherit_OBJECTS = inherit.$(OBJEXT)
60
inherit_OBJECTS = $(am_inherit_OBJECTS)
61
inherit_LDADD = $(LDADD)
62
inherit_DEPENDENCIES =
63
am_race_OBJECTS = race.$(OBJEXT)
64
race_OBJECTS = $(am_race_OBJECTS)
65
race_LDADD = $(LDADD)
66
race_DEPENDENCIES =
67
am_race2_OBJECTS = race2.$(OBJEXT)
68
race2_OBJECTS = $(am_race2_OBJECTS)
69
race2_LDADD = $(LDADD)
70
race2_DEPENDENCIES =
71
am_readshared_OBJECTS = readshared.$(OBJEXT)
72
readshared_OBJECTS = $(am_readshared_OBJECTS)
73
readshared_LDADD = $(LDADD)
74
readshared_DEPENDENCIES =
75
SCRIPTS = $(noinst_SCRIPTS)
76
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
77
depcomp = $(SHELL) $(top_srcdir)/depcomp
78
am__depfiles_maybe = depfiles
79
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/allok.Po ./$(DEPDIR)/deadlock.Po \
80
@AMDEP_TRUE@	./$(DEPDIR)/inherit.Po ./$(DEPDIR)/race.Po \
81
@AMDEP_TRUE@	./$(DEPDIR)/race2.Po ./$(DEPDIR)/readshared.Po
82
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
83
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
84
CCLD = $(CC)
85
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
86
SOURCES = $(allok_SOURCES) $(deadlock_SOURCES) $(inherit_SOURCES) \
87
	$(race_SOURCES) $(race2_SOURCES) $(readshared_SOURCES)
88
DIST_SOURCES = $(allok_SOURCES) $(deadlock_SOURCES) $(inherit_SOURCES) \
89
	$(race_SOURCES) $(race2_SOURCES) $(readshared_SOURCES)
90
ETAGS = etags
91
CTAGS = ctags
92
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
93
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
94
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
95
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
146
SHELL = @SHELL@
93
STRIP = @STRIP@
147
STRIP = @STRIP@
94
VERSION = @VERSION@
148
VERSION = @VERSION@
149
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
150
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
151
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
152
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
178
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
179
localstatedir = @localstatedir@
125
mandir = @mandir@
180
mandir = @mandir@
181
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
182
oldincludedir = @oldincludedir@
127
prefix = @prefix@
183
prefix = @prefix@
128
program_transform_name = @program_transform_name@
184
program_transform_name = @program_transform_name@
Lines 131-137 Link Here
131
sysconfdir = @sysconfdir@
187
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
188
target_alias = @target_alias@
133
noinst_SCRIPTS = filter_stderr
189
noinst_SCRIPTS = filter_stderr
134
135
EXTRA_DIST = $(noinst_SCRIPTS) \
190
EXTRA_DIST = $(noinst_SCRIPTS) \
136
	allok.stderr.exp allok.vgtest		\
191
	allok.stderr.exp allok.vgtest		\
137
	deadlock.stderr.exp deadlock.vgtest	\
192
	deadlock.stderr.exp deadlock.vgtest	\
Lines 140-150 Link Here
140
	race2.stderr.exp race2.vgtest		\
195
	race2.stderr.exp race2.vgtest		\
141
	readshared.stderr.exp readshared.vgtest
196
	readshared.stderr.exp readshared.vgtest
142
197
143
144
check_PROGRAMS = \
145
	allok deadlock inherit race race2 readshared
146
147
148
allok_SOURCES = allok.c
198
allok_SOURCES = allok.c
149
deadlock_SOURCES = deadlock.c
199
deadlock_SOURCES = deadlock.c
150
inherit_SOURCES = inherit.c
200
inherit_SOURCES = inherit.c
Lines 155-224 Link Here
155
# force -gstabs, because we don't print symaddr for DWARF yet
205
# force -gstabs, because we don't print symaddr for DWARF yet
156
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -gstabs
206
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -gstabs
157
LDADD = -lpthread
207
LDADD = -lpthread
158
subdir = helgrind/tests
159
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
160
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
161
CONFIG_HEADER = $(top_builddir)/config.h
162
CONFIG_CLEAN_FILES =
163
check_PROGRAMS = allok$(EXEEXT) deadlock$(EXEEXT) inherit$(EXEEXT) \
164
	race$(EXEEXT) race2$(EXEEXT) readshared$(EXEEXT)
165
am_allok_OBJECTS = allok.$(OBJEXT)
166
allok_OBJECTS = $(am_allok_OBJECTS)
167
allok_LDADD = $(LDADD)
168
allok_DEPENDENCIES =
169
allok_LDFLAGS =
170
am_deadlock_OBJECTS = deadlock.$(OBJEXT)
171
deadlock_OBJECTS = $(am_deadlock_OBJECTS)
172
deadlock_LDADD = $(LDADD)
173
deadlock_DEPENDENCIES =
174
deadlock_LDFLAGS =
175
am_inherit_OBJECTS = inherit.$(OBJEXT)
176
inherit_OBJECTS = $(am_inherit_OBJECTS)
177
inherit_LDADD = $(LDADD)
178
inherit_DEPENDENCIES =
179
inherit_LDFLAGS =
180
am_race_OBJECTS = race.$(OBJEXT)
181
race_OBJECTS = $(am_race_OBJECTS)
182
race_LDADD = $(LDADD)
183
race_DEPENDENCIES =
184
race_LDFLAGS =
185
am_race2_OBJECTS = race2.$(OBJEXT)
186
race2_OBJECTS = $(am_race2_OBJECTS)
187
race2_LDADD = $(LDADD)
188
race2_DEPENDENCIES =
189
race2_LDFLAGS =
190
am_readshared_OBJECTS = readshared.$(OBJEXT)
191
readshared_OBJECTS = $(am_readshared_OBJECTS)
192
readshared_LDADD = $(LDADD)
193
readshared_DEPENDENCIES =
194
readshared_LDFLAGS =
195
SCRIPTS = $(noinst_SCRIPTS)
196
197
198
DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
199
depcomp = $(SHELL) $(top_srcdir)/depcomp
200
am__depfiles_maybe = depfiles
201
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/allok.Po ./$(DEPDIR)/deadlock.Po \
202
@AMDEP_TRUE@	./$(DEPDIR)/inherit.Po ./$(DEPDIR)/race.Po \
203
@AMDEP_TRUE@	./$(DEPDIR)/race2.Po ./$(DEPDIR)/readshared.Po
204
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
205
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
206
CCLD = $(CC)
207
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
208
DIST_SOURCES = $(allok_SOURCES) $(deadlock_SOURCES) $(inherit_SOURCES) \
209
	$(race_SOURCES) $(race2_SOURCES) $(readshared_SOURCES)
210
DIST_COMMON = Makefile.am Makefile.in
211
SOURCES = $(allok_SOURCES) $(deadlock_SOURCES) $(inherit_SOURCES) $(race_SOURCES) $(race2_SOURCES) $(readshared_SOURCES)
212
213
all: all-am
208
all: all-am
214
209
215
.SUFFIXES:
210
.SUFFIXES:
216
.SUFFIXES: .c .o .obj
211
.SUFFIXES: .c .o .obj
217
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
212
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
213
	@for dep in $?; do \
214
	  case '$(am__configure_deps)' in \
215
	    *$$dep*) \
216
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
217
		&& exit 0; \
218
	      exit 1;; \
219
	  esac; \
220
	done; \
221
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  helgrind/tests/Makefile'; \
218
	cd $(top_srcdir) && \
222
	cd $(top_srcdir) && \
219
	  $(AUTOMAKE) --gnu  helgrind/tests/Makefile
223
	  $(AUTOMAKE) --gnu  helgrind/tests/Makefile
220
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
224
.PRECIOUS: Makefile
221
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
225
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
226
	@case '$?' in \
227
	  *config.status*) \
228
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
229
	  *) \
230
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
231
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
232
	esac;
233
234
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
235
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
236
237
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
238
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
239
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
240
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
222
241
223
clean-checkPROGRAMS:
242
clean-checkPROGRAMS:
224
	-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
243
	-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
Lines 242-248 Link Here
242
	$(LINK) $(readshared_LDFLAGS) $(readshared_OBJECTS) $(readshared_LDADD) $(LIBS)
261
	$(LINK) $(readshared_LDFLAGS) $(readshared_OBJECTS) $(readshared_LDADD) $(LIBS)
243
262
244
mostlyclean-compile:
263
mostlyclean-compile:
245
	-rm -f *.$(OBJEXT) core *.core
264
	-rm -f *.$(OBJEXT)
246
265
247
distclean-compile:
266
distclean-compile:
248
	-rm -f *.tab.c
267
	-rm -f *.tab.c
Lines 254-293 Link Here
254
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/race2.Po@am__quote@
273
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/race2.Po@am__quote@
255
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readshared.Po@am__quote@
274
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readshared.Po@am__quote@
256
275
257
distclean-depend:
258
	-rm -rf ./$(DEPDIR)
259
260
.c.o:
276
.c.o:
261
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
277
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
262
@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
278
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
263
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
264
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
265
@am__fastdepCC_TRUE@	fi
266
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
279
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
267
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
280
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
268
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
281
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
269
@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
282
@am__fastdepCC_FALSE@	$(COMPILE) -c $<
270
283
271
.c.obj:
284
.c.obj:
272
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
285
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
273
@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
286
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
274
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
275
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
276
@am__fastdepCC_TRUE@	fi
277
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
287
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
278
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
288
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
279
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
289
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
280
@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
290
@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
281
uninstall-info-am:
291
uninstall-info-am:
282
292
283
ETAGS = etags
284
ETAGSFLAGS =
285
286
CTAGS = ctags
287
CTAGSFLAGS =
288
289
tags: TAGS
290
291
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
293
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
292
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
294
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
293
	unique=`for i in $$list; do \
295
	unique=`for i in $$list; do \
Lines 296-301 Link Here
296
	  $(AWK) '    { files[$$0] = 1; } \
298
	  $(AWK) '    { files[$$0] = 1; } \
297
	       END { for (i in files) print i; }'`; \
299
	       END { for (i in files) print i; }'`; \
298
	mkid -fID $$unique
300
	mkid -fID $$unique
301
tags: TAGS
299
302
300
TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
303
TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
301
		$(TAGS_FILES) $(LISP)
304
		$(TAGS_FILES) $(LISP)
Lines 310-316 Link Here
310
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
313
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
311
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
314
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
312
	     $$tags $$unique
315
	     $$tags $$unique
313
314
ctags: CTAGS
316
ctags: CTAGS
315
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
317
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
316
		$(TAGS_FILES) $(LISP)
318
		$(TAGS_FILES) $(LISP)
Lines 333-342 Link Here
333
335
334
distclean-tags:
336
distclean-tags:
335
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
337
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
336
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
337
338
top_distdir = ../..
339
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
340
338
341
distdir: $(DISTFILES)
339
distdir: $(DISTFILES)
342
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
340
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 350-356 Link Here
350
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
348
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
351
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
349
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
352
	    dir="/$$dir"; \
350
	    dir="/$$dir"; \
353
	    $(mkinstalldirs) "$(distdir)$$dir"; \
351
	    $(mkdir_p) "$(distdir)$$dir"; \
354
	  else \
352
	  else \
355
	    dir=''; \
353
	    dir=''; \
356
	  fi; \
354
	  fi; \
Lines 369-375 Link Here
369
	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
367
	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
370
check: check-am
368
check: check-am
371
all-am: Makefile $(SCRIPTS)
369
all-am: Makefile $(SCRIPTS)
372
373
installdirs:
370
installdirs:
374
install: install-am
371
install: install-am
375
install-exec: install-exec-am
372
install-exec: install-exec-am
Lines 382-388 Link Here
382
installcheck: installcheck-am
379
installcheck: installcheck-am
383
install-strip:
380
install-strip:
384
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
381
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
385
	  INSTALL_STRIP_FLAG=-s \
382
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
386
	  `test -z '$(STRIP)' || \
383
	  `test -z '$(STRIP)' || \
387
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
384
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
388
mostlyclean-generic:
385
mostlyclean-generic:
Lines 390-396 Link Here
390
clean-generic:
387
clean-generic:
391
388
392
distclean-generic:
389
distclean-generic:
393
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
390
	-rm -f $(CONFIG_CLEAN_FILES)
394
391
395
maintainer-clean-generic:
392
maintainer-clean-generic:
396
	@echo "This command is intended for maintainers to use"
393
	@echo "This command is intended for maintainers to use"
Lines 400-413 Link Here
400
clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am
397
clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am
401
398
402
distclean: distclean-am
399
distclean: distclean-am
403
400
	-rm -rf ./$(DEPDIR)
404
distclean-am: clean-am distclean-compile distclean-depend \
401
	-rm -f Makefile
405
	distclean-generic distclean-tags
402
distclean-am: clean-am distclean-compile distclean-generic \
403
	distclean-tags
406
404
407
dvi: dvi-am
405
dvi: dvi-am
408
406
409
dvi-am:
407
dvi-am:
410
408
409
html: html-am
410
411
info: info-am
411
info: info-am
412
412
413
info-am:
413
info-am:
Lines 423-429 Link Here
423
installcheck-am:
423
installcheck-am:
424
424
425
maintainer-clean: maintainer-clean-am
425
maintainer-clean: maintainer-clean-am
426
426
	-rm -rf ./$(DEPDIR)
427
	-rm -f Makefile
427
maintainer-clean-am: distclean-am maintainer-clean-generic
428
maintainer-clean-am: distclean-am maintainer-clean-generic
428
429
429
mostlyclean: mostlyclean-am
430
mostlyclean: mostlyclean-am
Lines 440-452 Link Here
440
441
441
uninstall-am: uninstall-info-am
442
uninstall-am: uninstall-info-am
442
443
443
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-checkPROGRAMS \
444
.PHONY: CTAGS GTAGS all all-am check check-am clean \
444
	clean-generic ctags distclean distclean-compile \
445
	clean-checkPROGRAMS clean-generic ctags distclean \
445
	distclean-depend distclean-generic distclean-tags distdir dvi \
446
	distclean-compile distclean-generic distclean-tags distdir dvi \
446
	dvi-am info info-am install install-am install-data \
447
	dvi-am html html-am info info-am install install-am \
447
	install-data-am install-exec install-exec-am install-info \
448
	install-data install-data-am install-exec install-exec-am \
448
	install-info-am install-man install-strip installcheck \
449
	install-info install-info-am install-man install-strip \
449
	installcheck-am installdirs maintainer-clean \
450
	installcheck installcheck-am installdirs maintainer-clean \
450
	maintainer-clean-generic mostlyclean mostlyclean-compile \
451
	maintainer-clean-generic mostlyclean mostlyclean-compile \
451
	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
452
	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
452
	uninstall-am uninstall-info-am
453
	uninstall-am uninstall-info-am
(-)valgrind-2.1.0/helgrind/tests/deadlock.stderr.exp (-2 / +2 lines)
Lines 1-13 Link Here
1
1
2
Thread 3:
2
Thread 3:
3
Mutex 0x........(m1) locked in inconsistent order
3
Mutex 0x........(m1) locked in inconsistent order
4
   at 0x........: __pthread_mutex_lock (vg_libpthread.c:...)
4
   at 0x........: pthread_mutex_lock (vg_libpthread.c:...)
5
   by 0x........: t2 (deadlock.c:20)
5
   by 0x........: t2 (deadlock.c:20)
6
   by 0x........: thread_wrapper (vg_libpthread.c:...)
6
   by 0x........: thread_wrapper (vg_libpthread.c:...)
7
   by 0x........: do__quit (vg_scheduler.c:...)
7
   by 0x........: do__quit (vg_scheduler.c:...)
8
 while holding locks 0x........(m2)
8
 while holding locks 0x........(m2)
9
 0x........(m2) last locked at
9
 0x........(m2) last locked at
10
   at 0x........: __pthread_mutex_lock (vg_libpthread.c:...)
10
   at 0x........: pthread_mutex_lock (vg_libpthread.c:...)
11
   by 0x........: t2 (deadlock.c:19)
11
   by 0x........: t2 (deadlock.c:19)
12
   by 0x........: thread_wrapper (vg_libpthread.c:...)
12
   by 0x........: thread_wrapper (vg_libpthread.c:...)
13
   by 0x........: do__quit (vg_scheduler.c:...)
13
   by 0x........: do__quit (vg_scheduler.c:...)
(-)valgrind-2.1.0/include/.cvsignore (+3 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
3
vg_skin.h
(-)valgrind-2.1.0/include/CVS/Entries (+8 lines)
Line 0 Link Here
1
/.cvsignore/1.2/Wed Dec 17 13:28:12 2003//
2
/Makefile.am/1.5/Tue Dec 16 02:05:14 2003//
3
/valgrind.h/1.25/Wed Jan 21 15:08:04 2004//
4
/vg_constants_skin.h/1.7/Sun Jan  4 16:43:22 2004//
5
/vg_kerneliface.h/1.13/Tue Feb 10 23:44:15 2004//
6
/vg_profile.c/1.11/Wed Jan 21 15:08:04 2004//
7
/vg_skin.h.base/1.12/Wed Feb 11 23:33:28 2004//
8
D
(-)valgrind-2.1.0/include/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/include
(-)valgrind-2.1.0/include/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/include/Makefile.am (-1 / +12 lines)
Lines 1-5 Link Here
1
EXTRA_DIST = \
1
EXTRA_DIST = \
2
	vg_profile.c
2
	vg_profile.c \
3
	vg_skin.h.base
3
4
4
incincdir = $(includedir)/valgrind
5
incincdir = $(includedir)/valgrind
5
6
Lines 8-10 Link Here
8
	vg_constants_skin.h \
9
	vg_constants_skin.h \
9
	vg_skin.h \
10
	vg_skin.h \
10
	vg_kerneliface.h
11
	vg_kerneliface.h
12
13
BUILT_SOURCES = vg_skin.h
14
CLEANFILES = vg_skin.h
15
16
vg_skin.h: $(srcdir)/vg_skin.h.base \
17
	 $(top_srcdir)/coregrind/gen_toolint.pl $(top_srcdir)/coregrind/toolfuncs.def
18
	rm -f $@
19
	cat $(srcdir)/vg_skin.h.base > $@
20
	$(PERL) $(top_srcdir)/coregrind/gen_toolint.pl toolproto < $(top_srcdir)/coregrind/toolfuncs.def >> $@ || rm -f $@
21
	$(PERL) $(top_srcdir)/coregrind/gen_toolint.pl initproto < $(top_srcdir)/coregrind/toolfuncs.def >> $@ || rm -f $@
(-)valgrind-2.1.0/include/Makefile.in (-54 / +89 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
21
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ..
23
top_builddir = ..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
25
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
26
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
35
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
36
POST_UNINSTALL = :
38
host_triplet = @host@
37
host_triplet = @host@
38
subdir = include
39
DIST_COMMON = $(incinc_HEADERS) $(srcdir)/Makefile.am \
40
	$(srcdir)/Makefile.in
41
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
42
am__aclocal_m4_deps = $(top_srcdir)/configure.in
43
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
44
	$(ACLOCAL_M4)
45
mkinstalldirs = $(mkdir_p)
46
CONFIG_HEADER = $(top_builddir)/config.h
47
CONFIG_CLEAN_FILES =
48
SOURCES =
49
DIST_SOURCES =
50
am__installdirs = $(DESTDIR)$(incincdir)
51
incincHEADERS_INSTALL = $(INSTALL_HEADER)
52
HEADERS = $(incinc_HEADERS)
53
ETAGS = etags
54
CTAGS = ctags
55
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
56
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
57
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
58
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
109
SHELL = @SHELL@
93
STRIP = @STRIP@
110
STRIP = @STRIP@
94
VERSION = @VERSION@
111
VERSION = @VERSION@
112
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
113
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
114
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
115
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
141
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
142
localstatedir = @localstatedir@
125
mandir = @mandir@
143
mandir = @mandir@
144
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
145
oldincludedir = @oldincludedir@
127
prefix = @prefix@
146
prefix = @prefix@
128
program_transform_name = @program_transform_name@
147
program_transform_name = @program_transform_name@
Lines 131-169 Link Here
131
sysconfdir = @sysconfdir@
150
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
151
target_alias = @target_alias@
133
EXTRA_DIST = \
152
EXTRA_DIST = \
134
	vg_profile.c
153
	vg_profile.c \
135
154
	vg_skin.h.base
136
155
137
incincdir = $(includedir)/valgrind
156
incincdir = $(includedir)/valgrind
138
139
incinc_HEADERS = \
157
incinc_HEADERS = \
140
	valgrind.h \
158
	valgrind.h \
141
	vg_constants_skin.h \
159
	vg_constants_skin.h \
142
	vg_skin.h \
160
	vg_skin.h \
143
	vg_kerneliface.h
161
	vg_kerneliface.h
144
162
145
subdir = include
163
BUILT_SOURCES = vg_skin.h
146
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
164
CLEANFILES = vg_skin.h
147
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
165
all: $(BUILT_SOURCES)
148
CONFIG_HEADER = $(top_builddir)/config.h
166
	$(MAKE) $(AM_MAKEFLAGS) all-am
149
CONFIG_CLEAN_FILES =
150
DIST_SOURCES =
151
HEADERS = $(incinc_HEADERS)
152
153
DIST_COMMON = $(incinc_HEADERS) Makefile.am Makefile.in
154
all: all-am
155
167
156
.SUFFIXES:
168
.SUFFIXES:
157
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
169
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
170
	@for dep in $?; do \
171
	  case '$(am__configure_deps)' in \
172
	    *$$dep*) \
173
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
174
		&& exit 0; \
175
	      exit 1;; \
176
	  esac; \
177
	done; \
178
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  include/Makefile'; \
158
	cd $(top_srcdir) && \
179
	cd $(top_srcdir) && \
159
	  $(AUTOMAKE) --gnu  include/Makefile
180
	  $(AUTOMAKE) --gnu  include/Makefile
160
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
181
.PRECIOUS: Makefile
161
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
182
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
183
	@case '$?' in \
184
	  *config.status*) \
185
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
186
	  *) \
187
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
188
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
189
	esac;
190
191
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
192
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
193
194
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
195
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
196
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
197
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
162
uninstall-info-am:
198
uninstall-info-am:
163
incincHEADERS_INSTALL = $(INSTALL_HEADER)
164
install-incincHEADERS: $(incinc_HEADERS)
199
install-incincHEADERS: $(incinc_HEADERS)
165
	@$(NORMAL_INSTALL)
200
	@$(NORMAL_INSTALL)
166
	$(mkinstalldirs) $(DESTDIR)$(incincdir)
201
	$(mkdir_p) $(DESTDIR)$(incincdir)
167
	@list='$(incinc_HEADERS)'; for p in $$list; do \
202
	@list='$(incinc_HEADERS)'; for p in $$list; do \
168
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
203
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
169
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
204
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
Lines 179-192 Link Here
179
	  rm -f $(DESTDIR)$(incincdir)/$$f; \
214
	  rm -f $(DESTDIR)$(incincdir)/$$f; \
180
	done
215
	done
181
216
182
ETAGS = etags
183
ETAGSFLAGS =
184
185
CTAGS = ctags
186
CTAGSFLAGS =
187
188
tags: TAGS
189
190
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
217
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
191
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
218
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
192
	unique=`for i in $$list; do \
219
	unique=`for i in $$list; do \
Lines 195-200 Link Here
195
	  $(AWK) '    { files[$$0] = 1; } \
222
	  $(AWK) '    { files[$$0] = 1; } \
196
	       END { for (i in files) print i; }'`; \
223
	       END { for (i in files) print i; }'`; \
197
	mkid -fID $$unique
224
	mkid -fID $$unique
225
tags: TAGS
198
226
199
TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
227
TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
200
		$(TAGS_FILES) $(LISP)
228
		$(TAGS_FILES) $(LISP)
Lines 209-215 Link Here
209
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
237
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
210
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
238
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
211
	     $$tags $$unique
239
	     $$tags $$unique
212
213
ctags: CTAGS
240
ctags: CTAGS
214
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
241
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
215
		$(TAGS_FILES) $(LISP)
242
		$(TAGS_FILES) $(LISP)
Lines 232-241 Link Here
232
259
233
distclean-tags:
260
distclean-tags:
234
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
261
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
235
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
236
237
top_distdir = ..
238
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
239
262
240
distdir: $(DISTFILES)
263
distdir: $(DISTFILES)
241
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
264
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 249-255 Link Here
249
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
272
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
250
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
273
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
251
	    dir="/$$dir"; \
274
	    dir="/$$dir"; \
252
	    $(mkinstalldirs) "$(distdir)$$dir"; \
275
	    $(mkdir_p) "$(distdir)$$dir"; \
253
	  else \
276
	  else \
254
	    dir=''; \
277
	    dir=''; \
255
	  fi; \
278
	  fi; \
Lines 265-276 Link Here
265
	  fi; \
288
	  fi; \
266
	done
289
	done
267
check-am: all-am
290
check-am: all-am
268
check: check-am
291
check: $(BUILT_SOURCES)
292
	$(MAKE) $(AM_MAKEFLAGS) check-am
269
all-am: Makefile $(HEADERS)
293
all-am: Makefile $(HEADERS)
270
271
installdirs:
294
installdirs:
272
	$(mkinstalldirs) $(DESTDIR)$(incincdir)
295
	$(mkdir_p) $(DESTDIR)$(incincdir)
273
install: install-am
296
install: $(BUILT_SOURCES)
297
	$(MAKE) $(AM_MAKEFLAGS) install-am
274
install-exec: install-exec-am
298
install-exec: install-exec-am
275
install-data: install-data-am
299
install-data: install-data-am
276
uninstall: uninstall-am
300
uninstall: uninstall-am
Lines 281-311 Link Here
281
installcheck: installcheck-am
305
installcheck: installcheck-am
282
install-strip:
306
install-strip:
283
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
307
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
284
	  INSTALL_STRIP_FLAG=-s \
308
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
285
	  `test -z '$(STRIP)' || \
309
	  `test -z '$(STRIP)' || \
286
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
310
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
287
mostlyclean-generic:
311
mostlyclean-generic:
288
312
289
clean-generic:
313
clean-generic:
314
	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
290
315
291
distclean-generic:
316
distclean-generic:
292
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
317
	-rm -f $(CONFIG_CLEAN_FILES)
293
318
294
maintainer-clean-generic:
319
maintainer-clean-generic:
295
	@echo "This command is intended for maintainers to use"
320
	@echo "This command is intended for maintainers to use"
296
	@echo "it deletes files that may require special tools to rebuild."
321
	@echo "it deletes files that may require special tools to rebuild."
322
	-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
297
clean: clean-am
323
clean: clean-am
298
324
299
clean-am: clean-generic mostlyclean-am
325
clean-am: clean-generic mostlyclean-am
300
326
301
distclean: distclean-am
327
distclean: distclean-am
302
328
	-rm -f Makefile
303
distclean-am: clean-am distclean-generic distclean-tags
329
distclean-am: clean-am distclean-generic distclean-tags
304
330
305
dvi: dvi-am
331
dvi: dvi-am
306
332
307
dvi-am:
333
dvi-am:
308
334
335
html: html-am
336
309
info: info-am
337
info: info-am
310
338
311
info-am:
339
info-am:
Lines 321-327 Link Here
321
installcheck-am:
349
installcheck-am:
322
350
323
maintainer-clean: maintainer-clean-am
351
maintainer-clean: maintainer-clean-am
324
352
	-rm -f Makefile
325
maintainer-clean-am: distclean-am maintainer-clean-generic
353
maintainer-clean-am: distclean-am maintainer-clean-generic
326
354
327
mostlyclean: mostlyclean-am
355
mostlyclean: mostlyclean-am
Lines 338-353 Link Here
338
366
339
uninstall-am: uninstall-incincHEADERS uninstall-info-am
367
uninstall-am: uninstall-incincHEADERS uninstall-info-am
340
368
341
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic ctags \
369
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
342
	distclean distclean-generic distclean-tags distdir dvi dvi-am \
370
	ctags distclean distclean-generic distclean-tags distdir dvi \
343
	info info-am install install-am install-data install-data-am \
371
	dvi-am html html-am info info-am install install-am \
344
	install-exec install-exec-am install-incincHEADERS install-info \
372
	install-data install-data-am install-exec install-exec-am \
345
	install-info-am install-man install-strip installcheck \
373
	install-incincHEADERS install-info install-info-am install-man \
346
	installcheck-am installdirs maintainer-clean \
374
	install-strip installcheck installcheck-am installdirs \
347
	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
375
	maintainer-clean maintainer-clean-generic mostlyclean \
348
	pdf-am ps ps-am tags uninstall uninstall-am \
376
	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
349
	uninstall-incincHEADERS uninstall-info-am
377
	uninstall-am uninstall-incincHEADERS uninstall-info-am
350
378
379
380
vg_skin.h: $(srcdir)/vg_skin.h.base \
381
	 $(top_srcdir)/coregrind/gen_toolint.pl $(top_srcdir)/coregrind/toolfuncs.def
382
	rm -f $@
383
	cat $(srcdir)/vg_skin.h.base > $@
384
	$(PERL) $(top_srcdir)/coregrind/gen_toolint.pl toolproto < $(top_srcdir)/coregrind/toolfuncs.def >> $@ || rm -f $@
385
	$(PERL) $(top_srcdir)/coregrind/gen_toolint.pl initproto < $(top_srcdir)/coregrind/toolfuncs.def >> $@ || rm -f $@
351
# Tell versions [3.59,3.63) of GNU make to not export all variables.
386
# Tell versions [3.59,3.63) of GNU make to not export all variables.
352
# Otherwise a system limit (for SysV at least) may be exceeded.
387
# Otherwise a system limit (for SysV at least) may be exceeded.
353
.NOEXPORT:
388
.NOEXPORT:
(-)valgrind-2.1.0/include/valgrind.h (-5 / +8 lines)
Lines 12-18 Link Here
12
   This file is part of Valgrind, an extensible x86 protected-mode
12
   This file is part of Valgrind, an extensible x86 protected-mode
13
   emulator for monitoring program execution on x86-Unixes.
13
   emulator for monitoring program execution on x86-Unixes.
14
14
15
   Copyright (C) 2000-2003 Julian Seward.  All rights reserved.
15
   Copyright (C) 2000-2004 Julian Seward.  All rights reserved.
16
16
17
   Redistribution and use in source and binary forms, with or without
17
   Redistribution and use in source and binary forms, with or without
18
   modification, are permitted provided that the following conditions
18
   modification, are permitted provided that the following conditions
Lines 159-165 Link Here
159
             Valgrind's output to /dev/null and still count errors. */
159
             Valgrind's output to /dev/null and still count errors. */
160
          VG_USERREQ__COUNT_ERRORS = 0x1201,
160
          VG_USERREQ__COUNT_ERRORS = 0x1201,
161
161
162
          /* These are useful and can be interpreted by any skin that tracks
162
          /* These are useful and can be interpreted by any tool that tracks
163
             malloc() et al, by using vg_replace_malloc.c. */
163
             malloc() et al, by using vg_replace_malloc.c. */
164
          VG_USERREQ__MALLOCLIKE_BLOCK = 0x1301,
164
          VG_USERREQ__MALLOCLIKE_BLOCK = 0x1301,
165
          VG_USERREQ__FREELIKE_BLOCK   = 0x1302,
165
          VG_USERREQ__FREELIKE_BLOCK   = 0x1302,
Lines 169-178 Link Here
169
          VG_USERREQ__PRINTF_BACKTRACE = 0x1402,
169
          VG_USERREQ__PRINTF_BACKTRACE = 0x1402,
170
   } Vg_ClientRequest;
170
   } Vg_ClientRequest;
171
171
172
#ifndef __GNUC__
173
#define __extension__
174
#endif
172
175
173
/* Returns 1 if running on Valgrind, 0 if running on the real CPU. 
176
/* Returns 1 if running on Valgrind, 0 if running on the real CPU. 
174
   Currently implemented but untested. */
177
   Currently implemented but untested. */
175
#define RUNNING_ON_VALGRIND                                        \
178
#define RUNNING_ON_VALGRIND  __extension__                         \
176
   ({unsigned int _qzz_res;                                        \
179
   ({unsigned int _qzz_res;                                        \
177
    VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0 /* returned if not */,     \
180
    VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0 /* returned if not */,     \
178
                            VG_USERREQ__RUNNING_ON_VALGRIND,       \
181
                            VG_USERREQ__RUNNING_ON_VALGRIND,       \
Lines 270-277 Link Here
270
   })
273
   })
271
274
272
275
273
/* Counts the number of errors that have been recorded by a skin.  Nb:
276
/* Counts the number of errors that have been recorded by a tool.  Nb:
274
   the skin must record the errors with VG_(maybe_record_error)() or
277
   the tool must record the errors with VG_(maybe_record_error)() or
275
   VG_(unique_error)() for them to be counted. */
278
   VG_(unique_error)() for them to be counted. */
276
#define VALGRIND_COUNT_ERRORS                                           \
279
#define VALGRIND_COUNT_ERRORS                                           \
277
   ({unsigned int _qyy_res;                                             \
280
   ({unsigned int _qyy_res;                                             \
(-)valgrind-2.1.0/include/vg_constants_skin.h (-1 / +8 lines)
Lines 8-14 Link Here
8
   This file is part of Valgrind, an extensible x86 protected-mode
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
9
   emulator for monitoring program execution on x86-Unixes.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 45-54 Link Here
45
#define VGP_(str)   VGAPPEND(vgProf_,str)
45
#define VGP_(str)   VGAPPEND(vgProf_,str)
46
#define VGOFF_(str) VGAPPEND(vgOff_,str)
46
#define VGOFF_(str) VGAPPEND(vgOff_,str)
47
#define VGR_(str)   VGAPPEND(vgAllRoadsLeadToRome_,str)
47
#define VGR_(str)   VGAPPEND(vgAllRoadsLeadToRome_,str)
48
#define VGINJ_(str) VGAPPEND(__vgInject_,str)
48
49
49
/* Skin specific ones.  Note that final name still starts with "vg". */
50
/* Skin specific ones.  Note that final name still starts with "vg". */
50
#define SK_(str)    VGAPPEND(vgSkin_,str)
51
#define SK_(str)    VGAPPEND(vgSkin_,str)
51
52
53
/* This is specifically for stringifying VG_(x) function names.  We
54
   need to do two macroexpansions to get the VG_ macro expanded before
55
   stringifying */
56
#define _STR(x)	#x
57
#define STR(x)	_STR(x)
58
52
#endif /* ndef __VG_CONSTANTS_SKIN_H */
59
#endif /* ndef __VG_CONSTANTS_SKIN_H */
53
60
54
/*--------------------------------------------------------------------*/
61
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/include/vg_kerneliface.h (-1 / +36 lines)
Lines 9-15 Link Here
9
   This file is part of Valgrind, an extensible x86 protected-mode
9
   This file is part of Valgrind, an extensible x86 protected-mode
10
   emulator for monitoring program execution on x86-Unixes.
10
   emulator for monitoring program execution on x86-Unixes.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 305-316 Link Here
305
305
306
/* The following are copied from include/asm-i386/mman.h .*/
306
/* The following are copied from include/asm-i386/mman.h .*/
307
307
308
#define VKI_PROT_NONE      0x0		   /* No page permissions */
308
#define VKI_PROT_READ      0x1             /* Page can be read.  */
309
#define VKI_PROT_READ      0x1             /* Page can be read.  */
309
#define VKI_PROT_WRITE     0x2             /* Page can be written.  */
310
#define VKI_PROT_WRITE     0x2             /* Page can be written.  */
310
#define VKI_PROT_EXEC      0x4             /* Page can be executed.  */
311
#define VKI_PROT_EXEC      0x4             /* Page can be executed.  */
311
#define VKI_MAP_ANONYMOUS  0x20            /* Don't use a file.  */
312
#define VKI_MAP_ANONYMOUS  0x20            /* Don't use a file.  */
313
#define VKI_MAP_SHARED	   0x01		   /* Share changes.  */
312
#define VKI_MAP_PRIVATE    0x02            /* Changes are private.  */
314
#define VKI_MAP_PRIVATE    0x02            /* Changes are private.  */
313
#define VKI_MAP_FIXED      0x10            /* Interpret addr exactly */
315
#define VKI_MAP_FIXED      0x10            /* Interpret addr exactly */
316
#define VKI_MAP_NOSYMS     0x40000000	   /* internal pseudo-flag to disable symbol loading */
317
#define VKI_MAP_CLIENT     0x80000000	   /* internal pseudo-flag to distinguish client mappings */
318
319
/* linux/mman.h */
320
#define VKI_MREMAP_MAYMOVE	1
321
#define VKI_MREMAP_FIXED	2
314
322
315
/* Copied from linux-2.4.19/include/asm-i386/fcntl.h */
323
/* Copied from linux-2.4.19/include/asm-i386/fcntl.h */
316
324
Lines 501-506 Link Here
501
#define VKI_POLLNVAL        0x0020
509
#define VKI_POLLNVAL        0x0020
502
510
503
511
512
/* sys/epoll.h */
513
typedef union vki_epoll_data {
514
   void *ptr;
515
   Int   fd;
516
   UInt  u32;
517
   ULong u64;
518
} vki_epoll_data_t;
519
520
struct vki_epoll_event {
521
   UInt events;            /* Epoll events */
522
   vki_epoll_data_t data;      /* User data variable */
523
};
524
504
525
505
/* 
526
/* 
506
./include/asm-i386/posix_types.h:typedef long           __kernel_suseconds_t;
527
./include/asm-i386/posix_types.h:typedef long           __kernel_suseconds_t;
Lines 571-576 Link Here
571
   Logic from     /usr/src/linux-2.4.9-31/fs/binfmt_elf.c
592
   Logic from     /usr/src/linux-2.4.9-31/fs/binfmt_elf.c
572
                  and its counterpart in the 2.2.14 kernel sources 
593
                  and its counterpart in the 2.2.14 kernel sources 
573
                  in Red Hat 6.2.  */
594
                  in Red Hat 6.2.  */
595
#define VKI_AT_NULL   0
574
#define VKI_AT_SYSINFO 32   /* address of system info page */
596
#define VKI_AT_SYSINFO 32   /* address of system info page */
575
#define VKI_AT_CLKTCK 17    /* frequency at which times() increments */
597
#define VKI_AT_CLKTCK 17    /* frequency at which times() increments */
576
#define VKI_AT_HWCAP  16    /* arch dependent hints at CPU capabilities */
598
#define VKI_AT_HWCAP  16    /* arch dependent hints at CPU capabilities */
Lines 622-633 Link Here
622
        unsigned int  limit_in_pages:1;
644
        unsigned int  limit_in_pages:1;
623
        unsigned int  seg_not_present:1;
645
        unsigned int  seg_not_present:1;
624
        unsigned int  useable:1;
646
        unsigned int  useable:1;
647
        unsigned int  reserved:25;
625
} vki_modify_ldt_t;
648
} vki_modify_ldt_t;
626
649
627
#define VKI_MODIFY_LDT_CONTENTS_DATA        0
650
#define VKI_MODIFY_LDT_CONTENTS_DATA        0
628
#define VKI_MODIFY_LDT_CONTENTS_STACK       1
651
#define VKI_MODIFY_LDT_CONTENTS_STACK       1
629
#define VKI_MODIFY_LDT_CONTENTS_CODE        2
652
#define VKI_MODIFY_LDT_CONTENTS_CODE        2
630
653
654
#define VKI_GDT_TLS_ENTRIES 3
655
#define VKI_GDT_TLS_MIN     6
656
#define VKI_GDT_TLS_MAX     (VKI_GDT_TLS_MIN + VKI_GDT_TLS_ENTRIES)
631
657
632
/* Flags for clone() */
658
/* Flags for clone() */
633
/* linux/sched.h */
659
/* linux/sched.h */
Lines 717-722 Link Here
717
        unsigned int f_spare[5];
743
        unsigned int f_spare[5];
718
};
744
};
719
745
746
/* 
747
 * linux/futex.h
748
 */
749
750
#define VKI_FUTEX_WAIT    0
751
#define VKI_FUTEX_WAKE    1
752
#define VKI_FUTEX_FD      2
753
#define VKI_FUTEX_REQUEUE 3
754
720
755
721
#endif /*  __VG_KERNELIFACE_H */
756
#endif /*  __VG_KERNELIFACE_H */
722
757
(-)valgrind-2.1.0/include/vg_profile.c (-4 / +4 lines)
Lines 1-7 Link Here
1
1
2
/*--------------------------------------------------------------------*/
2
/*--------------------------------------------------------------------*/
3
/*--- Profiling machinery.  #include this file into a skin to      ---*/
3
/*--- Profiling machinery.  #include this file into a tool to      ---*/
4
/*--- enable --profile=yes, but not for release versions of skins, ---*/
4
/*--- enable --profile=yes, but not for release versions of tools, ---*/
5
/*--- because it uses glibc code.                                  ---*/
5
/*--- because it uses glibc code.                                  ---*/
6
/*---                                                 vg_profile.c ---*/
6
/*---                                                 vg_profile.c ---*/
7
/*--------------------------------------------------------------------*/
7
/*--------------------------------------------------------------------*/
Lines 10-16 Link Here
10
   This file is part of Valgrind, an extensible x86 protected-mode
10
   This file is part of Valgrind, an extensible x86 protected-mode
11
   emulator for monitoring program execution on x86-Unixes.
11
   emulator for monitoring program execution on x86-Unixes.
12
12
13
   Copyright (C) 2000-2003 Julian Seward 
13
   Copyright (C) 2000-2004 Julian Seward 
14
      jseward@acm.org
14
      jseward@acm.org
15
15
16
   This program is free software; you can redistribute it and/or
16
   This program is free software; you can redistribute it and/or
Lines 76-82 Link Here
76
   if (vgp_names[n] != NULL) {
76
   if (vgp_names[n] != NULL) {
77
      VG_(printf)("\nProfile event #%d being registered as `%s'\n"
77
      VG_(printf)("\nProfile event #%d being registered as `%s'\n"
78
                  "already registered as `%s'.\n"
78
                  "already registered as `%s'.\n"
79
                  "Note that skin and core event numbers must not overlap.\n",
79
                  "Note that tool and core event numbers must not overlap.\n",
80
                  n, name, vgp_names[n]);
80
                  n, name, vgp_names[n]);
81
      VG_(skin_panic)("profile event already registered");
81
      VG_(skin_panic)("profile event already registered");
82
   }
82
   }
(-)valgrind-2.1.0/include/vg_skin.h (-2096 lines)
Lines 1-2096 Link Here
1
2
/*--------------------------------------------------------------------*/
3
/*--- The only header your skin will ever need to #include...      ---*/
4
/*---                                                    vg_skin.h ---*/
5
/*--------------------------------------------------------------------*/
6
7
/*
8
   This file is part of Valgrind, an extensible x86 protected-mode
9
   emulator for monitoring program execution on x86-Unixes.
10
11
   Copyright (C) 2000-2003 Julian Seward
12
      jseward@acm.org
13
14
   This program is free software; you can redistribute it and/or
15
   modify it under the terms of the GNU General Public License as
16
   published by the Free Software Foundation; either version 2 of the
17
   License, or (at your option) any later version.
18
19
   This program is distributed in the hope that it will be useful, but
20
   WITHOUT ANY WARRANTY; without even the implied warranty of
21
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22
   General Public License for more details.
23
24
   You should have received a copy of the GNU General Public License
25
   along with this program; if not, write to the Free Software
26
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27
   02111-1307, USA.
28
29
   The GNU General Public License is contained in the file COPYING.
30
*/
31
32
#ifndef __VG_SKIN_H
33
#define __VG_SKIN_H
34
35
#include <stdarg.h>       /* ANSI varargs stuff  */
36
#include <setjmp.h>       /* for jmp_buf         */
37
38
#include "vg_constants_skin.h"
39
40
41
/* ---------------------------------------------------------------------
42
   Where to send bug reports to.
43
   ------------------------------------------------------------------ */
44
45
#define VG_BUGS_TO "valgrind.kde.org"
46
47
48
/*====================================================================*/
49
/*=== Build options and table sizes.                               ===*/
50
/*====================================================================*/
51
52
/* You should be able to change these options or sizes, recompile, and
53
   still have a working system. */
54
55
/* The maximum number of pthreads that we support.  This is
56
   deliberately not very high since our implementation of some of the
57
   scheduler algorithms is surely O(N) in the number of threads, since
58
   that's simple, at least.  And (in practice) we hope that most
59
   programs do not need many threads. */
60
#define VG_N_THREADS 100
61
62
/* Maximum number of pthread keys available.  Again, we start low until
63
   the need for a higher number presents itself. */
64
#define VG_N_THREAD_KEYS 50
65
66
/* Total number of integer registers available for allocation -- all of
67
   them except %esp, %ebp.  %ebp permanently points at VG_(baseBlock).
68
69
   If you increase this you'll have to also change at least these:
70
     - VG_(rank_to_realreg)()
71
     - VG_(realreg_to_rank)()
72
     - ppRegsLiveness()
73
     - the RegsLive type (maybe -- RegsLive type must have more than
74
                          VG_MAX_REALREGS bits)
75
76
   You can decrease it, and performance will drop because more spills will
77
   occur.  If you decrease it too much, everything will fall over.
78
79
   Do not change this unless you really know what you are doing!  */
80
#define VG_MAX_REALREGS 6
81
82
83
/*====================================================================*/
84
/*=== Basic types, useful macros                                   ===*/
85
/*====================================================================*/
86
87
typedef unsigned char          UChar;
88
typedef unsigned short         UShort;
89
typedef unsigned int           UInt;
90
typedef unsigned long long int ULong;
91
92
typedef signed char            Char;
93
typedef signed short           Short;
94
typedef signed int             Int;
95
typedef signed long long int   Long;
96
97
typedef unsigned int           Addr;
98
99
typedef unsigned char          Bool;
100
#define False                  ((Bool)0)
101
#define True                   ((Bool)1)
102
103
104
#define mycat_wrk(aaa,bbb) aaa##bbb
105
#define mycat(aaa,bbb) mycat_wrk(aaa,bbb)
106
107
/* No, really.  I _am_ that strange. */
108
#define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d",nnn)
109
110
/* ---------------------------------------------------------------------
111
   Now the basic types are set up, we can haul in the kernel-interface
112
   definitions.
113
   ------------------------------------------------------------------ */
114
115
#include "vg_kerneliface.h"
116
117
118
/*====================================================================*/
119
/*=== Core/skin interface version                                  ===*/
120
/*====================================================================*/
121
122
/* The major version number indicates binary-incompatible changes to the
123
   interface;  if the core and skin major versions don't match, Valgrind
124
   will abort.  The minor version indicates binary-compatible changes.
125
*/
126
#define VG_CORE_INTERFACE_MAJOR_VERSION   5
127
#define VG_CORE_INTERFACE_MINOR_VERSION   0
128
129
extern const Int VG_(skin_interface_major_version);
130
extern const Int VG_(skin_interface_minor_version);
131
132
/* Every skin must include this macro somewhere, exactly once. */
133
#define VG_DETERMINE_INTERFACE_VERSION \
134
const Int VG_(skin_interface_major_version) = VG_CORE_INTERFACE_MAJOR_VERSION; \
135
const Int VG_(skin_interface_minor_version) = VG_CORE_INTERFACE_MINOR_VERSION;
136
137
138
/*====================================================================*/
139
/*=== Command-line options                                         ===*/
140
/*====================================================================*/
141
142
/* Use this for normal null-termination-style string comparison */
143
#define VG_STREQ(s1,s2) (s1 != NULL && s2 != NULL \
144
                         && VG_(strcmp)((s1),(s2))==0)
145
146
/* Use these for recognising skin command line options -- stops comparing
147
   once whitespace is reached. */
148
#  define VG_CLO_STREQ(s1,s2)     (0==VG_(strcmp_ws)((s1),(s2)))
149
#  define VG_CLO_STREQN(nn,s1,s2) (0==VG_(strncmp_ws)((s1),(s2),(nn)))
150
151
/* Verbosity level: 0 = silent, 1 (default), > 1 = more verbose. */
152
extern Int   VG_(clo_verbosity);
153
154
/* Profile? */
155
extern Bool  VG_(clo_profile);
156
157
/* Call this if a recognised option was bad for some reason.
158
   Note: don't use it just because an option was unrecognised -- return 'False'
159
   from SKN_(process_cmd_line_option) to indicate that. */
160
extern void VG_(bad_option) ( Char* opt );
161
162
/* Client args */
163
extern Int    VG_(client_argc);
164
extern Char** VG_(client_argv);
165
166
/* Client environment.  Can be inspected with VG_(getenv)() */
167
extern Char** VG_(client_envp);
168
169
170
/*====================================================================*/
171
/*=== Printing messages for the user                               ===*/
172
/*====================================================================*/
173
174
/* Print a message prefixed by "??<pid>?? "; '?' depends on the VgMsgKind.
175
   Should be used for all user output. */
176
177
typedef
178
   enum { Vg_UserMsg,         /* '?' == '=' */
179
          Vg_DebugMsg,        /* '?' == '-' */
180
          Vg_DebugExtraMsg,   /* '?' == '+' */
181
          Vg_ClientMsg,       /* '?' == '*' */
182
   }
183
   VgMsgKind;
184
185
/* Functions for building a message from multiple parts. */
186
extern int VG_(start_msg)  ( VgMsgKind kind );
187
extern int VG_(add_to_msg) ( Char* format, ... );
188
/* Ends and prints the message.  Appends a newline. */
189
extern int VG_(end_msg)    ( void );
190
191
/* Send a single-part message.  Appends a newline. */
192
extern int VG_(message)    ( VgMsgKind kind, Char* format, ... );
193
extern int VG_(vmessage)   ( VgMsgKind kind, Char* format, va_list vargs );
194
195
196
/*====================================================================*/
197
/*=== Profiling                                                    ===*/
198
/*====================================================================*/
199
200
/* Nb: VGP_(register_profile_event)() relies on VgpUnc being the first one */
201
#define VGP_CORE_LIST \
202
   /* These ones depend on the core */                \
203
   VGP_PAIR(VgpUnc,         "unclassified"),          \
204
   VGP_PAIR(VgpRun,         "running"),               \
205
   VGP_PAIR(VgpSched,       "scheduler"),             \
206
   VGP_PAIR(VgpMalloc,      "low-lev malloc/free"),   \
207
   VGP_PAIR(VgpCliMalloc,   "client  malloc/free"),   \
208
   VGP_PAIR(VgpTranslate,   "translate-main"),        \
209
   VGP_PAIR(VgpToUCode,     "to-ucode"),              \
210
   VGP_PAIR(VgpFromUcode,   "from-ucode"),            \
211
   VGP_PAIR(VgpImprove,     "improve"),               \
212
   VGP_PAIR(VgpESPUpdate,   "ESP-update"),            \
213
   VGP_PAIR(VgpRegAlloc,    "reg-alloc"),             \
214
   VGP_PAIR(VgpLiveness,    "liveness-analysis"),     \
215
   VGP_PAIR(VgpDoLRU,       "do-lru"),                \
216
   VGP_PAIR(VgpSlowFindT,   "slow-search-transtab"),  \
217
   VGP_PAIR(VgpInitMem,     "init-memory"),           \
218
   VGP_PAIR(VgpExeContext,  "exe-context"),           \
219
   VGP_PAIR(VgpReadSyms,    "read-syms"),             \
220
   VGP_PAIR(VgpSearchSyms,  "search-syms"),           \
221
   VGP_PAIR(VgpAddToT,      "add-to-transtab"),       \
222
   VGP_PAIR(VgpCoreSysWrap, "core-syscall-wrapper"),  \
223
   VGP_PAIR(VgpDemangle,    "demangle"),              \
224
   VGP_PAIR(VgpCoreCheapSanity,     "core-cheap-sanity"),     \
225
   VGP_PAIR(VgpCoreExpensiveSanity, "core-expensive-sanity"), \
226
   /* These ones depend on the skin */                \
227
   VGP_PAIR(VgpPreCloInit,  "pre-clo-init"),          \
228
   VGP_PAIR(VgpPostCloInit, "post-clo-init"),         \
229
   VGP_PAIR(VgpInstrument,  "instrument"),            \
230
   VGP_PAIR(VgpSkinSysWrap, "skin-syscall-wrapper"),  \
231
   VGP_PAIR(VgpSkinCheapSanity,     "skin-cheap-sanity"),     \
232
   VGP_PAIR(VgpSkinExpensiveSanity, "skin-expensive-sanity"), \
233
   VGP_PAIR(VgpFini,        "fini")
234
235
#define VGP_PAIR(n,name) n
236
typedef enum { VGP_CORE_LIST } VgpCoreCC;
237
#undef  VGP_PAIR
238
239
/* When registering skin profiling events, ensure that the 'n' value is in
240
 * the range (VgpFini+1..) */
241
extern void VGP_(register_profile_event) ( Int n, Char* name );
242
243
extern void VGP_(pushcc) ( UInt cc );
244
extern void VGP_(popcc)  ( UInt cc );
245
246
/* Define them only if they haven't already been defined by vg_profile.c */
247
#ifndef VGP_PUSHCC
248
#  define VGP_PUSHCC(x)
249
#endif
250
#ifndef VGP_POPCC
251
#  define VGP_POPCC(x)
252
#endif
253
254
255
/*====================================================================*/
256
/*=== Useful stuff to call from generated code                     ===*/
257
/*====================================================================*/
258
259
/* ------------------------------------------------------------------ */
260
/* General stuff */
261
262
/* 64-bit counter for the number of basic blocks done. */
263
extern ULong VG_(bbs_done);
264
265
/* Get the simulated %esp */
266
extern Addr VG_(get_stack_pointer) ( void );
267
268
/* Detect if an address is within Valgrind's stack, Valgrind's
269
   m_state_static, or the VG_(threads) array.  This is useful for
270
   memory leak detectors to rule out spurious pointers to a block. */
271
extern Bool VG_(within_stack)(Addr a);
272
extern Bool VG_(within_m_state_static_OR_threads)(Addr a);
273
274
/* Check if an address is 4-byte aligned */
275
#define IS_ALIGNED4_ADDR(aaa_p) (0 == (((UInt)(aaa_p)) & 3))
276
#define IS_ALIGNED8_ADDR(aaa_p) (0 == (((UInt)(aaa_p)) & 7))
277
278
279
/* ------------------------------------------------------------------ */
280
/* Thread-related stuff */
281
282
/* Special magic value for an invalid ThreadId.  It corresponds to
283
   LinuxThreads using zero as the initial value for
284
   pthread_mutex_t.__m_owner and pthread_cond_t.__c_waiting. */
285
#define VG_INVALID_THREADID ((ThreadId)(0))
286
287
/* ThreadIds are simply indices into the VG_(threads)[] array. */
288
typedef
289
   UInt
290
   ThreadId;
291
292
/* When looking for the current ThreadId, this is the safe option and
293
   probably the one you want.
294
295
   Details: Use this one from non-generated code, eg. from functions called
296
   on events like 'new_mem_heap'.  In such a case, the "current" thread is
297
   temporarily suspended as Valgrind's dispatcher is running.  This function
298
   is also suitable to be called from generated code (ie. from UCode, or a C
299
   function called directly from UCode).
300
301
   If you use VG_(get_current_tid)() from non-generated code, it will return
302
   0 signifying the invalid thread, which is probably not what you want. */
303
extern ThreadId VG_(get_current_or_recent_tid) ( void );
304
305
/* When looking for the current ThreadId, only use this one if you know what
306
   you are doing.
307
308
   Details: Use this one from generated code, eg. from C functions called
309
   from UCode.  (VG_(get_current_or_recent_tid)() is also suitable in that
310
   case.)  If you use this function from non-generated code, it will return
311
   0 signifying the invalid thread, which is probably not what you want. */
312
extern ThreadId VG_(get_current_tid)           ( void );
313
314
/* Searches through all thread's stacks to see if any match.  Returns
315
   VG_INVALID_THREADID if none match. */
316
extern ThreadId VG_(first_matching_thread_stack)
317
                        ( Bool (*p) ( Addr stack_min, Addr stack_max ));
318
319
320
/*====================================================================*/
321
/*=== Valgrind's version of libc                                   ===*/
322
/*====================================================================*/
323
324
/* Valgrind doesn't use libc at all, for good reasons (trust us).  So here
325
   are its own versions of C library functions, but with VG_ prefixes.  Note
326
   that the types of some are slightly different to the real ones.  Some
327
   additional useful functions are provided too; descriptions of how they
328
   work are given below. */
329
330
#if !defined(NULL)
331
#  define NULL ((void*)0)
332
#endif
333
334
335
/* ------------------------------------------------------------------ */
336
/* stdio.h
337
 *
338
 * Note that they all output to the file descriptor given by the
339
 * --logfile-fd=N argument, which defaults to 2 (stderr).  Hence no
340
 * need for VG_(fprintf)().
341
 */
342
extern UInt VG_(printf)  ( const char *format, ... );
343
/* too noisy ...  __attribute__ ((format (printf, 1, 2))) ; */
344
extern UInt VG_(sprintf) ( Char* buf, Char *format, ... );
345
extern UInt VG_(vprintf) ( void(*send)(Char),
346
                           const Char *format, va_list vargs );
347
348
extern Int  VG_(rename) ( Char* old_name, Char* new_name );
349
350
/* ------------------------------------------------------------------ */
351
/* stdlib.h */
352
353
extern void* VG_(malloc)         ( Int nbytes );
354
extern void  VG_(free)           ( void* p );
355
extern void* VG_(calloc)         ( Int n, Int nbytes );
356
extern void* VG_(realloc)        ( void* p, Int size );
357
extern void* VG_(malloc_aligned) ( Int align_bytes, Int nbytes );
358
359
extern void  VG_(print_malloc_stats) ( void );
360
361
362
extern void  VG_(exit)( Int status )
363
             __attribute__ ((__noreturn__));
364
/* Prints a panic message (a constant string), appends newline and bug
365
   reporting info, aborts. */
366
__attribute__ ((__noreturn__))
367
extern void  VG_(skin_panic) ( Char* str );
368
369
/* Looks up VG_(client_envp) */
370
extern Char* VG_(getenv) ( Char* name );
371
372
/* Get client resource limit*/
373
extern Int VG_(getrlimit) ( Int resource, struct vki_rlimit *rlim );
374
375
/* Crude stand-in for the glibc system() call. */
376
extern Int   VG_(system) ( Char* cmd );
377
378
extern Long  VG_(atoll)  ( Char* str );
379
380
/* Like atoll(), but converts a number of base 2..36 */
381
extern Long  VG_(atoll36) ( UInt base, Char* str );
382
383
/* Like qsort(), but does shell-sort.  The size==1/2/4 cases are specialised. */
384
extern void VG_(ssort)( void* base, UInt nmemb, UInt size,
385
                        Int (*compar)(void*, void*) );
386
387
388
/* ------------------------------------------------------------------ */
389
/* ctype.h */
390
extern Bool VG_(isspace) ( Char c );
391
extern Bool VG_(isdigit) ( Char c );
392
extern Char VG_(toupper) ( Char c );
393
394
395
/* ------------------------------------------------------------------ */
396
/* string.h */
397
extern Int   VG_(strlen)         ( const Char* str );
398
extern Char* VG_(strcat)         ( Char* dest, const Char* src );
399
extern Char* VG_(strncat)        ( Char* dest, const Char* src, Int n );
400
extern Char* VG_(strpbrk)        ( const Char* s, const Char* accept );
401
extern Char* VG_(strcpy)         ( Char* dest, const Char* src );
402
extern Char* VG_(strncpy)        ( Char* dest, const Char* src, Int ndest );
403
extern Int   VG_(strcmp)         ( const Char* s1, const Char* s2 );
404
extern Int   VG_(strncmp)        ( const Char* s1, const Char* s2, Int nmax );
405
extern Char* VG_(strstr)         ( const Char* haystack, Char* needle );
406
extern Char* VG_(strchr)         ( const Char* s, Char c );
407
extern Char* VG_(strdup)         ( const Char* s);
408
extern void* VG_(memcpy)         ( void *d, const void *s, Int sz );
409
extern void* VG_(memset)         ( void *s, Int c, Int sz );
410
extern Int   VG_(memcmp)         ( const void* s1, const void* s2, Int n );
411
412
/* Like strcmp() and strncmp(), but stop comparing at any whitespace. */
413
extern Int   VG_(strcmp_ws)      ( const Char* s1, const Char* s2 );
414
extern Int   VG_(strncmp_ws)     ( const Char* s1, const Char* s2, Int nmax );
415
416
/* Like strncpy(), but if 'src' is longer than 'ndest' inserts a '\0' as the
417
   last character. */
418
extern void  VG_(strncpy_safely) ( Char* dest, const Char* src, Int ndest );
419
420
/* Mini-regexp function.  Searches for 'pat' in 'str'.  Supports
421
 * meta-symbols '*' and '?'.  '\' escapes meta-symbols. */
422
extern Bool  VG_(string_match)   ( Char* pat, Char* str );
423
424
425
/* ------------------------------------------------------------------ */
426
/* math.h */
427
/* Returns the base-2 logarithm of x. */
428
extern Int VG_(log2) ( Int x );
429
430
431
/* ------------------------------------------------------------------ */
432
/* unistd.h, fcntl.h, sys/stat.h */
433
extern Int  VG_(getdents)( UInt fd, struct vki_dirent *dirp, UInt count );
434
extern Int  VG_(readlink)( Char* path, Char* buf, UInt bufsize );
435
extern Int  VG_(getpid)  ( void );
436
extern Int  VG_(getppid) ( void );
437
extern Int  VG_(getpgrp) ( void );
438
extern Int  VG_(gettid)	 ( void );
439
extern Int  VG_(setpgid) ( Int pid, Int pgrp );
440
441
extern Int  VG_(open)   ( const Char* pathname, Int flags, Int mode );
442
extern Int  VG_(read)   ( Int fd, void* buf, Int count);
443
extern Int  VG_(write)  ( Int fd, const void* buf, Int count);
444
extern Int  VG_(lseek)  ( Int fd, Long offset, Int whence);
445
extern void VG_(close)  ( Int fd );
446
447
extern Int  VG_(pipe)   ( Int fd[2] );
448
449
/* Nb: VG_(rename)() declared in stdio.h section above */
450
extern Int  VG_(unlink) ( Char* file_name );
451
extern Int  VG_(stat)   ( Char* file_name, struct vki_stat* buf );
452
extern Int  VG_(fstat)  ( Int   fd,        struct vki_stat* buf );
453
extern Int  VG_(dup2)   ( Int oldfd, Int newfd );
454
455
extern Char* VG_(getcwd) ( Char* buf, Int size );
456
457
/* Easier to use than VG_(getcwd)() -- does the buffer fiddling itself.
458
   String put into 'cwd' is VG_(malloc)'d, and should be VG_(free)'d.
459
   Returns False if it fails.  Will fail if the pathname is > 65535 bytes. */
460
extern Bool VG_(getcwd_alloc) ( Char** cwd );
461
462
/* ------------------------------------------------------------------ */
463
/* assert.h */
464
/* Asserts permanently enabled -- no turning off with NDEBUG.  Hurrah! */
465
#define VG__STRING(__str)  #__str
466
467
#define sk_assert(expr)                                               \
468
  ((void) ((expr) ? 0 :						      \
469
	   (VG_(skin_assert_fail) (VG__STRING(expr),	              \
470
			           __FILE__, __LINE__,                \
471
                                   __PRETTY_FUNCTION__), 0)))
472
473
__attribute__ ((__noreturn__))
474
extern void VG_(skin_assert_fail) ( const Char* expr, const Char* file,
475
                                    Int line, const Char* fn );
476
477
478
/* ------------------------------------------------------------------ */
479
/* system/mman.h */
480
extern void* VG_(mmap)( void* start, UInt length,
481
                        UInt prot, UInt flags, UInt fd, UInt offset );
482
extern Int  VG_(munmap)( void* start, Int length );
483
484
/* Get memory by anonymous mmap. */
485
extern void* VG_(get_memory_from_mmap) ( Int nBytes, Char* who );
486
487
488
/* ------------------------------------------------------------------ */
489
/* signal.h.
490
491
   Note that these use the vk_ (kernel) structure
492
   definitions, which are different in places from those that glibc
493
   defines -- hence the 'k' prefix.  Since we're operating right at the
494
   kernel interface, glibc's view of the world is entirely irrelevant. */
495
496
/* --- Signal set ops --- */
497
extern Int  VG_(ksigfillset)  ( vki_ksigset_t* set );
498
extern Int  VG_(ksigemptyset) ( vki_ksigset_t* set );
499
500
extern Bool VG_(kisfullsigset)  ( vki_ksigset_t* set );
501
extern Bool VG_(kisemptysigset) ( vki_ksigset_t* set );
502
503
extern Int  VG_(ksigaddset)   ( vki_ksigset_t* set, Int signum );
504
extern Int  VG_(ksigdelset)   ( vki_ksigset_t* set, Int signum );
505
extern Int  VG_(ksigismember) ( vki_ksigset_t* set, Int signum );
506
507
extern void VG_(ksigaddset_from_set) ( vki_ksigset_t* dst, vki_ksigset_t* src );
508
extern void VG_(ksigdelset_from_set) ( vki_ksigset_t* dst, vki_ksigset_t* src );
509
510
/* --- Mess with the kernel's sig state --- */
511
extern Int VG_(ksigprocmask) ( Int how, const vki_ksigset_t* set,
512
                                       vki_ksigset_t* oldset );
513
extern Int VG_(ksigaction)   ( Int signum,
514
                               const vki_ksigaction* act,
515
                               vki_ksigaction* oldact );
516
517
extern Int VG_(ksigtimedwait)( const vki_ksigset_t *, vki_ksiginfo_t *, 
518
			       const struct vki_timespec * );
519
520
extern Int VG_(ksignal)      ( Int signum, void (*sighandler)(Int) );
521
extern Int VG_(ksigaltstack) ( const vki_kstack_t* ss, vki_kstack_t* oss );
522
523
extern Int VG_(kkill)        ( Int pid, Int signo );
524
extern Int VG_(ktkill)       ( Int pid, Int signo );
525
extern Int VG_(ksigpending)  ( vki_ksigset_t* set );
526
527
extern Int VG_(waitpid)	     ( Int pid, Int *status, Int options );
528
529
/* ------------------------------------------------------------------ */
530
/* socket.h. */
531
532
extern Int VG_(getsockname) ( Int sd, struct vki_sockaddr *name, Int *namelen);
533
extern Int VG_(getpeername) ( Int sd, struct vki_sockaddr *name, Int *namelen);
534
extern Int VG_(getsockopt) ( Int sd, Int level, Int optname, void *optval,
535
                             Int *optlen);
536
537
/* ------------------------------------------------------------------ */
538
/* other, randomly useful functions */
539
extern UInt VG_(read_millisecond_timer) ( void );
540
541
/*====================================================================*/
542
/*=== UCode definition                                             ===*/
543
/*====================================================================*/
544
545
/* Tags which describe what operands are.  Must fit into 4 bits, which
546
   they clearly do. */
547
typedef
548
enum { TempReg  =0, /* virtual temp-reg */
549
       ArchReg  =1, /* simulated integer reg */
550
       ArchRegS =2, /* simulated segment reg */
551
       RealReg  =3, /* real machine's real reg */
552
       SpillNo  =4, /* spill slot location */
553
       Literal  =5, /* literal; .lit32 field has actual value */
554
       Lit16    =6, /* literal; .val[123] field has actual value */
555
       NoValue  =7  /* operand not in use */
556
     }
557
     Tag;
558
559
/* Invalid register numbers (can't be negative) */
560
#define INVALID_TEMPREG 999999999
561
#define INVALID_REALREG 999999999
562
563
/* Microinstruction opcodes. */
564
typedef
565
   enum {
566
      NOP,         /* Null op */
567
568
      LOCK,	   /* Indicate the existence of a LOCK prefix (functionally NOP) */
569
570
      /* Moving values around */
571
      GET,  PUT,   /* simulated register <--> TempReg */
572
      GETF, PUTF,  /* simulated %eflags  <--> TempReg */
573
      LOAD, STORE, /* memory  <--> TempReg            */
574
      MOV,         /* TempReg <--> TempReg            */
575
      CMOV,        /* Used for cmpxchg and cmov       */
576
577
      /* Arithmetic/logical ops */
578
      MUL, UMUL,                	  /* Multiply */
579
      ADD, ADC, SUB, SBB,                 /* Add/subtract (w/wo carry)     */
580
      AND, OR,  XOR, NOT,                 /* Boolean ops                   */
581
      SHL, SHR, SAR, ROL, ROR, RCL, RCR,  /* Shift/rotate (w/wo carry)     */
582
      NEG,                                /* Negate                        */
583
      INC, DEC,                           /* Increment/decrement           */
584
      BSWAP,                              /* Big-endian <--> little-endian */
585
      CC2VAL,                             /* Condition code --> 0 or 1     */
586
      WIDEN,                              /* Signed or unsigned widening   */
587
588
      /* Conditional or unconditional jump  */
589
      JMP,
590
591
      /* FPU ops */
592
      FPU,           /* Doesn't touch memory */
593
      FPU_R, FPU_W,  /* Reads/writes memory  */
594
595
      /* ------------ MMX ops ------------ */
596
      /* In this and the SSE encoding, bytes at higher addresses are
597
	 held in bits [7:0] in these 16-bit words.  I guess this means
598
	 it is a big-endian encoding. */
599
600
      /* 1 byte, no memrefs, no iregdefs, copy exactly to the
601
	 output.  Held in val1[7:0]. */
602
      MMX1,
603
604
      /* 2 bytes, no memrefs, no iregdefs, copy exactly to the
605
	 output.  Held in val1[15:0]. */
606
      MMX2,
607
608
      /* 3 bytes, no memrefs, no iregdefs, copy exactly to the
609
         output.  Held in val1[15:0] and val2[7:0]. */
610
      MMX3,
611
612
      /* 2 bytes, reads/writes mem.  Insns of the form
613
         bbbbbbbb:mod mmxreg r/m.
614
         Held in val1[15:0], and mod and rm are to be replaced
615
         at codegen time by a reference to the Temp/RealReg holding
616
         the address.  Arg2 holds this Temp/Real Reg.
617
         Transfer is always at size 8.
618
      */
619
      MMX2_MemRd,
620
      MMX2_MemWr,
621
622
      /* 2 bytes, reads/writes an integer ("E") register.  Insns of the form
623
         bbbbbbbb:11 mmxreg ireg.
624
         Held in val1[15:0], and ireg is to be replaced
625
         at codegen time by a reference to the relevant RealReg.
626
         Transfer is always at size 4.  Arg2 holds this Temp/Real Reg.
627
      */
628
      MMX2_ERegRd,
629
      MMX2_ERegWr,
630
631
      /* ------------ SSE/SSE2 ops ------------ */
632
      /* In the following:
633
634
         a digit N indicates the next N bytes are to be copied exactly
635
         to the output.
636
637
         'a' indicates a mod-xmmreg-rm byte, where the mod-rm part is
638
         to be replaced at codegen time to a Temp/RealReg holding the
639
         address.
640
641
         'e' indicates a byte of the form '11 xmmreg ireg', where ireg
642
         is read or written, and is to be replaced at codegen time by
643
         a reference to the relevant RealReg.  'e' because it's the E
644
         reg in Intel encoding parlance.
645
646
         'g' indicates a byte of the form '11 ireg xmmreg', where ireg
647
         is read or written, and is to be replaced at codegen time by
648
         a reference to the relevant RealReg.  'g' because it's called
649
         G in Intel parlance. */
650
651
      /* 3 bytes, no memrefs, no iregdefs, copy exactly to the
652
         output.  Held in val1[15:0] and val2[7:0]. */
653
      SSE3,
654
655
      /* 3 bytes, reads/writes mem.  Insns of the form
656
         bbbbbbbb:bbbbbbbb:mod mmxreg r/m.
657
         Held in val1[15:0] and val2[7:0], and mod and rm are to be
658
         replaced at codegen time by a reference to the Temp/RealReg
659
         holding the address.  Arg3 holds this Temp/Real Reg.
660
         Transfer is usually, but not always, at size 16.  */
661
      SSE2a_MemRd,
662
      SSE2a_MemWr,
663
664
      /* 4 bytes, no memrefs, no iregdefs, copy exactly to the
665
         output.  Held in val1[15:0] and val2[15:0]. */
666
      SSE4,
667
668
      /* 4 bytes, reads/writes mem.  Insns of the form
669
         bbbbbbbb:bbbbbbbb:bbbbbbbb:mod mmxreg r/m.
670
         Held in val1[15:0] and val2[15:0], and mod and rm are to be
671
         replaced at codegen time by a reference to the Temp/RealReg
672
         holding the address.  Arg3 holds this Temp/Real Reg.
673
         Transfer is at stated size.  */
674
      SSE3a_MemRd,
675
      SSE3a_MemWr,
676
677
      /* 4 bytes, reads/writes mem.  Insns of the form
678
         bbbbbbbb:bbbbbbbb:mod mmxreg r/m:bbbbbbbb
679
         Held in val1[15:0] and val2[15:0], and mod and rm are to be
680
         replaced at codegen time by a reference to the Temp/RealReg
681
         holding the address.  Arg3 holds this Temp/Real Reg.
682
         Transfer is at stated size.  */
683
      SSE2a1_MemRd,
684
685
      /* 4 bytes, writes an integer register.  Insns of the form
686
         bbbbbbbb:bbbbbbbb:bbbbbbbb:11 ireg bbb.
687
         Held in val1[15:0] and val2[15:0], and ireg is to be replaced
688
         at codegen time by a reference to the relevant RealReg.
689
         Transfer is always at size 4.  Arg3 holds this Temp/Real Reg.
690
      */
691
      SSE3g_RegWr,
692
693
      /* 5 bytes, writes an integer register.  Insns of the form
694
         bbbbbbbb:bbbbbbbb:bbbbbbbb: 11 ireg bbb :bbbbbbbb. Held in
695
         val1[15:0] and val2[15:0] and lit32[7:0], and ireg is to be
696
         replaced at codegen time by a reference to the relevant
697
         RealReg.  Transfer is always at size 4.  Arg3 holds this
698
         Temp/Real Reg.
699
      */
700
      SSE3g1_RegWr,
701
702
      /* 4 bytes, reads an integer register.  Insns of the form
703
         bbbbbbbb:bbbbbbbb:bbbbbbbb:11 bbb ireg.
704
         Held in val1[15:0] and val2[15:0], and ireg is to be replaced
705
         at codegen time by a reference to the relevant RealReg.
706
         Transfer is always at size 4.  Arg3 holds this Temp/Real Reg.
707
      */
708
      SSE3e_RegRd,
709
      SSE3e_RegWr, /* variant that writes Ereg, not reads it */
710
711
      /* 5 bytes, reads an integer register.  Insns of the form
712
         bbbbbbbb:bbbbbbbb:bbbbbbbb: 11 bbb ireg :bbbbbbbb. Held in
713
         val1[15:0] and val2[15:0] and lit32[7:0], and ireg is to be
714
         replaced at codegen time by a reference to the relevant
715
         RealReg.  Transfer is always at size 4.  Arg3 holds this
716
         Temp/Real Reg.
717
      */
718
      SSE3e1_RegRd,
719
720
      /* 4 bytes, reads memory, writes an integer register, but is
721
         nevertheless an SSE insn.  The insn is of the form
722
         bbbbbbbb:bbbbbbbb:bbbbbbbb:mod ireg rm where mod indicates
723
         memory (ie is not 11b) and ireg is the int reg written.  The
724
         first 4 bytes are held in lit32[31:0] since there is
725
         insufficient space elsewhere.  mod and rm are to be replaced
726
         at codegen time by a reference to the Temp/RealReg holding
727
         the address.  Arg1 holds this Temp/RealReg.  ireg is to be
728
         replaced at codegen time by a reference to the relevant
729
         RealReg in which the answer is to be written.  Arg2 holds
730
         this Temp/RealReg.  Transfer to the destination reg is always
731
         at size 4.  However the memory read can be at sizes 4 or 8
732
         and so this is what the sz field holds.  Note that the 4th
733
         byte of the instruction (the modrm byte) is redundant, but we
734
         store it anyway so as to be consistent with all other SSE
735
         uinstrs.
736
      */
737
      SSE3ag_MemRd_RegWr,
738
739
      /* 5 bytes, no memrefs, no iregdefs, copy exactly to the
740
         output.  Held in val1[15:0], val2[15:0] and val3[7:0]. */
741
      SSE5,
742
743
      /* 5 bytes, reads/writes mem.  Insns of the form
744
         bbbbbbbb:bbbbbbbb:bbbbbbbb:mod mmxreg r/m:bbbbbbbb
745
         Held in val1[15:0], val2[15:0], lit32[7:0].
746
         mod and rm are to be replaced at codegen time by a reference
747
         to the Temp/RealReg holding the address.  Arg3 holds this
748
         Temp/Real Reg.  Transfer is always at size 16.  */
749
      SSE3a1_MemRd,
750
751
      /* ------------------------ */
752
753
      /* Not strictly needed, but improve address calculation translations. */
754
      LEA1,  /* reg2 := const + reg1 */
755
      LEA2,  /* reg3 := const + reg1 + reg2 * 1,2,4 or 8 */
756
757
      /* Hack for x86 REP insns.  Jump to literal if TempReg/RealReg
758
         is zero. */
759
      JIFZ,
760
761
      /* Advance the simulated %eip by some small (< 128) number. */
762
      INCEIP,
763
764
      /* Dealing with segment registers */
765
      GETSEG, PUTSEG,   /* simulated segment register <--> TempReg */
766
      USESEG,           /* (LDT/GDT index, virtual addr) --> linear addr */
767
768
      /* Not for translating x86 calls -- only to call helpers */
769
      CALLM_S, CALLM_E, /* Mark start/end of CALLM push/pop sequence */
770
      PUSH, POP, CLEAR, /* Add/remove/zap args for helpers           */
771
      CALLM,            /* Call assembly-code helper                 */
772
773
      /* Not for translating x86 calls -- only to call C helper functions of
774
         up to three arguments (or two if the functions has a return value).
775
         Arguments and return value must be word-sized.  More arguments can
776
         be faked with global variables (eg. use VG_(set_global_var)()).
777
778
         Seven possibilities: 'arg[123]' show where args go, 'ret' shows
779
         where return value goes (if present).
780
781
         CCALL(-,    -,    -   )    void f(void)
782
         CCALL(arg1, -,    -   )    void f(UInt arg1)
783
         CCALL(arg1, arg2, -   )    void f(UInt arg1, UInt arg2)
784
         CCALL(arg1, arg2, arg3)    void f(UInt arg1, UInt arg2, UInt arg3)
785
         CCALL(-,    -,    ret )    UInt f(UInt)
786
         CCALL(arg1, -,    ret )    UInt f(UInt arg1)
787
         CCALL(arg1, arg2, ret )    UInt f(UInt arg1, UInt arg2) */
788
      CCALL,
789
790
      /* This opcode makes it easy for skins that extend UCode to do this to
791
         avoid opcode overlap:
792
793
           enum { EU_OP1 = DUMMY_FINAL_UOPCODE + 1, ... }
794
795
         WARNING: Do not add new opcodes after this one!  They can be added
796
         before, though. */
797
      DUMMY_FINAL_UOPCODE
798
   }
799
   Opcode;
800
801
802
/* Condition codes, using the Intel encoding.  CondAlways is an extra. */
803
typedef
804
   enum {
805
      CondO      = 0,  /* overflow           */
806
      CondNO     = 1,  /* no overflow        */
807
      CondB      = 2,  /* below              */
808
      CondNB     = 3,  /* not below          */
809
      CondZ      = 4,  /* zero               */
810
      CondNZ     = 5,  /* not zero           */
811
      CondBE     = 6,  /* below or equal     */
812
      CondNBE    = 7,  /* not below or equal */
813
      CondS      = 8,  /* negative           */
814
      CondNS     = 9,  /* not negative       */
815
      CondP      = 10, /* parity even        */
816
      CondNP     = 11, /* not parity even    */
817
      CondL      = 12, /* jump less          */
818
      CondNL     = 13, /* not less           */
819
      CondLE     = 14, /* less or equal      */
820
      CondNLE    = 15, /* not less or equal  */
821
      CondAlways = 16  /* Jump always        */
822
   }
823
   Condcode;
824
825
826
/* Descriptions of additional properties of *unconditional* jumps. */
827
typedef
828
   enum {
829
     JmpBoring=0,   /* boring unconditional jump */
830
     JmpCall=1,     /* jump due to an x86 call insn */
831
     JmpRet=2,      /* jump due to an x86 ret insn */
832
     JmpSyscall=3,  /* do a system call, then jump */
833
     JmpClientReq=4 /* do a client request, then jump */
834
   }
835
   JmpKind;
836
837
838
/* Flags.  User-level code can only read/write O(verflow), S(ign),
839
   Z(ero), A(ux-carry), C(arry), P(arity), and may also write
840
   D(irection).  That's a total of 7 flags.  A FlagSet is a bitset,
841
   thusly:
842
      76543210
843
       DOSZACP
844
   and bit 7 must always be zero since it is unused.
845
846
   Note: these Flag? values are **not** the positions in the actual
847
   %eflags register.  */
848
849
typedef UChar FlagSet;
850
851
#define FlagD (1<<6)
852
#define FlagO (1<<5)
853
#define FlagS (1<<4)
854
#define FlagZ (1<<3)
855
#define FlagA (1<<2)
856
#define FlagC (1<<1)
857
#define FlagP (1<<0)
858
859
#define FlagsOSZACP (FlagO | FlagS | FlagZ | FlagA | FlagC | FlagP)
860
#define FlagsOSZAP  (FlagO | FlagS | FlagZ | FlagA |         FlagP)
861
#define FlagsOSZCP  (FlagO | FlagS | FlagZ |         FlagC | FlagP)
862
#define FlagsOSACP  (FlagO | FlagS |         FlagA | FlagC | FlagP)
863
#define FlagsSZACP  (        FlagS | FlagZ | FlagA | FlagC | FlagP)
864
#define FlagsSZAP   (        FlagS | FlagZ | FlagA |         FlagP)
865
#define FlagsZCP    (                FlagZ         | FlagC | FlagP)
866
#define FlagsOC     (FlagO |                         FlagC        )
867
#define FlagsAC     (                        FlagA | FlagC        )
868
869
#define FlagsALL    (FlagsOSZACP | FlagD)
870
#define FlagsEmpty  (FlagSet)0
871
872
873
/* flag positions in eflags */
874
#define EFlagC  (1 <<  0)       /* carry */
875
#define EFlagP  (1 <<  2)       /* parity */
876
#define EFlagA	(1 <<  4)	/* aux carry */
877
#define EFlagZ  (1 <<  6)       /* zero */
878
#define EFlagS  (1 <<  7)       /* sign */
879
#define EFlagD  (1 << 10)	/* direction */
880
#define EFlagO  (1 << 11)       /* overflow */
881
882
/* Liveness of general purpose registers, useful for code generation.
883
   Reg rank order 0..N-1 corresponds to bits 0..N-1, ie. first
884
   reg's liveness in bit 0, last reg's in bit N-1.  Note that
885
   these rankings don't match the Intel register ordering. */
886
typedef UInt RRegSet;
887
888
#define ALL_RREGS_DEAD      0                           /* 0000...00b */
889
#define ALL_RREGS_LIVE      ((1 << VG_MAX_REALREGS)-1)  /* 0011...11b */
890
#define UNIT_RREGSET(rank)  (1 << (rank))
891
892
#define IS_RREG_LIVE(rank,rregs_live) (rregs_live & UNIT_RREGSET(rank))
893
#define SET_RREG_LIVENESS(rank,rregs_live,b)       \
894
   do { RRegSet unit = UNIT_RREGSET(rank);         \
895
        if (b) rregs_live |= unit;                 \
896
        else   rregs_live &= ~unit;                \
897
   } while(0)
898
899
900
/* A Micro (u)-instruction. */
901
typedef
902
   struct {
903
      /* word 1 */
904
      UInt    lit32;      /* 32-bit literal */
905
906
      /* word 2 */
907
      UShort  val1;       /* first operand */
908
      UShort  val2;       /* second operand */
909
910
      /* word 3 */
911
      UShort  val3;       /* third operand */
912
      UChar   opcode;     /* opcode */
913
      UChar   size;       /* data transfer size */
914
915
      /* word 4 */
916
      FlagSet flags_r;    /* :: FlagSet */
917
      FlagSet flags_w;    /* :: FlagSet */
918
      UChar   tag1:4;     /* first  operand tag */
919
      UChar   tag2:4;     /* second operand tag */
920
      UChar   tag3:4;     /* third  operand tag */
921
      UChar   extra4b:4;  /* Spare field, used by WIDEN for src
922
                             -size, and by LEA2 for scale (1,2,4 or 8),
923
                             and by JMPs for original x86 instr size */
924
925
      /* word 5 */
926
      UChar   cond;            /* condition, for jumps */
927
      Bool    signed_widen:1;  /* signed or unsigned WIDEN ? */
928
      JmpKind jmpkind:3;       /* additional properties of unconditional JMP */
929
930
      /* Additional properties for UInstrs that call C functions:
931
           - CCALL
932
           - PUT (when %ESP is the target)
933
           - possibly skin-specific UInstrs
934
      */
935
      UChar   argc:2;          /* Number of args, max 3 */
936
      UChar   regparms_n:2;    /* Number of args passed in registers */
937
      Bool    has_ret_val:1;   /* Function has return value? */
938
939
      /* RealReg liveness;  only sensical after reg alloc and liveness
940
         analysis done.  This info is a little bit arch-specific --
941
         VG_MAX_REALREGS can vary on different architectures.  Note that
942
         to use this information requires converting between register ranks
943
         and the Intel register numbers, using VG_(realreg_to_rank)()
944
         and/or VG_(rank_to_realreg)() */
945
      RRegSet regs_live_after:VG_MAX_REALREGS;
946
   }
947
   UInstr;
948
949
950
typedef
951
   struct _UCodeBlock
952
   UCodeBlock;
953
954
extern Int     VG_(get_num_instrs) (UCodeBlock* cb);
955
extern Int     VG_(get_num_temps)  (UCodeBlock* cb);
956
957
extern UInstr* VG_(get_instr)      (UCodeBlock* cb, Int i);
958
extern UInstr* VG_(get_last_instr) (UCodeBlock* cb);
959
960
961
/*====================================================================*/
962
/*=== Instrumenting UCode                                          ===*/
963
/*====================================================================*/
964
965
/* Maximum number of registers read or written by a single UInstruction. */
966
#define VG_MAX_REGS_USED   3
967
968
/* Find what this instruction does to its regs, useful for
969
   analysis/optimisation passes.  `tag' indicates whether we're considering
970
   TempRegs (pre-reg-alloc) or RealRegs (post-reg-alloc).  `regs' is filled
971
   with the affected register numbers, `isWrites' parallels it and indicates
972
   if the reg is read or written.  If a reg is read and written, it will
973
   appear twice in `regs'.  `regs' and `isWrites' must be able to fit
974
   VG_MAX_REGS_USED elements. */
975
extern Int VG_(get_reg_usage) ( UInstr* u, Tag tag, Int* regs, Bool* isWrites );
976
977
978
/* Used to register helper functions to be called from generated code.  A
979
   limited number of compact helpers can be registered;  the code generated
980
   to call them is slightly shorter -- so register the mostly frequently
981
   called helpers as compact. */
982
extern void VG_(register_compact_helper)    ( Addr a );
983
extern void VG_(register_noncompact_helper) ( Addr a );
984
985
986
/* ------------------------------------------------------------------ */
987
/* Virtual register allocation */
988
989
/* Get a new virtual register */
990
extern Int VG_(get_new_temp)   ( UCodeBlock* cb );
991
992
/* Get a new virtual shadow register */
993
extern Int VG_(get_new_shadow) ( UCodeBlock* cb );
994
995
/* Get a virtual register's corresponding virtual shadow register */
996
#define SHADOW(tempreg)  ((tempreg)+1)
997
998
999
/* ------------------------------------------------------------------ */
1000
/* Low-level UInstr builders */
1001
extern void VG_(new_NOP)     ( UInstr* u );
1002
extern void VG_(new_UInstr0) ( UCodeBlock* cb, Opcode opcode, Int sz );
1003
extern void VG_(new_UInstr1) ( UCodeBlock* cb, Opcode opcode, Int sz,
1004
                               Tag tag1, UInt val1 );
1005
extern void VG_(new_UInstr2) ( UCodeBlock* cb, Opcode opcode, Int sz,
1006
                              Tag tag1, UInt val1,
1007
                              Tag tag2, UInt val2 );
1008
extern void VG_(new_UInstr3) ( UCodeBlock* cb, Opcode opcode, Int sz,
1009
                              Tag tag1, UInt val1,
1010
                              Tag tag2, UInt val2,
1011
                              Tag tag3, UInt val3 );
1012
1013
/* Set read/write/undefined flags.  Undefined flags are treaten as written,
1014
   but it's worth keeping them logically distinct. */
1015
extern void VG_(set_flag_fields)  ( UCodeBlock* cb, FlagSet fr, FlagSet fw,
1016
                                    FlagSet fu);
1017
extern void VG_(set_lit_field)    ( UCodeBlock* cb, UInt lit32 );
1018
extern void VG_(set_ccall_fields) ( UCodeBlock* cb, Addr fn, UChar argc,
1019
                                    UChar regparms_n, Bool has_ret_val );
1020
extern void VG_(set_cond_field)   ( UCodeBlock* cb, Condcode code );
1021
1022
extern void VG_(copy_UInstr) ( UCodeBlock* cb, UInstr* instr );
1023
1024
extern Bool VG_(any_flag_use)( UInstr* u );
1025
1026
/* Macro versions of the above;  just shorter to type. */
1027
#define uInstr0   VG_(new_UInstr0)
1028
#define uInstr1   VG_(new_UInstr1)
1029
#define uInstr2   VG_(new_UInstr2)
1030
#define uInstr3   VG_(new_UInstr3)
1031
#define uLiteral  VG_(set_lit_field)
1032
#define uCCall    VG_(set_ccall_fields)
1033
#define uCond     VG_(set_cond_field)
1034
#define uFlagsRWU VG_(set_flag_fields)
1035
#define newTemp   VG_(get_new_temp)
1036
#define newShadow VG_(get_new_shadow)
1037
1038
/* Refer to `the last instruction stuffed in' (can be lvalue). */
1039
#define LAST_UINSTR(cb) (cb)->instrs[(cb)->used-1]
1040
1041
1042
/* ------------------------------------------------------------------ */
1043
/* Higher-level UInstr sequence builders */
1044
extern void VG_(call_helper_0_0) ( UCodeBlock* cb, Addr f);
1045
extern void VG_(call_helper_1_0) ( UCodeBlock* cb, Addr f, UInt arg1,
1046
                                   UInt regparms_n);
1047
extern void VG_(call_helper_2_0) ( UCodeBlock* cb, Addr f, UInt arg1, UInt arg2,
1048
                                   UInt regparms_n);
1049
1050
/* One way around the 3-arg C function limit is to pass args via global
1051
 * variables... ugly, but it works.  This one puts a literal in there. */
1052
extern void VG_(set_global_var) ( UCodeBlock* cb, Addr globvar_ptr, UInt val);
1053
1054
/* This one puts the contents of a TempReg in the global variable. */
1055
extern void VG_(set_global_var_tempreg) ( UCodeBlock* cb, Addr globvar_ptr,
1056
                                          UInt t_val);
1057
1058
/* ------------------------------------------------------------------ */
1059
/* Allocating/freeing basic blocks of UCode */
1060
extern UCodeBlock* VG_(setup_UCodeBlock) ( UCodeBlock* cb );
1061
extern void        VG_(free_UCodeBlock)  ( UCodeBlock* cb );
1062
1063
/* ------------------------------------------------------------------ */
1064
/* UCode pretty/ugly printing.  Probably only useful to call from a skin
1065
   if VG_(needs).extended_UCode == True. */
1066
1067
/* When True, all generated code is/should be printed. */
1068
extern Bool  VG_(print_codegen);
1069
1070
/* Pretty/ugly printing functions */
1071
extern void  VG_(pp_UCodeBlock)  ( UCodeBlock* cb, Char* title );
1072
extern void  VG_(pp_UInstr)      ( Int instrNo, UInstr* u );
1073
extern void  VG_(pp_UInstr_regs) ( Int instrNo, UInstr* u );
1074
extern void  VG_(up_UInstr)      ( Int instrNo, UInstr* u );
1075
extern Char* VG_(name_UOpcode)   ( Bool upper, Opcode opc );
1076
extern Char* VG_(name_UCondcode) ( Condcode cond );
1077
extern void  VG_(pp_UOperand)    ( UInstr* u, Int operandNo,
1078
                                   Int sz, Bool parens );
1079
1080
/* ------------------------------------------------------------------ */
1081
/* Accessing archregs and their shadows */
1082
extern UInt VG_(get_archreg)            ( UInt archreg );
1083
extern UInt VG_(get_thread_archreg)     ( ThreadId tid, UInt archreg );
1084
1085
extern UInt VG_(get_shadow_archreg)     ( UInt archreg );
1086
extern void VG_(set_shadow_archreg)     ( UInt archreg, UInt val );
1087
extern void VG_(set_shadow_eflags)      ( UInt val );
1088
extern Addr VG_(shadow_archreg_address) ( UInt archreg );
1089
1090
extern UInt VG_(get_thread_shadow_archreg) ( ThreadId tid, UInt archreg );
1091
extern void VG_(set_thread_shadow_archreg) ( ThreadId tid, UInt archreg,
1092
                                             UInt val );
1093
1094
/* ------------------------------------------------------------------ */
1095
/* Offsets of addresses of helper functions.  A "helper" function is one
1096
   which is called from generated code via CALLM. */
1097
1098
extern Int VGOFF_(helper_idiv_64_32);
1099
extern Int VGOFF_(helper_div_64_32);
1100
extern Int VGOFF_(helper_idiv_32_16);
1101
extern Int VGOFF_(helper_div_32_16);
1102
extern Int VGOFF_(helper_idiv_16_8);
1103
extern Int VGOFF_(helper_div_16_8);
1104
1105
extern Int VGOFF_(helper_imul_32_64);
1106
extern Int VGOFF_(helper_mul_32_64);
1107
extern Int VGOFF_(helper_imul_16_32);
1108
extern Int VGOFF_(helper_mul_16_32);
1109
extern Int VGOFF_(helper_imul_8_16);
1110
extern Int VGOFF_(helper_mul_8_16);
1111
1112
extern Int VGOFF_(helper_CLD);
1113
extern Int VGOFF_(helper_STD);
1114
extern Int VGOFF_(helper_get_dirflag);
1115
1116
extern Int VGOFF_(helper_CLC);
1117
extern Int VGOFF_(helper_STC);
1118
1119
extern Int VGOFF_(helper_shldl);
1120
extern Int VGOFF_(helper_shldw);
1121
extern Int VGOFF_(helper_shrdl);
1122
extern Int VGOFF_(helper_shrdw);
1123
1124
extern Int VGOFF_(helper_RDTSC);
1125
extern Int VGOFF_(helper_CPUID);
1126
1127
extern Int VGOFF_(helper_IN);
1128
extern Int VGOFF_(helper_OUT);
1129
1130
extern Int VGOFF_(helper_bsf);
1131
extern Int VGOFF_(helper_bsr);
1132
1133
extern Int VGOFF_(helper_fstsw_AX);
1134
extern Int VGOFF_(helper_SAHF);
1135
extern Int VGOFF_(helper_LAHF);
1136
extern Int VGOFF_(helper_DAS);
1137
extern Int VGOFF_(helper_DAA);
1138
1139
1140
/*====================================================================*/
1141
/*=== Generating x86 code from UCode                               ===*/
1142
/*====================================================================*/
1143
1144
/* All this only necessary for skins with VG_(needs).extends_UCode == True. */
1145
1146
/* This is the Intel register encoding -- integer regs. */
1147
#define R_EAX 0
1148
#define R_ECX 1
1149
#define R_EDX 2
1150
#define R_EBX 3
1151
#define R_ESP 4
1152
#define R_EBP 5
1153
#define R_ESI 6
1154
#define R_EDI 7
1155
1156
#define R_AL (0+R_EAX)
1157
#define R_CL (0+R_ECX)
1158
#define R_DL (0+R_EDX)
1159
#define R_BL (0+R_EBX)
1160
#define R_AH (4+R_EAX)
1161
#define R_CH (4+R_ECX)
1162
#define R_DH (4+R_EDX)
1163
#define R_BH (4+R_EBX)
1164
1165
/* This is the Intel register encoding -- segment regs. */
1166
#define R_ES 0
1167
#define R_CS 1
1168
#define R_SS 2
1169
#define R_DS 3
1170
#define R_FS 4
1171
#define R_GS 5
1172
1173
/* For pretty printing x86 code */
1174
extern const Char* VG_(name_of_mmx_gran) ( UChar gran );
1175
extern const Char* VG_(name_of_mmx_reg)  ( Int mmxreg );
1176
extern const Char* VG_(name_of_seg_reg)  ( Int sreg );
1177
extern const Char* VG_(name_of_int_reg)  ( Int size, Int reg );
1178
extern const Char  VG_(name_of_int_size) ( Int size );
1179
1180
/* Shorter macros for convenience */
1181
#define nameIReg    VG_(name_of_int_reg)
1182
#define nameISize   VG_(name_of_int_size)
1183
#define nameSReg    VG_(name_of_seg_reg)
1184
#define nameMMXReg  VG_(name_of_mmx_reg)
1185
#define nameMMXGran VG_(name_of_mmx_gran)
1186
#define nameXMMReg  VG_(name_of_xmm_reg)
1187
1188
/* Randomly useful things */
1189
extern UInt  VG_(extend_s_8to32) ( UInt x );
1190
1191
/* Code emitters */
1192
extern void VG_(emitB)    ( UInt b );
1193
extern void VG_(emitW)    ( UInt w );
1194
extern void VG_(emitL)    ( UInt l );
1195
extern void VG_(new_emit) ( Bool upd_cc, FlagSet uses_flags, FlagSet sets_flags );
1196
1197
/* Finding offsets */
1198
extern Int  VG_(helper_offset)       ( Addr a );
1199
extern Int  VG_(shadow_reg_offset)   ( Int arch );
1200
extern Int  VG_(shadow_flags_offset) ( void );
1201
1202
/* Convert reg ranks <-> Intel register ordering, for using register
1203
   liveness information. */
1204
extern Int VG_(realreg_to_rank) ( Int realreg );
1205
extern Int VG_(rank_to_realreg) ( Int rank    );
1206
1207
/* Call a subroutine.  Does no argument passing, stack manipulations, etc. */
1208
extern void VG_(synth_call) ( Bool ensure_shortform, Int word_offset,
1209
			      Bool upd_cc, FlagSet use_flags, FlagSet set_flags );
1210
1211
/* For calling C functions -- saves caller save regs, pushes args, calls,
1212
   clears the stack, restores caller save regs.  `fn' must be registered in
1213
   the baseBlock first.  Acceptable tags are RealReg and Literal.  Optimises
1214
   things, eg. by not preserving non-live caller-save registers.
1215
1216
   WARNING:  a UInstr should *not* be translated with synth_ccall() followed
1217
   by some other x86 assembly code;  this will invalidate the results of
1218
   vg_realreg_liveness_analysis() and everything will fall over.  */
1219
extern void VG_(synth_ccall) ( Addr fn, Int argc, Int regparms_n, UInt argv[],
1220
                               Tag tagv[], Int ret_reg,
1221
                               RRegSet regs_live_before,
1222
                               RRegSet regs_live_after );
1223
1224
/* Addressing modes */
1225
extern void VG_(emit_amode_offregmem_reg)( Int off, Int regmem, Int reg );
1226
extern void VG_(emit_amode_ereg_greg)    ( Int e_reg, Int g_reg );
1227
1228
/* v-size (4, or 2 with OSO) insn emitters */
1229
extern void VG_(emit_movv_offregmem_reg) ( Int sz, Int off, Int areg, Int reg );
1230
extern void VG_(emit_movv_reg_offregmem) ( Int sz, Int reg, Int off, Int areg );
1231
extern void VG_(emit_movv_reg_reg)       ( Int sz, Int reg1, Int reg2 );
1232
extern void VG_(emit_nonshiftopv_lit_reg)( Bool upd_cc, Int sz, Opcode opc, UInt lit,
1233
                                           Int reg );
1234
extern void VG_(emit_shiftopv_lit_reg)   ( Bool upd_cc, Int sz, Opcode opc, UInt lit,
1235
                                           Int reg );
1236
extern void VG_(emit_nonshiftopv_reg_reg)( Bool upd_cc, Int sz, Opcode opc,
1237
                                           Int reg1, Int reg2 );
1238
extern void VG_(emit_movv_lit_reg)       ( Int sz, UInt lit, Int reg );
1239
extern void VG_(emit_unaryopv_reg)       ( Bool upd_cc, Int sz, Opcode opc, Int reg );
1240
extern void VG_(emit_pushv_reg)          ( Int sz, Int reg );
1241
extern void VG_(emit_popv_reg)           ( Int sz, Int reg );
1242
1243
extern void VG_(emit_pushl_lit32)        ( UInt int32 );
1244
extern void VG_(emit_pushl_lit8)         ( Int lit8 );
1245
extern void VG_(emit_cmpl_zero_reg)      ( Bool upd_cc, Int reg );
1246
extern void VG_(emit_swapl_reg_EAX)      ( Int reg );
1247
extern void VG_(emit_movv_lit_offregmem) ( Int sz, UInt lit, Int off,
1248
                                           Int memreg );
1249
1250
/* b-size (1 byte) instruction emitters */
1251
extern void VG_(emit_movb_lit_offregmem) ( UInt lit, Int off, Int memreg );
1252
extern void VG_(emit_movb_reg_offregmem) ( Int reg, Int off, Int areg );
1253
extern void VG_(emit_unaryopb_reg)       ( Bool upd_cc, Opcode opc, Int reg );
1254
extern void VG_(emit_testb_lit_reg)      ( Bool upd_cc, UInt lit, Int reg );
1255
1256
/* zero-extended load emitters */
1257
extern void VG_(emit_movzbl_offregmem_reg) ( Int off, Int regmem, Int reg );
1258
extern void VG_(emit_movzwl_offregmem_reg) ( Int off, Int areg, Int reg );
1259
extern void VG_(emit_movzwl_regmem_reg)    ( Int reg1, Int reg2 );
1260
1261
/* misc instruction emitters */
1262
extern void VG_(emit_call_reg)         ( Int reg );
1263
extern void VG_(emit_add_lit_to_esp)   ( Int lit );
1264
extern void VG_(emit_pushal)           ( void );
1265
extern void VG_(emit_popal)            ( void );
1266
extern void VG_(emit_AMD_prefetch_reg) ( Int reg );
1267
1268
/* jump emitters */
1269
extern void VG_(init_target)	       ( Int *tgt );
1270
1271
extern void VG_(target_back)	       ( Int *tgt );
1272
extern void VG_(target_forward)	       ( Int *tgt );
1273
extern void VG_(emit_target_delta)     ( Int *tgt );
1274
1275
extern void VG_(emit_jcondshort_delta) ( Bool simd_cc, Condcode cond, Int delta );
1276
extern void VG_(emit_jcondshort_target)( Bool simd_cc, Condcode cond, Int *tgt );
1277
1278
1279
/*====================================================================*/
1280
/*=== Execution contexts                                           ===*/
1281
/*====================================================================*/
1282
1283
/* Generic resolution type used in a few different ways, such as deciding
1284
   how closely to compare two errors for equality. */
1285
typedef
1286
   enum { Vg_LowRes, Vg_MedRes, Vg_HighRes }
1287
   VgRes;
1288
1289
typedef
1290
   struct _ExeContext
1291
   ExeContext;
1292
1293
/* Compare two ExeContexts.  Number of callers considered depends on `res':
1294
     Vg_LowRes:  2
1295
     Vg_MedRes:  4
1296
     Vg_HighRes: all */
1297
extern Bool VG_(eq_ExeContext) ( VgRes res,
1298
                                 ExeContext* e1, ExeContext* e2 );
1299
1300
/* Print an ExeContext. */
1301
extern void VG_(pp_ExeContext) ( ExeContext* );
1302
1303
/* Take a snapshot of the client's stack.  Search our collection of
1304
   ExeContexts to see if we already have it, and if not, allocate a
1305
   new one.  Either way, return a pointer to the context.  Context size
1306
   controlled by --num-callers option.
1307
1308
   If called from generated code, use VG_(get_current_tid)() to get the
1309
   current ThreadId.  If called from non-generated code, the current
1310
   ThreadId should be passed in by the core.
1311
*/
1312
extern ExeContext* VG_(get_ExeContext) ( ThreadId tid );
1313
1314
/* Get the nth EIP from the ExeContext.  0 is the EIP of the top function, 1
1315
   is its caller, etc.  Returns 0 if there isn't one, or if n is greater
1316
   than VG_(clo_backtrace_size), set by the --num-callers option. */
1317
extern Addr VG_(get_EIP_from_ExeContext) ( ExeContext* e, UInt n );
1318
1319
/* Just grab the client's EIP, as a much smaller and cheaper
1320
   indication of where they are.  Use is basically same as for
1321
   VG_(get_ExeContext)() above.
1322
*/
1323
extern Addr VG_(get_EIP)( ThreadId tid );
1324
1325
/* For skins needing more control over stack traces:  walks the stack to get
1326
   %eips from the top stack frames for thread 'tid'.  Maximum of 'n_eips'
1327
   addresses put into 'eips';  0 is the top of the stack, 1 is its caller,
1328
   etc. */
1329
extern UInt VG_(stack_snapshot) ( ThreadId tid, Addr* eips, UInt n_eips );
1330
1331
/* Does the same thing as VG_(pp_ExeContext)(), just with slightly
1332
   different input. */
1333
extern void VG_(mini_stack_dump) ( Addr eips[], UInt n_eips );
1334
1335
1336
/*====================================================================*/
1337
/*=== Error reporting                                              ===*/
1338
/*====================================================================*/
1339
1340
/* ------------------------------------------------------------------ */
1341
/* Suppressions describe errors which we want to suppress, ie, not
1342
   show the user, usually because it is caused by a problem in a library
1343
   which we can't fix, replace or work around.  Suppressions are read from
1344
   a file at startup time.  This gives flexibility so that new
1345
   suppressions can be added to the file as and when needed.
1346
*/
1347
1348
typedef
1349
   Int         /* Do not make this unsigned! */
1350
   SuppKind;
1351
1352
/* The skin-relevant parts of a suppression are:
1353
     kind:   what kind of suppression; must be in the range (0..)
1354
     string: use is optional.  NULL by default.
1355
     extra:  use is optional.  NULL by default.  void* so it's extensible.
1356
*/
1357
typedef
1358
   struct _Supp
1359
   Supp;
1360
1361
/* Useful in SK_(error_matches_suppression)() */
1362
SuppKind VG_(get_supp_kind)   ( Supp* su );
1363
Char*    VG_(get_supp_string) ( Supp* su );
1364
void*    VG_(get_supp_extra)  ( Supp* su );
1365
1366
/* Must be used in VG_(recognised_suppression)() */
1367
void VG_(set_supp_kind)   ( Supp* su, SuppKind suppkind );
1368
/* May be used in VG_(read_extra_suppression_info)() */
1369
void VG_(set_supp_string) ( Supp* su, Char* string );
1370
void VG_(set_supp_extra)  ( Supp* su, void* extra );
1371
1372
1373
/* ------------------------------------------------------------------ */
1374
/* Error records contain enough info to generate an error report.  The idea
1375
   is that (typically) the same few points in the program generate thousands
1376
   of errors, and we don't want to spew out a fresh error message for each
1377
   one.  Instead, we use these structures to common up duplicates.
1378
*/
1379
1380
typedef
1381
   Int         /* Do not make this unsigned! */
1382
   ErrorKind;
1383
1384
/* The skin-relevant parts of an Error are:
1385
     kind:   what kind of error; must be in the range (0..)
1386
     addr:   use is optional.  0 by default.
1387
     string: use is optional.  NULL by default.
1388
     extra:  use is optional.  NULL by default.  void* so it's extensible.
1389
*/
1390
typedef
1391
   struct _Error
1392
   Error;
1393
1394
/* Useful in SK_(error_matches_suppression)(), SK_(pp_SkinError)(), etc */
1395
ExeContext* VG_(get_error_where)   ( Error* err );
1396
SuppKind    VG_(get_error_kind)    ( Error* err );
1397
Addr        VG_(get_error_address) ( Error* err );
1398
Char*       VG_(get_error_string)  ( Error* err );
1399
void*       VG_(get_error_extra)   ( Error* err );
1400
1401
/* Call this when an error occurs.  It will be recorded if it hasn't been
1402
   seen before.  If it has, the existing error record will have its count
1403
   incremented.
1404
1405
   'tid' can be found as for VG_(get_ExeContext)().  The `extra' field can
1406
   be stack-allocated;  it will be copied by the core if needed (but it
1407
   won't be copied if it's NULL).
1408
1409
   If no 'a', 's' or 'extra' of interest needs to be recorded, just use
1410
   NULL for them.  */
1411
extern void VG_(maybe_record_error) ( ThreadId tid, ErrorKind ekind,
1412
                                      Addr a, Char* s, void* extra );
1413
1414
/* Similar to VG_(maybe_record_error)(), except this one doesn't record the
1415
   error -- useful for errors that can only happen once.  The errors can be
1416
   suppressed, though.  Return value is True if it was suppressed.
1417
   `print_error' dictates whether to print the error, which is a bit of a
1418
   hack that's useful sometimes if you just want to know if the error would
1419
   be suppressed without possibly printing it.  `count_error' dictates
1420
   whether to add the error in the error total count (another mild hack). */
1421
extern Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind,
1422
                                Addr a, Char* s, void* extra,
1423
                                ExeContext* where, Bool print_error,
1424
                                Bool allow_GDB_attach, Bool count_error );
1425
1426
/* Gets a non-blank, non-comment line of at most nBuf chars from fd.
1427
   Skips leading spaces on the line.  Returns True if EOF was hit instead.
1428
   Useful for reading in extra skin-specific suppression lines.  */
1429
extern Bool VG_(get_line) ( Int fd, Char* buf, Int nBuf );
1430
1431
1432
/*====================================================================*/
1433
/*=== Obtaining debug information                                  ===*/
1434
/*====================================================================*/
1435
1436
/* Get the file/function/line number of the instruction at address
1437
   'a'.  For these four, if debug info for the address is found, it
1438
   copies the info into the buffer/UInt and returns True.  If not, it
1439
   returns False and nothing is copied.  VG_(get_fnname) always
1440
   demangles C++ function names.  VG_(get_fnname_w_offset) is the
1441
   same, except it appends "+N" to symbol names to indicate offsets.  */
1442
extern Bool VG_(get_filename) ( Addr a, Char* filename, Int n_filename );
1443
extern Bool VG_(get_fnname)   ( Addr a, Char* fnname,   Int n_fnname   );
1444
extern Bool VG_(get_linenum)  ( Addr a, UInt* linenum );
1445
extern Bool VG_(get_fnname_w_offset)
1446
                              ( Addr a, Char* fnname,   Int n_fnname   );
1447
1448
/* This one is more efficient if getting both filename and line number,
1449
   because the two lookups are done together. */
1450
extern Bool VG_(get_filename_linenum)
1451
                              ( Addr a, Char* filename, Int n_filename,
1452
                                        UInt* linenum );
1453
1454
/* Succeeds only if we find from debug info that 'a' is the address of the
1455
   first instruction in a function -- as opposed to VG_(get_fnname) which
1456
   succeeds if we find from debug info that 'a' is the address of any
1457
   instruction in a function.  Use this to instrument the start of
1458
   a particular function.  Nb: if an executable/shared object is stripped
1459
   of its symbols, this function will not be able to recognise function
1460
   entry points within it. */
1461
extern Bool VG_(get_fnname_if_entry) ( Addr a, Char* fnname, Int n_fnname );
1462
1463
/* Succeeds if the address is within a shared object or the main executable.
1464
   It doesn't matter if debug info is present or not. */
1465
extern Bool VG_(get_objname)  ( Addr a, Char* objname,  Int n_objname  );
1466
1467
/* Puts into 'buf' info about the code address %eip:  the address, function
1468
   name (if known) and filename/line number (if known), like this:
1469
1470
      0x4001BF05: realloc (vg_replace_malloc.c:339)
1471
1472
   'n_buf' gives length of 'buf'.  Returns 'buf'.
1473
*/
1474
extern Char* VG_(describe_eip)(Addr eip, Char* buf, Int n_buf);
1475
1476
/* Returns a string containing an expression for the given
1477
   address. String is malloced with VG_(malloc)() */
1478
Char *VG_(describe_addr)(ThreadId, Addr);
1479
1480
/* A way to get information about what segments are mapped */
1481
typedef struct _SegInfo SegInfo;
1482
1483
/* Returns NULL if the SegInfo isn't found.  It doesn't matter if debug info
1484
   is present or not. */
1485
extern SegInfo* VG_(get_obj)  ( Addr a );
1486
1487
extern const SegInfo* VG_(next_seginfo)  ( const SegInfo *seg );
1488
extern       Addr     VG_(seg_start)     ( const SegInfo *seg );
1489
extern       UInt     VG_(seg_size)      ( const SegInfo *seg );
1490
extern const UChar*   VG_(seg_filename)  ( const SegInfo *seg );
1491
extern       UInt     VG_(seg_sym_offset)( const SegInfo *seg );
1492
1493
typedef
1494
   enum {
1495
      Vg_SectUnknown,
1496
      Vg_SectText,
1497
      Vg_SectData,
1498
      Vg_SectBSS,
1499
      Vg_SectGOT,
1500
      Vg_SectPLT,
1501
   }
1502
   VgSectKind;
1503
1504
extern VgSectKind VG_(seg_sect_kind)(Addr);
1505
1506
1507
/*====================================================================*/
1508
/*=== Generic hash table                                           ===*/
1509
/*====================================================================*/
1510
1511
/* Generic type for a separately-chained hash table.  Via a kind of dodgy
1512
   C-as-C++ style inheritance, skins can extend the VgHashNode type, so long
1513
   as the first two fields match the sizes of these two fields.  Requires
1514
   a bit of casting by the skin. */
1515
typedef
1516
   struct _VgHashNode {
1517
      struct _VgHashNode * next;
1518
      UInt               key;
1519
   }
1520
   VgHashNode;
1521
1522
typedef
1523
   VgHashNode**
1524
   VgHashTable;
1525
1526
/* Make a new table. */
1527
extern VgHashTable VG_(HT_construct) ( void );
1528
1529
/* Count the number of nodes in a table. */
1530
extern Int VG_(HT_count_nodes) ( VgHashTable table );
1531
1532
/* Add a node to the table. */
1533
extern void VG_(HT_add_node) ( VgHashTable t, VgHashNode* node );
1534
1535
/* Looks up a node in the hash table.  Also returns the address of the
1536
   previous node's `next' pointer which allows it to be removed from the
1537
   list later without having to look it up again.  */
1538
extern VgHashNode* VG_(HT_get_node) ( VgHashTable t, UInt key,
1539
                                    /*OUT*/VgHashNode*** next_ptr );
1540
1541
/* Allocates an array of pointers to all the shadow chunks of malloc'd
1542
   blocks.  Must be freed with VG_(free)(). */
1543
extern VgHashNode** VG_(HT_to_array) ( VgHashTable t, /*OUT*/ UInt* n_shadows );
1544
1545
/* Returns first node that matches predicate `p', or NULL if none do.
1546
   Extra arguments can be implicitly passed to `p' using nested functions;
1547
   see memcheck/mc_errcontext.c for an example. */
1548
extern VgHashNode* VG_(HT_first_match) ( VgHashTable t,
1549
                                         Bool (*p)(VgHashNode*) );
1550
1551
/* Applies a function f() once to each node.  Again, nested functions
1552
   can be very useful. */
1553
extern void VG_(HT_apply_to_all_nodes)( VgHashTable t, void (*f)(VgHashNode*) );
1554
1555
/* Destroy a table. */
1556
extern void VG_(HT_destruct) ( VgHashTable t );
1557
1558
1559
/*====================================================================*/
1560
/*=== Functions for shadow registers                               ===*/
1561
/*====================================================================*/
1562
1563
/* Nb: make sure the shadow_regs 'need' is set before using these! */
1564
1565
/* This one lets you override the shadow of the return value register for a
1566
   syscall.  Call it from SK_(post_syscall)() (not SK_(pre_syscall)()!) to
1567
   override the default shadow register value. */
1568
extern void VG_(set_return_from_syscall_shadow) ( ThreadId tid,
1569
                                                  UInt ret_shadow );
1570
1571
/* This can be called from SK_(fini)() to find the shadow of the argument
1572
   to exit(), ie. the shadow of the program's return value. */
1573
extern UInt VG_(get_exit_status_shadow) ( void );
1574
1575
1576
/*====================================================================*/
1577
/*=== General stuff for replacing functions                        ===*/
1578
/*====================================================================*/
1579
1580
/* Some skins need to replace the standard definitions of some functions. */
1581
1582
/* ------------------------------------------------------------------ */
1583
/* General stuff, for replacing any functions */
1584
1585
/* Is the client running on the simulated CPU or the real one?
1586
1587
   Nb: If it is, and you want to call a function to be run on the real CPU,
1588
   use one of the VALGRIND_NON_SIMD_CALL[123] macros in valgrind.h to call it.
1589
1590
   Nb: don't forget the function parentheses when using this in a
1591
   condition... write this:
1592
1593
     if (VG_(is_running_on_simd_CPU)()) { ... }    // calls function
1594
1595
   not this:
1596
1597
     if (VG_(is_running_on_simd_CPU)) { ... }      // address of var!
1598
*/
1599
extern Bool VG_(is_running_on_simd_CPU) ( void );
1600
1601
1602
/*====================================================================*/
1603
/*=== Specific stuff for replacing malloc() and friends            ===*/
1604
/*====================================================================*/
1605
1606
/* If a skin replaces malloc() et al, the easiest way to do so is to link
1607
   with coregrind/vg_replace_malloc.c, and follow the following instructions.
1608
   You can do it from scratch, though, if you enjoy that sort of thing. */
1609
1610
/* Arena size for valgrind's own malloc();  default value is 0, but can
1611
   be overridden by skin -- but must be done so *statically*, eg:
1612
1613
     Int VG_(vg_malloc_redzone_szB) = 4;
1614
1615
   It can't be done from a function like SK_(pre_clo_init)().  So it can't,
1616
   for example, be controlled with a command line option, unfortunately. */
1617
extern UInt VG_(vg_malloc_redzone_szB);
1618
1619
/* If a skin links with vg_replace_malloc.c, the following functions will be
1620
   called appropriately when malloc() et al are called. */
1621
extern void* SK_(malloc)               ( Int n );
1622
extern void* SK_(__builtin_new)        ( Int n );
1623
extern void* SK_(__builtin_vec_new)    ( Int n );
1624
extern void* SK_(memalign)             ( Int align, Int n );
1625
extern void* SK_(calloc)               ( Int nmemb, Int n );
1626
extern void  SK_(free)                 ( void* p );
1627
extern void  SK_(__builtin_delete)     ( void* p );
1628
extern void  SK_(__builtin_vec_delete) ( void* p );
1629
extern void* SK_(realloc)              ( void* p, Int size );
1630
1631
/* Can be called from SK_(malloc) et al to do the actual alloc/freeing. */
1632
extern void* VG_(cli_malloc) ( UInt align, Int nbytes );
1633
extern void  VG_(cli_free)   ( void* p );
1634
1635
/* Check if an address is within a range, allowing for redzones at edges */
1636
extern Bool VG_(addr_is_in_block)( Addr a, Addr start, UInt size );
1637
1638
/* ------------------------------------------------------------------ */
1639
/* Some options that can be used by a skin if malloc() et al are replaced.
1640
   The skin should call the functions in the appropriate places to give
1641
   control over these aspects of Valgrind's version of malloc(). */
1642
1643
/* Round malloc sizes upwards to integral number of words? default: NO */
1644
extern Bool VG_(clo_sloppy_malloc);
1645
/* DEBUG: print malloc details?  default: NO */
1646
extern Bool VG_(clo_trace_malloc);
1647
/* Minimum alignment in functions that don't specify alignment explicitly.
1648
   default: 0, i.e. use default of the machine (== 4) */
1649
extern Int  VG_(clo_alignment);
1650
1651
extern Bool VG_(replacement_malloc_process_cmd_line_option) ( Char* arg );
1652
extern void VG_(replacement_malloc_print_usage)             ( void );
1653
extern void VG_(replacement_malloc_print_debug_usage)       ( void );
1654
1655
1656
/*====================================================================*/
1657
/*=== Skin-specific stuff                                          ===*/
1658
/*====================================================================*/
1659
1660
/* ------------------------------------------------------------------ */
1661
/* Details */
1662
1663
/* Default value for avg_translations_sizeB (in bytes), indicating typical
1664
   code expansion of about 6:1. */
1665
#define VG_DEFAULT_TRANS_SIZEB   100
1666
1667
/* Information used in the startup message.  `name' also determines the
1668
   string used for identifying suppressions in a suppression file as
1669
   belonging to this skin.  `version' can be NULL, in which case (not
1670
   surprisingly) no version info is printed; this mechanism is designed for
1671
   skins distributed with Valgrind that share a version number with
1672
   Valgrind.  Other skins not distributed as part of Valgrind should
1673
   probably have their own version number.  */
1674
extern void VG_(details_name)                  ( Char* name );
1675
extern void VG_(details_version)               ( Char* version );
1676
extern void VG_(details_description)           ( Char* description );
1677
extern void VG_(details_copyright_author)      ( Char* copyright_author );
1678
1679
/* Average size of a translation, in bytes, so that the translation
1680
   storage machinery can allocate memory appropriately.  Not critical,
1681
   setting is optional. */
1682
extern void VG_(details_avg_translation_sizeB) ( UInt size );
1683
1684
/* String printed if an `sk_assert' assertion fails or VG_(skin_panic)
1685
   is called.  Should probably be an email address. */
1686
extern void VG_(details_bug_reports_to)   ( Char* bug_reports_to );
1687
1688
/* ------------------------------------------------------------------ */
1689
/* Needs */
1690
1691
/* Booleans that decide core behaviour, but don't require extra
1692
   operations to be defined if `True' */
1693
1694
/* Should __libc_freeres() be run?  Bugs in it can crash the skin. */
1695
extern void VG_(needs_libc_freeres) ( void );
1696
1697
/* Want to have errors detected by Valgrind's core reported?  Includes:
1698
   - pthread API errors (many;  eg. unlocking a non-locked mutex)
1699
   - invalid file descriptors to blocking syscalls read() and write()
1700
   - bad signal numbers passed to sigaction()
1701
   - attempt to install signal handler for SIGKILL or SIGSTOP */
1702
extern void VG_(needs_core_errors) ( void );
1703
1704
/* Booleans that indicate extra operations are defined;  if these are True,
1705
   the corresponding template functions (given below) must be defined.  A
1706
   lot like being a member of a type class. */
1707
1708
/* Want to report errors from skin?  This implies use of suppressions, too. */
1709
extern void VG_(needs_skin_errors) ( void );
1710
1711
/* Is information kept about specific individual basic blocks?  (Eg. for
1712
   cachegrind there are cost-centres for every instruction, stored at a
1713
   basic block level.)  If so, it sometimes has to be discarded, because
1714
   .so mmap/munmap-ping or self-modifying code (informed by the
1715
   DISCARD_TRANSLATIONS user request) can cause one instruction address
1716
   to be used for more than one instruction in one program run...  */
1717
extern void VG_(needs_basic_block_discards) ( void );
1718
1719
/* Skin maintains information about each register? */
1720
extern void VG_(needs_shadow_regs) ( void );
1721
1722
/* Skin defines its own command line options? */
1723
extern void VG_(needs_command_line_options) ( void );
1724
1725
/* Skin defines its own client requests? */
1726
extern void VG_(needs_client_requests) ( void );
1727
1728
/* Skin defines its own UInstrs? */
1729
extern void VG_(needs_extended_UCode) ( void );
1730
1731
/* Skin does stuff before and/or after system calls? */
1732
extern void VG_(needs_syscall_wrapper) ( void );
1733
1734
/* Are skin-state sanity checks performed? */
1735
extern void VG_(needs_sanity_checks) ( void );
1736
1737
/* Do we need to see data symbols? */
1738
extern void VG_(needs_data_syms) ( void );
1739
1740
/* ------------------------------------------------------------------ */
1741
/* Core events to track */
1742
1743
/* Part of the core from which this call was made.  Useful for determining
1744
   what kind of error message should be emitted. */
1745
typedef
1746
   enum { Vg_CorePThread, Vg_CoreSignal, Vg_CoreSysCall, Vg_CoreTranslate }
1747
   CorePart;
1748
1749
#define EV  extern void
1750
1751
/* Events happening in core to track.  To be notified, pass a callback
1752
   function to the appropriate function.  To ignore an event, don't do
1753
   anything (default is for events to be ignored).
1754
1755
   Note that most events aren't passed a ThreadId.  To find out the ThreadId
1756
   of the affected thread, use VG_(get_current_or_recent_tid)().  For the
1757
   ones passed a ThreadId, use that instead, since
1758
   VG_(get_current_or_recent_tid)() might not give the right ThreadId in
1759
   that case.
1760
*/
1761
1762
1763
/* Memory events (Nb: to track heap allocation/freeing, a skin must replace
1764
   malloc() et al.  See above how to do this.) */
1765
1766
/* These ones occur at startup, upon some signals, and upon some syscalls */
1767
EV VG_(track_new_mem_startup) ( void (*f)(Addr a, UInt len,
1768
                                          Bool rr, Bool ww, Bool xx) );
1769
EV VG_(track_new_mem_stack_signal)  ( void (*f)(Addr a, UInt len) );
1770
EV VG_(track_new_mem_brk)     ( void (*f)(Addr a, UInt len) );
1771
EV VG_(track_new_mem_mmap)    ( void (*f)(Addr a, UInt len,
1772
                                          Bool rr, Bool ww, Bool xx) );
1773
1774
EV VG_(track_copy_mem_remap)  ( void (*f)(Addr from, Addr to, UInt len) );
1775
EV VG_(track_change_mem_mprotect) ( void (*f)(Addr a, UInt len,
1776
                                              Bool rr, Bool ww, Bool xx) );
1777
EV VG_(track_die_mem_stack_signal)  ( void (*f)(Addr a, UInt len) );
1778
EV VG_(track_die_mem_brk)     ( void (*f)(Addr a, UInt len) );
1779
EV VG_(track_die_mem_munmap)  ( void (*f)(Addr a, UInt len) );
1780
1781
1782
/* These ones are called when %esp changes.  A skin could track these itself
1783
   (except for ban_mem_stack) but it's much easier to use the core's help.
1784
1785
   The specialised ones are called in preference to the general one, if they
1786
   are defined.  These functions are called a lot if they are used, so
1787
   specialising can optimise things significantly.  If any of the
1788
   specialised cases are defined, the general case must be defined too.
1789
1790
   Nb: they must all use the __attribute__((regparm(n))) attribute. */
1791
EV VG_(track_new_mem_stack_4)  ( void (*f)(Addr new_ESP) );
1792
EV VG_(track_new_mem_stack_8)  ( void (*f)(Addr new_ESP) );
1793
EV VG_(track_new_mem_stack_12) ( void (*f)(Addr new_ESP) );
1794
EV VG_(track_new_mem_stack_16) ( void (*f)(Addr new_ESP) );
1795
EV VG_(track_new_mem_stack_32) ( void (*f)(Addr new_ESP) );
1796
EV VG_(track_new_mem_stack)    ( void (*f)(Addr a, UInt len) );
1797
1798
EV VG_(track_die_mem_stack_4)  ( void (*f)(Addr die_ESP) );
1799
EV VG_(track_die_mem_stack_8)  ( void (*f)(Addr die_ESP) );
1800
EV VG_(track_die_mem_stack_12) ( void (*f)(Addr die_ESP) );
1801
EV VG_(track_die_mem_stack_16) ( void (*f)(Addr die_ESP) );
1802
EV VG_(track_die_mem_stack_32) ( void (*f)(Addr die_ESP) );
1803
EV VG_(track_die_mem_stack)    ( void (*f)(Addr a, UInt len) );
1804
1805
/* Used for redzone at end of thread stacks */
1806
EV VG_(track_ban_mem_stack)   ( void (*f)(Addr a, UInt len) );
1807
1808
/* These ones occur around syscalls, signal handling, etc */
1809
EV VG_(track_pre_mem_read)    ( void (*f)(CorePart part, ThreadId tid,
1810
                                          Char* s, Addr a, UInt size) );
1811
EV VG_(track_pre_mem_read_asciiz) ( void (*f)(CorePart part, ThreadId tid,
1812
                                              Char* s, Addr a) );
1813
EV VG_(track_pre_mem_write)   ( void (*f)(CorePart part, ThreadId tid,
1814
                                          Char* s, Addr a, UInt size) );
1815
/* Not implemented yet -- have to add in lots of places, which is a
1816
   pain.  Won't bother unless/until there's a need. */
1817
/* EV VG_(track_post_mem_read)  ( void (*f)(ThreadId tid, Char* s,
1818
                                            Addr a, UInt size) ); */
1819
EV VG_(track_post_mem_write) ( void (*f)(Addr a, UInt size) );
1820
1821
1822
/* Register events -- if `shadow_regs' need is set, all should probably be
1823
   used.  Use VG_(set_thread_shadow_archreg)() to set the shadow of the
1824
   changed register. */
1825
1826
/* Use VG_(set_shadow_archreg)() to set the eight general purpose regs,
1827
   and use VG_(set_shadow_eflags)() to set eflags. */
1828
EV VG_(track_post_regs_write_init)  ( void (*f)() );
1829
1830
/* Use VG_(set_thread_shadow_archreg)() to set the shadow regs for these
1831
   events. */
1832
EV VG_(track_post_reg_write_syscall_return)
1833
                                    ( void (*f)(ThreadId tid, UInt reg) );
1834
EV VG_(track_post_reg_write_deliver_signal)
1835
                                    ( void (*f)(ThreadId tid, UInt reg) );
1836
EV VG_(track_post_reg_write_pthread_return)
1837
                                    ( void (*f)(ThreadId tid, UInt reg) );
1838
EV VG_(track_post_reg_write_clientreq_return)
1839
                                    ( void (*f)(ThreadId tid, UInt reg) );
1840
   /* This one is called for malloc() et al if they are replaced by a skin. */
1841
EV VG_(track_post_reg_write_clientcall_return)
1842
                                    ( void (*f)(ThreadId tid, UInt reg,
1843
                                                Addr called_function) );
1844
1845
1846
/* Scheduler events (not exhaustive) */
1847
1848
EV VG_(track_thread_run) ( void (*f)(ThreadId tid) );
1849
1850
/* Thread events (not exhaustive) */
1851
1852
/* Called during thread create, before the new thread has run any
1853
   instructions (or touched any memory). */
1854
EV VG_(track_post_thread_create)( void (*f)(ThreadId tid, ThreadId child) );
1855
/* Called once the joinee thread is terminated and the joining thread is
1856
   about to resume. */
1857
EV VG_(track_post_thread_join)  ( void (*f)(ThreadId joiner, ThreadId joinee) );
1858
1859
1860
/* Mutex events (not exhaustive) */
1861
1862
/* Called before a thread can block while waiting for a mutex (called
1863
   regardless of whether the thread will block or not). */
1864
EV VG_(track_pre_mutex_lock)    ( void (*f)(ThreadId tid,
1865
                                          void* /*pthread_mutex_t* */ mutex) );
1866
/* Called once the thread actually holds the mutex (always paired with
1867
   pre_mutex_lock). */
1868
EV VG_(track_post_mutex_lock)   ( void (*f)(ThreadId tid,
1869
                                          void* /*pthread_mutex_t* */ mutex) );
1870
/* Called after a thread has released a mutex (no need for a corresponding
1871
   pre_mutex_unlock, because unlocking can't block). */
1872
EV VG_(track_post_mutex_unlock) ( void (*f)(ThreadId tid,
1873
                                          void* /*pthread_mutex_t* */ mutex) );
1874
1875
1876
/* Signal events (not exhaustive) */
1877
1878
/* ... pre_send_signal, post_send_signal ... */
1879
1880
/* Called before a signal is delivered;  `alt_stack' indicates if it is
1881
   delivered on an alternative stack. */
1882
EV VG_(track_pre_deliver_signal)  ( void (*f)(ThreadId tid, Int sigNum,
1883
                                             Bool alt_stack) );
1884
/* Called after a signal is delivered.  Nb: unfortunately, if the signal
1885
   handler longjmps, this won't be called. */
1886
EV VG_(track_post_deliver_signal) ( void (*f)(ThreadId tid, Int sigNum ) );
1887
1888
1889
/* Others... condition variables... */
1890
/* ... */
1891
1892
#undef EV
1893
1894
/* ------------------------------------------------------------------ */
1895
/* Template functions */
1896
1897
/* These are the parameterised functions in the core.  The default definitions
1898
   are overridden by LD_PRELOADed skin version.  At the very least, a skin
1899
   must define the fundamental template functions.  Depending on what needs
1900
   are set, extra template functions will be used too.  Functions are
1901
   grouped under the needs that govern their use. */
1902
1903
1904
/* ------------------------------------------------------------------ */
1905
/* Fundamental template functions */
1906
1907
/* Initialise skin.   Must do the following:
1908
     - initialise the `details' struct, via the VG_(details_*)() functions
1909
     - register any helpers called by generated code
1910
1911
   May do the following:
1912
     - initialise the `needs' struct to indicate certain requirements, via
1913
       the VG_(needs_*)() functions
1914
     - initialise the `track' struct to indicate core events of interest, via
1915
       the VG_(track_*)() functions
1916
     - register any skin-specific profiling events
1917
     - any other skin-specific initialisation
1918
*/
1919
extern void        SK_(pre_clo_init) ( void );
1920
1921
/* Do initialisation that can only be done after command line processing. */
1922
extern void        SK_(post_clo_init)( void );
1923
1924
/* Instrument a basic block.  Must be a true function, ie. the same input
1925
   always results in the same output, because basic blocks can be
1926
   retranslated.  Unless you're doing something really strange...
1927
   'orig_addr' is the address of the first instruction in the block. */
1928
extern UCodeBlock* SK_(instrument)   ( UCodeBlock* cb, Addr orig_addr );
1929
1930
/* Finish up, print out any results, etc.  `exitcode' is program's exit
1931
   code.  The shadow (if the `shadow_regs' need is set) can be found with
1932
   VG_(get_shadow_archreg)(R_EBX), since %ebx holds the argument to the
1933
   exit() syscall.  */
1934
extern void        SK_(fini)         ( Int exitcode );
1935
1936
1937
/* ------------------------------------------------------------------ */
1938
/* VG_(needs).core_errors */
1939
1940
/* (none needed) */
1941
1942
/* ------------------------------------------------------------------ */
1943
/* VG_(needs).skin_errors */
1944
1945
/* Identify if two errors are equal, or equal enough.  `res' indicates how
1946
   close is "close enough".  `res' should be passed on as necessary, eg. if
1947
   the Error's `extra' part contains an ExeContext, `res' should be
1948
   passed to VG_(eq_ExeContext)() if the ExeContexts are considered.  Other
1949
   than that, probably don't worry about it unless you have lots of very
1950
   similar errors occurring.
1951
 */
1952
extern Bool SK_(eq_SkinError) ( VgRes res, Error* e1, Error* e2 );
1953
1954
/* Print error context. */
1955
extern void SK_(pp_SkinError) ( Error* err );
1956
1957
/* Should fill in any details that could be postponed until after the
1958
   decision whether to ignore the error (ie. details not affecting the
1959
   result of SK_(eq_SkinError)()).  This saves time when errors are ignored.
1960
   Yuk.
1961
1962
   Return value: must be the size of the `extra' part in bytes -- used by
1963
   the core to make a copy.
1964
*/
1965
extern UInt SK_(update_extra) ( Error* err );
1966
1967
/* Return value indicates recognition.  If recognised, must set skind using
1968
   VG_(set_supp_kind)(). */
1969
extern Bool SK_(recognised_suppression) ( Char* name, Supp* su );
1970
1971
/* Read any extra info for this suppression kind.  Most likely for filling
1972
   in the `extra' and `string' parts (with VG_(set_supp_{extra,string})())
1973
   of a suppression if necessary.  Should return False if a syntax error
1974
   occurred, True otherwise. */
1975
extern Bool SK_(read_extra_suppression_info) ( Int fd, Char* buf, Int nBuf,
1976
                                               Supp* su );
1977
1978
/* This should just check the kinds match and maybe some stuff in the
1979
   `string' and `extra' field if appropriate (using VG_(get_supp_*)() to
1980
   get the relevant suppression parts). */
1981
extern Bool SK_(error_matches_suppression) ( Error* err, Supp* su );
1982
1983
/* This should return the suppression name, for --gen-suppressions, or NULL
1984
   if that error type cannot be suppressed.  This is the inverse of
1985
   SK_(recognised_suppression)(). */
1986
extern Char* SK_(get_error_name) ( Error* err );
1987
1988
/* This should print any extra info for the error, for --gen-suppressions,
1989
   including the newline.  This is the inverse of
1990
   SK_(read_extra_suppression_info)(). */
1991
extern void SK_(print_extra_suppression_info) ( Error* err );
1992
1993
1994
/* ------------------------------------------------------------------ */
1995
/* VG_(needs).basic_block_discards */
1996
1997
/* Should discard any information that pertains to specific basic blocks
1998
   or instructions within the address range given. */
1999
extern void SK_(discard_basic_block_info) ( Addr a, UInt size );
2000
2001
2002
/* ------------------------------------------------------------------ */
2003
/* VG_(needs).shadow_regs */
2004
2005
/* No functions must be defined, but the post_reg[s]_write_* events should
2006
   be tracked. */
2007
2008
/* ------------------------------------------------------------------ */
2009
/* VG_(needs).command_line_options */
2010
2011
/* Return True if option was recognised.  Presumably sets some state to
2012
   record the option as well. */
2013
extern Bool SK_(process_cmd_line_option) ( Char* argv );
2014
2015
/* Print out command line usage for options for normal skin operation. */
2016
extern void SK_(print_usage)             ( void );
2017
2018
/* Print out command line usage for options for debugging the skin. */
2019
extern void SK_(print_debug_usage)       ( void );
2020
2021
/* ------------------------------------------------------------------ */
2022
/* VG_(needs).client_requests */
2023
2024
/* If using client requests, the number of the first request should be equal
2025
   to VG_USERREQ_SKIN_BASE('X','Y'), where 'X' and 'Y' form a suitable two
2026
   character identification for the string.  The second and subsequent
2027
   requests should follow. */
2028
2029
/* This function should use the VG_IS_SKIN_USERREQ macro (in
2030
   include/valgrind.h) to first check if it's a request for this skin.  Then
2031
   should handle it if it's recognised (and return True), or return False if
2032
   not recognised.  arg_block[0] holds the request number, any further args
2033
   from the request are in arg_block[1..].  'ret' is for the return value...
2034
   it should probably be filled, if only with 0. */
2035
extern Bool SK_(handle_client_request) ( ThreadId tid, UInt* arg_block,
2036
                                         UInt *ret );
2037
2038
2039
/* ------------------------------------------------------------------ */
2040
/* VG_(needs).extends_UCode */
2041
2042
/* Useful to use in VG_(get_Xreg_usage)() */
2043
#define VG_UINSTR_READS_REG(ono,regs,isWrites)  \
2044
   { if (mycat(u->tag,ono) == tag)              \
2045
        { regs[n]     = mycat(u->val,ono);      \
2046
          isWrites[n] = False;                  \
2047
          n++;                                  \
2048
        }                                       \
2049
   }
2050
#define VG_UINSTR_WRITES_REG(ono,regs,isWrites) \
2051
   { if (mycat(u->tag,ono) == tag)              \
2052
        { regs[n]     = mycat(u->val,ono);      \
2053
          isWrites[n] = True;                   \
2054
          n++;                                  \
2055
        }                                       \
2056
   }
2057
2058
/* 'X' prefix indicates eXtended UCode. */
2059
extern Int   SK_(get_Xreg_usage) ( UInstr* u, Tag tag, Int* regs,
2060
                                   Bool* isWrites );
2061
extern void  SK_(emit_XUInstr)   ( UInstr* u, RRegSet regs_live_before );
2062
extern Bool  SK_(sane_XUInstr)   ( Bool beforeRA, Bool beforeLiveness,
2063
                                   UInstr* u );
2064
extern Char* SK_(name_XUOpcode)  ( Opcode opc );
2065
extern void  SK_(pp_XUInstr)     ( UInstr* u );
2066
2067
2068
/* ------------------------------------------------------------------ */
2069
/* VG_(needs).syscall_wrapper */
2070
2071
/* If either of the pre_ functions malloc() something to return, the
2072
 * corresponding post_ function had better free() it!
2073
 */
2074
extern void* SK_( pre_syscall) ( ThreadId tid, UInt syscallno,
2075
                                 Bool is_blocking );
2076
extern void  SK_(post_syscall) ( ThreadId tid, UInt syscallno,
2077
                                 void* pre_result, Int res,
2078
                                 Bool is_blocking );
2079
2080
2081
/* ---------------------------------------------------------------------
2082
   VG_(needs).sanity_checks */
2083
2084
/* Can be useful for ensuring a skin's correctness.  SK_(cheap_sanity_check)
2085
   is called very frequently;  SK_(expensive_sanity_check) is called less
2086
   frequently and can be more involved. */
2087
extern Bool SK_(cheap_sanity_check)     ( void );
2088
extern Bool SK_(expensive_sanity_check) ( void );
2089
2090
2091
#endif   /* NDEF __VG_SKIN_H */
2092
2093
/*--------------------------------------------------------------------*/
2094
/*--- end                                                vg_skin.h ---*/
2095
/*--------------------------------------------------------------------*/
2096
(-)valgrind-2.1.0/include/vg_skin.h.base (+1915 lines)
Line 0 Link Here
1
/*-*- c -*- ----------------------------------------------------------*/
2
/*--- The only header your skin will ever need to #include...      ---*/
3
/*---                                                    vg_skin.h ---*/
4
/*--------------------------------------------------------------------*/
5
6
/*
7
   This file is part of Valgrind, an extensible x86 protected-mode
8
   emulator for monitoring program execution on x86-Unixes.
9
10
   Copyright (C) 2000-2004 Julian Seward
11
      jseward@acm.org
12
13
   This program is free software; you can redistribute it and/or
14
   modify it under the terms of the GNU General Public License as
15
   published by the Free Software Foundation; either version 2 of the
16
   License, or (at your option) any later version.
17
18
   This program is distributed in the hope that it will be useful, but
19
   WITHOUT ANY WARRANTY; without even the implied warranty of
20
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21
   General Public License for more details.
22
23
   You should have received a copy of the GNU General Public License
24
   along with this program; if not, write to the Free Software
25
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26
   02111-1307, USA.
27
28
   The GNU General Public License is contained in the file COPYING.
29
*/
30
31
#ifndef __VG_SKIN_H
32
#define __VG_SKIN_H
33
34
#include <stdarg.h>       /* ANSI varargs stuff  */
35
#include <setjmp.h>       /* for jmp_buf         */
36
37
#include "vg_constants_skin.h"
38
39
40
/* ---------------------------------------------------------------------
41
   Where to send bug reports to.
42
   ------------------------------------------------------------------ */
43
44
#define VG_BUGS_TO "valgrind.kde.org"
45
46
47
/*====================================================================*/
48
/*=== Build options and table sizes.                               ===*/
49
/*====================================================================*/
50
51
/* You should be able to change these options or sizes, recompile, and
52
   still have a working system. */
53
54
/* The maximum number of pthreads that we support.  This is
55
   deliberately not very high since our implementation of some of the
56
   scheduler algorithms is surely O(N) in the number of threads, since
57
   that's simple, at least.  And (in practice) we hope that most
58
   programs do not need many threads. */
59
#define VG_N_THREADS 100
60
61
/* Maximum number of pthread keys available.  Again, we start low until
62
   the need for a higher number presents itself. */
63
#define VG_N_THREAD_KEYS 50
64
65
/* Total number of integer registers available for allocation -- all of
66
   them except %esp, %ebp.  %ebp permanently points at VG_(baseBlock).
67
68
   If you increase this you'll have to also change at least these:
69
     - VG_(rank_to_realreg)()
70
     - VG_(realreg_to_rank)()
71
     - ppRegsLiveness()
72
     - the RegsLive type (maybe -- RegsLive type must have more than
73
                          VG_MAX_REALREGS bits)
74
75
   You can decrease it, and performance will drop because more spills will
76
   occur.  If you decrease it too much, everything will fall over.
77
78
   Do not change this unless you really know what you are doing!  */
79
#define VG_MAX_REALREGS 6
80
81
82
/*====================================================================*/
83
/*=== Basic types, useful macros                                   ===*/
84
/*====================================================================*/
85
86
typedef unsigned char          UChar;
87
typedef unsigned short         UShort;
88
typedef unsigned int           UInt;
89
typedef unsigned long long int ULong;
90
91
typedef signed char            Char;
92
typedef signed short           Short;
93
typedef signed int             Int;
94
typedef signed long long int   Long;
95
96
typedef unsigned int           Addr;
97
98
typedef unsigned char          Bool;
99
#define False                  ((Bool)0)
100
#define True                   ((Bool)1)
101
102
103
#define mycat_wrk(aaa,bbb) aaa##bbb
104
#define mycat(aaa,bbb) mycat_wrk(aaa,bbb)
105
106
/* No, really.  I _am_ that strange. */
107
#define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d",nnn)
108
109
/* ---------------------------------------------------------------------
110
   Now the basic types are set up, we can haul in the kernel-interface
111
   definitions.
112
   ------------------------------------------------------------------ */
113
114
#include "vg_kerneliface.h"
115
116
117
/*====================================================================*/
118
/*=== Core/skin interface version                                  ===*/
119
/*====================================================================*/
120
121
/* The major version number indicates binary-incompatible changes to the
122
   interface;  if the core and skin major versions don't match, Valgrind
123
   will abort.  The minor version indicates binary-compatible changes.
124
*/
125
#define VG_CORE_INTERFACE_MAJOR_VERSION   5
126
#define VG_CORE_INTERFACE_MINOR_VERSION   0
127
128
typedef struct _ToolInfo {
129
   Int	sizeof_ToolInfo;
130
   Int	interface_major_version;
131
   Int	interface_minor_version;
132
133
   /* Initialise skin.   Must do the following:
134
      - initialise the `details' struct, via the VG_(details_*)() functions
135
      - register any helpers called by generated code
136
      
137
      May do the following:
138
      - initialise the `needs' struct to indicate certain requirements, via
139
      the VG_(needs_*)() functions
140
      - initialize all the tool's entrypoints via the VG_(init_*)() functions
141
      - register any skin-specific profiling events
142
      - any other skin-specific initialisation
143
   */
144
   void        (*sk_pre_clo_init) ( void );
145
146
   /* Specifies how big the shadow segment should be as a ratio to the
147
      client address space.  0 for no shadow segment. */
148
   float	shadow_ratio;
149
} ToolInfo;
150
151
/* Every skin must include this macro somewhere, exactly once. */
152
#define VG_DETERMINE_INTERFACE_VERSION(pre_clo_init, shadow)		\
153
   const ToolInfo SK_(tool_info) = {					\
154
      .sizeof_ToolInfo         = sizeof(ToolInfo),			\
155
      .interface_major_version = VG_CORE_INTERFACE_MAJOR_VERSION,	\
156
      .interface_minor_version = VG_CORE_INTERFACE_MINOR_VERSION,	\
157
      .sk_pre_clo_init         = pre_clo_init,				\
158
      .shadow_ratio	       = shadow,				\
159
   };
160
161
/*====================================================================*/
162
/*=== Command-line options                                         ===*/
163
/*====================================================================*/
164
165
/* Use this for normal null-termination-style string comparison */
166
#define VG_STREQ(s1,s2) (s1 != NULL && s2 != NULL \
167
                         && VG_(strcmp)((s1),(s2))==0)
168
169
/* Use these for recognising skin command line options -- stops comparing
170
   once whitespace is reached. */
171
#  define VG_CLO_STREQ(s1,s2)     (0==VG_(strcmp_ws)((s1),(s2)))
172
#  define VG_CLO_STREQN(nn,s1,s2) (0==VG_(strncmp_ws)((s1),(s2),(nn)))
173
174
/* Verbosity level: 0 = silent, 1 (default), > 1 = more verbose. */
175
extern Int   VG_(clo_verbosity);
176
177
/* Profile? */
178
extern Bool  VG_(clo_profile);
179
180
/* Call this if a recognised option was bad for some reason.
181
   Note: don't use it just because an option was unrecognised -- return 'False'
182
   from SKN_(process_cmd_line_option) to indicate that. */
183
extern void VG_(bad_option) ( Char* opt );
184
185
/* Client args */
186
extern Int    VG_(client_argc);
187
extern Char** VG_(client_argv);
188
189
/* Client environment.  Can be inspected with VG_(getenv)() */
190
extern Char** VG_(client_envp);
191
192
193
/*====================================================================*/
194
/*=== Printing messages for the user                               ===*/
195
/*====================================================================*/
196
197
/* Print a message prefixed by "??<pid>?? "; '?' depends on the VgMsgKind.
198
   Should be used for all user output. */
199
200
typedef
201
   enum { Vg_UserMsg,         /* '?' == '=' */
202
          Vg_DebugMsg,        /* '?' == '-' */
203
          Vg_DebugExtraMsg,   /* '?' == '+' */
204
          Vg_ClientMsg,       /* '?' == '*' */
205
   }
206
   VgMsgKind;
207
208
/* Functions for building a message from multiple parts. */
209
extern int VG_(start_msg)  ( VgMsgKind kind );
210
extern int VG_(add_to_msg) ( Char* format, ... );
211
/* Ends and prints the message.  Appends a newline. */
212
extern int VG_(end_msg)    ( void );
213
214
/* Send a single-part message.  Appends a newline. */
215
extern int VG_(message)    ( VgMsgKind kind, Char* format, ... );
216
extern int VG_(vmessage)   ( VgMsgKind kind, Char* format, va_list vargs );
217
218
219
/*====================================================================*/
220
/*=== Profiling                                                    ===*/
221
/*====================================================================*/
222
223
/* Nb: VGP_(register_profile_event)() relies on VgpUnc being the first one */
224
#define VGP_CORE_LIST \
225
   /* These ones depend on the core */                \
226
   VGP_PAIR(VgpUnc,         "unclassified"),          \
227
   VGP_PAIR(VgpStartup,     "startup"),               \
228
   VGP_PAIR(VgpRun,         "running"),               \
229
   VGP_PAIR(VgpSched,       "scheduler"),             \
230
   VGP_PAIR(VgpMalloc,      "low-lev malloc/free"),   \
231
   VGP_PAIR(VgpCliMalloc,   "client  malloc/free"),   \
232
   VGP_PAIR(VgpTranslate,   "translate-main"),        \
233
   VGP_PAIR(VgpToUCode,     "to-ucode"),              \
234
   VGP_PAIR(VgpFromUcode,   "from-ucode"),            \
235
   VGP_PAIR(VgpImprove,     "improve"),               \
236
   VGP_PAIR(VgpESPUpdate,   "ESP-update"),            \
237
   VGP_PAIR(VgpRegAlloc,    "reg-alloc"),             \
238
   VGP_PAIR(VgpLiveness,    "liveness-analysis"),     \
239
   VGP_PAIR(VgpDoLRU,       "do-lru"),                \
240
   VGP_PAIR(VgpSlowFindT,   "slow-search-transtab"),  \
241
   VGP_PAIR(VgpExeContext,  "exe-context"),           \
242
   VGP_PAIR(VgpReadSyms,    "read-syms"),             \
243
   VGP_PAIR(VgpSearchSyms,  "search-syms"),           \
244
   VGP_PAIR(VgpAddToT,      "add-to-transtab"),       \
245
   VGP_PAIR(VgpCoreSysWrap, "core-syscall-wrapper"),  \
246
   VGP_PAIR(VgpDemangle,    "demangle"),              \
247
   VGP_PAIR(VgpCoreCheapSanity,     "core-cheap-sanity"),     \
248
   VGP_PAIR(VgpCoreExpensiveSanity, "core-expensive-sanity"), \
249
   /* These ones depend on the skin */                \
250
   VGP_PAIR(VgpPreCloInit,  "pre-clo-init"),          \
251
   VGP_PAIR(VgpPostCloInit, "post-clo-init"),         \
252
   VGP_PAIR(VgpInstrument,  "instrument"),            \
253
   VGP_PAIR(VgpSkinSysWrap, "skin-syscall-wrapper"),  \
254
   VGP_PAIR(VgpSkinCheapSanity,     "skin-cheap-sanity"),     \
255
   VGP_PAIR(VgpSkinExpensiveSanity, "skin-expensive-sanity"), \
256
   VGP_PAIR(VgpFini,        "fini")
257
258
#define VGP_PAIR(n,name) n
259
typedef enum { VGP_CORE_LIST } VgpCoreCC;
260
#undef  VGP_PAIR
261
262
/* When registering skin profiling events, ensure that the 'n' value is in
263
 * the range (VgpFini+1..) */
264
extern void VGP_(register_profile_event) ( Int n, Char* name );
265
266
extern void VGP_(pushcc) ( UInt cc );
267
extern void VGP_(popcc)  ( UInt cc );
268
269
/* Define them only if they haven't already been defined by vg_profile.c */
270
#ifndef VGP_PUSHCC
271
#  define VGP_PUSHCC(x)
272
#endif
273
#ifndef VGP_POPCC
274
#  define VGP_POPCC(x)
275
#endif
276
277
278
/*====================================================================*/
279
/*=== Useful stuff to call from generated code                     ===*/
280
/*====================================================================*/
281
282
/* ------------------------------------------------------------------ */
283
/* General stuff */
284
285
/* 64-bit counter for the number of basic blocks done. */
286
extern ULong VG_(bbs_done);
287
288
/* Get the simulated %esp */
289
extern Addr VG_(get_stack_pointer) ( void );
290
291
/* Check if an address is 4-byte aligned */
292
#define IS_ALIGNED4_ADDR(aaa_p) (0 == (((UInt)(aaa_p)) & 3))
293
#define IS_ALIGNED8_ADDR(aaa_p) (0 == (((UInt)(aaa_p)) & 7))
294
295
296
/* ------------------------------------------------------------------ */
297
/* Thread-related stuff */
298
299
/* Special magic value for an invalid ThreadId.  It corresponds to
300
   LinuxThreads using zero as the initial value for
301
   pthread_mutex_t.__m_owner and pthread_cond_t.__c_waiting. */
302
#define VG_INVALID_THREADID ((ThreadId)(0))
303
304
/* ThreadIds are simply indices into the VG_(threads)[] array. */
305
typedef
306
   UInt
307
   ThreadId;
308
309
/* When looking for the current ThreadId, this is the safe option and
310
   probably the one you want.
311
312
   Details: Use this one from non-generated code, eg. from functions called
313
   on events like 'new_mem_heap'.  In such a case, the "current" thread is
314
   temporarily suspended as Valgrind's dispatcher is running.  This function
315
   is also suitable to be called from generated code (ie. from UCode, or a C
316
   function called directly from UCode).
317
318
   If you use VG_(get_current_tid)() from non-generated code, it will return
319
   0 signifying the invalid thread, which is probably not what you want. */
320
extern ThreadId VG_(get_current_or_recent_tid) ( void );
321
322
/* When looking for the current ThreadId, only use this one if you know what
323
   you are doing.
324
325
   Details: Use this one from generated code, eg. from C functions called
326
   from UCode.  (VG_(get_current_or_recent_tid)() is also suitable in that
327
   case.)  If you use this function from non-generated code, it will return
328
   0 signifying the invalid thread, which is probably not what you want. */
329
extern ThreadId VG_(get_current_tid)           ( void );
330
331
/* Searches through all thread's stacks to see if any match.  Returns
332
   VG_INVALID_THREADID if none match. */
333
extern ThreadId VG_(first_matching_thread_stack)
334
                        ( Bool (*p) ( Addr stack_min, Addr stack_max ));
335
336
337
/*====================================================================*/
338
/*=== Valgrind's version of libc                                   ===*/
339
/*====================================================================*/
340
341
/* Valgrind doesn't use libc at all, for good reasons (trust us).  So here
342
   are its own versions of C library functions, but with VG_ prefixes.  Note
343
   that the types of some are slightly different to the real ones.  Some
344
   additional useful functions are provided too; descriptions of how they
345
   work are given below. */
346
347
#if !defined(NULL)
348
#  define NULL ((void*)0)
349
#endif
350
351
352
/* ------------------------------------------------------------------ */
353
/* stdio.h
354
 *
355
 * Note that they all output to the file descriptor given by the
356
 * --logfile-fd=N argument, which defaults to 2 (stderr).  Hence no
357
 * need for VG_(fprintf)().
358
 */
359
extern UInt VG_(printf)  ( const char *format, ... );
360
/* too noisy ...  __attribute__ ((format (printf, 1, 2))) ; */
361
extern UInt VG_(sprintf) ( Char* buf, Char *format, ... );
362
extern UInt VG_(vprintf) ( void(*send)(Char),
363
                           const Char *format, va_list vargs );
364
365
extern Int  VG_(rename) ( Char* old_name, Char* new_name );
366
367
/* ------------------------------------------------------------------ */
368
/* stdlib.h */
369
370
extern void* VG_(malloc)         ( Int nbytes );
371
extern void  VG_(free)           ( void* p );
372
extern void* VG_(calloc)         ( Int n, Int nbytes );
373
extern void* VG_(realloc)        ( void* p, Int size );
374
extern void* VG_(malloc_aligned) ( Int align_bytes, Int nbytes );
375
376
extern void  VG_(print_malloc_stats) ( void );
377
378
379
extern void  VG_(exit)( Int status )
380
             __attribute__ ((__noreturn__));
381
/* Prints a panic message (a constant string), appends newline and bug
382
   reporting info, aborts. */
383
__attribute__ ((__noreturn__))
384
extern void  VG_(skin_panic) ( Char* str );
385
386
/* Looks up VG_(client_envp) */
387
extern Char* VG_(getenv) ( Char* name );
388
389
/* Get client resource limit*/
390
extern Int VG_(getrlimit) ( Int resource, struct vki_rlimit *rlim );
391
392
/* Set client resource limit*/
393
extern Int VG_(setrlimit) ( Int resource, struct vki_rlimit *rlim );
394
395
/* Crude stand-in for the glibc system() call. */
396
extern Int   VG_(system) ( Char* cmd );
397
398
extern Long  VG_(atoll)  ( Char* str );
399
400
/* Like atoll(), but converts a number of base 16 */
401
extern Long  VG_(atoll16) ( Char* str );
402
403
/* Like atoll(), but converts a number of base 2..36 */
404
extern Long  VG_(atoll36) ( UInt base, Char* str );
405
406
/* Like qsort(), but does shell-sort.  The size==1/2/4 cases are specialised. */
407
extern void VG_(ssort)( void* base, UInt nmemb, UInt size,
408
                        Int (*compar)(void*, void*) );
409
410
411
/* ------------------------------------------------------------------ */
412
/* ctype.h */
413
extern Bool VG_(isspace) ( Char c );
414
extern Bool VG_(isdigit) ( Char c );
415
extern Char VG_(toupper) ( Char c );
416
417
418
/* ------------------------------------------------------------------ */
419
/* string.h */
420
extern Int   VG_(strlen)         ( const Char* str );
421
extern Char* VG_(strcat)         ( Char* dest, const Char* src );
422
extern Char* VG_(strncat)        ( Char* dest, const Char* src, Int n );
423
extern Char* VG_(strpbrk)        ( const Char* s, const Char* accept );
424
extern Char* VG_(strcpy)         ( Char* dest, const Char* src );
425
extern Char* VG_(strncpy)        ( Char* dest, const Char* src, Int ndest );
426
extern Int   VG_(strcmp)         ( const Char* s1, const Char* s2 );
427
extern Int   VG_(strncmp)        ( const Char* s1, const Char* s2, Int nmax );
428
extern Char* VG_(strstr)         ( const Char* haystack, Char* needle );
429
extern Char* VG_(strchr)         ( const Char* s, Char c );
430
extern Char* VG_(strdup)         ( const Char* s);
431
extern void* VG_(memcpy)         ( void *d, const void *s, Int sz );
432
extern void* VG_(memset)         ( void *s, Int c, Int sz );
433
extern Int   VG_(memcmp)         ( const void* s1, const void* s2, Int n );
434
435
/* Like strcmp() and strncmp(), but stop comparing at any whitespace. */
436
extern Int   VG_(strcmp_ws)      ( const Char* s1, const Char* s2 );
437
extern Int   VG_(strncmp_ws)     ( const Char* s1, const Char* s2, Int nmax );
438
439
/* Like strncpy(), but if 'src' is longer than 'ndest' inserts a '\0' as the
440
   last character. */
441
extern void  VG_(strncpy_safely) ( Char* dest, const Char* src, Int ndest );
442
443
/* Mini-regexp function.  Searches for 'pat' in 'str'.  Supports
444
 * meta-symbols '*' and '?'.  '\' escapes meta-symbols. */
445
extern Bool  VG_(string_match)   ( const Char* pat, const Char* str );
446
447
448
/* ------------------------------------------------------------------ */
449
/* math.h */
450
/* Returns the base-2 logarithm of x. */
451
extern Int VG_(log2) ( Int x );
452
453
454
/* ------------------------------------------------------------------ */
455
/* unistd.h, fcntl.h, sys/stat.h */
456
extern Int  VG_(getdents)( UInt fd, struct vki_dirent *dirp, UInt count );
457
extern Int  VG_(readlink)( Char* path, Char* buf, UInt bufsize );
458
extern Int  VG_(getpid)  ( void );
459
extern Int  VG_(getppid) ( void );
460
extern Int  VG_(getpgrp) ( void );
461
extern Int  VG_(gettid)	 ( void );
462
extern Int  VG_(setpgid) ( Int pid, Int pgrp );
463
464
extern Int  VG_(open)   ( const Char* pathname, Int flags, Int mode );
465
extern Int  VG_(read)   ( Int fd, void* buf, Int count);
466
extern Int  VG_(write)  ( Int fd, const void* buf, Int count);
467
extern Int  VG_(lseek)  ( Int fd, Long offset, Int whence);
468
extern void VG_(close)  ( Int fd );
469
470
extern Int  VG_(pipe)   ( Int fd[2] );
471
472
/* Nb: VG_(rename)() declared in stdio.h section above */
473
extern Int  VG_(unlink) ( Char* file_name );
474
extern Int  VG_(stat)   ( Char* file_name, struct vki_stat* buf );
475
extern Int  VG_(fstat)  ( Int   fd,        struct vki_stat* buf );
476
extern Int  VG_(dup2)   ( Int oldfd, Int newfd );
477
478
extern Char* VG_(getcwd) ( Char* buf, Int size );
479
480
/* Easier to use than VG_(getcwd)() -- does the buffer fiddling itself.
481
   String put into 'cwd' is VG_(malloc)'d, and should be VG_(free)'d.
482
   Returns False if it fails.  Will fail if the pathname is > 65535 bytes. */
483
extern Bool VG_(getcwd_alloc) ( Char** cwd );
484
485
/* ------------------------------------------------------------------ */
486
/* assert.h */
487
/* Asserts permanently enabled -- no turning off with NDEBUG.  Hurrah! */
488
#define VG__STRING(__str)  #__str
489
490
#define sk_assert(expr)                                               \
491
  ((void) ((expr) ? 0 :						      \
492
	   (VG_(skin_assert_fail) (VG__STRING(expr),	              \
493
			           __FILE__, __LINE__,                \
494
                                   __PRETTY_FUNCTION__), 0)))
495
496
__attribute__ ((__noreturn__))
497
extern void VG_(skin_assert_fail) ( const Char* expr, const Char* file,
498
                                    Int line, const Char* fn );
499
500
501
/* ------------------------------------------------------------------ */
502
/* Get memory by anonymous mmap. */
503
extern void* VG_(get_memory_from_mmap) ( Int nBytes, Char* who );
504
505
extern Bool VG_(is_client_addr) (Addr a);
506
extern Addr VG_(get_client_base)(void);
507
extern Addr VG_(get_client_end) (void);
508
extern Addr VG_(get_client_size)(void);
509
510
extern Bool VG_(is_shadow_addr) (Addr a);
511
extern Addr VG_(get_shadow_base)(void);
512
extern Addr VG_(get_shadow_end) (void);
513
extern Addr VG_(get_shadow_size)(void);
514
515
extern void *VG_(shadow_alloc)(UInt size);
516
517
extern Bool VG_(is_addressable)(Addr p, Int sz);
518
519
extern Addr VG_(client_alloc)(Addr base, UInt len, UInt prot, UInt flags);
520
extern void VG_(client_free)(Addr addr);
521
522
extern Bool VG_(is_valgrind_addr)(Addr a);
523
524
/* initialize shadow pages in the range [p, p+sz) This calls
525
   init_shadow_page for each one.  It should be a lot more efficient
526
   for bulk-initializing shadow pages than faulting on each one. 
527
*/
528
extern void VG_(init_shadow_range)(Addr p, UInt sz, Bool call_init);
529
530
/* ------------------------------------------------------------------ */
531
/* signal.h.
532
533
   Note that these use the vk_ (kernel) structure
534
   definitions, which are different in places from those that glibc
535
   defines -- hence the 'k' prefix.  Since we're operating right at the
536
   kernel interface, glibc's view of the world is entirely irrelevant. */
537
538
/* --- Signal set ops --- */
539
extern Int  VG_(ksigfillset)  ( vki_ksigset_t* set );
540
extern Int  VG_(ksigemptyset) ( vki_ksigset_t* set );
541
542
extern Bool VG_(kisfullsigset)  ( vki_ksigset_t* set );
543
extern Bool VG_(kisemptysigset) ( vki_ksigset_t* set );
544
545
extern Int  VG_(ksigaddset)   ( vki_ksigset_t* set, Int signum );
546
extern Int  VG_(ksigdelset)   ( vki_ksigset_t* set, Int signum );
547
extern Int  VG_(ksigismember) ( vki_ksigset_t* set, Int signum );
548
549
extern void VG_(ksigaddset_from_set) ( vki_ksigset_t* dst, vki_ksigset_t* src );
550
extern void VG_(ksigdelset_from_set) ( vki_ksigset_t* dst, vki_ksigset_t* src );
551
552
/* --- Mess with the kernel's sig state --- */
553
extern Int VG_(ksigprocmask) ( Int how, const vki_ksigset_t* set,
554
                                       vki_ksigset_t* oldset );
555
extern Int VG_(ksigaction)   ( Int signum,
556
                               const vki_ksigaction* act,
557
                               vki_ksigaction* oldact );
558
559
extern Int VG_(ksigtimedwait)( const vki_ksigset_t *, vki_ksiginfo_t *, 
560
			       const struct vki_timespec * );
561
562
extern Int VG_(ksignal)      ( Int signum, void (*sighandler)(Int) );
563
extern Int VG_(ksigaltstack) ( const vki_kstack_t* ss, vki_kstack_t* oss );
564
565
extern Int VG_(kkill)        ( Int pid, Int signo );
566
extern Int VG_(ktkill)       ( Int pid, Int signo );
567
extern Int VG_(ksigpending)  ( vki_ksigset_t* set );
568
569
extern Int VG_(waitpid)	     ( Int pid, Int *status, Int options );
570
571
/* ------------------------------------------------------------------ */
572
/* socket.h. */
573
574
extern Int VG_(getsockname) ( Int sd, struct vki_sockaddr *name, Int *namelen);
575
extern Int VG_(getpeername) ( Int sd, struct vki_sockaddr *name, Int *namelen);
576
extern Int VG_(getsockopt) ( Int sd, Int level, Int optname, void *optval,
577
                             Int *optlen);
578
579
/* ------------------------------------------------------------------ */
580
/* other, randomly useful functions */
581
extern UInt VG_(read_millisecond_timer) ( void );
582
583
/*====================================================================*/
584
/*=== UCode definition                                             ===*/
585
/*====================================================================*/
586
587
/* Tags which describe what operands are.  Must fit into 4 bits, which
588
   they clearly do. */
589
typedef
590
enum { TempReg  =0, /* virtual temp-reg */
591
       ArchReg  =1, /* simulated integer reg */
592
       ArchRegS =2, /* simulated segment reg */
593
       RealReg  =3, /* real machine's real reg */
594
       SpillNo  =4, /* spill slot location */
595
       Literal  =5, /* literal; .lit32 field has actual value */
596
       Lit16    =6, /* literal; .val[123] field has actual value */
597
       NoValue  =7  /* operand not in use */
598
     }
599
     Tag;
600
601
/* Invalid register numbers (can't be negative) */
602
#define INVALID_TEMPREG 999999999
603
#define INVALID_REALREG 999999999
604
605
/* Microinstruction opcodes. */
606
typedef
607
   enum {
608
      NOP,         /* Null op */
609
610
      LOCK,	   /* Indicate the existence of a LOCK prefix (functionally NOP) */
611
612
      /* Moving values around */
613
      GET,  PUT,   /* simulated register <--> TempReg */
614
      GETF, PUTF,  /* simulated %eflags  <--> TempReg */
615
      LOAD, STORE, /* memory  <--> TempReg            */
616
      MOV,         /* TempReg <--> TempReg            */
617
      CMOV,        /* Used for cmpxchg and cmov       */
618
619
      /* Arithmetic/logical ops */
620
      MUL, UMUL,                	  /* Multiply */
621
      ADD, ADC, SUB, SBB,                 /* Add/subtract (w/wo carry)     */
622
      AND, OR,  XOR, NOT,                 /* Boolean ops                   */
623
      SHL, SHR, SAR, ROL, ROR, RCL, RCR,  /* Shift/rotate (w/wo carry)     */
624
      NEG,                                /* Negate                        */
625
      INC, DEC,                           /* Increment/decrement           */
626
      BSWAP,                              /* Big-endian <--> little-endian */
627
      CC2VAL,                             /* Condition code --> 0 or 1     */
628
      WIDEN,                              /* Signed or unsigned widening   */
629
630
      /* Conditional or unconditional jump  */
631
      JMP,
632
633
      /* FPU ops */
634
      FPU,           /* Doesn't touch memory */
635
      FPU_R, FPU_W,  /* Reads/writes memory  */
636
637
      /* ------------ MMX ops ------------ */
638
      /* In this and the SSE encoding, bytes at higher addresses are
639
	 held in bits [7:0] in these 16-bit words.  I guess this means
640
	 it is a big-endian encoding. */
641
642
      /* 1 byte, no memrefs, no iregdefs, copy exactly to the
643
	 output.  Held in val1[7:0]. */
644
      MMX1,
645
646
      /* 2 bytes, no memrefs, no iregdefs, copy exactly to the
647
	 output.  Held in val1[15:0]. */
648
      MMX2,
649
650
      /* 3 bytes, no memrefs, no iregdefs, copy exactly to the
651
         output.  Held in val1[15:0] and val2[7:0]. */
652
      MMX3,
653
654
      /* 2 bytes, reads/writes mem.  Insns of the form
655
         bbbbbbbb:mod mmxreg r/m.
656
         Held in val1[15:0], and mod and rm are to be replaced
657
         at codegen time by a reference to the Temp/RealReg holding
658
         the address.  Arg2 holds this Temp/Real Reg.
659
         Transfer is always at size 8.
660
      */
661
      MMX2_MemRd,
662
      MMX2_MemWr,
663
664
      /* 2 bytes, reads/writes an integer ("E") register.  Insns of the form
665
         bbbbbbbb:11 mmxreg ireg.
666
         Held in val1[15:0], and ireg is to be replaced
667
         at codegen time by a reference to the relevant RealReg.
668
         Transfer is always at size 4.  Arg2 holds this Temp/Real Reg.
669
      */
670
      MMX2_ERegRd,
671
      MMX2_ERegWr,
672
673
      /* ------------ SSE/SSE2 ops ------------ */
674
      /* In the following:
675
676
         a digit N indicates the next N bytes are to be copied exactly
677
         to the output.
678
679
         'a' indicates a mod-xmmreg-rm byte, where the mod-rm part is
680
         to be replaced at codegen time to a Temp/RealReg holding the
681
         address.
682
683
         'e' indicates a byte of the form '11 xmmreg ireg', where ireg
684
         is read or written, and is to be replaced at codegen time by
685
         a reference to the relevant RealReg.  'e' because it's the E
686
         reg in Intel encoding parlance.
687
688
         'g' indicates a byte of the form '11 ireg xmmreg', where ireg
689
         is read or written, and is to be replaced at codegen time by
690
         a reference to the relevant RealReg.  'g' because it's called
691
         G in Intel parlance. */
692
693
      /* 3 bytes, no memrefs, no iregdefs, copy exactly to the
694
         output.  Held in val1[15:0] and val2[7:0]. */
695
      SSE3,
696
697
      /* 3 bytes, reads/writes mem.  Insns of the form
698
         bbbbbbbb:bbbbbbbb:mod mmxreg r/m.
699
         Held in val1[15:0] and val2[7:0], and mod and rm are to be
700
         replaced at codegen time by a reference to the Temp/RealReg
701
         holding the address.  Arg3 holds this Temp/Real Reg.
702
         Transfer is usually, but not always, at size 16.  */
703
      SSE2a_MemRd,
704
      SSE2a_MemWr,
705
706
      /* 4 bytes, writes an integer register.  Insns of the form
707
         bbbbbbbb:bbbbbbbb:11 ireg bbb.
708
         Held in val1[15:0] and val2[7:0], and ireg is to be replaced
709
         at codegen time by a reference to the relevant RealReg.
710
         Transfer is always at size 4.  Arg3 holds this Temp/Real Reg.
711
      */
712
      SSE2g_RegWr,
713
714
      /* 5 bytes, writes an integer register.  Insns of the form
715
         bbbbbbbb:bbbbbbbb:11 ireg bbb :bbbbbbbb. Held in
716
         val1[15:0] and val2[7:0] and lit32[7:0], and ireg is to be
717
         replaced at codegen time by a reference to the relevant
718
         RealReg.  Transfer is always at size 4.  Arg3 holds this
719
         Temp/Real Reg.
720
      */
721
      SSE2g1_RegWr,
722
723
      /* 5 bytes, reads an integer register.  Insns of the form
724
         bbbbbbbb:bbbbbbbb:11 bbb ireg :bbbbbbbb. Held in
725
         val1[15:0] and val2[7:0] and lit32[7:0], and ireg is to be
726
         replaced at codegen time by a reference to the relevant
727
         RealReg.  Transfer is always at size 4.  Arg3 holds this
728
         Temp/Real Reg.
729
      */
730
      SSE2e1_RegRd,
731
732
      /* 4 bytes, no memrefs, no iregdefs, copy exactly to the
733
         output.  Held in val1[15:0] and val2[15:0]. */
734
      SSE4,
735
736
      /* 4 bytes, reads/writes mem.  Insns of the form
737
         bbbbbbbb:bbbbbbbb:bbbbbbbb:mod mmxreg r/m.
738
         Held in val1[15:0] and val2[15:0], and mod and rm are to be
739
         replaced at codegen time by a reference to the Temp/RealReg
740
         holding the address.  Arg3 holds this Temp/Real Reg.
741
         Transfer is at stated size.  */
742
      SSE3a_MemRd,
743
      SSE3a_MemWr,
744
745
      /* 4 bytes, reads/writes mem.  Insns of the form
746
         bbbbbbbb:bbbbbbbb:mod mmxreg r/m:bbbbbbbb
747
         Held in val1[15:0] and val2[15:0], and mod and rm are to be
748
         replaced at codegen time by a reference to the Temp/RealReg
749
         holding the address.  Arg3 holds this Temp/Real Reg.
750
         Transfer is at stated size.  */
751
      SSE2a1_MemRd,
752
753
      /* 4 bytes, writes an integer register.  Insns of the form
754
         bbbbbbbb:bbbbbbbb:bbbbbbbb:11 ireg bbb.
755
         Held in val1[15:0] and val2[15:0], and ireg is to be replaced
756
         at codegen time by a reference to the relevant RealReg.
757
         Transfer is always at size 4.  Arg3 holds this Temp/Real Reg.
758
      */
759
      SSE3g_RegWr,
760
761
      /* 5 bytes, writes an integer register.  Insns of the form
762
         bbbbbbbb:bbbbbbbb:bbbbbbbb: 11 ireg bbb :bbbbbbbb. Held in
763
         val1[15:0] and val2[15:0] and lit32[7:0], and ireg is to be
764
         replaced at codegen time by a reference to the relevant
765
         RealReg.  Transfer is always at size 4.  Arg3 holds this
766
         Temp/Real Reg.
767
      */
768
      SSE3g1_RegWr,
769
770
      /* 4 bytes, reads an integer register.  Insns of the form
771
         bbbbbbbb:bbbbbbbb:bbbbbbbb:11 bbb ireg.
772
         Held in val1[15:0] and val2[15:0], and ireg is to be replaced
773
         at codegen time by a reference to the relevant RealReg.
774
         Transfer is always at size 4.  Arg3 holds this Temp/Real Reg.
775
      */
776
      SSE3e_RegRd,
777
      SSE3e_RegWr, /* variant that writes Ereg, not reads it */
778
779
      /* 5 bytes, reads an integer register.  Insns of the form
780
         bbbbbbbb:bbbbbbbb:bbbbbbbb: 11 bbb ireg :bbbbbbbb. Held in
781
         val1[15:0] and val2[15:0] and lit32[7:0], and ireg is to be
782
         replaced at codegen time by a reference to the relevant
783
         RealReg.  Transfer is always at size 4.  Arg3 holds this
784
         Temp/Real Reg.
785
      */
786
      SSE3e1_RegRd,
787
788
      /* 4 bytes, reads memory, writes an integer register, but is
789
         nevertheless an SSE insn.  The insn is of the form
790
         bbbbbbbb:bbbbbbbb:bbbbbbbb:mod ireg rm where mod indicates
791
         memory (ie is not 11b) and ireg is the int reg written.  The
792
         first 4 bytes are held in lit32[31:0] since there is
793
         insufficient space elsewhere.  mod and rm are to be replaced
794
         at codegen time by a reference to the Temp/RealReg holding
795
         the address.  Arg1 holds this Temp/RealReg.  ireg is to be
796
         replaced at codegen time by a reference to the relevant
797
         RealReg in which the answer is to be written.  Arg2 holds
798
         this Temp/RealReg.  Transfer to the destination reg is always
799
         at size 4.  However the memory read can be at sizes 4 or 8
800
         and so this is what the sz field holds.  Note that the 4th
801
         byte of the instruction (the modrm byte) is redundant, but we
802
         store it anyway so as to be consistent with all other SSE
803
         uinstrs.
804
      */
805
      SSE3ag_MemRd_RegWr,
806
807
      /* 5 bytes, no memrefs, no iregdefs, copy exactly to the
808
         output.  Held in val1[15:0], val2[15:0] and val3[7:0]. */
809
      SSE5,
810
811
      /* 5 bytes, reads/writes mem.  Insns of the form
812
         bbbbbbbb:bbbbbbbb:bbbbbbbb:mod mmxreg r/m:bbbbbbbb
813
         Held in val1[15:0], val2[15:0], lit32[7:0].
814
         mod and rm are to be replaced at codegen time by a reference
815
         to the Temp/RealReg holding the address.  Arg3 holds this
816
         Temp/Real Reg.  Transfer is always at size 16.  */
817
      SSE3a1_MemRd,
818
819
      /* ------------------------ */
820
821
      /* Not strictly needed, but improve address calculation translations. */
822
      LEA1,  /* reg2 := const + reg1 */
823
      LEA2,  /* reg3 := const + reg1 + reg2 * 1,2,4 or 8 */
824
825
      /* Hack for x86 REP insns.  Jump to literal if TempReg/RealReg
826
         is zero. */
827
      JIFZ,
828
829
      /* Advance the simulated %eip by some small (< 128) number. */
830
      INCEIP,
831
832
      /* Dealing with segment registers */
833
      GETSEG, PUTSEG,   /* simulated segment register <--> TempReg */
834
      USESEG,           /* (LDT/GDT index, virtual addr) --> linear addr */
835
836
      /* Not for translating x86 calls -- only to call helpers */
837
      CALLM_S, CALLM_E, /* Mark start/end of CALLM push/pop sequence */
838
      PUSH, POP, CLEAR, /* Add/remove/zap args for helpers           */
839
      CALLM,            /* Call assembly-code helper                 */
840
841
      /* Not for translating x86 calls -- only to call C helper functions of
842
         up to three arguments (or two if the functions has a return value).
843
         Arguments and return value must be word-sized.  More arguments can
844
         be faked with global variables (eg. use VG_(set_global_var)()).
845
846
         Seven possibilities: 'arg[123]' show where args go, 'ret' shows
847
         where return value goes (if present).
848
849
         CCALL(-,    -,    -   )    void f(void)
850
         CCALL(arg1, -,    -   )    void f(UInt arg1)
851
         CCALL(arg1, arg2, -   )    void f(UInt arg1, UInt arg2)
852
         CCALL(arg1, arg2, arg3)    void f(UInt arg1, UInt arg2, UInt arg3)
853
         CCALL(-,    -,    ret )    UInt f(UInt)
854
         CCALL(arg1, -,    ret )    UInt f(UInt arg1)
855
         CCALL(arg1, arg2, ret )    UInt f(UInt arg1, UInt arg2) */
856
      CCALL,
857
858
      /* This opcode makes it easy for skins that extend UCode to do this to
859
         avoid opcode overlap:
860
861
           enum { EU_OP1 = DUMMY_FINAL_UOPCODE + 1, ... }
862
863
         WARNING: Do not add new opcodes after this one!  They can be added
864
         before, though. */
865
      DUMMY_FINAL_UOPCODE
866
   }
867
   Opcode;
868
869
870
/* Condition codes, using the Intel encoding.  CondAlways is an extra. */
871
typedef
872
   enum {
873
      CondO      = 0,  /* overflow           */
874
      CondNO     = 1,  /* no overflow        */
875
      CondB      = 2,  /* below              */
876
      CondNB     = 3,  /* not below          */
877
      CondZ      = 4,  /* zero               */
878
      CondNZ     = 5,  /* not zero           */
879
      CondBE     = 6,  /* below or equal     */
880
      CondNBE    = 7,  /* not below or equal */
881
      CondS      = 8,  /* negative           */
882
      CondNS     = 9,  /* not negative       */
883
      CondP      = 10, /* parity even        */
884
      CondNP     = 11, /* not parity even    */
885
      CondL      = 12, /* jump less          */
886
      CondNL     = 13, /* not less           */
887
      CondLE     = 14, /* less or equal      */
888
      CondNLE    = 15, /* not less or equal  */
889
      CondAlways = 16  /* Jump always        */
890
   }
891
   Condcode;
892
893
894
/* Descriptions of additional properties of *unconditional* jumps. */
895
typedef
896
   enum {
897
     JmpBoring=0,   /* boring unconditional jump */
898
     JmpCall=1,     /* jump due to an x86 call insn */
899
     JmpRet=2,      /* jump due to an x86 ret insn */
900
     JmpSyscall=3,  /* do a system call, then jump */
901
     JmpClientReq=4,/* do a client request, then jump */
902
     JmpYield=5     /* do a yield, then jump */
903
   }
904
   JmpKind;
905
906
907
/* Flags.  User-level code can only read/write O(verflow), S(ign),
908
   Z(ero), A(ux-carry), C(arry), P(arity), and may also write
909
   D(irection).  That's a total of 7 flags.  A FlagSet is a bitset,
910
   thusly:
911
      76543210
912
       DOSZACP
913
   and bit 7 must always be zero since it is unused.
914
915
   Note: these Flag? values are **not** the positions in the actual
916
   %eflags register.  */
917
918
typedef UChar FlagSet;
919
920
#define FlagD (1<<6)
921
#define FlagO (1<<5)
922
#define FlagS (1<<4)
923
#define FlagZ (1<<3)
924
#define FlagA (1<<2)
925
#define FlagC (1<<1)
926
#define FlagP (1<<0)
927
928
#define FlagsOSZACP (FlagO | FlagS | FlagZ | FlagA | FlagC | FlagP)
929
#define FlagsOSZAP  (FlagO | FlagS | FlagZ | FlagA |         FlagP)
930
#define FlagsOSZCP  (FlagO | FlagS | FlagZ |         FlagC | FlagP)
931
#define FlagsOSACP  (FlagO | FlagS |         FlagA | FlagC | FlagP)
932
#define FlagsSZACP  (        FlagS | FlagZ | FlagA | FlagC | FlagP)
933
#define FlagsSZAP   (        FlagS | FlagZ | FlagA |         FlagP)
934
#define FlagsSZP    (        FlagS | FlagZ |                 FlagP)
935
#define FlagsZCP    (                FlagZ         | FlagC | FlagP)
936
#define FlagsOC     (FlagO |                         FlagC        )
937
#define FlagsAC     (                        FlagA | FlagC        )
938
939
#define FlagsALL    (FlagsOSZACP | FlagD)
940
#define FlagsEmpty  (FlagSet)0
941
942
943
/* flag positions in eflags */
944
#define EFlagC  (1 <<  0)       /* carry */
945
#define EFlagP  (1 <<  2)       /* parity */
946
#define EFlagA	(1 <<  4)	/* aux carry */
947
#define EFlagZ  (1 <<  6)       /* zero */
948
#define EFlagS  (1 <<  7)       /* sign */
949
#define EFlagD  (1 << 10)	/* direction */
950
#define EFlagO  (1 << 11)       /* overflow */
951
#define EFlagID (1 << 21)	/* changable if CPUID exists */
952
953
/* Liveness of general purpose registers, useful for code generation.
954
   Reg rank order 0..N-1 corresponds to bits 0..N-1, ie. first
955
   reg's liveness in bit 0, last reg's in bit N-1.  Note that
956
   these rankings don't match the Intel register ordering. */
957
typedef UInt RRegSet;
958
959
#define ALL_RREGS_DEAD      0                           /* 0000...00b */
960
#define ALL_RREGS_LIVE      ((1 << VG_MAX_REALREGS)-1)  /* 0011...11b */
961
#define UNIT_RREGSET(rank)  (1 << (rank))
962
963
#define IS_RREG_LIVE(rank,rregs_live) (rregs_live & UNIT_RREGSET(rank))
964
#define SET_RREG_LIVENESS(rank,rregs_live,b)       \
965
   do { RRegSet unit = UNIT_RREGSET(rank);         \
966
        if (b) rregs_live |= unit;                 \
967
        else   rregs_live &= ~unit;                \
968
   } while(0)
969
970
971
/* A Micro (u)-instruction. */
972
typedef
973
   struct {
974
      /* word 1 */
975
      UInt    lit32;      /* 32-bit literal */
976
977
      /* word 2 */
978
      UShort  val1;       /* first operand */
979
      UShort  val2;       /* second operand */
980
981
      /* word 3 */
982
      UShort  val3;       /* third operand */
983
      UChar   opcode;     /* opcode */
984
      UShort  size;       /* data transfer size */
985
986
      /* word 4 */
987
      FlagSet flags_r;    /* :: FlagSet */
988
      FlagSet flags_w;    /* :: FlagSet */
989
      UChar   tag1:4;     /* first  operand tag */
990
      UChar   tag2:4;     /* second operand tag */
991
      UChar   tag3:4;     /* third  operand tag */
992
      UChar   extra4b:4;  /* Spare field, used by WIDEN for src
993
                             -size, and by LEA2 for scale (1,2,4 or 8),
994
                             and by JMPs for original x86 instr size */
995
996
      /* word 5 */
997
      UChar   cond;            /* condition, for jumps */
998
      Bool    signed_widen:1;  /* signed or unsigned WIDEN ? */
999
      JmpKind jmpkind:3;       /* additional properties of unconditional JMP */
1000
1001
      /* Additional properties for UInstrs that call C functions:
1002
           - CCALL
1003
           - PUT (when %ESP is the target)
1004
           - possibly skin-specific UInstrs
1005
      */
1006
      UChar   argc:2;          /* Number of args, max 3 */
1007
      UChar   regparms_n:2;    /* Number of args passed in registers */
1008
      Bool    has_ret_val:1;   /* Function has return value? */
1009
1010
      /* RealReg liveness;  only sensical after reg alloc and liveness
1011
         analysis done.  This info is a little bit arch-specific --
1012
         VG_MAX_REALREGS can vary on different architectures.  Note that
1013
         to use this information requires converting between register ranks
1014
         and the Intel register numbers, using VG_(realreg_to_rank)()
1015
         and/or VG_(rank_to_realreg)() */
1016
      RRegSet regs_live_after:VG_MAX_REALREGS;
1017
   }
1018
   UInstr;
1019
1020
1021
typedef
1022
   struct _UCodeBlock
1023
   UCodeBlock;
1024
1025
extern Int     VG_(get_num_instrs) (UCodeBlock* cb);
1026
extern Int     VG_(get_num_temps)  (UCodeBlock* cb);
1027
1028
extern UInstr* VG_(get_instr)      (UCodeBlock* cb, Int i);
1029
extern UInstr* VG_(get_last_instr) (UCodeBlock* cb);
1030
1031
1032
/*====================================================================*/
1033
/*=== Instrumenting UCode                                          ===*/
1034
/*====================================================================*/
1035
1036
/* Maximum number of registers read or written by a single UInstruction. */
1037
#define VG_MAX_REGS_USED   3
1038
1039
/* Find what this instruction does to its regs, useful for
1040
   analysis/optimisation passes.  `tag' indicates whether we're considering
1041
   TempRegs (pre-reg-alloc) or RealRegs (post-reg-alloc).  `regs' is filled
1042
   with the affected register numbers, `isWrites' parallels it and indicates
1043
   if the reg is read or written.  If a reg is read and written, it will
1044
   appear twice in `regs'.  `regs' and `isWrites' must be able to fit
1045
   VG_MAX_REGS_USED elements. */
1046
extern Int VG_(get_reg_usage) ( UInstr* u, Tag tag, Int* regs, Bool* isWrites );
1047
1048
1049
/* Used to register helper functions to be called from generated code.  A
1050
   limited number of compact helpers can be registered;  the code generated
1051
   to call them is slightly shorter -- so register the mostly frequently
1052
   called helpers as compact. */
1053
extern void VG_(register_compact_helper)    ( Addr a );
1054
extern void VG_(register_noncompact_helper) ( Addr a );
1055
1056
1057
/* ------------------------------------------------------------------ */
1058
/* Virtual register allocation */
1059
1060
/* Get a new virtual register */
1061
extern Int VG_(get_new_temp)   ( UCodeBlock* cb );
1062
1063
/* Get a new virtual shadow register */
1064
extern Int VG_(get_new_shadow) ( UCodeBlock* cb );
1065
1066
/* Get a virtual register's corresponding virtual shadow register */
1067
#define SHADOW(tempreg)  ((tempreg)+1)
1068
1069
1070
/* ------------------------------------------------------------------ */
1071
/* Low-level UInstr builders */
1072
extern void VG_(new_NOP)     ( UInstr* u );
1073
extern void VG_(new_UInstr0) ( UCodeBlock* cb, Opcode opcode, Int sz );
1074
extern void VG_(new_UInstr1) ( UCodeBlock* cb, Opcode opcode, Int sz,
1075
                               Tag tag1, UInt val1 );
1076
extern void VG_(new_UInstr2) ( UCodeBlock* cb, Opcode opcode, Int sz,
1077
                              Tag tag1, UInt val1,
1078
                              Tag tag2, UInt val2 );
1079
extern void VG_(new_UInstr3) ( UCodeBlock* cb, Opcode opcode, Int sz,
1080
                              Tag tag1, UInt val1,
1081
                              Tag tag2, UInt val2,
1082
                              Tag tag3, UInt val3 );
1083
1084
/* Set read/write/undefined flags.  Undefined flags are treaten as written,
1085
   but it's worth keeping them logically distinct. */
1086
extern void VG_(set_flag_fields)  ( UCodeBlock* cb, FlagSet fr, FlagSet fw,
1087
                                    FlagSet fu);
1088
extern void VG_(set_lit_field)    ( UCodeBlock* cb, UInt lit32 );
1089
extern void VG_(set_ccall_fields) ( UCodeBlock* cb, Addr fn, UChar argc,
1090
                                    UChar regparms_n, Bool has_ret_val );
1091
extern void VG_(set_cond_field)   ( UCodeBlock* cb, Condcode code );
1092
1093
extern void VG_(copy_UInstr) ( UCodeBlock* cb, UInstr* instr );
1094
1095
extern Bool VG_(any_flag_use)( UInstr* u );
1096
1097
/* Macro versions of the above;  just shorter to type. */
1098
#define uInstr0   VG_(new_UInstr0)
1099
#define uInstr1   VG_(new_UInstr1)
1100
#define uInstr2   VG_(new_UInstr2)
1101
#define uInstr3   VG_(new_UInstr3)
1102
#define uLiteral  VG_(set_lit_field)
1103
#define uCCall    VG_(set_ccall_fields)
1104
#define uCond     VG_(set_cond_field)
1105
#define uFlagsRWU VG_(set_flag_fields)
1106
#define newTemp   VG_(get_new_temp)
1107
#define newShadow VG_(get_new_shadow)
1108
1109
/* Refer to `the last instruction stuffed in' (can be lvalue). */
1110
#define LAST_UINSTR(cb) (cb)->instrs[(cb)->used-1]
1111
1112
1113
/* ------------------------------------------------------------------ */
1114
/* Higher-level UInstr sequence builders */
1115
extern void VG_(call_helper_0_0) ( UCodeBlock* cb, Addr f);
1116
extern void VG_(call_helper_1_0) ( UCodeBlock* cb, Addr f, UInt arg1,
1117
                                   UInt regparms_n);
1118
extern void VG_(call_helper_2_0) ( UCodeBlock* cb, Addr f, UInt arg1, UInt arg2,
1119
                                   UInt regparms_n);
1120
1121
/* One way around the 3-arg C function limit is to pass args via global
1122
 * variables... ugly, but it works.  This one puts a literal in there. */
1123
extern void VG_(set_global_var) ( UCodeBlock* cb, Addr globvar_ptr, UInt val);
1124
1125
/* This one puts the contents of a TempReg in the global variable. */
1126
extern void VG_(set_global_var_tempreg) ( UCodeBlock* cb, Addr globvar_ptr,
1127
                                          UInt t_val);
1128
1129
/* ------------------------------------------------------------------ */
1130
/* Allocating/freeing basic blocks of UCode */
1131
extern UCodeBlock* VG_(setup_UCodeBlock) ( UCodeBlock* cb );
1132
extern void        VG_(free_UCodeBlock)  ( UCodeBlock* cb );
1133
1134
/* ------------------------------------------------------------------ */
1135
/* UCode pretty/ugly printing.  Probably only useful to call from a skin
1136
   if VG_(needs).extended_UCode == True. */
1137
1138
/* When True, all generated code is/should be printed. */
1139
extern Bool  VG_(print_codegen);
1140
1141
/* Pretty/ugly printing functions */
1142
extern void  VG_(pp_UCodeBlock)  ( UCodeBlock* cb, Char* title );
1143
extern void  VG_(pp_UInstr)      ( Int instrNo, UInstr* u );
1144
extern void  VG_(pp_UInstr_regs) ( Int instrNo, UInstr* u );
1145
extern void  VG_(up_UInstr)      ( Int instrNo, UInstr* u );
1146
extern Char* VG_(name_UOpcode)   ( Bool upper, Opcode opc );
1147
extern Char* VG_(name_UCondcode) ( Condcode cond );
1148
extern void  VG_(pp_UOperand)    ( UInstr* u, Int operandNo,
1149
                                   Int sz, Bool parens );
1150
1151
/* ------------------------------------------------------------------ */
1152
/* Accessing archregs and their shadows */
1153
extern UInt VG_(get_archreg)            ( UInt archreg );
1154
extern UInt VG_(get_thread_archreg)     ( ThreadId tid, UInt archreg );
1155
1156
extern UInt VG_(get_shadow_archreg)     ( UInt archreg );
1157
extern void VG_(set_shadow_archreg)     ( UInt archreg, UInt val );
1158
extern void VG_(set_shadow_eflags)      ( UInt val );
1159
extern Addr VG_(shadow_archreg_address) ( UInt archreg );
1160
1161
extern UInt VG_(get_thread_shadow_archreg) ( ThreadId tid, UInt archreg );
1162
extern void VG_(set_thread_shadow_archreg) ( ThreadId tid, UInt archreg,
1163
                                             UInt val );
1164
1165
/* ------------------------------------------------------------------ */
1166
/* Offsets of addresses of helper functions.  A "helper" function is one
1167
   which is called from generated code via CALLM. */
1168
1169
extern Int VGOFF_(helper_idiv_64_32);
1170
extern Int VGOFF_(helper_div_64_32);
1171
extern Int VGOFF_(helper_idiv_32_16);
1172
extern Int VGOFF_(helper_div_32_16);
1173
extern Int VGOFF_(helper_idiv_16_8);
1174
extern Int VGOFF_(helper_div_16_8);
1175
1176
extern Int VGOFF_(helper_imul_32_64);
1177
extern Int VGOFF_(helper_mul_32_64);
1178
extern Int VGOFF_(helper_imul_16_32);
1179
extern Int VGOFF_(helper_mul_16_32);
1180
extern Int VGOFF_(helper_imul_8_16);
1181
extern Int VGOFF_(helper_mul_8_16);
1182
1183
extern Int VGOFF_(helper_CLD);
1184
extern Int VGOFF_(helper_STD);
1185
extern Int VGOFF_(helper_get_dirflag);
1186
1187
extern Int VGOFF_(helper_CLC);
1188
extern Int VGOFF_(helper_STC);
1189
extern Int VGOFF_(helper_CMC);
1190
1191
extern Int VGOFF_(helper_shldl);
1192
extern Int VGOFF_(helper_shldw);
1193
extern Int VGOFF_(helper_shrdl);
1194
extern Int VGOFF_(helper_shrdw);
1195
1196
extern Int VGOFF_(helper_RDTSC);
1197
extern Int VGOFF_(helper_CPUID);
1198
1199
extern Int VGOFF_(helper_IN);
1200
extern Int VGOFF_(helper_OUT);
1201
1202
extern Int VGOFF_(helper_bsfw);
1203
extern Int VGOFF_(helper_bsfl);
1204
extern Int VGOFF_(helper_bsrw);
1205
extern Int VGOFF_(helper_bsrl);
1206
1207
extern Int VGOFF_(helper_fstsw_AX);
1208
extern Int VGOFF_(helper_SAHF);
1209
extern Int VGOFF_(helper_LAHF);
1210
extern Int VGOFF_(helper_DAS);
1211
extern Int VGOFF_(helper_DAA);
1212
extern Int VGOFF_(helper_AAS);
1213
extern Int VGOFF_(helper_AAA);
1214
extern Int VGOFF_(helper_AAD);
1215
extern Int VGOFF_(helper_AAM);
1216
1217
extern Int VGOFF_(helper_cmpxchg8b);
1218
1219
1220
/*====================================================================*/
1221
/*=== Generating x86 code from UCode                               ===*/
1222
/*====================================================================*/
1223
1224
/* All this only necessary for skins with VG_(needs).extends_UCode == True. */
1225
1226
/* This is the Intel register encoding -- integer regs. */
1227
#define R_EAX 0
1228
#define R_ECX 1
1229
#define R_EDX 2
1230
#define R_EBX 3
1231
#define R_ESP 4
1232
#define R_EBP 5
1233
#define R_ESI 6
1234
#define R_EDI 7
1235
1236
#define R_AL (0+R_EAX)
1237
#define R_CL (0+R_ECX)
1238
#define R_DL (0+R_EDX)
1239
#define R_BL (0+R_EBX)
1240
#define R_AH (4+R_EAX)
1241
#define R_CH (4+R_ECX)
1242
#define R_DH (4+R_EDX)
1243
#define R_BH (4+R_EBX)
1244
1245
/* This is the Intel register encoding -- segment regs. */
1246
#define R_ES 0
1247
#define R_CS 1
1248
#define R_SS 2
1249
#define R_DS 3
1250
#define R_FS 4
1251
#define R_GS 5
1252
1253
/* For pretty printing x86 code */
1254
extern const Char* VG_(name_of_mmx_gran) ( UChar gran );
1255
extern const Char* VG_(name_of_mmx_reg)  ( Int mmxreg );
1256
extern const Char* VG_(name_of_seg_reg)  ( Int sreg );
1257
extern const Char* VG_(name_of_int_reg)  ( Int size, Int reg );
1258
extern const Char  VG_(name_of_int_size) ( Int size );
1259
1260
/* Shorter macros for convenience */
1261
#define nameIReg    VG_(name_of_int_reg)
1262
#define nameISize   VG_(name_of_int_size)
1263
#define nameSReg    VG_(name_of_seg_reg)
1264
#define nameMMXReg  VG_(name_of_mmx_reg)
1265
#define nameMMXGran VG_(name_of_mmx_gran)
1266
#define nameXMMReg  VG_(name_of_xmm_reg)
1267
1268
/* Randomly useful things */
1269
extern UInt  VG_(extend_s_8to32) ( UInt x );
1270
1271
/* Code emitters */
1272
extern void VG_(emitB)    ( UInt b );
1273
extern void VG_(emitW)    ( UInt w );
1274
extern void VG_(emitL)    ( UInt l );
1275
extern void VG_(new_emit) ( Bool upd_cc, FlagSet uses_flags, FlagSet sets_flags );
1276
1277
/* Finding offsets */
1278
extern Int  VG_(helper_offset)       ( Addr a );
1279
extern Int  VG_(shadow_reg_offset)   ( Int arch );
1280
extern Int  VG_(shadow_flags_offset) ( void );
1281
1282
/* Convert reg ranks <-> Intel register ordering, for using register
1283
   liveness information. */
1284
extern Int VG_(realreg_to_rank) ( Int realreg );
1285
extern Int VG_(rank_to_realreg) ( Int rank    );
1286
1287
/* Call a subroutine.  Does no argument passing, stack manipulations, etc. */
1288
extern void VG_(synth_call) ( Bool ensure_shortform, Int word_offset,
1289
			      Bool upd_cc, FlagSet use_flags, FlagSet set_flags );
1290
1291
/* For calling C functions -- saves caller save regs, pushes args, calls,
1292
   clears the stack, restores caller save regs.  `fn' must be registered in
1293
   the baseBlock first.  Acceptable tags are RealReg and Literal.  Optimises
1294
   things, eg. by not preserving non-live caller-save registers.
1295
1296
   WARNING:  a UInstr should *not* be translated with synth_ccall() followed
1297
   by some other x86 assembly code;  this will invalidate the results of
1298
   vg_realreg_liveness_analysis() and everything will fall over.  */
1299
extern void VG_(synth_ccall) ( Addr fn, Int argc, Int regparms_n, UInt argv[],
1300
                               Tag tagv[], Int ret_reg,
1301
                               RRegSet regs_live_before,
1302
                               RRegSet regs_live_after );
1303
1304
/* Addressing modes */
1305
extern void VG_(emit_amode_offregmem_reg)( Int off, Int regmem, Int reg );
1306
extern void VG_(emit_amode_ereg_greg)    ( Int e_reg, Int g_reg );
1307
1308
/* v-size (4, or 2 with OSO) insn emitters */
1309
extern void VG_(emit_movv_offregmem_reg) ( Int sz, Int off, Int areg, Int reg );
1310
extern void VG_(emit_movv_reg_offregmem) ( Int sz, Int reg, Int off, Int areg );
1311
extern void VG_(emit_movv_reg_reg)       ( Int sz, Int reg1, Int reg2 );
1312
extern void VG_(emit_nonshiftopv_lit_reg)( Bool upd_cc, Int sz, Opcode opc, UInt lit,
1313
                                           Int reg );
1314
extern void VG_(emit_shiftopv_lit_reg)   ( Bool upd_cc, Int sz, Opcode opc, UInt lit,
1315
                                           Int reg );
1316
extern void VG_(emit_nonshiftopv_reg_reg)( Bool upd_cc, Int sz, Opcode opc,
1317
                                           Int reg1, Int reg2 );
1318
extern void VG_(emit_movv_lit_reg)       ( Int sz, UInt lit, Int reg );
1319
extern void VG_(emit_unaryopv_reg)       ( Bool upd_cc, Int sz, Opcode opc, Int reg );
1320
extern void VG_(emit_pushv_reg)          ( Int sz, Int reg );
1321
extern void VG_(emit_popv_reg)           ( Int sz, Int reg );
1322
1323
extern void VG_(emit_pushl_lit32)        ( UInt int32 );
1324
extern void VG_(emit_pushl_lit8)         ( Int lit8 );
1325
extern void VG_(emit_cmpl_zero_reg)      ( Bool upd_cc, Int reg );
1326
extern void VG_(emit_swapl_reg_EAX)      ( Int reg );
1327
extern void VG_(emit_movv_lit_offregmem) ( Int sz, UInt lit, Int off,
1328
                                           Int memreg );
1329
1330
/* b-size (1 byte) instruction emitters */
1331
extern void VG_(emit_movb_lit_offregmem) ( UInt lit, Int off, Int memreg );
1332
extern void VG_(emit_movb_reg_offregmem) ( Int reg, Int off, Int areg );
1333
extern void VG_(emit_unaryopb_reg)       ( Bool upd_cc, Opcode opc, Int reg );
1334
extern void VG_(emit_testb_lit_reg)      ( Bool upd_cc, UInt lit, Int reg );
1335
1336
/* zero-extended load emitters */
1337
extern void VG_(emit_movzbl_offregmem_reg) ( Bool bounds, Int off, Int regmem, Int reg );
1338
extern void VG_(emit_movzwl_offregmem_reg) ( Bool bounds, Int off, Int areg, Int reg );
1339
extern void VG_(emit_movzwl_regmem_reg)    ( Bool bounds, Int reg1, Int reg2 );
1340
1341
/* misc instruction emitters */
1342
extern void VG_(emit_call_reg)         ( Int reg );
1343
extern void VG_(emit_add_lit_to_esp)   ( Int lit );
1344
extern void VG_(emit_pushal)           ( void );
1345
extern void VG_(emit_popal)            ( void );
1346
extern void VG_(emit_AMD_prefetch_reg) ( Int reg );
1347
1348
/* jump emitters */
1349
extern void VG_(init_target)	       ( Int *tgt );
1350
1351
extern void VG_(target_back)	       ( Int *tgt );
1352
extern void VG_(target_forward)	       ( Int *tgt );
1353
extern void VG_(emit_target_delta)     ( Int *tgt );
1354
1355
typedef enum {
1356
   JP_NONE,			/* no prediction */
1357
   JP_TAKEN,			/* predict taken */
1358
   JP_NOT_TAKEN,		/* predict not taken */
1359
} JumpPred;
1360
1361
extern void VG_(emit_jcondshort_delta) ( Bool simd_cc, Condcode cond, Int delta, JumpPred );
1362
extern void VG_(emit_jcondshort_target)( Bool simd_cc, Condcode cond, Int *tgt, JumpPred );
1363
1364
1365
/*====================================================================*/
1366
/*=== Execution contexts                                           ===*/
1367
/*====================================================================*/
1368
1369
/* Generic resolution type used in a few different ways, such as deciding
1370
   how closely to compare two errors for equality. */
1371
typedef
1372
   enum { Vg_LowRes, Vg_MedRes, Vg_HighRes }
1373
   VgRes;
1374
1375
typedef
1376
   struct _ExeContext
1377
   ExeContext;
1378
1379
/* Compare two ExeContexts.  Number of callers considered depends on `res':
1380
     Vg_LowRes:  2
1381
     Vg_MedRes:  4
1382
     Vg_HighRes: all */
1383
extern Bool VG_(eq_ExeContext) ( VgRes res,
1384
                                 ExeContext* e1, ExeContext* e2 );
1385
1386
/* Print an ExeContext. */
1387
extern void VG_(pp_ExeContext) ( ExeContext* );
1388
1389
/* Take a snapshot of the client's stack.  Search our collection of
1390
   ExeContexts to see if we already have it, and if not, allocate a
1391
   new one.  Either way, return a pointer to the context.  Context size
1392
   controlled by --num-callers option.
1393
1394
   If called from generated code, use VG_(get_current_tid)() to get the
1395
   current ThreadId.  If called from non-generated code, the current
1396
   ThreadId should be passed in by the core.
1397
*/
1398
extern ExeContext* VG_(get_ExeContext) ( ThreadId tid );
1399
1400
/* Get the nth EIP from the ExeContext.  0 is the EIP of the top function, 1
1401
   is its caller, etc.  Returns 0 if there isn't one, or if n is greater
1402
   than VG_(clo_backtrace_size), set by the --num-callers option. */
1403
extern Addr VG_(get_EIP_from_ExeContext) ( ExeContext* e, UInt n );
1404
1405
/* Just grab the client's EIP, as a much smaller and cheaper
1406
   indication of where they are.  Use is basically same as for
1407
   VG_(get_ExeContext)() above.
1408
*/
1409
extern Addr VG_(get_EIP)( ThreadId tid );
1410
1411
/* For skins needing more control over stack traces:  walks the stack to get
1412
   %eips from the top stack frames for thread 'tid'.  Maximum of 'n_eips'
1413
   addresses put into 'eips';  0 is the top of the stack, 1 is its caller,
1414
   etc. */
1415
extern UInt VG_(stack_snapshot) ( ThreadId tid, Addr* eips, UInt n_eips );
1416
1417
/* Does the same thing as VG_(pp_ExeContext)(), just with slightly
1418
   different input. */
1419
extern void VG_(mini_stack_dump) ( Addr eips[], UInt n_eips );
1420
1421
1422
/*====================================================================*/
1423
/*=== Error reporting                                              ===*/
1424
/*====================================================================*/
1425
1426
/* ------------------------------------------------------------------ */
1427
/* Suppressions describe errors which we want to suppress, ie, not
1428
   show the user, usually because it is caused by a problem in a library
1429
   which we can't fix, replace or work around.  Suppressions are read from
1430
   a file at startup time.  This gives flexibility so that new
1431
   suppressions can be added to the file as and when needed.
1432
*/
1433
1434
typedef
1435
   Int         /* Do not make this unsigned! */
1436
   SuppKind;
1437
1438
/* The skin-relevant parts of a suppression are:
1439
     kind:   what kind of suppression; must be in the range (0..)
1440
     string: use is optional.  NULL by default.
1441
     extra:  use is optional.  NULL by default.  void* so it's extensible.
1442
*/
1443
typedef
1444
   struct _Supp
1445
   Supp;
1446
1447
/* Useful in SK_(error_matches_suppression)() */
1448
SuppKind VG_(get_supp_kind)   ( Supp* su );
1449
Char*    VG_(get_supp_string) ( Supp* su );
1450
void*    VG_(get_supp_extra)  ( Supp* su );
1451
1452
/* Must be used in VG_(recognised_suppression)() */
1453
void VG_(set_supp_kind)   ( Supp* su, SuppKind suppkind );
1454
/* May be used in VG_(read_extra_suppression_info)() */
1455
void VG_(set_supp_string) ( Supp* su, Char* string );
1456
void VG_(set_supp_extra)  ( Supp* su, void* extra );
1457
1458
1459
/* ------------------------------------------------------------------ */
1460
/* Error records contain enough info to generate an error report.  The idea
1461
   is that (typically) the same few points in the program generate thousands
1462
   of errors, and we don't want to spew out a fresh error message for each
1463
   one.  Instead, we use these structures to common up duplicates.
1464
*/
1465
1466
typedef
1467
   Int         /* Do not make this unsigned! */
1468
   ErrorKind;
1469
1470
/* The skin-relevant parts of an Error are:
1471
     kind:   what kind of error; must be in the range (0..)
1472
     addr:   use is optional.  0 by default.
1473
     string: use is optional.  NULL by default.
1474
     extra:  use is optional.  NULL by default.  void* so it's extensible.
1475
*/
1476
typedef
1477
   struct _Error
1478
   Error;
1479
1480
/* Useful in SK_(error_matches_suppression)(), SK_(pp_SkinError)(), etc */
1481
ExeContext* VG_(get_error_where)   ( Error* err );
1482
SuppKind    VG_(get_error_kind)    ( Error* err );
1483
Addr        VG_(get_error_address) ( Error* err );
1484
Char*       VG_(get_error_string)  ( Error* err );
1485
void*       VG_(get_error_extra)   ( Error* err );
1486
1487
/* Call this when an error occurs.  It will be recorded if it hasn't been
1488
   seen before.  If it has, the existing error record will have its count
1489
   incremented.
1490
1491
   'tid' can be found as for VG_(get_ExeContext)().  The `extra' field can
1492
   be stack-allocated;  it will be copied by the core if needed (but it
1493
   won't be copied if it's NULL).
1494
1495
   If no 'a', 's' or 'extra' of interest needs to be recorded, just use
1496
   NULL for them.  */
1497
extern void VG_(maybe_record_error) ( ThreadId tid, ErrorKind ekind,
1498
                                      Addr a, Char* s, void* extra );
1499
1500
/* Similar to VG_(maybe_record_error)(), except this one doesn't record the
1501
   error -- useful for errors that can only happen once.  The errors can be
1502
   suppressed, though.  Return value is True if it was suppressed.
1503
   `print_error' dictates whether to print the error, which is a bit of a
1504
   hack that's useful sometimes if you just want to know if the error would
1505
   be suppressed without possibly printing it.  `count_error' dictates
1506
   whether to add the error in the error total count (another mild hack). */
1507
extern Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind,
1508
                                Addr a, Char* s, void* extra,
1509
                                ExeContext* where, Bool print_error,
1510
                                Bool allow_GDB_attach, Bool count_error );
1511
1512
/* Gets a non-blank, non-comment line of at most nBuf chars from fd.
1513
   Skips leading spaces on the line.  Returns True if EOF was hit instead.
1514
   Useful for reading in extra skin-specific suppression lines.  */
1515
extern Bool VG_(get_line) ( Int fd, Char* buf, Int nBuf );
1516
1517
1518
/*====================================================================*/
1519
/*=== Obtaining debug information                                  ===*/
1520
/*====================================================================*/
1521
1522
/* Get the file/function/line number of the instruction at address
1523
   'a'.  For these four, if debug info for the address is found, it
1524
   copies the info into the buffer/UInt and returns True.  If not, it
1525
   returns False and nothing is copied.  VG_(get_fnname) always
1526
   demangles C++ function names.  VG_(get_fnname_w_offset) is the
1527
   same, except it appends "+N" to symbol names to indicate offsets.  */
1528
extern Bool VG_(get_filename) ( Addr a, Char* filename, Int n_filename );
1529
extern Bool VG_(get_fnname)   ( Addr a, Char* fnname,   Int n_fnname   );
1530
extern Bool VG_(get_linenum)  ( Addr a, UInt* linenum );
1531
extern Bool VG_(get_fnname_w_offset)
1532
                              ( Addr a, Char* fnname,   Int n_fnname   );
1533
1534
/* This one is more efficient if getting both filename and line number,
1535
   because the two lookups are done together. */
1536
extern Bool VG_(get_filename_linenum)
1537
                              ( Addr a, Char* filename, Int n_filename,
1538
                                        UInt* linenum );
1539
1540
/* Succeeds only if we find from debug info that 'a' is the address of the
1541
   first instruction in a function -- as opposed to VG_(get_fnname) which
1542
   succeeds if we find from debug info that 'a' is the address of any
1543
   instruction in a function.  Use this to instrument the start of
1544
   a particular function.  Nb: if an executable/shared object is stripped
1545
   of its symbols, this function will not be able to recognise function
1546
   entry points within it. */
1547
extern Bool VG_(get_fnname_if_entry) ( Addr a, Char* fnname, Int n_fnname );
1548
1549
/* Succeeds if the address is within a shared object or the main executable.
1550
   It doesn't matter if debug info is present or not. */
1551
extern Bool VG_(get_objname)  ( Addr a, Char* objname,  Int n_objname  );
1552
1553
/* Puts into 'buf' info about the code address %eip:  the address, function
1554
   name (if known) and filename/line number (if known), like this:
1555
1556
      0x4001BF05: realloc (vg_replace_malloc.c:339)
1557
1558
   'n_buf' gives length of 'buf'.  Returns 'buf'.
1559
*/
1560
extern Char* VG_(describe_eip)(Addr eip, Char* buf, Int n_buf);
1561
1562
/* Returns a string containing an expression for the given
1563
   address. String is malloced with VG_(malloc)() */
1564
Char *VG_(describe_addr)(ThreadId, Addr);
1565
1566
/* A way to get information about what segments are mapped */
1567
typedef struct _SegInfo SegInfo;
1568
1569
/* Returns NULL if the SegInfo isn't found.  It doesn't matter if debug info
1570
   is present or not. */
1571
extern SegInfo* VG_(get_obj)  ( Addr a );
1572
1573
extern const SegInfo* VG_(next_seginfo)  ( const SegInfo *seg );
1574
extern       Addr     VG_(seg_start)     ( const SegInfo *seg );
1575
extern       UInt     VG_(seg_size)      ( const SegInfo *seg );
1576
extern const UChar*   VG_(seg_filename)  ( const SegInfo *seg );
1577
extern       UInt     VG_(seg_sym_offset)( const SegInfo *seg );
1578
1579
typedef
1580
   enum {
1581
      Vg_SectUnknown,
1582
      Vg_SectText,
1583
      Vg_SectData,
1584
      Vg_SectBSS,
1585
      Vg_SectGOT,
1586
      Vg_SectPLT,
1587
   }
1588
   VgSectKind;
1589
1590
extern VgSectKind VG_(seg_sect_kind)(Addr);
1591
1592
1593
/*====================================================================*/
1594
/*=== Generic hash table                                           ===*/
1595
/*====================================================================*/
1596
1597
/* Generic type for a separately-chained hash table.  Via a kind of dodgy
1598
   C-as-C++ style inheritance, skins can extend the VgHashNode type, so long
1599
   as the first two fields match the sizes of these two fields.  Requires
1600
   a bit of casting by the skin. */
1601
typedef
1602
   struct _VgHashNode {
1603
      struct _VgHashNode * next;
1604
      UInt               key;
1605
   }
1606
   VgHashNode;
1607
1608
typedef
1609
   VgHashNode**
1610
   VgHashTable;
1611
1612
/* Make a new table. */
1613
extern VgHashTable VG_(HT_construct) ( void );
1614
1615
/* Count the number of nodes in a table. */
1616
extern Int VG_(HT_count_nodes) ( VgHashTable table );
1617
1618
/* Add a node to the table. */
1619
extern void VG_(HT_add_node) ( VgHashTable t, VgHashNode* node );
1620
1621
/* Looks up a node in the hash table.  Also returns the address of the
1622
   previous node's `next' pointer which allows it to be removed from the
1623
   list later without having to look it up again.  */
1624
extern VgHashNode* VG_(HT_get_node) ( VgHashTable t, UInt key,
1625
                                    /*OUT*/VgHashNode*** next_ptr );
1626
1627
/* Allocates an array of pointers to all the shadow chunks of malloc'd
1628
   blocks.  Must be freed with VG_(free)(). */
1629
extern VgHashNode** VG_(HT_to_array) ( VgHashTable t, /*OUT*/ UInt* n_shadows );
1630
1631
/* Returns first node that matches predicate `p', or NULL if none do.
1632
   Extra arguments can be implicitly passed to `p' using nested functions;
1633
   see memcheck/mc_errcontext.c for an example. */
1634
extern VgHashNode* VG_(HT_first_match) ( VgHashTable t,
1635
                                         Bool (*p)(VgHashNode*) );
1636
1637
/* Applies a function f() once to each node.  Again, nested functions
1638
   can be very useful. */
1639
extern void VG_(HT_apply_to_all_nodes)( VgHashTable t, void (*f)(VgHashNode*) );
1640
1641
/* Destroy a table. */
1642
extern void VG_(HT_destruct) ( VgHashTable t );
1643
1644
1645
/*====================================================================*/
1646
/*=== A generic skiplist                                           ===*/
1647
/*====================================================================*/
1648
1649
/* 
1650
   The idea here is that the skiplist puts its per-element data at the
1651
   end of the structure.  When you initialize the skiplist, you tell
1652
   it what structure your list elements are going to be.  Then you
1653
   should allocate them with VG_(SkipNode_Alloc), which will allocate
1654
   enough memory for the extra bits.
1655
 */
1656
#include <stddef.h>		/* for offsetof */
1657
1658
typedef struct _SkipList SkipList;
1659
typedef struct _SkipNode SkipNode;
1660
1661
typedef Int (*SkipCmp_t)(const void *key1, const void *key2);
1662
1663
struct _SkipList {
1664
   const Short		arena;		/* allocation arena                        */
1665
   const UShort		size;		/* structure size (not including SkipNode) */
1666
   const UShort		keyoff;		/* key offset                              */
1667
   const SkipCmp_t	cmp;		/* compare two keys                        */
1668
	 Char *		(*strkey)(void *); /* stringify a key (for debugging)      */
1669
         SkipNode	*head;		/* list head                               */
1670
};
1671
1672
/* Use this macro to initialize your skiplist head.  The arguments are pretty self explanitory:
1673
   _type is the type of your element structure
1674
   _key is the field within that type which you want to use as the key
1675
   _cmp is the comparison function for keys - it gets two typeof(_key) pointers as args
1676
   _strkey is a function which can return a string of your key - it's only used for debugging
1677
   _arena is the arena to use for allocation - -1 is the default
1678
 */
1679
#define SKIPLIST_INIT(_type, _key, _cmp, _strkey, _arena)		\
1680
	{								\
1681
	   .arena       = _arena,					\
1682
	   .size	= sizeof(_type),				\
1683
	   .keyoff	= offsetof(_type, _key),			\
1684
	   .cmp		= _cmp,						\
1685
	   .strkey      = _strkey,					\
1686
	   .head	= NULL,						\
1687
	}
1688
1689
/* List operations:
1690
   SkipList_Find searchs a list.  If it can't find an exact match, it either returns NULL
1691
      or a pointer to the element before where k would go
1692
   SkipList_Insert inserts a new element into the list.  Duplicates are forbidden.
1693
   SkipList_Remove removes an element from the list and returns it.  It doesn't free the memory.
1694
 */
1695
extern void *VG_(SkipList_Find)  (const SkipList *l, void *key);
1696
extern void  VG_(SkipList_Insert)(      SkipList *l, void *data);
1697
extern void *VG_(SkipList_Remove)(      SkipList *l, void *key);
1698
1699
/* Node (element) operations:
1700
   SkipNode_Alloc: allocate memory for a new element on the list
1701
   SkipNode_Free: free memory allocated above
1702
   SkipNode_First: return the first element on the list
1703
   SkipNode_Next: return the next element after "data" on the list - 
1704
      NULL for none
1705
 */
1706
extern void *VG_(SkipNode_Alloc) (const SkipList *l);
1707
extern void  VG_(SkipNode_Free)  (const SkipList *l, void *p);
1708
extern void *VG_(SkipNode_First) (const SkipList *l);
1709
extern void *VG_(SkipNode_Next)  (const SkipList *l, void *data);
1710
1711
/*====================================================================*/
1712
/*=== Functions for shadow registers                               ===*/
1713
/*====================================================================*/
1714
1715
/* Nb: make sure the shadow_regs 'need' is set before using these! */
1716
1717
/* This one lets you override the shadow of the return value register for a
1718
   syscall.  Call it from SK_(post_syscall)() (not SK_(pre_syscall)()!) to
1719
   override the default shadow register value. */
1720
extern void VG_(set_return_from_syscall_shadow) ( ThreadId tid,
1721
                                                  UInt ret_shadow );
1722
1723
/* This can be called from SK_(fini)() to find the shadow of the argument
1724
   to exit(), ie. the shadow of the program's return value. */
1725
extern UInt VG_(get_exit_status_shadow) ( void );
1726
1727
1728
/*====================================================================*/
1729
/*=== General stuff for replacing functions                        ===*/
1730
/*====================================================================*/
1731
1732
/* Some skins need to replace the standard definitions of some functions. */
1733
1734
/* ------------------------------------------------------------------ */
1735
/* General stuff, for replacing any functions */
1736
1737
/* Is the client running on the simulated CPU or the real one?
1738
1739
   Nb: If it is, and you want to call a function to be run on the real CPU,
1740
   use one of the VALGRIND_NON_SIMD_CALL[123] macros in valgrind.h to call it.
1741
1742
   Nb: don't forget the function parentheses when using this in a
1743
   condition... write this:
1744
1745
     if (VG_(is_running_on_simd_CPU)()) { ... }    // calls function
1746
1747
   not this:
1748
1749
     if (VG_(is_running_on_simd_CPU)) { ... }      // address of var!
1750
*/
1751
extern Bool VG_(is_running_on_simd_CPU) ( void );
1752
1753
1754
/*====================================================================*/
1755
/*=== Specific stuff for replacing malloc() and friends            ===*/
1756
/*====================================================================*/
1757
1758
/* If a skin replaces malloc() et al, the easiest way to do so is to
1759
   link with vg_replace_malloc.o into its vgpreload_*.so file, and
1760
   follow the following instructions.  You can do it from scratch,
1761
   though, if you enjoy that sort of thing. */
1762
1763
/* Arena size for valgrind's own malloc();  default value is 0, but can
1764
   be overridden by skin -- but must be done so *statically*, eg:
1765
1766
     Int VG_(vg_malloc_redzone_szB) = 4;
1767
1768
   It can't be done from a function like SK_(pre_clo_init)().  So it can't,
1769
   for example, be controlled with a command line option, unfortunately. */
1770
extern UInt VG_(vg_malloc_redzone_szB);
1771
1772
/* Can be called from SK_(malloc) et al to do the actual alloc/freeing. */
1773
extern void* VG_(cli_malloc) ( UInt align, Int nbytes );
1774
extern void  VG_(cli_free)   ( void* p );
1775
1776
/* Check if an address is within a range, allowing for redzones at edges */
1777
extern Bool VG_(addr_is_in_block)( Addr a, Addr start, UInt size );
1778
1779
/* ------------------------------------------------------------------ */
1780
/* Some options that can be used by a skin if malloc() et al are replaced.
1781
   The skin should call the functions in the appropriate places to give
1782
   control over these aspects of Valgrind's version of malloc(). */
1783
1784
/* Round malloc sizes upwards to integral number of words? default: NO */
1785
extern Bool VG_(clo_sloppy_malloc);
1786
/* DEBUG: print malloc details?  default: NO */
1787
extern Bool VG_(clo_trace_malloc);
1788
/* Minimum alignment in functions that don't specify alignment explicitly.
1789
   default: 0, i.e. use default of the machine (== 4) */
1790
extern Int  VG_(clo_alignment);
1791
1792
extern Bool VG_(replacement_malloc_process_cmd_line_option) ( Char* arg );
1793
extern void VG_(replacement_malloc_print_usage)             ( void );
1794
extern void VG_(replacement_malloc_print_debug_usage)       ( void );
1795
1796
1797
/*====================================================================*/
1798
/*=== Skin-specific stuff                                          ===*/
1799
/*====================================================================*/
1800
1801
/* ------------------------------------------------------------------ */
1802
/* Details */
1803
1804
/* Default value for avg_translations_sizeB (in bytes), indicating typical
1805
   code expansion of about 6:1. */
1806
#define VG_DEFAULT_TRANS_SIZEB   100
1807
1808
/* Information used in the startup message.  `name' also determines the
1809
   string used for identifying suppressions in a suppression file as
1810
   belonging to this skin.  `version' can be NULL, in which case (not
1811
   surprisingly) no version info is printed; this mechanism is designed for
1812
   skins distributed with Valgrind that share a version number with
1813
   Valgrind.  Other skins not distributed as part of Valgrind should
1814
   probably have their own version number.  */
1815
extern void VG_(details_name)                  ( Char* name );
1816
extern void VG_(details_version)               ( Char* version );
1817
extern void VG_(details_description)           ( Char* description );
1818
extern void VG_(details_copyright_author)      ( Char* copyright_author );
1819
1820
/* Average size of a translation, in bytes, so that the translation
1821
   storage machinery can allocate memory appropriately.  Not critical,
1822
   setting is optional. */
1823
extern void VG_(details_avg_translation_sizeB) ( UInt size );
1824
1825
/* String printed if an `sk_assert' assertion fails or VG_(skin_panic)
1826
   is called.  Should probably be an email address. */
1827
extern void VG_(details_bug_reports_to)   ( Char* bug_reports_to );
1828
1829
/* ------------------------------------------------------------------ */
1830
/* Needs */
1831
1832
/* Booleans that decide core behaviour, but don't require extra
1833
   operations to be defined if `True' */
1834
1835
/* Should __libc_freeres() be run?  Bugs in it can crash the skin. */
1836
extern void VG_(needs_libc_freeres) ( void );
1837
1838
/* Want to have errors detected by Valgrind's core reported?  Includes:
1839
   - pthread API errors (many;  eg. unlocking a non-locked mutex)
1840
   - invalid file descriptors to blocking syscalls read() and write()
1841
   - bad signal numbers passed to sigaction()
1842
   - attempt to install signal handler for SIGKILL or SIGSTOP */
1843
extern void VG_(needs_core_errors) ( void );
1844
1845
/* Booleans that indicate extra operations are defined;  if these are True,
1846
   the corresponding template functions (given below) must be defined.  A
1847
   lot like being a member of a type class. */
1848
1849
/* Want to report errors from skin?  This implies use of suppressions, too. */
1850
extern void VG_(needs_skin_errors) ( void );
1851
1852
/* Is information kept about specific individual basic blocks?  (Eg. for
1853
   cachegrind there are cost-centres for every instruction, stored at a
1854
   basic block level.)  If so, it sometimes has to be discarded, because
1855
   .so mmap/munmap-ping or self-modifying code (informed by the
1856
   DISCARD_TRANSLATIONS user request) can cause one instruction address
1857
   to be used for more than one instruction in one program run...  */
1858
extern void VG_(needs_basic_block_discards) ( void );
1859
1860
/* Skin maintains information about each register? */
1861
extern void VG_(needs_shadow_regs) ( void );
1862
1863
/* Skin defines its own command line options? */
1864
extern void VG_(needs_command_line_options) ( void );
1865
1866
/* Skin defines its own client requests? */
1867
extern void VG_(needs_client_requests) ( void );
1868
1869
/* Skin defines its own UInstrs? */
1870
extern void VG_(needs_extended_UCode) ( void );
1871
1872
/* Skin does stuff before and/or after system calls? */
1873
extern void VG_(needs_syscall_wrapper) ( void );
1874
1875
/* Are skin-state sanity checks performed? */
1876
extern void VG_(needs_sanity_checks) ( void );
1877
1878
/* Do we need to see data symbols? */
1879
extern void VG_(needs_data_syms) ( void );
1880
1881
/* Does the skin need shadow memory allocated (if you set this, you must also statically initialize 
1882
   float SK_(shadow_ratio) = n./m;
1883
   to define how many shadow bits you need per client address space bit.
1884
*/
1885
extern void VG_(needs_shadow_memory)( void );
1886
extern float SK_(shadow_ratio);
1887
1888
/* ------------------------------------------------------------------ */
1889
/* Core events to track */
1890
1891
/* Part of the core from which this call was made.  Useful for determining
1892
   what kind of error message should be emitted. */
1893
typedef
1894
   enum { Vg_CorePThread, Vg_CoreSignal, Vg_CoreSysCall, Vg_CoreTranslate }
1895
   CorePart;
1896
1897
/* Useful to use in VG_(get_Xreg_usage)() */
1898
#define VG_UINSTR_READS_REG(ono,regs,isWrites)  \
1899
   { if (mycat(u->tag,ono) == tag)              \
1900
        { regs[n]     = mycat(u->val,ono);      \
1901
          isWrites[n] = False;                  \
1902
          n++;                                  \
1903
        }                                       \
1904
   }
1905
#define VG_UINSTR_WRITES_REG(ono,regs,isWrites) \
1906
   { if (mycat(u->tag,ono) == tag)              \
1907
        { regs[n]     = mycat(u->val,ono);      \
1908
          isWrites[n] = True;                   \
1909
          n++;                                  \
1910
        }                                       \
1911
   }
1912
1913
#endif   /* NDEF __VG_SKIN_H */
1914
1915
/* gen_toolint.pl will put the VG_(init_*)() functions here: */
(-)valgrind-2.1.0/install-sh (-223 / +239 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
#
3
# install - install a program, script, or datafile
2
# install - install a program, script, or datafile
4
#
3
4
scriptversion=2004-01-12.10
5
5
# This originates from X11R5 (mit/util/scripts/install.sh), which was
6
# This originates from X11R5 (mit/util/scripts/install.sh), which was
6
# later released in X11R6 (xc/config/util/install.sh) with the
7
# later released in X11R6 (xc/config/util/install.sh) with the
7
# following copyright and license.
8
# following copyright and license.
Lines 41-53 Link Here
41
# from scratch.  It can only install one file at a time, a restriction
42
# from scratch.  It can only install one file at a time, a restriction
42
# shared with many OS's install programs.
43
# shared with many OS's install programs.
43
44
44
45
# set DOITPROG to echo to test this script
45
# set DOITPROG to echo to test this script
46
46
47
# Don't use :- since 4.3BSD and earlier shells don't like it.
47
# Don't use :- since 4.3BSD and earlier shells don't like it.
48
doit="${DOITPROG-}"
48
doit="${DOITPROG-}"
49
49
50
51
# put in absolute paths if you don't have them in your path; or use env. vars.
50
# put in absolute paths if you don't have them in your path; or use env. vars.
52
51
53
mvprog="${MVPROG-mv}"
52
mvprog="${MVPROG-mv}"
Lines 59-294 Link Here
59
rmprog="${RMPROG-rm}"
58
rmprog="${RMPROG-rm}"
60
mkdirprog="${MKDIRPROG-mkdir}"
59
mkdirprog="${MKDIRPROG-mkdir}"
61
60
62
transformbasename=""
61
transformbasename=
63
transform_arg=""
62
transform_arg=
64
instcmd="$mvprog"
63
instcmd="$mvprog"
65
chmodcmd="$chmodprog 0755"
64
chmodcmd="$chmodprog 0755"
66
chowncmd=""
65
chowncmd=
67
chgrpcmd=""
66
chgrpcmd=
68
stripcmd=""
67
stripcmd=
69
rmcmd="$rmprog -f"
68
rmcmd="$rmprog -f"
70
mvcmd="$mvprog"
69
mvcmd="$mvprog"
71
src=""
70
src=
72
dst=""
71
dst=
73
dir_arg=""
72
dir_arg=
74
73
75
while [ x"$1" != x ]; do
74
usage="Usage: $0 [OPTION]... SRCFILE DSTFILE
76
    case $1 in
75
   or: $0 [OPTION]... SRCFILES... DIRECTORY
77
	-c) instcmd=$cpprog
76
   or: $0 -d DIRECTORIES...
78
	    shift
77
79
	    continue;;
78
In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default.
80
79
In the second, create the directory path DIR.
81
	-d) dir_arg=true
80
82
	    shift
81
Options:
83
	    continue;;
82
-b=TRANSFORMBASENAME
84
83
-c         copy source (using $cpprog) instead of moving (using $mvprog).
85
	-m) chmodcmd="$chmodprog $2"
84
-d         create directories instead of installing files.
86
	    shift
85
-g GROUP   $chgrp installed files to GROUP.
87
	    shift
86
-m MODE    $chmod installed files to MODE.
88
	    continue;;
87
-o USER    $chown installed files to USER.
89
88
-s         strip installed files (using $stripprog).
90
	-o) chowncmd="$chownprog $2"
89
-t=TRANSFORM
91
	    shift
90
--help     display this help and exit.
92
	    shift
91
--version  display version info and exit.
93
	    continue;;
92
94
93
Environment variables override the default commands:
95
	-g) chgrpcmd="$chgrpprog $2"
94
  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
96
	    shift
95
"
97
	    shift
96
98
	    continue;;
97
while test -n "$1"; do
99
98
  case $1 in
100
	-s) stripcmd=$stripprog
99
    -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
101
	    shift
100
        shift
102
	    continue;;
101
        continue;;
103
102
104
	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
103
    -c) instcmd=$cpprog
105
	    shift
104
        shift
106
	    continue;;
105
        continue;;
107
106
108
	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
107
    -d) dir_arg=true
109
	    shift
108
        shift
110
	    continue;;
109
        continue;;
111
110
112
	*)  if [ x"$src" = x ]
111
    -g) chgrpcmd="$chgrpprog $2"
113
	    then
112
        shift
114
		src=$1
113
        shift
115
	    else
114
        continue;;
116
		# this colon is to work around a 386BSD /bin/sh bug
115
117
		:
116
    --help) echo "$usage"; exit 0;;
118
		dst=$1
117
119
	    fi
118
    -m) chmodcmd="$chmodprog $2"
120
	    shift
119
        shift
121
	    continue;;
120
        shift
122
    esac
121
        continue;;
122
123
    -o) chowncmd="$chownprog $2"
124
        shift
125
        shift
126
        continue;;
127
128
    -s) stripcmd=$stripprog
129
        shift
130
        continue;;
131
132
    -t=*) transformarg=`echo $1 | sed 's/-t=//'`
133
        shift
134
        continue;;
135
136
    --version) echo "$0 $scriptversion"; exit 0;;
137
138
    *)  # When -d is used, all remaining arguments are directories to create.
139
	test -n "$dir_arg" && break
140
        # Otherwise, the last argument is the destination.  Remove it from $@.
141
	for arg
142
	do
143
          if test -n "$dstarg"; then
144
	    # $@ is not empty: it contains at least $arg.
145
	    set fnord "$@" "$dstarg"
146
	    shift # fnord
147
	  fi
148
	  shift # arg
149
	  dstarg=$arg
150
	done
151
	break;;
152
  esac
123
done
153
done
124
154
125
if [ x"$src" = x ]
155
if test -z "$1"; then
126
then
156
  if test -z "$dir_arg"; then
127
	echo "$0: no input file specified" >&2
157
    echo "$0: no input file specified." >&2
128
	exit 1
158
    exit 1
129
else
159
  fi
130
	:
160
  # It's OK to call `install-sh -d' without argument.
131
fi
161
  # This can happen when creating conditional directories.
132
162
  exit 0
133
if [ x"$dir_arg" != x ]; then
134
	dst=$src
135
	src=""
136
137
	if [ -d "$dst" ]; then
138
		instcmd=:
139
		chmodcmd=""
140
	else
141
		instcmd=$mkdirprog
142
	fi
143
else
144
145
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
146
# might cause directories to be created, which would be especially bad
147
# if $src (and thus $dsttmp) contains '*'.
148
149
	if [ -f "$src" ] || [ -d "$src" ]
150
	then
151
		:
152
	else
153
		echo "$0: $src does not exist" >&2
154
		exit 1
155
	fi
156
157
	if [ x"$dst" = x ]
158
	then
159
		echo "$0: no destination specified" >&2
160
		exit 1
161
	else
162
		:
163
	fi
164
165
# If destination is a directory, append the input filename; if your system
166
# does not like double slashes in filenames, you may need to add some logic
167
168
	if [ -d "$dst" ]
169
	then
170
		dst=$dst/`basename "$src"`
171
	else
172
		:
173
	fi
174
fi
163
fi
175
164
176
## this sed command emulates the dirname command
165
for src
177
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
166
do
178
167
  # Protect names starting with `-'.
179
# Make sure that the destination directory exists.
168
  case $src in
180
#  this part is taken from Noah Friedman's mkinstalldirs script
169
    -*) src=./$src ;;
181
170
  esac
182
# Skip lots of stat calls in the usual case.
171
183
if [ ! -d "$dstdir" ]; then
172
  if test -n "$dir_arg"; then
184
defaultIFS='
173
    dst=$src
185
	'
174
    src=
186
IFS="${IFS-$defaultIFS}"
175
187
176
    if test -d "$dst"; then
188
oIFS=$IFS
177
      instcmd=:
189
# Some sh's can't handle IFS=/ for some reason.
178
      chmodcmd=
190
IFS='%'
179
    else
191
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
180
      instcmd=$mkdirprog
192
IFS=$oIFS
181
    fi
193
182
  else
194
pathcomp=''
183
    # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
195
184
    # might cause directories to be created, which would be especially bad
196
while [ $# -ne 0 ] ; do
185
    # if $src (and thus $dsttmp) contains '*'.
197
	pathcomp=$pathcomp$1
186
    if test ! -f "$src" && test ! -d "$src"; then
198
	shift
187
      echo "$0: $src does not exist." >&2
199
188
      exit 1
200
	if [ ! -d "$pathcomp" ] ;
189
    fi
201
        then
190
202
		$mkdirprog "$pathcomp"
191
    if test -z "$dstarg"; then
203
	else
192
      echo "$0: no destination specified." >&2
204
		:
193
      exit 1
205
	fi
194
    fi
195
196
    dst=$dstarg
197
    # Protect names starting with `-'.
198
    case $dst in
199
      -*) dst=./$dst ;;
200
    esac
206
201
207
	pathcomp=$pathcomp/
202
    # If destination is a directory, append the input filename; won't work
203
    # if double slashes aren't ignored.
204
    if test -d "$dst"; then
205
      dst=$dst/`basename "$src"`
206
    fi
207
  fi
208
209
  # This sed command emulates the dirname command.
210
  dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
211
212
  # Make sure that the destination directory exists.
213
214
  # Skip lots of stat calls in the usual case.
215
  if test ! -d "$dstdir"; then
216
    defaultIFS='
217
  	'
218
    IFS="${IFS-$defaultIFS}"
219
220
    oIFS=$IFS
221
    # Some sh's can't handle IFS=/ for some reason.
222
    IFS='%'
223
    set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
224
    IFS=$oIFS
225
226
    pathcomp=
227
228
    while test $# -ne 0 ; do
229
      pathcomp=$pathcomp$1
230
      shift
231
      test -d "$pathcomp" || $mkdirprog "$pathcomp"
232
      pathcomp=$pathcomp/
233
    done
234
  fi
235
236
  if test -n "$dir_arg"; then
237
    $doit $instcmd "$dst" \
238
      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
239
      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
240
      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
241
      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
242
243
  else
244
    # If we're going to rename the final executable, determine the name now.
245
    if test -z "$transformarg"; then
246
      dstfile=`basename "$dst"`
247
    else
248
      dstfile=`basename "$dst" $transformbasename \
249
               | sed $transformarg`$transformbasename
250
    fi
251
252
    # don't allow the sed command to completely eliminate the filename.
253
    test -z "$dstfile" && dstfile=`basename "$dst"`
254
255
    # Make a couple of temp file names in the proper directory.
256
    dsttmp=$dstdir/_inst.$$_
257
    rmtmp=$dstdir/_rm.$$_
258
259
    # Trap to clean up those temp files at exit.
260
    trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
261
    trap '(exit $?); exit' 1 2 13 15
262
263
    # Move or copy the file name to the temp name
264
    $doit $instcmd "$src" "$dsttmp" &&
265
266
    # and set any options; do chmod last to preserve setuid bits.
267
    #
268
    # If any of these fail, we abort the whole thing.  If we want to
269
    # ignore errors from any of these, just make sure not to ignore
270
    # errors from the above "$doit $instcmd $src $dsttmp" command.
271
    #
272
    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
273
      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
274
      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
275
      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
276
277
    # Now remove or move aside any old file at destination location.  We
278
    # try this two ways since rm can't unlink itself on some systems and
279
    # the destination file might be busy for other reasons.  In this case,
280
    # the final cleanup might fail but the new file should still install
281
    # successfully.
282
    {
283
      if test -f "$dstdir/$dstfile"; then
284
        $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
285
        || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
286
        || {
287
  	  echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
288
  	  (exit 1); exit
289
        }
290
      else
291
        :
292
      fi
293
    } &&
294
295
    # Now rename the file to the real destination.
296
    $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
297
  fi || { (exit 1); exit; }
208
done
298
done
209
fi
210
211
if [ x"$dir_arg" != x ]
212
then
213
	$doit $instcmd "$dst" &&
214
215
	if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
216
	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
217
	if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
218
	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
219
else
220
221
# If we're going to rename the final executable, determine the name now.
222
223
	if [ x"$transformarg" = x ]
224
	then
225
		dstfile=`basename "$dst"`
226
	else
227
		dstfile=`basename "$dst" $transformbasename |
228
			sed $transformarg`$transformbasename
229
	fi
230
231
# don't allow the sed command to completely eliminate the filename
232
233
	if [ x"$dstfile" = x ]
234
	then
235
		dstfile=`basename "$dst"`
236
	else
237
		:
238
	fi
239
240
# Make a couple of temp file names in the proper directory.
241
242
	dsttmp=$dstdir/_inst.$$_
243
	rmtmp=$dstdir/_rm.$$_
244
245
# Trap to clean up temp files at exit.
246
247
	trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
248
	trap '(exit $?); exit' 1 2 13 15
249
250
# Move or copy the file name to the temp name
251
252
	$doit $instcmd "$src" "$dsttmp" &&
253
254
# and set any options; do chmod last to preserve setuid bits
255
256
# If any of these fail, we abort the whole thing.  If we want to
257
# ignore errors from any of these, just make sure not to ignore
258
# errors from the above "$doit $instcmd $src $dsttmp" command.
259
260
	if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
261
	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
262
	if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
263
	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
264
265
# Now remove or move aside any old file at destination location.  We try this
266
# two ways since rm can't unlink itself on some systems and the destination
267
# file might be busy for other reasons.  In this case, the final cleanup
268
# might fail but the new file should still install successfully.
269
270
{
271
	if [ -f "$dstdir/$dstfile" ]
272
	then
273
		$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
274
		$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
275
		{
276
		  echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
277
		  (exit 1); exit
278
		}
279
	else
280
		:
281
	fi
282
} &&
283
284
# Now rename the file to the real destination.
285
286
	$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
287
288
fi &&
289
299
290
# The final little trick to "correctly" pass the exit status to the exit trap.
300
# The final little trick to "correctly" pass the exit status to the exit trap.
291
292
{
301
{
293
	(exit 0); exit
302
  (exit 0); exit
294
}
303
}
304
305
# Local variables:
306
# eval: (add-hook 'write-file-hooks 'time-stamp)
307
# time-stamp-start: "scriptversion="
308
# time-stamp-format: "%:y-%02m-%02d.%02H"
309
# time-stamp-end: "$"
310
# End:
(-)valgrind-2.1.0/lackey/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/lackey/CVS/Entries (+4 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Mon Sep 23 11:36:33 2002//
2
/Makefile.am/1.42/Tue Dec 16 02:05:14 2003//
3
/lk_main.c/1.23/Sun Jan  4 16:43:22 2004//
4
D
(-)valgrind-2.1.0/lackey/CVS/Entries.Log (+2 lines)
Line 0 Link Here
1
A D/docs////
2
A D/tests////
(-)valgrind-2.1.0/lackey/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/lackey
(-)valgrind-2.1.0/lackey/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/lackey/Makefile.am (+6 lines)
Lines 6-14 Link Here
6
		@PREFERRED_STACK_BOUNDARY@ -g
6
		@PREFERRED_STACK_BOUNDARY@ -g
7
7
8
valdir = $(libdir)/valgrind
8
valdir = $(libdir)/valgrind
9
inplacedir = $(top_srcdir)/.in_place
9
10
10
val_PROGRAMS = vgskin_lackey.so
11
val_PROGRAMS = vgskin_lackey.so
11
12
12
vgskin_lackey_so_SOURCES = lk_main.c
13
vgskin_lackey_so_SOURCES = lk_main.c
13
vgskin_lackey_so_LDFLAGS = -shared
14
vgskin_lackey_so_LDFLAGS = -shared
14
15
16
17
all-local:
18
	mkdir -p $(inplacedir)
19
	-rm -f $(inplacedir)/$(val_PROGRAMS)
20
	ln -f -s $(top_srcdir)/$(subdir)/$(val_PROGRAMS) $(inplacedir)/$(val_PROGRAMS)
(-)valgrind-2.1.0/lackey/Makefile.in (-104 / +112 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 14-19 Link Here
14
14
15
@SET_MAKE@
15
@SET_MAKE@
16
16
17
SOURCES = $(vgskin_lackey_so_SOURCES)
18
17
srcdir = @srcdir@
19
srcdir = @srcdir@
18
top_srcdir = @top_srcdir@
20
top_srcdir = @top_srcdir@
19
VPATH = @srcdir@
21
VPATH = @srcdir@
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
23
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
24
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ..
25
top_builddir = ..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
27
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
28
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
37
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
38
POST_UNINSTALL = :
38
host_triplet = @host@
39
host_triplet = @host@
40
val_PROGRAMS = vgskin_lackey.so$(EXEEXT)
41
subdir = lackey
42
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
43
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
44
am__aclocal_m4_deps = $(top_srcdir)/configure.in
45
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
46
	$(ACLOCAL_M4)
47
mkinstalldirs = $(mkdir_p)
48
CONFIG_HEADER = $(top_builddir)/config.h
49
CONFIG_CLEAN_FILES =
50
am__installdirs = $(DESTDIR)$(valdir)
51
valPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
52
PROGRAMS = $(val_PROGRAMS)
53
am_vgskin_lackey_so_OBJECTS = lk_main.$(OBJEXT)
54
vgskin_lackey_so_OBJECTS = $(am_vgskin_lackey_so_OBJECTS)
55
vgskin_lackey_so_LDADD = $(LDADD)
56
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
57
depcomp = $(SHELL) $(top_srcdir)/depcomp
58
am__depfiles_maybe = depfiles
59
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/lk_main.Po
60
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
61
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
62
CCLD = $(CC)
63
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
64
SOURCES = $(vgskin_lackey_so_SOURCES)
65
DIST_SOURCES = $(vgskin_lackey_so_SOURCES)
66
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
67
	html-recursive info-recursive install-data-recursive \
68
	install-exec-recursive install-info-recursive \
69
	install-recursive installcheck-recursive installdirs-recursive \
70
	pdf-recursive ps-recursive uninstall-info-recursive \
71
	uninstall-recursive
72
ETAGS = etags
73
CTAGS = ctags
74
DIST_SUBDIRS = $(SUBDIRS)
75
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
76
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
77
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
78
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
129
SHELL = @SHELL@
93
STRIP = @STRIP@
130
STRIP = @STRIP@
94
VERSION = @VERSION@
131
VERSION = @VERSION@
132
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
133
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
134
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
135
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
161
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
162
localstatedir = @localstatedir@
125
mandir = @mandir@
163
mandir = @mandir@
164
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
165
oldincludedir = @oldincludedir@
127
prefix = @prefix@
166
prefix = @prefix@
128
program_transform_name = @program_transform_name@
167
program_transform_name = @program_transform_name@
Lines 130-194 Link Here
130
sharedstatedir = @sharedstatedir@
169
sharedstatedir = @sharedstatedir@
131
sysconfdir = @sysconfdir@
170
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
171
target_alias = @target_alias@
133
134
SUBDIRS = . docs tests
172
SUBDIRS = . docs tests
135
136
AM_CPPFLAGS = -I$(top_srcdir)/include -DVG_LIBDIR="\"$(libdir)"\"
173
AM_CPPFLAGS = -I$(top_srcdir)/include -DVG_LIBDIR="\"$(libdir)"\"
137
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer \
174
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer \
138
		@PREFERRED_STACK_BOUNDARY@ -g
175
		@PREFERRED_STACK_BOUNDARY@ -g
139
176
140
141
valdir = $(libdir)/valgrind
177
valdir = $(libdir)/valgrind
142
178
inplacedir = $(top_srcdir)/.in_place
143
val_PROGRAMS = vgskin_lackey.so
144
145
vgskin_lackey_so_SOURCES = lk_main.c
179
vgskin_lackey_so_SOURCES = lk_main.c
146
vgskin_lackey_so_LDFLAGS = -shared
180
vgskin_lackey_so_LDFLAGS = -shared
147
subdir = lackey
148
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
149
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
150
CONFIG_HEADER = $(top_builddir)/config.h
151
CONFIG_CLEAN_FILES =
152
val_PROGRAMS = vgskin_lackey.so$(EXEEXT)
153
PROGRAMS = $(val_PROGRAMS)
154
155
am_vgskin_lackey_so_OBJECTS = lk_main.$(OBJEXT)
156
vgskin_lackey_so_OBJECTS = $(am_vgskin_lackey_so_OBJECTS)
157
vgskin_lackey_so_LDADD = $(LDADD)
158
vgskin_lackey_so_DEPENDENCIES =
159
160
DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
161
depcomp = $(SHELL) $(top_srcdir)/depcomp
162
am__depfiles_maybe = depfiles
163
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/lk_main.Po
164
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
165
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
166
CCLD = $(CC)
167
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
168
DIST_SOURCES = $(vgskin_lackey_so_SOURCES)
169
170
RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
171
	ps-recursive install-info-recursive uninstall-info-recursive \
172
	all-recursive install-data-recursive install-exec-recursive \
173
	installdirs-recursive install-recursive uninstall-recursive \
174
	check-recursive installcheck-recursive
175
DIST_COMMON = Makefile.am Makefile.in
176
DIST_SUBDIRS = $(SUBDIRS)
177
SOURCES = $(vgskin_lackey_so_SOURCES)
178
179
all: all-recursive
181
all: all-recursive
180
182
181
.SUFFIXES:
183
.SUFFIXES:
182
.SUFFIXES: .c .o .obj
184
.SUFFIXES: .c .o .obj
183
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
185
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
186
	@for dep in $?; do \
187
	  case '$(am__configure_deps)' in \
188
	    *$$dep*) \
189
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
190
		&& exit 0; \
191
	      exit 1;; \
192
	  esac; \
193
	done; \
194
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  lackey/Makefile'; \
184
	cd $(top_srcdir) && \
195
	cd $(top_srcdir) && \
185
	  $(AUTOMAKE) --gnu  lackey/Makefile
196
	  $(AUTOMAKE) --gnu  lackey/Makefile
186
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
197
.PRECIOUS: Makefile
187
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
198
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
188
valPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
199
	@case '$?' in \
200
	  *config.status*) \
201
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
202
	  *) \
203
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
204
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
205
	esac;
206
207
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
208
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
209
210
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
211
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
212
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
213
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
189
install-valPROGRAMS: $(val_PROGRAMS)
214
install-valPROGRAMS: $(val_PROGRAMS)
190
	@$(NORMAL_INSTALL)
215
	@$(NORMAL_INSTALL)
191
	$(mkinstalldirs) $(DESTDIR)$(valdir)
216
	$(mkdir_p) $(DESTDIR)$(valdir)
192
	@list='$(val_PROGRAMS)'; for p in $$list; do \
217
	@list='$(val_PROGRAMS)'; for p in $$list; do \
193
	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
218
	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
194
	  if test -f $$p \
219
	  if test -f $$p \
Lines 214-250 Link Here
214
	$(LINK) $(vgskin_lackey_so_LDFLAGS) $(vgskin_lackey_so_OBJECTS) $(vgskin_lackey_so_LDADD) $(LIBS)
239
	$(LINK) $(vgskin_lackey_so_LDFLAGS) $(vgskin_lackey_so_OBJECTS) $(vgskin_lackey_so_LDADD) $(LIBS)
215
240
216
mostlyclean-compile:
241
mostlyclean-compile:
217
	-rm -f *.$(OBJEXT) core *.core
242
	-rm -f *.$(OBJEXT)
218
243
219
distclean-compile:
244
distclean-compile:
220
	-rm -f *.tab.c
245
	-rm -f *.tab.c
221
246
222
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lk_main.Po@am__quote@
247
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lk_main.Po@am__quote@
223
248
224
distclean-depend:
225
	-rm -rf ./$(DEPDIR)
226
227
.c.o:
249
.c.o:
228
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
250
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
229
@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
251
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
230
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
231
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
232
@am__fastdepCC_TRUE@	fi
233
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
252
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
234
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
253
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
235
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
254
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
236
@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
255
@am__fastdepCC_FALSE@	$(COMPILE) -c $<
237
256
238
.c.obj:
257
.c.obj:
239
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
258
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
240
@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
259
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
241
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
242
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
243
@am__fastdepCC_TRUE@	fi
244
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
260
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
245
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
261
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
246
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
262
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
247
@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
263
@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
248
uninstall-info-am:
264
uninstall-info-am:
249
265
250
# This directory's subdirectories are mostly independent; you can cd
266
# This directory's subdirectories are mostly independent; you can cd
Lines 306-319 Link Here
306
	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
322
	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
307
	done
323
	done
308
324
309
ETAGS = etags
310
ETAGSFLAGS =
311
312
CTAGS = ctags
313
CTAGSFLAGS =
314
315
tags: TAGS
316
317
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
325
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
318
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
326
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
319
	unique=`for i in $$list; do \
327
	unique=`for i in $$list; do \
Lines 322-327 Link Here
322
	  $(AWK) '    { files[$$0] = 1; } \
330
	  $(AWK) '    { files[$$0] = 1; } \
323
	       END { for (i in files) print i; }'`; \
331
	       END { for (i in files) print i; }'`; \
324
	mkid -fID $$unique
332
	mkid -fID $$unique
333
tags: TAGS
325
334
326
TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
335
TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
327
		$(TAGS_FILES) $(LISP)
336
		$(TAGS_FILES) $(LISP)
Lines 347-353 Link Here
347
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
356
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
348
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
357
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
349
	     $$tags $$unique
358
	     $$tags $$unique
350
351
ctags: CTAGS
359
ctags: CTAGS
352
CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
360
CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
353
		$(TAGS_FILES) $(LISP)
361
		$(TAGS_FILES) $(LISP)
Lines 370-379 Link Here
370
378
371
distclean-tags:
379
distclean-tags:
372
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
380
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
373
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
374
375
top_distdir = ..
376
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
377
381
378
distdir: $(DISTFILES)
382
distdir: $(DISTFILES)
379
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
383
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 387-393 Link Here
387
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
391
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
388
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
392
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
389
	    dir="/$$dir"; \
393
	    dir="/$$dir"; \
390
	    $(mkinstalldirs) "$(distdir)$$dir"; \
394
	    $(mkdir_p) "$(distdir)$$dir"; \
391
	  else \
395
	  else \
392
	    dir=''; \
396
	    dir=''; \
393
	  fi; \
397
	  fi; \
Lines 404-427 Link Here
404
	done
408
	done
405
	list='$(SUBDIRS)'; for subdir in $$list; do \
409
	list='$(SUBDIRS)'; for subdir in $$list; do \
406
	  if test "$$subdir" = .; then :; else \
410
	  if test "$$subdir" = .; then :; else \
407
	    test -d $(distdir)/$$subdir \
411
	    test -d "$(distdir)/$$subdir" \
408
	    || mkdir $(distdir)/$$subdir \
412
	    || mkdir "$(distdir)/$$subdir" \
409
	    || exit 1; \
413
	    || exit 1; \
410
	    (cd $$subdir && \
414
	    (cd $$subdir && \
411
	      $(MAKE) $(AM_MAKEFLAGS) \
415
	      $(MAKE) $(AM_MAKEFLAGS) \
412
	        top_distdir="$(top_distdir)" \
416
	        top_distdir="../$(top_distdir)" \
413
	        distdir=../$(distdir)/$$subdir \
417
	        distdir="../$(distdir)/$$subdir" \
414
	        distdir) \
418
	        distdir) \
415
	      || exit 1; \
419
	      || exit 1; \
416
	  fi; \
420
	  fi; \
417
	done
421
	done
418
check-am: all-am
422
check-am: all-am
419
check: check-recursive
423
check: check-recursive
420
all-am: Makefile $(PROGRAMS)
424
all-am: Makefile $(PROGRAMS) all-local
421
installdirs: installdirs-recursive
425
installdirs: installdirs-recursive
422
installdirs-am:
426
installdirs-am:
423
	$(mkinstalldirs) $(DESTDIR)$(valdir)
427
	$(mkdir_p) $(DESTDIR)$(valdir)
424
425
install: install-recursive
428
install: install-recursive
426
install-exec: install-exec-recursive
429
install-exec: install-exec-recursive
427
install-data: install-data-recursive
430
install-data: install-data-recursive
Lines 433-439 Link Here
433
installcheck: installcheck-recursive
436
installcheck: installcheck-recursive
434
install-strip:
437
install-strip:
435
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
438
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
436
	  INSTALL_STRIP_FLAG=-s \
439
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
437
	  `test -z '$(STRIP)' || \
440
	  `test -z '$(STRIP)' || \
438
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
441
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
439
mostlyclean-generic:
442
mostlyclean-generic:
Lines 441-447 Link Here
441
clean-generic:
444
clean-generic:
442
445
443
distclean-generic:
446
distclean-generic:
444
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
447
	-rm -f $(CONFIG_CLEAN_FILES)
445
448
446
maintainer-clean-generic:
449
maintainer-clean-generic:
447
	@echo "This command is intended for maintainers to use"
450
	@echo "This command is intended for maintainers to use"
Lines 451-464 Link Here
451
clean-am: clean-generic clean-valPROGRAMS mostlyclean-am
454
clean-am: clean-generic clean-valPROGRAMS mostlyclean-am
452
455
453
distclean: distclean-recursive
456
distclean: distclean-recursive
454
457
	-rm -rf ./$(DEPDIR)
455
distclean-am: clean-am distclean-compile distclean-depend \
458
	-rm -f Makefile
456
	distclean-generic distclean-tags
459
distclean-am: clean-am distclean-compile distclean-generic \
460
	distclean-tags
457
461
458
dvi: dvi-recursive
462
dvi: dvi-recursive
459
463
460
dvi-am:
464
dvi-am:
461
465
466
html: html-recursive
467
462
info: info-recursive
468
info: info-recursive
463
469
464
info-am:
470
info-am:
Lines 474-480 Link Here
474
installcheck-am:
480
installcheck-am:
475
481
476
maintainer-clean: maintainer-clean-recursive
482
maintainer-clean: maintainer-clean-recursive
477
483
	-rm -rf ./$(DEPDIR)
484
	-rm -f Makefile
478
maintainer-clean-am: distclean-am maintainer-clean-generic
485
maintainer-clean-am: distclean-am maintainer-clean-generic
479
486
480
mostlyclean: mostlyclean-recursive
487
mostlyclean: mostlyclean-recursive
Lines 493-516 Link Here
493
500
494
uninstall-info: uninstall-info-recursive
501
uninstall-info: uninstall-info-recursive
495
502
496
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
503
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am all-local check \
497
	clean-generic clean-recursive clean-valPROGRAMS ctags \
504
	check-am clean clean-generic clean-recursive clean-valPROGRAMS \
498
	ctags-recursive distclean distclean-compile distclean-depend \
505
	ctags ctags-recursive distclean distclean-compile \
499
	distclean-generic distclean-recursive distclean-tags distdir \
506
	distclean-generic distclean-recursive distclean-tags distdir \
500
	dvi dvi-am dvi-recursive info info-am info-recursive install \
507
	dvi dvi-am html html-am info info-am install install-am \
501
	install-am install-data install-data-am install-data-recursive \
508
	install-data install-data-am install-exec install-exec-am \
502
	install-exec install-exec-am install-exec-recursive \
509
	install-info install-info-am install-man install-strip \
503
	install-info install-info-am install-info-recursive install-man \
510
	install-valPROGRAMS installcheck installcheck-am installdirs \
504
	install-recursive install-strip install-valPROGRAMS \
511
	installdirs-am maintainer-clean maintainer-clean-generic \
505
	installcheck installcheck-am installdirs installdirs-am \
506
	installdirs-recursive maintainer-clean maintainer-clean-generic \
507
	maintainer-clean-recursive mostlyclean mostlyclean-compile \
512
	maintainer-clean-recursive mostlyclean mostlyclean-compile \
508
	mostlyclean-generic mostlyclean-recursive pdf pdf-am \
513
	mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \
509
	pdf-recursive ps ps-am ps-recursive tags tags-recursive \
514
	tags tags-recursive uninstall uninstall-am uninstall-info-am \
510
	uninstall uninstall-am uninstall-info-am \
511
	uninstall-info-recursive uninstall-recursive \
512
	uninstall-valPROGRAMS
515
	uninstall-valPROGRAMS
513
516
517
518
all-local:
519
	mkdir -p $(inplacedir)
520
	-rm -f $(inplacedir)/$(val_PROGRAMS)
521
	ln -f -s $(top_srcdir)/$(subdir)/$(val_PROGRAMS) $(inplacedir)/$(val_PROGRAMS)
514
# Tell versions [3.59,3.63) of GNU make to not export all variables.
522
# Tell versions [3.59,3.63) of GNU make to not export all variables.
515
# Otherwise a system limit (for SysV at least) may be exceeded.
523
# Otherwise a system limit (for SysV at least) may be exceeded.
516
.NOEXPORT:
524
.NOEXPORT:
(-)valgrind-2.1.0/lackey/docs/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/lackey/docs/CVS/Entries (+4 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Thu Oct  3 10:07:34 2002//
2
/Makefile.am/1.2/Wed Nov 13 21:24:56 2002//
3
/lk_main.html/1.4/Sun Jan  4 16:43:22 2004//
4
D
(-)valgrind-2.1.0/lackey/docs/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/lackey/docs
(-)valgrind-2.1.0/lackey/docs/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/lackey/docs/Makefile.in (-38 / +64 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
21
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
23
top_builddir = ../..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
25
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
26
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
35
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
36
POST_UNINSTALL = :
38
host_triplet = @host@
37
host_triplet = @host@
38
subdir = lackey/docs
39
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
40
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
41
am__aclocal_m4_deps = $(top_srcdir)/configure.in
42
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
43
	$(ACLOCAL_M4)
44
mkinstalldirs = $(mkdir_p)
45
CONFIG_HEADER = $(top_builddir)/config.h
46
CONFIG_CLEAN_FILES =
47
SOURCES =
48
DIST_SOURCES =
49
am__installdirs = $(DESTDIR)$(docdir)
50
docDATA_INSTALL = $(INSTALL_DATA)
51
DATA = $(doc_DATA)
52
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
53
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
54
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
55
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
106
SHELL = @SHELL@
93
STRIP = @STRIP@
107
STRIP = @STRIP@
94
VERSION = @VERSION@
108
VERSION = @VERSION@
109
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
110
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
111
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
112
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
138
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
139
localstatedir = @localstatedir@
125
mandir = @mandir@
140
mandir = @mandir@
141
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
142
oldincludedir = @oldincludedir@
127
prefix = @prefix@
143
prefix = @prefix@
128
program_transform_name = @program_transform_name@
144
program_transform_name = @program_transform_name@
Lines 131-162 Link Here
131
sysconfdir = @sysconfdir@
147
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
148
target_alias = @target_alias@
133
docdir = $(datadir)/doc/valgrind
149
docdir = $(datadir)/doc/valgrind
134
135
doc_DATA = lk_main.html
150
doc_DATA = lk_main.html
136
137
EXTRA_DIST = $(doc_DATA)
151
EXTRA_DIST = $(doc_DATA)
138
subdir = lackey/docs
139
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
140
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
141
CONFIG_HEADER = $(top_builddir)/config.h
142
CONFIG_CLEAN_FILES =
143
DIST_SOURCES =
144
DATA = $(doc_DATA)
145
146
DIST_COMMON = Makefile.am Makefile.in
147
all: all-am
152
all: all-am
148
153
149
.SUFFIXES:
154
.SUFFIXES:
150
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
155
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
156
	@for dep in $?; do \
157
	  case '$(am__configure_deps)' in \
158
	    *$$dep*) \
159
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
160
		&& exit 0; \
161
	      exit 1;; \
162
	  esac; \
163
	done; \
164
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  lackey/docs/Makefile'; \
151
	cd $(top_srcdir) && \
165
	cd $(top_srcdir) && \
152
	  $(AUTOMAKE) --gnu  lackey/docs/Makefile
166
	  $(AUTOMAKE) --gnu  lackey/docs/Makefile
153
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
167
.PRECIOUS: Makefile
154
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
168
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
169
	@case '$?' in \
170
	  *config.status*) \
171
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
172
	  *) \
173
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
174
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
175
	esac;
176
177
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
178
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
179
180
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
181
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
182
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
183
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
155
uninstall-info-am:
184
uninstall-info-am:
156
docDATA_INSTALL = $(INSTALL_DATA)
157
install-docDATA: $(doc_DATA)
185
install-docDATA: $(doc_DATA)
158
	@$(NORMAL_INSTALL)
186
	@$(NORMAL_INSTALL)
159
	$(mkinstalldirs) $(DESTDIR)$(docdir)
187
	$(mkdir_p) $(DESTDIR)$(docdir)
160
	@list='$(doc_DATA)'; for p in $$list; do \
188
	@list='$(doc_DATA)'; for p in $$list; do \
161
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
189
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
162
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
190
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
Lines 177-186 Link Here
177
ctags: CTAGS
205
ctags: CTAGS
178
CTAGS:
206
CTAGS:
179
207
180
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
181
182
top_distdir = ../..
183
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
184
208
185
distdir: $(DISTFILES)
209
distdir: $(DISTFILES)
186
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
210
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 194-200 Link Here
194
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
218
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
195
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
219
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
196
	    dir="/$$dir"; \
220
	    dir="/$$dir"; \
197
	    $(mkinstalldirs) "$(distdir)$$dir"; \
221
	    $(mkdir_p) "$(distdir)$$dir"; \
198
	  else \
222
	  else \
199
	    dir=''; \
223
	    dir=''; \
200
	  fi; \
224
	  fi; \
Lines 212-220 Link Here
212
check-am: all-am
236
check-am: all-am
213
check: check-am
237
check: check-am
214
all-am: Makefile $(DATA)
238
all-am: Makefile $(DATA)
215
216
installdirs:
239
installdirs:
217
	$(mkinstalldirs) $(DESTDIR)$(docdir)
240
	$(mkdir_p) $(DESTDIR)$(docdir)
218
install: install-am
241
install: install-am
219
install-exec: install-exec-am
242
install-exec: install-exec-am
220
install-data: install-data-am
243
install-data: install-data-am
Lines 226-232 Link Here
226
installcheck: installcheck-am
249
installcheck: installcheck-am
227
install-strip:
250
install-strip:
228
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
251
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
229
	  INSTALL_STRIP_FLAG=-s \
252
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
230
	  `test -z '$(STRIP)' || \
253
	  `test -z '$(STRIP)' || \
231
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
254
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
232
mostlyclean-generic:
255
mostlyclean-generic:
Lines 234-240 Link Here
234
clean-generic:
257
clean-generic:
235
258
236
distclean-generic:
259
distclean-generic:
237
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
260
	-rm -f $(CONFIG_CLEAN_FILES)
238
261
239
maintainer-clean-generic:
262
maintainer-clean-generic:
240
	@echo "This command is intended for maintainers to use"
263
	@echo "This command is intended for maintainers to use"
Lines 244-256 Link Here
244
clean-am: clean-generic mostlyclean-am
267
clean-am: clean-generic mostlyclean-am
245
268
246
distclean: distclean-am
269
distclean: distclean-am
247
270
	-rm -f Makefile
248
distclean-am: clean-am distclean-generic
271
distclean-am: clean-am distclean-generic
249
272
250
dvi: dvi-am
273
dvi: dvi-am
251
274
252
dvi-am:
275
dvi-am:
253
276
277
html: html-am
278
254
info: info-am
279
info: info-am
255
280
256
info-am:
281
info-am:
Lines 266-272 Link Here
266
installcheck-am:
291
installcheck-am:
267
292
268
maintainer-clean: maintainer-clean-am
293
maintainer-clean: maintainer-clean-am
269
294
	-rm -f Makefile
270
maintainer-clean-am: distclean-am maintainer-clean-generic
295
maintainer-clean-am: distclean-am maintainer-clean-generic
271
296
272
mostlyclean: mostlyclean-am
297
mostlyclean: mostlyclean-am
Lines 284-296 Link Here
284
uninstall-am: uninstall-docDATA uninstall-info-am
309
uninstall-am: uninstall-docDATA uninstall-info-am
285
310
286
.PHONY: all all-am check check-am clean clean-generic distclean \
311
.PHONY: all all-am check check-am clean clean-generic distclean \
287
	distclean-generic distdir dvi dvi-am info info-am install \
312
	distclean-generic distdir dvi dvi-am html html-am info info-am \
288
	install-am install-data install-data-am install-docDATA \
313
	install install-am install-data install-data-am \
289
	install-exec install-exec-am install-info install-info-am \
314
	install-docDATA install-exec install-exec-am install-info \
290
	install-man install-strip installcheck installcheck-am \
315
	install-info-am install-man install-strip installcheck \
291
	installdirs maintainer-clean maintainer-clean-generic \
316
	installcheck-am installdirs maintainer-clean \
292
	mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
317
	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
293
	uninstall-am uninstall-docDATA uninstall-info-am
318
	pdf-am ps ps-am uninstall uninstall-am uninstall-docDATA \
319
	uninstall-info-am
294
320
295
# Tell versions [3.59,3.63) of GNU make to not export all variables.
321
# Tell versions [3.59,3.63) of GNU make to not export all variables.
296
# Otherwise a system limit (for SysV at least) may be exceeded.
322
# Otherwise a system limit (for SysV at least) may be exceeded.
(-)valgrind-2.1.0/lackey/docs/lk_main.html (-1 / +1 lines)
Lines 31-37 Link Here
31
31
32
<center>
32
<center>
33
<a href="mailto:njn25@cam.ac.uk">njn25@cam.ac.uk</a><br>
33
<a href="mailto:njn25@cam.ac.uk">njn25@cam.ac.uk</a><br>
34
Copyright &copy; 2000-2003 Nicholas Nethercote
34
Copyright &copy; 2002-2004 Nicholas Nethercote
35
<p>
35
<p>
36
Lackey is licensed under the GNU General Public License, 
36
Lackey is licensed under the GNU General Public License, 
37
version 2<br>
37
version 2<br>
(-)valgrind-2.1.0/lackey/lk_main.c (-4 / +5 lines)
Lines 8-14 Link Here
8
   This file is part of Lackey, an example Valgrind tool that does
8
   This file is part of Lackey, an example Valgrind tool that does
9
   some simple program measurement.
9
   some simple program measurement.
10
10
11
   Copyright (C) 2002-2003 Nicholas Nethercote
11
   Copyright (C) 2002-2004 Nicholas Nethercote
12
      njn25@cam.ac.uk
12
      njn25@cam.ac.uk
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 31-38 Link Here
31
31
32
#include "vg_skin.h"
32
#include "vg_skin.h"
33
33
34
VG_DETERMINE_INTERFACE_VERSION
35
36
/* Nb: use ULongs because the numbers can get very big */
34
/* Nb: use ULongs because the numbers can get very big */
37
static ULong n_dlrr_calls   = 0;
35
static ULong n_dlrr_calls   = 0;
38
static ULong n_BBs          = 0;
36
static ULong n_BBs          = 0;
Lines 80-86 Link Here
80
   VG_(details_version)         (NULL);
78
   VG_(details_version)         (NULL);
81
   VG_(details_description)     ("an example Valgrind tool");
79
   VG_(details_description)     ("an example Valgrind tool");
82
   VG_(details_copyright_author)(
80
   VG_(details_copyright_author)(
83
      "Copyright (C) 2002-2003, and GNU GPL'd, by Nicholas Nethercote.");
81
      "Copyright (C) 2002-2004, and GNU GPL'd, by Nicholas Nethercote.");
84
   VG_(details_bug_reports_to)  (VG_BUGS_TO);
82
   VG_(details_bug_reports_to)  (VG_BUGS_TO);
85
   VG_(details_avg_translation_sizeB) ( 175 );
83
   VG_(details_avg_translation_sizeB) ( 175 );
86
84
Lines 224-229 Link Here
224
    VG_(message)(Vg_UserMsg, "Exit code:     %d", exitcode);
222
    VG_(message)(Vg_UserMsg, "Exit code:     %d", exitcode);
225
}
223
}
226
224
225
VG_DETERMINE_INTERFACE_VERSION(SK_(pre_clo_init), 0)
226
227
227
/*--------------------------------------------------------------------*/
228
/*--------------------------------------------------------------------*/
228
/*--- end                                                lk_main.c ---*/
229
/*--- end                                                lk_main.c ---*/
229
/*--------------------------------------------------------------------*/
230
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/lackey/tests/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/lackey/tests/CVS/Entries (+6 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Fri Oct  4 11:35:47 2002//
2
/Makefile.am/1.3/Thu Jun 12 14:12:58 2003//
3
/filter_stderr/1.2/Tue Apr 22 21:41:38 2003//
4
/true.stderr.exp/1.1/Fri Oct  4 11:35:47 2002//
5
/true.vgtest/1.1/Fri Oct  4 11:35:47 2002//
6
D
(-)valgrind-2.1.0/lackey/tests/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/lackey/tests
(-)valgrind-2.1.0/lackey/tests/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/lackey/tests/Makefile.in (-29 / +54 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
21
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
23
top_builddir = ../..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
25
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
26
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
35
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
36
POST_UNINSTALL = :
38
host_triplet = @host@
37
host_triplet = @host@
38
subdir = lackey/tests
39
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
40
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
41
am__aclocal_m4_deps = $(top_srcdir)/configure.in
42
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
43
	$(ACLOCAL_M4)
44
mkinstalldirs = $(mkdir_p)
45
CONFIG_HEADER = $(top_builddir)/config.h
46
CONFIG_CLEAN_FILES =
47
SCRIPTS = $(noinst_SCRIPTS)
48
SOURCES =
49
DIST_SOURCES =
50
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
51
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
52
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
53
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
104
SHELL = @SHELL@
93
STRIP = @STRIP@
105
STRIP = @STRIP@
94
VERSION = @VERSION@
106
VERSION = @VERSION@
107
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
108
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
109
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
110
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
136
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
137
localstatedir = @localstatedir@
125
mandir = @mandir@
138
mandir = @mandir@
139
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
140
oldincludedir = @oldincludedir@
127
prefix = @prefix@
141
prefix = @prefix@
128
program_transform_name = @program_transform_name@
142
program_transform_name = @program_transform_name@
Lines 131-157 Link Here
131
sysconfdir = @sysconfdir@
145
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
146
target_alias = @target_alias@
133
noinst_SCRIPTS = filter_stderr
147
noinst_SCRIPTS = filter_stderr
134
135
EXTRA_DIST = $(noinst_SCRIPTS) \
148
EXTRA_DIST = $(noinst_SCRIPTS) \
136
	true.stderr.exp true.vgtest
149
	true.stderr.exp true.vgtest
137
150
138
subdir = lackey/tests
139
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
140
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
141
CONFIG_HEADER = $(top_builddir)/config.h
142
CONFIG_CLEAN_FILES =
143
SCRIPTS = $(noinst_SCRIPTS)
144
145
DIST_SOURCES =
146
DIST_COMMON = Makefile.am Makefile.in
147
all: all-am
151
all: all-am
148
152
149
.SUFFIXES:
153
.SUFFIXES:
150
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
154
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
155
	@for dep in $?; do \
156
	  case '$(am__configure_deps)' in \
157
	    *$$dep*) \
158
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
159
		&& exit 0; \
160
	      exit 1;; \
161
	  esac; \
162
	done; \
163
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  lackey/tests/Makefile'; \
151
	cd $(top_srcdir) && \
164
	cd $(top_srcdir) && \
152
	  $(AUTOMAKE) --gnu  lackey/tests/Makefile
165
	  $(AUTOMAKE) --gnu  lackey/tests/Makefile
153
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
166
.PRECIOUS: Makefile
154
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
167
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
168
	@case '$?' in \
169
	  *config.status*) \
170
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
171
	  *) \
172
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
173
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
174
	esac;
175
176
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
177
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
178
179
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
180
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
181
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
182
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
155
uninstall-info-am:
183
uninstall-info-am:
156
tags: TAGS
184
tags: TAGS
157
TAGS:
185
TAGS:
Lines 159-168 Link Here
159
ctags: CTAGS
187
ctags: CTAGS
160
CTAGS:
188
CTAGS:
161
189
162
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
163
164
top_distdir = ../..
165
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
166
190
167
distdir: $(DISTFILES)
191
distdir: $(DISTFILES)
168
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
192
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 176-182 Link Here
176
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
200
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
177
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
201
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
178
	    dir="/$$dir"; \
202
	    dir="/$$dir"; \
179
	    $(mkinstalldirs) "$(distdir)$$dir"; \
203
	    $(mkdir_p) "$(distdir)$$dir"; \
180
	  else \
204
	  else \
181
	    dir=''; \
205
	    dir=''; \
182
	  fi; \
206
	  fi; \
Lines 194-200 Link Here
194
check-am: all-am
218
check-am: all-am
195
check: check-am
219
check: check-am
196
all-am: Makefile $(SCRIPTS)
220
all-am: Makefile $(SCRIPTS)
197
198
installdirs:
221
installdirs:
199
install: install-am
222
install: install-am
200
install-exec: install-exec-am
223
install-exec: install-exec-am
Lines 207-213 Link Here
207
installcheck: installcheck-am
230
installcheck: installcheck-am
208
install-strip:
231
install-strip:
209
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
232
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
210
	  INSTALL_STRIP_FLAG=-s \
233
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
211
	  `test -z '$(STRIP)' || \
234
	  `test -z '$(STRIP)' || \
212
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
235
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
213
mostlyclean-generic:
236
mostlyclean-generic:
Lines 215-221 Link Here
215
clean-generic:
238
clean-generic:
216
239
217
distclean-generic:
240
distclean-generic:
218
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
241
	-rm -f $(CONFIG_CLEAN_FILES)
219
242
220
maintainer-clean-generic:
243
maintainer-clean-generic:
221
	@echo "This command is intended for maintainers to use"
244
	@echo "This command is intended for maintainers to use"
Lines 225-237 Link Here
225
clean-am: clean-generic mostlyclean-am
248
clean-am: clean-generic mostlyclean-am
226
249
227
distclean: distclean-am
250
distclean: distclean-am
228
251
	-rm -f Makefile
229
distclean-am: clean-am distclean-generic
252
distclean-am: clean-am distclean-generic
230
253
231
dvi: dvi-am
254
dvi: dvi-am
232
255
233
dvi-am:
256
dvi-am:
234
257
258
html: html-am
259
235
info: info-am
260
info: info-am
236
261
237
info-am:
262
info-am:
Lines 247-253 Link Here
247
installcheck-am:
272
installcheck-am:
248
273
249
maintainer-clean: maintainer-clean-am
274
maintainer-clean: maintainer-clean-am
250
275
	-rm -f Makefile
251
maintainer-clean-am: distclean-am maintainer-clean-generic
276
maintainer-clean-am: distclean-am maintainer-clean-generic
252
277
253
mostlyclean: mostlyclean-am
278
mostlyclean: mostlyclean-am
Lines 265-272 Link Here
265
uninstall-am: uninstall-info-am
290
uninstall-am: uninstall-info-am
266
291
267
.PHONY: all all-am check check-am clean clean-generic distclean \
292
.PHONY: all all-am check check-am clean clean-generic distclean \
268
	distclean-generic distdir dvi dvi-am info info-am install \
293
	distclean-generic distdir dvi dvi-am html html-am info info-am \
269
	install-am install-data install-data-am install-exec \
294
	install install-am install-data install-data-am install-exec \
270
	install-exec-am install-info install-info-am install-man \
295
	install-exec-am install-info install-info-am install-man \
271
	install-strip installcheck installcheck-am installdirs \
296
	install-strip installcheck installcheck-am installdirs \
272
	maintainer-clean maintainer-clean-generic mostlyclean \
297
	maintainer-clean maintainer-clean-generic mostlyclean \
(-)valgrind-2.1.0/linux22.supp (+286 lines)
Line 0 Link Here
1
2
##----------------------------------------------------------------------##
3
4
# Errors to suppress by default on a RedHat 6.2 system
5
# (glibc 2.1.3, XFree86 3.3.6)
6
7
# Format of this file is:
8
# {
9
#     name_of_suppression
10
#     tool_name:supp_kind
11
#     (optional extra info for some suppression types)
12
#     caller0 name, or /name/of/so/file.so
13
#     caller1 name, or ditto
14
#     (optionally: caller2 name)
15
#     (optionally: caller3 name)
16
#  }
17
#
18
# For Memcheck, the supp_kinds are:
19
#
20
#     Param Value1 Value2 Value4 Value8 Value16
21
#     Free Addr1 Addr2 Addr4 Addr8 Addr16
22
#     Cond (previously known as Value0)
23
#
24
# and the optional extra info is:
25
#     if Param: name of system call param
26
#     if Free: name of free-ing fn)
27
28
##----------------------------------------------------------------------##
29
30
{
31
   socketcall.connect(serv_addr)/__libc_connect/*(Param)
32
   Addrcheck,Memcheck:Param
33
   socketcall.connect(serv_addr)
34
   fun:__libc_connect
35
   fun:*
36
}
37
38
{
39
   strrchr/_dl_map_object_from_fd/_dl_map_object(Addr4)
40
   Addrcheck,Memcheck:Addr4
41
   fun:strrchr
42
   fun:_dl_map_object_from_fd
43
   fun:_dl_map_object
44
}
45
46
{
47
   strrchr/_dl_map_object_from_fd/_dl_map_object(Value1)
48
   Memcheck:Value1
49
   fun:strrchr
50
   fun:_dl_map_object_from_fd
51
   fun:_dl_map_object
52
}
53
54
{
55
   llseek(result)/__libc_lseek64/_IO_file_seek(Param)
56
   Addrcheck,Memcheck:Param
57
   llseek(result)
58
   fun:__libc_lseek64
59
   fun:_IO_file_seek
60
}
61
62
{
63
   __rawmemchr/_nl_*/*locale(Addr4)
64
   Addrcheck,Memcheck:Addr4
65
   fun:__rawmemchr
66
   fun:_nl_*
67
   fun:*locale
68
}
69
70
# new ones for RH62 ls -l 
71
{
72
   __strchrnul/__nss_database_lookup(Cond)
73
   Memcheck:Cond
74
   fun:__strchrnul
75
   fun:__nss_database_lookup
76
}
77
{
78
   __strchrnul/__gethostbyname_r(Cond)
79
   Memcheck:Cond
80
   fun:__strchrnul
81
   fun:__gethostbyname_r
82
}
83
84
{
85
   strrchr/_dl_map*/_dl_map*(Cond)
86
   Memcheck:Cond
87
   fun:strrchr
88
   fun:_dl_map*
89
   fun:_dl_map*
90
}
91
92
{
93
   strchr/dl_open_worker/_dl_catch_error(Cond)
94
   Memcheck:Cond
95
   fun:strchr
96
   fun:dl_open_worker
97
   fun:_dl_catch_error
98
}
99
100
{
101
   __rawmemchr/???/__getgrgid_r(Cond)
102
   Memcheck:Cond
103
   fun:__rawmemchr
104
   fun:*
105
   fun:__getgrgid_r
106
}
107
108
{
109
   __rawmemchr/_nl_*/*locale*(Cond)
110
   Memcheck:Cond
111
   fun:__rawmemchr
112
   fun:_nl_*
113
   fun:*locale*
114
}
115
116
{
117
   _dl_relocate_object/dl_open_worker(Value0)
118
   Memcheck:Cond
119
   fun:_dl_relocate_object
120
   fun:dl_open_worker
121
}
122
123
##----------------------------------------------------------------------##
124
## from a Debian machine running kernel 2.2.19 I believe
125
## I guess most of these are the same as above really, but
126
## Debian stripped their libc-2.1.3
127
128
{
129
   libc-2.1.3.so/libc-2.1.3.so/libc-2.1.3.so(Cond)
130
   Memcheck:Cond
131
   obj:*libc-2.1.3.so
132
   obj:*libc-2.1.3.so
133
   obj:*libc-2.1.3.so
134
}
135
136
{
137
   strchr/libc-2.1.3.so(Cond)
138
   Memcheck:Cond
139
   fun:*strchr*
140
   obj:*libc-2.1.3.so
141
}
142
143
{
144
   libc-2.1.3.so/libXt.so(Cond)
145
   Memcheck:Cond
146
   obj:*libc-2.1.3.so
147
   obj:*libXt.so*
148
}
149
150
{
151
   socketcall.connect(serv_addr)/__libc_connect/*(Param)
152
   Addrcheck,Memcheck:Param
153
   socketcall.connect(serv_addr)
154
   obj:*libc-2.1.3.so
155
   obj:*libX11.so*
156
}
157
158
159
##----------------------------------------------------------------------##
160
161
{
162
   X11-Cond-0
163
   Memcheck:Cond
164
   obj:*libXt.so.6.0
165
   obj:*libXt.so.6.0
166
   obj:*libXt.so.6.0
167
}
168
{
169
   X11-Cond-1
170
   Memcheck:Cond
171
   fun:__rawmemchr
172
   obj:*libXt.so.6.0
173
   obj:*libXt.so.6.0
174
}
175
176
177
# Suppressions for XFree86-3.3.X
178
179
{
180
   X11-Addr4-1
181
   Addrcheck,Memcheck:Addr4
182
   obj:/usr/X11R6/lib/libX11.so.6.1
183
   obj:/usr/X11R6/lib/libX11.so.6.1
184
   obj:/usr/X11R6/lib/libX11.so.6.1
185
}
186
187
{
188
   X11-Addr4-2
189
   Addrcheck,Memcheck:Addr4
190
   obj:/usr/X11R6/lib/libX11.so.6.1
191
   obj:/usr/X11R6/lib/libX11.so.6.1
192
   obj:/usr/X11R6/lib/libXt.so.6.0
193
}
194
195
{
196
   X11-Addr4-3
197
   Addrcheck,Memcheck:Addr4
198
   obj:/usr/X11R6/lib/libXt.so.6.0
199
   obj:/usr/X11R6/lib/libXt.so.6.0
200
   obj:/usr/X11R6/lib/libXt.so.6.0
201
}
202
203
{
204
   X11-Addr4-4
205
   Addrcheck,Memcheck:Addr4
206
   obj:/usr/X11R6/lib/libX11.so.6.1
207
   obj:/usr/X11R6/lib/libXt.so.6.0
208
   obj:/usr/X11R6/lib/libXt.so.6.0
209
}
210
211
{
212
   X11-Addr4-5
213
   Addrcheck,Memcheck:Addr4
214
   fun:__rawmemchr
215
   obj:/usr/X11R6/lib/libXt.so.6.0
216
   obj:/usr/X11R6/lib/libXt.so.6.0
217
}
218
219
{
220
   X11-Addr4-6
221
   Addrcheck,Memcheck:Addr4
222
   obj:/usr/X11R6/lib/libXmu.so.6.0
223
   obj:/usr/X11R6/lib/libXmu.so.6.0
224
   obj:/usr/X11R6/lib/libXt.so.6.0
225
}
226
227
{
228
   X11-Addr4-7
229
   Addrcheck,Memcheck:Addr4
230
   obj:/usr/X11R6/lib/libXt.so.6.0
231
   obj:/usr/X11R6/lib/libXt.so.6.0
232
   obj:/usr/X11R6/lib/libXawXpm_posing_as_Xaw.so.6.1
233
}
234
235
{
236
   X11-Param-1
237
   Addrcheck,Memcheck:Param
238
   write(buf)
239
   fun:__libc_write
240
   obj:/usr/X11R6/lib/libX11.so.6.1
241
   obj:/usr/X11R6/lib/libX11.so.6.1
242
}
243
244
{
245
   X11-Addr4-8
246
   Addrcheck,Memcheck:Addr4
247
   obj:/usr/X11R6/lib/libX11.so.6.1
248
   obj:/usr/X11R6/lib/libXpm.so.4.11
249
   obj:/usr/X11R6/lib/libXpm.so.4.11
250
}
251
252
{
253
   X11-Addr4-8
254
   Addrcheck,Memcheck:Addr4
255
   obj:/usr/X11R6/lib/libXt.so.6.0
256
   obj:/usr/X11R6/lib/libXawXpm_posing_as_Xaw.so.6.1
257
   obj:/usr/X11R6/lib/libXt.so.6.0
258
}
259
260
{
261
   X11-Addr4-9
262
   Addrcheck,Memcheck:Addr4
263
   obj:/usr/X11R6/lib/libXaw.so.6.1
264
   obj:/usr/X11R6/lib/libXt.so.6.0
265
   obj:/usr/X11R6/lib/libXt.so.6.0
266
}
267
268
{
269
   X11-Addr4-10
270
   Addrcheck,Memcheck:Addr4
271
   obj:/usr/X11R6/lib/libXaw.so.6.1
272
   obj:/usr/X11R6/lib/libXaw.so.6.1
273
   obj:/usr/X11R6/lib/libXt.so.6.0
274
}
275
276
{
277
   X11-Addr4-11
278
   Addrcheck,Memcheck:Addr4
279
   obj:/usr/X11R6/lib/libXt.so.6.0
280
   obj:/usr/X11R6/lib/libXt.so.6.0
281
   obj:/usr/X11R6/lib/libXaw.so.6.1
282
}
283
284
285
286
##----------------------------------------------------------------------##
(-)valgrind-2.1.0/linux24.supp (+304 lines)
Line 0 Link Here
1
2
##----------------------------------------------------------------------##
3
4
# Errors to suppress by default on a Linux kernel 2.4 system
5
# (glibc 2.2.4, XFree86 4.1.0)
6
7
# Format of this file is:
8
# {
9
#     name_of_suppression
10
#     tool_name:supp_kind
11
#     (optional extra info for some suppression types)
12
#     caller0 name, or /name/of/so/file.so
13
#     caller1 name, or ditto
14
#     (optionally: caller2 name)
15
#     (optionally: caller3 name)
16
#  }
17
#
18
# For memcheck, the supp_kinds are:
19
#
20
#     Param Value1 Value2 Value4 Value8 Value16
21
#     Free Addr1 Addr2 Addr4 Addr8 Addr16
22
#     Cond (previously known as Value0)
23
#
24
# and the optional extra info is:
25
#     if Param: name of system call param
26
#     if Free: name of free-ing fn)
27
28
# even more glibc suppressions ?
29
{
30
   libc-2.2.4.so/libc-2.2.4.so/libc-2.2.4.so(Cond)
31
   memcheck:Cond
32
   obj:*libc-2.2.4.so
33
   obj:*libc-2.2.4.so
34
   obj:*libc-2.2.4.so
35
}
36
{
37
   libc-2.2.4.so/libc-2.2.4.so/libc-2.2.4.so(Value4)
38
   memcheck:Value4
39
   obj:*libc-2.2.4.so
40
   obj:*libc-2.2.4.so
41
   obj:*libc-2.2.4.so
42
}
43
44
##### glibc 2.2.5 stuff perhaps?
45
##### suppressions for coolo
46
{
47
   strchr/dl_open_worker(Cond)
48
   Memcheck:Cond
49
   fun:strchr
50
   fun:dl_open_worker
51
}
52
{ 
53
   __rawmemchr/internal_getgrgid_r(Cond)
54
   Memcheck:Cond 
55
   fun:__rawmemchr
56
   fun:internal_getgrgid_r
57
} 
58
{ 
59
   _IO_vfprintf/__strnlen(Cond)
60
   Memcheck:Cond 
61
   fun:__strnlen
62
   fun:_IO_vfprintf
63
} 
64
{ 
65
   __strchrnul/gethostbyname*(Cond)
66
   Memcheck:Cond 
67
   fun:__strchrnul
68
   fun:gethostbyname*
69
} 
70
71
72
##----
73
{
74
   strlen/*dl_map_object*(Cond)
75
   Memcheck:Cond
76
   fun:strlen
77
   fun:*dl_map_object*
78
}
79
80
{
81
   strlen/*dl_open_worker*(Cond)
82
   Memcheck:Cond
83
   fun:strlen
84
   fun:*dl_open_worker*
85
}
86
87
{
88
   *rawmemchr*/*nss*(Cond)
89
   Memcheck:Cond
90
   fun:*rawmemchr*
91
   fun:*nss*
92
}
93
94
{
95
   *strchrnul*/*nss*(Cond)
96
   Memcheck:Cond
97
   fun:*strchrnul*
98
   fun:*nss*
99
}
100
101
102
103
# gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)
104
# on Red Hat 7.2 (x86) miscompiles __mpn_construct_double in
105
# __mpn_construct_double (../sysdeps/ieee754/dbl-64/mpn2dbl.c:45)
106
# (glibc-2.2.4) to read and write below %esp.  Hence the following
107
# two:
108
{
109
   __mpn_construct_double/*(Addr4)
110
   Addrcheck,Memcheck:Addr4
111
   fun:__mpn_construct_double
112
   fun:*
113
}
114
{
115
   __mpn_construct_double/*(Addr8)
116
   Addrcheck,Memcheck:Addr8
117
   fun:__mpn_construct_double
118
   fun:*
119
}
120
121
# More of the same (gcc bug, I'm pretty sure)
122
{
123
   __fabs/*(Addr4)
124
   Addrcheck,Memcheck:Addr4
125
   fun:__fabs
126
   fun:*
127
}
128
{
129
   __fabs/*(Addr8)
130
   Addrcheck,Memcheck:Addr8
131
   fun:__fabs
132
   fun:*
133
}
134
135
136
# Not sure what this is about ... but anyway
137
{
138
   pthread_sighandler/*(Addr4)
139
   Addrcheck,Memcheck:Addr4
140
   fun:pthread_sighandler
141
   fun:*
142
}
143
144
145
# More glibc stuff, AFAICS
146
147
{
148
   __strnlen/__argz_stringify/_nl_make_l10nflist(Cond)
149
   Memcheck:Cond
150
   fun:__strnlen
151
   fun:__argz_stringify
152
   fun:_nl_make_l10nflist
153
}
154
155
#--------------
156
{
157
   _dl_relocate_object/dl_open_worker/_dl_catch_error(Cond)
158
   Memcheck:Cond
159
   fun:_dl_relocate_object
160
   fun:dl_open_worker
161
   fun:_dl_catch_error
162
}
163
{
164
   _dl_relocate_object/libc-2.2.4.so/_dl_catch_error(Cond)
165
   Memcheck:Cond
166
   fun:_dl_relocate_object
167
   obj:*libc-2.2.4.so
168
   fun:_dl_catch_error
169
}
170
171
{
172
   strrchr/_dl_map_object_from_fd/_dl_map_object(Cond)
173
   Memcheck:Cond
174
   fun:strrchr
175
   fun:_dl_map_object_from_fd
176
   fun:_dl_map_object
177
}
178
179
#-------------------
180
{
181
   socketcall.connect(serv_addr)/__libc_connect/*
182
   Addrcheck,Memcheck:Param
183
   socketcall.connect(serv_addr)
184
   fun:__libc_connect
185
   fun:*
186
}
187
{
188
   socketcall.connect(serv_addr)/libc-2.2.4.so/libc-2.2.4.so
189
   Addrcheck,Memcheck:Param
190
   socketcall.connect(serv_addr)
191
   obj:*libc-2.2.4.so
192
   obj:*libc-2.2.4.so
193
}
194
195
{
196
   libX11.so.6.2/libX11.so.6.2/libX11.so.6.2(Cond)
197
   Memcheck:Cond
198
   obj:/usr/X11R6/lib/libX11.so.6.2
199
   obj:/usr/X11R6/lib/libX11.so.6.2
200
   obj:/usr/X11R6/lib/libX11.so.6.2
201
}
202
203
{
204
   libXt.so.6.2/libXt.so.6.2/libXt.so.6.2(Cond)
205
   Memcheck:Cond
206
   obj:/usr/X11R6/lib/libXt.so.6.0
207
   obj:/usr/X11R6/lib/libXt.so.6.0
208
   obj:/usr/X11R6/lib/libXt.so.6.0
209
}
210
211
212
{
213
   libXaw.so.7.0/libXaw.so.7.0/libXaw.so.7.0(Cond)
214
   Memcheck:Cond
215
   obj:/usr/X11R6/lib/libXaw.so.7.0
216
   obj:/usr/X11R6/lib/libXaw.so.7.0
217
   obj:/usr/X11R6/lib/libXaw.so.7.0
218
}
219
220
{
221
   libXmu.so.6.2/libXmu.so.6.2/libXmu.so.6.2(Cond)
222
   Memcheck:Cond
223
   obj:/usr/X11R6/lib/libXmu.so.6.2
224
   obj:/usr/X11R6/lib/libXmu.so.6.2
225
   obj:/usr/X11R6/lib/libXmu.so.6.2
226
}
227
228
{
229
   libXt.so.6.0/libXt.so.6.0/libXaw.so.7.0(Cond)
230
   Memcheck:Cond
231
   obj:/usr/X11R6/lib/libXt.so.6.0
232
   obj:/usr/X11R6/lib/libXt.so.6.0
233
   obj:/usr/X11R6/lib/libXaw.so.7.0
234
}
235
236
{
237
   libXaw.so.7.0/libXaw.so.7.0/libXt.so.6.0(Value4)
238
   Memcheck:Value4
239
   obj:/usr/X11R6/lib/libXaw.so.7.0
240
   obj:/usr/X11R6/lib/libXaw.so.7.0
241
   obj:/usr/X11R6/lib/libXt.so.6.0
242
}
243
244
{
245
   libX11.so.6.2/libX11.so.6.2/libXaw.so.7.0(Cond)
246
   Memcheck:Cond
247
   obj:/usr/X11R6/lib/libX11.so.6.2
248
   obj:/usr/X11R6/lib/libX11.so.6.2
249
   obj:/usr/X11R6/lib/libXaw.so.7.0
250
}
251
252
#----------------------
253
{
254
   write(buf)/__libc_write/libX11.so.6.2/libX11.so.6.2(Param)
255
   Addrcheck,Memcheck:Param
256
   write(buf)
257
   fun:__libc_write
258
   obj:/usr/X11R6/lib/libX11.so.6.2
259
   obj:/usr/X11R6/lib/libX11.so.6.2
260
}
261
{
262
   write(buf)/libc-2.2.4.so/libX11.so.6.2/libX11.so.6.2(Param)
263
   Addrcheck,Memcheck:Param
264
   write(buf)
265
   obj:*libc-2.2.4.so
266
   obj:/usr/X11R6/lib/libX11.so.6.2
267
   obj:/usr/X11R6/lib/libX11.so.6.2
268
}
269
270
#{
271
#   llseek(result)/__libc_lseek64/_IO_file_seek(Param)
272
#   Addrcheck,Memcheck:Param
273
#   llseek(result)
274
#   fun:__libc_lseek64
275
#   fun:_IO_file_seek
276
#}
277
278
{
279
   writev(vector[...])/__writev/libX11.so.6.2/libX11.so.6.2
280
   Addrcheck,Memcheck:Param
281
   writev(vector[...])
282
   fun:__writev
283
   obj:/usr/X11R6/lib/libX11.so.6.2
284
   obj:/usr/X11R6/lib/libX11.so.6.2
285
}
286
287
#----------------
288
{
289
   __rawmemchr/libXt.so.6.0/libXt.so.6.0
290
   Memcheck:Cond
291
   fun:__rawmemchr
292
   obj:/usr/X11R6/lib/libXt.so.6.0
293
   obj:/usr/X11R6/lib/libXt.so.6.0
294
}
295
{
296
   libc-2.2.4.so/libXt.so.6.0/libXt.so.6.0
297
   Memcheck:Cond
298
   obj:*libc-2.2.4.so
299
   obj:/usr/X11R6/lib/libXt.so.6.0
300
   obj:/usr/X11R6/lib/libXt.so.6.0
301
}
302
303
##----------------------------------------------------------------------##
304
(-)valgrind-2.1.0/make-uninstall-docs (+21 lines)
Line 0 Link Here
1
#!/bin/sh
2
3
# small tool to help documentation writers.
4
# Copy docs out of an installation tree (`pwd`/Inst) back to the build tree
5
# since it is a lot easier to edit them in the installation tree.
6
# Use with care!
7
8
cp  Inst/share/doc/valgrind/coregrind_core.html   coregrind/docs
9
cp  Inst/share/doc/valgrind/coregrind_intro.html  coregrind/docs
10
cp  Inst/share/doc/valgrind/coregrind_tools.html  coregrind/docs
11
cp  Inst/share/doc/valgrind/manual.html           docs
12
cp  Inst/share/doc/valgrind/ac_main.html          addrcheck/docs
13
cp  Inst/share/doc/valgrind/mc_main.html          memcheck/docs
14
cp  Inst/share/doc/valgrind/mc_techdocs.html      memcheck/docs
15
cp  Inst/share/doc/valgrind/cg_main.html          cachegrind/docs
16
cp  Inst/share/doc/valgrind/cg_techdocs.html      cachegrind/docs
17
cp  Inst/share/doc/valgrind/cc_main.html          corecheck/docs
18
cp  Inst/share/doc/valgrind/hg_main.html          helgrind/docs
19
cp  Inst/share/doc/valgrind/lk_main.html          lackey/docs
20
cp  Inst/share/doc/valgrind/nl_main.html          none/docs
21
(-)valgrind-2.1.0/memcheck/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/memcheck/CVS/Entries (+17 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Mon Sep 23 11:36:34 2002//
2
/Makefile.am/1.47/Tue Dec 16 02:05:14 2003//
3
/mac_leakcheck.c/1.13/Sun Jan  4 16:43:22 2004//
4
/mac_malloc_wrappers.c/1.10/Wed Jan 21 15:08:04 2004//
5
/mac_needs.c/1.22/Sun Jan  4 23:30:55 2004//
6
/mac_replace_strmem.c/1.12/Sun Jan  4 16:43:22 2004//
7
/mac_shared.h/1.17/Wed Jan 21 15:08:04 2004//
8
/mc_clientreqs.c/1.18/Sun Jan  4 16:43:22 2004//
9
/mc_constants.h/1.4/Sun Jan  4 16:43:22 2004//
10
/mc_errcontext.c/1.22/Sun Jan  4 16:43:22 2004//
11
/mc_from_ucode.c/1.15/Sun Jan  4 16:43:22 2004//
12
/mc_helpers.S/1.8/Sun Jan  4 16:43:22 2004//
13
/mc_include.h/1.18/Sun Jan  4 16:43:22 2004//
14
/mc_main.c/1.46/Sun Jan  4 23:30:55 2004//
15
/mc_translate.c/1.36/Wed Feb 11 23:33:28 2004//
16
/memcheck.h/1.18/Wed Jan 21 15:08:04 2004//
17
D
(-)valgrind-2.1.0/memcheck/CVS/Entries.Log (+2 lines)
Line 0 Link Here
1
A D/docs////
2
A D/tests////
(-)valgrind-2.1.0/memcheck/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/memcheck
(-)valgrind-2.1.0/memcheck/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/memcheck/Makefile.am (-4 / +13 lines)
Lines 4-22 Link Here
4
all_includes = -I$(top_srcdir)/include
4
all_includes = -I$(top_srcdir)/include
5
5
6
AM_CPPFLAGS = $(all_includes) -DVG_LIBDIR="\"$(libdir)"\"
6
AM_CPPFLAGS = $(all_includes) -DVG_LIBDIR="\"$(libdir)"\"
7
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer \
7
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O2 -fomit-frame-pointer \
8
		@PREFERRED_STACK_BOUNDARY@ -g
8
		@PREFERRED_STACK_BOUNDARY@ -g
9
AM_CCASFLAGS = $(all_includes)
9
AM_CCASFLAGS = $(all_includes)
10
10
11
valdir = $(libdir)/valgrind
11
valdir = $(libdir)/valgrind
12
inplacedir = $(top_srcdir)/.in_place
12
13
13
val_PROGRAMS = vgskin_memcheck.so
14
val_PROGRAMS = vgskin_memcheck.so vgpreload_memcheck.so
15
16
vgpreload_memcheck_so_SOURCES = \
17
	mac_replace_strmem.c
18
vgpreload_memcheck_so_LDADD = $(top_srcdir)/coregrind/vg_replace_malloc.o
19
vgpreload_memcheck_so_DEPENDENCIES = $(top_srcdir)/coregrind/vg_replace_malloc.o
20
vgpreload_memcheck_so_LDFLAGS = -shared -Wl,-z,interpose,-z,initfirst
14
21
15
vgskin_memcheck_so_SOURCES = \
22
vgskin_memcheck_so_SOURCES = \
16
	mac_leakcheck.c \
23
	mac_leakcheck.c \
17
	mac_malloc_wrappers.c \
24
	mac_malloc_wrappers.c \
18
	mac_needs.c \
25
	mac_needs.c \
19
	mac_replace_strmem.c \
20
	mc_main.c \
26
	mc_main.c \
21
	mc_clientreqs.c \
27
	mc_clientreqs.c \
22
	mc_errcontext.c \
28
	mc_errcontext.c \
Lines 24-30 Link Here
24
	mc_translate.c \
30
	mc_translate.c \
25
	mc_helpers.S
31
	mc_helpers.S
26
vgskin_memcheck_so_LDFLAGS = -shared
32
vgskin_memcheck_so_LDFLAGS = -shared
27
vgskin_memcheck_so_LDADD = ../coregrind/vg_replace_malloc.o
28
33
29
mcincludedir = $(includedir)/valgrind
34
mcincludedir = $(includedir)/valgrind
30
35
Lines 38-40 Link Here
38
43
39
mac_replace_strmem.o: CFLAGS += -fno-omit-frame-pointer
44
mac_replace_strmem.o: CFLAGS += -fno-omit-frame-pointer
40
45
46
all-local:
47
	mkdir -p $(inplacedir)
48
	-rm -f $(addprefix $(inplacedir)/,$(val_PROGRAMS))
49
	ln -f -s $(addprefix $(top_srcdir)/$(subdir)/,$(val_PROGRAMS)) $(inplacedir)
(-)valgrind-2.1.0/memcheck/Makefile.in (-132 / +149 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 14-19 Link Here
14
14
15
@SET_MAKE@
15
@SET_MAKE@
16
16
17
18
SOURCES = $(vgpreload_memcheck_so_SOURCES) $(vgskin_memcheck_so_SOURCES)
19
17
srcdir = @srcdir@
20
srcdir = @srcdir@
18
top_srcdir = @top_srcdir@
21
top_srcdir = @top_srcdir@
19
VPATH = @srcdir@
22
VPATH = @srcdir@
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
24
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
25
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ..
26
top_builddir = ..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
27
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
28
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
29
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
38
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
39
POST_UNINSTALL = :
38
host_triplet = @host@
40
host_triplet = @host@
41
val_PROGRAMS = vgskin_memcheck.so$(EXEEXT) \
42
	vgpreload_memcheck.so$(EXEEXT)
43
subdir = memcheck
44
DIST_COMMON = $(mcinclude_HEADERS) $(noinst_HEADERS) \
45
	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
46
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
47
am__aclocal_m4_deps = $(top_srcdir)/configure.in
48
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
49
	$(ACLOCAL_M4)
50
mkinstalldirs = $(mkdir_p)
51
CONFIG_HEADER = $(top_builddir)/config.h
52
CONFIG_CLEAN_FILES =
53
am__installdirs = $(DESTDIR)$(valdir) $(DESTDIR)$(mcincludedir)
54
valPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
55
PROGRAMS = $(val_PROGRAMS)
56
am_vgpreload_memcheck_so_OBJECTS = mac_replace_strmem.$(OBJEXT)
57
vgpreload_memcheck_so_OBJECTS = $(am_vgpreload_memcheck_so_OBJECTS)
58
am_vgskin_memcheck_so_OBJECTS = mac_leakcheck.$(OBJEXT) \
59
	mac_malloc_wrappers.$(OBJEXT) mac_needs.$(OBJEXT) \
60
	mc_main.$(OBJEXT) mc_clientreqs.$(OBJEXT) \
61
	mc_errcontext.$(OBJEXT) mc_from_ucode.$(OBJEXT) \
62
	mc_translate.$(OBJEXT) mc_helpers.$(OBJEXT)
63
vgskin_memcheck_so_OBJECTS = $(am_vgskin_memcheck_so_OBJECTS)
64
vgskin_memcheck_so_LDADD = $(LDADD)
65
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
66
depcomp = $(SHELL) $(top_srcdir)/depcomp
67
am__depfiles_maybe = depfiles
68
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/mac_leakcheck.Po \
69
@AMDEP_TRUE@	./$(DEPDIR)/mac_malloc_wrappers.Po \
70
@AMDEP_TRUE@	./$(DEPDIR)/mac_needs.Po \
71
@AMDEP_TRUE@	./$(DEPDIR)/mac_replace_strmem.Po \
72
@AMDEP_TRUE@	./$(DEPDIR)/mc_clientreqs.Po \
73
@AMDEP_TRUE@	./$(DEPDIR)/mc_errcontext.Po \
74
@AMDEP_TRUE@	./$(DEPDIR)/mc_from_ucode.Po \
75
@AMDEP_TRUE@	./$(DEPDIR)/mc_main.Po ./$(DEPDIR)/mc_translate.Po
76
CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
77
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
78
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
79
CCLD = $(CC)
80
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
81
SOURCES = $(vgpreload_memcheck_so_SOURCES) \
82
	$(vgskin_memcheck_so_SOURCES)
83
DIST_SOURCES = $(vgpreload_memcheck_so_SOURCES) \
84
	$(vgskin_memcheck_so_SOURCES)
85
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
86
	html-recursive info-recursive install-data-recursive \
87
	install-exec-recursive install-info-recursive \
88
	install-recursive installcheck-recursive installdirs-recursive \
89
	pdf-recursive ps-recursive uninstall-info-recursive \
90
	uninstall-recursive
91
mcincludeHEADERS_INSTALL = $(INSTALL_HEADER)
92
HEADERS = $(mcinclude_HEADERS) $(noinst_HEADERS)
93
ETAGS = etags
94
CTAGS = ctags
95
DIST_SUBDIRS = $(SUBDIRS)
96
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
97
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
98
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
99
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
150
SHELL = @SHELL@
93
STRIP = @STRIP@
151
STRIP = @STRIP@
94
VERSION = @VERSION@
152
VERSION = @VERSION@
153
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
154
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
155
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
156
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
182
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
183
localstatedir = @localstatedir@
125
mandir = @mandir@
184
mandir = @mandir@
185
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
186
oldincludedir = @oldincludedir@
127
prefix = @prefix@
187
prefix = @prefix@
128
program_transform_name = @program_transform_name@
188
program_transform_name = @program_transform_name@
Lines 130-155 Link Here
130
sharedstatedir = @sharedstatedir@
190
sharedstatedir = @sharedstatedir@
131
sysconfdir = @sysconfdir@
191
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
192
target_alias = @target_alias@
133
134
SUBDIRS = . tests docs
193
SUBDIRS = . tests docs
135
136
all_includes = -I$(top_srcdir)/include
194
all_includes = -I$(top_srcdir)/include
137
138
AM_CPPFLAGS = $(all_includes) -DVG_LIBDIR="\"$(libdir)"\"
195
AM_CPPFLAGS = $(all_includes) -DVG_LIBDIR="\"$(libdir)"\"
139
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer \
196
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O2 -fomit-frame-pointer \
140
		@PREFERRED_STACK_BOUNDARY@ -g
197
		@PREFERRED_STACK_BOUNDARY@ -g
141
198
142
AM_CCASFLAGS = $(all_includes)
199
AM_CCASFLAGS = $(all_includes)
143
144
valdir = $(libdir)/valgrind
200
valdir = $(libdir)/valgrind
145
201
inplacedir = $(top_srcdir)/.in_place
146
val_PROGRAMS = vgskin_memcheck.so
202
vgpreload_memcheck_so_SOURCES = \
147
203
	mac_replace_strmem.c
204
205
vgpreload_memcheck_so_LDADD = $(top_srcdir)/coregrind/vg_replace_malloc.o
206
vgpreload_memcheck_so_DEPENDENCIES = $(top_srcdir)/coregrind/vg_replace_malloc.o
207
vgpreload_memcheck_so_LDFLAGS = -shared -Wl,-z,interpose,-z,initfirst
148
vgskin_memcheck_so_SOURCES = \
208
vgskin_memcheck_so_SOURCES = \
149
	mac_leakcheck.c \
209
	mac_leakcheck.c \
150
	mac_malloc_wrappers.c \
210
	mac_malloc_wrappers.c \
151
	mac_needs.c \
211
	mac_needs.c \
152
	mac_replace_strmem.c \
153
	mc_main.c \
212
	mc_main.c \
154
	mc_clientreqs.c \
213
	mc_clientreqs.c \
155
	mc_errcontext.c \
214
	mc_errcontext.c \
Lines 158-236 Link Here
158
	mc_helpers.S
217
	mc_helpers.S
159
218
160
vgskin_memcheck_so_LDFLAGS = -shared
219
vgskin_memcheck_so_LDFLAGS = -shared
161
vgskin_memcheck_so_LDADD = ../coregrind/vg_replace_malloc.o
162
163
mcincludedir = $(includedir)/valgrind
220
mcincludedir = $(includedir)/valgrind
164
165
mcinclude_HEADERS = \
221
mcinclude_HEADERS = \
166
	memcheck.h
222
	memcheck.h
167
223
168
169
noinst_HEADERS = \
224
noinst_HEADERS = \
170
	mac_shared.h	\
225
	mac_shared.h	\
171
	mc_constants.h	\
226
	mc_constants.h	\
172
	mc_include.h
227
	mc_include.h
173
228
174
subdir = memcheck
175
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
176
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
177
CONFIG_HEADER = $(top_builddir)/config.h
178
CONFIG_CLEAN_FILES =
179
val_PROGRAMS = vgskin_memcheck.so$(EXEEXT)
180
PROGRAMS = $(val_PROGRAMS)
181
182
am_vgskin_memcheck_so_OBJECTS = mac_leakcheck.$(OBJEXT) \
183
	mac_malloc_wrappers.$(OBJEXT) mac_needs.$(OBJEXT) \
184
	mac_replace_strmem.$(OBJEXT) mc_main.$(OBJEXT) \
185
	mc_clientreqs.$(OBJEXT) mc_errcontext.$(OBJEXT) \
186
	mc_from_ucode.$(OBJEXT) mc_translate.$(OBJEXT) \
187
	mc_helpers.$(OBJEXT)
188
vgskin_memcheck_so_OBJECTS = $(am_vgskin_memcheck_so_OBJECTS)
189
vgskin_memcheck_so_DEPENDENCIES = ../coregrind/vg_replace_malloc.o
190
191
DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
192
depcomp = $(SHELL) $(top_srcdir)/depcomp
193
am__depfiles_maybe = depfiles
194
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/mac_leakcheck.Po \
195
@AMDEP_TRUE@	./$(DEPDIR)/mac_malloc_wrappers.Po \
196
@AMDEP_TRUE@	./$(DEPDIR)/mac_needs.Po \
197
@AMDEP_TRUE@	./$(DEPDIR)/mac_replace_strmem.Po \
198
@AMDEP_TRUE@	./$(DEPDIR)/mc_clientreqs.Po \
199
@AMDEP_TRUE@	./$(DEPDIR)/mc_errcontext.Po \
200
@AMDEP_TRUE@	./$(DEPDIR)/mc_from_ucode.Po ./$(DEPDIR)/mc_main.Po \
201
@AMDEP_TRUE@	./$(DEPDIR)/mc_translate.Po
202
CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
203
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
204
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
205
CCLD = $(CC)
206
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
207
DIST_SOURCES = $(vgskin_memcheck_so_SOURCES)
208
HEADERS = $(mcinclude_HEADERS) $(noinst_HEADERS)
209
210
211
RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
212
	ps-recursive install-info-recursive uninstall-info-recursive \
213
	all-recursive install-data-recursive install-exec-recursive \
214
	installdirs-recursive install-recursive uninstall-recursive \
215
	check-recursive installcheck-recursive
216
DIST_COMMON = $(mcinclude_HEADERS) $(noinst_HEADERS) Makefile.am \
217
	Makefile.in
218
DIST_SUBDIRS = $(SUBDIRS)
219
SOURCES = $(vgskin_memcheck_so_SOURCES)
220
221
all: all-recursive
229
all: all-recursive
222
230
223
.SUFFIXES:
231
.SUFFIXES:
224
.SUFFIXES: .S .c .o .obj
232
.SUFFIXES: .S .c .o .obj
225
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
233
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
234
	@for dep in $?; do \
235
	  case '$(am__configure_deps)' in \
236
	    *$$dep*) \
237
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
238
		&& exit 0; \
239
	      exit 1;; \
240
	  esac; \
241
	done; \
242
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  memcheck/Makefile'; \
226
	cd $(top_srcdir) && \
243
	cd $(top_srcdir) && \
227
	  $(AUTOMAKE) --gnu  memcheck/Makefile
244
	  $(AUTOMAKE) --gnu  memcheck/Makefile
228
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
245
.PRECIOUS: Makefile
229
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
246
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
230
valPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
247
	@case '$?' in \
248
	  *config.status*) \
249
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
250
	  *) \
251
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
252
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
253
	esac;
254
255
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
256
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
257
258
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
259
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
260
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
261
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
231
install-valPROGRAMS: $(val_PROGRAMS)
262
install-valPROGRAMS: $(val_PROGRAMS)
232
	@$(NORMAL_INSTALL)
263
	@$(NORMAL_INSTALL)
233
	$(mkinstalldirs) $(DESTDIR)$(valdir)
264
	$(mkdir_p) $(DESTDIR)$(valdir)
234
	@list='$(val_PROGRAMS)'; for p in $$list; do \
265
	@list='$(val_PROGRAMS)'; for p in $$list; do \
235
	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
266
	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
236
	  if test -f $$p \
267
	  if test -f $$p \
Lines 251-262 Link Here
251
282
252
clean-valPROGRAMS:
283
clean-valPROGRAMS:
253
	-test -z "$(val_PROGRAMS)" || rm -f $(val_PROGRAMS)
284
	-test -z "$(val_PROGRAMS)" || rm -f $(val_PROGRAMS)
285
vgpreload_memcheck.so$(EXEEXT): $(vgpreload_memcheck_so_OBJECTS) $(vgpreload_memcheck_so_DEPENDENCIES) 
286
	@rm -f vgpreload_memcheck.so$(EXEEXT)
287
	$(LINK) $(vgpreload_memcheck_so_LDFLAGS) $(vgpreload_memcheck_so_OBJECTS) $(vgpreload_memcheck_so_LDADD) $(LIBS)
254
vgskin_memcheck.so$(EXEEXT): $(vgskin_memcheck_so_OBJECTS) $(vgskin_memcheck_so_DEPENDENCIES) 
288
vgskin_memcheck.so$(EXEEXT): $(vgskin_memcheck_so_OBJECTS) $(vgskin_memcheck_so_DEPENDENCIES) 
255
	@rm -f vgskin_memcheck.so$(EXEEXT)
289
	@rm -f vgskin_memcheck.so$(EXEEXT)
256
	$(LINK) $(vgskin_memcheck_so_LDFLAGS) $(vgskin_memcheck_so_OBJECTS) $(vgskin_memcheck_so_LDADD) $(LIBS)
290
	$(LINK) $(vgskin_memcheck_so_LDFLAGS) $(vgskin_memcheck_so_OBJECTS) $(vgskin_memcheck_so_LDADD) $(LIBS)
257
291
258
mostlyclean-compile:
292
mostlyclean-compile:
259
	-rm -f *.$(OBJEXT) core *.core
293
	-rm -f *.$(OBJEXT)
260
294
261
distclean-compile:
295
distclean-compile:
262
	-rm -f *.tab.c
296
	-rm -f *.tab.c
Lines 271-311 Link Here
271
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mc_main.Po@am__quote@
305
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mc_main.Po@am__quote@
272
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mc_translate.Po@am__quote@
306
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mc_translate.Po@am__quote@
273
307
274
distclean-depend:
275
	-rm -rf ./$(DEPDIR)
276
277
.S.o:
308
.S.o:
278
	$(CCASCOMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
309
	$(CCASCOMPILE) -c $<
279
310
280
.S.obj:
311
.S.obj:
281
	$(CCASCOMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
312
	$(CCASCOMPILE) -c `$(CYGPATH_W) '$<'`
282
313
283
.c.o:
314
.c.o:
284
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
315
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
285
@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
316
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
286
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
287
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
288
@am__fastdepCC_TRUE@	fi
289
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
317
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
290
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
318
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
291
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
319
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
292
@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
320
@am__fastdepCC_FALSE@	$(COMPILE) -c $<
293
321
294
.c.obj:
322
.c.obj:
295
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
323
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
296
@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
324
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
297
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
298
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
299
@am__fastdepCC_TRUE@	fi
300
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
325
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
301
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
326
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
302
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
327
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
303
@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
328
@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
304
uninstall-info-am:
329
uninstall-info-am:
305
mcincludeHEADERS_INSTALL = $(INSTALL_HEADER)
306
install-mcincludeHEADERS: $(mcinclude_HEADERS)
330
install-mcincludeHEADERS: $(mcinclude_HEADERS)
307
	@$(NORMAL_INSTALL)
331
	@$(NORMAL_INSTALL)
308
	$(mkinstalldirs) $(DESTDIR)$(mcincludedir)
332
	$(mkdir_p) $(DESTDIR)$(mcincludedir)
309
	@list='$(mcinclude_HEADERS)'; for p in $$list; do \
333
	@list='$(mcinclude_HEADERS)'; for p in $$list; do \
310
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
334
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
311
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
335
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
Lines 380-393 Link Here
380
	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
404
	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
381
	done
405
	done
382
406
383
ETAGS = etags
384
ETAGSFLAGS =
385
386
CTAGS = ctags
387
CTAGSFLAGS =
388
389
tags: TAGS
390
391
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
407
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
392
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
408
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
393
	unique=`for i in $$list; do \
409
	unique=`for i in $$list; do \
Lines 396-401 Link Here
396
	  $(AWK) '    { files[$$0] = 1; } \
412
	  $(AWK) '    { files[$$0] = 1; } \
397
	       END { for (i in files) print i; }'`; \
413
	       END { for (i in files) print i; }'`; \
398
	mkid -fID $$unique
414
	mkid -fID $$unique
415
tags: TAGS
399
416
400
TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
417
TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
401
		$(TAGS_FILES) $(LISP)
418
		$(TAGS_FILES) $(LISP)
Lines 421-427 Link Here
421
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
438
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
422
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
439
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
423
	     $$tags $$unique
440
	     $$tags $$unique
424
425
ctags: CTAGS
441
ctags: CTAGS
426
CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
442
CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
427
		$(TAGS_FILES) $(LISP)
443
		$(TAGS_FILES) $(LISP)
Lines 444-453 Link Here
444
460
445
distclean-tags:
461
distclean-tags:
446
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
462
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
447
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
448
449
top_distdir = ..
450
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
451
463
452
distdir: $(DISTFILES)
464
distdir: $(DISTFILES)
453
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
465
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 461-467 Link Here
461
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
473
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
462
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
474
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
463
	    dir="/$$dir"; \
475
	    dir="/$$dir"; \
464
	    $(mkinstalldirs) "$(distdir)$$dir"; \
476
	    $(mkdir_p) "$(distdir)$$dir"; \
465
	  else \
477
	  else \
466
	    dir=''; \
478
	    dir=''; \
467
	  fi; \
479
	  fi; \
Lines 478-501 Link Here
478
	done
490
	done
479
	list='$(SUBDIRS)'; for subdir in $$list; do \
491
	list='$(SUBDIRS)'; for subdir in $$list; do \
480
	  if test "$$subdir" = .; then :; else \
492
	  if test "$$subdir" = .; then :; else \
481
	    test -d $(distdir)/$$subdir \
493
	    test -d "$(distdir)/$$subdir" \
482
	    || mkdir $(distdir)/$$subdir \
494
	    || mkdir "$(distdir)/$$subdir" \
483
	    || exit 1; \
495
	    || exit 1; \
484
	    (cd $$subdir && \
496
	    (cd $$subdir && \
485
	      $(MAKE) $(AM_MAKEFLAGS) \
497
	      $(MAKE) $(AM_MAKEFLAGS) \
486
	        top_distdir="$(top_distdir)" \
498
	        top_distdir="../$(top_distdir)" \
487
	        distdir=../$(distdir)/$$subdir \
499
	        distdir="../$(distdir)/$$subdir" \
488
	        distdir) \
500
	        distdir) \
489
	      || exit 1; \
501
	      || exit 1; \
490
	  fi; \
502
	  fi; \
491
	done
503
	done
492
check-am: all-am
504
check-am: all-am
493
check: check-recursive
505
check: check-recursive
494
all-am: Makefile $(PROGRAMS) $(HEADERS)
506
all-am: Makefile $(PROGRAMS) $(HEADERS) all-local
495
installdirs: installdirs-recursive
507
installdirs: installdirs-recursive
496
installdirs-am:
508
installdirs-am:
497
	$(mkinstalldirs) $(DESTDIR)$(valdir) $(DESTDIR)$(mcincludedir)
509
	$(mkdir_p) $(DESTDIR)$(valdir) $(DESTDIR)$(mcincludedir)
498
499
install: install-recursive
510
install: install-recursive
500
install-exec: install-exec-recursive
511
install-exec: install-exec-recursive
501
install-data: install-data-recursive
512
install-data: install-data-recursive
Lines 507-513 Link Here
507
installcheck: installcheck-recursive
518
installcheck: installcheck-recursive
508
install-strip:
519
install-strip:
509
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
520
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
510
	  INSTALL_STRIP_FLAG=-s \
521
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
511
	  `test -z '$(STRIP)' || \
522
	  `test -z '$(STRIP)' || \
512
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
523
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
513
mostlyclean-generic:
524
mostlyclean-generic:
Lines 515-521 Link Here
515
clean-generic:
526
clean-generic:
516
527
517
distclean-generic:
528
distclean-generic:
518
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
529
	-rm -f $(CONFIG_CLEAN_FILES)
519
530
520
maintainer-clean-generic:
531
maintainer-clean-generic:
521
	@echo "This command is intended for maintainers to use"
532
	@echo "This command is intended for maintainers to use"
Lines 525-538 Link Here
525
clean-am: clean-generic clean-valPROGRAMS mostlyclean-am
536
clean-am: clean-generic clean-valPROGRAMS mostlyclean-am
526
537
527
distclean: distclean-recursive
538
distclean: distclean-recursive
528
539
	-rm -rf ./$(DEPDIR)
529
distclean-am: clean-am distclean-compile distclean-depend \
540
	-rm -f Makefile
530
	distclean-generic distclean-tags
541
distclean-am: clean-am distclean-compile distclean-generic \
542
	distclean-tags
531
543
532
dvi: dvi-recursive
544
dvi: dvi-recursive
533
545
534
dvi-am:
546
dvi-am:
535
547
548
html: html-recursive
549
536
info: info-recursive
550
info: info-recursive
537
551
538
info-am:
552
info-am:
Lines 548-554 Link Here
548
installcheck-am:
562
installcheck-am:
549
563
550
maintainer-clean: maintainer-clean-recursive
564
maintainer-clean: maintainer-clean-recursive
551
565
	-rm -rf ./$(DEPDIR)
566
	-rm -f Makefile
552
maintainer-clean-am: distclean-am maintainer-clean-generic
567
maintainer-clean-am: distclean-am maintainer-clean-generic
553
568
554
mostlyclean: mostlyclean-recursive
569
mostlyclean: mostlyclean-recursive
Lines 568-593 Link Here
568
583
569
uninstall-info: uninstall-info-recursive
584
uninstall-info: uninstall-info-recursive
570
585
571
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
586
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am all-local check \
572
	clean-generic clean-recursive clean-valPROGRAMS ctags \
587
	check-am clean clean-generic clean-recursive clean-valPROGRAMS \
573
	ctags-recursive distclean distclean-compile distclean-depend \
588
	ctags ctags-recursive distclean distclean-compile \
574
	distclean-generic distclean-recursive distclean-tags distdir \
589
	distclean-generic distclean-recursive distclean-tags distdir \
575
	dvi dvi-am dvi-recursive info info-am info-recursive install \
590
	dvi dvi-am html html-am info info-am install install-am \
576
	install-am install-data install-data-am install-data-recursive \
591
	install-data install-data-am install-exec install-exec-am \
577
	install-exec install-exec-am install-exec-recursive \
592
	install-info install-info-am install-man \
578
	install-info install-info-am install-info-recursive install-man \
593
	install-mcincludeHEADERS install-strip install-valPROGRAMS \
579
	install-mcincludeHEADERS install-recursive install-strip \
594
	installcheck installcheck-am installdirs installdirs-am \
580
	install-valPROGRAMS installcheck installcheck-am installdirs \
595
	maintainer-clean maintainer-clean-generic \
581
	installdirs-am installdirs-recursive maintainer-clean \
596
	maintainer-clean-recursive mostlyclean mostlyclean-compile \
582
	maintainer-clean-generic maintainer-clean-recursive mostlyclean \
597
	mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \
583
	mostlyclean-compile mostlyclean-generic mostlyclean-recursive \
598
	tags tags-recursive uninstall uninstall-am uninstall-info-am \
584
	pdf pdf-am pdf-recursive ps ps-am ps-recursive tags \
599
	uninstall-mcincludeHEADERS uninstall-valPROGRAMS
585
	tags-recursive uninstall uninstall-am uninstall-info-am \
586
	uninstall-info-recursive uninstall-mcincludeHEADERS \
587
	uninstall-recursive uninstall-valPROGRAMS
588
600
589
601
590
mac_replace_strmem.o: CFLAGS += -fno-omit-frame-pointer
602
mac_replace_strmem.o: CFLAGS += -fno-omit-frame-pointer
603
604
all-local:
605
	mkdir -p $(inplacedir)
606
	-rm -f $(addprefix $(inplacedir)/,$(val_PROGRAMS))
607
	ln -f -s $(addprefix $(top_srcdir)/$(subdir)/,$(val_PROGRAMS)) $(inplacedir)
591
# Tell versions [3.59,3.63) of GNU make to not export all variables.
608
# Tell versions [3.59,3.63) of GNU make to not export all variables.
592
# Otherwise a system limit (for SysV at least) may be exceeded.
609
# Otherwise a system limit (for SysV at least) may be exceeded.
593
.NOEXPORT:
610
.NOEXPORT:
(-)valgrind-2.1.0/memcheck/docs/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/memcheck/docs/CVS/Entries (+5 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Mon Sep 23 11:36:35 2002//
2
/Makefile.am/1.2/Wed Nov 13 21:24:56 2002//
3
/mc_main.html/1.10/Fri Nov 14 17:47:54 2003//
4
/mc_techdocs.html/1.9/Sun Jan  4 16:43:23 2004//
5
D
(-)valgrind-2.1.0/memcheck/docs/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/memcheck/docs
(-)valgrind-2.1.0/memcheck/docs/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/memcheck/docs/Makefile.in (-38 / +64 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
21
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
23
top_builddir = ../..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
25
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
26
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
35
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
36
POST_UNINSTALL = :
38
host_triplet = @host@
37
host_triplet = @host@
38
subdir = memcheck/docs
39
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
40
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
41
am__aclocal_m4_deps = $(top_srcdir)/configure.in
42
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
43
	$(ACLOCAL_M4)
44
mkinstalldirs = $(mkdir_p)
45
CONFIG_HEADER = $(top_builddir)/config.h
46
CONFIG_CLEAN_FILES =
47
SOURCES =
48
DIST_SOURCES =
49
am__installdirs = $(DESTDIR)$(docdir)
50
docDATA_INSTALL = $(INSTALL_DATA)
51
DATA = $(doc_DATA)
52
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
53
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
54
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
55
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
106
SHELL = @SHELL@
93
STRIP = @STRIP@
107
STRIP = @STRIP@
94
VERSION = @VERSION@
108
VERSION = @VERSION@
109
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
110
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
111
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
112
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
138
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
139
localstatedir = @localstatedir@
125
mandir = @mandir@
140
mandir = @mandir@
141
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
142
oldincludedir = @oldincludedir@
127
prefix = @prefix@
143
prefix = @prefix@
128
program_transform_name = @program_transform_name@
144
program_transform_name = @program_transform_name@
Lines 131-162 Link Here
131
sysconfdir = @sysconfdir@
147
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
148
target_alias = @target_alias@
133
docdir = $(datadir)/doc/valgrind
149
docdir = $(datadir)/doc/valgrind
134
135
doc_DATA = mc_main.html mc_techdocs.html
150
doc_DATA = mc_main.html mc_techdocs.html
136
137
EXTRA_DIST = $(doc_DATA)
151
EXTRA_DIST = $(doc_DATA)
138
subdir = memcheck/docs
139
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
140
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
141
CONFIG_HEADER = $(top_builddir)/config.h
142
CONFIG_CLEAN_FILES =
143
DIST_SOURCES =
144
DATA = $(doc_DATA)
145
146
DIST_COMMON = Makefile.am Makefile.in
147
all: all-am
152
all: all-am
148
153
149
.SUFFIXES:
154
.SUFFIXES:
150
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
155
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
156
	@for dep in $?; do \
157
	  case '$(am__configure_deps)' in \
158
	    *$$dep*) \
159
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
160
		&& exit 0; \
161
	      exit 1;; \
162
	  esac; \
163
	done; \
164
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  memcheck/docs/Makefile'; \
151
	cd $(top_srcdir) && \
165
	cd $(top_srcdir) && \
152
	  $(AUTOMAKE) --gnu  memcheck/docs/Makefile
166
	  $(AUTOMAKE) --gnu  memcheck/docs/Makefile
153
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
167
.PRECIOUS: Makefile
154
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
168
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
169
	@case '$?' in \
170
	  *config.status*) \
171
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
172
	  *) \
173
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
174
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
175
	esac;
176
177
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
178
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
179
180
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
181
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
182
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
183
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
155
uninstall-info-am:
184
uninstall-info-am:
156
docDATA_INSTALL = $(INSTALL_DATA)
157
install-docDATA: $(doc_DATA)
185
install-docDATA: $(doc_DATA)
158
	@$(NORMAL_INSTALL)
186
	@$(NORMAL_INSTALL)
159
	$(mkinstalldirs) $(DESTDIR)$(docdir)
187
	$(mkdir_p) $(DESTDIR)$(docdir)
160
	@list='$(doc_DATA)'; for p in $$list; do \
188
	@list='$(doc_DATA)'; for p in $$list; do \
161
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
189
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
162
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
190
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
Lines 177-186 Link Here
177
ctags: CTAGS
205
ctags: CTAGS
178
CTAGS:
206
CTAGS:
179
207
180
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
181
182
top_distdir = ../..
183
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
184
208
185
distdir: $(DISTFILES)
209
distdir: $(DISTFILES)
186
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
210
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 194-200 Link Here
194
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
218
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
195
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
219
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
196
	    dir="/$$dir"; \
220
	    dir="/$$dir"; \
197
	    $(mkinstalldirs) "$(distdir)$$dir"; \
221
	    $(mkdir_p) "$(distdir)$$dir"; \
198
	  else \
222
	  else \
199
	    dir=''; \
223
	    dir=''; \
200
	  fi; \
224
	  fi; \
Lines 212-220 Link Here
212
check-am: all-am
236
check-am: all-am
213
check: check-am
237
check: check-am
214
all-am: Makefile $(DATA)
238
all-am: Makefile $(DATA)
215
216
installdirs:
239
installdirs:
217
	$(mkinstalldirs) $(DESTDIR)$(docdir)
240
	$(mkdir_p) $(DESTDIR)$(docdir)
218
install: install-am
241
install: install-am
219
install-exec: install-exec-am
242
install-exec: install-exec-am
220
install-data: install-data-am
243
install-data: install-data-am
Lines 226-232 Link Here
226
installcheck: installcheck-am
249
installcheck: installcheck-am
227
install-strip:
250
install-strip:
228
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
251
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
229
	  INSTALL_STRIP_FLAG=-s \
252
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
230
	  `test -z '$(STRIP)' || \
253
	  `test -z '$(STRIP)' || \
231
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
254
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
232
mostlyclean-generic:
255
mostlyclean-generic:
Lines 234-240 Link Here
234
clean-generic:
257
clean-generic:
235
258
236
distclean-generic:
259
distclean-generic:
237
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
260
	-rm -f $(CONFIG_CLEAN_FILES)
238
261
239
maintainer-clean-generic:
262
maintainer-clean-generic:
240
	@echo "This command is intended for maintainers to use"
263
	@echo "This command is intended for maintainers to use"
Lines 244-256 Link Here
244
clean-am: clean-generic mostlyclean-am
267
clean-am: clean-generic mostlyclean-am
245
268
246
distclean: distclean-am
269
distclean: distclean-am
247
270
	-rm -f Makefile
248
distclean-am: clean-am distclean-generic
271
distclean-am: clean-am distclean-generic
249
272
250
dvi: dvi-am
273
dvi: dvi-am
251
274
252
dvi-am:
275
dvi-am:
253
276
277
html: html-am
278
254
info: info-am
279
info: info-am
255
280
256
info-am:
281
info-am:
Lines 266-272 Link Here
266
installcheck-am:
291
installcheck-am:
267
292
268
maintainer-clean: maintainer-clean-am
293
maintainer-clean: maintainer-clean-am
269
294
	-rm -f Makefile
270
maintainer-clean-am: distclean-am maintainer-clean-generic
295
maintainer-clean-am: distclean-am maintainer-clean-generic
271
296
272
mostlyclean: mostlyclean-am
297
mostlyclean: mostlyclean-am
Lines 284-296 Link Here
284
uninstall-am: uninstall-docDATA uninstall-info-am
309
uninstall-am: uninstall-docDATA uninstall-info-am
285
310
286
.PHONY: all all-am check check-am clean clean-generic distclean \
311
.PHONY: all all-am check check-am clean clean-generic distclean \
287
	distclean-generic distdir dvi dvi-am info info-am install \
312
	distclean-generic distdir dvi dvi-am html html-am info info-am \
288
	install-am install-data install-data-am install-docDATA \
313
	install install-am install-data install-data-am \
289
	install-exec install-exec-am install-info install-info-am \
314
	install-docDATA install-exec install-exec-am install-info \
290
	install-man install-strip installcheck installcheck-am \
315
	install-info-am install-man install-strip installcheck \
291
	installdirs maintainer-clean maintainer-clean-generic \
316
	installcheck-am installdirs maintainer-clean \
292
	mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
317
	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
293
	uninstall-am uninstall-docDATA uninstall-info-am
318
	pdf-am ps ps-am uninstall uninstall-am uninstall-docDATA \
319
	uninstall-info-am
294
320
295
# Tell versions [3.59,3.63) of GNU make to not export all variables.
321
# Tell versions [3.59,3.63) of GNU make to not export all variables.
296
# Otherwise a system limit (for SysV at least) may be exceeded.
322
# Otherwise a system limit (for SysV at least) may be exceeded.
(-)valgrind-2.1.0/memcheck/docs/mc_techdocs.html (-1 / +1 lines)
Lines 34-40 Link Here
34
<p>
34
<p>
35
<a href="mailto:jseward@acm.org">jseward@acm.org</a><br>
35
<a href="mailto:jseward@acm.org">jseward@acm.org</a><br>
36
<a href="http://valgrind.kde.org">http://valgrind.kde.org</a><br>
36
<a href="http://valgrind.kde.org">http://valgrind.kde.org</a><br>
37
Copyright &copy; 2000-2003 Julian Seward
37
Copyright &copy; 2000-2004 Julian Seward
38
<p>
38
<p>
39
Valgrind is licensed under the GNU General Public License, 
39
Valgrind is licensed under the GNU General Public License, 
40
version 2<br>
40
version 2<br>
(-)valgrind-2.1.0/memcheck/mac_leakcheck.c (-5 / +2 lines)
Lines 9-15 Link Here
9
   detecting memory errors, and AddrCheck, a lightweight Valgrind tool 
9
   detecting memory errors, and AddrCheck, a lightweight Valgrind tool 
10
   for detecting memory errors.
10
   for detecting memory errors.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 311-320 Link Here
311
      where the .bss segment has been put.  If you can, drop me a
311
      where the .bss segment has been put.  If you can, drop me a
312
      line.  
312
      line.  
313
   */
313
   */
314
   if (VG_(within_stack)(a))                      return;
314
   if (!VG_(is_client_addr)(a))			  return;
315
   if (VG_(within_m_state_static_OR_threads)(a))  return;
316
   if (a == (Addr)(&lc_min_mallocd_addr))         return;
317
   if (a == (Addr)(&lc_max_mallocd_addr))         return;
318
315
319
   /* OK, let's get on and do something Useful for a change. */
316
   /* OK, let's get on and do something Useful for a change. */
320
317
(-)valgrind-2.1.0/memcheck/mac_malloc_wrappers.c (-2 / +2 lines)
Lines 9-15 Link Here
9
   detecting memory errors, and AddrCheck, a lightweight Valgrind tool 
9
   detecting memory errors, and AddrCheck, a lightweight Valgrind tool 
10
   for detecting memory errors.
10
   for detecting memory errors.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 44-50 Link Here
44
/* We want a 16B redzone on heap blocks for Addrcheck and Memcheck */
44
/* We want a 16B redzone on heap blocks for Addrcheck and Memcheck */
45
UInt VG_(vg_malloc_redzone_szB) = 16;
45
UInt VG_(vg_malloc_redzone_szB) = 16;
46
46
47
/* Function pointers for the two skins to track interesting events. */
47
/* Function pointers for the two tools to track interesting events. */
48
void (*MAC_(new_mem_heap)) ( Addr a, UInt len, Bool is_inited )  = NULL;
48
void (*MAC_(new_mem_heap)) ( Addr a, UInt len, Bool is_inited )  = NULL;
49
void (*MAC_(ban_mem_heap)) ( Addr a, UInt len )                  = NULL;
49
void (*MAC_(ban_mem_heap)) ( Addr a, UInt len )                  = NULL;
50
void (*MAC_(die_mem_heap)) ( Addr a, UInt len )                  = NULL;
50
void (*MAC_(die_mem_heap)) ( Addr a, UInt len )                  = NULL;
(-)valgrind-2.1.0/memcheck/mac_needs.c (-4 / +4 lines)
Lines 9-15 Link Here
9
   detecting memory errors, and AddrCheck, a lightweight Valgrind tool 
9
   detecting memory errors, and AddrCheck, a lightweight Valgrind tool 
10
   for detecting memory errors.
10
   for detecting memory errors.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 732-750 Link Here
732
   81   fpu_read aligned 4
732
   81   fpu_read aligned 4
733
   82   fpu_read aligned 8
733
   82   fpu_read aligned 8
734
   83   fpu_read 2
734
   83   fpu_read 2
735
   84   fpu_read 10/28/108
735
   84   fpu_read 10/28/108/512
736
736
737
M  85   fpu_write
737
M  85   fpu_write
738
M  86   fpu_write aligned 4
738
M  86   fpu_write aligned 4
739
M  87   fpu_write aligned 8
739
M  87   fpu_write aligned 8
740
M  88   fpu_write 2
740
M  88   fpu_write 2
741
M  89   fpu_write 10/28/108
741
M  89   fpu_write 10/28/108/512
742
742
743
   90   fpu_access
743
   90   fpu_access
744
   91   fpu_access aligned 4
744
   91   fpu_access aligned 4
745
   92   fpu_access aligned 8
745
   92   fpu_access aligned 8
746
   93   fpu_access 2
746
   93   fpu_access 2
747
   94   fpu_access 10/28/108
747
   94   fpu_access 10/28/108/512
748
748
749
   100  fpu_access_check_SLOWLY
749
   100  fpu_access_check_SLOWLY
750
   101  fpu_access_check_SLOWLY(byte loop)
750
   101  fpu_access_check_SLOWLY(byte loop)
(-)valgrind-2.1.0/memcheck/mac_replace_strmem.c (-3 / +54 lines)
Lines 9-15 Link Here
9
   This file is part of MemCheck, a heavyweight Valgrind tool for
9
   This file is part of MemCheck, a heavyweight Valgrind tool for
10
   detecting memory errors.
10
   detecting memory errors.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 31-38 Link Here
31
*/
31
*/
32
32
33
#include "mc_include.h"
33
#include "mc_include.h"
34
#include "memcheck.h"
34
#include "valgrind.h"
35
#include "valgrind.h"
35
36
37
static Addr record_overlap_error;
38
39
static int init_done;
40
41
/* Startup hook - called as init section */
42
static void init(void) __attribute__((constructor));
43
static void init(void) 
44
{
45
   if (init_done)
46
      return;
47
48
   VALGRIND_MAGIC_SEQUENCE(record_overlap_error, 0,
49
			   _VG_USERREQ__MEMCHECK_GET_RECORD_OVERLAP,
50
			   0, 0, 0, 0);
51
   init_done = 1;
52
}
53
36
/* ---------------------------------------------------------------------
54
/* ---------------------------------------------------------------------
37
   The normal versions of these functions are hyper-optimised, which fools
55
   The normal versions of these functions are hyper-optimised, which fools
38
   Memcheck and cause spurious value warnings.  So we replace them with
56
   Memcheck and cause spurious value warnings.  So we replace them with
Lines 80-86 Link Here
80
   OverlapExtra extra = {
98
   OverlapExtra extra = {
81
      .src = (Addr)src, .dst = (Addr)dst, .len = -1,
99
      .src = (Addr)src, .dst = (Addr)dst, .len = -1,
82
   };
100
   };
83
   VALGRIND_NON_SIMD_CALL2( MAC_(record_overlap_error), s, &extra );
101
   init();
102
   VALGRIND_NON_SIMD_CALL2( record_overlap_error, s, &extra );
84
}
103
}
85
104
86
static __inline__
105
static __inline__
Lines 90-96 Link Here
90
   OverlapExtra extra = {
109
   OverlapExtra extra = {
91
      .src = (Addr)src, .dst = (Addr)dst, .len = n,
110
      .src = (Addr)src, .dst = (Addr)dst, .len = n,
92
   };
111
   };
93
   VALGRIND_NON_SIMD_CALL2( MAC_(record_overlap_error), s, &extra );
112
   init();
113
   VALGRIND_NON_SIMD_CALL2( record_overlap_error, s, &extra );
94
}
114
}
95
115
96
char* strrchr ( const char* s, int c )
116
char* strrchr ( const char* s, int c )
Lines 156-161 Link Here
156
   return dst_orig;
176
   return dst_orig;
157
}
177
}
158
178
179
unsigned int strnlen ( const char* str, unsigned int n )
180
{
181
   UInt i = 0;
182
   while (i < n && str[i] != 0) i++;
183
   return i;
184
}
185
159
unsigned int strlen ( const char* str )
186
unsigned int strlen ( const char* str )
160
{
187
{
161
   UInt i = 0;
188
   UInt i = 0;
Lines 300-305 Link Here
300
   return 0;
327
   return 0;
301
}
328
}
302
329
330
331
/* Copy SRC to DEST, returning the address of the terminating '\0' in
332
   DEST. (minor variant of strcpy) */
333
334
char* stpcpy ( char* dst, const char* src )
335
{
336
   const Char* src_orig = src;
337
         Char* dst_orig = dst;
338
339
   while (*src) *dst++ = *src++;
340
   *dst = 0;
341
342
   /* This checks for overlap after copying, unavoidable without
343
      pre-counting length... should be ok */
344
   if (is_overlap(dst_orig, 
345
                  src_orig, 
346
                  (Addr)dst-(Addr)dst_orig+1, 
347
                  (Addr)src-(Addr)src_orig+1))
348
      complain2("stpcpy", dst_orig, src_orig);
349
350
   return dst;
351
}
352
353
303
/*--------------------------------------------------------------------*/
354
/*--------------------------------------------------------------------*/
304
/*--- end                                     mac_replace_strmem.c ---*/
355
/*--- end                                     mac_replace_strmem.c ---*/
305
/*--------------------------------------------------------------------*/
356
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/memcheck/mac_shared.h (-4 / +4 lines)
Lines 9-15 Link Here
9
   detecting memory errors, and AddrCheck, a lightweight Valgrind tool 
9
   detecting memory errors, and AddrCheck, a lightweight Valgrind tool 
10
   for detecting memory errors.
10
   for detecting memory errors.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 154-160 Link Here
154
   MAC_Chunk;
154
   MAC_Chunk;
155
155
156
/*------------------------------------------------------------*/
156
/*------------------------------------------------------------*/
157
/*--- Profiling of skins and memory events                 ---*/
157
/*--- Profiling of tools and memory events                 ---*/
158
/*------------------------------------------------------------*/
158
/*------------------------------------------------------------*/
159
159
160
typedef 
160
typedef 
Lines 163-169 Link Here
163
      VgpSetMem,
163
      VgpSetMem,
164
      VgpESPAdj
164
      VgpESPAdj
165
   } 
165
   } 
166
   VgpSkinCC;
166
   VgpToolCC;
167
167
168
/* Define to collect detailed performance info. */
168
/* Define to collect detailed performance info. */
169
/* #define MAC_PROFILE_MEMORY */
169
/* #define MAC_PROFILE_MEMORY */
Lines 270-276 Link Here
270
/* For tracking malloc'd blocks */
270
/* For tracking malloc'd blocks */
271
extern VgHashTable MAC_(malloc_list);
271
extern VgHashTable MAC_(malloc_list);
272
272
273
/* Function pointers for the two skins to track interesting events. */
273
/* Function pointers for the two tools to track interesting events. */
274
extern void (*MAC_(new_mem_heap)) ( Addr a, UInt len, Bool is_inited );
274
extern void (*MAC_(new_mem_heap)) ( Addr a, UInt len, Bool is_inited );
275
extern void (*MAC_(ban_mem_heap)) ( Addr a, UInt len );
275
extern void (*MAC_(ban_mem_heap)) ( Addr a, UInt len );
276
extern void (*MAC_(die_mem_heap)) ( Addr a, UInt len );
276
extern void (*MAC_(die_mem_heap)) ( Addr a, UInt len );
(-)valgrind-2.1.0/memcheck/mc_clientreqs.c (-1 / +5 lines)
Lines 9-15 Link Here
9
   This file is part of MemCheck, a heavyweight Valgrind tool for
9
   This file is part of MemCheck, a heavyweight Valgrind tool for
10
   detecting memory errors.
10
   detecting memory errors.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 232-237 Link Here
232
                   ( tid, arg[1], arg[2], arg[3], True /* set them */ );
232
                   ( tid, arg[1], arg[2], arg[3], True /* set them */ );
233
         break;
233
         break;
234
234
235
      case _VG_USERREQ__MEMCHECK_GET_RECORD_OVERLAP:
236
	 *ret = (Addr)MAC_(record_overlap_error);
237
	 break;
238
235
      default:
239
      default:
236
         if (MAC_(handle_common_client_requests)(tid, arg, ret )) {
240
         if (MAC_(handle_common_client_requests)(tid, arg, ret )) {
237
            return True;
241
            return True;
(-)valgrind-2.1.0/memcheck/mc_constants.h (-1 / +1 lines)
Lines 7-13 Link Here
7
   This file is part of MemCheck, a heavyweight Valgrind tool for
7
   This file is part of MemCheck, a heavyweight Valgrind tool for
8
   detecting memory errors.
8
   detecting memory errors.
9
9
10
   Copyright (C) 2000-2003 Julian Seward 
10
   Copyright (C) 2000-2004 Julian Seward 
11
      jseward@acm.org
11
      jseward@acm.org
12
12
13
   This program is free software; you can redistribute it and/or
13
   This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/memcheck/mc_errcontext.c (-1 / +1 lines)
Lines 8-14 Link Here
8
   This file is part of MemCheck, a heavyweight Valgrind tool for
8
   This file is part of MemCheck, a heavyweight Valgrind tool for
9
   detecting memory errors.
9
   detecting memory errors.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/memcheck/mc_from_ucode.c (-6 / +14 lines)
Lines 8-14 Link Here
8
   This file is part of MemCheck, a heavyweight Valgrind tool for
8
   This file is part of MemCheck, a heavyweight Valgrind tool for
9
   detecting memory errors.
9
   detecting memory errors.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 166-171 Link Here
166
166
167
static void synth_TESTV ( Int sz, Int tag, Int val )
167
static void synth_TESTV ( Int sz, Int tag, Int val )
168
{
168
{
169
   Int tgt;			/* jump target */
170
169
   /* Important note.  Note that that the calls to
171
   /* Important note.  Note that that the calls to
170
      MC_(helper_value_check[0124]_fail) must be compact helpers due to
172
      MC_(helper_value_check[0124]_fail) must be compact helpers due to
171
      the codegen scheme used below.  Since there are a shortage of
173
      the codegen scheme used below.  Since there are a shortage of
Lines 173-178 Link Here
173
      actually used, we assert against it. */
175
      actually used, we assert against it. */
174
   sk_assert(sz == 0 || sz == 2 || sz == 4);
176
   sk_assert(sz == 0 || sz == 2 || sz == 4);
175
177
178
   VG_(init_target)(&tgt);
179
176
   sk_assert(tag == ArchReg || tag == RealReg);
180
   sk_assert(tag == ArchReg || tag == RealReg);
177
   if (tag == ArchReg) {
181
   if (tag == ArchReg) {
178
      switch (sz) {
182
      switch (sz) {
Lines 222-230 Link Here
222
            VG_(skin_panic)("synth_TESTV(RealReg)");
226
            VG_(skin_panic)("synth_TESTV(RealReg)");
223
      }
227
      }
224
   }
228
   }
225
   VG_(emit_jcondshort_delta) ( False, CondZ, 3 );
229
   
230
   /* predict taken because we assume failures are rare */
231
   VG_(emit_jcondshort_target) ( False, CondZ, &tgt, JP_TAKEN );
232
226
   VG_(synth_call) (
233
   VG_(synth_call) (
227
      True, /* needed to guarantee that this insn is indeed 3 bytes long */
234
      False,
228
      ( sz==4 
235
      ( sz==4 
229
      ? VG_(helper_offset)((Addr) & MC_(helper_value_check4_fail))
236
      ? VG_(helper_offset)((Addr) & MC_(helper_value_check4_fail))
230
      : ( sz==2 
237
      : ( sz==2 
Lines 234-239 Link Here
234
	  : VG_(helper_offset)((Addr) & MC_(helper_value_check0_fail))))),
241
	  : VG_(helper_offset)((Addr) & MC_(helper_value_check0_fail))))),
235
      False, FlagsEmpty, FlagsOSZACP /* helpers don't preserve flags */
242
      False, FlagsEmpty, FlagsOSZACP /* helpers don't preserve flags */
236
   );
243
   );
244
   VG_(target_forward)(&tgt);
237
}
245
}
238
246
239
247
Lines 246-261 Link Here
246
                                        R_EBP, reg );
254
                                        R_EBP, reg );
247
         break;
255
         break;
248
      case 2: 
256
      case 2: 
249
         VG_(emit_movzwl_offregmem_reg) ( VG_(shadow_reg_offset)(arch),
257
         VG_(emit_movzwl_offregmem_reg) ( False, VG_(shadow_reg_offset)(arch),
250
                                          R_EBP, reg );
258
                                          R_EBP, reg );
251
         VG_(emit_nonshiftopv_lit_reg) ( False, 4, OR, 0xFFFF0000, reg );
259
         VG_(emit_nonshiftopv_lit_reg) ( False, 4, OR, 0xFFFF0000, reg );
252
         break;
260
         break;
253
      case 1: 
261
      case 1: 
254
         if (arch < 4) {
262
         if (arch < 4) {
255
            VG_(emit_movzbl_offregmem_reg) ( VG_(shadow_reg_offset)(arch),
263
            VG_(emit_movzbl_offregmem_reg) ( False, VG_(shadow_reg_offset)(arch),
256
                                             R_EBP, reg );
264
                                             R_EBP, reg );
257
         } else {
265
         } else {
258
            VG_(emit_movzbl_offregmem_reg) ( VG_(shadow_reg_offset)(arch-4)+1,
266
            VG_(emit_movzbl_offregmem_reg) ( False, VG_(shadow_reg_offset)(arch-4)+1,
259
                                             R_EBP, reg );
267
                                             R_EBP, reg );
260
         }
268
         }
261
         VG_(emit_nonshiftopv_lit_reg) ( False, 4, OR, 0xFFFFFF00, reg );
269
         VG_(emit_nonshiftopv_lit_reg) ( False, 4, OR, 0xFFFFFF00, reg );
(-)valgrind-2.1.0/memcheck/mc_helpers.S (-1 / +1 lines)
Lines 8-14 Link Here
8
  This file is part of MemCheck, a heavyweight Valgrind tool for
8
  This file is part of MemCheck, a heavyweight Valgrind tool for
9
  detecting memory errors.
9
  detecting memory errors.
10
10
11
  Copyright (C) 2000-2003 Julian Seward 
11
  Copyright (C) 2000-2004 Julian Seward 
12
     jseward@acm.org
12
     jseward@acm.org
13
13
14
  This program is free software; you can redistribute it and/or
14
  This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/memcheck/mc_include.h (-1 / +1 lines)
Lines 8-14 Link Here
8
   This file is part of MemCheck, a heavyweight Valgrind tool for
8
   This file is part of MemCheck, a heavyweight Valgrind tool for
9
   detecting memory errors.
9
   detecting memory errors.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
(-)valgrind-2.1.0/memcheck/mc_main.c (-58 / +45 lines)
Lines 9-15 Link Here
9
   This file is part of MemCheck, a heavyweight Valgrind tool for
9
   This file is part of MemCheck, a heavyweight Valgrind tool for
10
   detecting memory errors.
10
   detecting memory errors.
11
11
12
   Copyright (C) 2000-2003 Julian Seward 
12
   Copyright (C) 2000-2004 Julian Seward 
13
      jseward@acm.org
13
      jseward@acm.org
14
14
15
   This program is free software; you can redistribute it and/or
15
   This program is free software; you can redistribute it and/or
Lines 34-41 Link Here
34
#include "memcheck.h"   /* for client requests */
34
#include "memcheck.h"   /* for client requests */
35
//#include "vg_profile.c"
35
//#include "vg_profile.c"
36
36
37
VG_DETERMINE_INTERFACE_VERSION
38
39
/* Define to debug the mem audit system. */
37
/* Define to debug the mem audit system. */
40
/* #define VG_DEBUG_MEMORY */
38
/* #define VG_DEBUG_MEMORY */
41
39
Lines 118-124 Link Here
118
static SecMap* primary_map[ /*65536*/ 262144 ];
116
static SecMap* primary_map[ /*65536*/ 262144 ];
119
static SecMap  distinguished_secondary_map;
117
static SecMap  distinguished_secondary_map;
120
118
121
122
static void init_shadow_memory ( void )
119
static void init_shadow_memory ( void )
123
{
120
{
124
   Int i;
121
   Int i;
Lines 157-163 Link Here
157
      although this isn't important, so the following assert is
154
      although this isn't important, so the following assert is
158
      spurious. */
155
      spurious. */
159
   sk_assert(0 == (sizeof(SecMap) % VKI_BYTES_PER_PAGE));
156
   sk_assert(0 == (sizeof(SecMap) % VKI_BYTES_PER_PAGE));
160
   map = VG_(get_memory_from_mmap)( sizeof(SecMap), caller );
157
   map = (SecMap *)VG_(shadow_alloc)(sizeof(SecMap));
161
158
162
   for (i = 0; i < 8192; i++)
159
   for (i = 0; i < 8192; i++)
163
      map->abits[i] = VGM_BYTE_INVALID; /* Invalid address */
160
      map->abits[i] = VGM_BYTE_INVALID; /* Invalid address */
Lines 1193-1199 Link Here
1193
   }
1190
   }
1194
1191
1195
   if (size == 16 /*SSE*/ 
1192
   if (size == 16 /*SSE*/ 
1196
       || size == 10 || size == 28 || size == 108) {
1193
       || size == 10 || size == 28 || size == 108 || size == 512) {
1197
      PROF_EVENT(84);
1194
      PROF_EVENT(84);
1198
      mc_fpu_read_check_SLOWLY ( addr, size );
1195
      mc_fpu_read_check_SLOWLY ( addr, size );
1199
      return;
1196
      return;
Lines 1276-1282 Link Here
1276
   }
1273
   }
1277
1274
1278
   if (size == 16 /*SSE*/ 
1275
   if (size == 16 /*SSE*/ 
1279
       || size == 10 || size == 28 || size == 108) {
1276
       || size == 10 || size == 28 || size == 108 || size == 512) {
1280
      PROF_EVENT(89);
1277
      PROF_EVENT(89);
1281
      mc_fpu_write_check_SLOWLY ( addr, size );
1278
      mc_fpu_write_check_SLOWLY ( addr, size );
1282
      return;
1279
      return;
Lines 1471-1493 Link Here
1471
   Sanity check machinery (permanently engaged).
1468
   Sanity check machinery (permanently engaged).
1472
   ------------------------------------------------------------------ */
1469
   ------------------------------------------------------------------ */
1473
1470
1474
/* Check that nobody has spuriously claimed that the first or last 16
1475
   pages (64 KB) of address space have become accessible.  Failure of
1476
   the following do not per se indicate an internal consistency
1477
   problem, but they are so likely to that we really want to know
1478
   about it if so. */
1479
1480
Bool SK_(cheap_sanity_check) ( void )
1471
Bool SK_(cheap_sanity_check) ( void )
1481
{
1472
{
1482
   if (IS_DISTINGUISHED_SM(primary_map[0])
1473
   /* nothing useful we can rapidly check */
1483
       /* kludge: kernel drops a page up at top of address range for
1474
   return True;
1484
          magic "optimized syscalls", so we can no longer check the
1485
          highest page */
1486
       /* && IS_DISTINGUISHED_SM(primary_map[65535]) */
1487
      )
1488
      return True;
1489
   else
1490
      return False;
1491
}
1475
}
1492
1476
1493
Bool SK_(expensive_sanity_check) ( void )
1477
Bool SK_(expensive_sanity_check) ( void )
Lines 1658-1664 Link Here
1658
   VG_(details_version)         (NULL);
1642
   VG_(details_version)         (NULL);
1659
   VG_(details_description)     ("a memory error detector");
1643
   VG_(details_description)     ("a memory error detector");
1660
   VG_(details_copyright_author)(
1644
   VG_(details_copyright_author)(
1661
      "Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward.");
1645
      "Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward.");
1662
   VG_(details_bug_reports_to)  (VG_BUGS_TO);
1646
   VG_(details_bug_reports_to)  (VG_BUGS_TO);
1663
   VG_(details_avg_translation_sizeB) ( 228 );
1647
   VG_(details_avg_translation_sizeB) ( 228 );
1664
1648
Lines 1671-1676 Link Here
1671
   VG_(needs_extended_UCode)      ();
1655
   VG_(needs_extended_UCode)      ();
1672
   VG_(needs_syscall_wrapper)     ();
1656
   VG_(needs_syscall_wrapper)     ();
1673
   VG_(needs_sanity_checks)       ();
1657
   VG_(needs_sanity_checks)       ();
1658
   VG_(needs_shadow_memory)       ();
1674
1659
1675
   MAC_( new_mem_heap)             = & mc_new_mem_heap;
1660
   MAC_( new_mem_heap)             = & mc_new_mem_heap;
1676
   MAC_( ban_mem_heap)             = & MC_(make_noaccess);
1661
   MAC_( ban_mem_heap)             = & MC_(make_noaccess);
Lines 1678-1722 Link Here
1678
   MAC_( die_mem_heap)             = & MC_(make_noaccess);
1663
   MAC_( die_mem_heap)             = & MC_(make_noaccess);
1679
   MAC_(check_noaccess)            = & MC_(check_noaccess);
1664
   MAC_(check_noaccess)            = & MC_(check_noaccess);
1680
1665
1681
   VG_(track_new_mem_startup)      ( & mc_new_mem_startup );
1666
   VG_(init_new_mem_startup)      ( & mc_new_mem_startup );
1682
   VG_(track_new_mem_stack_signal) ( & MC_(make_writable) );
1667
   VG_(init_new_mem_stack_signal) ( & MC_(make_writable) );
1683
   VG_(track_new_mem_brk)          ( & MC_(make_writable) );
1668
   VG_(init_new_mem_brk)          ( & MC_(make_writable) );
1684
   VG_(track_new_mem_mmap)         ( & mc_set_perms );
1669
   VG_(init_new_mem_mmap)         ( & mc_set_perms );
1685
   
1670
   
1686
   VG_(track_copy_mem_remap)       ( & mc_copy_address_range_state );
1671
   VG_(init_copy_mem_remap)       ( & mc_copy_address_range_state );
1687
   VG_(track_change_mem_mprotect)  ( & mc_set_perms );
1672
   VG_(init_change_mem_mprotect)  ( & mc_set_perms );
1688
      
1673
      
1689
   VG_(track_die_mem_stack_signal) ( & MC_(make_noaccess) ); 
1674
   VG_(init_die_mem_stack_signal) ( & MC_(make_noaccess) ); 
1690
   VG_(track_die_mem_brk)          ( & MC_(make_noaccess) );
1675
   VG_(init_die_mem_brk)          ( & MC_(make_noaccess) );
1691
   VG_(track_die_mem_munmap)       ( & MC_(make_noaccess) ); 
1676
   VG_(init_die_mem_munmap)       ( & MC_(make_noaccess) ); 
1692
1677
1693
   VG_(track_new_mem_stack_4)      ( & MAC_(new_mem_stack_4)  );
1678
   VG_(init_new_mem_stack_4)      ( & MAC_(new_mem_stack_4)  );
1694
   VG_(track_new_mem_stack_8)      ( & MAC_(new_mem_stack_8)  );
1679
   VG_(init_new_mem_stack_8)      ( & MAC_(new_mem_stack_8)  );
1695
   VG_(track_new_mem_stack_12)     ( & MAC_(new_mem_stack_12) );
1680
   VG_(init_new_mem_stack_12)     ( & MAC_(new_mem_stack_12) );
1696
   VG_(track_new_mem_stack_16)     ( & MAC_(new_mem_stack_16) );
1681
   VG_(init_new_mem_stack_16)     ( & MAC_(new_mem_stack_16) );
1697
   VG_(track_new_mem_stack_32)     ( & MAC_(new_mem_stack_32) );
1682
   VG_(init_new_mem_stack_32)     ( & MAC_(new_mem_stack_32) );
1698
   VG_(track_new_mem_stack)        ( & MAC_(new_mem_stack)    );
1683
   VG_(init_new_mem_stack)        ( & MAC_(new_mem_stack)    );
1699
1684
1700
   VG_(track_die_mem_stack_4)      ( & MAC_(die_mem_stack_4)  );
1685
   VG_(init_die_mem_stack_4)      ( & MAC_(die_mem_stack_4)  );
1701
   VG_(track_die_mem_stack_8)      ( & MAC_(die_mem_stack_8)  );
1686
   VG_(init_die_mem_stack_8)      ( & MAC_(die_mem_stack_8)  );
1702
   VG_(track_die_mem_stack_12)     ( & MAC_(die_mem_stack_12) );
1687
   VG_(init_die_mem_stack_12)     ( & MAC_(die_mem_stack_12) );
1703
   VG_(track_die_mem_stack_16)     ( & MAC_(die_mem_stack_16) );
1688
   VG_(init_die_mem_stack_16)     ( & MAC_(die_mem_stack_16) );
1704
   VG_(track_die_mem_stack_32)     ( & MAC_(die_mem_stack_32) );
1689
   VG_(init_die_mem_stack_32)     ( & MAC_(die_mem_stack_32) );
1705
   VG_(track_die_mem_stack)        ( & MAC_(die_mem_stack)    );
1690
   VG_(init_die_mem_stack)        ( & MAC_(die_mem_stack)    );
1706
   
1691
   
1707
   VG_(track_ban_mem_stack)        ( & MC_(make_noaccess) );
1692
   VG_(init_ban_mem_stack)        ( & MC_(make_noaccess) );
1708
1693
1709
   VG_(track_pre_mem_read)         ( & mc_check_is_readable );
1694
   VG_(init_pre_mem_read)         ( & mc_check_is_readable );
1710
   VG_(track_pre_mem_read_asciiz)  ( & mc_check_is_readable_asciiz );
1695
   VG_(init_pre_mem_read_asciiz)  ( & mc_check_is_readable_asciiz );
1711
   VG_(track_pre_mem_write)        ( & mc_check_is_writable );
1696
   VG_(init_pre_mem_write)        ( & mc_check_is_writable );
1712
   VG_(track_post_mem_write)       ( & MC_(make_readable) );
1697
   VG_(init_post_mem_write)       ( & MC_(make_readable) );
1713
1698
1714
   VG_(track_post_regs_write_init)             ( & mc_post_regs_write_init );
1699
   VG_(init_post_regs_write_init)             ( & mc_post_regs_write_init );
1715
   VG_(track_post_reg_write_syscall_return)    ( & mc_post_reg_write );
1700
   VG_(init_post_reg_write_syscall_return)    ( & mc_post_reg_write );
1716
   VG_(track_post_reg_write_deliver_signal)    ( & mc_post_reg_write );
1701
   VG_(init_post_reg_write_deliver_signal)    ( & mc_post_reg_write );
1717
   VG_(track_post_reg_write_pthread_return)    ( & mc_post_reg_write );
1702
   VG_(init_post_reg_write_pthread_return)    ( & mc_post_reg_write );
1718
   VG_(track_post_reg_write_clientreq_return)  ( & mc_post_reg_write );
1703
   VG_(init_post_reg_write_clientreq_return)  ( & mc_post_reg_write );
1719
   VG_(track_post_reg_write_clientcall_return) ( & mc_post_reg_write_clientcall );
1704
   VG_(init_post_reg_write_clientcall_return) ( & mc_post_reg_write_clientcall );
1720
1705
1721
   /* Three compact slots taken up by stack memory helpers */
1706
   /* Three compact slots taken up by stack memory helpers */
1722
   VG_(register_compact_helper)((Addr) & MC_(helper_value_check4_fail));
1707
   VG_(register_compact_helper)((Addr) & MC_(helper_value_check4_fail));
Lines 1760-1765 Link Here
1760
   }
1745
   }
1761
}
1746
}
1762
1747
1748
VG_DETERMINE_INTERFACE_VERSION(SK_(pre_clo_init), 9./8)
1749
1763
/*--------------------------------------------------------------------*/
1750
/*--------------------------------------------------------------------*/
1764
/*--- end                                                mc_main.c ---*/
1751
/*--- end                                                mc_main.c ---*/
1765
/*--------------------------------------------------------------------*/
1752
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/memcheck/mc_translate.c (-10 / +15 lines)
Lines 1-4 Link Here
1
/* -*- c-basic-offset: 3 -*- */
1
2
/*--------------------------------------------------------------------*/
2
/*--------------------------------------------------------------------*/
3
/*--- Instrument UCode to perform memory checking operations.      ---*/
3
/*--- Instrument UCode to perform memory checking operations.      ---*/
4
/*---                                               mc_translate.c ---*/
4
/*---                                               mc_translate.c ---*/
Lines 8-14 Link Here
8
   This file is part of MemCheck, a heavyweight Valgrind tool for
8
   This file is part of MemCheck, a heavyweight Valgrind tool for
9
   detecting memory errors.
9
   detecting memory errors.
10
10
11
   Copyright (C) 2000-2003 Julian Seward 
11
   Copyright (C) 2000-2004 Julian Seward 
12
      jseward@acm.org
12
      jseward@acm.org
13
13
14
   This program is free software; you can redistribute it and/or
14
   This program is free software; you can redistribute it and/or
Lines 718-726 Link Here
718
               Noticed by Kevin Ryde <user42@zip.com.au>
718
               Noticed by Kevin Ryde <user42@zip.com.au>
719
            */
719
            */
720
	    /* sk_assert(u_in->flags_w != FlagsEmpty); */
720
	    /* sk_assert(u_in->flags_w != FlagsEmpty); */
721
            qs = getOperandShadow(cb, u_in->size, u_in->tag1, u_in->val1);
721
            qs = getOperandShadow(cb, 1, u_in->tag1, u_in->val1);
722
            /* We can safely modify qs; cast it to 0-size. */
722
            /* We can safely modify qs; cast it to 0-size. */
723
            create_PCast(cb, u_in->size, 0, qs);
723
            create_PCast(cb, 1, 0, qs);
724
            qd = SHADOW(u_in->val2);
724
            qd = SHADOW(u_in->val2);
725
            create_PCast(cb, u_in->size, 0, qd);
725
            create_PCast(cb, u_in->size, 0, qd);
726
            /* qs is cast-to-0(shift count#), and qd is cast-to-0(value#). */
726
            /* qs is cast-to-0(shift count#), and qd is cast-to-0(value#). */
Lines 1076-1089 Link Here
1076
         }
1076
         }
1077
1077
1078
	 /* SSE ins referencing scalar integer registers */
1078
	 /* SSE ins referencing scalar integer registers */
1079
	 case SSE3g_RegWr:
1079
         case SSE2g_RegWr:
1080
         case SSE2g1_RegWr:
1081
         case SSE2e1_RegRd:
1082
         case SSE3g_RegWr:
1080
         case SSE3e_RegRd:
1083
         case SSE3e_RegRd:
1081
         case SSE3e_RegWr: 
1084
         case SSE3e_RegWr: 
1082
         case SSE3g1_RegWr:
1085
         case SSE3g1_RegWr:
1083
         case SSE3e1_RegRd:
1086
         case SSE3e1_RegRd:
1084
            sk_assert(u_in->tag3 == TempReg);
1087
            sk_assert(u_in->tag3 == TempReg);
1085
1088
1086
            if (u_in->opcode == SSE3e1_RegRd) {
1089
            if (u_in->opcode == SSE2e1_RegRd || u_in->opcode == SSE3e1_RegRd) {
1087
               sk_assert(u_in->size == 2);
1090
               sk_assert(u_in->size == 2);
1088
            } else {
1091
            } else {
1089
               sk_assert(u_in->size == 4);
1092
               sk_assert(u_in->size == 4);
Lines 1108-1123 Link Here
1108
         case SSE3a_MemWr:
1111
         case SSE3a_MemWr:
1109
         case SSE2a_MemWr:
1112
         case SSE2a_MemWr:
1110
         case SSE2a_MemRd:
1113
         case SSE2a_MemRd:
1111
         case SSE3a1_MemRd: { 
1114
         case SSE3a1_MemRd:
1115
         case SSE2a1_MemRd: { 
1112
            Bool is_load;
1116
            Bool is_load;
1113
            Int t_size;
1117
            Int t_size;
1114
1118
1115
            sk_assert(u_in->size == 4 
1119
            sk_assert(u_in->size == 4 || u_in->size == 8
1116
                      || u_in->size == 8 || u_in->size == 16);
1120
                      || u_in->size == 16 || u_in->size == 512);
1117
1121
1118
            t_size = INVALID_TEMPREG;
1122
            t_size = INVALID_TEMPREG;
1119
            is_load = u_in->opcode==SSE2a_MemRd 
1123
            is_load = u_in->opcode==SSE2a_MemRd 
1120
                      || u_in->opcode==SSE3a_MemRd
1124
                      || u_in->opcode==SSE3a_MemRd
1125
                      || u_in->opcode==SSE2a1_MemRd
1121
                      || u_in->opcode==SSE3a1_MemRd;
1126
                      || u_in->opcode==SSE3a1_MemRd;
1122
1127
1123
            sk_assert(u_in->tag3 == TempReg);
1128
            sk_assert(u_in->tag3 == TempReg);
Lines 1491-1497 Link Here
1491
               case Tag_ImproveAND1_TQ:
1496
               case Tag_ImproveAND1_TQ:
1492
                  sz = 1; goto do_ImproveAND;
1497
                  sz = 1; goto do_ImproveAND;
1493
               do_ImproveAND:
1498
               do_ImproveAND:
1494
                  /* Implements Q = T OR Q.  So if Q is entirely defined,
1499
                  /* Implements Q = T AND Q.  So if Q is entirely defined,
1495
                     ie all 0s, we get MOV T, Q. */
1500
                     ie all 0s, we get MOV T, Q. */
1496
		  if (def[u->val2] <= 4) {
1501
		  if (def[u->val2] <= 4) {
1497
                     sk_assert(def[u->val2] == sz);
1502
                     sk_assert(def[u->val2] == sz);
(-)valgrind-2.1.0/memcheck/memcheck.h (-3 / +6 lines)
Lines 12-18 Link Here
12
   This file is part of MemCheck, a heavyweight Valgrind tool for
12
   This file is part of MemCheck, a heavyweight Valgrind tool for
13
   detecting memory errors.
13
   detecting memory errors.
14
14
15
   Copyright (C) 2002-2003 Julian Seward.  All rights reserved.
15
   Copyright (C) 2000-2004 Julian Seward.  All rights reserved.
16
16
17
   Redistribution and use in source and binary forms, with or without
17
   Redistribution and use in source and binary forms, with or without
18
   modification, are permitted provided that the following conditions
18
   modification, are permitted provided that the following conditions
Lines 82-95 Link Here
82
      VG_USERREQ__COUNT_LEAKS,
82
      VG_USERREQ__COUNT_LEAKS,
83
83
84
      /* These two have been moved into core, because they are useful for
84
      /* These two have been moved into core, because they are useful for
85
         any skin that tracks heap blocks.  Hence the suffix.  But they're
85
         any tool that tracks heap blocks.  Hence the suffix.  But they're
86
         still here for backwards compatibility, although Valgrind will
86
         still here for backwards compatibility, although Valgrind will
87
         abort with an explanatory message if you use them. */
87
         abort with an explanatory message if you use them. */
88
      VG_USERREQ__MALLOCLIKE_BLOCK__OLD_DO_NOT_USE,
88
      VG_USERREQ__MALLOCLIKE_BLOCK__OLD_DO_NOT_USE,
89
      VG_USERREQ__FREELIKE_BLOCK__OLD_DO_NOT_USE,
89
      VG_USERREQ__FREELIKE_BLOCK__OLD_DO_NOT_USE,
90
90
91
      VG_USERREQ__GET_VBITS,
91
      VG_USERREQ__GET_VBITS,
92
      VG_USERREQ__SET_VBITS
92
      VG_USERREQ__SET_VBITS,
93
94
      /* This is just for memcheck's internal use - don't use it */
95
      _VG_USERREQ__MEMCHECK_GET_RECORD_OVERLAP = VG_USERREQ_SKIN_BASE('M','C')+256,
93
   } Vg_MemCheckClientRequest;
96
   } Vg_MemCheckClientRequest;
94
97
95
98
(-)valgrind-2.1.0/memcheck/tests/.cvsignore (+58 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
3
badaddrvalue
4
badfree
5
badjump
6
badloop
7
buflen_check
8
clientperm
9
clientstackperm
10
custom_alloc
11
dir
12
doublefree
13
error_counts
14
errs1
15
exitprog
16
filter_leak_check_size
17
filter_stderr
18
fprw
19
fwrite
20
inits
21
inline
22
malloc1
23
malloc2
24
malloc3
25
manuel1
26
manuel2
27
manuel3
28
memalign_test
29
memcmptest
30
mismatches
31
mmaptest
32
nanoleak
33
new_override
34
null_socket
35
overlap
36
pushfpopf
37
realloc1
38
realloc2
39
sigaltstack
40
signal2
41
supp1
42
supp2
43
suppfree
44
trivialleak
45
tronical
46
weirdioctl
47
*.stdout.diff
48
*.stderr.diff
49
*.stdout.out
50
*.stderr.out
51
badrw
52
brk
53
metadata
54
new_nothrow
55
realloc3
56
threadederrno
57
writev
58
zeropage
(-)valgrind-2.1.0/memcheck/tests/CVS/Entries (+177 lines)
Line 0 Link Here
1
/.cvsignore/1.8/Sat Jan  3 15:22:09 2004//
2
/Makefile.am/1.30/Tue Dec  2 14:56:04 2003//
3
/badaddrvalue.c/1.2/Mon Sep 23 09:36:25 2002//
4
/badaddrvalue.stderr.exp/1.8/Thu Nov 13 17:53:43 2003//
5
/badaddrvalue.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
6
/badaddrvalue.vgtest/1.3/Sun Jul  6 23:24:18 2003//
7
/badfree-2trace.stderr.exp/1.5/Thu Nov 13 17:53:43 2003//
8
/badfree-2trace.vgtest/1.3/Sun Jul  6 23:43:01 2003//
9
/badfree.c/1.2/Mon Sep 23 09:36:25 2002//
10
/badfree.stderr.exp/1.9/Thu Nov 13 17:53:43 2003//
11
/badfree.vgtest/1.3/Sun Jul  6 23:43:01 2003//
12
/badjump.c/1.2/Mon Sep 23 09:36:25 2002//
13
/badjump.stderr.exp/1.7/Tue Dec 16 02:05:15 2003//
14
/badjump.vgtest/1.2/Mon Sep 23 09:36:25 2002//
15
/badloop.c/1.2/Mon Sep 23 09:36:25 2002//
16
/badloop.stderr.exp/1.6/Thu Nov 13 17:35:04 2003//
17
/badloop.vgtest/1.3/Sun Jul  6 23:43:01 2003//
18
/badrw.c/1.2/Wed Jan  7 08:47:03 2004//
19
/badrw.stderr.exp/1.4/Wed Jan  7 08:47:03 2004//
20
/badrw.vgtest/1.1/Fri Sep  5 23:29:33 2003//
21
/brk.c/1.1/Thu Sep  4 20:57:51 2003//
22
/brk.stderr.exp/1.1/Thu Sep  4 20:57:51 2003//
23
/brk.vgtest/1.1/Thu Sep  4 20:57:51 2003//
24
/buflen_check.c/1.2/Mon Sep 23 09:36:25 2002//
25
/buflen_check.stderr.exp/1.7/Thu Nov 13 17:53:43 2003//
26
/buflen_check.vgtest/1.3/Sun Jul  6 23:43:01 2003//
27
/clientperm.c/1.1/Fri Oct  4 14:16:35 2002//
28
/clientperm.stderr.exp/1.5/Thu Nov 13 17:35:04 2003//
29
/clientperm.stdout.exp/1.1/Fri Oct  4 14:16:35 2002//
30
/clientperm.vgtest/1.2/Sun Jul  6 23:43:01 2003//
31
/custom_alloc.c/1.2/Sat Jan  3 14:18:02 2004//
32
/custom_alloc.stderr.exp/1.4/Thu Nov 13 17:53:43 2003//
33
/custom_alloc.vgtest/1.2/Sun Jul  6 23:43:01 2003//
34
/doublefree.c/1.2/Mon Sep 23 09:36:25 2002//
35
/doublefree.stderr.exp/1.9/Thu Nov 13 17:53:43 2003//
36
/doublefree.vgtest/1.3/Mon Jul  7 00:23:23 2003//
37
/error_counts.c/1.4/Tue Jul 22 22:03:58 2003//
38
/error_counts.stderr.exp/1.1/Mon Apr 21 13:24:40 2003//
39
/error_counts.stdout.exp/1.1/Mon Apr 21 13:24:40 2003//
40
/error_counts.vgtest/1.1/Mon Apr 21 13:24:40 2003//
41
/errs1.c/1.2/Mon Sep 23 09:36:25 2002//
42
/errs1.stderr.exp/1.5/Thu Nov 13 17:53:43 2003//
43
/errs1.vgtest/1.3/Sun Jul 13 22:35:55 2003//
44
/exitprog.c/1.3/Mon Jul  7 00:32:44 2003//
45
/exitprog.stderr.exp/1.10/Thu Nov 13 17:53:43 2003//
46
/exitprog.vgtest/1.3/Mon Jul  7 00:23:23 2003//
47
/filter_allocs/1.3/Sat Jan  3 14:18:02 2004//
48
/filter_leak_check_size/1.4/Sat Jan  3 14:18:02 2004//
49
/filter_pushfpopf/1.2/Mon May  5 16:18:51 2003//
50
/filter_stderr/1.9/Sat Jan  3 14:18:02 2004//
51
/filter_stderr_backtrace/1.1/Thu Apr 24 00:40:38 2003//
52
/filter_tronical/1.2/Mon May  5 16:18:51 2003//
53
/fprw.c/1.2/Mon Sep 23 09:36:25 2002//
54
/fprw.stderr.exp/1.9/Thu Nov 13 17:53:43 2003//
55
/fprw.vgtest/1.4/Tue Dec 16 02:05:15 2003//
56
/fwrite.c/1.2/Mon Sep 23 09:36:25 2002//
57
/fwrite.stderr.exp/1.9/Mon Dec 15 09:00:21 2003//
58
/fwrite.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
59
/fwrite.vgtest/1.3/Mon Jul  7 00:23:23 2003//
60
/inits.c/1.2/Mon Sep 23 09:36:25 2002//
61
/inits.stderr.exp/1.6/Thu Nov 13 17:35:04 2003//
62
/inits.vgtest/1.3/Mon Jul  7 00:23:23 2003//
63
/inline.c/1.2/Mon Sep 23 09:36:25 2002//
64
/inline.stderr.exp/1.9/Thu Nov 13 17:53:43 2003//
65
/inline.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
66
/inline.vgtest/1.3/Mon Jul  7 00:23:23 2003//
67
/malloc1.c/1.2/Mon Sep 23 09:36:25 2002//
68
/malloc1.stderr.exp/1.9/Thu Nov 13 17:53:43 2003//
69
/malloc1.vgtest/1.3/Mon Jul  7 00:23:23 2003//
70
/malloc2.c/1.2/Mon Sep 23 09:36:25 2002//
71
/malloc2.stderr.exp/1.9/Thu Nov 13 17:53:43 2003//
72
/malloc2.vgtest/1.3/Mon Jul  7 00:23:23 2003//
73
/malloc3.c/1.1/Tue Apr 15 13:03:20 2003//
74
/malloc3.stderr.exp/1.2/Mon Jul  7 00:23:23 2003//
75
/malloc3.stdout.exp/1.1/Tue Apr 15 13:03:20 2003//
76
/malloc3.vgtest/1.2/Mon Jul  7 00:23:23 2003//
77
/manuel1.c/1.2/Mon Sep 23 09:36:25 2002//
78
/manuel1.stderr.exp/1.6/Thu Nov 13 17:35:04 2003//
79
/manuel1.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
80
/manuel1.vgtest/1.3/Mon Jul  7 00:43:34 2003//
81
/manuel2.c/1.3/Sat Jan  3 14:18:02 2004//
82
/manuel2.stderr.exp/1.6/Thu Nov 13 17:35:04 2003//
83
/manuel2.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
84
/manuel2.vgtest/1.3/Mon Jul  7 00:43:34 2003//
85
/manuel3.c/1.3/Sat Jan  3 14:18:02 2004//
86
/manuel3.stderr.exp/1.6/Thu Nov 13 17:35:04 2003//
87
/manuel3.vgtest/1.3/Mon Jul  7 00:43:34 2003//
88
/memalign_test.c/1.2/Mon Sep 23 09:36:25 2002//
89
/memalign_test.stderr.exp/1.9/Thu Nov 13 17:53:43 2003//
90
/memalign_test.vgtest/1.3/Mon Jul  7 00:43:34 2003//
91
/memcmptest.c/1.2/Mon Sep 23 09:36:25 2002//
92
/memcmptest.stderr.exp/1.7/Thu Nov 13 17:35:04 2003//
93
/memcmptest.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
94
/memcmptest.vgtest/1.3/Mon Jul  7 00:43:34 2003//
95
/metadata.c/1.2/Sat Jan  3 14:18:02 2004//
96
/metadata.stderr.exp/1.2/Thu Nov 13 17:35:04 2003//
97
/metadata.stdout.exp/1.1/Mon Jul  7 00:03:52 2003//
98
/metadata.vgtest/1.1/Mon Jul  7 00:03:52 2003//
99
/mismatches.cpp/1.2/Mon Sep 23 09:36:25 2002//
100
/mismatches.stderr.exp/1.10/Thu Nov 13 17:53:43 2003//
101
/mismatches.vgtest/1.5/Tue Sep 30 16:52:47 2003//
102
/mmaptest.c/1.2/Mon Sep 23 09:36:25 2002//
103
/mmaptest.stderr.exp/1.3/Mon Jul  7 00:43:34 2003//
104
/mmaptest.vgtest/1.3/Mon Jul  7 00:43:34 2003//
105
/nanoleak.c/1.3/Sat Jan  3 14:18:02 2004//
106
/nanoleak.stderr.exp/1.9/Tue Dec  2 10:17:44 2003//
107
/nanoleak.supp/1.2/Tue Dec 16 02:05:15 2003//
108
/nanoleak.vgtest/1.3/Mon Jul  7 00:43:34 2003//
109
/nanoleak_supp.stderr.exp/1.3/Tue Dec  2 10:17:44 2003//
110
/nanoleak_supp.vgtest/1.2/Mon Jul  7 23:56:10 2003//
111
/new_nothrow.cpp/1.1/Thu Oct  9 15:40:38 2003//
112
/new_nothrow.stderr.exp/1.1/Thu Oct  9 15:40:38 2003//
113
/new_nothrow.vgtest/1.1/Thu Oct  9 15:40:38 2003//
114
/new_override.cpp/1.2/Mon Sep 23 09:36:25 2002//
115
/new_override.stderr.exp/1.6/Sun Jun  1 20:04:10 2003//
116
/new_override.vgtest/1.3/Wed Feb 26 10:16:02 2003//
117
/null_socket.c/1.1/Fri May  2 16:19:10 2003//
118
/null_socket.stderr.exp/1.2/Mon Jul  7 23:56:10 2003//
119
/null_socket.vgtest/1.2/Mon Jul  7 23:56:10 2003//
120
/overlap.c/1.3/Sun Nov  2 17:43:27 2003//
121
/overlap.stderr.exp/1.7/Thu Nov 13 17:35:04 2003//
122
/overlap.stdout.exp/1.1/Tue Apr 15 13:03:21 2003//
123
/overlap.vgtest/1.2/Mon Jul  7 23:56:10 2003//
124
/pth_once.stderr.exp/1.1/Thu Oct 30 09:11:03 2003//
125
/pth_once.stdout.exp/1.1/Thu Oct 30 09:11:03 2003//
126
/pth_once.vgtest/1.1/Thu Oct 30 09:11:03 2003//
127
/pushfpopf.stderr.exp/1.7/Thu Nov 13 17:35:04 2003//
128
/pushfpopf.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
129
/pushfpopf.vgtest/1.4/Mon Jul  7 23:56:10 2003//
130
/pushfpopf_c.c/1.2/Mon Sep 23 09:36:25 2002//
131
/pushfpopf_s.s/1.2/Mon Sep 23 09:36:25 2002//
132
/realloc1.c/1.3/Mon Jul  7 23:56:10 2003//
133
/realloc1.stderr.exp/1.3/Mon Jul  7 23:56:10 2003//
134
/realloc1.vgtest/1.3/Mon Jul  7 23:56:10 2003//
135
/realloc2.c/1.3/Sat Jan  3 14:18:02 2004//
136
/realloc2.stderr.exp/1.3/Mon Jul  7 23:56:10 2003//
137
/realloc2.vgtest/1.3/Mon Jul  7 23:56:10 2003//
138
/realloc3.c/1.1/Thu Jul 24 17:39:59 2003//
139
/realloc3.stderr.exp/1.3/Thu Nov 13 17:53:43 2003//
140
/realloc3.vgtest/1.1/Thu Jul 24 17:39:59 2003//
141
/sigaltstack.c/1.7/Sat Jan  3 14:18:02 2004//
142
/sigaltstack.stderr.exp/1.8/Tue Dec 16 02:05:15 2003//
143
/sigaltstack.vgtest/1.4/Mon Jul  7 23:56:10 2003//
144
/signal2.c/1.2/Mon Sep 23 09:36:25 2002//
145
/signal2.stderr.exp/1.8/Thu Nov 13 17:53:43 2003//
146
/signal2.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
147
/signal2.vgtest/1.3/Mon Jul  7 23:56:10 2003//
148
/supp.c/1.3/Mon Jul  7 23:56:10 2003//
149
/supp.supp/1.5/Mon Oct  7 14:46:07 2002//
150
/supp1.stderr.exp/1.3/Mon Jul  7 23:56:10 2003//
151
/supp1.vgtest/1.3/Mon Jul  7 23:56:10 2003//
152
/supp2.stderr.exp/1.6/Thu Nov 13 17:35:04 2003//
153
/supp2.vgtest/1.3/Mon Jul  7 23:56:10 2003//
154
/suppfree.c/1.2/Mon Sep 23 09:36:25 2002//
155
/suppfree.stderr.exp/1.5/Thu Nov 13 17:53:43 2003//
156
/suppfree.vgtest/1.3/Mon Jul  7 23:56:10 2003//
157
/threadederrno.c/1.4/Wed Jan 21 17:40:16 2004//
158
/threadederrno.stderr.exp/1.2/Tue Dec 16 02:05:15 2003//
159
/threadederrno.stdout.exp/1.4/Wed Jan 21 17:40:16 2004//
160
/threadederrno.vgtest/1.1/Sun Jul 13 11:13:37 2003//
161
/trivialleak.c/1.2/Mon Sep 23 09:36:25 2002//
162
/trivialleak.stderr.exp/1.8/Tue Dec  2 10:17:44 2003//
163
/trivialleak.vgtest/1.3/Mon Jul  7 23:56:10 2003//
164
/tronical.S/1.3/Sun Oct  6 00:08:57 2002//
165
/tronical.stderr.exp/1.7/Thu Nov 13 17:35:04 2003//
166
/tronical.vgtest/1.4/Mon Jul  7 23:56:10 2003//
167
/weirdioctl.c/1.2/Mon Sep 23 09:36:25 2002//
168
/weirdioctl.stderr.exp/1.8/Mon Dec 15 09:00:21 2003//
169
/weirdioctl.stdout.exp/1.3/Mon Jul  7 23:56:10 2003//
170
/weirdioctl.vgtest/1.3/Mon Jul  7 23:56:10 2003//
171
/writev.c/1.1/Fri Sep  5 23:02:38 2003//
172
/writev.stderr.exp/1.5/Mon Dec 15 09:00:21 2003//
173
/writev.vgtest/1.1/Fri Sep  5 23:02:38 2003//
174
/zeropage.c/1.2/Sat Jan  3 14:18:02 2004//
175
/zeropage.stderr.exp/1.2/Tue Dec 16 02:05:15 2003//
176
/zeropage.vgtest/1.1/Tue Dec  2 14:56:04 2003//
177
D
(-)valgrind-2.1.0/memcheck/tests/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/memcheck/tests
(-)valgrind-2.1.0/memcheck/tests/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/memcheck/tests/Makefile.in (-406 / +321 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 14-19 Link Here
14
14
15
@SET_MAKE@
15
@SET_MAKE@
16
16
17
SOURCES = $(badaddrvalue_SOURCES) $(badfree_SOURCES) $(badjump_SOURCES) $(badloop_SOURCES) $(badrw_SOURCES) $(brk_SOURCES) $(buflen_check_SOURCES) $(clientperm_SOURCES) $(custom_alloc_SOURCES) $(doublefree_SOURCES) $(error_counts_SOURCES) $(errs1_SOURCES) $(exitprog_SOURCES) $(fprw_SOURCES) $(fwrite_SOURCES) $(inits_SOURCES) $(inline_SOURCES) $(malloc1_SOURCES) $(malloc2_SOURCES) $(malloc3_SOURCES) $(manuel1_SOURCES) $(manuel2_SOURCES) $(manuel3_SOURCES) $(memalign_test_SOURCES) $(memcmptest_SOURCES) $(metadata_SOURCES) $(mismatches_SOURCES) $(mmaptest_SOURCES) $(nanoleak_SOURCES) $(new_nothrow_SOURCES) $(new_override_SOURCES) $(null_socket_SOURCES) $(overlap_SOURCES) $(pushfpopf_SOURCES) $(realloc1_SOURCES) $(realloc2_SOURCES) $(realloc3_SOURCES) $(sigaltstack_SOURCES) $(signal2_SOURCES) $(supp1_SOURCES) $(supp2_SOURCES) $(suppfree_SOURCES) $(threadederrno_SOURCES) $(trivialleak_SOURCES) $(tronical_SOURCES) $(weirdioctl_SOURCES) $(writev_SOURCES) $(zeropage_SOURCES)
18
17
srcdir = @srcdir@
19
srcdir = @srcdir@
18
top_srcdir = @top_srcdir@
20
top_srcdir = @top_srcdir@
19
VPATH = @srcdir@
21
VPATH = @srcdir@
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
23
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
24
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
25
top_builddir = ../..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
27
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
28
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
37
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
38
POST_UNINSTALL = :
38
host_triplet = @host@
39
host_triplet = @host@
40
check_PROGRAMS = badaddrvalue$(EXEEXT) badfree$(EXEEXT) \
41
	badjump$(EXEEXT) badloop$(EXEEXT) badrw$(EXEEXT) brk$(EXEEXT) \
42
	buflen_check$(EXEEXT) clientperm$(EXEEXT) \
43
	custom_alloc$(EXEEXT) doublefree$(EXEEXT) \
44
	error_counts$(EXEEXT) errs1$(EXEEXT) exitprog$(EXEEXT) \
45
	fprw$(EXEEXT) fwrite$(EXEEXT) inits$(EXEEXT) inline$(EXEEXT) \
46
	malloc1$(EXEEXT) malloc2$(EXEEXT) malloc3$(EXEEXT) \
47
	manuel1$(EXEEXT) manuel2$(EXEEXT) manuel3$(EXEEXT) \
48
	memalign_test$(EXEEXT) memcmptest$(EXEEXT) mmaptest$(EXEEXT) \
49
	nanoleak$(EXEEXT) new_nothrow$(EXEEXT) null_socket$(EXEEXT) \
50
	overlap$(EXEEXT) pushfpopf$(EXEEXT) realloc1$(EXEEXT) \
51
	realloc2$(EXEEXT) realloc3$(EXEEXT) sigaltstack$(EXEEXT) \
52
	signal2$(EXEEXT) supp1$(EXEEXT) supp2$(EXEEXT) \
53
	suppfree$(EXEEXT) trivialleak$(EXEEXT) tronical$(EXEEXT) \
54
	weirdioctl$(EXEEXT) mismatches$(EXEEXT) new_override$(EXEEXT) \
55
	metadata$(EXEEXT) threadederrno$(EXEEXT) writev$(EXEEXT) \
56
	zeropage$(EXEEXT)
57
subdir = memcheck/tests
58
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
59
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
60
am__aclocal_m4_deps = $(top_srcdir)/configure.in
61
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
62
	$(ACLOCAL_M4)
63
mkinstalldirs = $(mkdir_p)
64
CONFIG_HEADER = $(top_builddir)/config.h
65
CONFIG_CLEAN_FILES =
66
am_badaddrvalue_OBJECTS = badaddrvalue.$(OBJEXT)
67
badaddrvalue_OBJECTS = $(am_badaddrvalue_OBJECTS)
68
badaddrvalue_LDADD = $(LDADD)
69
am_badfree_OBJECTS = badfree.$(OBJEXT)
70
badfree_OBJECTS = $(am_badfree_OBJECTS)
71
badfree_LDADD = $(LDADD)
72
am_badjump_OBJECTS = badjump.$(OBJEXT)
73
badjump_OBJECTS = $(am_badjump_OBJECTS)
74
badjump_LDADD = $(LDADD)
75
am_badloop_OBJECTS = badloop.$(OBJEXT)
76
badloop_OBJECTS = $(am_badloop_OBJECTS)
77
badloop_LDADD = $(LDADD)
78
am_badrw_OBJECTS = badrw.$(OBJEXT)
79
badrw_OBJECTS = $(am_badrw_OBJECTS)
80
badrw_LDADD = $(LDADD)
81
am_brk_OBJECTS = brk.$(OBJEXT)
82
brk_OBJECTS = $(am_brk_OBJECTS)
83
brk_LDADD = $(LDADD)
84
am_buflen_check_OBJECTS = buflen_check.$(OBJEXT)
85
buflen_check_OBJECTS = $(am_buflen_check_OBJECTS)
86
buflen_check_LDADD = $(LDADD)
87
am_clientperm_OBJECTS = clientperm.$(OBJEXT)
88
clientperm_OBJECTS = $(am_clientperm_OBJECTS)
89
clientperm_LDADD = $(LDADD)
90
am_custom_alloc_OBJECTS = custom_alloc.$(OBJEXT)
91
custom_alloc_OBJECTS = $(am_custom_alloc_OBJECTS)
92
custom_alloc_LDADD = $(LDADD)
93
am_doublefree_OBJECTS = doublefree.$(OBJEXT)
94
doublefree_OBJECTS = $(am_doublefree_OBJECTS)
95
doublefree_LDADD = $(LDADD)
96
am_error_counts_OBJECTS = error_counts.$(OBJEXT)
97
error_counts_OBJECTS = $(am_error_counts_OBJECTS)
98
error_counts_LDADD = $(LDADD)
99
am_errs1_OBJECTS = errs1.$(OBJEXT)
100
errs1_OBJECTS = $(am_errs1_OBJECTS)
101
errs1_LDADD = $(LDADD)
102
am_exitprog_OBJECTS = exitprog.$(OBJEXT)
103
exitprog_OBJECTS = $(am_exitprog_OBJECTS)
104
exitprog_LDADD = $(LDADD)
105
am_fprw_OBJECTS = fprw.$(OBJEXT)
106
fprw_OBJECTS = $(am_fprw_OBJECTS)
107
fprw_LDADD = $(LDADD)
108
am_fwrite_OBJECTS = fwrite.$(OBJEXT)
109
fwrite_OBJECTS = $(am_fwrite_OBJECTS)
110
fwrite_LDADD = $(LDADD)
111
am_inits_OBJECTS = inits.$(OBJEXT)
112
inits_OBJECTS = $(am_inits_OBJECTS)
113
inits_LDADD = $(LDADD)
114
am_inline_OBJECTS = inline.$(OBJEXT)
115
inline_OBJECTS = $(am_inline_OBJECTS)
116
inline_LDADD = $(LDADD)
117
am_malloc1_OBJECTS = malloc1.$(OBJEXT)
118
malloc1_OBJECTS = $(am_malloc1_OBJECTS)
119
malloc1_LDADD = $(LDADD)
120
am_malloc2_OBJECTS = malloc2.$(OBJEXT)
121
malloc2_OBJECTS = $(am_malloc2_OBJECTS)
122
malloc2_LDADD = $(LDADD)
123
am_malloc3_OBJECTS = malloc3.$(OBJEXT)
124
malloc3_OBJECTS = $(am_malloc3_OBJECTS)
125
malloc3_LDADD = $(LDADD)
126
am_manuel1_OBJECTS = manuel1.$(OBJEXT)
127
manuel1_OBJECTS = $(am_manuel1_OBJECTS)
128
manuel1_LDADD = $(LDADD)
129
am_manuel2_OBJECTS = manuel2.$(OBJEXT)
130
manuel2_OBJECTS = $(am_manuel2_OBJECTS)
131
manuel2_LDADD = $(LDADD)
132
am_manuel3_OBJECTS = manuel3.$(OBJEXT)
133
manuel3_OBJECTS = $(am_manuel3_OBJECTS)
134
manuel3_LDADD = $(LDADD)
135
am_memalign_test_OBJECTS = memalign_test.$(OBJEXT)
136
memalign_test_OBJECTS = $(am_memalign_test_OBJECTS)
137
memalign_test_LDADD = $(LDADD)
138
am_memcmptest_OBJECTS = memcmptest.$(OBJEXT)
139
memcmptest_OBJECTS = $(am_memcmptest_OBJECTS)
140
memcmptest_LDADD = $(LDADD)
141
am_metadata_OBJECTS = metadata.$(OBJEXT)
142
metadata_OBJECTS = $(am_metadata_OBJECTS)
143
metadata_LDADD = $(LDADD)
144
am_mismatches_OBJECTS = mismatches.$(OBJEXT)
145
mismatches_OBJECTS = $(am_mismatches_OBJECTS)
146
mismatches_LDADD = $(LDADD)
147
am_mmaptest_OBJECTS = mmaptest.$(OBJEXT)
148
mmaptest_OBJECTS = $(am_mmaptest_OBJECTS)
149
mmaptest_LDADD = $(LDADD)
150
am_nanoleak_OBJECTS = nanoleak.$(OBJEXT)
151
nanoleak_OBJECTS = $(am_nanoleak_OBJECTS)
152
nanoleak_LDADD = $(LDADD)
153
am_new_nothrow_OBJECTS = new_nothrow.$(OBJEXT)
154
new_nothrow_OBJECTS = $(am_new_nothrow_OBJECTS)
155
new_nothrow_LDADD = $(LDADD)
156
am_new_override_OBJECTS = new_override.$(OBJEXT)
157
new_override_OBJECTS = $(am_new_override_OBJECTS)
158
new_override_LDADD = $(LDADD)
159
am_null_socket_OBJECTS = null_socket.$(OBJEXT)
160
null_socket_OBJECTS = $(am_null_socket_OBJECTS)
161
null_socket_LDADD = $(LDADD)
162
am_overlap_OBJECTS = overlap.$(OBJEXT)
163
overlap_OBJECTS = $(am_overlap_OBJECTS)
164
overlap_LDADD = $(LDADD)
165
am_pushfpopf_OBJECTS = pushfpopf_c.$(OBJEXT) pushfpopf_s.$(OBJEXT)
166
pushfpopf_OBJECTS = $(am_pushfpopf_OBJECTS)
167
pushfpopf_LDADD = $(LDADD)
168
am_realloc1_OBJECTS = realloc1.$(OBJEXT)
169
realloc1_OBJECTS = $(am_realloc1_OBJECTS)
170
realloc1_LDADD = $(LDADD)
171
am_realloc2_OBJECTS = realloc2.$(OBJEXT)
172
realloc2_OBJECTS = $(am_realloc2_OBJECTS)
173
realloc2_LDADD = $(LDADD)
174
am_realloc3_OBJECTS = realloc3.$(OBJEXT)
175
realloc3_OBJECTS = $(am_realloc3_OBJECTS)
176
realloc3_LDADD = $(LDADD)
177
am_sigaltstack_OBJECTS = sigaltstack.$(OBJEXT)
178
sigaltstack_OBJECTS = $(am_sigaltstack_OBJECTS)
179
sigaltstack_LDADD = $(LDADD)
180
am_signal2_OBJECTS = signal2.$(OBJEXT)
181
signal2_OBJECTS = $(am_signal2_OBJECTS)
182
signal2_LDADD = $(LDADD)
183
am_supp1_OBJECTS = supp.$(OBJEXT)
184
supp1_OBJECTS = $(am_supp1_OBJECTS)
185
supp1_LDADD = $(LDADD)
186
am_supp2_OBJECTS = supp.$(OBJEXT)
187
supp2_OBJECTS = $(am_supp2_OBJECTS)
188
supp2_LDADD = $(LDADD)
189
am_suppfree_OBJECTS = suppfree.$(OBJEXT)
190
suppfree_OBJECTS = $(am_suppfree_OBJECTS)
191
suppfree_LDADD = $(LDADD)
192
am_threadederrno_OBJECTS = threadederrno.$(OBJEXT)
193
threadederrno_OBJECTS = $(am_threadederrno_OBJECTS)
194
threadederrno_DEPENDENCIES =
195
am_trivialleak_OBJECTS = trivialleak.$(OBJEXT)
196
trivialleak_OBJECTS = $(am_trivialleak_OBJECTS)
197
trivialleak_LDADD = $(LDADD)
198
am_tronical_OBJECTS = tronical.$(OBJEXT)
199
tronical_OBJECTS = $(am_tronical_OBJECTS)
200
tronical_LDADD = $(LDADD)
201
am_weirdioctl_OBJECTS = weirdioctl.$(OBJEXT)
202
weirdioctl_OBJECTS = $(am_weirdioctl_OBJECTS)
203
weirdioctl_LDADD = $(LDADD)
204
am_writev_OBJECTS = writev.$(OBJEXT)
205
writev_OBJECTS = $(am_writev_OBJECTS)
206
writev_LDADD = $(LDADD)
207
am_zeropage_OBJECTS = zeropage.$(OBJEXT)
208
zeropage_OBJECTS = $(am_zeropage_OBJECTS)
209
zeropage_LDADD = $(LDADD)
210
SCRIPTS = $(noinst_SCRIPTS)
211
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
212
depcomp = $(SHELL) $(top_srcdir)/depcomp
213
am__depfiles_maybe = depfiles
214
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/badaddrvalue.Po \
215
@AMDEP_TRUE@	./$(DEPDIR)/badfree.Po ./$(DEPDIR)/badjump.Po \
216
@AMDEP_TRUE@	./$(DEPDIR)/badloop.Po ./$(DEPDIR)/badrw.Po \
217
@AMDEP_TRUE@	./$(DEPDIR)/brk.Po ./$(DEPDIR)/buflen_check.Po \
218
@AMDEP_TRUE@	./$(DEPDIR)/clientperm.Po \
219
@AMDEP_TRUE@	./$(DEPDIR)/custom_alloc.Po \
220
@AMDEP_TRUE@	./$(DEPDIR)/doublefree.Po \
221
@AMDEP_TRUE@	./$(DEPDIR)/error_counts.Po ./$(DEPDIR)/errs1.Po \
222
@AMDEP_TRUE@	./$(DEPDIR)/exitprog.Po ./$(DEPDIR)/fprw.Po \
223
@AMDEP_TRUE@	./$(DEPDIR)/fwrite.Po ./$(DEPDIR)/inits.Po \
224
@AMDEP_TRUE@	./$(DEPDIR)/inline.Po ./$(DEPDIR)/malloc1.Po \
225
@AMDEP_TRUE@	./$(DEPDIR)/malloc2.Po ./$(DEPDIR)/malloc3.Po \
226
@AMDEP_TRUE@	./$(DEPDIR)/manuel1.Po ./$(DEPDIR)/manuel2.Po \
227
@AMDEP_TRUE@	./$(DEPDIR)/manuel3.Po \
228
@AMDEP_TRUE@	./$(DEPDIR)/memalign_test.Po \
229
@AMDEP_TRUE@	./$(DEPDIR)/memcmptest.Po ./$(DEPDIR)/metadata.Po \
230
@AMDEP_TRUE@	./$(DEPDIR)/mismatches.Po ./$(DEPDIR)/mmaptest.Po \
231
@AMDEP_TRUE@	./$(DEPDIR)/nanoleak.Po ./$(DEPDIR)/new_nothrow.Po \
232
@AMDEP_TRUE@	./$(DEPDIR)/new_override.Po \
233
@AMDEP_TRUE@	./$(DEPDIR)/null_socket.Po ./$(DEPDIR)/overlap.Po \
234
@AMDEP_TRUE@	./$(DEPDIR)/pushfpopf_c.Po ./$(DEPDIR)/realloc1.Po \
235
@AMDEP_TRUE@	./$(DEPDIR)/realloc2.Po ./$(DEPDIR)/realloc3.Po \
236
@AMDEP_TRUE@	./$(DEPDIR)/sigaltstack.Po ./$(DEPDIR)/signal2.Po \
237
@AMDEP_TRUE@	./$(DEPDIR)/supp.Po ./$(DEPDIR)/suppfree.Po \
238
@AMDEP_TRUE@	./$(DEPDIR)/threadederrno.Po \
239
@AMDEP_TRUE@	./$(DEPDIR)/trivialleak.Po \
240
@AMDEP_TRUE@	./$(DEPDIR)/weirdioctl.Po ./$(DEPDIR)/writev.Po \
241
@AMDEP_TRUE@	./$(DEPDIR)/zeropage.Po
242
CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
243
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
244
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
245
CCLD = $(CC)
246
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
247
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
248
	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
249
CXXLD = $(CXX)
250
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
251
	-o $@
252
SOURCES = $(badaddrvalue_SOURCES) $(badfree_SOURCES) \
253
	$(badjump_SOURCES) $(badloop_SOURCES) $(badrw_SOURCES) \
254
	$(brk_SOURCES) $(buflen_check_SOURCES) $(clientperm_SOURCES) \
255
	$(custom_alloc_SOURCES) $(doublefree_SOURCES) \
256
	$(error_counts_SOURCES) $(errs1_SOURCES) $(exitprog_SOURCES) \
257
	$(fprw_SOURCES) $(fwrite_SOURCES) $(inits_SOURCES) \
258
	$(inline_SOURCES) $(malloc1_SOURCES) $(malloc2_SOURCES) \
259
	$(malloc3_SOURCES) $(manuel1_SOURCES) $(manuel2_SOURCES) \
260
	$(manuel3_SOURCES) $(memalign_test_SOURCES) \
261
	$(memcmptest_SOURCES) $(metadata_SOURCES) \
262
	$(mismatches_SOURCES) $(mmaptest_SOURCES) $(nanoleak_SOURCES) \
263
	$(new_nothrow_SOURCES) $(new_override_SOURCES) \
264
	$(null_socket_SOURCES) $(overlap_SOURCES) $(pushfpopf_SOURCES) \
265
	$(realloc1_SOURCES) $(realloc2_SOURCES) $(realloc3_SOURCES) \
266
	$(sigaltstack_SOURCES) $(signal2_SOURCES) $(supp1_SOURCES) \
267
	$(supp2_SOURCES) $(suppfree_SOURCES) $(threadederrno_SOURCES) \
268
	$(trivialleak_SOURCES) $(tronical_SOURCES) \
269
	$(weirdioctl_SOURCES) $(writev_SOURCES) $(zeropage_SOURCES)
270
DIST_SOURCES = $(badaddrvalue_SOURCES) $(badfree_SOURCES) \
271
	$(badjump_SOURCES) $(badloop_SOURCES) $(badrw_SOURCES) \
272
	$(brk_SOURCES) $(buflen_check_SOURCES) $(clientperm_SOURCES) \
273
	$(custom_alloc_SOURCES) $(doublefree_SOURCES) \
274
	$(error_counts_SOURCES) $(errs1_SOURCES) $(exitprog_SOURCES) \
275
	$(fprw_SOURCES) $(fwrite_SOURCES) $(inits_SOURCES) \
276
	$(inline_SOURCES) $(malloc1_SOURCES) $(malloc2_SOURCES) \
277
	$(malloc3_SOURCES) $(manuel1_SOURCES) $(manuel2_SOURCES) \
278
	$(manuel3_SOURCES) $(memalign_test_SOURCES) \
279
	$(memcmptest_SOURCES) $(metadata_SOURCES) \
280
	$(mismatches_SOURCES) $(mmaptest_SOURCES) $(nanoleak_SOURCES) \
281
	$(new_nothrow_SOURCES) $(new_override_SOURCES) \
282
	$(null_socket_SOURCES) $(overlap_SOURCES) $(pushfpopf_SOURCES) \
283
	$(realloc1_SOURCES) $(realloc2_SOURCES) $(realloc3_SOURCES) \
284
	$(sigaltstack_SOURCES) $(signal2_SOURCES) $(supp1_SOURCES) \
285
	$(supp2_SOURCES) $(suppfree_SOURCES) $(threadederrno_SOURCES) \
286
	$(trivialleak_SOURCES) $(tronical_SOURCES) \
287
	$(weirdioctl_SOURCES) $(writev_SOURCES) $(zeropage_SOURCES)
288
ETAGS = etags
289
CTAGS = ctags
290
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
291
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
292
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
293
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
344
SHELL = @SHELL@
93
STRIP = @STRIP@
345
STRIP = @STRIP@
94
VERSION = @VERSION@
346
VERSION = @VERSION@
347
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
348
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
349
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
350
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
376
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
377
localstatedir = @localstatedir@
125
mandir = @mandir@
378
mandir = @mandir@
379
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
380
oldincludedir = @oldincludedir@
127
prefix = @prefix@
381
prefix = @prefix@
128
program_transform_name = @program_transform_name@
382
program_transform_name = @program_transform_name@
Lines 130-141 Link Here
130
sharedstatedir = @sharedstatedir@
384
sharedstatedir = @sharedstatedir@
131
sysconfdir = @sysconfdir@
385
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
386
target_alias = @target_alias@
133
134
noinst_SCRIPTS = filter_allocs filter_leak_check_size \
387
noinst_SCRIPTS = filter_allocs filter_leak_check_size \
135
		 filter_stderr filter_stderr_backtrace filter_pushfpopf \
388
		 filter_stderr filter_stderr_backtrace filter_pushfpopf \
136
		 filter_tronical
389
		 filter_tronical
137
390
138
139
EXTRA_DIST = $(noinst_SCRIPTS) \
391
EXTRA_DIST = $(noinst_SCRIPTS) \
140
	badaddrvalue.stderr.exp \
392
	badaddrvalue.stderr.exp \
141
	badaddrvalue.stdout.exp badaddrvalue.vgtest \
393
	badaddrvalue.stdout.exp badaddrvalue.vgtest \
Lines 194-212 Link Here
194
	writev.stderr.exp writev.vgtest \
446
	writev.stderr.exp writev.vgtest \
195
	zeropage.stderr.exp zeropage.vgtest
447
	zeropage.stderr.exp zeropage.vgtest
196
448
197
198
check_PROGRAMS = \
199
	badaddrvalue badfree badjump badloop badrw brk buflen_check \
200
	clientperm custom_alloc \
201
	doublefree error_counts errs1 exitprog fprw fwrite inits inline \
202
	malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
203
	memalign_test memcmptest mmaptest nanoleak new_nothrow null_socket \
204
	overlap pushfpopf \
205
	realloc1 realloc2 realloc3 sigaltstack signal2 supp1 supp2 suppfree \
206
	trivialleak tronical weirdioctl	\
207
	mismatches new_override metadata threadederrno writev zeropage
208
209
210
AM_CPPFLAGS = -I$(top_srcdir)/include
449
AM_CPPFLAGS = -I$(top_srcdir)/include
211
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g 
450
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g 
212
AM_CXXFLAGS = $(AM_CFLAGS)
451
AM_CXXFLAGS = $(AM_CFLAGS)
Lines 263-601 Link Here
263
mismatches_SOURCES = mismatches.cpp
502
mismatches_SOURCES = mismatches.cpp
264
new_nothrow_SOURCES = new_nothrow.cpp
503
new_nothrow_SOURCES = new_nothrow.cpp
265
new_override_SOURCES = new_override.cpp
504
new_override_SOURCES = new_override.cpp
266
subdir = memcheck/tests
267
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
268
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
269
CONFIG_HEADER = $(top_builddir)/config.h
270
CONFIG_CLEAN_FILES =
271
check_PROGRAMS = badaddrvalue$(EXEEXT) badfree$(EXEEXT) badjump$(EXEEXT) \
272
	badloop$(EXEEXT) badrw$(EXEEXT) brk$(EXEEXT) \
273
	buflen_check$(EXEEXT) clientperm$(EXEEXT) custom_alloc$(EXEEXT) \
274
	doublefree$(EXEEXT) error_counts$(EXEEXT) errs1$(EXEEXT) \
275
	exitprog$(EXEEXT) fprw$(EXEEXT) fwrite$(EXEEXT) inits$(EXEEXT) \
276
	inline$(EXEEXT) malloc1$(EXEEXT) malloc2$(EXEEXT) \
277
	malloc3$(EXEEXT) manuel1$(EXEEXT) manuel2$(EXEEXT) \
278
	manuel3$(EXEEXT) memalign_test$(EXEEXT) memcmptest$(EXEEXT) \
279
	mmaptest$(EXEEXT) nanoleak$(EXEEXT) new_nothrow$(EXEEXT) \
280
	null_socket$(EXEEXT) overlap$(EXEEXT) pushfpopf$(EXEEXT) \
281
	realloc1$(EXEEXT) realloc2$(EXEEXT) realloc3$(EXEEXT) \
282
	sigaltstack$(EXEEXT) signal2$(EXEEXT) supp1$(EXEEXT) \
283
	supp2$(EXEEXT) suppfree$(EXEEXT) trivialleak$(EXEEXT) \
284
	tronical$(EXEEXT) weirdioctl$(EXEEXT) mismatches$(EXEEXT) \
285
	new_override$(EXEEXT) metadata$(EXEEXT) threadederrno$(EXEEXT) \
286
	writev$(EXEEXT) zeropage$(EXEEXT)
287
am_badaddrvalue_OBJECTS = badaddrvalue.$(OBJEXT)
288
badaddrvalue_OBJECTS = $(am_badaddrvalue_OBJECTS)
289
badaddrvalue_LDADD = $(LDADD)
290
badaddrvalue_DEPENDENCIES =
291
badaddrvalue_LDFLAGS =
292
am_badfree_OBJECTS = badfree.$(OBJEXT)
293
badfree_OBJECTS = $(am_badfree_OBJECTS)
294
badfree_LDADD = $(LDADD)
295
badfree_DEPENDENCIES =
296
badfree_LDFLAGS =
297
am_badjump_OBJECTS = badjump.$(OBJEXT)
298
badjump_OBJECTS = $(am_badjump_OBJECTS)
299
badjump_LDADD = $(LDADD)
300
badjump_DEPENDENCIES =
301
badjump_LDFLAGS =
302
am_badloop_OBJECTS = badloop.$(OBJEXT)
303
badloop_OBJECTS = $(am_badloop_OBJECTS)
304
badloop_LDADD = $(LDADD)
305
badloop_DEPENDENCIES =
306
badloop_LDFLAGS =
307
am_badrw_OBJECTS = badrw.$(OBJEXT)
308
badrw_OBJECTS = $(am_badrw_OBJECTS)
309
badrw_LDADD = $(LDADD)
310
badrw_DEPENDENCIES =
311
badrw_LDFLAGS =
312
am_brk_OBJECTS = brk.$(OBJEXT)
313
brk_OBJECTS = $(am_brk_OBJECTS)
314
brk_LDADD = $(LDADD)
315
brk_DEPENDENCIES =
316
brk_LDFLAGS =
317
am_buflen_check_OBJECTS = buflen_check.$(OBJEXT)
318
buflen_check_OBJECTS = $(am_buflen_check_OBJECTS)
319
buflen_check_LDADD = $(LDADD)
320
buflen_check_DEPENDENCIES =
321
buflen_check_LDFLAGS =
322
am_clientperm_OBJECTS = clientperm.$(OBJEXT)
323
clientperm_OBJECTS = $(am_clientperm_OBJECTS)
324
clientperm_LDADD = $(LDADD)
325
clientperm_DEPENDENCIES =
326
clientperm_LDFLAGS =
327
am_custom_alloc_OBJECTS = custom_alloc.$(OBJEXT)
328
custom_alloc_OBJECTS = $(am_custom_alloc_OBJECTS)
329
custom_alloc_LDADD = $(LDADD)
330
custom_alloc_DEPENDENCIES =
331
custom_alloc_LDFLAGS =
332
am_doublefree_OBJECTS = doublefree.$(OBJEXT)
333
doublefree_OBJECTS = $(am_doublefree_OBJECTS)
334
doublefree_LDADD = $(LDADD)
335
doublefree_DEPENDENCIES =
336
doublefree_LDFLAGS =
337
am_error_counts_OBJECTS = error_counts.$(OBJEXT)
338
error_counts_OBJECTS = $(am_error_counts_OBJECTS)
339
error_counts_LDADD = $(LDADD)
340
error_counts_DEPENDENCIES =
341
error_counts_LDFLAGS =
342
am_errs1_OBJECTS = errs1.$(OBJEXT)
343
errs1_OBJECTS = $(am_errs1_OBJECTS)
344
errs1_LDADD = $(LDADD)
345
errs1_DEPENDENCIES =
346
errs1_LDFLAGS =
347
am_exitprog_OBJECTS = exitprog.$(OBJEXT)
348
exitprog_OBJECTS = $(am_exitprog_OBJECTS)
349
exitprog_LDADD = $(LDADD)
350
exitprog_DEPENDENCIES =
351
exitprog_LDFLAGS =
352
am_fprw_OBJECTS = fprw.$(OBJEXT)
353
fprw_OBJECTS = $(am_fprw_OBJECTS)
354
fprw_LDADD = $(LDADD)
355
fprw_DEPENDENCIES =
356
fprw_LDFLAGS =
357
am_fwrite_OBJECTS = fwrite.$(OBJEXT)
358
fwrite_OBJECTS = $(am_fwrite_OBJECTS)
359
fwrite_LDADD = $(LDADD)
360
fwrite_DEPENDENCIES =
361
fwrite_LDFLAGS =
362
am_inits_OBJECTS = inits.$(OBJEXT)
363
inits_OBJECTS = $(am_inits_OBJECTS)
364
inits_LDADD = $(LDADD)
365
inits_DEPENDENCIES =
366
inits_LDFLAGS =
367
am_inline_OBJECTS = inline.$(OBJEXT)
368
inline_OBJECTS = $(am_inline_OBJECTS)
369
inline_LDADD = $(LDADD)
370
inline_DEPENDENCIES =
371
inline_LDFLAGS =
372
am_malloc1_OBJECTS = malloc1.$(OBJEXT)
373
malloc1_OBJECTS = $(am_malloc1_OBJECTS)
374
malloc1_LDADD = $(LDADD)
375
malloc1_DEPENDENCIES =
376
malloc1_LDFLAGS =
377
am_malloc2_OBJECTS = malloc2.$(OBJEXT)
378
malloc2_OBJECTS = $(am_malloc2_OBJECTS)
379
malloc2_LDADD = $(LDADD)
380
malloc2_DEPENDENCIES =
381
malloc2_LDFLAGS =
382
am_malloc3_OBJECTS = malloc3.$(OBJEXT)
383
malloc3_OBJECTS = $(am_malloc3_OBJECTS)
384
malloc3_LDADD = $(LDADD)
385
malloc3_DEPENDENCIES =
386
malloc3_LDFLAGS =
387
am_manuel1_OBJECTS = manuel1.$(OBJEXT)
388
manuel1_OBJECTS = $(am_manuel1_OBJECTS)
389
manuel1_LDADD = $(LDADD)
390
manuel1_DEPENDENCIES =
391
manuel1_LDFLAGS =
392
am_manuel2_OBJECTS = manuel2.$(OBJEXT)
393
manuel2_OBJECTS = $(am_manuel2_OBJECTS)
394
manuel2_LDADD = $(LDADD)
395
manuel2_DEPENDENCIES =
396
manuel2_LDFLAGS =
397
am_manuel3_OBJECTS = manuel3.$(OBJEXT)
398
manuel3_OBJECTS = $(am_manuel3_OBJECTS)
399
manuel3_LDADD = $(LDADD)
400
manuel3_DEPENDENCIES =
401
manuel3_LDFLAGS =
402
am_memalign_test_OBJECTS = memalign_test.$(OBJEXT)
403
memalign_test_OBJECTS = $(am_memalign_test_OBJECTS)
404
memalign_test_LDADD = $(LDADD)
405
memalign_test_DEPENDENCIES =
406
memalign_test_LDFLAGS =
407
am_memcmptest_OBJECTS = memcmptest.$(OBJEXT)
408
memcmptest_OBJECTS = $(am_memcmptest_OBJECTS)
409
memcmptest_LDADD = $(LDADD)
410
memcmptest_DEPENDENCIES =
411
memcmptest_LDFLAGS =
412
am_metadata_OBJECTS = metadata.$(OBJEXT)
413
metadata_OBJECTS = $(am_metadata_OBJECTS)
414
metadata_LDADD = $(LDADD)
415
metadata_DEPENDENCIES =
416
metadata_LDFLAGS =
417
am_mismatches_OBJECTS = mismatches.$(OBJEXT)
418
mismatches_OBJECTS = $(am_mismatches_OBJECTS)
419
mismatches_LDADD = $(LDADD)
420
mismatches_DEPENDENCIES =
421
mismatches_LDFLAGS =
422
am_mmaptest_OBJECTS = mmaptest.$(OBJEXT)
423
mmaptest_OBJECTS = $(am_mmaptest_OBJECTS)
424
mmaptest_LDADD = $(LDADD)
425
mmaptest_DEPENDENCIES =
426
mmaptest_LDFLAGS =
427
am_nanoleak_OBJECTS = nanoleak.$(OBJEXT)
428
nanoleak_OBJECTS = $(am_nanoleak_OBJECTS)
429
nanoleak_LDADD = $(LDADD)
430
nanoleak_DEPENDENCIES =
431
nanoleak_LDFLAGS =
432
am_new_nothrow_OBJECTS = new_nothrow.$(OBJEXT)
433
new_nothrow_OBJECTS = $(am_new_nothrow_OBJECTS)
434
new_nothrow_LDADD = $(LDADD)
435
new_nothrow_DEPENDENCIES =
436
new_nothrow_LDFLAGS =
437
am_new_override_OBJECTS = new_override.$(OBJEXT)
438
new_override_OBJECTS = $(am_new_override_OBJECTS)
439
new_override_LDADD = $(LDADD)
440
new_override_DEPENDENCIES =
441
new_override_LDFLAGS =
442
am_null_socket_OBJECTS = null_socket.$(OBJEXT)
443
null_socket_OBJECTS = $(am_null_socket_OBJECTS)
444
null_socket_LDADD = $(LDADD)
445
null_socket_DEPENDENCIES =
446
null_socket_LDFLAGS =
447
am_overlap_OBJECTS = overlap.$(OBJEXT)
448
overlap_OBJECTS = $(am_overlap_OBJECTS)
449
overlap_LDADD = $(LDADD)
450
overlap_DEPENDENCIES =
451
overlap_LDFLAGS =
452
am_pushfpopf_OBJECTS = pushfpopf_c.$(OBJEXT) pushfpopf_s.$(OBJEXT)
453
pushfpopf_OBJECTS = $(am_pushfpopf_OBJECTS)
454
pushfpopf_LDADD = $(LDADD)
455
pushfpopf_DEPENDENCIES =
456
pushfpopf_LDFLAGS =
457
am_realloc1_OBJECTS = realloc1.$(OBJEXT)
458
realloc1_OBJECTS = $(am_realloc1_OBJECTS)
459
realloc1_LDADD = $(LDADD)
460
realloc1_DEPENDENCIES =
461
realloc1_LDFLAGS =
462
am_realloc2_OBJECTS = realloc2.$(OBJEXT)
463
realloc2_OBJECTS = $(am_realloc2_OBJECTS)
464
realloc2_LDADD = $(LDADD)
465
realloc2_DEPENDENCIES =
466
realloc2_LDFLAGS =
467
am_realloc3_OBJECTS = realloc3.$(OBJEXT)
468
realloc3_OBJECTS = $(am_realloc3_OBJECTS)
469
realloc3_LDADD = $(LDADD)
470
realloc3_DEPENDENCIES =
471
realloc3_LDFLAGS =
472
am_sigaltstack_OBJECTS = sigaltstack.$(OBJEXT)
473
sigaltstack_OBJECTS = $(am_sigaltstack_OBJECTS)
474
sigaltstack_LDADD = $(LDADD)
475
sigaltstack_DEPENDENCIES =
476
sigaltstack_LDFLAGS =
477
am_signal2_OBJECTS = signal2.$(OBJEXT)
478
signal2_OBJECTS = $(am_signal2_OBJECTS)
479
signal2_LDADD = $(LDADD)
480
signal2_DEPENDENCIES =
481
signal2_LDFLAGS =
482
am_supp1_OBJECTS = supp.$(OBJEXT)
483
supp1_OBJECTS = $(am_supp1_OBJECTS)
484
supp1_LDADD = $(LDADD)
485
supp1_DEPENDENCIES =
486
supp1_LDFLAGS =
487
am_supp2_OBJECTS = supp.$(OBJEXT)
488
supp2_OBJECTS = $(am_supp2_OBJECTS)
489
supp2_LDADD = $(LDADD)
490
supp2_DEPENDENCIES =
491
supp2_LDFLAGS =
492
am_suppfree_OBJECTS = suppfree.$(OBJEXT)
493
suppfree_OBJECTS = $(am_suppfree_OBJECTS)
494
suppfree_LDADD = $(LDADD)
495
suppfree_DEPENDENCIES =
496
suppfree_LDFLAGS =
497
am_threadederrno_OBJECTS = threadederrno.$(OBJEXT)
498
threadederrno_OBJECTS = $(am_threadederrno_OBJECTS)
499
threadederrno_DEPENDENCIES =
500
threadederrno_LDFLAGS =
501
am_trivialleak_OBJECTS = trivialleak.$(OBJEXT)
502
trivialleak_OBJECTS = $(am_trivialleak_OBJECTS)
503
trivialleak_LDADD = $(LDADD)
504
trivialleak_DEPENDENCIES =
505
trivialleak_LDFLAGS =
506
am_tronical_OBJECTS = tronical.$(OBJEXT)
507
tronical_OBJECTS = $(am_tronical_OBJECTS)
508
tronical_LDADD = $(LDADD)
509
tronical_DEPENDENCIES =
510
tronical_LDFLAGS =
511
am_weirdioctl_OBJECTS = weirdioctl.$(OBJEXT)
512
weirdioctl_OBJECTS = $(am_weirdioctl_OBJECTS)
513
weirdioctl_LDADD = $(LDADD)
514
weirdioctl_DEPENDENCIES =
515
weirdioctl_LDFLAGS =
516
am_writev_OBJECTS = writev.$(OBJEXT)
517
writev_OBJECTS = $(am_writev_OBJECTS)
518
writev_LDADD = $(LDADD)
519
writev_DEPENDENCIES =
520
writev_LDFLAGS =
521
am_zeropage_OBJECTS = zeropage.$(OBJEXT)
522
zeropage_OBJECTS = $(am_zeropage_OBJECTS)
523
zeropage_LDADD = $(LDADD)
524
zeropage_DEPENDENCIES =
525
zeropage_LDFLAGS =
526
SCRIPTS = $(noinst_SCRIPTS)
527
528
529
DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
530
depcomp = $(SHELL) $(top_srcdir)/depcomp
531
am__depfiles_maybe = depfiles
532
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/badaddrvalue.Po \
533
@AMDEP_TRUE@	./$(DEPDIR)/badfree.Po ./$(DEPDIR)/badjump.Po \
534
@AMDEP_TRUE@	./$(DEPDIR)/badloop.Po ./$(DEPDIR)/badrw.Po \
535
@AMDEP_TRUE@	./$(DEPDIR)/brk.Po ./$(DEPDIR)/buflen_check.Po \
536
@AMDEP_TRUE@	./$(DEPDIR)/clientperm.Po \
537
@AMDEP_TRUE@	./$(DEPDIR)/custom_alloc.Po \
538
@AMDEP_TRUE@	./$(DEPDIR)/doublefree.Po \
539
@AMDEP_TRUE@	./$(DEPDIR)/error_counts.Po ./$(DEPDIR)/errs1.Po \
540
@AMDEP_TRUE@	./$(DEPDIR)/exitprog.Po ./$(DEPDIR)/fprw.Po \
541
@AMDEP_TRUE@	./$(DEPDIR)/fwrite.Po ./$(DEPDIR)/inits.Po \
542
@AMDEP_TRUE@	./$(DEPDIR)/inline.Po ./$(DEPDIR)/malloc1.Po \
543
@AMDEP_TRUE@	./$(DEPDIR)/malloc2.Po ./$(DEPDIR)/malloc3.Po \
544
@AMDEP_TRUE@	./$(DEPDIR)/manuel1.Po ./$(DEPDIR)/manuel2.Po \
545
@AMDEP_TRUE@	./$(DEPDIR)/manuel3.Po ./$(DEPDIR)/memalign_test.Po \
546
@AMDEP_TRUE@	./$(DEPDIR)/memcmptest.Po ./$(DEPDIR)/metadata.Po \
547
@AMDEP_TRUE@	./$(DEPDIR)/mismatches.Po ./$(DEPDIR)/mmaptest.Po \
548
@AMDEP_TRUE@	./$(DEPDIR)/nanoleak.Po ./$(DEPDIR)/new_nothrow.Po \
549
@AMDEP_TRUE@	./$(DEPDIR)/new_override.Po \
550
@AMDEP_TRUE@	./$(DEPDIR)/null_socket.Po ./$(DEPDIR)/overlap.Po \
551
@AMDEP_TRUE@	./$(DEPDIR)/pushfpopf_c.Po ./$(DEPDIR)/realloc1.Po \
552
@AMDEP_TRUE@	./$(DEPDIR)/realloc2.Po ./$(DEPDIR)/realloc3.Po \
553
@AMDEP_TRUE@	./$(DEPDIR)/sigaltstack.Po ./$(DEPDIR)/signal2.Po \
554
@AMDEP_TRUE@	./$(DEPDIR)/supp.Po ./$(DEPDIR)/suppfree.Po \
555
@AMDEP_TRUE@	./$(DEPDIR)/threadederrno.Po \
556
@AMDEP_TRUE@	./$(DEPDIR)/trivialleak.Po \
557
@AMDEP_TRUE@	./$(DEPDIR)/weirdioctl.Po ./$(DEPDIR)/writev.Po \
558
@AMDEP_TRUE@	./$(DEPDIR)/zeropage.Po
559
CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
560
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
561
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
562
CCLD = $(CC)
563
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
564
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
565
	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
566
CXXLD = $(CXX)
567
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
568
	-o $@
569
DIST_SOURCES = $(badaddrvalue_SOURCES) $(badfree_SOURCES) \
570
	$(badjump_SOURCES) $(badloop_SOURCES) $(badrw_SOURCES) \
571
	$(brk_SOURCES) $(buflen_check_SOURCES) $(clientperm_SOURCES) \
572
	$(custom_alloc_SOURCES) $(doublefree_SOURCES) \
573
	$(error_counts_SOURCES) $(errs1_SOURCES) $(exitprog_SOURCES) \
574
	$(fprw_SOURCES) $(fwrite_SOURCES) $(inits_SOURCES) \
575
	$(inline_SOURCES) $(malloc1_SOURCES) $(malloc2_SOURCES) \
576
	$(malloc3_SOURCES) $(manuel1_SOURCES) $(manuel2_SOURCES) \
577
	$(manuel3_SOURCES) $(memalign_test_SOURCES) \
578
	$(memcmptest_SOURCES) $(metadata_SOURCES) $(mismatches_SOURCES) \
579
	$(mmaptest_SOURCES) $(nanoleak_SOURCES) $(new_nothrow_SOURCES) \
580
	$(new_override_SOURCES) $(null_socket_SOURCES) \
581
	$(overlap_SOURCES) $(pushfpopf_SOURCES) $(realloc1_SOURCES) \
582
	$(realloc2_SOURCES) $(realloc3_SOURCES) $(sigaltstack_SOURCES) \
583
	$(signal2_SOURCES) $(supp1_SOURCES) $(supp2_SOURCES) \
584
	$(suppfree_SOURCES) $(threadederrno_SOURCES) \
585
	$(trivialleak_SOURCES) $(tronical_SOURCES) \
586
	$(weirdioctl_SOURCES) $(writev_SOURCES) $(zeropage_SOURCES)
587
DIST_COMMON = Makefile.am Makefile.in
588
SOURCES = $(badaddrvalue_SOURCES) $(badfree_SOURCES) $(badjump_SOURCES) $(badloop_SOURCES) $(badrw_SOURCES) $(brk_SOURCES) $(buflen_check_SOURCES) $(clientperm_SOURCES) $(custom_alloc_SOURCES) $(doublefree_SOURCES) $(error_counts_SOURCES) $(errs1_SOURCES) $(exitprog_SOURCES) $(fprw_SOURCES) $(fwrite_SOURCES) $(inits_SOURCES) $(inline_SOURCES) $(malloc1_SOURCES) $(malloc2_SOURCES) $(malloc3_SOURCES) $(manuel1_SOURCES) $(manuel2_SOURCES) $(manuel3_SOURCES) $(memalign_test_SOURCES) $(memcmptest_SOURCES) $(metadata_SOURCES) $(mismatches_SOURCES) $(mmaptest_SOURCES) $(nanoleak_SOURCES) $(new_nothrow_SOURCES) $(new_override_SOURCES) $(null_socket_SOURCES) $(overlap_SOURCES) $(pushfpopf_SOURCES) $(realloc1_SOURCES) $(realloc2_SOURCES) $(realloc3_SOURCES) $(sigaltstack_SOURCES) $(signal2_SOURCES) $(supp1_SOURCES) $(supp2_SOURCES) $(suppfree_SOURCES) $(threadederrno_SOURCES) $(trivialleak_SOURCES) $(tronical_SOURCES) $(weirdioctl_SOURCES) $(writev_SOURCES) $(zeropage_SOURCES)
589
590
all: all-am
505
all: all-am
591
506
592
.SUFFIXES:
507
.SUFFIXES:
593
.SUFFIXES: .S .c .cpp .o .obj .s
508
.SUFFIXES: .S .c .cpp .o .obj .s
594
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
509
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
510
	@for dep in $?; do \
511
	  case '$(am__configure_deps)' in \
512
	    *$$dep*) \
513
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
514
		&& exit 0; \
515
	      exit 1;; \
516
	  esac; \
517
	done; \
518
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  memcheck/tests/Makefile'; \
595
	cd $(top_srcdir) && \
519
	cd $(top_srcdir) && \
596
	  $(AUTOMAKE) --gnu  memcheck/tests/Makefile
520
	  $(AUTOMAKE) --gnu  memcheck/tests/Makefile
597
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
521
.PRECIOUS: Makefile
598
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
522
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
523
	@case '$?' in \
524
	  *config.status*) \
525
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
526
	  *) \
527
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
528
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
529
	esac;
530
531
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
532
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
533
534
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
535
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
536
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
537
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
599
538
600
clean-checkPROGRAMS:
539
clean-checkPROGRAMS:
601
	-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
540
	-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
Lines 745-751 Link Here
745
	$(LINK) $(zeropage_LDFLAGS) $(zeropage_OBJECTS) $(zeropage_LDADD) $(LIBS)
684
	$(LINK) $(zeropage_LDFLAGS) $(zeropage_OBJECTS) $(zeropage_LDADD) $(LIBS)
746
685
747
mostlyclean-compile:
686
mostlyclean-compile:
748
	-rm -f *.$(OBJEXT) core *.core
687
	-rm -f *.$(OBJEXT)
749
688
750
distclean-compile:
689
distclean-compile:
751
	-rm -f *.tab.c
690
	-rm -f *.tab.c
Lines 797-870 Link Here
797
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writev.Po@am__quote@
736
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writev.Po@am__quote@
798
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zeropage.Po@am__quote@
737
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zeropage.Po@am__quote@
799
738
800
distclean-depend:
801
	-rm -rf ./$(DEPDIR)
802
803
.S.o:
739
.S.o:
804
	$(CCASCOMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
740
	$(CCASCOMPILE) -c $<
805
741
806
.S.obj:
742
.S.obj:
807
	$(CCASCOMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
743
	$(CCASCOMPILE) -c `$(CYGPATH_W) '$<'`
808
744
809
.c.o:
745
.c.o:
810
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
746
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
811
@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
747
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
812
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
813
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
814
@am__fastdepCC_TRUE@	fi
815
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
748
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
816
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
749
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
817
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
750
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
818
@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
751
@am__fastdepCC_FALSE@	$(COMPILE) -c $<
819
752
820
.c.obj:
753
.c.obj:
821
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
754
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
822
@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
755
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
823
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
824
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
825
@am__fastdepCC_TRUE@	fi
826
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
756
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
827
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
757
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
828
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
758
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
829
@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
759
@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
830
760
831
.cpp.o:
761
.cpp.o:
832
@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
762
@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
833
@am__fastdepCXX_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
763
@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
834
@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
835
@am__fastdepCXX_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
836
@am__fastdepCXX_TRUE@	fi
837
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
764
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
838
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
765
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
839
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
766
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
840
@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
767
@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
841
768
842
.cpp.obj:
769
.cpp.obj:
843
@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
770
@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
844
@am__fastdepCXX_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
771
@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
845
@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
846
@am__fastdepCXX_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
847
@am__fastdepCXX_TRUE@	fi
848
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
772
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
849
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
773
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
850
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
774
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
851
@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
775
@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
852
776
853
.s.o:
777
.s.o:
854
	$(CCASCOMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
778
	$(CCASCOMPILE) -c $<
855
779
856
.s.obj:
780
.s.obj:
857
	$(CCASCOMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
781
	$(CCASCOMPILE) -c `$(CYGPATH_W) '$<'`
858
uninstall-info-am:
782
uninstall-info-am:
859
783
860
ETAGS = etags
861
ETAGSFLAGS =
862
863
CTAGS = ctags
864
CTAGSFLAGS =
865
866
tags: TAGS
867
868
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
784
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
869
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
785
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
870
	unique=`for i in $$list; do \
786
	unique=`for i in $$list; do \
Lines 873-878 Link Here
873
	  $(AWK) '    { files[$$0] = 1; } \
789
	  $(AWK) '    { files[$$0] = 1; } \
874
	       END { for (i in files) print i; }'`; \
790
	       END { for (i in files) print i; }'`; \
875
	mkid -fID $$unique
791
	mkid -fID $$unique
792
tags: TAGS
876
793
877
TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
794
TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
878
		$(TAGS_FILES) $(LISP)
795
		$(TAGS_FILES) $(LISP)
Lines 887-893 Link Here
887
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
804
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
888
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
805
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
889
	     $$tags $$unique
806
	     $$tags $$unique
890
891
ctags: CTAGS
807
ctags: CTAGS
892
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
808
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
893
		$(TAGS_FILES) $(LISP)
809
		$(TAGS_FILES) $(LISP)
Lines 910-919 Link Here
910
826
911
distclean-tags:
827
distclean-tags:
912
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
828
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
913
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
914
915
top_distdir = ../..
916
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
917
829
918
distdir: $(DISTFILES)
830
distdir: $(DISTFILES)
919
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
831
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 927-933 Link Here
927
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
839
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
928
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
840
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
929
	    dir="/$$dir"; \
841
	    dir="/$$dir"; \
930
	    $(mkinstalldirs) "$(distdir)$$dir"; \
842
	    $(mkdir_p) "$(distdir)$$dir"; \
931
	  else \
843
	  else \
932
	    dir=''; \
844
	    dir=''; \
933
	  fi; \
845
	  fi; \
Lines 946-952 Link Here
946
	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
858
	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
947
check: check-am
859
check: check-am
948
all-am: Makefile $(SCRIPTS)
860
all-am: Makefile $(SCRIPTS)
949
950
installdirs:
861
installdirs:
951
install: install-am
862
install: install-am
952
install-exec: install-exec-am
863
install-exec: install-exec-am
Lines 959-965 Link Here
959
installcheck: installcheck-am
870
installcheck: installcheck-am
960
install-strip:
871
install-strip:
961
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
872
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
962
	  INSTALL_STRIP_FLAG=-s \
873
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
963
	  `test -z '$(STRIP)' || \
874
	  `test -z '$(STRIP)' || \
964
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
875
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
965
mostlyclean-generic:
876
mostlyclean-generic:
Lines 967-973 Link Here
967
clean-generic:
878
clean-generic:
968
879
969
distclean-generic:
880
distclean-generic:
970
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
881
	-rm -f $(CONFIG_CLEAN_FILES)
971
882
972
maintainer-clean-generic:
883
maintainer-clean-generic:
973
	@echo "This command is intended for maintainers to use"
884
	@echo "This command is intended for maintainers to use"
Lines 977-990 Link Here
977
clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am
888
clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am
978
889
979
distclean: distclean-am
890
distclean: distclean-am
980
891
	-rm -rf ./$(DEPDIR)
981
distclean-am: clean-am distclean-compile distclean-depend \
892
	-rm -f Makefile
982
	distclean-generic distclean-tags
893
distclean-am: clean-am distclean-compile distclean-generic \
894
	distclean-tags
983
895
984
dvi: dvi-am
896
dvi: dvi-am
985
897
986
dvi-am:
898
dvi-am:
987
899
900
html: html-am
901
988
info: info-am
902
info: info-am
989
903
990
info-am:
904
info-am:
Lines 1000-1006 Link Here
1000
installcheck-am:
914
installcheck-am:
1001
915
1002
maintainer-clean: maintainer-clean-am
916
maintainer-clean: maintainer-clean-am
1003
917
	-rm -rf ./$(DEPDIR)
918
	-rm -f Makefile
1004
maintainer-clean-am: distclean-am maintainer-clean-generic
919
maintainer-clean-am: distclean-am maintainer-clean-generic
1005
920
1006
mostlyclean: mostlyclean-am
921
mostlyclean: mostlyclean-am
Lines 1017-1029 Link Here
1017
932
1018
uninstall-am: uninstall-info-am
933
uninstall-am: uninstall-info-am
1019
934
1020
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-checkPROGRAMS \
935
.PHONY: CTAGS GTAGS all all-am check check-am clean \
1021
	clean-generic ctags distclean distclean-compile \
936
	clean-checkPROGRAMS clean-generic ctags distclean \
1022
	distclean-depend distclean-generic distclean-tags distdir dvi \
937
	distclean-compile distclean-generic distclean-tags distdir dvi \
1023
	dvi-am info info-am install install-am install-data \
938
	dvi-am html html-am info info-am install install-am \
1024
	install-data-am install-exec install-exec-am install-info \
939
	install-data install-data-am install-exec install-exec-am \
1025
	install-info-am install-man install-strip installcheck \
940
	install-info install-info-am install-man install-strip \
1026
	installcheck-am installdirs maintainer-clean \
941
	installcheck installcheck-am installdirs maintainer-clean \
1027
	maintainer-clean-generic mostlyclean mostlyclean-compile \
942
	maintainer-clean-generic mostlyclean mostlyclean-compile \
1028
	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
943
	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
1029
	uninstall-am uninstall-info-am
944
	uninstall-am uninstall-info-am
(-)valgrind-2.1.0/memcheck/tests/badjump.stderr.exp (-1 / +1 lines)
Lines 6-12 Link Here
6
 Address 0x........ is not stack'd, malloc'd or free'd
6
 Address 0x........ is not stack'd, malloc'd or free'd
7
7
8
Process terminating with default action of signal 11 (SIGSEGV): dumping core
8
Process terminating with default action of signal 11 (SIGSEGV): dumping core
9
 Address not mapped to object at address 0x........
9
 Access not within mapped region at address 0x........
10
   at 0x........: ???
10
   at 0x........: ???
11
   by 0x........: __libc_start_main (...libc...)
11
   by 0x........: __libc_start_main (...libc...)
12
   by 0x........: ...
12
   by 0x........: ...
(-)valgrind-2.1.0/memcheck/tests/badrw.c (-6 / +18 lines)
Lines 4-17 Link Here
4
{
4
{
5
   void* x = malloc(10);
5
   void* x = malloc(10);
6
6
7
   int*        x4 = x-4;
7
   int   *x4;
8
   short int*  x2 = x-4;
8
   short *x2;
9
   char*       x1 = x-1;
9
   char  *x1;
10
   int    y4;
11
   short  y2;
12
   char   y1;
13
14
   x4 = x-4;
15
   x2 = x-4;
16
   x1 = x-1;
10
17
11
   // Invalid reads and writes of sizes 4, 2, 1
18
   // Invalid reads and writes of sizes 4, 2, 1
12
   int       y4 = *x4;  *x4 = y4;
19
   y4 = *x4;
13
   short int y2 = *x2;  *x2 = y2;
20
   *x4 = y4;
14
   char      y1 = *x1;  *x1 = y1;
21
22
   y2 = *x2;
23
   *x2 = y2;
24
25
   y1 = *x1;
26
   *x1 = y1;
15
   
27
   
16
   return 0;
28
   return 0;
17
}
29
}
(-)valgrind-2.1.0/memcheck/tests/badrw.stderr.exp (-6 / +6 lines)
Lines 1-35 Link Here
1
Invalid read of size 4
1
Invalid read of size 4
2
   at 0x........: main (badrw.c:12)
2
   at 0x........: main (badrw.c:19)
3
 Address 0x........ is 4 bytes before a block of size 10 alloc'd
3
 Address 0x........ is 4 bytes before a block of size 10 alloc'd
4
   at 0x........: malloc (vg_replace_malloc.c:...)
4
   at 0x........: malloc (vg_replace_malloc.c:...)
5
   by 0x........: main (badrw.c:5)
5
   by 0x........: main (badrw.c:5)
6
6
7
Invalid write of size 4
7
Invalid write of size 4
8
   at 0x........: main (badrw.c:12)
8
   at 0x........: main (badrw.c:20)
9
 Address 0x........ is 4 bytes before a block of size 10 alloc'd
9
 Address 0x........ is 4 bytes before a block of size 10 alloc'd
10
   at 0x........: malloc (vg_replace_malloc.c:...)
10
   at 0x........: malloc (vg_replace_malloc.c:...)
11
   by 0x........: main (badrw.c:5)
11
   by 0x........: main (badrw.c:5)
12
12
13
Invalid read of size 2
13
Invalid read of size 2
14
   at 0x........: main (badrw.c:13)
14
   at 0x........: main (badrw.c:22)
15
 Address 0x........ is 4 bytes before a block of size 10 alloc'd
15
 Address 0x........ is 4 bytes before a block of size 10 alloc'd
16
   at 0x........: malloc (vg_replace_malloc.c:...)
16
   at 0x........: malloc (vg_replace_malloc.c:...)
17
   by 0x........: main (badrw.c:5)
17
   by 0x........: main (badrw.c:5)
18
18
19
Invalid write of size 2
19
Invalid write of size 2
20
   at 0x........: main (badrw.c:13)
20
   at 0x........: main (badrw.c:23)
21
 Address 0x........ is 4 bytes before a block of size 10 alloc'd
21
 Address 0x........ is 4 bytes before a block of size 10 alloc'd
22
   at 0x........: malloc (vg_replace_malloc.c:...)
22
   at 0x........: malloc (vg_replace_malloc.c:...)
23
   by 0x........: main (badrw.c:5)
23
   by 0x........: main (badrw.c:5)
24
24
25
Invalid read of size 1
25
Invalid read of size 1
26
   at 0x........: main (badrw.c:14)
26
   at 0x........: main (badrw.c:25)
27
 Address 0x........ is 1 bytes before a block of size 10 alloc'd
27
 Address 0x........ is 1 bytes before a block of size 10 alloc'd
28
   at 0x........: malloc (vg_replace_malloc.c:...)
28
   at 0x........: malloc (vg_replace_malloc.c:...)
29
   by 0x........: main (badrw.c:5)
29
   by 0x........: main (badrw.c:5)
30
30
31
Invalid write of size 1
31
Invalid write of size 1
32
   at 0x........: main (badrw.c:14)
32
   at 0x........: main (badrw.c:26)
33
 Address 0x........ is 1 bytes before a block of size 10 alloc'd
33
 Address 0x........ is 1 bytes before a block of size 10 alloc'd
34
   at 0x........: malloc (vg_replace_malloc.c:...)
34
   at 0x........: malloc (vg_replace_malloc.c:...)
35
   by 0x........: main (badrw.c:5)
35
   by 0x........: main (badrw.c:5)
(-)valgrind-2.1.0/memcheck/tests/custom_alloc.c (-1 / +1 lines)
Lines 14-20 Link Here
14
void* get_superblock(void)
14
void* get_superblock(void)
15
{
15
{
16
   void* p = mmap( 0, SUPERBLOCK_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC,
16
   void* p = mmap( 0, SUPERBLOCK_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC,
17
                   MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
17
                   MAP_PRIVATE|MAP_ANON, -1, 0 );
18
18
19
   assert(p != ((void*)(-1)));
19
   assert(p != ((void*)(-1)));
20
20
(-)valgrind-2.1.0/memcheck/tests/filter_allocs (-2 / +2 lines)
Lines 1-6 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
2
3
./filter_stderr |
3
./filter_stderr |
4
sed "s/malloc\/free: in use at exit: [0-9]\+ bytes in [0-9]\+ blocks./malloc\/free: in use at exit: ... bytes in ... blocks./" |
4
sed "s/malloc\/free: in use at exit: [0-9]* bytes in [0-9]* blocks./malloc\/free: in use at exit: ... bytes in ... blocks./" |
5
sed "s/malloc.free: [0-9]\+ allocs, [0-9]\+ frees, [0-9]\+ bytes allocated./malloc\/free: ... allocs, ... frees, ... bytes allocated./"
5
sed "s/malloc.free: [0-9]* allocs, [0-9]* frees, [0-9]* bytes allocated./malloc\/free: ... allocs, ... frees, ... bytes allocated./"
6
6
(-)valgrind-2.1.0/memcheck/tests/filter_leak_check_size (-1 / +1 lines)
Lines 1-4 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
2
3
./filter_stderr |
3
./filter_stderr |
4
sed "s/checked [0-9]\+ bytes./checked ... bytes./"
4
sed "s/checked [0-9]* bytes./checked ... bytes./"
(-)valgrind-2.1.0/memcheck/tests/filter_stderr (-1 / +1 lines)
Lines 8-14 Link Here
8
$dir/../../tests/filter_addresses                       |
8
$dir/../../tests/filter_addresses                       |
9
9
10
# Anonymise line numbers in mac_replace_strmem.c
10
# Anonymise line numbers in mac_replace_strmem.c
11
sed "s/mac_replace_strmem.c:[0-9]\+/mac_replace_strmem.c:.../"  |
11
sed "s/mac_replace_strmem.c:[0-9]*/mac_replace_strmem.c:.../"  |
12
12
13
$dir/../../tests/filter_test_paths                      |
13
$dir/../../tests/filter_test_paths                      |
14
14
(-)valgrind-2.1.0/memcheck/tests/fprw.vgtest (-1 / +1 lines)
Lines 1-2 Link Here
1
vgopts: --single-step=yes -q
1
vgopts: -q
2
prog:   fprw
2
prog:   fprw
(-)valgrind-2.1.0/memcheck/tests/fwrite.stderr.exp (-1 / +1 lines)
Lines 1-5 Link Here
1
Syscall param write(buf) contains uninitialised or unaddressable byte(s)
1
Syscall param write(buf) contains uninitialised or unaddressable byte(s)
2
   at 0x........: __libc_write (...libc...)
2
   at 0x........: write (in /...libc...)
3
   by 0x........: __libc_start_main (...libc...)
3
   by 0x........: __libc_start_main (...libc...)
4
   by 0x........: ...
4
   by 0x........: ...
5
 Address 0x........ is 0 bytes inside a block of size 10 alloc'd
5
 Address 0x........ is 0 bytes inside a block of size 10 alloc'd
(-)valgrind-2.1.0/memcheck/tests/manuel2.c (-1 / +1 lines)
Lines 1-5 Link Here
1
#include <stdio.h>
1
#include <stdio.h>
2
#include <malloc.h>
2
#include <stdlib.h>
3
3
4
int main ()
4
int main ()
5
{
5
{
(-)valgrind-2.1.0/memcheck/tests/manuel3.c (-1 / +1 lines)
Lines 1-5 Link Here
1
#include <stdio.h>
1
#include <stdio.h>
2
#include <malloc.h>
2
#include <stdlib.h>
3
3
4
int gcc_cant_inline_me ( int );
4
int gcc_cant_inline_me ( int );
5
5
(-)valgrind-2.1.0/memcheck/tests/metadata.c (-1 / +1 lines)
Lines 1-6 Link Here
1
1
2
#include <stdio.h>
2
#include <stdio.h>
3
#include <malloc.h>
3
#include <stdlib.h>
4
#include "../memcheck.h"
4
#include "../memcheck.h"
5
5
6
/* Program demonstrating copying of metadata in memcheck. */
6
/* Program demonstrating copying of metadata in memcheck. */
(-)valgrind-2.1.0/memcheck/tests/nanoleak.c (-1 / +1 lines)
Lines 1-5 Link Here
1
1
2
#include <malloc.h>
2
#include <stdlib.h>
3
3
4
int main ( void )
4
int main ( void )
5
{
5
{
(-)valgrind-2.1.0/memcheck/tests/nanoleak.supp (-1 lines)
Lines 3-8 Link Here
3
   Addrcheck,Memcheck:Leak
3
   Addrcheck,Memcheck:Leak
4
   fun:malloc
4
   fun:malloc
5
   fun:main
5
   fun:main
6
   fun:__libc_start_main
7
}
6
}
8
7
(-)valgrind-2.1.0/memcheck/tests/realloc2.c (-1 / +1 lines)
Lines 3-9 Link Here
3
   realloc time due to bad ordering of the things happening.  Now runs
3
   realloc time due to bad ordering of the things happening.  Now runs
4
   without error. */
4
   without error. */
5
5
6
#include <malloc.h>
6
#include <stdlib.h>
7
#include <stdio.h>
7
#include <stdio.h>
8
8
9
int main ( void )
9
int main ( void )
(-)valgrind-2.1.0/memcheck/tests/sigaltstack.c (-2 / +3 lines)
Lines 1-7 Link Here
1
1
2
2
3
#include <stdio.h>
3
#include <stdio.h>
4
#include <malloc.h>
4
#include <stdlib.h>
5
#include <signal.h>
5
#include <signal.h>
6
#include <sys/mman.h>
6
#include <sys/mman.h>
7
7
Lines 15-21 Link Here
15
  stack_t sigstk;
15
  stack_t sigstk;
16
  struct sigaction act;
16
  struct sigaction act;
17
  static const int size = SIGSTKSZ*2;
17
  static const int size = SIGSTKSZ*2;
18
  char *stk = (char *)mmap(0, size, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
18
  char *stk = (char *)mmap(0, size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
19
  sigstk.ss_sp = stk;
19
  sigstk.ss_sp = stk;
20
20
21
  sigstk.ss_size = size;
21
  sigstk.ss_size = size;
Lines 26-31 Link Here
26
  fprintf(stderr,"setting sigaction\n");
26
  fprintf(stderr,"setting sigaction\n");
27
  act.sa_flags=SA_ONSTACK;
27
  act.sa_flags=SA_ONSTACK;
28
  act.sa_handler=&sig_handler;
28
  act.sa_handler=&sig_handler;
29
  sigemptyset(&act.sa_mask);
29
  res = sigaction(SIGUSR1,&act,0);
30
  res = sigaction(SIGUSR1,&act,0);
30
  fprintf(stderr, "res = %d\n", res);
31
  fprintf(stderr, "res = %d\n", res);
31
  fprintf(stderr, "raising the signal\n");
32
  fprintf(stderr, "raising the signal\n");
(-)valgrind-2.1.0/memcheck/tests/sigaltstack.stderr.exp (-3 lines)
Lines 1-8 Link Here
1
calling sigaltstack, stack base is 0x........
1
calling sigaltstack, stack base is 0x........
2
setting sigaction
2
setting sigaction
3
Syscall param sigaction(act) contains uninitialised or unaddressable byte(s)
4
   at 0x........: __libc_sigaction (...libc...)
5
 Address 0x........ is on thread 1's stack
6
res = 0
3
res = 0
7
raising the signal
4
raising the signal
8
caught signal, local var is on 0x........
5
caught signal, local var is on 0x........
(-)valgrind-2.1.0/memcheck/tests/threadederrno.c (-7 / +4 lines)
Lines 2-23 Link Here
2
#include <pthread.h>
2
#include <pthread.h>
3
#include <stdio.h>
3
#include <stdio.h>
4
#include <errno.h>
4
#include <errno.h>
5
5
#include <string.h>
6
6
7
7
8
void* thr2 ( void* v )
8
void* thr2 ( void* v )
9
{
9
{
10
  FILE* f = fopen("bogus2", "r");
10
  FILE* f = fopen("bogus2", "r");
11
  printf("f2 = %p, errno2 = %d\n", f, errno);
11
  printf("f  = %p, errno  = %d (%s)\n", f, errno, strerror(errno));
12
  perror("wurble2");
13
  return NULL;
12
  return NULL;
14
}
13
}
15
14
16
void* thr3 ( void* v )
15
void* thr3 ( void* v )
17
{
16
{
18
  FILE* f = fopen("bogus3", "r");
17
  FILE* f = fopen("bogus3", "r");
19
  printf("f3 = %p, errno3 = %d\n", f, errno);
18
  printf("f  = %p, errno  = %d (%s)\n", f, errno, strerror(errno));
20
  perror("wurble3");
21
  return NULL;
19
  return NULL;
22
}
20
}
23
21
Lines 29-36 Link Here
29
  pthread_create(&tid2, NULL, &thr2, NULL);
27
  pthread_create(&tid2, NULL, &thr2, NULL);
30
  pthread_create(&tid3, NULL, &thr3, NULL);
28
  pthread_create(&tid3, NULL, &thr3, NULL);
31
  f = fopen("bogus", "r");
29
  f = fopen("bogus", "r");
32
  printf("f1 = %p, errno1 = %d\n", f, errno);
30
  printf("f  = %p, errno  = %d (%s)\n", f, errno, strerror(errno));
33
  perror("wurble1");
34
  pthread_join(tid2, NULL);
31
  pthread_join(tid2, NULL);
35
  pthread_join(tid3, NULL);
32
  pthread_join(tid3, NULL);
36
  return 0;
33
  return 0;
(-)valgrind-2.1.0/memcheck/tests/threadederrno.stderr.exp (-3 lines)
Lines 1-3 Link Here
1
wurble1: No such file or directory
2
wurble2: No such file or directory
3
wurble3: No such file or directory
(-)valgrind-2.1.0/memcheck/tests/threadederrno.stdout.exp (-3 / +3 lines)
Lines 1-3 Link Here
1
f1 = (nil), errno1 = 2
1
f  = (nil), errno  = 2 (No such file or directory)
2
f2 = (nil), errno2 = 2
2
f  = (nil), errno  = 2 (No such file or directory)
3
f3 = (nil), errno3 = 2
3
f  = (nil), errno  = 2 (No such file or directory)
(-)valgrind-2.1.0/memcheck/tests/weirdioctl.stderr.exp (-1 / +1 lines)
Lines 1-5 Link Here
1
Syscall param ioctl(TCSET{A,AW,AF}) contains uninitialised or unaddressable byte(s)
1
Syscall param ioctl(TCSET{A,AW,AF}) contains uninitialised or unaddressable byte(s)
2
   at 0x........: __ioctl (in /...libc...)
2
   at 0x........: ioctl (in /...libc...)
3
   by 0x........: __libc_start_main (...libc...)
3
   by 0x........: __libc_start_main (...libc...)
4
   by 0x........: ...
4
   by 0x........: ...
5
 Address 0x........ is on thread 1's stack
5
 Address 0x........ is on thread 1's stack
(-)valgrind-2.1.0/memcheck/tests/writev.stderr.exp (-3 / +3 lines)
Lines 1-19 Link Here
1
1
2
Test file created.
2
Test file created.
3
Syscall param writev(vector[...]) contains uninitialised or unaddressable byte(s)
3
Syscall param writev(vector[...]) contains uninitialised or unaddressable byte(s)
4
   at 0x........: __libc_writev (...libc...)
4
   at 0x........: writev (in /...libc...)
5
   by 0x........: main (writev.c:56)
5
   by 0x........: main (writev.c:56)
6
 Address 0x........ is not stack'd, malloc'd or free'd
6
 Address 0x........ is not stack'd, malloc'd or free'd
7
Received EFAULT as expected
7
Received EFAULT as expected
8
8
9
Syscall param writev(vector) contains uninitialised or unaddressable byte(s)
9
Syscall param writev(vector) contains uninitialised or unaddressable byte(s)
10
   at 0x........: __libc_writev (...libc...)
10
   at 0x........: writev (in /...libc...)
11
   by 0x........: main (writev.c:68)
11
   by 0x........: main (writev.c:68)
12
 Address 0x........ is not stack'd, malloc'd or free'd
12
 Address 0x........ is not stack'd, malloc'd or free'd
13
Received EINVAL as expected
13
Received EINVAL as expected
14
14
15
Syscall param readv(vector) contains uninitialised or unaddressable byte(s)
15
Syscall param readv(vector) contains uninitialised or unaddressable byte(s)
16
   at 0x........: __libc_readv (...libc...)
16
   at 0x........: readv (in /...libc...)
17
   by 0x........: main (writev.c:76)
17
   by 0x........: main (writev.c:76)
18
 Address 0x........ is not stack'd, malloc'd or free'd
18
 Address 0x........ is not stack'd, malloc'd or free'd
19
Received EINVAL as expected
19
Received EINVAL as expected
(-)valgrind-2.1.0/memcheck/tests/zeropage.c (-4 / +4 lines)
Lines 12-36 Link Here
12
{
12
{
13
   /* mmap(0x0, ... FIXED) should fail */
13
   /* mmap(0x0, ... FIXED) should fail */
14
   int* m = mmap(0x0, 1000000, PROT_READ|PROT_WRITE, 
14
   int* m = mmap(0x0, 1000000, PROT_READ|PROT_WRITE, 
15
                 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
15
                 MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0);
16
   if (m != (int*)-1)
16
   if (m != (int*)-1)
17
      printf("succeeded?!\n");
17
      printf("succeeded?!\n");
18
18
19
   /* mmap(0x1000, ... FIXED) should fail */
19
   /* mmap(0x1000, ... FIXED) should fail */
20
        m = mmap((void*)0x1000, 1000000, PROT_READ|PROT_WRITE, 
20
        m = mmap((void*)0x1000, 1000000, PROT_READ|PROT_WRITE, 
21
                 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
21
                 MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0);
22
   if (m != (int*)-1)
22
   if (m != (int*)-1)
23
      printf("succeeded?!\n");
23
      printf("succeeded?!\n");
24
24
25
   /* mmap(0xa000, ... FIXED) should fail */
25
   /* mmap(0xa000, ... FIXED) should fail */
26
        m = mmap((void*)0xa000, 1000000, PROT_READ|PROT_WRITE, 
26
        m = mmap((void*)0xa000, 1000000, PROT_READ|PROT_WRITE, 
27
                 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
27
                 MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0);
28
   if (m != (int*)-1)
28
   if (m != (int*)-1)
29
      printf("succeeded?!\n");
29
      printf("succeeded?!\n");
30
30
31
   /* mmap(0x10000, ... FIXED) should fail */
31
   /* mmap(0x10000, ... FIXED) should fail */
32
        m = mmap((void*)0x10000, 1000000, PROT_READ|PROT_WRITE, 
32
        m = mmap((void*)0x10000, 1000000, PROT_READ|PROT_WRITE, 
33
                 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
33
                 MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0);
34
   if (m == (int*)-1)
34
   if (m == (int*)-1)
35
      printf("failed?!\n");
35
      printf("failed?!\n");
36
36
(-)valgrind-2.1.0/memcheck/tests/zeropage.stderr.exp (+3 lines)
Line 0 Link Here
1
Warning: client syscall mmap2 tried to modify addresses 0x........-0x........
2
Warning: client syscall mmap2 tried to modify addresses 0x........-0x........
3
Warning: client syscall mmap2 tried to modify addresses 0x........-0x........
(-)valgrind-2.1.0/missing (-17 / +41 lines)
Lines 1-6 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Common stub for a few missing GNU programs while installing.
2
# Common stub for a few missing GNU programs while installing.
3
# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
3
4
scriptversion=2003-09-02.23
5
6
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 
7
#   Free Software Foundation, Inc.
4
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
5
9
6
# This program is free software; you can redistribute it and/or modify
10
# This program is free software; you can redistribute it and/or modify
Lines 38-49 Link Here
38
  configure_ac=configure.in
42
  configure_ac=configure.in
39
fi
43
fi
40
44
45
msg="missing on your system"
46
41
case "$1" in
47
case "$1" in
42
--run)
48
--run)
43
  # Try to run requested program, and just exit if it succeeds.
49
  # Try to run requested program, and just exit if it succeeds.
44
  run=
50
  run=
45
  shift
51
  shift
46
  "$@" && exit 0
52
  "$@" && exit 0
53
  # Exit code 63 means version mismatch.  This often happens
54
  # when the user try to use an ancient version of a tool on
55
  # a file that requires a minimum version.  In this case we
56
  # we should proceed has if the program had been absent, or
57
  # if --run hadn't been passed.
58
  if test $? = 63; then
59
    run=:
60
    msg="probably too old"
61
  fi
47
  ;;
62
  ;;
48
esac
63
esac
49
64
Lines 74-84 Link Here
74
  lex          create \`lex.yy.c', if possible, from existing .c
89
  lex          create \`lex.yy.c', if possible, from existing .c
75
  makeinfo     touch the output file
90
  makeinfo     touch the output file
76
  tar          try tar, gnutar, gtar, then tar without non-portable flags
91
  tar          try tar, gnutar, gtar, then tar without non-portable flags
77
  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
92
  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
93
94
Send bug reports to <bug-automake@gnu.org>."
78
    ;;
95
    ;;
79
96
80
  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
97
  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
81
    echo "missing 0.4 - GNU automake"
98
    echo "missing $scriptversion (GNU Automake)"
82
    ;;
99
    ;;
83
100
84
  -*)
101
  -*)
Lines 94-100 Link Here
94
    fi
111
    fi
95
112
96
    echo 1>&2 "\
113
    echo 1>&2 "\
97
WARNING: \`$1' is missing on your system.  You should only need it if
114
WARNING: \`$1' is $msg.  You should only need it if
98
         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
115
         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
99
         to install the \`Automake' and \`Perl' packages.  Grab them from
116
         to install the \`Automake' and \`Perl' packages.  Grab them from
100
         any GNU archive site."
117
         any GNU archive site."
Lines 108-114 Link Here
108
    fi
125
    fi
109
126
110
    echo 1>&2 "\
127
    echo 1>&2 "\
111
WARNING: \`$1' is missing on your system.  You should only need it if
128
WARNING: \`$1' is $msg.  You should only need it if
112
         you modified \`${configure_ac}'.  You might want to install the
129
         you modified \`${configure_ac}'.  You might want to install the
113
         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
130
         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
114
         archive site."
131
         archive site."
Lines 122-128 Link Here
122
    fi
139
    fi
123
140
124
    echo 1>&2 "\
141
    echo 1>&2 "\
125
WARNING: \`$1' is missing on your system.  You should only need it if
142
WARNING: \`$1' is $msg.  You should only need it if
126
         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
143
         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
127
         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
144
         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
128
         from any GNU archive site."
145
         from any GNU archive site."
Lines 146-152 Link Here
146
    fi
163
    fi
147
164
148
    echo 1>&2 "\
165
    echo 1>&2 "\
149
WARNING: \`$1' is missing on your system.  You should only need it if
166
WARNING: \`$1' is $msg.  You should only need it if
150
         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
167
         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
151
         You might want to install the \`Automake' and \`Perl' packages.
168
         You might want to install the \`Automake' and \`Perl' packages.
152
         Grab them from any GNU archive site."
169
         Grab them from any GNU archive site."
Lines 162-171 Link Here
162
    fi
179
    fi
163
180
164
    echo 1>&2 "\
181
    echo 1>&2 "\
165
WARNING: \`$1' is needed, and you do not seem to have it handy on your
182
WARNING: \`$1' is needed, but is $msg.
166
         system.  You might have modified some files without having the
183
         You might have modified some files without having the
167
         proper tools for further handling them.
184
         proper tools for further handling them.
168
         You can get \`$1Help2man' as part of \`Autoconf' from any GNU
185
         You can get \`$1' as part of \`Autoconf' from any GNU
169
         archive site."
186
         archive site."
170
187
171
    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
188
    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
Lines 185-191 Link Here
185
202
186
  bison|yacc)
203
  bison|yacc)
187
    echo 1>&2 "\
204
    echo 1>&2 "\
188
WARNING: \`$1' is missing on your system.  You should only need it if
205
WARNING: \`$1' $msg.  You should only need it if
189
         you modified a \`.y' file.  You may need the \`Bison' package
206
         you modified a \`.y' file.  You may need the \`Bison' package
190
         in order for those modifications to take effect.  You can get
207
         in order for those modifications to take effect.  You can get
191
         \`Bison' from any GNU archive site."
208
         \`Bison' from any GNU archive site."
Lines 215-221 Link Here
215
232
216
  lex|flex)
233
  lex|flex)
217
    echo 1>&2 "\
234
    echo 1>&2 "\
218
WARNING: \`$1' is missing on your system.  You should only need it if
235
WARNING: \`$1' is $msg.  You should only need it if
219
         you modified a \`.l' file.  You may need the \`Flex' package
236
         you modified a \`.l' file.  You may need the \`Flex' package
220
         in order for those modifications to take effect.  You can get
237
         in order for those modifications to take effect.  You can get
221
         \`Flex' from any GNU archive site."
238
         \`Flex' from any GNU archive site."
Lines 243-249 Link Here
243
    fi
260
    fi
244
261
245
    echo 1>&2 "\
262
    echo 1>&2 "\
246
WARNING: \`$1' is missing on your system.  You should only need it if
263
WARNING: \`$1' is $msg.  You should only need it if
247
	 you modified a dependency of a manual page.  You may need the
264
	 you modified a dependency of a manual page.  You may need the
248
	 \`Help2man' package in order for those modifications to take
265
	 \`Help2man' package in order for those modifications to take
249
	 effect.  You can get \`Help2man' from any GNU archive site."
266
	 effect.  You can get \`Help2man' from any GNU archive site."
Lines 268-274 Link Here
268
    fi
285
    fi
269
286
270
    echo 1>&2 "\
287
    echo 1>&2 "\
271
WARNING: \`$1' is missing on your system.  You should only need it if
288
WARNING: \`$1' is $msg.  You should only need it if
272
         you modified a \`.texi' or \`.texinfo' file, or any other file
289
         you modified a \`.texi' or \`.texinfo' file, or any other file
273
         indirectly affecting the aspect of the manual.  The spurious
290
         indirectly affecting the aspect of the manual.  The spurious
274
         call might also be the consequence of using a buggy \`make' (AIX,
291
         call might also be the consequence of using a buggy \`make' (AIX,
Lines 323-332 Link Here
323
340
324
  *)
341
  *)
325
    echo 1>&2 "\
342
    echo 1>&2 "\
326
WARNING: \`$1' is needed, and you do not seem to have it handy on your
343
WARNING: \`$1' is needed, and is $msg.
327
         system.  You might have modified some files without having the
344
         You might have modified some files without having the
328
         proper tools for further handling them.  Check the \`README' file,
345
         proper tools for further handling them.  Check the \`README' file,
329
         it often tells you about the needed prerequirements for installing
346
         it often tells you about the needed prerequisites for installing
330
         this package.  You may also peek at any GNU archive site, in case
347
         this package.  You may also peek at any GNU archive site, in case
331
         some other package would contain this missing \`$1' program."
348
         some other package would contain this missing \`$1' program."
332
    exit 1
349
    exit 1
Lines 334-336 Link Here
334
esac
351
esac
335
352
336
exit 0
353
exit 0
354
355
# Local variables:
356
# eval: (add-hook 'write-file-hooks 'time-stamp)
357
# time-stamp-start: "scriptversion="
358
# time-stamp-format: "%:y-%02m-%02d.%02H"
359
# time-stamp-end: "$"
360
# End:
(-)valgrind-2.1.0/mkinstalldirs (-111 lines)
Lines 1-111 Link Here
1
#! /bin/sh
2
# mkinstalldirs --- make directory hierarchy
3
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
4
# Created: 1993-05-16
5
# Public domain
6
7
errstatus=0
8
dirmode=""
9
10
usage="\
11
Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
12
13
# process command line arguments
14
while test $# -gt 0 ; do
15
  case $1 in
16
    -h | --help | --h*)         # -h for help
17
      echo "$usage" 1>&2
18
      exit 0
19
      ;;
20
    -m)                         # -m PERM arg
21
      shift
22
      test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
23
      dirmode=$1
24
      shift
25
      ;;
26
    --)                         # stop option processing
27
      shift
28
      break
29
      ;;
30
    -*)                         # unknown option
31
      echo "$usage" 1>&2
32
      exit 1
33
      ;;
34
    *)                          # first non-opt arg
35
      break
36
      ;;
37
  esac
38
done
39
40
for file
41
do
42
  if test -d "$file"; then
43
    shift
44
  else
45
    break
46
  fi
47
done
48
49
case $# in
50
  0) exit 0 ;;
51
esac
52
53
case $dirmode in
54
  '')
55
    if mkdir -p -- . 2>/dev/null; then
56
      echo "mkdir -p -- $*"
57
      exec mkdir -p -- "$@"
58
    fi
59
    ;;
60
  *)
61
    if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
62
      echo "mkdir -m $dirmode -p -- $*"
63
      exec mkdir -m "$dirmode" -p -- "$@"
64
    fi
65
    ;;
66
esac
67
68
for file
69
do
70
  set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
71
  shift
72
73
  pathcomp=
74
  for d
75
  do
76
    pathcomp="$pathcomp$d"
77
    case $pathcomp in
78
      -*) pathcomp=./$pathcomp ;;
79
    esac
80
81
    if test ! -d "$pathcomp"; then
82
      echo "mkdir $pathcomp"
83
84
      mkdir "$pathcomp" || lasterr=$?
85
86
      if test ! -d "$pathcomp"; then
87
  	errstatus=$lasterr
88
      else
89
  	if test ! -z "$dirmode"; then
90
	  echo "chmod $dirmode $pathcomp"
91
    	  lasterr=""
92
  	  chmod "$dirmode" "$pathcomp" || lasterr=$?
93
94
  	  if test ! -z "$lasterr"; then
95
  	    errstatus=$lasterr
96
  	  fi
97
  	fi
98
      fi
99
    fi
100
101
    pathcomp="$pathcomp/"
102
  done
103
done
104
105
exit $errstatus
106
107
# Local Variables:
108
# mode: shell-script
109
# sh-indentation: 2
110
# End:
111
# mkinstalldirs ends here
(-)valgrind-2.1.0/none/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/none/CVS/Entries (+4 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Mon Sep 23 11:36:38 2002//
2
/Makefile.am/1.42/Tue Dec 16 02:05:15 2003//
3
/nl_main.c/1.18/Sun Jan  4 16:43:23 2004//
4
D
(-)valgrind-2.1.0/none/CVS/Entries.Log (+2 lines)
Line 0 Link Here
1
A D/docs////
2
A D/tests////
(-)valgrind-2.1.0/none/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/none
(-)valgrind-2.1.0/none/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/none/Makefile.am (-1 / +6 lines)
Lines 6-14 Link Here
6
		@PREFERRED_STACK_BOUNDARY@ -g
6
		@PREFERRED_STACK_BOUNDARY@ -g
7
7
8
valdir = $(libdir)/valgrind
8
valdir = $(libdir)/valgrind
9
inplacedir = $(top_srcdir)/.in_place
9
10
10
val_PROGRAMS = vgskin_none.so
11
val_PROGRAMS = vgskin_none.so
11
12
12
vgskin_none_so_SOURCES 	 = nl_main.c
13
vgskin_none_so_SOURCES 	 = nl_main.c
13
vgskin_none_so_LDFLAGS   = -shared
14
vgskin_none_so_LDFLAGS   = -shared -Wl,-rpath,$(top_srcdir)/coregrind
14
15
16
all-local:
17
	mkdir -p $(inplacedir)
18
	-rm -f $(inplacedir)/$(val_PROGRAMS)
19
	ln -f -s $(top_srcdir)/$(subdir)/$(val_PROGRAMS) $(inplacedir)/$(val_PROGRAMS)
(-)valgrind-2.1.0/none/Makefile.in (-105 / +113 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 14-19 Link Here
14
14
15
@SET_MAKE@
15
@SET_MAKE@
16
16
17
SOURCES = $(vgskin_none_so_SOURCES)
18
17
srcdir = @srcdir@
19
srcdir = @srcdir@
18
top_srcdir = @top_srcdir@
20
top_srcdir = @top_srcdir@
19
VPATH = @srcdir@
21
VPATH = @srcdir@
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
23
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
24
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ..
25
top_builddir = ..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
27
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
28
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
37
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
38
POST_UNINSTALL = :
38
host_triplet = @host@
39
host_triplet = @host@
40
val_PROGRAMS = vgskin_none.so$(EXEEXT)
41
subdir = none
42
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
43
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
44
am__aclocal_m4_deps = $(top_srcdir)/configure.in
45
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
46
	$(ACLOCAL_M4)
47
mkinstalldirs = $(mkdir_p)
48
CONFIG_HEADER = $(top_builddir)/config.h
49
CONFIG_CLEAN_FILES =
50
am__installdirs = $(DESTDIR)$(valdir)
51
valPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
52
PROGRAMS = $(val_PROGRAMS)
53
am_vgskin_none_so_OBJECTS = nl_main.$(OBJEXT)
54
vgskin_none_so_OBJECTS = $(am_vgskin_none_so_OBJECTS)
55
vgskin_none_so_LDADD = $(LDADD)
56
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
57
depcomp = $(SHELL) $(top_srcdir)/depcomp
58
am__depfiles_maybe = depfiles
59
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/nl_main.Po
60
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
61
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
62
CCLD = $(CC)
63
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
64
SOURCES = $(vgskin_none_so_SOURCES)
65
DIST_SOURCES = $(vgskin_none_so_SOURCES)
66
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
67
	html-recursive info-recursive install-data-recursive \
68
	install-exec-recursive install-info-recursive \
69
	install-recursive installcheck-recursive installdirs-recursive \
70
	pdf-recursive ps-recursive uninstall-info-recursive \
71
	uninstall-recursive
72
ETAGS = etags
73
CTAGS = ctags
74
DIST_SUBDIRS = $(SUBDIRS)
75
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
76
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
77
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
78
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
129
SHELL = @SHELL@
93
STRIP = @STRIP@
130
STRIP = @STRIP@
94
VERSION = @VERSION@
131
VERSION = @VERSION@
132
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
133
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
134
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
135
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
161
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
162
localstatedir = @localstatedir@
125
mandir = @mandir@
163
mandir = @mandir@
164
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
165
oldincludedir = @oldincludedir@
127
prefix = @prefix@
166
prefix = @prefix@
128
program_transform_name = @program_transform_name@
167
program_transform_name = @program_transform_name@
Lines 130-194 Link Here
130
sharedstatedir = @sharedstatedir@
169
sharedstatedir = @sharedstatedir@
131
sysconfdir = @sysconfdir@
170
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
171
target_alias = @target_alias@
133
134
SUBDIRS = . docs tests
172
SUBDIRS = . docs tests
135
136
AM_CPPFLAGS = -I$(top_srcdir)/include -DVG_LIBDIR="\"$(libdir)"\"
173
AM_CPPFLAGS = -I$(top_srcdir)/include -DVG_LIBDIR="\"$(libdir)"\"
137
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer \
174
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer \
138
		@PREFERRED_STACK_BOUNDARY@ -g
175
		@PREFERRED_STACK_BOUNDARY@ -g
139
176
140
141
valdir = $(libdir)/valgrind
177
valdir = $(libdir)/valgrind
142
178
inplacedir = $(top_srcdir)/.in_place
143
val_PROGRAMS = vgskin_none.so
144
145
vgskin_none_so_SOURCES = nl_main.c
179
vgskin_none_so_SOURCES = nl_main.c
146
vgskin_none_so_LDFLAGS = -shared
180
vgskin_none_so_LDFLAGS = -shared -Wl,-rpath,$(top_srcdir)/coregrind
147
subdir = none
148
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
149
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
150
CONFIG_HEADER = $(top_builddir)/config.h
151
CONFIG_CLEAN_FILES =
152
val_PROGRAMS = vgskin_none.so$(EXEEXT)
153
PROGRAMS = $(val_PROGRAMS)
154
155
am_vgskin_none_so_OBJECTS = nl_main.$(OBJEXT)
156
vgskin_none_so_OBJECTS = $(am_vgskin_none_so_OBJECTS)
157
vgskin_none_so_LDADD = $(LDADD)
158
vgskin_none_so_DEPENDENCIES =
159
160
DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
161
depcomp = $(SHELL) $(top_srcdir)/depcomp
162
am__depfiles_maybe = depfiles
163
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/nl_main.Po
164
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
165
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
166
CCLD = $(CC)
167
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
168
DIST_SOURCES = $(vgskin_none_so_SOURCES)
169
170
RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
171
	ps-recursive install-info-recursive uninstall-info-recursive \
172
	all-recursive install-data-recursive install-exec-recursive \
173
	installdirs-recursive install-recursive uninstall-recursive \
174
	check-recursive installcheck-recursive
175
DIST_COMMON = Makefile.am Makefile.in
176
DIST_SUBDIRS = $(SUBDIRS)
177
SOURCES = $(vgskin_none_so_SOURCES)
178
179
all: all-recursive
181
all: all-recursive
180
182
181
.SUFFIXES:
183
.SUFFIXES:
182
.SUFFIXES: .c .o .obj
184
.SUFFIXES: .c .o .obj
183
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
185
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
186
	@for dep in $?; do \
187
	  case '$(am__configure_deps)' in \
188
	    *$$dep*) \
189
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
190
		&& exit 0; \
191
	      exit 1;; \
192
	  esac; \
193
	done; \
194
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  none/Makefile'; \
184
	cd $(top_srcdir) && \
195
	cd $(top_srcdir) && \
185
	  $(AUTOMAKE) --gnu  none/Makefile
196
	  $(AUTOMAKE) --gnu  none/Makefile
186
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
197
.PRECIOUS: Makefile
187
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
198
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
188
valPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
199
	@case '$?' in \
200
	  *config.status*) \
201
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
202
	  *) \
203
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
204
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
205
	esac;
206
207
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
208
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
209
210
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
211
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
212
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
213
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
189
install-valPROGRAMS: $(val_PROGRAMS)
214
install-valPROGRAMS: $(val_PROGRAMS)
190
	@$(NORMAL_INSTALL)
215
	@$(NORMAL_INSTALL)
191
	$(mkinstalldirs) $(DESTDIR)$(valdir)
216
	$(mkdir_p) $(DESTDIR)$(valdir)
192
	@list='$(val_PROGRAMS)'; for p in $$list; do \
217
	@list='$(val_PROGRAMS)'; for p in $$list; do \
193
	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
218
	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
194
	  if test -f $$p \
219
	  if test -f $$p \
Lines 214-250 Link Here
214
	$(LINK) $(vgskin_none_so_LDFLAGS) $(vgskin_none_so_OBJECTS) $(vgskin_none_so_LDADD) $(LIBS)
239
	$(LINK) $(vgskin_none_so_LDFLAGS) $(vgskin_none_so_OBJECTS) $(vgskin_none_so_LDADD) $(LIBS)
215
240
216
mostlyclean-compile:
241
mostlyclean-compile:
217
	-rm -f *.$(OBJEXT) core *.core
242
	-rm -f *.$(OBJEXT)
218
243
219
distclean-compile:
244
distclean-compile:
220
	-rm -f *.tab.c
245
	-rm -f *.tab.c
221
246
222
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nl_main.Po@am__quote@
247
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nl_main.Po@am__quote@
223
248
224
distclean-depend:
225
	-rm -rf ./$(DEPDIR)
226
227
.c.o:
249
.c.o:
228
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
250
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
229
@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
251
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
230
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
231
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
232
@am__fastdepCC_TRUE@	fi
233
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
252
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
234
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
253
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
235
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
254
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
236
@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
255
@am__fastdepCC_FALSE@	$(COMPILE) -c $<
237
256
238
.c.obj:
257
.c.obj:
239
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
258
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
240
@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
259
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
241
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
242
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
243
@am__fastdepCC_TRUE@	fi
244
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
260
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
245
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
261
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
246
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
262
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
247
@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
263
@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
248
uninstall-info-am:
264
uninstall-info-am:
249
265
250
# This directory's subdirectories are mostly independent; you can cd
266
# This directory's subdirectories are mostly independent; you can cd
Lines 306-319 Link Here
306
	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
322
	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
307
	done
323
	done
308
324
309
ETAGS = etags
310
ETAGSFLAGS =
311
312
CTAGS = ctags
313
CTAGSFLAGS =
314
315
tags: TAGS
316
317
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
325
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
318
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
326
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
319
	unique=`for i in $$list; do \
327
	unique=`for i in $$list; do \
Lines 322-327 Link Here
322
	  $(AWK) '    { files[$$0] = 1; } \
330
	  $(AWK) '    { files[$$0] = 1; } \
323
	       END { for (i in files) print i; }'`; \
331
	       END { for (i in files) print i; }'`; \
324
	mkid -fID $$unique
332
	mkid -fID $$unique
333
tags: TAGS
325
334
326
TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
335
TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
327
		$(TAGS_FILES) $(LISP)
336
		$(TAGS_FILES) $(LISP)
Lines 347-353 Link Here
347
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
356
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
348
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
357
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
349
	     $$tags $$unique
358
	     $$tags $$unique
350
351
ctags: CTAGS
359
ctags: CTAGS
352
CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
360
CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
353
		$(TAGS_FILES) $(LISP)
361
		$(TAGS_FILES) $(LISP)
Lines 370-379 Link Here
370
378
371
distclean-tags:
379
distclean-tags:
372
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
380
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
373
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
374
375
top_distdir = ..
376
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
377
381
378
distdir: $(DISTFILES)
382
distdir: $(DISTFILES)
379
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
383
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 387-393 Link Here
387
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
391
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
388
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
392
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
389
	    dir="/$$dir"; \
393
	    dir="/$$dir"; \
390
	    $(mkinstalldirs) "$(distdir)$$dir"; \
394
	    $(mkdir_p) "$(distdir)$$dir"; \
391
	  else \
395
	  else \
392
	    dir=''; \
396
	    dir=''; \
393
	  fi; \
397
	  fi; \
Lines 404-427 Link Here
404
	done
408
	done
405
	list='$(SUBDIRS)'; for subdir in $$list; do \
409
	list='$(SUBDIRS)'; for subdir in $$list; do \
406
	  if test "$$subdir" = .; then :; else \
410
	  if test "$$subdir" = .; then :; else \
407
	    test -d $(distdir)/$$subdir \
411
	    test -d "$(distdir)/$$subdir" \
408
	    || mkdir $(distdir)/$$subdir \
412
	    || mkdir "$(distdir)/$$subdir" \
409
	    || exit 1; \
413
	    || exit 1; \
410
	    (cd $$subdir && \
414
	    (cd $$subdir && \
411
	      $(MAKE) $(AM_MAKEFLAGS) \
415
	      $(MAKE) $(AM_MAKEFLAGS) \
412
	        top_distdir="$(top_distdir)" \
416
	        top_distdir="../$(top_distdir)" \
413
	        distdir=../$(distdir)/$$subdir \
417
	        distdir="../$(distdir)/$$subdir" \
414
	        distdir) \
418
	        distdir) \
415
	      || exit 1; \
419
	      || exit 1; \
416
	  fi; \
420
	  fi; \
417
	done
421
	done
418
check-am: all-am
422
check-am: all-am
419
check: check-recursive
423
check: check-recursive
420
all-am: Makefile $(PROGRAMS)
424
all-am: Makefile $(PROGRAMS) all-local
421
installdirs: installdirs-recursive
425
installdirs: installdirs-recursive
422
installdirs-am:
426
installdirs-am:
423
	$(mkinstalldirs) $(DESTDIR)$(valdir)
427
	$(mkdir_p) $(DESTDIR)$(valdir)
424
425
install: install-recursive
428
install: install-recursive
426
install-exec: install-exec-recursive
429
install-exec: install-exec-recursive
427
install-data: install-data-recursive
430
install-data: install-data-recursive
Lines 433-439 Link Here
433
installcheck: installcheck-recursive
436
installcheck: installcheck-recursive
434
install-strip:
437
install-strip:
435
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
438
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
436
	  INSTALL_STRIP_FLAG=-s \
439
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
437
	  `test -z '$(STRIP)' || \
440
	  `test -z '$(STRIP)' || \
438
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
441
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
439
mostlyclean-generic:
442
mostlyclean-generic:
Lines 441-447 Link Here
441
clean-generic:
444
clean-generic:
442
445
443
distclean-generic:
446
distclean-generic:
444
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
447
	-rm -f $(CONFIG_CLEAN_FILES)
445
448
446
maintainer-clean-generic:
449
maintainer-clean-generic:
447
	@echo "This command is intended for maintainers to use"
450
	@echo "This command is intended for maintainers to use"
Lines 451-464 Link Here
451
clean-am: clean-generic clean-valPROGRAMS mostlyclean-am
454
clean-am: clean-generic clean-valPROGRAMS mostlyclean-am
452
455
453
distclean: distclean-recursive
456
distclean: distclean-recursive
454
457
	-rm -rf ./$(DEPDIR)
455
distclean-am: clean-am distclean-compile distclean-depend \
458
	-rm -f Makefile
456
	distclean-generic distclean-tags
459
distclean-am: clean-am distclean-compile distclean-generic \
460
	distclean-tags
457
461
458
dvi: dvi-recursive
462
dvi: dvi-recursive
459
463
460
dvi-am:
464
dvi-am:
461
465
466
html: html-recursive
467
462
info: info-recursive
468
info: info-recursive
463
469
464
info-am:
470
info-am:
Lines 474-480 Link Here
474
installcheck-am:
480
installcheck-am:
475
481
476
maintainer-clean: maintainer-clean-recursive
482
maintainer-clean: maintainer-clean-recursive
477
483
	-rm -rf ./$(DEPDIR)
484
	-rm -f Makefile
478
maintainer-clean-am: distclean-am maintainer-clean-generic
485
maintainer-clean-am: distclean-am maintainer-clean-generic
479
486
480
mostlyclean: mostlyclean-recursive
487
mostlyclean: mostlyclean-recursive
Lines 493-516 Link Here
493
500
494
uninstall-info: uninstall-info-recursive
501
uninstall-info: uninstall-info-recursive
495
502
496
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
503
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am all-local check \
497
	clean-generic clean-recursive clean-valPROGRAMS ctags \
504
	check-am clean clean-generic clean-recursive clean-valPROGRAMS \
498
	ctags-recursive distclean distclean-compile distclean-depend \
505
	ctags ctags-recursive distclean distclean-compile \
499
	distclean-generic distclean-recursive distclean-tags distdir \
506
	distclean-generic distclean-recursive distclean-tags distdir \
500
	dvi dvi-am dvi-recursive info info-am info-recursive install \
507
	dvi dvi-am html html-am info info-am install install-am \
501
	install-am install-data install-data-am install-data-recursive \
508
	install-data install-data-am install-exec install-exec-am \
502
	install-exec install-exec-am install-exec-recursive \
509
	install-info install-info-am install-man install-strip \
503
	install-info install-info-am install-info-recursive install-man \
510
	install-valPROGRAMS installcheck installcheck-am installdirs \
504
	install-recursive install-strip install-valPROGRAMS \
511
	installdirs-am maintainer-clean maintainer-clean-generic \
505
	installcheck installcheck-am installdirs installdirs-am \
506
	installdirs-recursive maintainer-clean maintainer-clean-generic \
507
	maintainer-clean-recursive mostlyclean mostlyclean-compile \
512
	maintainer-clean-recursive mostlyclean mostlyclean-compile \
508
	mostlyclean-generic mostlyclean-recursive pdf pdf-am \
513
	mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \
509
	pdf-recursive ps ps-am ps-recursive tags tags-recursive \
514
	tags tags-recursive uninstall uninstall-am uninstall-info-am \
510
	uninstall uninstall-am uninstall-info-am \
511
	uninstall-info-recursive uninstall-recursive \
512
	uninstall-valPROGRAMS
515
	uninstall-valPROGRAMS
513
516
517
518
all-local:
519
	mkdir -p $(inplacedir)
520
	-rm -f $(inplacedir)/$(val_PROGRAMS)
521
	ln -f -s $(top_srcdir)/$(subdir)/$(val_PROGRAMS) $(inplacedir)/$(val_PROGRAMS)
514
# Tell versions [3.59,3.63) of GNU make to not export all variables.
522
# Tell versions [3.59,3.63) of GNU make to not export all variables.
515
# Otherwise a system limit (for SysV at least) may be exceeded.
523
# Otherwise a system limit (for SysV at least) may be exceeded.
516
.NOEXPORT:
524
.NOEXPORT:
(-)valgrind-2.1.0/none/docs/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/none/docs/CVS/Entries (+4 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Thu Oct  3 09:12:58 2002//
2
/Makefile.am/1.2/Wed Nov 13 21:24:57 2002//
3
/nl_main.html/1.4/Sun Jan  4 16:43:23 2004//
4
D
(-)valgrind-2.1.0/none/docs/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/none/docs
(-)valgrind-2.1.0/none/docs/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/none/docs/Makefile.in (-38 / +64 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
21
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
23
top_builddir = ../..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
25
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
26
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
35
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
36
POST_UNINSTALL = :
38
host_triplet = @host@
37
host_triplet = @host@
38
subdir = none/docs
39
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
40
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
41
am__aclocal_m4_deps = $(top_srcdir)/configure.in
42
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
43
	$(ACLOCAL_M4)
44
mkinstalldirs = $(mkdir_p)
45
CONFIG_HEADER = $(top_builddir)/config.h
46
CONFIG_CLEAN_FILES =
47
SOURCES =
48
DIST_SOURCES =
49
am__installdirs = $(DESTDIR)$(docdir)
50
docDATA_INSTALL = $(INSTALL_DATA)
51
DATA = $(doc_DATA)
52
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
53
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
54
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
55
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
106
SHELL = @SHELL@
93
STRIP = @STRIP@
107
STRIP = @STRIP@
94
VERSION = @VERSION@
108
VERSION = @VERSION@
109
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
110
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
111
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
112
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
138
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
139
localstatedir = @localstatedir@
125
mandir = @mandir@
140
mandir = @mandir@
141
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
142
oldincludedir = @oldincludedir@
127
prefix = @prefix@
143
prefix = @prefix@
128
program_transform_name = @program_transform_name@
144
program_transform_name = @program_transform_name@
Lines 131-162 Link Here
131
sysconfdir = @sysconfdir@
147
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
148
target_alias = @target_alias@
133
docdir = $(datadir)/doc/valgrind
149
docdir = $(datadir)/doc/valgrind
134
135
doc_DATA = nl_main.html
150
doc_DATA = nl_main.html
136
137
EXTRA_DIST = $(doc_DATA)
151
EXTRA_DIST = $(doc_DATA)
138
subdir = none/docs
139
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
140
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
141
CONFIG_HEADER = $(top_builddir)/config.h
142
CONFIG_CLEAN_FILES =
143
DIST_SOURCES =
144
DATA = $(doc_DATA)
145
146
DIST_COMMON = Makefile.am Makefile.in
147
all: all-am
152
all: all-am
148
153
149
.SUFFIXES:
154
.SUFFIXES:
150
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
155
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
156
	@for dep in $?; do \
157
	  case '$(am__configure_deps)' in \
158
	    *$$dep*) \
159
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
160
		&& exit 0; \
161
	      exit 1;; \
162
	  esac; \
163
	done; \
164
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  none/docs/Makefile'; \
151
	cd $(top_srcdir) && \
165
	cd $(top_srcdir) && \
152
	  $(AUTOMAKE) --gnu  none/docs/Makefile
166
	  $(AUTOMAKE) --gnu  none/docs/Makefile
153
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
167
.PRECIOUS: Makefile
154
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
168
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
169
	@case '$?' in \
170
	  *config.status*) \
171
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
172
	  *) \
173
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
174
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
175
	esac;
176
177
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
178
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
179
180
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
181
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
182
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
183
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
155
uninstall-info-am:
184
uninstall-info-am:
156
docDATA_INSTALL = $(INSTALL_DATA)
157
install-docDATA: $(doc_DATA)
185
install-docDATA: $(doc_DATA)
158
	@$(NORMAL_INSTALL)
186
	@$(NORMAL_INSTALL)
159
	$(mkinstalldirs) $(DESTDIR)$(docdir)
187
	$(mkdir_p) $(DESTDIR)$(docdir)
160
	@list='$(doc_DATA)'; for p in $$list; do \
188
	@list='$(doc_DATA)'; for p in $$list; do \
161
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
189
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
162
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
190
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
Lines 177-186 Link Here
177
ctags: CTAGS
205
ctags: CTAGS
178
CTAGS:
206
CTAGS:
179
207
180
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
181
182
top_distdir = ../..
183
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
184
208
185
distdir: $(DISTFILES)
209
distdir: $(DISTFILES)
186
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
210
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 194-200 Link Here
194
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
218
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
195
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
219
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
196
	    dir="/$$dir"; \
220
	    dir="/$$dir"; \
197
	    $(mkinstalldirs) "$(distdir)$$dir"; \
221
	    $(mkdir_p) "$(distdir)$$dir"; \
198
	  else \
222
	  else \
199
	    dir=''; \
223
	    dir=''; \
200
	  fi; \
224
	  fi; \
Lines 212-220 Link Here
212
check-am: all-am
236
check-am: all-am
213
check: check-am
237
check: check-am
214
all-am: Makefile $(DATA)
238
all-am: Makefile $(DATA)
215
216
installdirs:
239
installdirs:
217
	$(mkinstalldirs) $(DESTDIR)$(docdir)
240
	$(mkdir_p) $(DESTDIR)$(docdir)
218
install: install-am
241
install: install-am
219
install-exec: install-exec-am
242
install-exec: install-exec-am
220
install-data: install-data-am
243
install-data: install-data-am
Lines 226-232 Link Here
226
installcheck: installcheck-am
249
installcheck: installcheck-am
227
install-strip:
250
install-strip:
228
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
251
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
229
	  INSTALL_STRIP_FLAG=-s \
252
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
230
	  `test -z '$(STRIP)' || \
253
	  `test -z '$(STRIP)' || \
231
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
254
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
232
mostlyclean-generic:
255
mostlyclean-generic:
Lines 234-240 Link Here
234
clean-generic:
257
clean-generic:
235
258
236
distclean-generic:
259
distclean-generic:
237
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
260
	-rm -f $(CONFIG_CLEAN_FILES)
238
261
239
maintainer-clean-generic:
262
maintainer-clean-generic:
240
	@echo "This command is intended for maintainers to use"
263
	@echo "This command is intended for maintainers to use"
Lines 244-256 Link Here
244
clean-am: clean-generic mostlyclean-am
267
clean-am: clean-generic mostlyclean-am
245
268
246
distclean: distclean-am
269
distclean: distclean-am
247
270
	-rm -f Makefile
248
distclean-am: clean-am distclean-generic
271
distclean-am: clean-am distclean-generic
249
272
250
dvi: dvi-am
273
dvi: dvi-am
251
274
252
dvi-am:
275
dvi-am:
253
276
277
html: html-am
278
254
info: info-am
279
info: info-am
255
280
256
info-am:
281
info-am:
Lines 266-272 Link Here
266
installcheck-am:
291
installcheck-am:
267
292
268
maintainer-clean: maintainer-clean-am
293
maintainer-clean: maintainer-clean-am
269
294
	-rm -f Makefile
270
maintainer-clean-am: distclean-am maintainer-clean-generic
295
maintainer-clean-am: distclean-am maintainer-clean-generic
271
296
272
mostlyclean: mostlyclean-am
297
mostlyclean: mostlyclean-am
Lines 284-296 Link Here
284
uninstall-am: uninstall-docDATA uninstall-info-am
309
uninstall-am: uninstall-docDATA uninstall-info-am
285
310
286
.PHONY: all all-am check check-am clean clean-generic distclean \
311
.PHONY: all all-am check check-am clean clean-generic distclean \
287
	distclean-generic distdir dvi dvi-am info info-am install \
312
	distclean-generic distdir dvi dvi-am html html-am info info-am \
288
	install-am install-data install-data-am install-docDATA \
313
	install install-am install-data install-data-am \
289
	install-exec install-exec-am install-info install-info-am \
314
	install-docDATA install-exec install-exec-am install-info \
290
	install-man install-strip installcheck installcheck-am \
315
	install-info-am install-man install-strip installcheck \
291
	installdirs maintainer-clean maintainer-clean-generic \
316
	installcheck-am installdirs maintainer-clean \
292
	mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
317
	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
293
	uninstall-am uninstall-docDATA uninstall-info-am
318
	pdf-am ps ps-am uninstall uninstall-am uninstall-docDATA \
319
	uninstall-info-am
294
320
295
# Tell versions [3.59,3.63) of GNU make to not export all variables.
321
# Tell versions [3.59,3.63) of GNU make to not export all variables.
296
# Otherwise a system limit (for SysV at least) may be exceeded.
322
# Otherwise a system limit (for SysV at least) may be exceeded.
(-)valgrind-2.1.0/none/docs/nl_main.html (-1 / +1 lines)
Lines 31-37 Link Here
31
31
32
<center>
32
<center>
33
<a href="mailto:njn25@cam.ac.uk">njn25@cam.ac.uk</a><br>
33
<a href="mailto:njn25@cam.ac.uk">njn25@cam.ac.uk</a><br>
34
Copyright &copy; 2000-2003 Nicholas Nethercote
34
Copyright &copy; 2000-2004 Nicholas Nethercote
35
<p>
35
<p>
36
Nulgrind is licensed under the GNU General Public License, 
36
Nulgrind is licensed under the GNU General Public License, 
37
version 2<br>
37
version 2<br>
(-)valgrind-2.1.0/none/nl_main.c (-15 / +22 lines)
Lines 7-13 Link Here
7
   This file is part of Nulgrind, the simplest possible Valgrind tool,
7
   This file is part of Nulgrind, the simplest possible Valgrind tool,
8
   which does nothing.
8
   which does nothing.
9
9
10
   Copyright (C) 2002-2003 Nicholas Nethercote
10
   Copyright (C) 2002-2004 Nicholas Nethercote
11
      njn25@cam.ac.uk
11
      njn25@cam.ac.uk
12
12
13
   This program is free software; you can redistribute it and/or
13
   This program is free software; you can redistribute it and/or
Lines 30-62 Link Here
30
30
31
#include "vg_skin.h"
31
#include "vg_skin.h"
32
32
33
VG_DETERMINE_INTERFACE_VERSION
33
//float SK_(shadow_ratio) = 9. / 8.;
34
34
35
void SK_(pre_clo_init)(void)
35
static void post_clo_init(void)
36
{
36
{
37
   VG_(details_name)            ("Nulgrind");
38
   VG_(details_version)         (NULL);
39
   VG_(details_description)     ("a binary JIT-compiler");
40
   VG_(details_copyright_author)(
41
      "Copyright (C) 2002-2003, and GNU GPL'd, by Nicholas Nethercote.");
42
   VG_(details_bug_reports_to)  (VG_BUGS_TO);
43
44
   /* No needs, no core events to track */
45
}
37
}
46
38
47
void SK_(post_clo_init)(void)
39
static UCodeBlock* instrument(UCodeBlock* cb, Addr a)
48
{
40
{
41
    return cb;
49
}
42
}
50
43
51
UCodeBlock* SK_(instrument)(UCodeBlock* cb, Addr a)
44
static void fini(Int exitcode)
52
{
45
{
53
    return cb;
54
}
46
}
55
47
56
void SK_(fini)(Int exitcode)
48
static void pre_clo_init(void)
57
{
49
{
50
   VG_(details_name)            ("Nulgrind");
51
   VG_(details_version)         (NULL);
52
   VG_(details_description)     ("a binary JIT-compiler");
53
   VG_(details_copyright_author)(
54
      "Copyright (C) 2002-2004, and GNU GPL'd, by Nicholas Nethercote.");
55
   VG_(details_bug_reports_to)  (VG_BUGS_TO);
56
57
   /* No needs, no core events to track */
58
59
   /* entrypoints */
60
   VG_(init_post_clo_init)(post_clo_init);
61
   VG_(init_instrument)(instrument);
62
   VG_(init_fini)(fini);
58
}
63
}
59
64
65
VG_DETERMINE_INTERFACE_VERSION(pre_clo_init, 0)
66
60
/*--------------------------------------------------------------------*/
67
/*--------------------------------------------------------------------*/
61
/*--- end                                                nl_main.c ---*/
68
/*--- end                                                nl_main.c ---*/
62
/*--------------------------------------------------------------------*/
69
/*--------------------------------------------------------------------*/
(-)valgrind-2.1.0/none/tests/.cvsignore (+46 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
3
args
4
bitfield1
5
bt_everything
6
bt_literal
7
coolo_sigaction
8
coolo_strlen
9
cpuid
10
dastest
11
discard
12
floored
13
fork
14
fpu_lazy_eflags
15
fucomip
16
gxx304
17
map_unmap
18
munmap_exe
19
mremap
20
pluto
21
pth_blockedsig
22
rcl_assert
23
rcrl
24
readline1
25
resolv
26
seg_override
27
sha1_test
28
shortpush
29
shorts
30
smc1
31
pth_atfork1
32
pth_cancel1
33
pth_cancel2
34
pth_cvsimple
35
pth_mutexspeed
36
pth_once
37
pth_semaphore1
38
pth_simple_mutex
39
pth_simple_threads
40
pth_specific
41
pth_yield
42
*.stdout.diff
43
*.stderr.diff
44
*.stdout.out
45
*.stderr.out
46
yield
(-)valgrind-2.1.0/none/tests/CVS/Entries (+144 lines)
Line 0 Link Here
1
/.cvsignore/1.8/Sat Jan  3 15:21:55 2004//
2
/Makefile.am/1.24/Wed Feb 11 23:33:29 2004//
3
/args.c/1.1/Mon Feb 24 22:05:36 2003//
4
/args.stderr.exp/1.1/Mon Feb 24 22:05:37 2003//
5
/args.stdout.exp/1.1/Mon Feb 24 22:05:37 2003//
6
/args.vgtest/1.1/Mon Feb 24 22:05:38 2003//
7
/bitfield1.c/1.3/Sat Jan  3 14:24:42 2004//
8
/bitfield1.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
9
/bitfield1.vgtest/1.2/Mon Sep 23 09:36:25 2002//
10
/bt_everything.c/1.2/Mon Sep 23 09:36:25 2002//
11
/bt_everything.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
12
/bt_everything.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
13
/bt_everything.vgtest/1.2/Mon Sep 23 09:36:25 2002//
14
/bt_literal.c/1.2/Mon Sep 23 09:36:25 2002//
15
/bt_literal.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
16
/bt_literal.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
17
/bt_literal.vgtest/1.2/Mon Sep 23 09:36:25 2002//
18
/coolo_sigaction.cpp/1.2/Mon Sep 23 09:36:25 2002//
19
/coolo_sigaction.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
20
/coolo_sigaction.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
21
/coolo_sigaction.vgtest/1.2/Mon Sep 23 09:36:25 2002//
22
/coolo_strlen.c/1.2/Mon Sep 23 09:36:25 2002//
23
/coolo_strlen.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
24
/coolo_strlen.vgtest/1.2/Mon Sep 23 09:36:25 2002//
25
/cpuid.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
26
/cpuid.stdout.exp/1.4/Sun Jun 29 10:12:58 2003//
27
/cpuid.vgtest/1.3/Sun Jun 29 10:12:58 2003//
28
/cpuid_c.c/1.2/Mon Sep 23 09:36:25 2002//
29
/cpuid_s.s/1.2/Mon Sep 23 09:36:25 2002//
30
/dastest.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
31
/dastest.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
32
/dastest.vgtest/1.2/Mon Sep 23 09:36:25 2002//
33
/dastest_c.c/1.2/Mon Sep 23 09:36:25 2002//
34
/dastest_s.s/1.2/Mon Sep 23 09:36:25 2002//
35
/discard.c/1.3/Thu Nov 13 23:02:16 2003//
36
/discard.stderr.exp/1.2/Sun Dec 15 02:51:21 2002//
37
/discard.stdout.exp/1.1/Fri Oct  4 14:16:37 2002//
38
/discard.vgtest/1.1/Fri Oct  4 14:16:37 2002//
39
/exec-sigmask.c/1.1/Fri Jan 16 05:37:46 2004//
40
/exec-sigmask.stderr.exp/1.1/Fri Jan 16 02:17:29 2004//
41
/exec-sigmask.stdout.exp/1.1/Fri Jan 16 02:19:15 2004//
42
/exec-sigmask.vgtest/1.1/Wed Jan 21 01:20:38 2004//
43
/filter_cpuid/1.1/Sun Jun 29 10:12:58 2003//
44
/filter_none_discards/1.1/Wed Oct 30 15:22:03 2002//
45
/filter_stderr/1.3/Mon Sep 23 11:21:55 2002//
46
/floored.c/1.2/Mon Sep 23 09:36:25 2002//
47
/floored.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
48
/floored.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
49
/floored.vgtest/1.2/Mon Sep 23 09:36:25 2002//
50
/fork.c/1.4/Tue Jan  6 21:46:02 2004//
51
/fork.stderr.exp/1.4/Tue Jan  6 21:46:02 2004//
52
/fork.stdout.exp/1.3/Fri Sep 27 10:38:20 2002//
53
/fork.vgtest/1.3/Tue Jan  6 21:46:02 2004//
54
/fpu_lazy_eflags.c/1.1/Tue Apr  8 10:04:31 2003//
55
/fpu_lazy_eflags.stderr.exp/1.1/Tue Apr  8 10:04:32 2003//
56
/fpu_lazy_eflags.stdout.exp/1.1/Tue Apr  8 10:04:32 2003//
57
/fpu_lazy_eflags.vgtest/1.1/Tue Apr  8 10:04:32 2003//
58
/fucomip.c/1.2/Mon Sep 23 09:36:25 2002//
59
/fucomip.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
60
/fucomip.vgtest/1.2/Mon Sep 23 09:36:25 2002//
61
/gen_insn_test.pl/1.2/Wed Feb 11 23:33:29 2004//
62
/gxx304.cpp/1.2/Mon Sep 23 09:36:25 2002//
63
/gxx304.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
64
/gxx304.vgtest/1.2/Mon Sep 23 09:36:25 2002//
65
/insn_mmx.def/1.2/Wed Feb 11 23:33:29 2004//
66
/insn_mmx.stderr.exp/1.1/Tue Jan 20 09:24:53 2004//
67
/insn_mmx.stdout.exp/1.1/Tue Jan 20 09:24:53 2004//
68
/insn_mmx.vgtest/1.1/Tue Jan 20 09:24:53 2004//
69
/insn_sse.def/1.2/Wed Feb 11 23:33:29 2004//
70
/insn_sse.stderr.exp/1.1/Tue Jan 20 09:24:53 2004//
71
/insn_sse.stdout.exp/1.1/Tue Jan 20 09:24:53 2004//
72
/insn_sse.vgtest/1.1/Tue Jan 20 09:24:53 2004//
73
/insn_sse2.def/1.2/Wed Feb 11 23:33:29 2004//
74
/insn_sse2.stderr.exp/1.1/Tue Jan 20 09:24:53 2004//
75
/insn_sse2.stdout.exp/1.1/Tue Jan 20 09:24:53 2004//
76
/insn_sse2.vgtest/1.1/Tue Jan 20 09:24:53 2004//
77
/map_unmap.c/1.4/Mon Jan 19 21:47:52 2004//
78
/map_unmap.stderr.exp/1.1/Fri Dec 19 21:56:04 2003//
79
/map_unmap.stdout.exp/1.1/Fri Dec 19 21:56:04 2003//
80
/map_unmap.vgtest/1.1/Fri Dec 19 21:56:04 2003//
81
/mremap.c/1.1/Mon Dec 22 08:48:50 2003//
82
/mremap.stderr.exp/1.1/Mon Dec 22 08:48:50 2003//
83
/mremap.stdout.exp/1.1/Mon Dec 22 08:48:50 2003//
84
/mremap.vgtest/1.1/Mon Dec 22 08:48:50 2003//
85
/munmap_exe.c/1.3/Sat Jan  3 14:24:42 2004//
86
/munmap_exe.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
87
/munmap_exe.vgtest/1.2/Mon Sep 23 09:36:25 2002//
88
/pth_blockedsig.c/1.2/Mon Sep 23 09:36:25 2002//
89
/pth_blockedsig.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
90
/pth_blockedsig.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
91
/pth_blockedsig.vgtest/1.2/Mon Sep 23 09:36:25 2002//
92
/pth_specific.c/1.2/Mon Sep 23 09:36:25 2002//
93
/rcl_assert.S/1.2/Mon Sep 23 09:36:25 2002//
94
/rcl_assert.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
95
/rcl_assert.vgtest/1.2/Mon Sep 23 09:36:25 2002//
96
/rcrl.c/1.2/Mon Sep 23 09:36:25 2002//
97
/rcrl.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
98
/rcrl.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
99
/rcrl.vgtest/1.2/Mon Sep 23 09:36:25 2002//
100
/readline1.c/1.2/Mon Sep 23 09:36:25 2002//
101
/readline1.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
102
/readline1.stdout.exp/1.2/Mon Sep 23 09:36:25 2002//
103
/readline1.vgtest/1.2/Mon Sep 23 09:36:25 2002//
104
/resolv.c/1.3/Sat Jan  3 14:24:42 2004//
105
/resolv.stderr.exp/1.1/Tue Oct  1 11:45:34 2002//
106
/resolv.stdout.exp/1.2/Thu Apr  3 00:50:21 2003//
107
/resolv.vgtest/1.1/Tue Oct  1 11:45:34 2002//
108
/seg_override.c/1.2/Wed Jan 21 01:27:27 2004//
109
/seg_override.stderr.exp/1.1/Wed Oct  2 10:36:46 2002//
110
/seg_override.stdout.exp/1.1/Wed Oct  2 10:36:46 2002//
111
/seg_override.vgtest/1.1/Wed Oct  2 10:36:46 2002//
112
/sha1_test.c/1.4/Sat Jan  3 14:24:42 2004//
113
/sha1_test.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
114
/sha1_test.vgtest/1.2/Mon Sep 23 09:36:25 2002//
115
/shortpush.c/1.2/Mon Sep 23 09:36:25 2002//
116
/shortpush.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
117
/shortpush.vgtest/1.2/Mon Sep 23 09:36:25 2002//
118
/shorts.c/1.2/Mon Sep 23 09:36:25 2002//
119
/shorts.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
120
/shorts.vgtest/1.2/Mon Sep 23 09:36:25 2002//
121
/smc1.c/1.3/Tue Dec 16 02:05:15 2003//
122
/smc1.stderr.exp/1.2/Mon Sep 23 09:36:25 2002//
123
/smc1.stdout.exp/1.3/Tue Dec 16 02:05:15 2003//
124
/smc1.vgtest/1.2/Mon Sep 23 09:36:25 2002//
125
/syscall-restart1.c/1.1/Fri Jan 16 02:15:23 2004//
126
/syscall-restart1.stderr.exp/1.1/Fri Jan 16 02:15:23 2004//
127
/syscall-restart1.stdout.exp/1.1/Fri Jan 16 02:15:23 2004//
128
/syscall-restart1.vgtest/1.1/Fri Jan 16 02:15:23 2004//
129
/syscall-restart2.c/1.1/Fri Jan 16 02:15:23 2004//
130
/syscall-restart2.stderr.exp/1.1/Fri Jan 16 02:15:23 2004//
131
/syscall-restart2.stdout.exp/1.1/Fri Jan 16 02:15:23 2004//
132
/syscall-restart2.vgtest/1.1/Fri Jan 16 02:15:23 2004//
133
/tls.c/1.1/Wed Jan 21 01:27:27 2004//
134
/tls.stderr.exp/1.1/Wed Jan 21 01:27:27 2004//
135
/tls.stdout.exp/1.1/Wed Jan 21 01:27:27 2004//
136
/tls.vgtest/1.1/Wed Jan 21 01:27:27 2004//
137
/tls2.c/1.1/Wed Jan 21 01:27:27 2004//
138
/tls2_so.c/1.1/Wed Jan 21 01:27:27 2004//
139
/tls_so.c/1.1/Wed Jan 21 01:27:27 2004//
140
/yield.c/1.1/Thu Dec 18 09:08:51 2003//
141
/yield.stderr.exp/1.1/Thu Dec 18 09:08:51 2003//
142
/yield.stdout.exp/1.1/Thu Dec 18 09:08:51 2003//
143
/yield.vgtest/1.1/Thu Dec 18 09:08:51 2003//
144
D
(-)valgrind-2.1.0/none/tests/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/none/tests
(-)valgrind-2.1.0/none/tests/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/none/tests/Makefile.am (-6 / +63 lines)
Lines 15-20 Link Here
15
	dastest.vgtest \
15
	dastest.vgtest \
16
	discard.stderr.exp discard.stdout.exp \
16
	discard.stderr.exp discard.stdout.exp \
17
	discard.vgtest \
17
	discard.vgtest \
18
	exec-sigmask.vgtest 
19
	exec-sigmask.stdout.exp exec-sigmask.stderr.exp \
18
	floored.stderr.exp floored.stdout.exp \
20
	floored.stderr.exp floored.stdout.exp \
19
	floored.vgtest \
21
	floored.vgtest \
20
	fork.stderr.exp fork.stdout.exp fork.vgtest \
22
	fork.stderr.exp fork.stdout.exp fork.vgtest \
Lines 22-27 Link Here
22
	fpu_lazy_eflags.vgtest \
24
	fpu_lazy_eflags.vgtest \
23
	fucomip.stderr.exp fucomip.vgtest \
25
	fucomip.stderr.exp fucomip.vgtest \
24
	gxx304.stderr.exp gxx304.vgtest \
26
	gxx304.stderr.exp gxx304.vgtest \
27
	insn_basic.stderr.exp insn_basic.stdout.exp insn_basic.vgtest \
28
	insn_cmov.stderr.exp insn_cmov.stdout.exp insn_cmov.vgtest \
29
	insn_mmx.stderr.exp insn_mmx.stdout.exp insn_mmx.vgtest \
30
	insn_mmxext.stderr.exp insn_mmxext.stdout.exp insn_mmxext.vgtest \
31
	insn_sse.stderr.exp insn_sse.stdout.exp insn_sse.vgtest \
32
	insn_sse2.stderr.exp insn_sse2.stdout.exp insn_sse2.vgtest \
33
	map_unmap.stdout.exp map_unmap.vgtest \
34
	mremap.stdout.exp mremap.vgtest \
25
	munmap_exe.stderr.exp munmap_exe.vgtest \
35
	munmap_exe.stderr.exp munmap_exe.vgtest \
26
	pth_blockedsig.stderr.exp \
36
	pth_blockedsig.stderr.exp \
27
	pth_blockedsig.stdout.exp pth_blockedsig.vgtest \
37
	pth_blockedsig.stdout.exp pth_blockedsig.vgtest \
Lines 35-51 Link Here
35
	sha1_test.stderr.exp sha1_test.vgtest \
45
	sha1_test.stderr.exp sha1_test.vgtest \
36
	shortpush.stderr.exp shortpush.vgtest \
46
	shortpush.stderr.exp shortpush.vgtest \
37
	shorts.stderr.exp shorts.vgtest \
47
	shorts.stderr.exp shorts.vgtest \
38
	smc1.stderr.exp smc1.stdout.exp smc1.vgtest
48
	tls.stderr.exp tls.stdout.exp tls.vgtest \
49
	smc1.stderr.exp smc1.stdout.exp smc1.vgtest \
50
	syscall-restart1.vgtest syscall-restart1.stdout.exp syscall-restart1.stderr.exp \
51
	syscall-restart2.vgtest syscall-restart2.stdout.exp syscall-restart2.stderr.exp \
52
	yield.stdout.exp yield.vgtest
39
53
40
check_PROGRAMS = \
54
check_PROGRAMS = \
41
	args bitfield1 bt_everything bt_literal coolo_strlen \
55
	args bitfield1 bt_everything bt_literal coolo_strlen \
42
	cpuid dastest discard floored fork fpu_lazy_eflags \
56
	cpuid dastest discard exec-sigmask floored fork fpu_lazy_eflags \
43
	fucomip munmap_exe rcl_assert \
57
	fucomip insn_basic insn_cmov insn_mmx insn_mmxext insn_sse insn_sse2 \
58
	munmap_exe map_unmap mremap rcl_assert \
44
	rcrl readline1 resolv seg_override sha1_test shortpush shorts smc1 \
59
	rcrl readline1 resolv seg_override sha1_test shortpush shorts smc1 \
45
	pth_blockedsig \
60
	tls.so tls2.so tls pth_blockedsig \
46
	coolo_sigaction gxx304
61
	syscall-restart1 syscall-restart2 \
62
	coolo_sigaction gxx304 yield
47
63
48
AM_CFLAGS   = $(WERROR) -Winline -Wall -Wshadow -g
64
AM_CFLAGS   = $(WERROR) -Winline -Wall -Wshadow -g -I$(top_srcdir)/include
49
AM_CXXFLAGS = $(AM_CFLAGS)
65
AM_CXXFLAGS = $(AM_CFLAGS)
50
66
51
# generic C ones
67
# generic C ones
Lines 57-67 Link Here
57
coolo_strlen_SOURCES 	= coolo_strlen.c
73
coolo_strlen_SOURCES 	= coolo_strlen.c
58
dastest_SOURCES 	= dastest_c.c dastest_s.s
74
dastest_SOURCES 	= dastest_c.c dastest_s.s
59
discard_SOURCES 	= discard.c
75
discard_SOURCES 	= discard.c
76
exec_sigmask_SOURCES	= exec-sigmask.c
60
fork_SOURCES 		= fork.c
77
fork_SOURCES 		= fork.c
61
floored_SOURCES 	= floored.c
78
floored_SOURCES 	= floored.c
62
floored_LDADD 		= -lm
79
floored_LDADD 		= -lm
63
fpu_lazy_eflags_SOURCES	= fpu_lazy_eflags.c
80
fpu_lazy_eflags_SOURCES	= fpu_lazy_eflags.c
64
fucomip_SOURCES 	= fucomip.c
81
fucomip_SOURCES 	= fucomip.c
82
insn_basic_SOURCES	= insn_basic.def
83
insn_basic_LDADD	= -lm
84
insn_cmov_SOURCES	= insn_cmov.def
85
insn_cmov_LDADD		= -lm
86
insn_mmx_SOURCES	= insn_mmx.def
87
insn_mmx_LDADD		= -lm
88
insn_mmxext_SOURCES	= insn_mmxext.def
89
insn_mmxext_LDADD	= -lm
90
insn_sse_SOURCES	= insn_sse.def
91
insn_sse_LDADD		= -lm
92
insn_sse2_SOURCES	= insn_sse2.def
93
insn_sse2_LDADD		= -lm
94
map_unmap_SOURCES	= map_unmap.c
95
mremap_SOURCES		= mremap.c
65
munmap_exe_SOURCES 	= munmap_exe.c
96
munmap_exe_SOURCES 	= munmap_exe.c
66
rcl_assert_SOURCES 	= rcl_assert.S
97
rcl_assert_SOURCES 	= rcl_assert.S
67
rcrl_SOURCES 		= rcrl.c
98
rcrl_SOURCES 		= rcrl.c
Lines 72-77 Link Here
72
sha1_test_SOURCES 	= sha1_test.c
103
sha1_test_SOURCES 	= sha1_test.c
73
shortpush_SOURCES 	= shortpush.c
104
shortpush_SOURCES 	= shortpush.c
74
shorts_SOURCES 		= shorts.c
105
shorts_SOURCES 		= shorts.c
106
syscall_restart1_SOURCES = syscall-restart1.c
107
syscall_restart2_SOURCES = syscall-restart2.c
108
tls_SOURCES		= tls.c tls2.c
109
tls_DEPENDENCIES	= tls.so
110
tls_LDFLAGS		= -Wl,-rpath,$(srcdir)
111
tls_LDADD		= tls.so -lpthread
112
tls_so_SOURCES		= tls_so.c
113
tls_so_LDADD		= tls2.so
114
tls_so_DEPENDENCIES	= tls2.so
115
tls_so_LDFLAGS		= -Wl,-rpath,$(srcdir) -shared
116
tls2_so_SOURCES		= tls2_so.c
117
tls2_so_LDFLAGS		= -shared
118
yield_SOURCES		= yield.c
119
yield_LDADD		= -lpthread
120
121
tls_so.o tls2_so.o: CFLAGS += -fpic
75
122
76
# pthread C ones
123
# pthread C ones
77
pth_blockedsig_SOURCES	= pth_blockedsig.c
124
pth_blockedsig_SOURCES	= pth_blockedsig.c
Lines 84-86 Link Here
84
# must be built with these flags -- bug only occurred with them
131
# must be built with these flags -- bug only occurred with them
85
fpu_lazy_eflags.o: CFLAGS += -O2 -mcpu=pentiumpro -march=pentiumpro
132
fpu_lazy_eflags.o: CFLAGS += -O2 -mcpu=pentiumpro -march=pentiumpro
86
133
134
# rebuild instruction tests if test generator changes
135
insn_basic.c: gen_insn_test.pl
136
insn_cmov.c: gen_insn_test.pl
137
insn_mmx.c: gen_insn_test.pl
138
insn_mmxext.c: gen_insn_test.pl
139
insn_sse.c: gen_insn_test.pl
140
insn_sse2.c: gen_insn_test.pl
141
142
.def.c:
143
	$(PERL) gen_insn_test.pl < $< > $@
(-)valgrind-2.1.0/none/tests/Makefile.in (-282 / +424 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 14-19 Link Here
14
14
15
@SET_MAKE@
15
@SET_MAKE@
16
16
17
SOURCES = $(args_SOURCES) $(bitfield1_SOURCES) $(bt_everything_SOURCES) $(bt_literal_SOURCES) $(coolo_sigaction_SOURCES) $(coolo_strlen_SOURCES) $(cpuid_SOURCES) $(dastest_SOURCES) $(discard_SOURCES) $(exec_sigmask_SOURCES) $(floored_SOURCES) $(fork_SOURCES) $(fpu_lazy_eflags_SOURCES) $(fucomip_SOURCES) $(gxx304_SOURCES) $(insn_basic_SOURCES) $(insn_cmov_SOURCES) $(insn_mmx_SOURCES) $(insn_mmxext_SOURCES) $(insn_sse_SOURCES) $(insn_sse2_SOURCES) $(map_unmap_SOURCES) $(mremap_SOURCES) $(munmap_exe_SOURCES) $(pth_blockedsig_SOURCES) $(rcl_assert_SOURCES) $(rcrl_SOURCES) $(readline1_SOURCES) $(resolv_SOURCES) $(seg_override_SOURCES) $(sha1_test_SOURCES) $(shortpush_SOURCES) $(shorts_SOURCES) $(smc1_SOURCES) $(syscall_restart1_SOURCES) $(syscall_restart2_SOURCES) $(tls_SOURCES) $(tls_so_SOURCES) $(tls2_so_SOURCES) $(yield_SOURCES)
18
17
srcdir = @srcdir@
19
srcdir = @srcdir@
18
top_srcdir = @top_srcdir@
20
top_srcdir = @top_srcdir@
19
VPATH = @srcdir@
21
VPATH = @srcdir@
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
23
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
24
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
25
top_builddir = ../..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
27
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
28
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
37
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
38
POST_UNINSTALL = :
38
host_triplet = @host@
39
host_triplet = @host@
40
check_PROGRAMS = args$(EXEEXT) bitfield1$(EXEEXT) \
41
	bt_everything$(EXEEXT) bt_literal$(EXEEXT) \
42
	coolo_strlen$(EXEEXT) cpuid$(EXEEXT) dastest$(EXEEXT) \
43
	discard$(EXEEXT) exec-sigmask$(EXEEXT) floored$(EXEEXT) \
44
	fork$(EXEEXT) fpu_lazy_eflags$(EXEEXT) fucomip$(EXEEXT) \
45
	insn_basic$(EXEEXT) insn_cmov$(EXEEXT) insn_mmx$(EXEEXT) \
46
	insn_mmxext$(EXEEXT) insn_sse$(EXEEXT) insn_sse2$(EXEEXT) \
47
	munmap_exe$(EXEEXT) map_unmap$(EXEEXT) mremap$(EXEEXT) \
48
	rcl_assert$(EXEEXT) rcrl$(EXEEXT) readline1$(EXEEXT) \
49
	resolv$(EXEEXT) seg_override$(EXEEXT) sha1_test$(EXEEXT) \
50
	shortpush$(EXEEXT) shorts$(EXEEXT) smc1$(EXEEXT) \
51
	tls.so$(EXEEXT) tls2.so$(EXEEXT) tls$(EXEEXT) \
52
	pth_blockedsig$(EXEEXT) syscall-restart1$(EXEEXT) \
53
	syscall-restart2$(EXEEXT) coolo_sigaction$(EXEEXT) \
54
	gxx304$(EXEEXT) yield$(EXEEXT)
55
subdir = none/tests
56
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
57
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
58
am__aclocal_m4_deps = $(top_srcdir)/configure.in
59
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
60
	$(ACLOCAL_M4)
61
mkinstalldirs = $(mkdir_p)
62
CONFIG_HEADER = $(top_builddir)/config.h
63
CONFIG_CLEAN_FILES =
64
am_args_OBJECTS = args.$(OBJEXT)
65
args_OBJECTS = $(am_args_OBJECTS)
66
args_LDADD = $(LDADD)
67
am_bitfield1_OBJECTS = bitfield1.$(OBJEXT)
68
bitfield1_OBJECTS = $(am_bitfield1_OBJECTS)
69
bitfield1_LDADD = $(LDADD)
70
am_bt_everything_OBJECTS = bt_everything.$(OBJEXT)
71
bt_everything_OBJECTS = $(am_bt_everything_OBJECTS)
72
bt_everything_LDADD = $(LDADD)
73
am_bt_literal_OBJECTS = bt_literal.$(OBJEXT)
74
bt_literal_OBJECTS = $(am_bt_literal_OBJECTS)
75
bt_literal_LDADD = $(LDADD)
76
am_coolo_sigaction_OBJECTS = coolo_sigaction.$(OBJEXT)
77
coolo_sigaction_OBJECTS = $(am_coolo_sigaction_OBJECTS)
78
coolo_sigaction_LDADD = $(LDADD)
79
am_coolo_strlen_OBJECTS = coolo_strlen.$(OBJEXT)
80
coolo_strlen_OBJECTS = $(am_coolo_strlen_OBJECTS)
81
coolo_strlen_LDADD = $(LDADD)
82
am_cpuid_OBJECTS = cpuid_c.$(OBJEXT) cpuid_s.$(OBJEXT)
83
cpuid_OBJECTS = $(am_cpuid_OBJECTS)
84
cpuid_LDADD = $(LDADD)
85
am_dastest_OBJECTS = dastest_c.$(OBJEXT) dastest_s.$(OBJEXT)
86
dastest_OBJECTS = $(am_dastest_OBJECTS)
87
dastest_LDADD = $(LDADD)
88
am_discard_OBJECTS = discard.$(OBJEXT)
89
discard_OBJECTS = $(am_discard_OBJECTS)
90
discard_LDADD = $(LDADD)
91
am_exec_sigmask_OBJECTS = exec-sigmask.$(OBJEXT)
92
exec_sigmask_OBJECTS = $(am_exec_sigmask_OBJECTS)
93
exec_sigmask_LDADD = $(LDADD)
94
am_floored_OBJECTS = floored.$(OBJEXT)
95
floored_OBJECTS = $(am_floored_OBJECTS)
96
floored_DEPENDENCIES =
97
am_fork_OBJECTS = fork.$(OBJEXT)
98
fork_OBJECTS = $(am_fork_OBJECTS)
99
fork_LDADD = $(LDADD)
100
am_fpu_lazy_eflags_OBJECTS = fpu_lazy_eflags.$(OBJEXT)
101
fpu_lazy_eflags_OBJECTS = $(am_fpu_lazy_eflags_OBJECTS)
102
fpu_lazy_eflags_LDADD = $(LDADD)
103
am_fucomip_OBJECTS = fucomip.$(OBJEXT)
104
fucomip_OBJECTS = $(am_fucomip_OBJECTS)
105
fucomip_LDADD = $(LDADD)
106
am_gxx304_OBJECTS = gxx304.$(OBJEXT)
107
gxx304_OBJECTS = $(am_gxx304_OBJECTS)
108
gxx304_LDADD = $(LDADD)
109
am_insn_basic_OBJECTS = insn_basic.$(OBJEXT)
110
insn_basic_OBJECTS = $(am_insn_basic_OBJECTS)
111
insn_basic_DEPENDENCIES =
112
am_insn_cmov_OBJECTS = insn_cmov.$(OBJEXT)
113
insn_cmov_OBJECTS = $(am_insn_cmov_OBJECTS)
114
insn_cmov_DEPENDENCIES =
115
am_insn_mmx_OBJECTS = insn_mmx.$(OBJEXT)
116
insn_mmx_OBJECTS = $(am_insn_mmx_OBJECTS)
117
insn_mmx_DEPENDENCIES =
118
am_insn_mmxext_OBJECTS = insn_mmxext.$(OBJEXT)
119
insn_mmxext_OBJECTS = $(am_insn_mmxext_OBJECTS)
120
insn_mmxext_DEPENDENCIES =
121
am_insn_sse_OBJECTS = insn_sse.$(OBJEXT)
122
insn_sse_OBJECTS = $(am_insn_sse_OBJECTS)
123
insn_sse_DEPENDENCIES =
124
am_insn_sse2_OBJECTS = insn_sse2.$(OBJEXT)
125
insn_sse2_OBJECTS = $(am_insn_sse2_OBJECTS)
126
insn_sse2_DEPENDENCIES =
127
am_map_unmap_OBJECTS = map_unmap.$(OBJEXT)
128
map_unmap_OBJECTS = $(am_map_unmap_OBJECTS)
129
map_unmap_LDADD = $(LDADD)
130
am_mremap_OBJECTS = mremap.$(OBJEXT)
131
mremap_OBJECTS = $(am_mremap_OBJECTS)
132
mremap_LDADD = $(LDADD)
133
am_munmap_exe_OBJECTS = munmap_exe.$(OBJEXT)
134
munmap_exe_OBJECTS = $(am_munmap_exe_OBJECTS)
135
munmap_exe_LDADD = $(LDADD)
136
am_pth_blockedsig_OBJECTS = pth_blockedsig.$(OBJEXT)
137
pth_blockedsig_OBJECTS = $(am_pth_blockedsig_OBJECTS)
138
pth_blockedsig_DEPENDENCIES =
139
am_rcl_assert_OBJECTS = rcl_assert.$(OBJEXT)
140
rcl_assert_OBJECTS = $(am_rcl_assert_OBJECTS)
141
rcl_assert_LDADD = $(LDADD)
142
am_rcrl_OBJECTS = rcrl.$(OBJEXT)
143
rcrl_OBJECTS = $(am_rcrl_OBJECTS)
144
rcrl_LDADD = $(LDADD)
145
am_readline1_OBJECTS = readline1.$(OBJEXT)
146
readline1_OBJECTS = $(am_readline1_OBJECTS)
147
readline1_LDADD = $(LDADD)
148
am_resolv_OBJECTS = resolv.$(OBJEXT)
149
resolv_OBJECTS = $(am_resolv_OBJECTS)
150
resolv_LDADD = $(LDADD)
151
am_seg_override_OBJECTS = seg_override.$(OBJEXT)
152
seg_override_OBJECTS = $(am_seg_override_OBJECTS)
153
seg_override_LDADD = $(LDADD)
154
am_sha1_test_OBJECTS = sha1_test.$(OBJEXT)
155
sha1_test_OBJECTS = $(am_sha1_test_OBJECTS)
156
sha1_test_LDADD = $(LDADD)
157
am_shortpush_OBJECTS = shortpush.$(OBJEXT)
158
shortpush_OBJECTS = $(am_shortpush_OBJECTS)
159
shortpush_LDADD = $(LDADD)
160
am_shorts_OBJECTS = shorts.$(OBJEXT)
161
shorts_OBJECTS = $(am_shorts_OBJECTS)
162
shorts_LDADD = $(LDADD)
163
am_smc1_OBJECTS = smc1.$(OBJEXT)
164
smc1_OBJECTS = $(am_smc1_OBJECTS)
165
smc1_LDADD = $(LDADD)
166
am_syscall_restart1_OBJECTS = syscall-restart1.$(OBJEXT)
167
syscall_restart1_OBJECTS = $(am_syscall_restart1_OBJECTS)
168
syscall_restart1_LDADD = $(LDADD)
169
am_syscall_restart2_OBJECTS = syscall-restart2.$(OBJEXT)
170
syscall_restart2_OBJECTS = $(am_syscall_restart2_OBJECTS)
171
syscall_restart2_LDADD = $(LDADD)
172
am_tls_OBJECTS = tls.$(OBJEXT) tls2.$(OBJEXT)
173
tls_OBJECTS = $(am_tls_OBJECTS)
174
am_tls_so_OBJECTS = tls_so.$(OBJEXT)
175
tls_so_OBJECTS = $(am_tls_so_OBJECTS)
176
am_tls2_so_OBJECTS = tls2_so.$(OBJEXT)
177
tls2_so_OBJECTS = $(am_tls2_so_OBJECTS)
178
tls2_so_LDADD = $(LDADD)
179
am_yield_OBJECTS = yield.$(OBJEXT)
180
yield_OBJECTS = $(am_yield_OBJECTS)
181
yield_DEPENDENCIES =
182
SCRIPTS = $(noinst_SCRIPTS)
183
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
184
depcomp = $(SHELL) $(top_srcdir)/depcomp
185
am__depfiles_maybe = depfiles
186
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/args.Po ./$(DEPDIR)/bitfield1.Po \
187
@AMDEP_TRUE@	./$(DEPDIR)/bt_everything.Po \
188
@AMDEP_TRUE@	./$(DEPDIR)/bt_literal.Po \
189
@AMDEP_TRUE@	./$(DEPDIR)/coolo_sigaction.Po \
190
@AMDEP_TRUE@	./$(DEPDIR)/coolo_strlen.Po ./$(DEPDIR)/cpuid_c.Po \
191
@AMDEP_TRUE@	./$(DEPDIR)/dastest_c.Po ./$(DEPDIR)/discard.Po \
192
@AMDEP_TRUE@	./$(DEPDIR)/exec-sigmask.Po ./$(DEPDIR)/floored.Po \
193
@AMDEP_TRUE@	./$(DEPDIR)/fork.Po ./$(DEPDIR)/fpu_lazy_eflags.Po \
194
@AMDEP_TRUE@	./$(DEPDIR)/fucomip.Po ./$(DEPDIR)/gxx304.Po \
195
@AMDEP_TRUE@	./$(DEPDIR)/insn_basic.Po ./$(DEPDIR)/insn_cmov.Po \
196
@AMDEP_TRUE@	./$(DEPDIR)/insn_mmx.Po ./$(DEPDIR)/insn_mmxext.Po \
197
@AMDEP_TRUE@	./$(DEPDIR)/insn_sse.Po ./$(DEPDIR)/insn_sse2.Po \
198
@AMDEP_TRUE@	./$(DEPDIR)/map_unmap.Po ./$(DEPDIR)/mremap.Po \
199
@AMDEP_TRUE@	./$(DEPDIR)/munmap_exe.Po \
200
@AMDEP_TRUE@	./$(DEPDIR)/pth_blockedsig.Po ./$(DEPDIR)/rcrl.Po \
201
@AMDEP_TRUE@	./$(DEPDIR)/readline1.Po ./$(DEPDIR)/resolv.Po \
202
@AMDEP_TRUE@	./$(DEPDIR)/seg_override.Po \
203
@AMDEP_TRUE@	./$(DEPDIR)/sha1_test.Po ./$(DEPDIR)/shortpush.Po \
204
@AMDEP_TRUE@	./$(DEPDIR)/shorts.Po ./$(DEPDIR)/smc1.Po \
205
@AMDEP_TRUE@	./$(DEPDIR)/syscall-restart1.Po \
206
@AMDEP_TRUE@	./$(DEPDIR)/syscall-restart2.Po ./$(DEPDIR)/tls.Po \
207
@AMDEP_TRUE@	./$(DEPDIR)/tls2.Po ./$(DEPDIR)/tls2_so.Po \
208
@AMDEP_TRUE@	./$(DEPDIR)/tls_so.Po ./$(DEPDIR)/yield.Po
209
CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
210
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
211
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
212
CCLD = $(CC)
213
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
214
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
215
	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
216
CXXLD = $(CXX)
217
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
218
	-o $@
219
SOURCES = $(args_SOURCES) $(bitfield1_SOURCES) \
220
	$(bt_everything_SOURCES) $(bt_literal_SOURCES) \
221
	$(coolo_sigaction_SOURCES) $(coolo_strlen_SOURCES) \
222
	$(cpuid_SOURCES) $(dastest_SOURCES) $(discard_SOURCES) \
223
	$(exec_sigmask_SOURCES) $(floored_SOURCES) $(fork_SOURCES) \
224
	$(fpu_lazy_eflags_SOURCES) $(fucomip_SOURCES) \
225
	$(gxx304_SOURCES) $(insn_basic_SOURCES) $(insn_cmov_SOURCES) \
226
	$(insn_mmx_SOURCES) $(insn_mmxext_SOURCES) $(insn_sse_SOURCES) \
227
	$(insn_sse2_SOURCES) $(map_unmap_SOURCES) $(mremap_SOURCES) \
228
	$(munmap_exe_SOURCES) $(pth_blockedsig_SOURCES) \
229
	$(rcl_assert_SOURCES) $(rcrl_SOURCES) $(readline1_SOURCES) \
230
	$(resolv_SOURCES) $(seg_override_SOURCES) $(sha1_test_SOURCES) \
231
	$(shortpush_SOURCES) $(shorts_SOURCES) $(smc1_SOURCES) \
232
	$(syscall_restart1_SOURCES) $(syscall_restart2_SOURCES) \
233
	$(tls_SOURCES) $(tls_so_SOURCES) $(tls2_so_SOURCES) \
234
	$(yield_SOURCES)
235
DIST_SOURCES = $(args_SOURCES) $(bitfield1_SOURCES) \
236
	$(bt_everything_SOURCES) $(bt_literal_SOURCES) \
237
	$(coolo_sigaction_SOURCES) $(coolo_strlen_SOURCES) \
238
	$(cpuid_SOURCES) $(dastest_SOURCES) $(discard_SOURCES) \
239
	$(exec_sigmask_SOURCES) $(floored_SOURCES) $(fork_SOURCES) \
240
	$(fpu_lazy_eflags_SOURCES) $(fucomip_SOURCES) \
241
	$(gxx304_SOURCES) $(insn_basic_SOURCES) $(insn_cmov_SOURCES) \
242
	$(insn_mmx_SOURCES) $(insn_mmxext_SOURCES) $(insn_sse_SOURCES) \
243
	$(insn_sse2_SOURCES) $(map_unmap_SOURCES) $(mremap_SOURCES) \
244
	$(munmap_exe_SOURCES) $(pth_blockedsig_SOURCES) \
245
	$(rcl_assert_SOURCES) $(rcrl_SOURCES) $(readline1_SOURCES) \
246
	$(resolv_SOURCES) $(seg_override_SOURCES) $(sha1_test_SOURCES) \
247
	$(shortpush_SOURCES) $(shorts_SOURCES) $(smc1_SOURCES) \
248
	$(syscall_restart1_SOURCES) $(syscall_restart2_SOURCES) \
249
	$(tls_SOURCES) $(tls_so_SOURCES) $(tls2_so_SOURCES) \
250
	$(yield_SOURCES)
251
ETAGS = etags
252
CTAGS = ctags
253
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
254
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
255
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
256
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
307
SHELL = @SHELL@
93
STRIP = @STRIP@
308
STRIP = @STRIP@
94
VERSION = @VERSION@
309
VERSION = @VERSION@
310
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
311
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
312
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
313
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
339
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
340
localstatedir = @localstatedir@
125
mandir = @mandir@
341
mandir = @mandir@
342
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
343
oldincludedir = @oldincludedir@
127
prefix = @prefix@
344
prefix = @prefix@
128
program_transform_name = @program_transform_name@
345
program_transform_name = @program_transform_name@
Lines 131-137 Link Here
131
sysconfdir = @sysconfdir@
348
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
349
target_alias = @target_alias@
133
noinst_SCRIPTS = filter_cpuid  filter_none_discards filter_stderr
350
noinst_SCRIPTS = filter_cpuid  filter_none_discards filter_stderr
134
135
EXTRA_DIST = $(noinst_SCRIPTS) \
351
EXTRA_DIST = $(noinst_SCRIPTS) \
136
	args.stderr.exp args.stdout.exp args.vgtest \
352
	args.stderr.exp args.stdout.exp args.vgtest \
137
	bitfield1.stderr.exp bitfield1.vgtest \
353
	bitfield1.stderr.exp bitfield1.vgtest \
Lines 147-185 Link Here
147
	dastest.vgtest \
363
	dastest.vgtest \
148
	discard.stderr.exp discard.stdout.exp \
364
	discard.stderr.exp discard.stdout.exp \
149
	discard.vgtest \
365
	discard.vgtest \
150
	floored.stderr.exp floored.stdout.exp \
366
	exec-sigmask.vgtest 
151
	floored.vgtest \
152
	fork.stderr.exp fork.stdout.exp fork.vgtest \
153
	fpu_lazy_eflags.stderr.exp fpu_lazy_eflags.stdout.exp \
154
	fpu_lazy_eflags.vgtest \
155
	fucomip.stderr.exp fucomip.vgtest \
156
	gxx304.stderr.exp gxx304.vgtest \
157
	munmap_exe.stderr.exp munmap_exe.vgtest \
158
	pth_blockedsig.stderr.exp \
159
	pth_blockedsig.stdout.exp pth_blockedsig.vgtest \
160
	rcl_assert.stderr.exp rcl_assert.vgtest \
161
	rcrl.stderr.exp rcrl.stdout.exp rcrl.vgtest \
162
	readline1.stderr.exp readline1.stdout.exp \
163
	readline1.vgtest \
164
	resolv.stderr.exp resolv.stdout.exp resolv.vgtest \
165
	seg_override.stderr.exp \
166
	seg_override.stdout.exp seg_override.vgtest \
167
	sha1_test.stderr.exp sha1_test.vgtest \
168
	shortpush.stderr.exp shortpush.vgtest \
169
	shorts.stderr.exp shorts.vgtest \
170
	smc1.stderr.exp smc1.stdout.exp smc1.vgtest
171
172
367
173
check_PROGRAMS = \
368
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g -I$(top_srcdir)/include
174
	args bitfield1 bt_everything bt_literal coolo_strlen \
175
	cpuid dastest discard floored fork fpu_lazy_eflags \
176
	fucomip munmap_exe rcl_assert \
177
	rcrl readline1 resolv seg_override sha1_test shortpush shorts smc1 \
178
	pth_blockedsig \
179
	coolo_sigaction gxx304
180
181
182
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g
183
AM_CXXFLAGS = $(AM_CFLAGS)
369
AM_CXXFLAGS = $(AM_CFLAGS)
184
370
185
# generic C ones
371
# generic C ones
Lines 191-201 Link Here
191
coolo_strlen_SOURCES = coolo_strlen.c
377
coolo_strlen_SOURCES = coolo_strlen.c
192
dastest_SOURCES = dastest_c.c dastest_s.s
378
dastest_SOURCES = dastest_c.c dastest_s.s
193
discard_SOURCES = discard.c
379
discard_SOURCES = discard.c
380
exec_sigmask_SOURCES = exec-sigmask.c
194
fork_SOURCES = fork.c
381
fork_SOURCES = fork.c
195
floored_SOURCES = floored.c
382
floored_SOURCES = floored.c
196
floored_LDADD = -lm
383
floored_LDADD = -lm
197
fpu_lazy_eflags_SOURCES = fpu_lazy_eflags.c
384
fpu_lazy_eflags_SOURCES = fpu_lazy_eflags.c
198
fucomip_SOURCES = fucomip.c
385
fucomip_SOURCES = fucomip.c
386
insn_basic_SOURCES = insn_basic.def
387
insn_basic_LDADD = -lm
388
insn_cmov_SOURCES = insn_cmov.def
389
insn_cmov_LDADD = -lm
390
insn_mmx_SOURCES = insn_mmx.def
391
insn_mmx_LDADD = -lm
392
insn_mmxext_SOURCES = insn_mmxext.def
393
insn_mmxext_LDADD = -lm
394
insn_sse_SOURCES = insn_sse.def
395
insn_sse_LDADD = -lm
396
insn_sse2_SOURCES = insn_sse2.def
397
insn_sse2_LDADD = -lm
398
map_unmap_SOURCES = map_unmap.c
399
mremap_SOURCES = mremap.c
199
munmap_exe_SOURCES = munmap_exe.c
400
munmap_exe_SOURCES = munmap_exe.c
200
rcl_assert_SOURCES = rcl_assert.S
401
rcl_assert_SOURCES = rcl_assert.S
201
rcrl_SOURCES = rcrl.c
402
rcrl_SOURCES = rcrl.c
Lines 206-211 Link Here
206
sha1_test_SOURCES = sha1_test.c
407
sha1_test_SOURCES = sha1_test.c
207
shortpush_SOURCES = shortpush.c
408
shortpush_SOURCES = shortpush.c
208
shorts_SOURCES = shorts.c
409
shorts_SOURCES = shorts.c
410
syscall_restart1_SOURCES = syscall-restart1.c
411
syscall_restart2_SOURCES = syscall-restart2.c
412
tls_SOURCES = tls.c tls2.c
413
tls_DEPENDENCIES = tls.so
414
tls_LDFLAGS = -Wl,-rpath,$(srcdir)
415
tls_LDADD = tls.so -lpthread
416
tls_so_SOURCES = tls_so.c
417
tls_so_LDADD = tls2.so
418
tls_so_DEPENDENCIES = tls2.so
419
tls_so_LDFLAGS = -Wl,-rpath,$(srcdir) -shared
420
tls2_so_SOURCES = tls2_so.c
421
tls2_so_LDFLAGS = -shared
422
yield_SOURCES = yield.c
423
yield_LDADD = -lpthread
209
424
210
# pthread C ones
425
# pthread C ones
211
pth_blockedsig_SOURCES = pth_blockedsig.c
426
pth_blockedsig_SOURCES = pth_blockedsig.c
Lines 214-409 Link Here
214
# generic C++ ones
429
# generic C++ ones
215
coolo_sigaction_SOURCES = coolo_sigaction.cpp
430
coolo_sigaction_SOURCES = coolo_sigaction.cpp
216
gxx304_SOURCES = gxx304.cpp
431
gxx304_SOURCES = gxx304.cpp
217
subdir = none/tests
218
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
219
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
220
CONFIG_HEADER = $(top_builddir)/config.h
221
CONFIG_CLEAN_FILES =
222
check_PROGRAMS = args$(EXEEXT) bitfield1$(EXEEXT) bt_everything$(EXEEXT) \
223
	bt_literal$(EXEEXT) coolo_strlen$(EXEEXT) cpuid$(EXEEXT) \
224
	dastest$(EXEEXT) discard$(EXEEXT) floored$(EXEEXT) \
225
	fork$(EXEEXT) fpu_lazy_eflags$(EXEEXT) fucomip$(EXEEXT) \
226
	munmap_exe$(EXEEXT) rcl_assert$(EXEEXT) rcrl$(EXEEXT) \
227
	readline1$(EXEEXT) resolv$(EXEEXT) seg_override$(EXEEXT) \
228
	sha1_test$(EXEEXT) shortpush$(EXEEXT) shorts$(EXEEXT) \
229
	smc1$(EXEEXT) pth_blockedsig$(EXEEXT) coolo_sigaction$(EXEEXT) \
230
	gxx304$(EXEEXT)
231
am_args_OBJECTS = args.$(OBJEXT)
232
args_OBJECTS = $(am_args_OBJECTS)
233
args_LDADD = $(LDADD)
234
args_DEPENDENCIES =
235
args_LDFLAGS =
236
am_bitfield1_OBJECTS = bitfield1.$(OBJEXT)
237
bitfield1_OBJECTS = $(am_bitfield1_OBJECTS)
238
bitfield1_LDADD = $(LDADD)
239
bitfield1_DEPENDENCIES =
240
bitfield1_LDFLAGS =
241
am_bt_everything_OBJECTS = bt_everything.$(OBJEXT)
242
bt_everything_OBJECTS = $(am_bt_everything_OBJECTS)
243
bt_everything_LDADD = $(LDADD)
244
bt_everything_DEPENDENCIES =
245
bt_everything_LDFLAGS =
246
am_bt_literal_OBJECTS = bt_literal.$(OBJEXT)
247
bt_literal_OBJECTS = $(am_bt_literal_OBJECTS)
248
bt_literal_LDADD = $(LDADD)
249
bt_literal_DEPENDENCIES =
250
bt_literal_LDFLAGS =
251
am_coolo_sigaction_OBJECTS = coolo_sigaction.$(OBJEXT)
252
coolo_sigaction_OBJECTS = $(am_coolo_sigaction_OBJECTS)
253
coolo_sigaction_LDADD = $(LDADD)
254
coolo_sigaction_DEPENDENCIES =
255
coolo_sigaction_LDFLAGS =
256
am_coolo_strlen_OBJECTS = coolo_strlen.$(OBJEXT)
257
coolo_strlen_OBJECTS = $(am_coolo_strlen_OBJECTS)
258
coolo_strlen_LDADD = $(LDADD)
259
coolo_strlen_DEPENDENCIES =
260
coolo_strlen_LDFLAGS =
261
am_cpuid_OBJECTS = cpuid_c.$(OBJEXT) cpuid_s.$(OBJEXT)
262
cpuid_OBJECTS = $(am_cpuid_OBJECTS)
263
cpuid_LDADD = $(LDADD)
264
cpuid_DEPENDENCIES =
265
cpuid_LDFLAGS =
266
am_dastest_OBJECTS = dastest_c.$(OBJEXT) dastest_s.$(OBJEXT)
267
dastest_OBJECTS = $(am_dastest_OBJECTS)
268
dastest_LDADD = $(LDADD)
269
dastest_DEPENDENCIES =
270
dastest_LDFLAGS =
271
am_discard_OBJECTS = discard.$(OBJEXT)
272
discard_OBJECTS = $(am_discard_OBJECTS)
273
discard_LDADD = $(LDADD)
274
discard_DEPENDENCIES =
275
discard_LDFLAGS =
276
am_floored_OBJECTS = floored.$(OBJEXT)
277
floored_OBJECTS = $(am_floored_OBJECTS)
278
floored_DEPENDENCIES =
279
floored_LDFLAGS =
280
am_fork_OBJECTS = fork.$(OBJEXT)
281
fork_OBJECTS = $(am_fork_OBJECTS)
282
fork_LDADD = $(LDADD)
283
fork_DEPENDENCIES =
284
fork_LDFLAGS =
285
am_fpu_lazy_eflags_OBJECTS = fpu_lazy_eflags.$(OBJEXT)
286
fpu_lazy_eflags_OBJECTS = $(am_fpu_lazy_eflags_OBJECTS)
287
fpu_lazy_eflags_LDADD = $(LDADD)
288
fpu_lazy_eflags_DEPENDENCIES =
289
fpu_lazy_eflags_LDFLAGS =
290
am_fucomip_OBJECTS = fucomip.$(OBJEXT)
291
fucomip_OBJECTS = $(am_fucomip_OBJECTS)
292
fucomip_LDADD = $(LDADD)
293
fucomip_DEPENDENCIES =
294
fucomip_LDFLAGS =
295
am_gxx304_OBJECTS = gxx304.$(OBJEXT)
296
gxx304_OBJECTS = $(am_gxx304_OBJECTS)
297
gxx304_LDADD = $(LDADD)
298
gxx304_DEPENDENCIES =
299
gxx304_LDFLAGS =
300
am_munmap_exe_OBJECTS = munmap_exe.$(OBJEXT)
301
munmap_exe_OBJECTS = $(am_munmap_exe_OBJECTS)
302
munmap_exe_LDADD = $(LDADD)
303
munmap_exe_DEPENDENCIES =
304
munmap_exe_LDFLAGS =
305
am_pth_blockedsig_OBJECTS = pth_blockedsig.$(OBJEXT)
306
pth_blockedsig_OBJECTS = $(am_pth_blockedsig_OBJECTS)
307
pth_blockedsig_DEPENDENCIES =
308
pth_blockedsig_LDFLAGS =
309
am_rcl_assert_OBJECTS = rcl_assert.$(OBJEXT)
310
rcl_assert_OBJECTS = $(am_rcl_assert_OBJECTS)
311
rcl_assert_LDADD = $(LDADD)
312
rcl_assert_DEPENDENCIES =
313
rcl_assert_LDFLAGS =
314
am_rcrl_OBJECTS = rcrl.$(OBJEXT)
315
rcrl_OBJECTS = $(am_rcrl_OBJECTS)
316
rcrl_LDADD = $(LDADD)
317
rcrl_DEPENDENCIES =
318
rcrl_LDFLAGS =
319
am_readline1_OBJECTS = readline1.$(OBJEXT)
320
readline1_OBJECTS = $(am_readline1_OBJECTS)
321
readline1_LDADD = $(LDADD)
322
readline1_DEPENDENCIES =
323
readline1_LDFLAGS =
324
am_resolv_OBJECTS = resolv.$(OBJEXT)
325
resolv_OBJECTS = $(am_resolv_OBJECTS)
326
resolv_LDADD = $(LDADD)
327
resolv_DEPENDENCIES =
328
resolv_LDFLAGS =
329
am_seg_override_OBJECTS = seg_override.$(OBJEXT)
330
seg_override_OBJECTS = $(am_seg_override_OBJECTS)
331
seg_override_LDADD = $(LDADD)
332
seg_override_DEPENDENCIES =
333
seg_override_LDFLAGS =
334
am_sha1_test_OBJECTS = sha1_test.$(OBJEXT)
335
sha1_test_OBJECTS = $(am_sha1_test_OBJECTS)
336
sha1_test_LDADD = $(LDADD)
337
sha1_test_DEPENDENCIES =
338
sha1_test_LDFLAGS =
339
am_shortpush_OBJECTS = shortpush.$(OBJEXT)
340
shortpush_OBJECTS = $(am_shortpush_OBJECTS)
341
shortpush_LDADD = $(LDADD)
342
shortpush_DEPENDENCIES =
343
shortpush_LDFLAGS =
344
am_shorts_OBJECTS = shorts.$(OBJEXT)
345
shorts_OBJECTS = $(am_shorts_OBJECTS)
346
shorts_LDADD = $(LDADD)
347
shorts_DEPENDENCIES =
348
shorts_LDFLAGS =
349
am_smc1_OBJECTS = smc1.$(OBJEXT)
350
smc1_OBJECTS = $(am_smc1_OBJECTS)
351
smc1_LDADD = $(LDADD)
352
smc1_DEPENDENCIES =
353
smc1_LDFLAGS =
354
SCRIPTS = $(noinst_SCRIPTS)
355
356
357
DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
358
depcomp = $(SHELL) $(top_srcdir)/depcomp
359
am__depfiles_maybe = depfiles
360
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/args.Po ./$(DEPDIR)/bitfield1.Po \
361
@AMDEP_TRUE@	./$(DEPDIR)/bt_everything.Po \
362
@AMDEP_TRUE@	./$(DEPDIR)/bt_literal.Po \
363
@AMDEP_TRUE@	./$(DEPDIR)/coolo_sigaction.Po \
364
@AMDEP_TRUE@	./$(DEPDIR)/coolo_strlen.Po ./$(DEPDIR)/cpuid_c.Po \
365
@AMDEP_TRUE@	./$(DEPDIR)/dastest_c.Po ./$(DEPDIR)/discard.Po \
366
@AMDEP_TRUE@	./$(DEPDIR)/floored.Po ./$(DEPDIR)/fork.Po \
367
@AMDEP_TRUE@	./$(DEPDIR)/fpu_lazy_eflags.Po \
368
@AMDEP_TRUE@	./$(DEPDIR)/fucomip.Po ./$(DEPDIR)/gxx304.Po \
369
@AMDEP_TRUE@	./$(DEPDIR)/munmap_exe.Po \
370
@AMDEP_TRUE@	./$(DEPDIR)/pth_blockedsig.Po ./$(DEPDIR)/rcrl.Po \
371
@AMDEP_TRUE@	./$(DEPDIR)/readline1.Po ./$(DEPDIR)/resolv.Po \
372
@AMDEP_TRUE@	./$(DEPDIR)/seg_override.Po \
373
@AMDEP_TRUE@	./$(DEPDIR)/sha1_test.Po ./$(DEPDIR)/shortpush.Po \
374
@AMDEP_TRUE@	./$(DEPDIR)/shorts.Po ./$(DEPDIR)/smc1.Po
375
CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
376
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
377
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
378
CCLD = $(CC)
379
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
380
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
381
	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
382
CXXLD = $(CXX)
383
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
384
	-o $@
385
DIST_SOURCES = $(args_SOURCES) $(bitfield1_SOURCES) \
386
	$(bt_everything_SOURCES) $(bt_literal_SOURCES) \
387
	$(coolo_sigaction_SOURCES) $(coolo_strlen_SOURCES) \
388
	$(cpuid_SOURCES) $(dastest_SOURCES) $(discard_SOURCES) \
389
	$(floored_SOURCES) $(fork_SOURCES) $(fpu_lazy_eflags_SOURCES) \
390
	$(fucomip_SOURCES) $(gxx304_SOURCES) $(munmap_exe_SOURCES) \
391
	$(pth_blockedsig_SOURCES) $(rcl_assert_SOURCES) $(rcrl_SOURCES) \
392
	$(readline1_SOURCES) $(resolv_SOURCES) $(seg_override_SOURCES) \
393
	$(sha1_test_SOURCES) $(shortpush_SOURCES) $(shorts_SOURCES) \
394
	$(smc1_SOURCES)
395
DIST_COMMON = Makefile.am Makefile.in
396
SOURCES = $(args_SOURCES) $(bitfield1_SOURCES) $(bt_everything_SOURCES) $(bt_literal_SOURCES) $(coolo_sigaction_SOURCES) $(coolo_strlen_SOURCES) $(cpuid_SOURCES) $(dastest_SOURCES) $(discard_SOURCES) $(floored_SOURCES) $(fork_SOURCES) $(fpu_lazy_eflags_SOURCES) $(fucomip_SOURCES) $(gxx304_SOURCES) $(munmap_exe_SOURCES) $(pth_blockedsig_SOURCES) $(rcl_assert_SOURCES) $(rcrl_SOURCES) $(readline1_SOURCES) $(resolv_SOURCES) $(seg_override_SOURCES) $(sha1_test_SOURCES) $(shortpush_SOURCES) $(shorts_SOURCES) $(smc1_SOURCES)
397
398
all: all-am
432
all: all-am
399
433
400
.SUFFIXES:
434
.SUFFIXES:
401
.SUFFIXES: .S .c .cpp .o .obj .s
435
.SUFFIXES: .S .c .cpp .def .o .obj .s
402
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
436
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
437
	@for dep in $?; do \
438
	  case '$(am__configure_deps)' in \
439
	    *$$dep*) \
440
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
441
		&& exit 0; \
442
	      exit 1;; \
443
	  esac; \
444
	done; \
445
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  none/tests/Makefile'; \
403
	cd $(top_srcdir) && \
446
	cd $(top_srcdir) && \
404
	  $(AUTOMAKE) --gnu  none/tests/Makefile
447
	  $(AUTOMAKE) --gnu  none/tests/Makefile
405
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
448
.PRECIOUS: Makefile
406
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
449
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
450
	@case '$?' in \
451
	  *config.status*) \
452
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
453
	  *) \
454
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
455
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
456
	esac;
457
458
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
459
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
460
461
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
462
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
463
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
464
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
407
465
408
clean-checkPROGRAMS:
466
clean-checkPROGRAMS:
409
	-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
467
	-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
Lines 434-439 Link Here
434
discard$(EXEEXT): $(discard_OBJECTS) $(discard_DEPENDENCIES) 
492
discard$(EXEEXT): $(discard_OBJECTS) $(discard_DEPENDENCIES) 
435
	@rm -f discard$(EXEEXT)
493
	@rm -f discard$(EXEEXT)
436
	$(LINK) $(discard_LDFLAGS) $(discard_OBJECTS) $(discard_LDADD) $(LIBS)
494
	$(LINK) $(discard_LDFLAGS) $(discard_OBJECTS) $(discard_LDADD) $(LIBS)
495
exec-sigmask$(EXEEXT): $(exec_sigmask_OBJECTS) $(exec_sigmask_DEPENDENCIES) 
496
	@rm -f exec-sigmask$(EXEEXT)
497
	$(LINK) $(exec_sigmask_LDFLAGS) $(exec_sigmask_OBJECTS) $(exec_sigmask_LDADD) $(LIBS)
437
floored$(EXEEXT): $(floored_OBJECTS) $(floored_DEPENDENCIES) 
498
floored$(EXEEXT): $(floored_OBJECTS) $(floored_DEPENDENCIES) 
438
	@rm -f floored$(EXEEXT)
499
	@rm -f floored$(EXEEXT)
439
	$(LINK) $(floored_LDFLAGS) $(floored_OBJECTS) $(floored_LDADD) $(LIBS)
500
	$(LINK) $(floored_LDFLAGS) $(floored_OBJECTS) $(floored_LDADD) $(LIBS)
Lines 449-454 Link Here
449
gxx304$(EXEEXT): $(gxx304_OBJECTS) $(gxx304_DEPENDENCIES) 
510
gxx304$(EXEEXT): $(gxx304_OBJECTS) $(gxx304_DEPENDENCIES) 
450
	@rm -f gxx304$(EXEEXT)
511
	@rm -f gxx304$(EXEEXT)
451
	$(CXXLINK) $(gxx304_LDFLAGS) $(gxx304_OBJECTS) $(gxx304_LDADD) $(LIBS)
512
	$(CXXLINK) $(gxx304_LDFLAGS) $(gxx304_OBJECTS) $(gxx304_LDADD) $(LIBS)
513
insn_basic$(EXEEXT): $(insn_basic_OBJECTS) $(insn_basic_DEPENDENCIES) 
514
	@rm -f insn_basic$(EXEEXT)
515
	$(LINK) $(insn_basic_LDFLAGS) $(insn_basic_OBJECTS) $(insn_basic_LDADD) $(LIBS)
516
insn_cmov$(EXEEXT): $(insn_cmov_OBJECTS) $(insn_cmov_DEPENDENCIES) 
517
	@rm -f insn_cmov$(EXEEXT)
518
	$(LINK) $(insn_cmov_LDFLAGS) $(insn_cmov_OBJECTS) $(insn_cmov_LDADD) $(LIBS)
519
insn_mmx$(EXEEXT): $(insn_mmx_OBJECTS) $(insn_mmx_DEPENDENCIES) 
520
	@rm -f insn_mmx$(EXEEXT)
521
	$(LINK) $(insn_mmx_LDFLAGS) $(insn_mmx_OBJECTS) $(insn_mmx_LDADD) $(LIBS)
522
insn_mmxext$(EXEEXT): $(insn_mmxext_OBJECTS) $(insn_mmxext_DEPENDENCIES) 
523
	@rm -f insn_mmxext$(EXEEXT)
524
	$(LINK) $(insn_mmxext_LDFLAGS) $(insn_mmxext_OBJECTS) $(insn_mmxext_LDADD) $(LIBS)
525
insn_sse$(EXEEXT): $(insn_sse_OBJECTS) $(insn_sse_DEPENDENCIES) 
526
	@rm -f insn_sse$(EXEEXT)
527
	$(LINK) $(insn_sse_LDFLAGS) $(insn_sse_OBJECTS) $(insn_sse_LDADD) $(LIBS)
528
insn_sse2$(EXEEXT): $(insn_sse2_OBJECTS) $(insn_sse2_DEPENDENCIES) 
529
	@rm -f insn_sse2$(EXEEXT)
530
	$(LINK) $(insn_sse2_LDFLAGS) $(insn_sse2_OBJECTS) $(insn_sse2_LDADD) $(LIBS)
531
map_unmap$(EXEEXT): $(map_unmap_OBJECTS) $(map_unmap_DEPENDENCIES) 
532
	@rm -f map_unmap$(EXEEXT)
533
	$(LINK) $(map_unmap_LDFLAGS) $(map_unmap_OBJECTS) $(map_unmap_LDADD) $(LIBS)
534
mremap$(EXEEXT): $(mremap_OBJECTS) $(mremap_DEPENDENCIES) 
535
	@rm -f mremap$(EXEEXT)
536
	$(LINK) $(mremap_LDFLAGS) $(mremap_OBJECTS) $(mremap_LDADD) $(LIBS)
452
munmap_exe$(EXEEXT): $(munmap_exe_OBJECTS) $(munmap_exe_DEPENDENCIES) 
537
munmap_exe$(EXEEXT): $(munmap_exe_OBJECTS) $(munmap_exe_DEPENDENCIES) 
453
	@rm -f munmap_exe$(EXEEXT)
538
	@rm -f munmap_exe$(EXEEXT)
454
	$(LINK) $(munmap_exe_LDFLAGS) $(munmap_exe_OBJECTS) $(munmap_exe_LDADD) $(LIBS)
539
	$(LINK) $(munmap_exe_LDFLAGS) $(munmap_exe_OBJECTS) $(munmap_exe_LDADD) $(LIBS)
Lines 482-490 Link Here
482
smc1$(EXEEXT): $(smc1_OBJECTS) $(smc1_DEPENDENCIES) 
567
smc1$(EXEEXT): $(smc1_OBJECTS) $(smc1_DEPENDENCIES) 
483
	@rm -f smc1$(EXEEXT)
568
	@rm -f smc1$(EXEEXT)
484
	$(LINK) $(smc1_LDFLAGS) $(smc1_OBJECTS) $(smc1_LDADD) $(LIBS)
569
	$(LINK) $(smc1_LDFLAGS) $(smc1_OBJECTS) $(smc1_LDADD) $(LIBS)
570
syscall-restart1$(EXEEXT): $(syscall_restart1_OBJECTS) $(syscall_restart1_DEPENDENCIES) 
571
	@rm -f syscall-restart1$(EXEEXT)
572
	$(LINK) $(syscall_restart1_LDFLAGS) $(syscall_restart1_OBJECTS) $(syscall_restart1_LDADD) $(LIBS)
573
syscall-restart2$(EXEEXT): $(syscall_restart2_OBJECTS) $(syscall_restart2_DEPENDENCIES) 
574
	@rm -f syscall-restart2$(EXEEXT)
575
	$(LINK) $(syscall_restart2_LDFLAGS) $(syscall_restart2_OBJECTS) $(syscall_restart2_LDADD) $(LIBS)
576
tls$(EXEEXT): $(tls_OBJECTS) $(tls_DEPENDENCIES) 
577
	@rm -f tls$(EXEEXT)
578
	$(LINK) $(tls_LDFLAGS) $(tls_OBJECTS) $(tls_LDADD) $(LIBS)
579
tls.so$(EXEEXT): $(tls_so_OBJECTS) $(tls_so_DEPENDENCIES) 
580
	@rm -f tls.so$(EXEEXT)
581
	$(LINK) $(tls_so_LDFLAGS) $(tls_so_OBJECTS) $(tls_so_LDADD) $(LIBS)
582
tls2.so$(EXEEXT): $(tls2_so_OBJECTS) $(tls2_so_DEPENDENCIES) 
583
	@rm -f tls2.so$(EXEEXT)
584
	$(LINK) $(tls2_so_LDFLAGS) $(tls2_so_OBJECTS) $(tls2_so_LDADD) $(LIBS)
585
yield$(EXEEXT): $(yield_OBJECTS) $(yield_DEPENDENCIES) 
586
	@rm -f yield$(EXEEXT)
587
	$(LINK) $(yield_LDFLAGS) $(yield_OBJECTS) $(yield_LDADD) $(LIBS)
485
588
486
mostlyclean-compile:
589
mostlyclean-compile:
487
	-rm -f *.$(OBJEXT) core *.core
590
	-rm -f *.$(OBJEXT)
488
591
489
distclean-compile:
592
distclean-compile:
490
	-rm -f *.tab.c
593
	-rm -f *.tab.c
Lines 498-508 Link Here
498
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpuid_c.Po@am__quote@
601
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpuid_c.Po@am__quote@
499
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dastest_c.Po@am__quote@
602
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dastest_c.Po@am__quote@
500
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/discard.Po@am__quote@
603
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/discard.Po@am__quote@
604
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exec-sigmask.Po@am__quote@
501
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/floored.Po@am__quote@
605
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/floored.Po@am__quote@
502
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fork.Po@am__quote@
606
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fork.Po@am__quote@
503
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fpu_lazy_eflags.Po@am__quote@
607
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fpu_lazy_eflags.Po@am__quote@
504
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fucomip.Po@am__quote@
608
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fucomip.Po@am__quote@
505
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gxx304.Po@am__quote@
609
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gxx304.Po@am__quote@
610
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insn_basic.Po@am__quote@
611
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insn_cmov.Po@am__quote@
612
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insn_mmx.Po@am__quote@
613
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insn_mmxext.Po@am__quote@
614
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insn_sse.Po@am__quote@
615
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insn_sse2.Po@am__quote@
616
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map_unmap.Po@am__quote@
617
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mremap.Po@am__quote@
506
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/munmap_exe.Po@am__quote@
618
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/munmap_exe.Po@am__quote@
507
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pth_blockedsig.Po@am__quote@
619
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pth_blockedsig.Po@am__quote@
508
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rcrl.Po@am__quote@
620
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rcrl.Po@am__quote@
Lines 513-587 Link Here
513
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shortpush.Po@am__quote@
625
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shortpush.Po@am__quote@
514
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shorts.Po@am__quote@
626
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shorts.Po@am__quote@
515
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smc1.Po@am__quote@
627
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smc1.Po@am__quote@
516
628
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syscall-restart1.Po@am__quote@
517
distclean-depend:
629
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syscall-restart2.Po@am__quote@
518
	-rm -rf ./$(DEPDIR)
630
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls.Po@am__quote@
631
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls2.Po@am__quote@
632
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls2_so.Po@am__quote@
633
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_so.Po@am__quote@
634
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yield.Po@am__quote@
519
635
520
.S.o:
636
.S.o:
521
	$(CCASCOMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
637
	$(CCASCOMPILE) -c $<
522
638
523
.S.obj:
639
.S.obj:
524
	$(CCASCOMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
640
	$(CCASCOMPILE) -c `$(CYGPATH_W) '$<'`
525
641
526
.c.o:
642
.c.o:
527
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
643
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
528
@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
644
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
529
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
530
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
531
@am__fastdepCC_TRUE@	fi
532
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
645
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
533
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
646
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
534
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
647
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
535
@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
648
@am__fastdepCC_FALSE@	$(COMPILE) -c $<
536
649
537
.c.obj:
650
.c.obj:
538
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
651
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
539
@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
652
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
540
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
541
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
542
@am__fastdepCC_TRUE@	fi
543
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
653
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
544
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
654
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
545
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
655
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
546
@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
656
@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
547
657
548
.cpp.o:
658
.cpp.o:
549
@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
659
@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
550
@am__fastdepCXX_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
660
@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
551
@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
552
@am__fastdepCXX_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
553
@am__fastdepCXX_TRUE@	fi
554
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
661
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
555
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
662
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
556
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
663
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
557
@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
664
@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
558
665
559
.cpp.obj:
666
.cpp.obj:
560
@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
667
@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
561
@am__fastdepCXX_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
668
@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
562
@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
563
@am__fastdepCXX_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
564
@am__fastdepCXX_TRUE@	fi
565
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
669
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
566
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
670
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
567
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
671
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
568
@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
672
@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
569
673
570
.s.o:
674
.s.o:
571
	$(CCASCOMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
675
	$(CCASCOMPILE) -c $<
572
676
573
.s.obj:
677
.s.obj:
574
	$(CCASCOMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
678
	$(CCASCOMPILE) -c `$(CYGPATH_W) '$<'`
575
uninstall-info-am:
679
uninstall-info-am:
576
680
577
ETAGS = etags
578
ETAGSFLAGS =
579
580
CTAGS = ctags
581
CTAGSFLAGS =
582
583
tags: TAGS
584
585
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
681
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
586
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
682
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
587
	unique=`for i in $$list; do \
683
	unique=`for i in $$list; do \
Lines 590-595 Link Here
590
	  $(AWK) '    { files[$$0] = 1; } \
686
	  $(AWK) '    { files[$$0] = 1; } \
591
	       END { for (i in files) print i; }'`; \
687
	       END { for (i in files) print i; }'`; \
592
	mkid -fID $$unique
688
	mkid -fID $$unique
689
tags: TAGS
593
690
594
TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
691
TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
595
		$(TAGS_FILES) $(LISP)
692
		$(TAGS_FILES) $(LISP)
Lines 604-610 Link Here
604
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
701
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
605
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
702
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
606
	     $$tags $$unique
703
	     $$tags $$unique
607
608
ctags: CTAGS
704
ctags: CTAGS
609
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
705
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
610
		$(TAGS_FILES) $(LISP)
706
		$(TAGS_FILES) $(LISP)
Lines 627-636 Link Here
627
723
628
distclean-tags:
724
distclean-tags:
629
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
725
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
630
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
631
632
top_distdir = ../..
633
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
634
726
635
distdir: $(DISTFILES)
727
distdir: $(DISTFILES)
636
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
728
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 644-650 Link Here
644
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
736
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
645
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
737
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
646
	    dir="/$$dir"; \
738
	    dir="/$$dir"; \
647
	    $(mkinstalldirs) "$(distdir)$$dir"; \
739
	    $(mkdir_p) "$(distdir)$$dir"; \
648
	  else \
740
	  else \
649
	    dir=''; \
741
	    dir=''; \
650
	  fi; \
742
	  fi; \
Lines 663-669 Link Here
663
	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
755
	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
664
check: check-am
756
check: check-am
665
all-am: Makefile $(SCRIPTS)
757
all-am: Makefile $(SCRIPTS)
666
667
installdirs:
758
installdirs:
668
install: install-am
759
install: install-am
669
install-exec: install-exec-am
760
install-exec: install-exec-am
Lines 676-682 Link Here
676
installcheck: installcheck-am
767
installcheck: installcheck-am
677
install-strip:
768
install-strip:
678
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
769
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
679
	  INSTALL_STRIP_FLAG=-s \
770
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
680
	  `test -z '$(STRIP)' || \
771
	  `test -z '$(STRIP)' || \
681
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
772
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
682
mostlyclean-generic:
773
mostlyclean-generic:
Lines 684-690 Link Here
684
clean-generic:
775
clean-generic:
685
776
686
distclean-generic:
777
distclean-generic:
687
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
778
	-rm -f $(CONFIG_CLEAN_FILES)
688
779
689
maintainer-clean-generic:
780
maintainer-clean-generic:
690
	@echo "This command is intended for maintainers to use"
781
	@echo "This command is intended for maintainers to use"
Lines 694-707 Link Here
694
clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am
785
clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am
695
786
696
distclean: distclean-am
787
distclean: distclean-am
697
788
	-rm -rf ./$(DEPDIR)
698
distclean-am: clean-am distclean-compile distclean-depend \
789
	-rm -f Makefile
699
	distclean-generic distclean-tags
790
distclean-am: clean-am distclean-compile distclean-generic \
791
	distclean-tags
700
792
701
dvi: dvi-am
793
dvi: dvi-am
702
794
703
dvi-am:
795
dvi-am:
704
796
797
html: html-am
798
705
info: info-am
799
info: info-am
706
800
707
info-am:
801
info-am:
Lines 717-723 Link Here
717
installcheck-am:
811
installcheck-am:
718
812
719
maintainer-clean: maintainer-clean-am
813
maintainer-clean: maintainer-clean-am
720
814
	-rm -rf ./$(DEPDIR)
815
	-rm -f Makefile
721
maintainer-clean-am: distclean-am maintainer-clean-generic
816
maintainer-clean-am: distclean-am maintainer-clean-generic
722
817
723
mostlyclean: mostlyclean-am
818
mostlyclean: mostlyclean-am
Lines 734-753 Link Here
734
829
735
uninstall-am: uninstall-info-am
830
uninstall-am: uninstall-info-am
736
831
737
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-checkPROGRAMS \
832
.PHONY: CTAGS GTAGS all all-am check check-am clean \
738
	clean-generic ctags distclean distclean-compile \
833
	clean-checkPROGRAMS clean-generic ctags distclean \
739
	distclean-depend distclean-generic distclean-tags distdir dvi \
834
	distclean-compile distclean-generic distclean-tags distdir dvi \
740
	dvi-am info info-am install install-am install-data \
835
	dvi-am html html-am info info-am install install-am \
741
	install-data-am install-exec install-exec-am install-info \
836
	install-data install-data-am install-exec install-exec-am \
742
	install-info-am install-man install-strip installcheck \
837
	install-info install-info-am install-man install-strip \
743
	installcheck-am installdirs maintainer-clean \
838
	installcheck installcheck-am installdirs maintainer-clean \
744
	maintainer-clean-generic mostlyclean mostlyclean-compile \
839
	maintainer-clean-generic mostlyclean mostlyclean-compile \
745
	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
840
	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
746
	uninstall-am uninstall-info-am
841
	uninstall-am uninstall-info-am
747
842
843
	exec-sigmask.stdout.exp exec-sigmask.stderr.exp \
844
	floored.stderr.exp floored.stdout.exp \
845
	floored.vgtest \
846
	fork.stderr.exp fork.stdout.exp fork.vgtest \
847
	fpu_lazy_eflags.stderr.exp fpu_lazy_eflags.stdout.exp \
848
	fpu_lazy_eflags.vgtest \
849
	fucomip.stderr.exp fucomip.vgtest \
850
	gxx304.stderr.exp gxx304.vgtest \
851
	insn_basic.stderr.exp insn_basic.stdout.exp insn_basic.vgtest \
852
	insn_cmov.stderr.exp insn_cmov.stdout.exp insn_cmov.vgtest \
853
	insn_mmx.stderr.exp insn_mmx.stdout.exp insn_mmx.vgtest \
854
	insn_mmxext.stderr.exp insn_mmxext.stdout.exp insn_mmxext.vgtest \
855
	insn_sse.stderr.exp insn_sse.stdout.exp insn_sse.vgtest \
856
	insn_sse2.stderr.exp insn_sse2.stdout.exp insn_sse2.vgtest \
857
	map_unmap.stdout.exp map_unmap.vgtest \
858
	mremap.stdout.exp mremap.vgtest \
859
	munmap_exe.stderr.exp munmap_exe.vgtest \
860
	pth_blockedsig.stderr.exp \
861
	pth_blockedsig.stdout.exp pth_blockedsig.vgtest \
862
	rcl_assert.stderr.exp rcl_assert.vgtest \
863
	rcrl.stderr.exp rcrl.stdout.exp rcrl.vgtest \
864
	readline1.stderr.exp readline1.stdout.exp \
865
	readline1.vgtest \
866
	resolv.stderr.exp resolv.stdout.exp resolv.vgtest \
867
	seg_override.stderr.exp \
868
	seg_override.stdout.exp seg_override.vgtest \
869
	sha1_test.stderr.exp sha1_test.vgtest \
870
	shortpush.stderr.exp shortpush.vgtest \
871
	shorts.stderr.exp shorts.vgtest \
872
	tls.stderr.exp tls.stdout.exp tls.vgtest \
873
	smc1.stderr.exp smc1.stdout.exp smc1.vgtest \
874
	syscall-restart1.vgtest syscall-restart1.stdout.exp syscall-restart1.stderr.exp \
875
	syscall-restart2.vgtest syscall-restart2.stdout.exp syscall-restart2.stderr.exp \
876
	yield.stdout.exp yield.vgtest
877
878
tls_so.o tls2_so.o: CFLAGS += -fpic
748
879
749
# must be built with these flags -- bug only occurred with them
880
# must be built with these flags -- bug only occurred with them
750
fpu_lazy_eflags.o: CFLAGS += -O2 -mcpu=pentiumpro -march=pentiumpro
881
fpu_lazy_eflags.o: CFLAGS += -O2 -mcpu=pentiumpro -march=pentiumpro
882
883
# rebuild instruction tests if test generator changes
884
insn_basic.c: gen_insn_test.pl
885
insn_cmov.c: gen_insn_test.pl
886
insn_mmx.c: gen_insn_test.pl
887
insn_mmxext.c: gen_insn_test.pl
888
insn_sse.c: gen_insn_test.pl
889
insn_sse2.c: gen_insn_test.pl
890
891
.def.c:
892
	$(PERL) gen_insn_test.pl < $< > $@
751
# Tell versions [3.59,3.63) of GNU make to not export all variables.
893
# Tell versions [3.59,3.63) of GNU make to not export all variables.
752
# Otherwise a system limit (for SysV at least) may be exceeded.
894
# Otherwise a system limit (for SysV at least) may be exceeded.
753
.NOEXPORT:
895
.NOEXPORT:
(-)valgrind-2.1.0/none/tests/bitfield1.c (-1 / +1 lines)
Lines 1-5 Link Here
1
1
2
#include <malloc.h>
2
#include <stdlib.h>
3
3
4
typedef
4
typedef
5
   struct {
5
   struct {
(-)valgrind-2.1.0/none/tests/exec-sigmask.c (+37 lines)
Line 0 Link Here
1
#include <unistd.h>
2
#include <signal.h>
3
#include <errno.h>
4
#include <string.h>
5
#include <stdio.h>
6
7
int main(int argc, char **argv)
8
{
9
	if (argc == 1) {
10
		sigset_t all;
11
12
13
		sigfillset(&all);
14
		sigprocmask(SIG_SETMASK, &all, NULL);
15
16
		execl(argv[0], argv[0], "test", NULL);
17
18
		fprintf(stderr, "FAILED: execl failed with %s\n",
19
			strerror(errno));
20
		return 1;
21
	} else {
22
		sigset_t mask;
23
		int i;
24
25
		sigprocmask(SIG_SETMASK, NULL, &mask);
26
27
		for(i = 1; i < NSIG; i++) {
28
			if (i == SIGKILL || i == SIGSTOP)
29
				continue;
30
31
			if (!sigismember(&mask, i))
32
				printf("signal %d missing from mask\n", i);
33
		}
34
	}
35
36
	return 0;
37
}
(-)valgrind-2.1.0/none/tests/exec-sigmask.stderr.exp (+1 lines)
Line 0 Link Here
1
(-)valgrind-2.1.0/none/tests/exec-sigmask.vgtest (+1 lines)
Line 0 Link Here
1
prog: exec-sigmask
(-)valgrind-2.1.0/none/tests/fork.c (+4 lines)
Lines 1-6 Link Here
1
1
2
#include <unistd.h>
2
#include <unistd.h>
3
#include <sys/types.h>
3
#include <sys/types.h>
4
#include <sys/wait.h>
4
#include <stdio.h>
5
#include <stdio.h>
5
6
6
int main(void)
7
int main(void)
Lines 16-20 Link Here
16
17
17
  printf("%s", pid==0 ? "X" : "XX");
18
  printf("%s", pid==0 ? "X" : "XX");
18
19
20
  if (pid != 0)
21
     waitpid(pid, NULL, 0);
22
19
  return 0;
23
  return 0;
20
}
24
}
(-)valgrind-2.1.0/none/tests/fork.stderr.exp (-2 lines)
Lines 1-2 Link Here
1
2
(-)valgrind-2.1.0/none/tests/fork.vgtest (+1 lines)
Line 1 Link Here
1
prog: fork
1
prog: fork
2
vgopts: -q
(-)valgrind-2.1.0/none/tests/gen_insn_test.pl (+667 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
use strict;
4
use warnings;
5
6
our %ArgTypes = (
7
                 r8 => "reg8_t",
8
                 r16 => "reg16_t",
9
                 r32 => "reg32_t",
10
                 mm => "mm_reg_t",
11
                 xmm => "xmm_reg_t",
12
                 m8 => "reg8_t",
13
                 m16 => "reg16_t",
14
                 m32 => "reg32_t",
15
                 m64 => "mm_reg_t",
16
                 m128 => "xmm_reg_t",
17
                 eflags => "reg32_t"
18
                 );
19
20
our %SubTypeFormats = (
21
                       sb => "%d",
22
                       ub => "%u",
23
                       sw => "%d",
24
                       uw => "%u",
25
                       sd => "%ld",
26
                       ud => "%lu",
27
                       sq => "%lld",
28
                       uq => "%llu",
29
                       ps => "%.16g",
30
                       pd => "%.16g"
31
                       );
32
33
our %SubTypeSuffixes = (
34
                        sb => "",
35
                        ub => "U",
36
                        sw => "",
37
                        uw => "",
38
                        sd => "L",
39
                        ud => "UL",
40
                        sq => "LL",
41
                        uq => "ULL",
42
                        ps => "F",
43
                        pd => ""
44
                        );
45
46
our %RegNums = (
47
                al => 0, ax => 0, eax => 0,
48
                bl => 1, bx => 1, ebx => 1,
49
                cl => 2, cx => 2, ecx => 2,
50
                dl => 3, dx => 3, edx => 3,
51
                ah => 4,
52
                bh => 5,
53
                ch => 6,
54
                dh => 7
55
                );
56
57
our %RegTypes = (
58
                 al => "r8", ah => "r8", ax => "r16", eax => "r32",
59
                 bl => "r8", bh => "r8", bx => "r16", ebx => "r32",
60
                 cl => "r8", ch => "r8", cx => "r16", ecx => "r32",
61
                 dl => "r8", dh => "r8", dx => "r16", edx => "r32"
62
                 );
63
64
our @IntRegs = (
65
                { r8 => "al", r16 => "ax", r32 => "eax" },
66
                { r8 => "bl", r16 => "bx", r32 => "ebx" },
67
                { r8 => "cl", r16 => "cx", r32 => "ecx" },
68
                { r8 => "dl", r16 => "dx", r32 => "edx" },
69
                { r8 => "ah" },
70
                { r8 => "bh" },
71
                { r8 => "ch" },
72
                { r8 => "dh" }
73
                );
74
75
print <<EOF;
76
#include <math.h>
77
#include <setjmp.h>
78
#include <signal.h>
79
#include <stdio.h>
80
#include <stdlib.h>
81
82
typedef union {
83
  char sb[1];
84
  unsigned char ub[1];
85
} reg8_t;
86
87
typedef union {
88
  char sb[2];
89
  unsigned char ub[2];
90
  short sw[1];
91
  unsigned short uw[1];
92
} reg16_t;
93
94
typedef union {
95
  char sb[4];
96
  unsigned char ub[4];
97
  short sw[2];
98
  unsigned short uw[2];
99
  long int sd[1];
100
  unsigned long int ud[1];
101
  float ps[1];
102
} reg32_t;
103
104
typedef union {
105
  char sb[8];
106
  unsigned char ub[8];
107
  short sw[4];
108
  unsigned short uw[4];
109
  long int sd[2];
110
  unsigned long int ud[2];
111
  long long int sq[1];
112
  unsigned long long int uq[1];
113
  float ps[2];
114
  double pd[1];
115
} mm_reg_t __attribute__ ((aligned (8)));
116
117
typedef union {
118
  char sb[16];
119
  unsigned char ub[16];
120
  short sw[8];
121
  unsigned short uw[8];
122
  long int sd[4];
123
  unsigned long int ud[4];
124
  long long int sq[2];
125
  unsigned long long int uq[2];
126
  float ps[4];
127
  double pd[2];
128
} xmm_reg_t __attribute__ ((aligned (16)));
129
130
static sigjmp_buf catchpoint;
131
132
static void handle_sigill(int signum)
133
{
134
   siglongjmp(catchpoint, 1);
135
}
136
137
static int eq_float(float f1, float f2)
138
{
139
   return f1 == f2 || fabsf(f1 - f2) < fabsf(f1) * 1.5 * pow(2,-12);
140
}
141
142
static int eq_double(double d1, double d2)
143
{
144
   return d1 == d2 || fabs(d1 - d2) < fabs(d1) * 1.5 * pow(2,-12);
145
}
146
147
EOF
148
149
my %tests;
150
my @tests;
151
152
while (<>)
153
{
154
    next if /^#/;
155
156
    my $insn;
157
    my $presets;
158
    my $args;
159
    my $results;
160
161
    if (/^(\S+)\s+(?:(\S+(?:\s+\S+)*)\s+:\s+)?((?:\S+\s+)*)=>\s+(\S+(?:\s+\S+)*)$/)
162
    {
163
        $insn = $1;
164
        $presets = $2 || "";
165
        $args = $3;
166
        $results = $4;
167
    }
168
    else
169
    {
170
        die "Can't parse test $_";
171
    }
172
    
173
    $tests{$insn}++;
174
    
175
    my $test = "${insn}_$tests{$insn}";
176
    
177
    push @tests, $test;
178
    
179
    print qq|static void $test(void)\n|;
180
    print qq|\{\n|;
181
182
    my @intregs = @IntRegs;
183
    my @mmregs = map { "mm$_" } (0 .. 7);
184
    my @xmmregs = map { "xmm$_" } (0 .. 7);
185
186
    my @presets;
187
    my $presetc = 0;
188
    my $eflagsmask;
189
    my $eflagsset;
190
    
191
    foreach my $preset (split(/\s+/, $presets))
192
    {
193
        if ($preset =~ /^([abcd][lh]|[abcd]x|e[abcd]x)\.(sb|ub|sw|uw|sd|ud|sq|uq|ps|pd)\[([^\]]+)\]$/)
194
        {
195
            my $name = "preset$presetc";
196
            my $type = $RegTypes{$1};
197
            my $regnum = $RegNums{$1};
198
            my $register = $intregs[$regnum];
199
            my $subtype = $2;
200
            my @values = split(/,/, $3);
201
    
202
            die "Register $1 already used" unless defined($register);
203
204
            my $preset = {
205
                name => $name,
206
                type => $type,
207
                subtype => $subtype,
208
                register => $register
209
            };
210
211
            delete($intregs[$regnum]);
212
213
            push @presets, $preset;
214
            
215
            print qq|   $ArgTypes{$type} $name = \{|;
216
            
217
            my $valuec = 0;
218
            
219
            foreach my $value (@values)
220
    {
221
                print qq|,| if $valuec > 0;
222
                print qq| .$subtype\[$valuec\] = $value$SubTypeSuffixes{$subtype}|;
223
                $valuec++;
224
            }
225
            
226
            print qq| \};\n|;
227
228
            $presetc++;
229
        }
230
        elsif ($preset =~ /^(eflags)\[([^\]]+)\]$/)
231
        {
232
            my $type = $1;
233
            my @values = split(/,/, $2);
234
235
            $values[0] = oct($values[0]) if $values[0] =~ /^0/;
236
            $values[1] = oct($values[1]) if $values[1] =~ /^0/;
237
238
            $eflagsmask = sprintf "0x%x", ~$values[0];
239
            $eflagsset = sprintf "0x%x", $values[1];
240
        }
241
        else
242
        {
243
            die "Can't parse preset $preset";
244
        }
245
    }
246
247
    my @args;
248
    my $argc = 0;
249
    
250
    foreach my $arg (split(/\s+/, $args))
251
    {
252
        my $name = "arg$argc";
253
254
        if ($arg =~ /^([abcd]l|[abcd]x|e[abcd]x|r8|r16|r32|mm|xmm|m8|m16|m32|m64|m128)\.(sb|ub|sw|uw|sd|ud|sq|uq|ps|pd)\[([^\]]+)\]$/)
255
        {
256
            my $type = $RegTypes{$1} || $1;
257
            my $regnum = $RegNums{$1};
258
            my $register = $intregs[$regnum] if defined($regnum);
259
            my $subtype = $2;
260
            my @values = split(/,/, $3);
261
            
262
            die "Register $1 already used" if defined($regnum) && !defined($register);
263
264
            my $arg = {
265
                name => $name,
266
                type => $type,
267
                subtype => $subtype
268
            };
269
270
            if (defined($register))
271
            {
272
                $arg->{register} = $register;
273
                delete($intregs[$regnum]);
274
            }
275
276
            push @args, $arg;
277
            
278
            print qq|   $ArgTypes{$type} $name = \{|;
279
            
280
            my $valuec = 0;
281
            
282
            foreach my $value (@values)
283
            {
284
                print qq|,| if $valuec > 0;
285
                print qq| .$subtype\[$valuec\] = $value$SubTypeSuffixes{$subtype}|;
286
                $valuec++;
287
            }
288
289
            print qq| \};\n|;
290
        }
291
        elsif ($arg =~ /^(imm8|imm16|imm32)\[([^\]]+)\]$/)
292
        {
293
            my $type = $1;
294
            my $value = $2;
295
            
296
            my $arg = {
297
                type => $type,
298
                value => $value
299
            };
300
301
            push @args, $arg;
302
        }
303
        else
304
        {
305
            die "Can't parse argument $arg";
306
        }
307
308
        $argc++;
309
    }
310
    
311
    foreach my $arg (@presets, @args)
312
    {
313
        if ($arg->{type} =~ /^(r8|r16|r32|m8|m16|m32)$/)
314
        {
315
            while (!exists($arg->{register}) || !defined($arg->{register}))
316
            {
317
                $arg->{register} = shift @intregs;
318
            }
319
320
            $arg->{register} = $arg->{register}->{$arg->{type}};
321
        }
322
        elsif ($arg->{type} =~ /^(mm|m64)$/)
323
        {
324
            $arg->{register} = shift @mmregs;
325
        }
326
        elsif ($arg->{type} =~ /^(xmm|m128)$/)
327
        {
328
            $arg->{register} = shift @xmmregs;
329
        }
330
    }
331
332
    my @results;
333
    my $resultc = 0;
334
    
335
    foreach my $result (split(/\s+/, $results))
336
    {
337
        my $name = "result$resultc";
338
    
339
    if ($result =~ /^(\d+)\.(sb|ub|sw|uw|sd|ud|sq|uq|ps|pd)\[([^\]]+)\]$/)
340
    {
341
            my $index = $1;
342
            my $type = $args[$index]->{type};
343
            my $subtype = $2;
344
            my @values = split(/,/, $3);
345
            
346
            die "Argument $index not specified" unless exists($args[$index]);
347
348
            my $result = {
349
                name => $name,
350
                type => $type,
351
                subtype => $subtype,
352
                arg => $args[$index],
353
                register => $args[$index]->{register},
354
                values => [ @values ]
355
            };
356
357
            push @results, $result;
358
359
            print qq|   $ArgTypes{$type} $name|;
360
            print qq| = arg$index| if $type =~ /^m(8|16|32|64|128)$/;
361
            print qq|;\n|;
362
363
            $args[$index]->{result} = $result;
364
        }
365
        elsif ($result =~ /^([abcd][lh]|[abcd]x|e[abcd]x)\.(sb|ub|sw|uw|sd|ud|sq|uq|ps|pd)\[([^\]]+)\]$/)
366
        {
367
            my $register = $1;
368
            my $type = $RegTypes{$register};
369
            my $subtype = $2;
370
            my @values = split(/,/, $3);
371
                        
372
            my $result = {
373
                name => $name,
374
                type => $type,
375
                subtype => $subtype,
376
                register => $register,
377
                values => [ @values ]
378
            };
379
380
            push @results, $result;
381
382
            print qq|   $ArgTypes{$type} $name;\n|;
383
    }
384
    elsif ($result =~ /^eflags\[([^\]]+)\]$/)
385
    {
386
            my @values = split(/,/, $1);
387
388
            $values[0] = oct($values[0]) if $values[0] =~ /^0/;
389
            $values[1] = oct($values[1]) if $values[1] =~ /^0/;
390
391
            my $result = {
392
                name => $name,
393
                type => "eflags",
394
                subtype => "ud",
395
                values => [ map { sprintf "0x%x", $_ } @values ]
396
            };
397
398
            push @results, $result;
399
            
400
            print qq|   $ArgTypes{eflags} $name;\n|;
401
402
            if (!defined($eflagsmask) && !defined($eflagsset))
403
            {
404
                $eflagsmask = sprintf "0x%x", ~$values[0];
405
                $eflagsset = sprintf "0x%x", $values[0] & ~$values[1];
406
            }
407
    }
408
    else
409
    {
410
        die "Can't parse result $result";
411
    }
412
    
413
        $resultc++;
414
    }
415
    
416
    print qq|   char state\[108\];\n|;
417
    print qq|\n|;
418
    print qq|   if (sigsetjmp(catchpoint, 1) == 0)\n|;
419
    print qq|   \{\n|;
420
    print qq|      asm\(\n|;
421
    print qq|         \"fsave %\[state\]\\n\"\n|;
422
    
423
    foreach my $arg (@presets, @args)
424
    {
425
        if ($arg->{type} eq "r8")
426
        {
427
            print qq|         \"movb %\[$arg->{name}\], %%$arg->{register}\\n\"\n|;
428
        }
429
        elsif ($arg->{type} eq "r16")
430
        {
431
            print qq|         \"movw %\[$arg->{name}\], %%$arg->{register}\\n\"\n|;
432
        }
433
        elsif ($arg->{type} eq "r32")
434
        {
435
            print qq|         \"movl %\[$arg->{name}\], %%$arg->{register}\\n\"\n|;
436
        }
437
        elsif ($arg->{type} eq "mm")
438
    {
439
            print qq|         \"movq %\[$arg->{name}\], %%$arg->{register}\\n\"\n|;
440
    }
441
        elsif ($arg->{type} eq "xmm")
442
    {
443
            print qq|         \"movlps 0%\[$arg->{name}\], %%$arg->{register}\\n\"\n|;
444
            print qq|         \"movhps 8%\[$arg->{name}\], %%$arg->{register}\\n\"\n|;
445
    }
446
    }
447
    
448
    if (defined($eflagsmask) || defined($eflagsset))
449
    {
450
        print qq|         \"pushfl\\n\"\n|;
451
        print qq|         \"andl \$$eflagsmask, (%%esp)\\n\"\n| if defined($eflagsmask);
452
        print qq|         \"orl \$$eflagsset, (%%esp)\\n\"\n| if defined($eflagsset);
453
        print qq|         \"popfl\\n\"\n|;
454
    }
455
456
    print qq|         \"$insn|;
457
    
458
    my $prefix = " ";
459
    
460
    foreach my $arg (@args)
461
        {
462
        next if $arg->{type} eq "eflags";
463
464
        if ($arg->{type} =~ /^(r8|r16|r32|mm|xmm)$/)
465
        {
466
            print qq|$prefix%%$arg->{register}|;
467
        }
468
        elsif ($arg->{type} =~ /^(m(8|16|32|64|128))$/)
469
        {
470
            if (exists($arg->{result}))
471
            {
472
                print qq|$prefix%\[$arg->{result}->{name}\]|;
473
            }
474
            else
475
            {
476
                print qq|$prefix%\[$arg->{name}\]|;
477
            }
478
        }
479
        elsif ($arg->{type} =~ /^imm(8|16|32)$/)
480
        {
481
            print qq|$prefix\$$arg->{value}|;
482
        }
483
484
        $prefix = ", ";
485
    }
486
487
    print qq|\\n\"\n|;
488
489
    foreach my $result (@results)
490
    {
491
        if ($result->{type} eq "r8")
492
        {
493
            print qq|         \"movb %%$result->{register}, %\[$result->{name}\]\\n\"\n|;
494
        }
495
        elsif ($result->{type} eq "r16")
496
    {
497
            print qq|         \"movw %%$result->{register}, %\[$result->{name}\]\\n\"\n|;
498
    }
499
        elsif ($result->{type} eq "r32")
500
    {
501
            print qq|         \"movl %%$result->{register}, %\[$result->{name}\]\\n\"\n|;
502
    }
503
        elsif ($result->{type} eq "mm")
504
    {
505
            print qq|         \"movq %%$result->{register}, %\[$result->{name}\]\\n\"\n|;
506
    }
507
        elsif ($result->{type} eq "xmm")
508
        {
509
            print qq|         \"movlps %%$result->{register}, 0%\[$result->{name}\]\\n\"\n|;
510
            print qq|         \"movhps %%$result->{register}, 8%\[$result->{name}\]\\n\"\n|;
511
        }
512
        elsif ($result->{type} eq "eflags")
513
    {
514
        print qq|         \"pushfl\\n\"\n|;
515
            print qq|         \"popl %\[$result->{name}\]\\n\"\n|;
516
        }
517
    }
518
519
    print qq|         \"frstor %\[state\]\\n\"\n|;
520
521
    print qq|         :|;
522
523
    $prefix = " ";
524
525
    foreach my $result (@results)
526
    {
527
        if ($result->{type} =~ /^(m(8|16|32|64|128)|eflags)$/)
528
    {
529
            print qq|$prefix\[$result->{name}\] \"=m\" \($result->{name}\)|;
530
            $prefix = ", ";
531
        }
532
    }
533
534
    print qq|\n|;
535
    
536
    $prefix = "         : ";
537
    
538
    foreach my $arg (@presets, @args)
539
    {
540
        if (defined($arg->{name}))
541
        {
542
            print qq|$prefix\[$arg->{name}\] \"m\" \($arg->{name}\)|;
543
            $prefix = ", ";
544
        }
545
    }
546
    
547
    foreach my $result (@results)
548
    {
549
        if ($result->{type} =~ /^(r(8|16|32)|mm|xmm)$/)
550
        {
551
            print qq|$prefix\[$result->{name}\] \"m\" \($result->{name}\)|;
552
            $prefix = ", ";
553
        }
554
    }
555
556
    print qq|$prefix\[state\] \"m\" \(state[0]\)\n|;
557
558
    $prefix = "         : ";
559
560
    foreach my $arg (@presets, @args)
561
        {
562
        if ($arg->{register})
563
        {
564
            print qq|$prefix\"$arg->{register}\"|;
565
            $prefix = ", ";
566
        }
567
    }
568
569
    print qq|\n|;
570
    
571
    print qq|      \);\n|;                          
572
    print qq|\n|;
573
    
574
    print qq|      if \(|;
575
    
576
    $prefix = "";
577
            
578
    foreach my $result (@results)
579
    {
580
        my $type = $result->{type};
581
        my $subtype = $result->{subtype};
582
        my $suffix = $SubTypeSuffixes{$subtype};
583
        my @values = @{$result->{values}};
584
585
        if ($type eq "eflags")
586
    {
587
            print qq|${prefix}\($result->{name}.ud[0] & $values[0]UL\) == $values[1]UL|;
588
    }
589
    else
590
    {
591
            foreach my $value (0 .. $#values)
592
        {
593
                if ($subtype eq "ps")
594
            {
595
                    print qq|${prefix}eq_float($result->{name}.$subtype\[$value\], $values[$value]$suffix)|;
596
            }
597
                elsif ($subtype eq "pd")
598
            {
599
                    print qq|${prefix}eq_double($result->{name}.$subtype\[$value\], $values[$value]$suffix)|;
600
            }
601
            else
602
            {
603
                    print qq|${prefix}$result->{name}.$subtype\[$value\] == $values[$value]$suffix|;
604
            }
605
606
            $prefix = " && ";
607
        }
608
    }
609
    
610
        $prefix = " &&\n          ";
611
    }
612
    
613
    print qq| \)\n|;
614
    print qq|      \{\n|;
615
    print qq|         printf("$test ... ok\\n");\n|;
616
    print qq|      \}\n|;
617
    print qq|      else\n|;
618
    print qq|      \{\n|;
619
    print qq|         printf("$test ... not ok\\n");\n|;
620
    
621
    foreach my $result (@results)
622
    {
623
        my $type = $result->{type};
624
        my $subtype = $result->{subtype};
625
        my $suffix = $SubTypeSuffixes{$subtype};
626
        my @values = @{$result->{values}};
627
628
        if ($type eq "eflags")
629
    {
630
            print qq|         printf("  eflags & 0x%lx = 0x%lx (expected 0x%lx)\\n", $values[0]UL, $result->{name}.ud\[0\] & $values[0]UL, $values[1]UL);\n|;
631
    }
632
    else
633
    {
634
            foreach my $value (0 .. $#values)
635
        {
636
                print qq|         printf("  $result->{name}.$subtype\[$value\] = $SubTypeFormats{$subtype} (expected $SubTypeFormats{$subtype})\\n", $result->{name}.$subtype\[$value\], $values[$value]$suffix);\n|;
637
            }
638
        }
639
    }
640
641
    print qq|      \}\n|;
642
    print qq|   \}\n|;
643
    print qq|   else\n|;
644
    print qq|   \{\n|;
645
    print qq|      printf("$test ... failed\\n");\n|;
646
    print qq|   \}\n|;
647
    print qq|\n|;
648
    print qq|   return;\n|;
649
    print qq|\}\n|;
650
    print qq|\n|;
651
}
652
653
print qq|int main(int argc, char **argv)\n|;
654
print qq|\{\n|;
655
print qq|   signal(SIGILL, handle_sigill);\n|;
656
print qq|\n|;
657
658
foreach my $test (@tests)
659
{
660
    print qq|   $test();\n|;
661
}
662
663
print qq|\n|;
664
print qq|   exit(0);\n|;
665
print qq|\}\n|;
666
667
exit 0;
(-)valgrind-2.1.0/none/tests/insn_mmx.def (+103 lines)
Line 0 Link Here
1
movd r32.sd[1234] mm.sd[1111,2222] => 1.sd[1234,0]
2
movd m32.sd[1234] mm.sd[1111,2222] => 1.sd[1234,0]
3
movd mm.sd[1234,2222] r32.sd[1111] => 1.sd[1234]
4
movd mm.sd[1234,2222] m32.sd[1111] => 1.sd[1234]
5
movq mm.uq[0x012345678abcdef] mm.uq[0x1212121234343434] => 1.uq[0x012345678abcdef]
6
movq m64.uq[0x012345678abcdef] mm.uq[0x1212121234343434] => 1.uq[0x012345678abcdef]
7
movq mm.uq[0x012345678abcdef] m64.uq[0x1212121234343434] => 1.uq[0x012345678abcdef]
8
packssdw mm.sd[12345,123456] mm.sd[-12345,-123456] => 1.sw[-12345,-32768,12345,32767]
9
packssdw m64.sd[12345,123456] mm.sd[-12345,-123456] => 1.sw[-12345,-32768,12345,32767]
10
packsswb mm.sw[123,-123,1234,-1234] mm.sw[21,-21,321,-321] => 1.sb[21,-21,127,-128,123,-123,127,-128]
11
packsswb m64.sw[123,-123,1234,-1234] mm.sw[21,-21,321,-321] => 1.sb[21,-21,127,-128,123,-123,127,-128]
12
packuswb mm.sw[123,-123,1234,-1234] mm.sw[21,-21,321,-321] => 1.ub[21,0,255,0,123,0,255,0]
13
packuswb m64.sw[123,-123,1234,-1234] mm.sw[21,-21,321,-321] => 1.ub[21,0,255,0,123,0,255,0]
14
paddb mm.sb[12,34,56,78,21,43,65,87] mm.sb[8,7,6,5,4,3,2,1] => 1.sb[20,41,62,83,25,46,67,88]
15
paddb m64.sb[12,34,56,78,21,43,65,87] mm.sb[8,7,6,5,4,3,2,1] => 1.sb[20,41,62,83,25,46,67,88]
16
paddd mm.sd[12345678,87654321] mm.sd[8765,4321] => 1.sd[12354443,87658642]
17
paddd m64.sd[12345678,87654321] mm.sd[8765,4321] => 1.sd[12354443,87658642]
18
paddsb mm.sb[25,-25,50,-50,100,-100,125,-125] mm.sb[40,-40,30,-30,20,-20,10,-10] => 1.sb[65,-65,80,-80,120,-120,127,-128]
19
paddsb m64.sb[25,-25,50,-50,100,-100,125,-125] mm.sb[40,-40,30,-30,20,-20,10,-10] => 1.sb[65,-65,80,-80,120,-120,127,-128]
20
paddsw mm.sw[12345,-12345,32145,-32145] mm.sw[32145,-32145,-12345,12345] => 1.sw[32767,-32768,19800,-19800]
21
paddsw m64.sw[12345,-12345,32145,-32145] mm.sw[32145,-32145,-12345,12345] => 1.sw[32767,-32768,19800,-19800]
22
paddusb mm.ub[25,50,75,100,125,150,175,200] mm.ub[10,20,30,40,50,60,70,80] => 1.ub[35,70,105,140,175,210,245,255]
23
paddusb m64.ub[25,50,75,100,125,150,175,200] mm.ub[10,20,30,40,50,60,70,80] => 1.ub[35,70,105,140,175,210,245,255]
24
paddusw mm.uw[22222,33333,44444,55555] mm.uw[6666,7777,8888,9999] => 1.uw[28888,41110,53332,65535]
25
paddusw m64.uw[22222,33333,44444,55555] mm.uw[6666,7777,8888,9999] => 1.uw[28888,41110,53332,65535]
26
paddw mm.sw[1234,5678,4321,8765] mm.sw[87,65,43,21] => 1.sw[1321,5743,4364,8786]
27
paddw m64.sw[1234,5678,4321,8765] mm.sw[87,65,43,21] => 1.sw[1321,5743,4364,8786]
28
pand mm.uq[0xfdb97531eca86420] mm.uq[0x0123456789abcdef] => 1.uq[0x0121452188a84420]
29
pand m64.uq[0xfdb97531eca86420] mm.uq[0x0123456789abcdef] => 1.uq[0x0121452188a84420]
30
pandn mm.uq[0xfdb97531eca86420] mm.uq[0x0123456789abcdef] => 1.uq[0xfc98301064002000]
31
pandn m64.uq[0xfdb97531eca86420] mm.uq[0x0123456789abcdef] => 1.uq[0xfc98301064002000]
32
pcmpeqb mm.ub[11,22,33,44,55,66,77,88] mm.ub[11,11,33,33,55,55,77,77] => 1.ub[0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00]
33
pcmpeqb m64.ub[11,22,33,44,55,66,77,88] mm.ub[11,11,33,33,55,55,77,77] => 1.ub[0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00]
34
pcmpeqd mm.ud[11223344,55667788] mm.ud[11223344,11223344] => 1.ud[0xffffffff,0x00000000]
35
pcmpeqd m64.ud[11223344,55667788] mm.ud[11223344,11223344] => 1.ud[0xffffffff,0x00000000]
36
pcmpeqw mm.uw[1122,3344,5566,7788] mm.uw[1122,1122,5566,5566] => 1.uw[0xffff,0x0000,0xffff,0x0000]
37
pcmpeqw m64.uw[1122,3344,5566,7788] mm.uw[1122,1122,5566,5566] => 1.uw[0xffff,0x0000,0xffff,0x0000]
38
pcmpgtb mm.sb[-77,-55,-33,-11,11,33,55,77] mm.sb[77,55,33,11,-11,-33,-55,-77] => 1.ub[0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00]
39
pcmpgtb m64.sb[-77,-55,-33,-11,11,33,55,77] mm.sb[77,55,33,11,-11,-33,-55,-77] => 1.ub[0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00]
40
pcmpgtd mm.sd[-11111111,11111111] mm.sd[11111111,-11111111] => 1.ud[0xffffffff,0x00000000]
41
pcmpgtd m64.sd[-11111111,11111111] mm.sd[11111111,-11111111] => 1.ud[0xffffffff,0x00000000]
42
pcmpgtw mm.sw[-3333,-1111,1111,3333] mm.sw[3333,1111,-1111,-3333] => 1.uw[0xffff,0xffff,0x0000,0x0000]
43
pcmpgtw m64.sw[-3333,-1111,1111,3333] mm.sw[3333,1111,-1111,-3333] => 1.uw[0xffff,0xffff,0x0000,0x0000]
44
pmaddwd mm.sw[1234,5678,-4321,-8765] mm.sw[1111,-2222,3333,-4444] => 1.sd[-11245542,24549767]
45
pmaddwd m64.sw[1234,5678,-4321,-8765] mm.sw[1111,-2222,3333,-4444] => 1.sd[-11245542,24549767]
46
pmulhw mm.sw[1111,2222,-1111,-2222] mm.sw[3333,-4444,3333,-4444] => 1.uw[0x0038,0xff69,0xffc7,0x0096]
47
pmulhw m64.sw[1111,2222,-1111,-2222] mm.sw[3333,-4444,3333,-4444] => 1.uw[0x0038,0xff69,0xffc7,0x0096]
48
pmullw mm.sw[1111,2222,-1111,-2222] mm.sw[3333,-4444,3333,-4444] => 1.uw[0x80b3,0x5378,0x7f4d,0xac88]
49
pmullw m64.sw[1111,2222,-1111,-2222] mm.sw[3333,-4444,3333,-4444] => 1.uw[0x80b3,0x5378,0x7f4d,0xac88]
50
por mm.uq[0xfdb97531eca86420] mm.uq[0x0123456789abcdef] => 1.uq[0xfdbb7577edabedef]
51
por m64.uq[0xfdb97531eca86420] mm.uq[0x0123456789abcdef] => 1.uq[0xfdbb7577edabedef]
52
pslld imm8[4] mm.ud[0x01234567,0x89abcdef] => 1.ud[0x12345670,0x9abcdef0]
53
pslld mm.uq[4] mm.ud[0x01234567,0x89abcdef] => 1.ud[0x12345670,0x9abcdef0]
54
pslld m64.uq[4] mm.ud[0x01234567,0x89abcdef] => 1.ud[0x12345670,0x9abcdef0]
55
psllq imm8[4] mm.uq[0x0123456789abcdef] => 1.uq[0x123456789abcdef0]
56
psllq mm.uq[4] mm.uq[0x0123456789abcdef] => 1.uq[0x123456789abcdef0]
57
psllq m64.uq[4] mm.uq[0x0123456789abcdef] => 1.uq[0x123456789abcdef0]
58
psllw imm8[4] mm.uw[0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x1230,0x5670,0x9ab0,0xdef0]
59
psllw mm.uq[4] mm.uw[0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x1230,0x5670,0x9ab0,0xdef0]
60
psllw m64.uq[4] mm.uw[0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x1230,0x5670,0x9ab0,0xdef0]
61
psrad imm8[4] mm.ud[0x01234567,0x89abcdef] => 1.ud[0x00123456,0xf89abcde]
62
psrad mm.uq[4] mm.ud[0x01234567,0x89abcdef] => 1.ud[0x00123456,0xf89abcde]
63
psrad m64.uq[4] mm.ud[0x01234567,0x89abcdef] => 1.ud[0x00123456,0xf89abcde]
64
psraw imm8[4] mm.uw[0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0xf89a,0xfcde]
65
psraw mm.uq[4] mm.uw[0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0xf89a,0xfcde]
66
psraw m64.uq[4] mm.uw[0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0xf89a,0xfcde]
67
psrld imm8[4] mm.ud[0x01234567,0x89abcdef] => 1.ud[0x00123456,0x089abcde]
68
psrld mm.uq[4] mm.ud[0x01234567,0x89abcdef] => 1.ud[0x00123456,0x089abcde]
69
psrld m64.uq[4] mm.ud[0x01234567,0x89abcdef] => 1.ud[0x00123456,0x089abcde]
70
psrlq imm8[4] mm.uq[0x0123456789abcdef] => 1.uq[0x00123456789abcde]
71
psrlq mm.uq[4] mm.uq[0x0123456789abcdef] => 1.uq[0x00123456789abcde]
72
psrlq m64.uq[4] mm.uq[0x0123456789abcdef] => 1.uq[0x00123456789abcde]
73
psrlw imm8[4] mm.uw[0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0x089a,0x0cde]
74
psrlw mm.uq[4] mm.uw[0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0x089a,0x0cde]
75
psrlw m64.uq[4] mm.uw[0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0x089a,0x0cde]
76
psubb mm.sb[8,7,6,5,4,3,2,1] mm.sb[12,34,56,78,21,43,65,87] => 1.sb[4,27,50,73,17,40,63,86]
77
psubb m64.sb[8,7,6,5,4,3,2,1] mm.sb[12,34,56,78,21,43,65,87] => 1.sb[4,27,50,73,17,40,63,86]
78
psubd mm.sd[8765,4321] mm.sd[12345678,87654321] => 1.sd[12336913,87650000]
79
psubd m64.sd[8765,4321] mm.sd[12345678,87654321] => 1.sd[12336913,87650000]
80
psubsb mm.sb[-50,50,-40,40,-30,30,-20,20] mm.sb[25,-25,50,-50,100,-100,125,-125] => 1.sb[75,-75,90,-90,127,-128,127,-128]
81
psubsb m64.sb[-50,50,-40,40,-30,30,-20,20] mm.sb[25,-25,50,-50,100,-100,125,-125] => 1.sb[75,-75,90,-90,127,-128,127,-128]
82
psubsw mm.sw[-32145,32145,12345,-12345] mm.sw[12345,-12345,32145,-32145] => 1.sw[32767,-32768,19800,-19800]
83
psubsw m64.sw[-32145,32145,12345,-12345] mm.sw[12345,-12345,32145,-32145] => 1.sw[32767,-32768,19800,-19800]
84
psubusb mm.ub[11,22,33,44,55,66,77,88] mm.ub[88,77,66,55,44,33,22,11] => 1.ub[77,55,33,11,0,0,0,0]
85
psubusb m64.ub[11,22,33,44,55,66,77,88] mm.ub[88,77,66,55,44,33,22,11] => 1.ub[77,55,33,11,0,0,0,0]
86
psubusw mm.uw[1122,3344,5566,7788] mm.uw[8877,6655,4433,2211] => 1.uw[7755,3311,0,0]
87
psubusw m64.uw[1122,3344,5566,7788] mm.uw[8877,6655,4433,2211] => 1.uw[7755,3311,0,0]
88
psubw mm.sw[87,65,43,21] mm.sw[1234,5678,4321,8765] => 1.sw[1147,5613,4278,8744]
89
psubw m64.sw[87,65,43,21] mm.sw[1234,5678,4321,8765] => 1.sw[1147,5613,4278,8744]
90
punpckhbw mm.ub[12,34,56,78,21,43,65,87] mm.ub[11,22,33,44,55,66,77,88] => 1.ub[55,21,66,43,77,65,88,87]
91
punpckhbw m64.ub[12,34,56,78,21,43,65,87] mm.ub[11,22,33,44,55,66,77,88] => 1.ub[55,21,66,43,77,65,88,87]
92
punpckhdq mm.ud[12345678,21436587] mm.ud[11223344,55667788] => 1.ud[55667788,21436587]
93
punpckhdq m64.ud[12345678,21436587] mm.ud[11223344,55667788] => 1.ud[55667788,21436587]
94
punpckhwd mm.uw[1234,5678,2143,6587] mm.uw[1122,3344,5566,7788] => 1.uw[5566,2143,7788,6587]
95
punpckhwd m64.uw[1234,5678,2143,6587] mm.uw[1122,3344,5566,7788] => 1.uw[5566,2143,7788,6587]
96
punpcklbw mm.ub[12,34,56,78,21,43,65,87] mm.ub[11,22,33,44,55,66,77,88] => 1.ub[11,12,22,34,33,56,44,78]
97
punpcklbw m64.ub[12,34,56,78,21,43,65,87] mm.ub[11,22,33,44,55,66,77,88] => 1.ub[11,12,22,34,33,56,44,78]
98
punpckldq mm.ud[12345678,21436587] mm.ud[11223344,55667788] => 1.ud[11223344,12345678]
99
punpckldq m64.ud[12345678,21436587] mm.ud[11223344,55667788] => 1.ud[11223344,12345678]
100
punpcklwd mm.uw[1234,5678,2143,6587] mm.uw[1122,3344,5566,7788] => 1.uw[1122,1234,3344,5678]
101
punpcklwd m64.uw[1234,5678,2143,6587] mm.uw[1122,3344,5566,7788] => 1.uw[1122,1234,3344,5678]
102
pxor mm.uq[0xfdb97531eca86420] mm.uq[0x0123456789abcdef] => 1.uq[0xfc9a30566503a9cf]
103
pxor m64.uq[0xfdb97531eca86420] mm.uq[0x0123456789abcdef] => 1.uq[0xfc9a30566503a9cf]
(-)valgrind-2.1.0/none/tests/insn_mmx.stderr.exp (+2 lines)
Line 0 Link Here
1
2
(-)valgrind-2.1.0/none/tests/insn_mmx.stdout.exp (+103 lines)
Line 0 Link Here
1
movd_1 ... ok
2
movd_2 ... ok
3
movd_3 ... ok
4
movd_4 ... ok
5
movq_1 ... ok
6
movq_2 ... ok
7
movq_3 ... ok
8
packssdw_1 ... ok
9
packssdw_2 ... ok
10
packsswb_1 ... ok
11
packsswb_2 ... ok
12
packuswb_1 ... ok
13
packuswb_2 ... ok
14
paddb_1 ... ok
15
paddb_2 ... ok
16
paddd_1 ... ok
17
paddd_2 ... ok
18
paddsb_1 ... ok
19
paddsb_2 ... ok
20
paddsw_1 ... ok
21
paddsw_2 ... ok
22
paddusb_1 ... ok
23
paddusb_2 ... ok
24
paddusw_1 ... ok
25
paddusw_2 ... ok
26
paddw_1 ... ok
27
paddw_2 ... ok
28
pand_1 ... ok
29
pand_2 ... ok
30
pandn_1 ... ok
31
pandn_2 ... ok
32
pcmpeqb_1 ... ok
33
pcmpeqb_2 ... ok
34
pcmpeqd_1 ... ok
35
pcmpeqd_2 ... ok
36
pcmpeqw_1 ... ok
37
pcmpeqw_2 ... ok
38
pcmpgtb_1 ... ok
39
pcmpgtb_2 ... ok
40
pcmpgtd_1 ... ok
41
pcmpgtd_2 ... ok
42
pcmpgtw_1 ... ok
43
pcmpgtw_2 ... ok
44
pmaddwd_1 ... ok
45
pmaddwd_2 ... ok
46
pmulhw_1 ... ok
47
pmulhw_2 ... ok
48
pmullw_1 ... ok
49
pmullw_2 ... ok
50
por_1 ... ok
51
por_2 ... ok
52
pslld_1 ... ok
53
pslld_2 ... ok
54
pslld_3 ... ok
55
psllq_1 ... ok
56
psllq_2 ... ok
57
psllq_3 ... ok
58
psllw_1 ... ok
59
psllw_2 ... ok
60
psllw_3 ... ok
61
psrad_1 ... ok
62
psrad_2 ... ok
63
psrad_3 ... ok
64
psraw_1 ... ok
65
psraw_2 ... ok
66
psraw_3 ... ok
67
psrld_1 ... ok
68
psrld_2 ... ok
69
psrld_3 ... ok
70
psrlq_1 ... ok
71
psrlq_2 ... ok
72
psrlq_3 ... ok
73
psrlw_1 ... ok
74
psrlw_2 ... ok
75
psrlw_3 ... ok
76
psubb_1 ... ok
77
psubb_2 ... ok
78
psubd_1 ... ok
79
psubd_2 ... ok
80
psubsb_1 ... ok
81
psubsb_2 ... ok
82
psubsw_1 ... ok
83
psubsw_2 ... ok
84
psubusb_1 ... ok
85
psubusb_2 ... ok
86
psubusw_1 ... ok
87
psubusw_2 ... ok
88
psubw_1 ... ok
89
psubw_2 ... ok
90
punpckhbw_1 ... ok
91
punpckhbw_2 ... ok
92
punpckhdq_1 ... ok
93
punpckhdq_2 ... ok
94
punpckhwd_1 ... ok
95
punpckhwd_2 ... ok
96
punpcklbw_1 ... ok
97
punpcklbw_2 ... ok
98
punpckldq_1 ... ok
99
punpckldq_2 ... ok
100
punpcklwd_1 ... ok
101
punpcklwd_2 ... ok
102
pxor_1 ... ok
103
pxor_2 ... ok
(-)valgrind-2.1.0/none/tests/insn_mmx.vgtest (+2 lines)
Line 0 Link Here
1
prog: insn_mmx
2
cpu_test: mmx
(-)valgrind-2.1.0/none/tests/insn_sse.def (+141 lines)
Line 0 Link Here
1
addps xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[44.44,33.33,22.22,11.11] => 1.ps[56.78,90.11,65.43,98.76]
2
addps m128.ps[12.34,56.78,43.21,87.65] xmm.ps[44.44,33.33,22.22,11.11] => 1.ps[56.78,90.11,65.43,98.76]
3
addss xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[44.44,33.33,22.22,11.11] => 1.ps[56.78,33.33,22.22,11.11]
4
addss m128.ps[12.34,56.78,43.21,87.65] xmm.ps[44.44,33.33,22.22,11.11] => 1.ps[56.78,33.33,22.22,11.11]
5
andnps xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc98301064002000,0x00020046010389cf]
6
andnps m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc98301064002000,0x00020046010389cf]
7
andps xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0x0121452188a84420,0x0121452188a84420]
8
andps m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0x0121452188a84420,0x0121452188a84420]
9
cmpeqps xmm.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5678,234.5679,234.5678,234.5679] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
10
cmpeqps m128.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5678,234.5679,234.5678,234.5679] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
11
cmpeqss xmm.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5678,0.0,0.0,0.0] => 1.ud[0xffffffff,0,0,0]
12
cmpeqss m128.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5679,0.0,0.0,0.0] => 1.ud[0x00000000,0,0,0]
13
cmpleps xmm.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5678,234.5679,234.5678,234.5679] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
14
cmpleps m128.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5678,234.5679,234.5678,234.5679] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
15
cmpless xmm.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5678,0.0,0.0,0.0] => 1.ud[0xffffffff,0,0,0]
16
cmpless m128.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5679,0.0,0.0,0.0] => 1.ud[0x00000000,0,0,0]
17
cmpltps xmm.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5677,234.5679,234.5677,234.5679] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
18
cmpltps m128.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5677,234.5679,234.5677,234.5679] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
19
cmpltss xmm.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5676,0.0,0.0,0.0] => 1.ud[0xffffffff,0,0,0]
20
cmpltss m128.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5679,0.0,0.0,0.0] => 1.ud[0x00000000,0,0,0]
21
cmpneqps xmm.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5679,234.5678,234.5679,234.5678] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
22
cmpneqps m128.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5679,234.5678,234.5679,234.5678] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
23
cmpneqss xmm.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5679,0.0,0.0,0.0] => 1.ud[0xffffffff,0,0,0]
24
cmpneqss m128.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5678,0.0,0.0,0.0] => 1.ud[0x00000000,0,0,0]
25
cmpnleps xmm.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5679,234.5678,234.5679,234.5678] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
26
cmpnleps m128.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5679,234.5678,234.5679,234.5678] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
27
cmpnless xmm.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5679,0.0,0.0,0.0] => 1.ud[0xffffffff,0,0,0]
28
cmpnless m128.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5678,0.0,0.0,0.0] => 1.ud[0x00000000,0,0,0]
29
cmpnltps xmm.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5679,234.5677,234.5679,234.5677] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
30
cmpnltps m128.ps[234.5678,234.5678,234.5678,234.5678] xmm.ps[234.5679,234.5677,234.5679,234.5677] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
31
cmpnltss xmm.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5679,0.0,0.0,0.0] => 1.ud[0xffffffff,0,0,0]
32
cmpnltss m128.ps[1234.5678,0.0,0.0,0.0] xmm.ps[1234.5676,0.0,0.0,0.0] => 1.ud[0x00000000,0,0,0]
33
comiss xmm.ps[234.5678,0.0] xmm.ps[234.5679,0.0] => eflags[0x8d5,0x000]
34
comiss m32.ps[234.5678] xmm.ps[234.5679,0.0] => eflags[0x8d5,0x000]
35
comiss xmm.ps[234.5678,0.0] xmm.ps[234.5677,0.0] => eflags[0x8d5,0x001]
36
comiss m32.ps[234.5678] xmm.ps[234.5677,0.0] => eflags[0x8d5,0x001]
37
comiss xmm.ps[234.5678,0.0] xmm.ps[234.5678,0.0] => eflags[0x8d5,0x040]
38
comiss m32.ps[234.5678] xmm.ps[234.5678,0.0] => eflags[0x8d5,0x040]
39
cvtpi2ps mm.sd[1234,5678] xmm.ps[1.1,2.2,3.3,4.4] => 1.ps[1234.0,5678.0,3.3,4.4]
40
cvtpi2ps m64.sd[1234,5678] xmm.ps[1.1,2.2,3.3,4.4] => 1.ps[1234.0,5678.0,3.3,4.4]
41
cvtps2pi xmm.ps[12.34,56.78,1.11,2.22] mm.sd[1,2] => 1.sd[12,57]
42
cvtps2pi m128.ps[12.34,56.78,1.11,2.22] mm.sd[1,2] => 1.sd[12,57]
43
cvtsi2ss r32.sd[12] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[12.0,2.22,3.33,4.44]
44
cvtsi2ss m32.sd[12] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[12.0,2.22,3.33,4.44]
45
cvtss2si xmm.ps[12.34,56.78,43.21,87.65] r32.sd[99] => 1.sd[12]
46
cvtss2si m128.ps[56.78,12.34,87.65,43.21] r32.sd[99] => 1.sd[57]
47
cvttps2pi xmm.ps[12.34,56.78,1.11,2.22] mm.sd[1,2] => 1.sd[12,56]
48
cvttps2pi m128.ps[12.34,56.78,1.11,2.22] mm.sd[1,2] => 1.sd[12,56]
49
cvttss2si xmm.ps[12.34,56.78,43.21,87.65] r32.sd[99] => 1.sd[12]
50
cvttss2si m128.ps[56.78,12.34,87.65,43.21] r32.sd[99] => 1.sd[56]
51
divps xmm.ps[2.0,3.0,4.0,5.0] xmm.ps[24.68,3.69,48.48,55.55] => 1.ps[12.34,1.23,12.12,11.11]
52
divps m128.ps[2.0,3.0,4.0,5.0] xmm.ps[24.68,3.69,48.48,55.55] => 1.ps[12.34,1.23,12.12,11.11]
53
divss xmm.ps[2.0,3.0,4.0,5.0] xmm.ps[24.68,3.69,48.48,55.55] => 1.ps[12.34,3.69,48.48,55.55]
54
divss m128.ps[2.0,3.0,4.0,5.0] xmm.ps[24.68,3.69,48.48,55.55] => 1.ps[12.34,3.69,48.48,55.55]
55
maxps xmm.ps[2.22,4.44,6.66,8.88] xmm.ps[7.77,5.55,3.33,1.11] => 1.ps[7.77,5.55,6.66,8.88]
56
maxps m128.ps[2.22,4.44,6.66,8.88] xmm.ps[7.77,5.55,3.33,1.11] => 1.ps[7.77,5.55,6.66,8.88]
57
maxss xmm.ps[2.22,4.44,6.66,8.88] xmm.ps[7.77,5.55,3.33,1.11] => 1.ps[7.77,5.55,3.33,1.11]
58
maxss m128.ps[8.88,6.66,4.44,2.22] xmm.ps[1.11,3.33,5.55,7.77] => 1.ps[8.88,3.33,5.55,7.77]
59
minps xmm.ps[2.22,4.44,6.66,8.88] xmm.ps[7.77,5.55,3.33,1.11] => 1.ps[2.22,4.44,3.33,1.11]
60
minps m128.ps[2.22,4.44,6.66,8.88] xmm.ps[7.77,5.55,3.33,1.11] => 1.ps[2.22,4.44,3.33,1.11]
61
minss xmm.ps[2.22,4.44,6.66,8.88] xmm.ps[7.77,5.55,3.33,1.11] => 1.ps[2.22,5.55,3.33,1.11]
62
minss m128.ps[8.88,6.66,4.44,2.22] xmm.ps[1.11,3.33,5.55,7.77] => 1.ps[1.11,3.33,5.55,7.77]
63
movaps xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[11.11,22.22,33.33,44.44] => 1.ps[12.34,56.78,43.21,87.65]
64
movaps m128.ps[12.34,56.78,43.21,87.65] xmm.ps[11.11,22.22,33.33,44.44] => 1.ps[12.34,56.78,43.21,87.65]
65
movhlps xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[11.11,22.22,33.33,44.44] => 1.ps[43.21,87.65,33.33,44.44]
66
movhps m64.ps[12.34,56.78] xmm.ps[11.11,22.22,33.33,44.44] => 1.ps[11.11,22.22,12.34,56.78]
67
movhps xmm.ps[12.34,56.78,43.21,87.65] m64.ps[11.11,22.22] => 1.ps[43.21,87.65]
68
movlhps xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[11.11,22.22,33.33,44.44] => 1.ps[11.11,22.22,12.34,56.78]
69
movlps m64.ps[12.34,56.78] xmm.ps[11.11,22.22,33.33,44.44] => 1.ps[12.34,56.78,33.33,44.44]
70
movlps xmm.ps[12.34,56.78,43.21,87.65] m64.ps[11.11,22.22] => 1.ps[12.34,56.78]
71
movmskps xmm.ps[12.34,-56.78,43.21,-87.65] r32.sd[0] => 1.sd[10]
72
movntps xmm.ps[12.34,56.78,43.21,87.65] m128.ps[11.11,22.22,33.33,44.44] => 1.ps[12.34,56.78,43.21,87.65]
73
movntq mm.uq[0x0123456789abcdef] m64.uq[0x1212121234343434] => 1.uq[0x0123456789abcdef]
74
movss xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[11.11,22.22,33.33,44.44] => 1.ps[12.34,22.22,33.33,44.44]
75
movss m32.ps[12.34] xmm.ps[11.11,22.22,33.33,44.44] => 1.ps[12.34,0.0,0.0,0.0]
76
movss xmm.ps[12.34,56.78,43.21,87.65] m32.ps[11.11] => 1.ps[12.34]
77
movups xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[11.11,22.22,33.33,44.44] => 1.ps[12.34,56.78,43.21,87.65]
78
movups m128.ps[12.34,56.78,43.21,87.65] xmm.ps[11.11,22.22,33.33,44.44] => 1.ps[12.34,56.78,43.21,87.65]
79
mulps xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[5.0,4.0,3.0,2.0] => 1.ps[61.70,227.12,129.63,175.30]
80
mulps m128.ps[12.34,56.78,43.21,87.65] xmm.ps[5.0,4.0,3.0,2.0] => 1.ps[61.70,227.12,129.63,175.30]
81
mulss xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[5.0,4.0,3.0,2.0] => 1.ps[61.70,4.0,3.0,2.0]
82
mulss m128.ps[12.34,56.78,43.21,87.65] xmm.ps[5.0,4.0,3.0,2.0] => 1.ps[61.70,4.0,3.0,2.0]
83
orps xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfdbb7577edabedef,0xfdbb7577edabedef]
84
orps m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfdbb7577edabedef,0xfdbb7577edabedef]
85
pavgb mm.ub[11,22,33,44,55,66,77,88] mm.ub[15,25,35,45,55,65,75,85] => 1.ub[13,24,34,45,55,66,76,87]
86
pavgb m64.ub[11,22,33,44,55,66,77,88] mm.ub[15,25,35,45,55,65,75,85] => 1.ub[13,24,34,45,55,66,76,87]
87
pavgw mm.uw[1122,3344,5566,7788] mm.uw[1525,3545,5565,7585] => 1.uw[1324,3445,5566,7687]
88
pavgw m64.uw[1122,3344,5566,7788] mm.uw[1525,3545,5565,7585] => 1.uw[1324,3445,5566,7687]
89
pextrw imm8[0] mm.uw[1234,5678,4321,8765] r32.ud[0xffffffff] => 2.ud[1234]
90
pextrw imm8[1] mm.uw[1234,5678,4321,8765] r32.ud[0xffffffff] => 2.ud[5678]
91
pextrw imm8[2] mm.uw[1234,5678,4321,8765] r32.ud[0xffffffff] => 2.ud[4321]
92
pextrw imm8[3] mm.uw[1234,5678,4321,8765] r32.ud[0xffffffff] => 2.ud[8765]
93
pinsrw imm8[0] r32.ud[0xffffffff] mm.uw[1234,5678,4321,8765] => 2.uw[65535,5678,4321,8765]
94
pinsrw imm8[1] r32.ud[0xffffffff] mm.uw[1234,5678,4321,8765] => 2.uw[1234,65535,4321,8765]
95
pinsrw imm8[2] r32.ud[0xffffffff] mm.uw[1234,5678,4321,8765] => 2.uw[1234,5678,65535,8765]
96
pinsrw imm8[3] r32.ud[0xffffffff] mm.uw[1234,5678,4321,8765] => 2.uw[1234,5678,4321,65535]
97
pmaxsw mm.sw[-1,2,-3,4] mm.sw[2,-3,4,-5] => 1.sw[2,2,4,4]
98
pmaxsw m64.sw[-1,2,-3,4] mm.sw[2,-3,4,-5] => 1.sw[2,2,4,4]
99
pmaxub mm.ub[1,2,3,4,5,6,7,8] mm.ub[8,7,6,5,4,3,2,1] => 1.ub[8,7,6,5,5,6,7,8]
100
pmaxub m64.ub[1,2,3,4,5,6,7,8] mm.ub[8,7,6,5,4,3,2,1] => 1.ub[8,7,6,5,5,6,7,8]
101
pminsw mm.sw[-1,2,-3,4] mm.sw[2,-3,4,-5] => 1.sw[-1,-3,-3,-5]
102
pminsw m64.sw[-1,2,-3,4] mm.sw[2,-3,4,-5] => 1.sw[-1,-3,-3,-5]
103
pminub mm.ub[1,2,3,4,5,6,7,8] mm.ub[8,7,6,5,4,3,2,1] => 1.ub[1,2,3,4,4,3,2,1]
104
pminub m64.ub[1,2,3,4,5,6,7,8] mm.ub[8,7,6,5,4,3,2,1] => 1.ub[1,2,3,4,4,3,2,1]
105
pmovmskb mm.uq[0x8000000080008088] r32.ud[0] => 1.ud[0x8b]
106
pmulhuw mm.uw[1111,2222,3333,4444] mm.uw[5555,6666,7777,8888] => 1.uw[0x005e,0x00e2,0x018b,0x025a]
107
pmulhuw m64.uw[1111,2222,3333,4444] mm.uw[5555,6666,7777,8888] => 1.uw[0x005e,0x00e2,0x018b,0x025a]
108
psadbw mm.ub[1,2,3,4,5,6,7,8] mm.ub[8,7,6,5,4,3,2,1] => 1.sw[32,0,0,0]
109
psadbw m64.ub[1,2,3,4,5,6,7,8] mm.ub[8,7,6,5,4,3,2,1] => 1.sw[32,0,0,0]
110
pshufw imm8[0x1b] mm.sw[11,22,33,44] mm.sw[0,0,0,0] => 2.sw[44,33,22,11]
111
pshufw imm8[0x1b] m64.sw[11,22,33,44] mm.sw[0,0,0,0] => 2.sw[44,33,22,11]
112
rcpps xmm.ps[2.0,4.0,0.5,0.25] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[0.5,0.25,2.0,4.0]
113
rcpps m128.ps[2.0,4.0,0.5,0.25] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[0.5,0.25,2.0,4.0]
114
rcpss xmm.ps[2.0,4.0,0.5,0.25] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[0.5,2.22,3.33,4.44]
115
rcpss m128.ps[2.0,4.0,0.5,0.25] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[0.5,2.22,3.33,4.44]
116
rsqrtps xmm.ps[4.0,16.0,25.0,64.0] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[0.499878,0.249939,0.199982,0.124969]
117
rsqrtps m128.ps[4.0,16.0,25.0,64.0] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[0.499878,0.249939,0.199982,0.124969]
118
rsqrtss xmm.ps[16.0,5.55,6.66,7.77] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[0.249939,2.22,3.33,4.44]
119
rsqrtss m128.ps[16.0,5.55,6.66,7.77] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[0.249939,2.22,3.33,4.44]
120
shufps imm8[0xe4] xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[12.34,56.78,43.21,87.65] => 2.ps[12.34,56.78,43.21,87.65]
121
shufps imm8[0xb1] m128.ps[12.34,56.78,43.21,87.65] xmm.ps[12.34,56.78,43.21,87.65] => 2.ps[56.78,12.34,87.65,43.21]
122
sqrtps xmm.ps[16.0,25.0,36.0,49.0] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[4.0,5.0,6.0,7.0]
123
sqrtps m128.ps[16.0,25.0,36.0,49.0] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[4.0,5.0,6.0,7.0]
124
sqrtss xmm.ps[16.0,5.55,6.66,7.77] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[4.0,2.22,3.33,4.44]
125
sqrtss m128.ps[16.0,5.55,6.66,7.77] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[4.0,2.22,3.33,4.44]
126
subps xmm.ps[12.34,56.77,43.21,87.65] xmm.ps[44.0,33.0,22.0,11.0] => 1.ps[31.66,-23.77,-21.21,-76.65]
127
subps m128.ps[12.34,56.77,43.21,87.65] xmm.ps[44.0,33.0,22.0,11.0] => 1.ps[31.66,-23.77,-21.21,-76.65]
128
subss xmm.ps[12.34,56.77,43.21,87.65] xmm.ps[44.0,33.0,22.0,11.0] => 1.ps[31.66,33.0,22.0,11.0]
129
subss m128.ps[12.34,56.77,43.21,87.65] xmm.ps[44.0,33.0,22.0,11.0] => 1.ps[31.66,33.0,22.0,11.0]
130
ucomiss xmm.ps[234.5678,0.0] xmm.ps[234.5679,0.0] => eflags[0x8d5,0x000]
131
ucomiss m32.ps[234.5678] xmm.ps[234.5679,0.0] => eflags[0x8d5,0x000]
132
ucomiss xmm.ps[234.5678,0.0] xmm.ps[234.5677,0.0] => eflags[0x8d5,0x001]
133
ucomiss m32.ps[234.5678] xmm.ps[234.5677,0.0] => eflags[0x8d5,0x001]
134
ucomiss xmm.ps[234.5678,0.0] xmm.ps[234.5678,0.0] => eflags[0x8d5,0x040]
135
ucomiss m32.ps[234.5678] xmm.ps[234.5678,0.0] => eflags[0x8d5,0x040]
136
unpckhps xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[11.22,33.44,55.66,77.88] => 1.ps[55.66,43.21,77.88,87.65]
137
unpckhps m128.ps[12.34,56.78,43.21,87.65] xmm.ps[11.22,33.44,55.66,77.88] => 1.ps[55.66,43.21,77.88,87.65]
138
unpcklps xmm.ps[12.34,56.78,43.21,87.65] xmm.ps[11.22,33.44,55.66,77.88] => 1.ps[11.22,12.34,33.44,56.78]
139
unpcklps m128.ps[12.34,56.78,43.21,87.65] xmm.ps[11.22,33.44,55.66,77.88] => 1.ps[11.22,12.34,33.44,56.78]
140
xorps xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc9a30566503a9cf,0xfc9a30566503a9cf]
141
xorps m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc9a30566503a9cf,0xfc9a30566503a9cf]
(-)valgrind-2.1.0/none/tests/insn_sse.stderr.exp (+2 lines)
Line 0 Link Here
1
2
(-)valgrind-2.1.0/none/tests/insn_sse.stdout.exp (+141 lines)
Line 0 Link Here
1
addps_1 ... ok
2
addps_2 ... ok
3
addss_1 ... ok
4
addss_2 ... ok
5
andnps_1 ... ok
6
andnps_2 ... ok
7
andps_1 ... ok
8
andps_2 ... ok
9
cmpeqps_1 ... ok
10
cmpeqps_2 ... ok
11
cmpeqss_1 ... ok
12
cmpeqss_2 ... ok
13
cmpleps_1 ... ok
14
cmpleps_2 ... ok
15
cmpless_1 ... ok
16
cmpless_2 ... ok
17
cmpltps_1 ... ok
18
cmpltps_2 ... ok
19
cmpltss_1 ... ok
20
cmpltss_2 ... ok
21
cmpneqps_1 ... ok
22
cmpneqps_2 ... ok
23
cmpneqss_1 ... ok
24
cmpneqss_2 ... ok
25
cmpnleps_1 ... ok
26
cmpnleps_2 ... ok
27
cmpnless_1 ... ok
28
cmpnless_2 ... ok
29
cmpnltps_1 ... ok
30
cmpnltps_2 ... ok
31
cmpnltss_1 ... ok
32
cmpnltss_2 ... ok
33
comiss_1 ... ok
34
comiss_2 ... ok
35
comiss_3 ... ok
36
comiss_4 ... ok
37
comiss_5 ... ok
38
comiss_6 ... ok
39
cvtpi2ps_1 ... ok
40
cvtpi2ps_2 ... ok
41
cvtps2pi_1 ... ok
42
cvtps2pi_2 ... ok
43
cvtsi2ss_1 ... ok
44
cvtsi2ss_2 ... ok
45
cvtss2si_1 ... ok
46
cvtss2si_2 ... ok
47
cvttps2pi_1 ... ok
48
cvttps2pi_2 ... ok
49
cvttss2si_1 ... ok
50
cvttss2si_2 ... ok
51
divps_1 ... ok
52
divps_2 ... ok
53
divss_1 ... ok
54
divss_2 ... ok
55
maxps_1 ... ok
56
maxps_2 ... ok
57
maxss_1 ... ok
58
maxss_2 ... ok
59
minps_1 ... ok
60
minps_2 ... ok
61
minss_1 ... ok
62
minss_2 ... ok
63
movaps_1 ... ok
64
movaps_2 ... ok
65
movhlps_1 ... ok
66
movhps_1 ... ok
67
movhps_2 ... ok
68
movlhps_1 ... ok
69
movlps_1 ... ok
70
movlps_2 ... ok
71
movmskps_1 ... ok
72
movntps_1 ... ok
73
movntq_1 ... ok
74
movss_1 ... ok
75
movss_2 ... ok
76
movss_3 ... ok
77
movups_1 ... ok
78
movups_2 ... ok
79
mulps_1 ... ok
80
mulps_2 ... ok
81
mulss_1 ... ok
82
mulss_2 ... ok
83
orps_1 ... ok
84
orps_2 ... ok
85
pavgb_1 ... ok
86
pavgb_2 ... ok
87
pavgw_1 ... ok
88
pavgw_2 ... ok
89
pextrw_1 ... ok
90
pextrw_2 ... ok
91
pextrw_3 ... ok
92
pextrw_4 ... ok
93
pinsrw_1 ... ok
94
pinsrw_2 ... ok
95
pinsrw_3 ... ok
96
pinsrw_4 ... ok
97
pmaxsw_1 ... ok
98
pmaxsw_2 ... ok
99
pmaxub_1 ... ok
100
pmaxub_2 ... ok
101
pminsw_1 ... ok
102
pminsw_2 ... ok
103
pminub_1 ... ok
104
pminub_2 ... ok
105
pmovmskb_1 ... ok
106
pmulhuw_1 ... ok
107
pmulhuw_2 ... ok
108
psadbw_1 ... ok
109
psadbw_2 ... ok
110
pshufw_1 ... ok
111
pshufw_2 ... ok
112
rcpps_1 ... ok
113
rcpps_2 ... ok
114
rcpss_1 ... ok
115
rcpss_2 ... ok
116
rsqrtps_1 ... ok
117
rsqrtps_2 ... ok
118
rsqrtss_1 ... ok
119
rsqrtss_2 ... ok
120
shufps_1 ... ok
121
shufps_2 ... ok
122
sqrtps_1 ... ok
123
sqrtps_2 ... ok
124
sqrtss_1 ... ok
125
sqrtss_2 ... ok
126
subps_1 ... ok
127
subps_2 ... ok
128
subss_1 ... ok
129
subss_2 ... ok
130
ucomiss_1 ... ok
131
ucomiss_2 ... ok
132
ucomiss_3 ... ok
133
ucomiss_4 ... ok
134
ucomiss_5 ... ok
135
ucomiss_6 ... ok
136
unpckhps_1 ... ok
137
unpckhps_2 ... ok
138
unpcklps_1 ... ok
139
unpcklps_2 ... ok
140
xorps_1 ... ok
141
xorps_2 ... ok
(-)valgrind-2.1.0/none/tests/insn_sse.vgtest (+2 lines)
Line 0 Link Here
1
prog: insn_sse
2
cpu_test: sse
(-)valgrind-2.1.0/none/tests/insn_sse2.def (+292 lines)
Line 0 Link Here
1
addpd xmm.pd[1234.5678,8765.4321] xmm.pd[2222.2222,1111.1111] => 1.pd[3456.79,9876.5432]
2
addpd m128.pd[1234.5678,8765.4321] xmm.pd[2222.2222,1111.1111] => 1.pd[3456.79,9876.5432]
3
addsd xmm.pd[1234.5678,8765.4321] xmm.pd[2222.2222,1111.1111] => 1.pd[3456.79,1111.1111]
4
addsd m128.pd[1234.5678,8765.4321] xmm.pd[2222.2222,1111.1111] => 1.pd[3456.79,1111.1111]
5
andpd xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0x0121452188a84420,0x0121452188a84420]
6
andpd m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0x0121452188a84420,0x0121452188a84420]
7
andnpd xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc98301064002000,0x00020046010389cf]
8
andnpd m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc98301064002000,0x00020046010389cf]
9
cmpeqpd xmm.pd[1234.5678,1234.5678] xmm.pd[1234.5678,1234.5679] => 1.uq[0xffffffffffffffff,0x0000000000000000]
10
cmpeqpd m128.pd[1234.5678,1234.5678] xmm.pd[1234.5678,1234.5679] => 1.uq[0xffffffffffffffff,0x0000000000000000]
11
cmpltpd xmm.pd[1234.5678,1234.5678] xmm.pd[1234.5677,1234.5679] => 1.uq[0xffffffffffffffff,0x0000000000000000]
12
cmpltpd m128.pd[1234.5678,1234.5678] xmm.pd[1234.5677,1234.5679] => 1.uq[0xffffffffffffffff,0x0000000000000000]
13
cmplepd xmm.pd[1234.5678,1234.5678] xmm.pd[1234.5678,1234.5679] => 1.uq[0xffffffffffffffff,0x0000000000000000]
14
cmplepd m128.pd[1234.5678,1234.5678] xmm.pd[1234.5678,1234.5679] => 1.uq[0xffffffffffffffff,0x0000000000000000]
15
cmpneqpd xmm.pd[1234.5678,1234.5678] xmm.pd[1234.5679,1234.5678] => 1.uq[0xffffffffffffffff,0x0000000000000000]
16
cmpneqpd m128.pd[1234.5678,1234.5678] xmm.pd[1234.5679,1234.5678] => 1.uq[0xffffffffffffffff,0x0000000000000000]
17
cmpnltpd xmm.pd[1234.5678,1234.5678] xmm.pd[1234.5679,1234.5677] => 1.uq[0xffffffffffffffff,0x0000000000000000]
18
cmpnltpd m128.pd[1234.5678,1234.5678] xmm.pd[1234.5679,1234.5677] => 1.uq[0xffffffffffffffff,0x0000000000000000]
19
cmpnlepd xmm.pd[1234.5678,1234.5678] xmm.pd[1234.5679,1234.5678] => 1.uq[0xffffffffffffffff,0x0000000000000000]
20
cmpnlepd m128.pd[1234.5678,1234.5678] xmm.pd[1234.5679,1234.5678] => 1.uq[0xffffffffffffffff,0x0000000000000000]
21
cmpeqsd xmm.pd[1234.5678,0.0] xmm.pd[1234.5678,0.0] => 1.uq[0xffffffffffffffff,0]
22
cmpeqsd m128.pd[1234.5678,0.0] xmm.pd[1234.5679,0.0] => 1.uq[0x0000000000000000,0]
23
cmpltsd xmm.pd[1234.5678,0.0] xmm.pd[1234.5677,0.0] => 1.uq[0xffffffffffffffff,0]
24
cmpltsd m128.pd[1234.5678,0.0] xmm.pd[1234.5679,0.0] => 1.uq[0x0000000000000000,0]
25
cmplesd xmm.pd[1234.5678,0.0] xmm.pd[1234.5678,0.0] => 1.uq[0xffffffffffffffff,0]
26
cmplesd m128.pd[1234.5678,0.0] xmm.pd[1234.5679,0.0] => 1.uq[0x0000000000000000,0]
27
cmpneqsd xmm.pd[1234.5678,0.0] xmm.pd[1234.5679,0.0] => 1.uq[0xffffffffffffffff,0]
28
cmpneqsd m128.pd[1234.5678,0.0] xmm.pd[1234.5678,0.0] => 1.uq[0x0000000000000000,0]
29
cmpnltsd xmm.pd[1234.5678,0.0] xmm.pd[1234.5679,0.0] => 1.uq[0xffffffffffffffff,0]
30
cmpnltsd m128.pd[1234.5678,0.0] xmm.pd[1234.5677,0.0] => 1.uq[0x0000000000000000,0]
31
cmpnlesd xmm.pd[1234.5678,0.0] xmm.pd[1234.5679,0.0] => 1.uq[0xffffffffffffffff,0]
32
cmpnlesd m128.pd[1234.5678,0.0] xmm.pd[1234.5678,0.0] => 1.uq[0x0000000000000000,0]
33
comisd xmm.pd[1234.5678,0.0] xmm.pd[1234.5679,0.0] => eflags[0x8d5,0x000]
34
comisd xmm.pd[1234.5678,0.0] xmm.pd[1234.5677,0.0] => eflags[0x8d5,0x001]
35
comisd xmm.pd[1234.5678,0.0] xmm.pd[1234.5678,0.0] => eflags[0x8d5,0x040]
36
comisd m64.pd[1234.5678] xmm.pd[1234.5679,0.0] => eflags[0x8d5,0x000]
37
comisd m64.pd[1234.5678] xmm.pd[1234.5677,0.0] => eflags[0x8d5,0x001]
38
comisd m64.pd[1234.5678] xmm.pd[1234.5678,0.0] => eflags[0x8d5,0x040]
39
cvtdq2pd xmm.sd[1234,5678,0,0] xmm.pd[0.0,0.0] => 1.pd[1234.0,5678.0]
40
cvtdq2pd m128.sd[1234,5678,0,0] xmm.pd[0.0,0.0] => 1.pd[1234.0,5678.0]
41
cvtdq2ps xmm.sd[1234,5678,-1234,-5678] xmm.ps[0.0,0.0,0.0,0.0] => 1.ps[1234.0,5678.0,-1234.0,-5678.0]
42
cvtdq2ps m128.sd[1234,5678,-1234,-5678] xmm.ps[0.0,0.0,0.0,0.0] => 1.ps[1234.0,5678.0,-1234.0,-5678.0]
43
cvtpd2dq xmm.pd[12.34,56.78] xmm.sd[1,2,3,4] => 1.sd[12,57,0,0]
44
cvtpd2dq m128.pd[12.34,56.78] xmm.sd[1,2,3,4] => 1.sd[12,57,0,0]
45
cvtpd2pi xmm.pd[12.34,56.78] mm.sd[1,2] => 1.sd[12,57]
46
cvtpd2pi m128.pd[12.34,56.78] mm.sd[1,2] => 1.sd[12,57]
47
cvtpd2ps xmm.pd[12.34,56.78] xmm.ps[1.1,2.2,3.3,4.4] => 1.ps[12.34,56.78,0.0,0.0]
48
cvtpd2ps m128.pd[12.34,56.78] xmm.ps[1.1,2.2,3.3,4.4] => 1.ps[12.34,56.78,0.0,0.0]
49
cvtpi2pd mm.sd[1234,5678] xmm.pd[1.1,2.2] => 1.pd[1234.0,5678.0]
50
cvtpi2pd m64.sd[1234,5678] xmm.pd[1.1,2.2] => 1.pd[1234.0,5678.0]
51
cvtps2dq xmm.ps[12.34,56.78,43.21,87.65] xmm.sd[1,2,3,4] => 1.sd[12,57,43,88]
52
cvtps2dq m128.ps[12.34,56.78,43.21,87.65] xmm.sd[1,2,3,4] => 1.sd[12,57,43,88]
53
cvtps2pd xmm.ps[12.34,56.78,1.1,2.2] xmm.pd[3.3,4.4] => 1.pd[12.34,56.78]
54
cvtps2pd m128.ps[12.34,56.78,1.1,2.2] xmm.pd[3.3,4.4] => 1.pd[12.34,56.78]
55
cvtsd2si xmm.pd[12.34,56.78] r32.sd[99] => 1.sd[12]
56
cvtsd2si m128.pd[56.78,12.34] r32.sd[99] => 1.sd[57]
57
cvtsd2ss xmm.pd[12.34,56.78] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[12.34,2.22,3.33,4.44]
58
cvtsd2ss m128.pd[12.34,56.78] xmm.ps[1.11,2.22,3.33,4.44] => 1.ps[12.34,2.22,3.33,4.44]
59
cvtsi2sd r32.sd[12] xmm.pd[1.11,2.22] => 1.pd[12.0,2.22]
60
cvtsi2sd m32.sd[12] xmm.pd[1.11,2.22] => 1.pd[12.0,2.22]
61
cvtss2sd xmm.ps[12.34,3.33,4.44,5.55] xmm.pd[1.11,2.22] => 1.pd[12.34,2.22]
62
cvtss2sd m128.ps[12.34,3.33,4.44,5.55] xmm.pd[1.11,2.22] => 1.pd[12.34,2.22]
63
cvttpd2pi xmm.pd[12.34,56.78] mm.sd[1,2] => 1.sd[12,56]
64
cvttpd2pi m128.pd[12.34,56.78] mm.sd[1,2] => 1.sd[12,56]
65
cvttpd2dq xmm.pd[12.34,56.78] xmm.sd[1,2,3,4] => 1.sd[12,56,0,0]
66
cvttpd2dq m128.pd[12.34,56.78] xmm.sd[1,2,3,4] => 1.sd[12,56,0,0]
67
cvttps2dq xmm.ps[12.34,56.78,43.21,87.65] xmm.sd[1,2,3,4] => 1.sd[12,56,43,87]
68
cvttps2dq m128.ps[12.34,56.78,43.21,87.65] xmm.sd[1,2,3,4] => 1.sd[12,56,43,87]
69
cvttsd2si xmm.pd[12.34,56.78] r32.sd[99] => 1.sd[12]
70
cvttsd2si m128.pd[56.78,12.34] r32.sd[99] => 1.sd[56]
71
divpd xmm.pd[2.0,3.0] xmm.pd[24.68,3.69] => 1.pd[12.34,1.23]
72
divpd m128.pd[2.0,3.0] xmm.pd[24.68,3.69] => 1.pd[12.34,1.23]
73
divsd xmm.pd[2.0,3.0] xmm.pd[24.68,3.69] => 1.pd[12.34,3.69]
74
divsd m128.pd[2.0,3.0] xmm.pd[24.68,3.69] => 1.pd[12.34,3.69]
75
maxpd xmm.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[55.555,44.444]
76
maxpd m128.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[55.555,44.444]
77
maxsd xmm.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[55.555,33.333]
78
maxsd m128.pd[44.444,22.222] xmm.pd[33.333,55.555] => 1.pd[44.444,55.555]
79
minpd xmm.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[22.222,33.333]
80
minpd m128.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[22.222,33.333]
81
minsd xmm.pd[22.222,44.444] xmm.pd[55.555,33.333] => 1.pd[22.222,33.333]
82
minsd m128.pd[44.444,22.222] xmm.pd[33.333,55.555] => 1.pd[33.333,55.555]
83
movapd xmm.pd[1234.5678,8765.4321] xmm.pd[1111.1111,2222.2222] => 1.pd[1234.5678,8765.4321]
84
movapd m128.pd[1234.5678,8765.4321] xmm.pd[1111.1111,2222.2222] => 1.pd[1234.5678,8765.4321]
85
movd r32.sd[1234] xmm.sd[1111,2222,3333,4444] => 1.sd[1234,0,0,0]
86
movd m32.sd[1234] xmm.sd[1111,2222,3333,4444] => 1.sd[1234,0,0,0]
87
movd xmm.sd[1234,2222,3333,4444] r32.sd[1111] => 1.sd[1234]
88
movd xmm.sd[1234,2222,3333,4444] m32.sd[1111] => 1.sd[1234]
89
movdqa xmm.uq[0x012345678abcdef,0xfedcba9876543210] xmm.uq[0x1212121234343434,0x5656565678787878] => 1.uq[0x012345678abcdef,0xfedcba9876543210]
90
movdqa m128.uq[0x012345678abcdef,0xfedcba9876543210] xmm.uq[0x1212121234343434,0x5656565678787878] => 1.uq[0x012345678abcdef,0xfedcba9876543210]
91
movdqa xmm.uq[0x012345678abcdef,0xfedcba9876543210] m128.uq[0x1212121234343434,0x5656565678787878] => 1.uq[0x012345678abcdef,0xfedcba9876543210]
92
movdqu xmm.uq[0x012345678abcdef,0xfedcba9876543210] xmm.uq[0x1212121234343434,0x5656565678787878] => 1.uq[0x012345678abcdef,0xfedcba9876543210]
93
movdqu m128.uq[0x012345678abcdef,0xfedcba9876543210] xmm.uq[0x1212121234343434,0x5656565678787878] => 1.uq[0x012345678abcdef,0xfedcba9876543210]
94
movdqu xmm.uq[0x012345678abcdef,0xfedcba9876543210] m128.uq[0x1212121234343434,0x5656565678787878] => 1.uq[0x012345678abcdef,0xfedcba9876543210]
95
movdq2q xmm.uq[0x012345678abcdef,0xfedcba9876543210] mm.uq[0x1212121234343434] => 1.uq[0x012345678abcdef]
96
movhpd m64.pd[1234.5678] xmm.pd[1111.1111,2222.2222] => 1.pd[1111.1111,1234.5678]
97
movhpd xmm.pd[1234.5678,8765.4321] m64.pd[1111.1111] => 1.pd[8765.4321]
98
movlpd m64.pd[1234.5678] xmm.pd[1111.1111,2222.2222] => 1.pd[1234.5678,2222.2222]
99
movlpd xmm.pd[1234.5678,8765.4321] m64.pd[1111.1111] => 1.pd[1234.5678]
100
movmskpd xmm.pd[1234.5678,-1234.5678] r32.sd[0] => 1.sd[2]
101
movntdq xmm.uq[0x012345678abcdef,0xfedcba9876543210] m128.uq[0x1212121234343434,0x5656565678787878] => 1.uq[0x012345678abcdef,0xfedcba9876543210]
102
movnti r32.sd[12345678] m32.sd[11111111] => 1.sd[12345678]
103
movntpd xmm.pd[1234.5678,8765.4321] m128.pd[1111.1111,2222.2222] => 1.pd[1234.5678,8765.4321]
104
movq2dq mm.uq[0x012345678abcdef] xmm.uq[0x1212121234343434,0x5656565678787878] => 1.uq[0x012345678abcdef,0]
105
movsd xmm.pd[1234.5678,8765.4321] xmm.pd[1111.1111,2222.2222] => 1.pd[1234.5678,2222.2222]
106
movsd m64.pd[1234.5678] xmm.pd[1111.1111,2222.2222] => 1.pd[1234.5678,0.0]
107
movsd xmm.pd[1234.5678,8765.4321] m64.pd[1111.1111] => 1.pd[1234.5678]
108
movupd xmm.pd[1234.5678,8765.4321] xmm.pd[1111.1111,2222.2222] => 1.pd[1234.5678,8765.4321]
109
movupd m128.pd[1234.5678,8765.4321] xmm.pd[1111.1111,2222.2222] => 1.pd[1234.5678,8765.4321]
110
mulpd xmm.pd[1234.5678,8765.4321] xmm.pd[3.0,2.0] => 1.pd[3703.7034,17530.8642]
111
mulpd m128.pd[1234.5678,8765.4321] xmm.pd[3.0,2.0] => 1.pd[3703.7034,17530.8642]
112
mulsd xmm.pd[1234.5678,8765.4321] xmm.pd[3.0,2.0] => 1.pd[3703.7034,2.0]
113
mulsd m128.pd[1234.5678,8765.4321] xmm.pd[3.0,2.0] => 1.pd[3703.7034,2.0]
114
orpd xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfdbb7577edabedef,0xfdbb7577edabedef]
115
orpd m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfdbb7577edabedef,0xfdbb7577edabedef]
116
packssdw xmm.sd[12345,-12345,123456,-123456] xmm.sd[4321,-4321,54321,-54321] => 1.sw[4321,-4321,32767,-32768,12345,-12345,32767,-32768]
117
packssdw m128.sd[12345,-12345,123456,-123456] xmm.sd[4321,-4321,54321,-54321] => 1.sw[4321,-4321,32767,-32768,12345,-12345,32767,-32768]
118
packsswb xmm.sw[123,-123,1234,-1234,123,-123,1234,-1234] xmm.sw[21,-21,321,-321,21,-21,321,-321] => 1.sb[21,-21,127,-128,21,-21,127,-128,123,-123,127,-128,123,-123,127,-128]
119
packsswb m128.sw[123,-123,1234,-1234,123,-123,1234,-1234] xmm.sw[21,-21,321,-321,21,-21,321,-321] => 1.sb[21,-21,127,-128,21,-21,127,-128,123,-123,127,-128,123,-123,127,-128]
120
packuswb xmm.sw[123,-123,1234,-1234,123,-123,1234,-1234] xmm.sw[21,-21,321,-321,21,-21,321,-321] => 1.ub[21,0,255,0,21,0,255,0,123,0,255,0,123,0,255,0]
121
packuswb m128.sw[123,-123,1234,-1234,123,-123,1234,-1234] xmm.sw[21,-21,321,-321,21,-21,321,-321] => 1.ub[21,0,255,0,21,0,255,0,123,0,255,0,123,0,255,0]
122
paddb xmm.sb[12,34,56,78,21,43,65,87,12,34,56,78,21,43,65,87] xmm.sb[8,7,6,5,4,3,2,1,8,7,6,5,4,3,2,1] => 1.sb[20,41,62,83,25,46,67,88,20,41,62,83,25,46,67,88]
123
paddb m128.sb[12,34,56,78,21,43,65,87,12,34,56,78,21,43,65,87] xmm.sb[8,7,6,5,4,3,2,1,8,7,6,5,4,3,2,1] => 1.sb[20,41,62,83,25,46,67,88,20,41,62,83,25,46,67,88]
124
paddd xmm.sd[12345678,87654321,12345678,87654321] xmm.sd[8765,4321,8765,4321] => 1.sd[12354443,87658642,12354443,87658642]
125
paddd m128.sd[12345678,87654321,12345678,87654321] xmm.sd[8765,4321,8765,4321] => 1.sd[12354443,87658642,12354443,87658642]
126
paddq mm.sq[11111111] mm.sq[22222222] => 1.sq[33333333]
127
paddq m64.sq[11111111] mm.sq[22222222] => 1.sq[33333333]
128
paddq xmm.sq[11111111,22222222] xmm.sq[22222222,33333333] => 1.sq[33333333,55555555]
129
paddq m128.sq[11111111,22222222] xmm.sq[22222222,33333333] => 1.sq[33333333,55555555]
130
paddsb xmm.sb[25,-25,50,-50,100,-100,125,-125,25,-25,50,-50,100,-100,125,-125] xmm.sb[40,-40,30,-30,20,-20,10,-10,40,-40,30,-30,20,-20,10,-10] => 1.sb[65,-65,80,-80,120,-120,127,-128,65,-65,80,-80,120,-120,127,-128]
131
paddsb m128.sb[25,-25,50,-50,100,-100,125,-125,25,-25,50,-50,100,-100,125,-125] xmm.sb[40,-40,30,-30,20,-20,10,-10,40,-40,30,-30,20,-20,10,-10] => 1.sb[65,-65,80,-80,120,-120,127,-128,65,-65,80,-80,120,-120,127,-128]
132
paddsw xmm.sw[12345,-12345,32145,-32145,12345,-12345,32145,-32145] xmm.sw[32145,-32145,-12345,12345,32145,-32145,-12345,12345] => 1.sw[32767,-32768,19800,-19800,32767,-32768,19800,-19800]
133
paddsw m128.sw[12345,-12345,32145,-32145,12345,-12345,32145,-32145] xmm.sw[32145,-32145,-12345,12345,32145,-32145,-12345,12345] => 1.sw[32767,-32768,19800,-19800,32767,-32768,19800,-19800]
134
paddusb xmm.ub[25,50,75,100,125,150,175,200,25,50,75,100,125,150,175,200] xmm.ub[10,20,30,40,50,60,70,80,10,20,30,40,50,60,70,80] => 1.ub[35,70,105,140,175,210,245,255,35,70,105,140,175,210,245,255]
135
paddusb m128.ub[25,50,75,100,125,150,175,200,25,50,75,100,125,150,175,200] xmm.ub[10,20,30,40,50,60,70,80,10,20,30,40,50,60,70,80] => 1.ub[35,70,105,140,175,210,245,255,35,70,105,140,175,210,245,255]
136
paddusw xmm.uw[22222,33333,44444,55555,22222,33333,44444,55555] xmm.uw[6666,7777,8888,9999,6666,7777,8888,9999] => 1.uw[28888,41110,53332,65535,28888,41110,53332,65535]
137
paddusw m128.uw[22222,33333,44444,55555,22222,33333,44444,55555] xmm.uw[6666,7777,8888,9999,6666,7777,8888,9999] => 1.uw[28888,41110,53332,65535,28888,41110,53332,65535]
138
paddw xmm.sw[1234,5678,4321,8765,1234,5678,4321,8765] xmm.sw[87,65,43,21,87,65,43,21] => 1.sw[1321,5743,4364,8786,1321,5743,4364,8786]
139
paddw m128.sw[1234,5678,4321,8765,1234,5678,4321,8765] xmm.sw[87,65,43,21,87,65,43,21] => 1.sw[1321,5743,4364,8786,1321,5743,4364,8786]
140
pand xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0x0121452188a84420,0x0121452188a84420]
141
pand m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0x0121452188a84420,0x0121452188a84420]
142
pandn xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc98301064002000,0x00020046010389cf]
143
pandn m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc98301064002000,0x00020046010389cf]
144
pavgb xmm.ub[11,22,33,44,55,66,77,88,11,22,33,44,55,66,77,88] xmm.ub[15,25,35,45,55,65,75,85,15,25,35,45,55,65,75,85] => 1.ub[13,24,34,45,55,66,76,87,13,24,34,45,55,66,76,87]
145
pavgb m128.ub[11,22,33,44,55,66,77,88,11,22,33,44,55,66,77,88] xmm.ub[15,25,35,45,55,65,75,85,15,25,35,45,55,65,75,85] => 1.ub[13,24,34,45,55,66,76,87,13,24,34,45,55,66,76,87]
146
pavgw xmm.uw[1122,3344,5566,7788,1122,3344,5566,7788] xmm.uw[1525,3545,5565,7585,1525,3545,5565,7585] => 1.uw[1324,3445,5566,7687,1324,3445,5566,7687]
147
pavgw m128.uw[1122,3344,5566,7788,1122,3344,5566,7788] xmm.uw[1525,3545,5565,7585,1525,3545,5565,7585] => 1.uw[1324,3445,5566,7687,1324,3445,5566,7687]
148
pcmpeqb xmm.ub[11,22,33,44,55,66,77,88,11,22,33,44,55,66,77,88] xmm.ub[11,11,33,33,55,55,77,77,11,11,33,33,55,55,77,77] => 1.ub[0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00]
149
pcmpeqb m128.ub[11,22,33,44,55,66,77,88,11,22,33,44,55,66,77,88] xmm.ub[11,11,33,33,55,55,77,77,11,11,33,33,55,55,77,77] => 1.ub[0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00]
150
pcmpeqd xmm.ud[11223344,55667788,11223344,55667788] xmm.ud[11223344,11223344,11223344,11223344] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
151
pcmpeqd m128.ud[11223344,55667788,11223344,55667788] xmm.ud[11223344,11223344,11223344,11223344] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
152
pcmpeqw xmm.uw[1122,3344,5566,7788,1122,3344,5566,7788] xmm.uw[1122,1122,5566,5566,1122,1122,5566,5566] => 1.uw[0xffff,0x0000,0xffff,0x0000,0xffff,0x0000,0xffff,0x0000]
153
pcmpeqw m128.uw[1122,3344,5566,7788,1122,3344,5566,7788] xmm.uw[1122,1122,5566,5566,1122,1122,5566,5566] => 1.uw[0xffff,0x0000,0xffff,0x0000,0xffff,0x0000,0xffff,0x0000]
154
pcmpgtb xmm.sb[-77,-55,-33,-11,11,33,55,77,-77,-55,-33,-11,11,33,55,77] xmm.sb[77,55,33,11,-11,-33,-55,-77,77,55,33,11,-11,-33,-55,-77] => 1.ub[0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00]
155
pcmpgtb m128.sb[-77,-55,-33,-11,11,33,55,77,-77,-55,-33,-11,11,33,55,77] xmm.sb[77,55,33,11,-11,-33,-55,-77,77,55,33,11,-11,-33,-55,-77] => 1.ub[0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00]
156
pcmpgtd xmm.sd[-11111111,11111111,-11111111,11111111] xmm.sd[11111111,-11111111,11111111,-11111111] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
157
pcmpgtd m128.sd[-11111111,11111111,-11111111,11111111] xmm.sd[11111111,-11111111,11111111,-11111111] => 1.ud[0xffffffff,0x00000000,0xffffffff,0x00000000]
158
pcmpgtw xmm.sw[-3333,-1111,1111,3333,-3333,-1111,1111,3333] xmm.sw[3333,1111,-1111,-3333,3333,1111,-1111,-3333] => 1.uw[0xffff,0xffff,0x0000,0x0000,0xffff,0xffff,0x0000,0x0000]
159
pcmpgtw m128.sw[-3333,-1111,1111,3333,-3333,-1111,1111,3333] xmm.sw[3333,1111,-1111,-3333,3333,1111,-1111,-3333] => 1.uw[0xffff,0xffff,0x0000,0x0000,0xffff,0xffff,0x0000,0x0000]
160
pextrw imm8[0] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] r32.ud[0xffffffff] => 2.ud[1234]
161
pextrw imm8[1] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] r32.ud[0xffffffff] => 2.ud[5678]
162
pextrw imm8[2] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] r32.ud[0xffffffff] => 2.ud[4321]
163
pextrw imm8[3] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] r32.ud[0xffffffff] => 2.ud[8765]
164
pextrw imm8[4] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] r32.ud[0xffffffff] => 2.ud[1111]
165
pextrw imm8[5] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] r32.ud[0xffffffff] => 2.ud[2222]
166
pextrw imm8[6] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] r32.ud[0xffffffff] => 2.ud[3333]
167
pextrw imm8[7] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] r32.ud[0xffffffff] => 2.ud[4444]
168
pinsrw imm8[0] r32.ud[0xffffffff] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] => 2.uw[65535,5678,4321,8765,1111,2222,3333,4444]
169
pinsrw imm8[1] r32.ud[0xffffffff] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] => 2.uw[1234,65535,4321,8765,1111,2222,3333,4444]
170
pinsrw imm8[2] r32.ud[0xffffffff] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] => 2.uw[1234,5678,65535,8765,1111,2222,3333,4444]
171
pinsrw imm8[3] r32.ud[0xffffffff] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] => 2.uw[1234,5678,4321,65535,1111,2222,3333,4444]
172
pinsrw imm8[4] r32.ud[0xffffffff] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] => 2.uw[1234,5678,4321,8765,65535,2222,3333,4444]
173
pinsrw imm8[5] r32.ud[0xffffffff] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] => 2.uw[1234,5678,4321,8765,1111,65535,3333,4444]
174
pinsrw imm8[6] r32.ud[0xffffffff] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] => 2.uw[1234,5678,4321,8765,1111,2222,65535,4444]
175
pinsrw imm8[7] r32.ud[0xffffffff] xmm.uw[1234,5678,4321,8765,1111,2222,3333,4444] => 2.uw[1234,5678,4321,8765,1111,2222,3333,65535]
176
pmaddwd xmm.sw[1234,5678,-4321,-8765,1234,5678,-4321,-8765] xmm.sw[1111,-2222,3333,-4444,1111,-2222,3333,-4444] => 1.sd[-11245542,24549767,-11245542,24549767]
177
pmaddwd m128.sw[1234,5678,-4321,-8765,1234,5678,-4321,-8765] xmm.sw[1111,-2222,3333,-4444,1111,-2222,3333,-4444] => 1.sd[-11245542,24549767,-11245542,24549767]
178
pmaxsw xmm.sw[-1,2,-3,4,-5,6,-7,8] xmm.sw[2,-3,4,-5,6,-7,8,-9] => 1.sw[2,2,4,4,6,6,8,8]
179
pmaxsw m128.sw[-1,2,-3,4,-5,6,-7,8] xmm.sw[2,-3,4,-5,6,-7,8,-9] => 1.sw[2,2,4,4,6,6,8,8]
180
pmaxub xmm.ub[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25] xmm.ub[25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10] => 1.ub[25,24,23,22,21,20,19,18,18,19,20,21,22,23,24,25]
181
pmaxub m128.ub[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25] xmm.ub[25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10] => 1.ub[25,24,23,22,21,20,19,18,18,19,20,21,22,23,24,25]
182
pminsw xmm.sw[-1,2,-3,4,-5,6,-7,8] xmm.sw[2,-3,4,-5,6,-7,8,-9] => 1.sw[-1,-3,-3,-5,-5,-7,-7,-9]
183
pminsw m128.sw[-1,2,-3,4,-5,6,-7,8] xmm.sw[2,-3,4,-5,6,-7,8,-9] => 1.sw[-1,-3,-3,-5,-5,-7,-7,-9]
184
pminub xmm.ub[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25] xmm.ub[25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10] => 1.ub[10,11,12,13,14,15,16,17,17,16,15,14,13,12,11,10]
185
pminub m128.ub[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25] xmm.ub[25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10] => 1.ub[10,11,12,13,14,15,16,17,17,16,15,14,13,12,11,10]
186
pmovmskb xmm.uq[0x8000000080008088,0x8000000080008088] r32.ud[0] => 1.ud[0x8b8b]
187
pmulhuw xmm.uw[1111,2222,3333,4444,5555,6666,7777,8888] xmm.uw[5555,6666,7777,8888,9999,1111,2222,3333] => 1.uw[0x005e,0x00e2,0x018b,0x025a,0x034f,0x0071,0x0107,0x01c4]
188
pmulhuw m128.uw[1111,2222,3333,4444,5555,6666,7777,8888] xmm.uw[5555,6666,7777,8888,9999,1111,2222,3333] => 1.uw[0x005e,0x00e2,0x018b,0x025a,0x034f,0x0071,0x0107,0x01c4]
189
pmulhw xmm.sw[1111,2222,-1111,-2222,1111,2222,-1111,-2222] xmm.sw[3333,-4444,3333,-4444,3333,-4444,3333,-4444] => 1.uw[0x0038,0xff69,0xffc7,0x0096,0x0038,0xff69,0xffc7,0x0096]
190
pmulhw m128.sw[1111,2222,-1111,-2222,1111,2222,-1111,-2222] xmm.sw[3333,-4444,3333,-4444,3333,-4444,3333,-4444] => 1.uw[0x0038,0xff69,0xffc7,0x0096,0x0038,0xff69,0xffc7,0x0096]
191
pmullw xmm.sw[1111,2222,-1111,-2222,1111,2222,-1111,-2222] xmm.sw[3333,-4444,3333,-4444,3333,-4444,3333,-4444] => 1.uw[0x80b3,0x5378,0x7f4d,0xac88,0x80b3,0x5378,0x7f4d,0xac88]
192
pmullw m128.sw[1111,2222,-1111,-2222,1111,2222,-1111,-2222] xmm.sw[3333,-4444,3333,-4444,3333,-4444,3333,-4444] => 1.uw[0x80b3,0x5378,0x7f4d,0xac88,0x80b3,0x5378,0x7f4d,0xac88]
193
pmuludq mm.ud[12345678,0] mm.ud[87654321,0] => 1.uq[1082152022374638]
194
pmuludq m64.ud[12345678,0] mm.ud[87654321,0] => 1.uq[1082152022374638]
195
pmuludq xmm.ud[12345678,0,87654321,0] xmm.ud[87654321,0,12345678,0] => 1.uq[1082152022374638,1082152022374638]
196
pmuludq m128.ud[12345678,0,87654321,0] xmm.ud[87654321,0,12345678,0] => 1.uq[1082152022374638,1082152022374638]
197
por xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfdbb7577edabedef,0xfdbb7577edabedef]
198
por m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfdbb7577edabedef,0xfdbb7577edabedef]
199
psadbw xmm.ub[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] xmm.ub[16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1] => 1.sw[64,0,0,0,64,0,0,0]
200
psadbw m128.ub[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] xmm.ub[16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1] => 1.sw[64,0,0,0,64,0,0,0]
201
pshufd imm8[0x1b] xmm.sd[1122,3344,5566,7788] xmm.sd[0,0,0,0] => 2.sd[7788,5566,3344,1122]
202
pshufd imm8[0x1b] m128.sd[1122,3344,5566,7788] xmm.sd[0,0,0,0] => 2.sd[7788,5566,3344,1122]
203
pshufhw imm8[0x1b] xmm.sw[11,22,33,44,55,66,77,88] xmm.sw[0,0,0,0,0,0,0,0] => 2.sw[11,22,33,44,88,77,66,55]
204
pshufhw imm8[0x1b] m128.sw[11,22,33,44,55,66,77,88] xmm.sw[0,0,0,0,0,0,0,0] => 2.sw[11,22,33,44,88,77,66,55]
205
pshuflw imm8[0x1b] xmm.sw[11,22,33,44,55,66,77,88] xmm.sw[0,0,0,0,0,0,0,0] => 2.sw[44,33,22,11,55,66,77,88]
206
pshuflw imm8[0x1b] m128.sw[11,22,33,44,55,66,77,88] xmm.sw[0,0,0,0,0,0,0,0] => 2.sw[44,33,22,11,55,66,77,88]
207
pslld imm8[4] xmm.ud[0x01234567,0x89abcdef,0x01234567,0x89abcdef] => 1.ud[0x12345670,0x9abcdef0,0x12345670,0x9abcdef0]
208
pslld xmm.uq[4,0] xmm.ud[0x01234567,0x89abcdef,0x01234567,0x89abcdef] => 1.ud[0x12345670,0x9abcdef0,0x12345670,0x9abcdef0]
209
pslld m128.uq[4,0] xmm.ud[0x01234567,0x89abcdef,0x01234567,0x89abcdef] => 1.ud[0x12345670,0x9abcdef0,0x12345670,0x9abcdef0]
210
pslldq imm8[4] xmm.uq[0x8899aabbccddeeff,0x0011223344556677] => 1.uq[0xccddeeff00000000,0x445566778899aabb]
211
pslldq imm8[4] xmm.uq[0x8899aabbccddeeff,0x0011223344556677] => 1.uq[0xccddeeff00000000,0x445566778899aabb]
212
psllq imm8[4] xmm.uq[0x0123456789abcdef,0x0123456789abcdef] => 1.uq[0x123456789abcdef0,0x123456789abcdef0]
213
psllq xmm.uq[4,0] xmm.uq[0x0123456789abcdef,0x0123456789abcdef] => 1.uq[0x123456789abcdef0,0x123456789abcdef0]
214
psllq m128.uq[4,0] xmm.uq[0x0123456789abcdef,0x0123456789abcdef] => 1.uq[0x123456789abcdef0,0x123456789abcdef0]
215
psllw imm8[4] xmm.uw[0x0123,0x4567,0x89ab,0xcdef,0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x1230,0x5670,0x9ab0,0xdef0,0x1230,0x5670,0x9ab0,0xdef0]
216
psllw xmm.uq[4,0] xmm.uw[0x0123,0x4567,0x89ab,0xcdef,0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x1230,0x5670,0x9ab0,0xdef0,0x1230,0x5670,0x9ab0,0xdef0]
217
psllw m128.uq[4,0] xmm.uw[0x0123,0x4567,0x89ab,0xcdef,0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x1230,0x5670,0x9ab0,0xdef0,0x1230,0x5670,0x9ab0,0xdef0]
218
psrad imm8[4] xmm.ud[0x01234567,0x89abcdef,0x01234567,0x89abcdef] => 1.ud[0x00123456,0xf89abcde,0x00123456,0xf89abcde]
219
psrad xmm.uq[4,0] xmm.ud[0x01234567,0x89abcdef,0x01234567,0x89abcdef] => 1.ud[0x00123456,0xf89abcde,0x00123456,0xf89abcde]
220
psrad m128.uq[4,0] xmm.ud[0x01234567,0x89abcdef,0x01234567,0x89abcdef] => 1.ud[0x00123456,0xf89abcde,0x00123456,0xf89abcde]
221
psraw imm8[4] xmm.uw[0x0123,0x4567,0x89ab,0xcdef,0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0xf89a,0xfcde,0x0012,0x0456,0xf89a,0xfcde]
222
psraw xmm.uq[4,0] xmm.uw[0x0123,0x4567,0x89ab,0xcdef,0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0xf89a,0xfcde,0x0012,0x0456,0xf89a,0xfcde]
223
psraw m128.uq[4,0] xmm.uw[0x0123,0x4567,0x89ab,0xcdef,0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0xf89a,0xfcde,0x0012,0x0456,0xf89a,0xfcde]
224
psrld imm8[4] xmm.ud[0x01234567,0x89abcdef,0x01234567,0x89abcdef] => 1.ud[0x00123456,0x089abcde,0x00123456,0x089abcde]
225
psrld xmm.uq[4,0] xmm.ud[0x01234567,0x89abcdef,0x01234567,0x89abcdef] => 1.ud[0x00123456,0x089abcde,0x00123456,0x089abcde]
226
psrld m128.uq[4,0] xmm.ud[0x01234567,0x89abcdef,0x01234567,0x89abcdef] => 1.ud[0x00123456,0x089abcde,0x00123456,0x089abcde]
227
psrldq imm8[4] xmm.uq[0x8899aabbccddeeff,0x0011223344556677] => 1.uq[0x445566778899aabb,0x0000000000112233]
228
psrldq imm8[4] xmm.uq[0x8899aabbccddeeff,0x0011223344556677] => 1.uq[0x445566778899aabb,0x0000000000112233]
229
psrlq imm8[4] xmm.uq[0x0123456789abcdef,0x0123456789abcdef] => 1.uq[0x00123456789abcde,0x00123456789abcde]
230
psrlq xmm.uq[4,0] xmm.uq[0x0123456789abcdef,0x0123456789abcdef] => 1.uq[0x00123456789abcde,0x00123456789abcde]
231
psrlq m128.uq[4,0] xmm.uq[0x0123456789abcdef,0x0123456789abcdef] => 1.uq[0x00123456789abcde,0x00123456789abcde]
232
psrlw imm8[4] xmm.uw[0x0123,0x4567,0x89ab,0xcdef,0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0x089a,0x0cde,0x0012,0x0456,0x089a,0x0cde]
233
psrlw xmm.uq[4,0] xmm.uw[0x0123,0x4567,0x89ab,0xcdef,0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0x089a,0x0cde,0x0012,0x0456,0x089a,0x0cde]
234
psrlw m128.uq[4,0] xmm.uw[0x0123,0x4567,0x89ab,0xcdef,0x0123,0x4567,0x89ab,0xcdef] => 1.uw[0x0012,0x0456,0x089a,0x0cde,0x0012,0x0456,0x089a,0x0cde]
235
psubb xmm.sb[8,7,6,5,4,3,2,1,8,7,6,5,4,3,2,1] xmm.sb[12,34,56,78,21,43,65,87,12,34,56,78,21,43,65,87] => 1.sb[4,27,50,73,17,40,63,86,4,27,50,73,17,40,63,86]
236
psubb m128.sb[8,7,6,5,4,3,2,1,8,7,6,5,4,3,2,1] xmm.sb[12,34,56,78,21,43,65,87,12,34,56,78,21,43,65,87] => 1.sb[4,27,50,73,17,40,63,86,4,27,50,73,17,40,63,86]
237
psubd xmm.sd[8765,4321,8765,4321] xmm.sd[12345678,87654321,12345678,87654321] => 1.sd[12336913,87650000,12336913,87650000]
238
psubd m128.sd[8765,4321,8765,4321] xmm.sd[12345678,87654321,12345678,87654321] => 1.sd[12336913,87650000,12336913,87650000]
239
psubq mm.sq[11111111] mm.sq[33333333] => 1.sq[22222222]
240
psubq m64.sq[11111111] mm.sq[33333333] => 1.sq[22222222]
241
psubq xmm.sq[11111111,22222222] xmm.sq[55555555,33333333] => 1.sq[44444444,11111111]
242
psubq m128.sq[11111111,22222222] xmm.sq[55555555,33333333] => 1.sq[44444444,11111111]
243
psubsb xmm.sb[-50,50,-40,40,-30,30,-20,20,-50,50,-40,40,-30,30,-20,20] xmm.sb[25,-25,50,-50,100,-100,125,-125,25,-25,50,-50,100,-100,125,-125] => 1.sb[75,-75,90,-90,127,-128,127,-128,75,-75,90,-90,127,-128,127,-128]
244
psubsb m128.sb[-50,50,-40,40,-30,30,-20,20,-50,50,-40,40,-30,30,-20,20] xmm.sb[25,-25,50,-50,100,-100,125,-125,25,-25,50,-50,100,-100,125,-125] => 1.sb[75,-75,90,-90,127,-128,127,-128,75,-75,90,-90,127,-128,127,-128]
245
psubsw xmm.sw[-32145,32145,12345,-12345,-32145,32145,12345,-12345] xmm.sw[12345,-12345,32145,-32145,12345,-12345,32145,-32145] => 1.sw[32767,-32768,19800,-19800,32767,-32768,19800,-19800]
246
psubsw m128.sw[-32145,32145,12345,-12345,-32145,32145,12345,-12345] xmm.sw[12345,-12345,32145,-32145,12345,-12345,32145,-32145] => 1.sw[32767,-32768,19800,-19800,32767,-32768,19800,-19800]
247
psubusb xmm.ub[11,22,33,44,55,66,77,88,11,22,33,44,55,66,77,88] xmm.ub[88,77,66,55,44,33,22,11,88,77,66,55,44,33,22,11] => 1.ub[77,55,33,11,0,0,0,0,77,55,33,11,0,0,0,0]
248
psubusb m128.ub[11,22,33,44,55,66,77,88,11,22,33,44,55,66,77,88] xmm.ub[88,77,66,55,44,33,22,11,88,77,66,55,44,33,22,11] => 1.ub[77,55,33,11,0,0,0,0,77,55,33,11,0,0,0,0]
249
psubusw xmm.uw[1122,3344,5566,7788,1122,3344,5566,7788] xmm.uw[8877,6655,4433,2211,8877,6655,4433,2211] => 1.uw[7755,3311,0,0,7755,3311,0,0]
250
psubusw m128.uw[1122,3344,5566,7788,1122,3344,5566,7788] xmm.uw[8877,6655,4433,2211,8877,6655,4433,2211] => 1.uw[7755,3311,0,0,7755,3311,0,0]
251
psubw xmm.sw[87,65,43,21,87,65,43,21] xmm.sw[1234,5678,4321,8765,1234,5678,4321,8765] => 1.sw[1147,5613,4278,8744,1147,5613,4278,8744]
252
psubw m128.sw[87,65,43,21,87,65,43,21] xmm.sw[1234,5678,4321,8765,1234,5678,4321,8765] => 1.sw[1147,5613,4278,8744,1147,5613,4278,8744]
253
punpckhbw xmm.ub[12,34,56,78,21,43,65,87,78,56,34,12,87,65,43,21] xmm.ub[11,22,33,44,55,66,77,88,88,77,66,55,44,33,22,11] => 1.ub[88,78,77,56,66,34,55,12,44,87,33,65,22,43,11,21]
254
punpckhbw m128.ub[12,34,56,78,21,43,65,87,78,56,34,12,87,65,43,21] xmm.ub[11,22,33,44,55,66,77,88,88,77,66,55,44,33,22,11] => 1.ub[88,78,77,56,66,34,55,12,44,87,33,65,22,43,11,21]
255
punpckhdq xmm.ud[12345678,21436587,78563412,87654321] xmm.ud[11223344,55667788,88776655,44332211] => 1.ud[88776655,78563412,44332211,87654321]
256
punpckhdq m128.ud[12345678,21436587,78563412,87654321] xmm.ud[11223344,55667788,88776655,44332211] => 1.ud[88776655,78563412,44332211,87654321]
257
punpckhqdq xmm.uq[1234567821436587,7856341287654321] xmm.uq[1122334455667788,8877665544332211] => 1.uq[8877665544332211,7856341287654321]
258
punpckhqdq m128.uq[1234567821436587,7856341287654321] xmm.uq[1122334455667788,8877665544332211] => 1.uq[8877665544332211,7856341287654321]
259
punpckhwd xmm.uw[1234,5678,2143,6587,7856,3412,8765,4321] xmm.uw[1122,3344,5566,7788,8877,6655,4433,2211] => 1.uw[8877,7856,6655,3412,4433,8765,2211,4321]
260
punpckhwd m128.uw[1234,5678,2143,6587,7856,3412,8765,4321] xmm.uw[1122,3344,5566,7788,8877,6655,4433,2211] => 1.uw[8877,7856,6655,3412,4433,8765,2211,4321]
261
punpcklbw xmm.ub[12,34,56,78,21,43,65,87,78,56,34,12,87,65,43,21] xmm.ub[11,22,33,44,55,66,77,88,88,77,66,55,44,33,22,11] => 1.ub[11,12,22,34,33,56,44,78,55,21,66,43,77,65,88,87]
262
punpcklbw m128.ub[12,34,56,78,21,43,65,87,78,56,34,12,87,65,43,21] xmm.ub[11,22,33,44,55,66,77,88,88,77,66,55,44,33,22,11] => 1.ub[11,12,22,34,33,56,44,78,55,21,66,43,77,65,88,87]
263
punpckldq xmm.ud[12345678,21436587,78563412,87654321] xmm.ud[11223344,55667788,88776655,44332211] => 1.ud[11223344,12345678,55667788,21436587]
264
punpckldq m128.ud[12345678,21436587,78563412,87654321] xmm.ud[11223344,55667788,88776655,44332211] => 1.ud[11223344,12345678,55667788,21436587]
265
punpcklqdq xmm.uq[1234567821436587,7856341287654321] xmm.uq[1122334455667788,8877665544332211] => 1.uq[1122334455667788,1234567821436587]
266
punpcklqdq m128.uq[1234567821436587,7856341287654321] xmm.uq[1122334455667788,8877665544332211] => 1.uq[1122334455667788,1234567821436587]
267
punpcklwd xmm.uw[1234,5678,2143,6587,7856,3412,8765,4321] xmm.uw[1122,3344,5566,7788,8877,6655,4433,2211] => 1.uw[1122,1234,3344,5678,5566,2143,7788,6587]
268
punpcklwd m128.uw[1234,5678,2143,6587,7856,3412,8765,4321] xmm.uw[1122,3344,5566,7788,8877,6655,4433,2211] => 1.uw[1122,1234,3344,5678,5566,2143,7788,6587]
269
pxor xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc9a30566503a9cf,0xfc9a30566503a9cf]
270
pxor m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc9a30566503a9cf,0xfc9a30566503a9cf]
271
shufpd imm8[0x0] xmm.pd[1234.5678,8765.4321] xmm.pd[1234.5678,8765.4321] => 2.pd[1234.5678,1234.5678]
272
shufpd imm8[0x3] m128.pd[1234.5678,8765.4321] xmm.pd[1234.5678,8765.4321] => 2.pd[8765.4321,8765.4321]
273
sqrtpd xmm.pd[36.0,49.0] xmm.pd[1.11,2.22] => 1.pd[6.0,7.0]
274
sqrtpd m128.pd[36.0,49.0] xmm.pd[1.11,2.22] => 1.pd[6.0,7.0]
275
sqrtsd xmm.pd[36.0,5.55] xmm.pd[1.11,2.22] => 1.pd[6.0,2.22]
276
sqrtsd m128.pd[36.0,5.55] xmm.pd[1.11,2.22] => 1.pd[6.0,2.22]
277
subpd xmm.pd[1234.5678,8765.4321] xmm.pd[2222.0,1111.0] => 1.pd[987.4322,-7654.4321]
278
subpd m128.pd[1234.5678,8765.4321] xmm.pd[2222.0,1111.0] => 1.pd[987.4322,-7654.4321]
279
subsd xmm.pd[1234.5678,8765.4321] xmm.pd[2222.0,1111.0] => 1.pd[987.4322,1111.0]
280
subsd m128.pd[1234.5678,8765.4321] xmm.pd[2222.0,1111.0] => 1.pd[987.4322,1111.0]
281
ucomisd xmm.pd[1234.5678,0.0] xmm.pd[1234.5679,0.0] => eflags[0x8d5,0x000]
282
ucomisd xmm.pd[1234.5678,0.0] xmm.pd[1234.5677,0.0] => eflags[0x8d5,0x001]
283
ucomisd xmm.pd[1234.5678,0.0] xmm.pd[1234.5678,0.0] => eflags[0x8d5,0x040]
284
ucomisd m64.pd[1234.5678] xmm.pd[1234.5679,0.0] => eflags[0x8d5,0x000]
285
ucomisd m64.pd[1234.5678] xmm.pd[1234.5677,0.0] => eflags[0x8d5,0x001]
286
ucomisd m64.pd[1234.5678] xmm.pd[1234.5678,0.0] => eflags[0x8d5,0x040]
287
unpckhpd xmm.pd[1234.5678,8765.4321] xmm.pd[1122.3344,5566.7788] => 1.pd[5566.7788,8765.4321]
288
unpckhpd m128.pd[1234.5678,8765.4321] xmm.pd[1122.3344,5566.7788] => 1.pd[5566.7788,8765.4321]
289
unpcklpd xmm.pd[1234.5678,8765.4321] xmm.pd[1122.3344,5566.7788] => 1.pd[1122.3344,1234.5678]
290
unpcklpd m128.pd[1234.5678,8765.4321] xmm.pd[1122.3344,5566.7788] => 1.pd[1122.3344,1234.5678]
291
xorpd xmm.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc9a30566503a9cf,0xfc9a30566503a9cf]
292
xorpd m128.uq[0xfdb97531eca86420,0x0123456789abcdef] xmm.uq[0x0123456789abcdef,0xfdb97531eca86420] => 1.uq[0xfc9a30566503a9cf,0xfc9a30566503a9cf]
(-)valgrind-2.1.0/none/tests/insn_sse2.stderr.exp (+2 lines)
Line 0 Link Here
1
2
(-)valgrind-2.1.0/none/tests/insn_sse2.stdout.exp (+292 lines)
Line 0 Link Here
1
addpd_1 ... ok
2
addpd_2 ... ok
3
addsd_1 ... ok
4
addsd_2 ... ok
5
andpd_1 ... ok
6
andpd_2 ... ok
7
andnpd_1 ... ok
8
andnpd_2 ... ok
9
cmpeqpd_1 ... ok
10
cmpeqpd_2 ... ok
11
cmpltpd_1 ... ok
12
cmpltpd_2 ... ok
13
cmplepd_1 ... ok
14
cmplepd_2 ... ok
15
cmpneqpd_1 ... ok
16
cmpneqpd_2 ... ok
17
cmpnltpd_1 ... ok
18
cmpnltpd_2 ... ok
19
cmpnlepd_1 ... ok
20
cmpnlepd_2 ... ok
21
cmpeqsd_1 ... ok
22
cmpeqsd_2 ... ok
23
cmpltsd_1 ... ok
24
cmpltsd_2 ... ok
25
cmplesd_1 ... ok
26
cmplesd_2 ... ok
27
cmpneqsd_1 ... ok
28
cmpneqsd_2 ... ok
29
cmpnltsd_1 ... ok
30
cmpnltsd_2 ... ok
31
cmpnlesd_1 ... ok
32
cmpnlesd_2 ... ok
33
comisd_1 ... ok
34
comisd_2 ... ok
35
comisd_3 ... ok
36
comisd_4 ... ok
37
comisd_5 ... ok
38
comisd_6 ... ok
39
cvtdq2pd_1 ... ok
40
cvtdq2pd_2 ... ok
41
cvtdq2ps_1 ... ok
42
cvtdq2ps_2 ... ok
43
cvtpd2dq_1 ... ok
44
cvtpd2dq_2 ... ok
45
cvtpd2pi_1 ... ok
46
cvtpd2pi_2 ... ok
47
cvtpd2ps_1 ... ok
48
cvtpd2ps_2 ... ok
49
cvtpi2pd_1 ... ok
50
cvtpi2pd_2 ... ok
51
cvtps2dq_1 ... ok
52
cvtps2dq_2 ... ok
53
cvtps2pd_1 ... ok
54
cvtps2pd_2 ... ok
55
cvtsd2si_1 ... ok
56
cvtsd2si_2 ... ok
57
cvtsd2ss_1 ... ok
58
cvtsd2ss_2 ... ok
59
cvtsi2sd_1 ... ok
60
cvtsi2sd_2 ... ok
61
cvtss2sd_1 ... ok
62
cvtss2sd_2 ... ok
63
cvttpd2pi_1 ... ok
64
cvttpd2pi_2 ... ok
65
cvttpd2dq_1 ... ok
66
cvttpd2dq_2 ... ok
67
cvttps2dq_1 ... ok
68
cvttps2dq_2 ... ok
69
cvttsd2si_1 ... ok
70
cvttsd2si_2 ... ok
71
divpd_1 ... ok
72
divpd_2 ... ok
73
divsd_1 ... ok
74
divsd_2 ... ok
75
maxpd_1 ... ok
76
maxpd_2 ... ok
77
maxsd_1 ... ok
78
maxsd_2 ... ok
79
minpd_1 ... ok
80
minpd_2 ... ok
81
minsd_1 ... ok
82
minsd_2 ... ok
83
movapd_1 ... ok
84
movapd_2 ... ok
85
movd_1 ... ok
86
movd_2 ... ok
87
movd_3 ... ok
88
movd_4 ... ok
89
movdqa_1 ... ok
90
movdqa_2 ... ok
91
movdqa_3 ... ok
92
movdqu_1 ... ok
93
movdqu_2 ... ok
94
movdqu_3 ... ok
95
movdq2q_1 ... ok
96
movhpd_1 ... ok
97
movhpd_2 ... ok
98
movlpd_1 ... ok
99
movlpd_2 ... ok
100
movmskpd_1 ... ok
101
movntdq_1 ... ok
102
movnti_1 ... ok
103
movntpd_1 ... ok
104
movq2dq_1 ... ok
105
movsd_1 ... ok
106
movsd_2 ... ok
107
movsd_3 ... ok
108
movupd_1 ... ok
109
movupd_2 ... ok
110
mulpd_1 ... ok
111
mulpd_2 ... ok
112
mulsd_1 ... ok
113
mulsd_2 ... ok
114
orpd_1 ... ok
115
orpd_2 ... ok
116
packssdw_1 ... ok
117
packssdw_2 ... ok
118
packsswb_1 ... ok
119
packsswb_2 ... ok
120
packuswb_1 ... ok
121
packuswb_2 ... ok
122
paddb_1 ... ok
123
paddb_2 ... ok
124
paddd_1 ... ok
125
paddd_2 ... ok
126
paddq_1 ... ok
127
paddq_2 ... ok
128
paddq_3 ... ok
129
paddq_4 ... ok
130
paddsb_1 ... ok
131
paddsb_2 ... ok
132
paddsw_1 ... ok
133
paddsw_2 ... ok
134
paddusb_1 ... ok
135
paddusb_2 ... ok
136
paddusw_1 ... ok
137
paddusw_2 ... ok
138
paddw_1 ... ok
139
paddw_2 ... ok
140
pand_1 ... ok
141
pand_2 ... ok
142
pandn_1 ... ok
143
pandn_2 ... ok
144
pavgb_1 ... ok
145
pavgb_2 ... ok
146
pavgw_1 ... ok
147
pavgw_2 ... ok
148
pcmpeqb_1 ... ok
149
pcmpeqb_2 ... ok
150
pcmpeqd_1 ... ok
151
pcmpeqd_2 ... ok
152
pcmpeqw_1 ... ok
153
pcmpeqw_2 ... ok
154
pcmpgtb_1 ... ok
155
pcmpgtb_2 ... ok
156
pcmpgtd_1 ... ok
157
pcmpgtd_2 ... ok
158
pcmpgtw_1 ... ok
159
pcmpgtw_2 ... ok
160
pextrw_1 ... ok
161
pextrw_2 ... ok
162
pextrw_3 ... ok
163
pextrw_4 ... ok
164
pextrw_5 ... ok
165
pextrw_6 ... ok
166
pextrw_7 ... ok
167
pextrw_8 ... ok
168
pinsrw_1 ... ok
169
pinsrw_2 ... ok
170
pinsrw_3 ... ok
171
pinsrw_4 ... ok
172
pinsrw_5 ... ok
173
pinsrw_6 ... ok
174
pinsrw_7 ... ok
175
pinsrw_8 ... ok
176
pmaddwd_1 ... ok
177
pmaddwd_2 ... ok
178
pmaxsw_1 ... ok
179
pmaxsw_2 ... ok
180
pmaxub_1 ... ok
181
pmaxub_2 ... ok
182
pminsw_1 ... ok
183
pminsw_2 ... ok
184
pminub_1 ... ok
185
pminub_2 ... ok
186
pmovmskb_1 ... ok
187
pmulhuw_1 ... ok
188
pmulhuw_2 ... ok
189
pmulhw_1 ... ok
190
pmulhw_2 ... ok
191
pmullw_1 ... ok
192
pmullw_2 ... ok
193
pmuludq_1 ... ok
194
pmuludq_2 ... ok
195
pmuludq_3 ... ok
196
pmuludq_4 ... ok
197
por_1 ... ok
198
por_2 ... ok
199
psadbw_1 ... ok
200
psadbw_2 ... ok
201
pshufd_1 ... ok
202
pshufd_2 ... ok
203
pshufhw_1 ... ok
204
pshufhw_2 ... ok
205
pshuflw_1 ... ok
206
pshuflw_2 ... ok
207
pslld_1 ... ok
208
pslld_2 ... ok
209
pslld_3 ... ok
210
pslldq_1 ... ok
211
pslldq_2 ... ok
212
psllq_1 ... ok
213
psllq_2 ... ok
214
psllq_3 ... ok
215
psllw_1 ... ok
216
psllw_2 ... ok
217
psllw_3 ... ok
218
psrad_1 ... ok
219
psrad_2 ... ok
220
psrad_3 ... ok
221
psraw_1 ... ok
222
psraw_2 ... ok
223
psraw_3 ... ok
224
psrld_1 ... ok
225
psrld_2 ... ok
226
psrld_3 ... ok
227
psrldq_1 ... ok
228
psrldq_2 ... ok
229
psrlq_1 ... ok
230
psrlq_2 ... ok
231
psrlq_3 ... ok
232
psrlw_1 ... ok
233
psrlw_2 ... ok
234
psrlw_3 ... ok
235
psubb_1 ... ok
236
psubb_2 ... ok
237
psubd_1 ... ok
238
psubd_2 ... ok
239
psubq_1 ... ok
240
psubq_2 ... ok
241
psubq_3 ... ok
242
psubq_4 ... ok
243
psubsb_1 ... ok
244
psubsb_2 ... ok
245
psubsw_1 ... ok
246
psubsw_2 ... ok
247
psubusb_1 ... ok
248
psubusb_2 ... ok
249
psubusw_1 ... ok
250
psubusw_2 ... ok
251
psubw_1 ... ok
252
psubw_2 ... ok
253
punpckhbw_1 ... ok
254
punpckhbw_2 ... ok
255
punpckhdq_1 ... ok
256
punpckhdq_2 ... ok
257
punpckhqdq_1 ... ok
258
punpckhqdq_2 ... ok
259
punpckhwd_1 ... ok
260
punpckhwd_2 ... ok
261
punpcklbw_1 ... ok
262
punpcklbw_2 ... ok
263
punpckldq_1 ... ok
264
punpckldq_2 ... ok
265
punpcklqdq_1 ... ok
266
punpcklqdq_2 ... ok
267
punpcklwd_1 ... ok
268
punpcklwd_2 ... ok
269
pxor_1 ... ok
270
pxor_2 ... ok
271
shufpd_1 ... ok
272
shufpd_2 ... ok
273
sqrtpd_1 ... ok
274
sqrtpd_2 ... ok
275
sqrtsd_1 ... ok
276
sqrtsd_2 ... ok
277
subpd_1 ... ok
278
subpd_2 ... ok
279
subsd_1 ... ok
280
subsd_2 ... ok
281
ucomisd_1 ... ok
282
ucomisd_2 ... ok
283
ucomisd_3 ... ok
284
ucomisd_4 ... ok
285
ucomisd_5 ... ok
286
ucomisd_6 ... ok
287
unpckhpd_1 ... ok
288
unpckhpd_2 ... ok
289
unpcklpd_1 ... ok
290
unpcklpd_2 ... ok
291
xorpd_1 ... ok
292
xorpd_2 ... ok
(-)valgrind-2.1.0/none/tests/insn_sse2.vgtest (+2 lines)
Line 0 Link Here
1
prog: insn_sse2
2
cpu_test: sse2
(-)valgrind-2.1.0/none/tests/map_unmap.c (+82 lines)
Line 0 Link Here
1
#include <stdio.h>
2
#include <sys/mman.h>
3
#include <stdlib.h>
4
#include <unistd.h>
5
6
static unsigned int pagesize;
7
8
#define PAGES	1024u
9
#define LEN	(PAGES*pagesize)
10
11
static void *domap(void)
12
{
13
	void *ret = mmap(0, LEN, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
14
15
	if (ret == (void *)-1) {
16
		perror("mmap");
17
		exit(1);
18
	}
19
20
	return ret;
21
}
22
23
/* unmap in pieces to exercise munmap more */
24
static void nibblemap(void *p)
25
{
26
	int off;
27
	int i;
28
29
	off = (random() % LEN) & ~(pagesize-1);
30
	
31
	for(i = 0; i < PAGES; i++) {
32
		/* printf("unmapping off=%d\n", off/pagesize); */
33
		munmap((char *)p + off, pagesize);
34
		off += 619*pagesize;
35
		off %= LEN;
36
	}
37
}
38
39
static void prmaps()
40
{
41
	char buf[100];
42
	sprintf(buf, "/bin/cat /proc/%d/maps", getpid());
43
	system(buf);
44
	exit(1);
45
}
46
47
int main()
48
{
49
	int i;
50
	void *expect1, *expect2;
51
52
	pagesize = getpagesize();
53
54
	expect1 = domap();
55
	expect2 = domap();
56
	munmap(expect1, LEN);
57
	munmap(expect2, LEN);
58
59
	for(i = 0; i < 100; i++) {
60
		void *m1, *m2;
61
62
		m1 = domap();
63
		if (m1 != expect1) {
64
			printf("FAIL i=%d: m1=%p expect1=%p\n",
65
			       i, m1, expect1);
66
			prmaps();
67
			return 1;
68
		}
69
		m2 = domap();
70
		if (m2 != expect2) {
71
			printf("FAIL i=%d: m2=%p expect2=%p\n",
72
			       i, m2, expect2);
73
			prmaps();
74
			return 1;
75
		}
76
		nibblemap(m2);
77
		munmap(m1, LEN);
78
	}
79
	
80
	printf("PASS\n");
81
	return 0;
82
}
(-)valgrind-2.1.0/none/tests/map_unmap.stderr.exp (+2 lines)
Line 0 Link Here
1
2
(-)valgrind-2.1.0/none/tests/map_unmap.stdout.exp (+1 lines)
Line 0 Link Here
1
PASS
(-)valgrind-2.1.0/none/tests/map_unmap.vgtest (+1 lines)
Line 0 Link Here
1
prog: map_unmap
(-)valgrind-2.1.0/none/tests/mremap.c (+98 lines)
Line 0 Link Here
1
#define _GNU_SOURCE
2
#include <sys/mman.h>
3
#include <stdio.h>
4
#include <stdlib.h>
5
6
static char *mkmap(unsigned sz)
7
{
8
	static char *map;
9
	static unsigned mapsz;
10
	char *p;
11
12
	if (map != NULL)
13
		munmap(map, mapsz);
14
15
	p = (char *)mmap(0, sz, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
16
	
17
	if (p == (char *)-1) {
18
		perror("mmap");
19
		exit(1);
20
	}
21
22
	map = p;
23
	mapsz = sz;
24
25
	return p;
26
}
27
28
29
int main()
30
{
31
	char *np;
32
	char *p;
33
34
	p = mkmap(1024*1024);
35
	np = mremap(p, 1024*1024, 256*1024, 0);	/* shrink, fixed */	
36
	if (np == (char *)-1)
37
		perror("mremap(shrink, fixed)");
38
	if (np != p)
39
		fprintf(stderr, "shrink, nomove: p=%p np=%p: shrink moved?!\n",
40
			p, np);
41
	if (np != (char *)-1)
42
		munmap(np, 256*1024);
43
44
	p = mkmap(1024*1024);
45
	np = mremap(p, 1024*1024, 256*1024, MREMAP_MAYMOVE);	/* shrink, maymove */	
46
	if (np == (char *)-1)
47
		perror("mremap(shrink, maymove)");
48
	if (np != p)
49
		fprintf(stderr, "shrink, maymove: p=%p np=%p: shrink moved?!\n",
50
			p, np);
51
	if (np != (char *)-1)
52
		munmap(np, 256*1024);
53
54
	p = mkmap(1024*1024);
55
	np = mremap(p, 1024*1024, 2048*1024, 0); /* grow, fixed */
56
	if (np == (char *)-1)
57
		perror("mremap(grow, fixed)");
58
	if (np != p)
59
		fprintf(stderr, "grow, nomove: p=%p np=%p: shrink moved?!\n",
60
			p, np);
61
	if (np != (char *)-1)
62
		munmap(np, 2048*1024);
63
	
64
	p = mkmap(1024*1024);
65
	np = mremap(p, 1024*1024, 2048*1024, MREMAP_MAYMOVE); /* grow, maymove */
66
	if (np == (char *)-1)
67
		perror("mremap(grow, maymove)");
68
	if (np != p)
69
		fprintf(stderr, "grow, maymove: p=%p np=%p: shrink moved?!\n",
70
			p, np);
71
	if (np != (char *)-1)
72
		munmap(np, 2048*1024);
73
	
74
	p = mkmap(1024*1024);
75
	munmap(p+512*1024, 4096);
76
	np = mremap(p, 512*1024, 1024*1024, 0); /* grow, nomove, constrained */
77
	if (np == (char *)-1)
78
		perror("mremap(grow, nomove, constrained)");
79
	else if (np == p)
80
		fprintf(stderr, "grow, maymove, constrained: p=%p np=%p (managed to grow without moving?!)\n",
81
			p, np);
82
	if (np != (char *)-1)
83
		munmap(np, 1024*1024);
84
	
85
	p = mkmap(1024*1024);
86
	munmap(p+512*1024, 4096);
87
88
	np = mremap(p, 512*1024, 1024*1024, MREMAP_MAYMOVE); /* grow, maymove, constrained */
89
	if (np == (char *)-1)
90
		perror("mremap(grow, maymove, constrained)");
91
	if (np == p)
92
		fprintf(stderr, "grow, maymove, constrained: p=%p np=%p (managed to grow without moving?!)\n",
93
			p, np);
94
	if (np != (char *)-1)
95
		munmap(np, 1024*1024);
96
97
	return 0;
98
}
(-)valgrind-2.1.0/none/tests/mremap.stderr.exp (+3 lines)
Line 0 Link Here
1
2
mremap(grow, nomove, constrained): Cannot allocate memory
3
(-)valgrind-2.1.0/none/tests/mremap.vgtest (+1 lines)
Line 0 Link Here
1
prog: mremap
(-)valgrind-2.1.0/none/tests/munmap_exe.c (-1 / +1 lines)
Lines 11-17 Link Here
11
{
11
{
12
    void* m;
12
    void* m;
13
    
13
    
14
    m = mmap(NULL, 100, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
14
    m = mmap(NULL, 100, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0);
15
15
16
    if (m == (void*)-1) {
16
    if (m == (void*)-1) {
17
       fprintf(stderr, "error mmapping\n");
17
       fprintf(stderr, "error mmapping\n");
(-)valgrind-2.1.0/none/tests/pth_specific.c (+104 lines)
Line 0 Link Here
1
/********************************************************
2
 * An example source module to accompany...
3
 *
4
 * "Using POSIX Threads: Programming with Pthreads"
5
 *     by Brad nichols, Dick Buttlar, Jackie Farrell
6
 *     O'Reilly & Associates, Inc.
7
 *
8
 ********************************************************
9
 * specific.c
10
 *
11
 */
12
#include <stdlib.h>
13
#include <stdio.h>
14
#include <unistd.h>
15
16
#include <sys/time.h>
17
18
#include <pthread.h>
19
20
#define NUM_THREADS  3
21
pthread_key_t     saved_time_key;
22
23
24
void free_time(void *arg )
25
{
26
  struct timeval *timev=(struct timeval *)arg; 
27
  printf("free_time:\n");
28
  free(timev);
29
}
30
31
void save_the_time(void)
32
{
33
  struct timeval *timev;
34
35
  timev = (struct timeval *)malloc(sizeof(struct timeval));
36
  
37
  gettimeofday(timev, NULL);
38
39
  printf("save_the_time: \t\t%ld %ld\n",timev->tv_sec, timev->tv_usec);
40
41
42
  pthread_setspecific(saved_time_key, (void *)timev);
43
  
44
}
45
46
void what_time_did_i_save(void)
47
{
48
  struct timeval *timev;
49
50
  timev = pthread_getspecific(saved_time_key);
51
52
  printf("what_time_did_i_save: \t%ld %ld\n",timev->tv_sec, timev->tv_usec);
53
54
}  
55
56
void *thread_routine(void *arg)
57
{
58
  int *my_id=(int *)arg;
59
60
  printf("thread_routine %d\n", *my_id);
61
62
  save_the_time();
63
64
  what_time_did_i_save();
65
 
66
  return(NULL); 
67
}
68
69
extern int 
70
main(void)
71
{
72
	int       i, *id_arg;
73
	pthread_t threads[NUM_THREADS];
74
75
	id_arg = (int *)malloc(NUM_THREADS*sizeof(int));
76
77
	printf("main : initializing the key\n");
78
	pthread_key_create(&saved_time_key, free_time);
79
80
	printf("main : spawing the threads\n");
81
	for (i = 0; i < NUM_THREADS; i++) {
82
83
		id_arg[i] = i;
84
85
		pthread_create(&(threads[i]), 
86
			       NULL,
87
			       thread_routine,
88
			       (void *) &(id_arg[i]));
89
	}
90
91
92
	for (i = 0; i < NUM_THREADS; i++) {
93
	  pthread_join(threads[i], NULL);
94
 	  printf("main : thread %d has finished. \n", i);
95
	}
96
97
	printf("main : goodbye\n");
98
99
	return 0;
100
}
101
102
103
104
(-)valgrind-2.1.0/none/tests/resolv.c (+1 lines)
Lines 1-4 Link Here
1
1
2
#include <netinet/in.h>
2
#include <resolv.h>
3
#include <resolv.h>
3
#include <stdio.h>
4
#include <stdio.h>
4
5
(-)valgrind-2.1.0/none/tests/seg_override.c (-2 / +2 lines)
Lines 110-117 Link Here
110
{
110
{
111
  asm volatile("movl %2, %%eax\n\t"
111
  asm volatile("movl %2, %%eax\n\t"
112
               "movl %1, %%edx\n\t"
112
               "movl %1, %%edx\n\t"
113
	       "movl %0, %%gs\n\t"
113
	       "movl %0, %%fs\n\t"
114
               "movl %%eax, %%gs:(%%edx)\t"
114
               "movl %%eax, %%fs:(%%edx)\t"
115
	       : 
115
	       : 
116
               : "r" (7 /* LDT(TI), least privilege */ + (ldt_entno << 3)), 
116
               : "r" (7 /* LDT(TI), least privilege */ + (ldt_entno << 3)), 
117
                 "r" (offset), "r" (val)
117
                 "r" (offset), "r" (val)
(-)valgrind-2.1.0/none/tests/sha1_test.c (+9 lines)
Lines 42-47 Link Here
42
42
43
#define SHA1HANDSOFF
43
#define SHA1HANDSOFF
44
44
45
#include <config.h>
46
45
#include <string.h>
47
#include <string.h>
46
#include <sys/types.h>	/* for u_int*_t */
48
#include <sys/types.h>	/* for u_int*_t */
47
49
Lines 63-69 Link Here
63
void SHA1Update(SHA1_CTX* context, const unsigned char* data, u_int32_t len);
65
void SHA1Update(SHA1_CTX* context, const unsigned char* data, u_int32_t len);
64
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
66
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
65
/* ================ end of sha1.h ================ */
67
/* ================ end of sha1.h ================ */
68
69
#ifdef HAVE_SYS_ENDIAN_H
70
#include <sys/endian.h>
71
#endif
72
73
#ifdef HAVE_ENDIAN_H
66
#include <endian.h>
74
#include <endian.h>
75
#endif
67
76
68
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
77
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
69
78
(-)valgrind-2.1.0/none/tests/smc1.c (-1 / +5 lines)
Lines 30-35 Link Here
30
*/
30
*/
31
31
32
#include <stdio.h>
32
#include <stdio.h>
33
#include "valgrind.h"
33
34
34
typedef unsigned int Addr;
35
typedef unsigned int Addr;
35
typedef unsigned char UChar;
36
typedef unsigned char UChar;
Lines 44-50 Link Here
44
   printf("in p %d\n", n);
45
   printf("in p %d\n", n);
45
}
46
}
46
47
47
UChar code[100];
48
UChar code[10];
48
49
49
/* Make `code' be JMP-32 dest */
50
/* Make `code' be JMP-32 dest */
50
void set_dest ( Addr dest )
51
void set_dest ( Addr dest )
Lines 58-63 Link Here
58
   code[2] = ((delta >> 8) & 0xFF);
59
   code[2] = ((delta >> 8) & 0xFF);
59
   code[3] = ((delta >> 16) & 0xFF);
60
   code[3] = ((delta >> 16) & 0xFF);
60
   code[4] = ((delta >> 24) & 0xFF);
61
   code[4] = ((delta >> 24) & 0xFF);
62
63
   /* XXX this should be automatic */
64
   VALGRIND_DISCARD_TRANSLATIONS(code, sizeof(code));
61
}
65
}
62
66
63
int main ( void )
67
int main ( void )
(-)valgrind-2.1.0/none/tests/smc1.stdout.exp (-5 / +5 lines)
Lines 1-10 Link Here
1
in p 0
1
in p 0
2
in p 1
2
in q 1
3
in p 2
3
in p 2
4
in p 3
4
in q 3
5
in p 4
5
in p 4
6
in p 5
6
in q 5
7
in p 6
7
in p 6
8
in p 7
8
in q 7
9
in p 8
9
in p 8
10
in p 9
10
in q 9
(-)valgrind-2.1.0/none/tests/syscall-restart1.c (+63 lines)
Line 0 Link Here
1
#include <stdio.h>
2
#include <unistd.h>
3
#include <signal.h>
4
#include <errno.h>
5
#include <sys/wait.h>
6
#include <string.h>
7
8
/* Make sure that a blocking syscall returns EINTR if hit by a signal,
9
   and there's no SA_RESTART */
10
11
static void handler(int s)
12
{
13
}
14
15
int main()
16
{
17
	int pid;
18
	int fds[2];
19
20
	if (pipe(fds) == -1) {
21
		perror("FAIL: pipe\n");
22
		return 1;
23
	}
24
25
	pid = fork();
26
27
	if (pid == -1) {
28
		perror("fork failed");
29
		return 1;
30
	}
31
32
	if (pid == 0) {
33
		char ch = '?';
34
		int ret;
35
		struct sigaction sa;
36
		
37
		sa.sa_handler = handler;
38
		sigfillset(&sa.sa_mask);
39
		sa.sa_flags = 0; /* no SA_RESTART */
40
41
		sigaction(SIGUSR1, &sa, NULL);
42
43
		close(fds[1]);
44
		ret = read(fds[0], &ch, 1);
45
46
		if (ret != -1 || errno != EINTR)
47
			fprintf(stderr, "FAIL: expected EINTR, not %d/%s/%c\n", 
48
				ret, strerror(errno), ch);
49
	} else {
50
		signal(SIGPIPE, SIG_IGN);
51
52
		close(fds[0]);
53
		sleep(1);
54
		kill(pid, SIGUSR1);
55
		sleep(1);
56
		if (write(fds[1], "x", 1) != -1 || errno != EPIPE)
57
			fprintf(stderr, "FAIL: expected write to fail with EPIPE\n");
58
59
		waitpid(pid, NULL, 0);
60
	}
61
62
	return 0;
63
}
(-)valgrind-2.1.0/none/tests/syscall-restart1.stderr.exp (+3 lines)
Line 0 Link Here
1
2
3
(-)valgrind-2.1.0/none/tests/syscall-restart1.vgtest (+1 lines)
Line 0 Link Here
1
prog: syscall-restart1
(-)valgrind-2.1.0/none/tests/syscall-restart2.c (+62 lines)
Line 0 Link Here
1
#include <stdio.h>
2
#include <unistd.h>
3
#include <signal.h>
4
#include <errno.h>
5
#include <sys/wait.h>
6
#include <string.h>
7
8
/* Make sure that a blocking syscall restarts if hit by a signal,
9
   and SA_RESTART is set */
10
11
static void handler(int s)
12
{
13
}
14
15
int main()
16
{
17
	int pid;
18
	int fds[2];
19
20
	if (pipe(fds) == -1) {
21
		perror("FAIL: pipe\n");
22
		return 1;
23
	}
24
25
	pid = fork();
26
27
	if (pid == -1) {
28
		perror("fork failed");
29
		return 1;
30
	}
31
32
	if (pid == 0) {
33
		char ch = '?';
34
		int ret;
35
		struct sigaction sa;
36
		
37
		sa.sa_handler = handler;
38
		sigfillset(&sa.sa_mask);
39
		sa.sa_flags = SA_RESTART;
40
41
		sigaction(SIGUSR1, &sa, NULL);
42
43
		close(fds[1]);
44
		ret = read(fds[0], &ch, 1);
45
46
		if (ret != 1 || ch != 'x')
47
			fprintf(stderr, "FAIL: expected 1 byte, not %d/%s/%c\n", 
48
				ret, strerror(errno), ch);
49
	} else {
50
		signal(SIGPIPE, SIG_IGN);
51
52
		close(fds[0]);
53
		sleep(1);
54
		kill(pid, SIGUSR1);
55
		sleep(1);
56
		write(fds[1], "x", 1);
57
58
		waitpid(pid, NULL, 0);
59
	}
60
61
	return 0;
62
}
(-)valgrind-2.1.0/none/tests/syscall-restart2.stderr.exp (+3 lines)
Line 0 Link Here
1
2
3
(-)valgrind-2.1.0/none/tests/syscall-restart2.vgtest (+1 lines)
Line 0 Link Here
1
prog: syscall-restart2
(-)valgrind-2.1.0/none/tests/tls.c (+101 lines)
Line 0 Link Here
1
#include <pthread.h>
2
#include <stdio.h>
3
#include <unistd.h>
4
#include <time.h>
5
6
#define COUNT 10
7
8
static int race;
9
static __thread int local;
10
__thread int global;
11
extern __thread int static_extern;
12
extern __thread int so_extern;
13
14
/* deliberate failure */
15
static int *test_race(void)
16
{
17
	return &race;
18
}
19
20
static int *test_local(void)
21
{
22
	return &local;
23
}
24
25
static int *test_global(void)
26
{
27
	return &global;
28
}
29
30
static int *test_static_extern(void)
31
{
32
	return &static_extern;
33
}
34
35
static int *test_so_extern(void)
36
{
37
	return &so_extern;
38
}
39
40
static const struct timespec awhile = { 0, 100000000 };
41
42
typedef int *(*func_t)(void);
43
struct testcase {
44
	const char *name;
45
	func_t func;
46
};
47
48
static void *tls_ptr(void *p)
49
{
50
	struct testcase *test = (struct testcase *)p;
51
	int *ip = (*test->func)();
52
	int here = 0;
53
	int i;
54
55
	for(i = 0; i < COUNT; i++) {
56
		int a = (*ip)++;
57
		int b = here++;
58
		if (a != b)
59
			printf("tls_ptr: case \"%s\" has mismatch: *ip=%d here=%d\n",
60
			       test->name, a, b);
61
		nanosleep(&awhile, 0);
62
	}
63
64
	return 0;
65
}
66
67
int *test_so_extern(void);
68
int *test_so_local(void);
69
int *test_so_global(void);
70
71
static const struct testcase tests[] = {
72
#define T(t)	{ #t, test_##t }
73
	T(race),
74
	T(local),
75
	T(global),
76
	T(static_extern),
77
	T(so_extern),
78
	T(so_local),
79
	T(so_global),
80
#undef T
81
};
82
83
#define NTESTS	(sizeof(tests)/sizeof(*tests))
84
85
int main()
86
{
87
	pthread_t threads[NTESTS*2];
88
	int curthread = 0;
89
	static 
90
	int i;
91
92
	for(i = 0; i < NTESTS; i++) {
93
		pthread_create(&threads[curthread++], NULL, tls_ptr, (void *)&tests[i]);
94
		pthread_create(&threads[curthread++], NULL, tls_ptr, (void *)&tests[i]);
95
	}
96
97
	for(i = 0; i < curthread; i++)
98
		pthread_join(threads[i], NULL);
99
100
	return 0;
101
}
(-)valgrind-2.1.0/none/tests/tls.stderr.exp (+2 lines)
Line 0 Link Here
1
2
(-)valgrind-2.1.0/none/tests/tls.stdout.exp (+19 lines)
Line 0 Link Here
1
tls_ptr: case "race" has mismatch: *ip=1 here=0
2
tls_ptr: case "race" has mismatch: *ip=2 here=1
3
tls_ptr: case "race" has mismatch: *ip=3 here=1
4
tls_ptr: case "race" has mismatch: *ip=4 here=2
5
tls_ptr: case "race" has mismatch: *ip=5 here=2
6
tls_ptr: case "race" has mismatch: *ip=6 here=3
7
tls_ptr: case "race" has mismatch: *ip=7 here=3
8
tls_ptr: case "race" has mismatch: *ip=8 here=4
9
tls_ptr: case "race" has mismatch: *ip=9 here=4
10
tls_ptr: case "race" has mismatch: *ip=10 here=5
11
tls_ptr: case "race" has mismatch: *ip=11 here=5
12
tls_ptr: case "race" has mismatch: *ip=12 here=6
13
tls_ptr: case "race" has mismatch: *ip=13 here=6
14
tls_ptr: case "race" has mismatch: *ip=14 here=7
15
tls_ptr: case "race" has mismatch: *ip=15 here=7
16
tls_ptr: case "race" has mismatch: *ip=16 here=8
17
tls_ptr: case "race" has mismatch: *ip=17 here=8
18
tls_ptr: case "race" has mismatch: *ip=18 here=9
19
tls_ptr: case "race" has mismatch: *ip=19 here=9
(-)valgrind-2.1.0/none/tests/tls.vgtest (+1 lines)
Line 0 Link Here
1
prog: tls
(-)valgrind-2.1.0/none/tests/tls2.c (+1 lines)
Line 0 Link Here
1
__thread int static_extern;
(-)valgrind-2.1.0/none/tests/tls2_so.c (+1 lines)
Line 0 Link Here
1
__thread int so_extern;
(-)valgrind-2.1.0/none/tests/tls_so.c (+20 lines)
Line 0 Link Here
1
#include <pthread.h>
2
3
extern __thread int so_extern;
4
static __thread int so_local;
5
extern __thread int global;
6
7
int *test_so_extern(void)
8
{
9
	return &so_extern;
10
}
11
12
int *test_so_local(void)
13
{
14
	return &so_local;
15
}
16
17
int *test_so_global(void)
18
{
19
	return &global;
20
}
(-)valgrind-2.1.0/none/tests/yield.c (+70 lines)
Line 0 Link Here
1
#include <pthread.h>
2
#include <stdio.h>
3
#include <stdlib.h>
4
#include <unistd.h>
5
6
static pthread_mutex_t m_go;
7
static pthread_cond_t c_go;
8
9
static volatile int alive;
10
11
static int sch_yield;
12
static int rep_nop;
13
14
static void *th1(void *v)
15
{
16
	pthread_mutex_lock(&m_go);
17
	while(!alive)
18
		pthread_cond_wait(&c_go, &m_go);
19
	pthread_mutex_unlock(&m_go);
20
21
	while(alive) {
22
		sch_yield++;
23
		sched_yield();
24
	}
25
26
	return 0;
27
}
28
29
static void *th2(void *v)
30
{
31
	pthread_mutex_lock(&m_go);
32
	while(!alive)
33
		pthread_cond_wait(&c_go, &m_go);
34
	pthread_mutex_unlock(&m_go);
35
36
	while(alive) {
37
		rep_nop++;
38
		asm volatile ("rep; nop" : : : "memory");
39
	}
40
41
	return 0;
42
}
43
44
int main()
45
{
46
	pthread_t a, b;
47
48
	pthread_create(&a, NULL, th1, NULL);
49
	pthread_create(&b, NULL, th2, NULL);
50
51
	/* make sure both threads start at the same time */
52
	pthread_mutex_lock(&m_go);
53
	alive = 1;
54
	pthread_cond_signal(&c_go);
55
	pthread_mutex_unlock(&m_go);
56
57
	sleep(1);
58
59
	alive = 0;
60
	pthread_join(a, NULL);
61
	pthread_join(b, NULL);
62
63
	if (abs(sch_yield - rep_nop) < 2)
64
		printf("PASS\n");
65
	else
66
		printf("FAIL sch_yield=%d rep_nop=%d\n", 
67
		       sch_yield, rep_nop);
68
69
	return 0;
70
}
(-)valgrind-2.1.0/none/tests/yield.stderr.exp (+2 lines)
Line 0 Link Here
1
2
(-)valgrind-2.1.0/none/tests/yield.stdout.exp (+1 lines)
Line 0 Link Here
1
PASS
(-)valgrind-2.1.0/none/tests/yield.vgtest (+1 lines)
Line 0 Link Here
1
prog: yield
(-)valgrind-2.1.0/tests/.cvsignore (+4 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
3
vg_regtest
4
true
(-)valgrind-2.1.0/tests/CVS/Entries (+11 lines)
Line 0 Link Here
1
/.cvsignore/1.3/Fri Oct  4 11:43:11 2002//
2
/Makefile.am/1.35/Mon Jan 19 19:14:18 2004//
3
/cputest.c/1.2/Wed Feb 11 23:33:29 2004//
4
/filter_addresses/1.3/Sat Jan  3 15:02:59 2004//
5
/filter_discards/1.2/Mon Sep 23 09:36:24 2002//
6
/filter_numbers/1.1/Fri Oct 31 18:52:18 2003//
7
/filter_stderr_basic/1.15/Wed Jan 21 15:08:04 2004//
8
/filter_test_paths/1.3/Mon May  5 16:18:51 2003//
9
/true.c/1.1/Fri Oct  4 11:35:47 2002//
10
/vg_regtest.in/1.18/Mon Jan 19 19:14:18 2004//
11
D
(-)valgrind-2.1.0/tests/CVS/Entries.Log (+5 lines)
Line 0 Link Here
1
A D/cachesim////
2
A D/corecheck////
3
A D/memcheck////
4
A D/none////
5
A D/unused////
(-)valgrind-2.1.0/tests/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/tests
(-)valgrind-2.1.0/tests/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/tests/Makefile.am (-2 / +3 lines)
Lines 12-23 Link Here
12
EXTRA_DIST = $(noinst_SCRIPTS)
12
EXTRA_DIST = $(noinst_SCRIPTS)
13
13
14
check_PROGRAMS = \
14
check_PROGRAMS = \
15
	true
15
	true \
16
	cputest
16
17
17
AM_CFLAGS   = $(WERROR) -Winline -Wall -Wshadow -g
18
AM_CFLAGS   = $(WERROR) -Winline -Wall -Wshadow -g
18
AM_CXXFLAGS = $(AM_CFLAGS)
19
AM_CXXFLAGS = $(AM_CFLAGS)
19
20
20
# generic C ones
21
# generic C ones
21
true_SOURCES 	= true.c
22
true_SOURCES 	= true.c
22
23
cputest_SOURCES = cputest.c
23
24
(-)valgrind-2.1.0/tests/Makefile.in (-106 / +113 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 14-19 Link Here
14
14
15
@SET_MAKE@
15
@SET_MAKE@
16
16
17
SOURCES = $(cputest_SOURCES) $(true_SOURCES)
18
17
srcdir = @srcdir@
19
srcdir = @srcdir@
18
top_srcdir = @top_srcdir@
20
top_srcdir = @top_srcdir@
19
VPATH = @srcdir@
21
VPATH = @srcdir@
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
23
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
24
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ..
25
top_builddir = ..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
27
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
28
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
37
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
38
POST_UNINSTALL = :
38
host_triplet = @host@
39
host_triplet = @host@
40
check_PROGRAMS = true$(EXEEXT) cputest$(EXEEXT)
41
subdir = tests
42
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
43
	$(srcdir)/vg_regtest.in
44
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
45
am__aclocal_m4_deps = $(top_srcdir)/configure.in
46
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
47
	$(ACLOCAL_M4)
48
mkinstalldirs = $(mkdir_p)
49
CONFIG_HEADER = $(top_builddir)/config.h
50
CONFIG_CLEAN_FILES = vg_regtest
51
am_cputest_OBJECTS = cputest.$(OBJEXT)
52
cputest_OBJECTS = $(am_cputest_OBJECTS)
53
cputest_LDADD = $(LDADD)
54
am_true_OBJECTS = true.$(OBJEXT)
55
true_OBJECTS = $(am_true_OBJECTS)
56
true_LDADD = $(LDADD)
57
SCRIPTS = $(noinst_SCRIPTS)
58
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
59
depcomp = $(SHELL) $(top_srcdir)/depcomp
60
am__depfiles_maybe = depfiles
61
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cputest.Po ./$(DEPDIR)/true.Po
62
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
63
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
64
CCLD = $(CC)
65
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
66
SOURCES = $(cputest_SOURCES) $(true_SOURCES)
67
DIST_SOURCES = $(cputest_SOURCES) $(true_SOURCES)
68
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
69
	html-recursive info-recursive install-data-recursive \
70
	install-exec-recursive install-info-recursive \
71
	install-recursive installcheck-recursive installdirs-recursive \
72
	pdf-recursive ps-recursive uninstall-info-recursive \
73
	uninstall-recursive
74
ETAGS = etags
75
CTAGS = ctags
76
DIST_SUBDIRS = $(SUBDIRS)
77
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
78
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
79
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
80
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
131
SHELL = @SHELL@
93
STRIP = @STRIP@
132
STRIP = @STRIP@
94
VERSION = @VERSION@
133
VERSION = @VERSION@
134
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
135
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
136
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
137
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
163
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
164
localstatedir = @localstatedir@
125
mandir = @mandir@
165
mandir = @mandir@
166
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
167
oldincludedir = @oldincludedir@
127
prefix = @prefix@
168
prefix = @prefix@
128
program_transform_name = @program_transform_name@
169
program_transform_name = @program_transform_name@
Lines 130-138 Link Here
130
sharedstatedir = @sharedstatedir@
171
sharedstatedir = @sharedstatedir@
131
sysconfdir = @sysconfdir@
172
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
173
target_alias = @target_alias@
133
134
SUBDIRS = . unused
174
SUBDIRS = . unused
135
136
noinst_SCRIPTS = \
175
noinst_SCRIPTS = \
137
	vg_regtest \
176
	vg_regtest \
138
	filter_addresses \
177
	filter_addresses \
Lines 141-241 Link Here
141
	filter_stderr_basic \
180
	filter_stderr_basic \
142
	filter_test_paths
181
	filter_test_paths
143
182
144
145
EXTRA_DIST = $(noinst_SCRIPTS)
183
EXTRA_DIST = $(noinst_SCRIPTS)
146
147
check_PROGRAMS = \
148
	true
149
150
151
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g
184
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g
152
AM_CXXFLAGS = $(AM_CFLAGS)
185
AM_CXXFLAGS = $(AM_CFLAGS)
153
186
154
# generic C ones
187
# generic C ones
155
true_SOURCES = true.c
188
true_SOURCES = true.c
156
subdir = tests
189
cputest_SOURCES = cputest.c
157
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
158
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
159
CONFIG_HEADER = $(top_builddir)/config.h
160
CONFIG_CLEAN_FILES = vg_regtest
161
check_PROGRAMS = true$(EXEEXT)
162
am_true_OBJECTS = true.$(OBJEXT)
163
true_OBJECTS = $(am_true_OBJECTS)
164
true_LDADD = $(LDADD)
165
true_DEPENDENCIES =
166
true_LDFLAGS =
167
SCRIPTS = $(noinst_SCRIPTS)
168
169
170
DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
171
depcomp = $(SHELL) $(top_srcdir)/depcomp
172
am__depfiles_maybe = depfiles
173
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/true.Po
174
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
175
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
176
CCLD = $(CC)
177
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
178
DIST_SOURCES = $(true_SOURCES)
179
180
RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
181
	ps-recursive install-info-recursive uninstall-info-recursive \
182
	all-recursive install-data-recursive install-exec-recursive \
183
	installdirs-recursive install-recursive uninstall-recursive \
184
	check-recursive installcheck-recursive
185
DIST_COMMON = Makefile.am Makefile.in vg_regtest.in
186
DIST_SUBDIRS = $(SUBDIRS)
187
SOURCES = $(true_SOURCES)
188
189
all: all-recursive
190
all: all-recursive
190
191
191
.SUFFIXES:
192
.SUFFIXES:
192
.SUFFIXES: .c .o .obj
193
.SUFFIXES: .c .o .obj
193
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
194
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
195
	@for dep in $?; do \
196
	  case '$(am__configure_deps)' in \
197
	    *$$dep*) \
198
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
199
		&& exit 0; \
200
	      exit 1;; \
201
	  esac; \
202
	done; \
203
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  tests/Makefile'; \
194
	cd $(top_srcdir) && \
204
	cd $(top_srcdir) && \
195
	  $(AUTOMAKE) --gnu  tests/Makefile
205
	  $(AUTOMAKE) --gnu  tests/Makefile
196
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
206
.PRECIOUS: Makefile
197
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
207
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
198
vg_regtest: $(top_builddir)/config.status vg_regtest.in
208
	@case '$?' in \
209
	  *config.status*) \
210
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
211
	  *) \
212
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
213
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
214
	esac;
215
216
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
217
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
218
219
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
220
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
221
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
222
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
223
vg_regtest: $(top_builddir)/config.status $(srcdir)/vg_regtest.in
199
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
224
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
200
225
201
clean-checkPROGRAMS:
226
clean-checkPROGRAMS:
202
	-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
227
	-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
228
cputest$(EXEEXT): $(cputest_OBJECTS) $(cputest_DEPENDENCIES) 
229
	@rm -f cputest$(EXEEXT)
230
	$(LINK) $(cputest_LDFLAGS) $(cputest_OBJECTS) $(cputest_LDADD) $(LIBS)
203
true$(EXEEXT): $(true_OBJECTS) $(true_DEPENDENCIES) 
231
true$(EXEEXT): $(true_OBJECTS) $(true_DEPENDENCIES) 
204
	@rm -f true$(EXEEXT)
232
	@rm -f true$(EXEEXT)
205
	$(LINK) $(true_LDFLAGS) $(true_OBJECTS) $(true_LDADD) $(LIBS)
233
	$(LINK) $(true_LDFLAGS) $(true_OBJECTS) $(true_LDADD) $(LIBS)
206
234
207
mostlyclean-compile:
235
mostlyclean-compile:
208
	-rm -f *.$(OBJEXT) core *.core
236
	-rm -f *.$(OBJEXT)
209
237
210
distclean-compile:
238
distclean-compile:
211
	-rm -f *.tab.c
239
	-rm -f *.tab.c
212
240
241
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cputest.Po@am__quote@
213
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/true.Po@am__quote@
242
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/true.Po@am__quote@
214
243
215
distclean-depend:
216
	-rm -rf ./$(DEPDIR)
217
218
.c.o:
244
.c.o:
219
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
245
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
220
@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
246
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
221
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
222
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
223
@am__fastdepCC_TRUE@	fi
224
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
247
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
225
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
248
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
226
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
249
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
227
@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
250
@am__fastdepCC_FALSE@	$(COMPILE) -c $<
228
251
229
.c.obj:
252
.c.obj:
230
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
253
@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
231
@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
254
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
232
@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
233
@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
234
@am__fastdepCC_TRUE@	fi
235
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
255
@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
236
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
256
@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
237
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
257
@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
238
@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
258
@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
239
uninstall-info-am:
259
uninstall-info-am:
240
260
241
# This directory's subdirectories are mostly independent; you can cd
261
# This directory's subdirectories are mostly independent; you can cd
Lines 297-310 Link Here
297
	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
317
	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
298
	done
318
	done
299
319
300
ETAGS = etags
301
ETAGSFLAGS =
302
303
CTAGS = ctags
304
CTAGSFLAGS =
305
306
tags: TAGS
307
308
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
320
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
309
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
321
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
310
	unique=`for i in $$list; do \
322
	unique=`for i in $$list; do \
Lines 313-318 Link Here
313
	  $(AWK) '    { files[$$0] = 1; } \
325
	  $(AWK) '    { files[$$0] = 1; } \
314
	       END { for (i in files) print i; }'`; \
326
	       END { for (i in files) print i; }'`; \
315
	mkid -fID $$unique
327
	mkid -fID $$unique
328
tags: TAGS
316
329
317
TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
330
TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
318
		$(TAGS_FILES) $(LISP)
331
		$(TAGS_FILES) $(LISP)
Lines 338-344 Link Here
338
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
351
	test -z "$(ETAGS_ARGS)$$tags$$unique" \
339
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
352
	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
340
	     $$tags $$unique
353
	     $$tags $$unique
341
342
ctags: CTAGS
354
ctags: CTAGS
343
CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
355
CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
344
		$(TAGS_FILES) $(LISP)
356
		$(TAGS_FILES) $(LISP)
Lines 361-370 Link Here
361
373
362
distclean-tags:
374
distclean-tags:
363
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
375
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
364
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
365
366
top_distdir = ..
367
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
368
376
369
distdir: $(DISTFILES)
377
distdir: $(DISTFILES)
370
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
378
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 378-384 Link Here
378
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
386
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
379
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
387
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
380
	    dir="/$$dir"; \
388
	    dir="/$$dir"; \
381
	    $(mkinstalldirs) "$(distdir)$$dir"; \
389
	    $(mkdir_p) "$(distdir)$$dir"; \
382
	  else \
390
	  else \
383
	    dir=''; \
391
	    dir=''; \
384
	  fi; \
392
	  fi; \
Lines 395-407 Link Here
395
	done
403
	done
396
	list='$(SUBDIRS)'; for subdir in $$list; do \
404
	list='$(SUBDIRS)'; for subdir in $$list; do \
397
	  if test "$$subdir" = .; then :; else \
405
	  if test "$$subdir" = .; then :; else \
398
	    test -d $(distdir)/$$subdir \
406
	    test -d "$(distdir)/$$subdir" \
399
	    || mkdir $(distdir)/$$subdir \
407
	    || mkdir "$(distdir)/$$subdir" \
400
	    || exit 1; \
408
	    || exit 1; \
401
	    (cd $$subdir && \
409
	    (cd $$subdir && \
402
	      $(MAKE) $(AM_MAKEFLAGS) \
410
	      $(MAKE) $(AM_MAKEFLAGS) \
403
	        top_distdir="$(top_distdir)" \
411
	        top_distdir="../$(top_distdir)" \
404
	        distdir=../$(distdir)/$$subdir \
412
	        distdir="../$(distdir)/$$subdir" \
405
	        distdir) \
413
	        distdir) \
406
	      || exit 1; \
414
	      || exit 1; \
407
	  fi; \
415
	  fi; \
Lines 412-418 Link Here
412
all-am: Makefile $(SCRIPTS)
420
all-am: Makefile $(SCRIPTS)
413
installdirs: installdirs-recursive
421
installdirs: installdirs-recursive
414
installdirs-am:
422
installdirs-am:
415
416
install: install-recursive
423
install: install-recursive
417
install-exec: install-exec-recursive
424
install-exec: install-exec-recursive
418
install-data: install-data-recursive
425
install-data: install-data-recursive
Lines 424-430 Link Here
424
installcheck: installcheck-recursive
431
installcheck: installcheck-recursive
425
install-strip:
432
install-strip:
426
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
433
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
427
	  INSTALL_STRIP_FLAG=-s \
434
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
428
	  `test -z '$(STRIP)' || \
435
	  `test -z '$(STRIP)' || \
429
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
436
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
430
mostlyclean-generic:
437
mostlyclean-generic:
Lines 432-438 Link Here
432
clean-generic:
439
clean-generic:
433
440
434
distclean-generic:
441
distclean-generic:
435
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
442
	-rm -f $(CONFIG_CLEAN_FILES)
436
443
437
maintainer-clean-generic:
444
maintainer-clean-generic:
438
	@echo "This command is intended for maintainers to use"
445
	@echo "This command is intended for maintainers to use"
Lines 442-455 Link Here
442
clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am
449
clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am
443
450
444
distclean: distclean-recursive
451
distclean: distclean-recursive
445
452
	-rm -rf ./$(DEPDIR)
446
distclean-am: clean-am distclean-compile distclean-depend \
453
	-rm -f Makefile
447
	distclean-generic distclean-tags
454
distclean-am: clean-am distclean-compile distclean-generic \
455
	distclean-tags
448
456
449
dvi: dvi-recursive
457
dvi: dvi-recursive
450
458
451
dvi-am:
459
dvi-am:
452
460
461
html: html-recursive
462
453
info: info-recursive
463
info: info-recursive
454
464
455
info-am:
465
info-am:
Lines 465-471 Link Here
465
installcheck-am:
475
installcheck-am:
466
476
467
maintainer-clean: maintainer-clean-recursive
477
maintainer-clean: maintainer-clean-recursive
468
478
	-rm -rf ./$(DEPDIR)
479
	-rm -f Makefile
469
maintainer-clean-am: distclean-am maintainer-clean-generic
480
maintainer-clean-am: distclean-am maintainer-clean-generic
470
481
471
mostlyclean: mostlyclean-recursive
482
mostlyclean: mostlyclean-recursive
Lines 484-505 Link Here
484
495
485
uninstall-info: uninstall-info-recursive
496
uninstall-info: uninstall-info-recursive
486
497
487
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
498
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
488
	clean-checkPROGRAMS clean-generic clean-recursive ctags \
499
	clean clean-checkPROGRAMS clean-generic clean-recursive ctags \
489
	ctags-recursive distclean distclean-compile distclean-depend \
500
	ctags-recursive distclean distclean-compile distclean-generic \
490
	distclean-generic distclean-recursive distclean-tags distdir \
501
	distclean-recursive distclean-tags distdir dvi dvi-am html \
491
	dvi dvi-am dvi-recursive info info-am info-recursive install \
502
	html-am info info-am install install-am install-data \
492
	install-am install-data install-data-am install-data-recursive \
503
	install-data-am install-exec install-exec-am install-info \
493
	install-exec install-exec-am install-exec-recursive \
504
	install-info-am install-man install-strip installcheck \
494
	install-info install-info-am install-info-recursive install-man \
505
	installcheck-am installdirs installdirs-am maintainer-clean \
495
	install-recursive install-strip installcheck installcheck-am \
506
	maintainer-clean-generic maintainer-clean-recursive \
496
	installdirs installdirs-am installdirs-recursive \
507
	mostlyclean mostlyclean-compile mostlyclean-generic \
497
	maintainer-clean maintainer-clean-generic \
508
	mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
498
	maintainer-clean-recursive mostlyclean mostlyclean-compile \
509
	uninstall uninstall-am uninstall-info-am
499
	mostlyclean-generic mostlyclean-recursive pdf pdf-am \
500
	pdf-recursive ps ps-am ps-recursive tags tags-recursive \
501
	uninstall uninstall-am uninstall-info-am \
502
	uninstall-info-recursive uninstall-recursive
503
510
504
# Tell versions [3.59,3.63) of GNU make to not export all variables.
511
# Tell versions [3.59,3.63) of GNU make to not export all variables.
505
# Otherwise a system limit (for SysV at least) may be exceeded.
512
# Otherwise a system limit (for SysV at least) may be exceeded.
(-)valgrind-2.1.0/tests/cachesim/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)valgrind-2.1.0/tests/cachesim/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/tests/cachesim
(-)valgrind-2.1.0/tests/cachesim/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/tests/corecheck/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)valgrind-2.1.0/tests/corecheck/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/tests/corecheck
(-)valgrind-2.1.0/tests/corecheck/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/tests/cputest.c (+58 lines)
Line 0 Link Here
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
5
static __inline__ void cpuid(unsigned int n,
6
                             unsigned int *a, unsigned int *b,
7
                             unsigned int *c, unsigned int *d)
8
{
9
   __asm__ __volatile__ (
10
      "cpuid"
11
      : "=a" (*a), "=b" (*b), "=c" (*c), "=d" (*d)      /* output */
12
      : "0" (n)         /* input */
13
   );
14
}
15
16
int main(int argc, char **argv)
17
{
18
   unsigned int level = 0;
19
   unsigned int mask = 0;
20
   unsigned int a;
21
   unsigned int b;
22
   unsigned int c;
23
   unsigned int d;
24
25
   if ( argc == 2 ) {
26
      if ( strcmp( argv[1], "cmov" ) == 0 ) {
27
        level = 1;
28
        mask = 1 << 15;
29
      } else if ( strcmp( argv[1], "mmx" ) == 0 ) {
30
        level = 1;
31
        mask = 1 << 23;
32
      } else if ( strcmp( argv[1], "mmxext" ) == 0 ) {
33
        level = 0x80000001;
34
        mask = 1 << 22;
35
      } else if ( strcmp( argv[1], "sse" ) == 0 ) {
36
        level = 1;
37
        mask = 1 << 25;
38
      } else if ( strcmp( argv[1], "sse2" ) == 0 ) {
39
        level = 1;
40
        mask = 1 << 26;
41
      }
42
   }
43
44
   if ( level == 0 || mask == 0 ) {
45
      fprintf( stderr, "usage: cputest [cmov|mmx|mmxext|sse|sse2]\n" );
46
      exit( 1 );
47
   }
48
   
49
   cpuid( level & 0x80000000, &a, &b, &c, &d );
50
51
   if ( a >= level ) {
52
      cpuid( level, &a, &b, &c, &d );
53
54
      if ( ( d & mask ) != 0 ) exit( 0 );
55
   }
56
57
   exit( 1 );
58
}
(-)valgrind-2.1.0/tests/filter_addresses (-1 / +1 lines)
Lines 1-4 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
2
3
sed "s/0x[0-9A-Fa-f]\+/0x......../g"
3
sed "s/0x[0-9A-Fa-f]*/0x......../g"
4
4
(-)valgrind-2.1.0/tests/filter_stderr_basic (-6 / +10 lines)
Lines 4-27 Link Here
4
# startup stuff and pid numbers.
4
# startup stuff and pid numbers.
5
5
6
# Remove ==pid== and --pid-- and ++pid++ and **pid** strings 
6
# Remove ==pid== and --pid-- and ++pid++ and **pid** strings 
7
sed "s/\(==\|--\|\+\+\|\*\*\)[0-9]\{1,5\}\1 //"                            |
7
sed "s/\(==\|--\|\+\+\|\*\*\)[0-9]\{1,5\}\1 //"             |
8
8
9
# Remove "<name>, a <description> for x86-linux." line and the following
9
# Remove "<name>, a <description> for x86-linux." line and the following
10
# copyright notice line.  Works for skin and core intro lines.
10
# copyright notice line.  Works for tool and core intro lines.
11
sed "/^.*, .* for x86-linux\./ , /./ d"                                | 
11
sed "/^.*, .* for x86-linux\./ , /./ d"                                | 
12
12
13
# Remove other introductory lines
13
# Remove other introductory lines
14
sed "/Estimated CPU clock rate is [0-9]\+ MHz/d"                       |
14
sed "/Estimated CPU clock rate is [0-9]* MHz/d"                       |
15
sed "/For more details, rerun with: -v/d"                              |
15
sed "/For more details, rerun with: -v/d"                              |
16
16
17
# Anonymise line numbers in vg_replace_malloc.c
17
# Anonymise line numbers in vg_replace_malloc.c
18
sed "s/vg_replace_malloc.c:[0-9]\+/vg_replace_malloc.c:.../"           |
18
sed "s/vg_replace_malloc.c:[0-9]*/vg_replace_malloc.c:.../"           |
19
19
20
# Anonymise vg_intercept lines
20
# Anonymise vg_intercept lines
21
sed "s/vg_intercept.c:[0-9]\+/vg_intercept.c:.../"                     |
21
sed "s/vg_intercept.c:[0-9]*/vg_intercept.c:.../"                     |
22
22
23
# Anonymise vg_libpthread lines
23
# Anonymise vg_libpthread lines
24
sed "s/vg_libpthread.c:[0-9]\+/vg_libpthread.c:.../"                   |
24
sed "s/vg_libpthread.c:[0-9]*/vg_libpthread.c:.../"                   |
25
26
# Hide suppressed error counts
27
sed "s/^\(ERROR SUMMARY[^(]*(suppressed: \)[0-9]*\( from \)[0-9]*)$/\10\20)/" |
28
25
29
26
# Reduce some libc incompatibility
30
# Reduce some libc incompatibility
27
sed "s/ __getsockname / getsockname /"                                 |
31
sed "s/ __getsockname / getsockname /"                                 |
(-)valgrind-2.1.0/tests/memcheck/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)valgrind-2.1.0/tests/memcheck/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/tests/memcheck
(-)valgrind-2.1.0/tests/memcheck/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/tests/none/CVS/Entries (+1 lines)
Line 0 Link Here
1
D
(-)valgrind-2.1.0/tests/none/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/tests/none
(-)valgrind-2.1.0/tests/none/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/tests/unused/.cvsignore (+2 lines)
Line 0 Link Here
1
Makefile.in
2
Makefile
(-)valgrind-2.1.0/tests/unused/CVS/Entries (+21 lines)
Line 0 Link Here
1
/.cvsignore/1.1/Tue Oct  1 11:50:39 2002//
2
/Makefile.am/1.2/Sat Oct  5 16:19:56 2002//
3
/blocked_syscall.c/1.1/Fri Oct  4 14:16:38 2002//
4
/oneparam.c/1.2/Mon Sep 23 09:36:25 2002//
5
/pth_cancel1.c/1.2/Mon Sep 23 09:36:25 2002//
6
/pth_pause.c/1.2/Mon Sep 23 09:36:25 2002//
7
/pth_semaphore1.c/1.2/Mon Sep 23 09:36:25 2002//
8
/pth_signal1.c/1.2/Mon Sep 23 09:36:25 2002//
9
/pth_signal2.c/1.2/Mon Sep 23 09:36:25 2002//
10
/pth_signal_gober.c/1.2/Mon Sep 23 09:36:25 2002//
11
/pth_sigpending.c/1.2/Mon Sep 23 09:36:25 2002//
12
/pth_simple_mutex.c/1.2/Mon Sep 23 09:36:25 2002//
13
/pth_simple_threads.c/1.2/Mon Sep 23 09:36:25 2002//
14
/pth_threadpool.c/1.3/Fri Jul  4 16:18:15 2003//
15
/pth_yield.c/1.2/Mon Sep 23 09:36:25 2002//
16
/signal1.c/1.2/Mon Sep 23 09:36:25 2002//
17
/signal3.c/1.2/Mon Sep 23 09:36:25 2002//
18
/sigwait_all.c/1.2/Mon Sep 23 09:36:25 2002//
19
/twoparams.c/1.2/Mon Sep 23 09:36:25 2002//
20
/twoparams.s/1.2/Mon Sep 23 09:36:25 2002//
21
D
(-)valgrind-2.1.0/tests/unused/CVS/Repository (+1 lines)
Line 0 Link Here
1
valgrind/tests/unused
(-)valgrind-2.1.0/tests/unused/CVS/Root (+1 lines)
Line 0 Link Here
1
:pserver:anonymous@anoncvs.kde.org:/home/kde
(-)valgrind-2.1.0/tests/unused/Makefile.in (-28 / +53 lines)
Lines 1-8 Link Here
1
# Makefile.in generated by automake 1.7.6 from Makefile.am.
1
# Makefile.in generated by automake 1.8.2 from Makefile.am.
2
# @configure_input@
2
# @configure_input@
3
3
4
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
# Free Software Foundation, Inc.
5
# 2003, 2004  Free Software Foundation, Inc.
6
# This Makefile.in is free software; the Free Software Foundation
6
# This Makefile.in is free software; the Free Software Foundation
7
# gives unlimited permission to copy and/or distribute it,
7
# gives unlimited permission to copy and/or distribute it,
8
# with or without modifications, as long as this notice is preserved.
8
# with or without modifications, as long as this notice is preserved.
Lines 13-19 Link Here
13
# PARTICULAR PURPOSE.
13
# PARTICULAR PURPOSE.
14
14
15
@SET_MAKE@
15
@SET_MAKE@
16
17
srcdir = @srcdir@
16
srcdir = @srcdir@
18
top_srcdir = @top_srcdir@
17
top_srcdir = @top_srcdir@
19
VPATH = @srcdir@
18
VPATH = @srcdir@
Lines 21-27 Link Here
21
pkglibdir = $(libdir)/@PACKAGE@
20
pkglibdir = $(libdir)/@PACKAGE@
22
pkgincludedir = $(includedir)/@PACKAGE@
21
pkgincludedir = $(includedir)/@PACKAGE@
23
top_builddir = ../..
22
top_builddir = ../..
24
25
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
23
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
26
INSTALL = @INSTALL@
24
INSTALL = @INSTALL@
27
install_sh_DATA = $(install_sh) -c -m 644
25
install_sh_DATA = $(install_sh) -c -m 644
Lines 36-41 Link Here
36
PRE_UNINSTALL = :
34
PRE_UNINSTALL = :
37
POST_UNINSTALL = :
35
POST_UNINSTALL = :
38
host_triplet = @host@
36
host_triplet = @host@
37
subdir = tests/unused
38
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
39
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
40
am__aclocal_m4_deps = $(top_srcdir)/configure.in
41
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
42
	$(ACLOCAL_M4)
43
mkinstalldirs = $(mkdir_p)
44
CONFIG_HEADER = $(top_builddir)/config.h
45
CONFIG_CLEAN_FILES =
46
SOURCES =
47
DIST_SOURCES =
48
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
39
ACLOCAL = @ACLOCAL@
49
ACLOCAL = @ACLOCAL@
40
AMDEP_FALSE = @AMDEP_FALSE@
50
AMDEP_FALSE = @AMDEP_FALSE@
41
AMDEP_TRUE = @AMDEP_TRUE@
51
AMDEP_TRUE = @AMDEP_TRUE@
Lines 92-97 Link Here
92
SHELL = @SHELL@
102
SHELL = @SHELL@
93
STRIP = @STRIP@
103
STRIP = @STRIP@
94
VERSION = @VERSION@
104
VERSION = @VERSION@
105
VG_PLATFORM = @VG_PLATFORM@
95
ac_ct_CC = @ac_ct_CC@
106
ac_ct_CC = @ac_ct_CC@
96
ac_ct_CXX = @ac_ct_CXX@
107
ac_ct_CXX = @ac_ct_CXX@
97
ac_ct_RANLIB = @ac_ct_RANLIB@
108
ac_ct_RANLIB = @ac_ct_RANLIB@
Lines 123-128 Link Here
123
libexecdir = @libexecdir@
134
libexecdir = @libexecdir@
124
localstatedir = @localstatedir@
135
localstatedir = @localstatedir@
125
mandir = @mandir@
136
mandir = @mandir@
137
mkdir_p = @mkdir_p@
126
oldincludedir = @oldincludedir@
138
oldincludedir = @oldincludedir@
127
prefix = @prefix@
139
prefix = @prefix@
128
program_transform_name = @program_transform_name@
140
program_transform_name = @program_transform_name@
Lines 130-136 Link Here
130
sharedstatedir = @sharedstatedir@
142
sharedstatedir = @sharedstatedir@
131
sysconfdir = @sysconfdir@
143
sysconfdir = @sysconfdir@
132
target_alias = @target_alias@
144
target_alias = @target_alias@
133
134
EXTRA_DIST = \
145
EXTRA_DIST = \
135
	oneparam.c		\
146
	oneparam.c		\
136
	pth_signal2.c 		\
147
	pth_signal2.c 		\
Lines 151-171 Link Here
151
	twoparams.s 		\
162
	twoparams.s 		\
152
	blocked_syscall.c
163
	blocked_syscall.c
153
164
154
subdir = tests/unused
155
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
156
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
157
CONFIG_HEADER = $(top_builddir)/config.h
158
CONFIG_CLEAN_FILES =
159
DIST_SOURCES =
160
DIST_COMMON = Makefile.am Makefile.in
161
all: all-am
165
all: all-am
162
166
163
.SUFFIXES:
167
.SUFFIXES:
164
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
168
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
169
	@for dep in $?; do \
170
	  case '$(am__configure_deps)' in \
171
	    *$$dep*) \
172
	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
173
		&& exit 0; \
174
	      exit 1;; \
175
	  esac; \
176
	done; \
177
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  tests/unused/Makefile'; \
165
	cd $(top_srcdir) && \
178
	cd $(top_srcdir) && \
166
	  $(AUTOMAKE) --gnu  tests/unused/Makefile
179
	  $(AUTOMAKE) --gnu  tests/unused/Makefile
167
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in  $(top_builddir)/config.status
180
.PRECIOUS: Makefile
168
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
181
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
182
	@case '$?' in \
183
	  *config.status*) \
184
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
185
	  *) \
186
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
187
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
188
	esac;
189
190
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
191
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
192
193
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
194
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
195
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
196
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
169
uninstall-info-am:
197
uninstall-info-am:
170
tags: TAGS
198
tags: TAGS
171
TAGS:
199
TAGS:
Lines 173-182 Link Here
173
ctags: CTAGS
201
ctags: CTAGS
174
CTAGS:
202
CTAGS:
175
203
176
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
177
178
top_distdir = ../..
179
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
180
204
181
distdir: $(DISTFILES)
205
distdir: $(DISTFILES)
182
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
206
	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
Lines 190-196 Link Here
190
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
214
	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
191
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
215
	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
192
	    dir="/$$dir"; \
216
	    dir="/$$dir"; \
193
	    $(mkinstalldirs) "$(distdir)$$dir"; \
217
	    $(mkdir_p) "$(distdir)$$dir"; \
194
	  else \
218
	  else \
195
	    dir=''; \
219
	    dir=''; \
196
	  fi; \
220
	  fi; \
Lines 208-214 Link Here
208
check-am: all-am
232
check-am: all-am
209
check: check-am
233
check: check-am
210
all-am: Makefile
234
all-am: Makefile
211
212
installdirs:
235
installdirs:
213
install: install-am
236
install: install-am
214
install-exec: install-exec-am
237
install-exec: install-exec-am
Lines 221-227 Link Here
221
installcheck: installcheck-am
244
installcheck: installcheck-am
222
install-strip:
245
install-strip:
223
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
246
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
224
	  INSTALL_STRIP_FLAG=-s \
247
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
225
	  `test -z '$(STRIP)' || \
248
	  `test -z '$(STRIP)' || \
226
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
249
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
227
mostlyclean-generic:
250
mostlyclean-generic:
Lines 229-235 Link Here
229
clean-generic:
252
clean-generic:
230
253
231
distclean-generic:
254
distclean-generic:
232
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
255
	-rm -f $(CONFIG_CLEAN_FILES)
233
256
234
maintainer-clean-generic:
257
maintainer-clean-generic:
235
	@echo "This command is intended for maintainers to use"
258
	@echo "This command is intended for maintainers to use"
Lines 239-251 Link Here
239
clean-am: clean-generic mostlyclean-am
262
clean-am: clean-generic mostlyclean-am
240
263
241
distclean: distclean-am
264
distclean: distclean-am
242
265
	-rm -f Makefile
243
distclean-am: clean-am distclean-generic
266
distclean-am: clean-am distclean-generic
244
267
245
dvi: dvi-am
268
dvi: dvi-am
246
269
247
dvi-am:
270
dvi-am:
248
271
272
html: html-am
273
249
info: info-am
274
info: info-am
250
275
251
info-am:
276
info-am:
Lines 261-267 Link Here
261
installcheck-am:
286
installcheck-am:
262
287
263
maintainer-clean: maintainer-clean-am
288
maintainer-clean: maintainer-clean-am
264
289
	-rm -f Makefile
265
maintainer-clean-am: distclean-am maintainer-clean-generic
290
maintainer-clean-am: distclean-am maintainer-clean-generic
266
291
267
mostlyclean: mostlyclean-am
292
mostlyclean: mostlyclean-am
Lines 279-286 Link Here
279
uninstall-am: uninstall-info-am
304
uninstall-am: uninstall-info-am
280
305
281
.PHONY: all all-am check check-am clean clean-generic distclean \
306
.PHONY: all all-am check check-am clean clean-generic distclean \
282
	distclean-generic distdir dvi dvi-am info info-am install \
307
	distclean-generic distdir dvi dvi-am html html-am info info-am \
283
	install-am install-data install-data-am install-exec \
308
	install install-am install-data install-data-am install-exec \
284
	install-exec-am install-info install-info-am install-man \
309
	install-exec-am install-info install-info-am install-man \
285
	install-strip installcheck installcheck-am installdirs \
310
	install-strip installcheck installcheck-am installdirs \
286
	maintainer-clean maintainer-clean-generic mostlyclean \
311
	maintainer-clean maintainer-clean-generic mostlyclean \
(-)valgrind-2.1.0/tests/vg_regtest (-360 lines)
Lines 1-360 Link Here
1
#! /usr/bin/perl
2
##--------------------------------------------------------------------##
3
##--- Valgrind regression testing script                vg_regtest ---##
4
##--------------------------------------------------------------------##
5
6
#  This file is part of Valgrind, an extensible x86 protected-mode
7
#  emulator for monitoring program execution on x86-Unixes.
8
#
9
#  Copyright (C) 2003 Nicholas Nethercote
10
#     njn25@cam.ac.uk
11
#
12
#  This program is free software; you can redistribute it and/or
13
#  modify it under the terms of the GNU General Public License as
14
#  published by the Free Software Foundation; either version 2 of the
15
#  License, or (at your option) any later version.
16
#
17
#  This program is distributed in the hope that it will be useful, but
18
#  WITHOUT ANY WARRANTY; without even the implied warranty of
19
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
#  General Public License for more details.
21
#
22
#  You should have received a copy of the GNU General Public License
23
#  along with this program; if not, write to the Free Software
24
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25
#  02111-1307, USA.
26
#
27
#  The GNU General Public License is contained in the file COPYING.
28
29
#----------------------------------------------------------------------------
30
# usage: vg_regtest [options] <dirs | files>
31
#
32
# Options:
33
#   --all:      run tests in all subdirs
34
#   --valgrind: valgrind to use.  Default is one built from this source tree.
35
#
36
# The easiest way is to run all tests in valgrind/ with (assuming you installed
37
# in $PREFIX):
38
#
39
#   $PREFIX/bin/vg_regtest --all
40
#
41
# You can specify individual files to test, or whole directories, or both.
42
# Directories are traversed recursively, except for ones named, for example, 
43
# CVS/ or docs/.
44
#
45
# Each test is defined in a file <test>.vgtest, containing one or more of the
46
# following lines, in any order:
47
#   - prog:   <prog to run>                         (compulsory)
48
#   - args:   <args for prog>                       (default: none)
49
#   - vgopts: <Valgrind options>                    (default: none)
50
#   - stdout_filter: <filter to run stdout through> (default: none)
51
#   - stderr_filter: <filter to run stderr through> (default: ./filter_stderr)
52
#
53
# Note that filters are necessary for stderr results to filter out things that
54
# always change, eg. process id numbers.
55
#
56
# Expected stdout (filtered) is kept in <test>.stdout.exp.  It can be missing
57
# if it would be empty.  Expected stderr (filtered) is kept in
58
# <test>.stderr.exp. 
59
#
60
# If results don't match, the output can be found in <test>.std<strm>.out,
61
# and the diff between expected and actual in <test>.std<strm>.diff.
62
#
63
# Notes on adding regression tests for a new tool are in
64
# coregrind/docs/coregrind_tools.html.
65
#----------------------------------------------------------------------------
66
67
use warnings;
68
use strict;
69
70
#----------------------------------------------------------------------------
71
# Global vars
72
#----------------------------------------------------------------------------
73
my $usage="vg_regtest [--all, --valgrind]\n";
74
75
my $tmp="vg_regtest.tmp.$$";
76
77
# Test variables
78
my $vgopts;             # valgrind options
79
my $prog;               # test prog
80
my $args;               # test prog args
81
my $stdout_filter;      # filter program to run stdout results file through
82
my $stderr_filter;      # filter program to run stderr results file through
83
84
my @failures;           # List of failed tests
85
86
my $num_tests_done      = 0;
87
my %num_failures        = (stderr => 0, stdout => 0);
88
89
# Default valgrind to use is this build tree's (uninstalled) one
90
my $prefix="/home/sewardj/VgHEAD/valgrind/Inst";
91
my $exec_prefix="${prefix}";
92
my $valgrind = "./coregrind/valgrind";
93
94
chomp(my $tests_dir = `pwd`);
95
96
# default filter is the one named "filter_stderr" in the test's directory
97
my $default_stderr_filter = "filter_stderr";
98
99
100
#----------------------------------------------------------------------------
101
# Process command line, setup
102
#----------------------------------------------------------------------------
103
104
# If $prog is a relative path, it prepends $dir to it.  Useful for two reasons:
105
#
106
# 1. Can prepend "." onto programs to avoid trouble with users who don't have
107
#    "." in their path (by making $dir = ".")
108
# 2. Can prepend the current dir to make the command absolute to avoid
109
#    subsequent trouble when we change directories.
110
#
111
# Also checks the program exists and is executable.
112
sub validate_program ($$$) 
113
{
114
    my ($dir, $prog, $must_be_executable) = @_;
115
116
    # If absolute path, leave it alone.  If relative, make it
117
    # absolute -- by prepending current dir -- so we can change
118
    # dirs and still use it.
119
    $prog = "$dir/$prog" if ($prog !~ /^\//);
120
    (-f $prog) or die "vg_regtest: `$prog' not found or not a file ($dir)\n";
121
    if ($must_be_executable) { 
122
       (-x $prog) or die "vg_regtest: `$prog' not executable ($dir)\n";
123
    }
124
125
    return $prog;
126
}
127
128
sub process_command_line() 
129
{
130
    my $alldirs = 0;
131
    my @fs;
132
    
133
    for my $arg (@ARGV) {
134
        if ($arg =~ /^-/) {
135
            if      ($arg =~ /^--all$/) {
136
                $alldirs = 1;
137
            } elsif ($arg =~ /^--valgrind=(.*)$/) {
138
                $valgrind = $1;
139
            } else {
140
                die $usage;
141
            }
142
        } else {
143
            push(@fs, $arg);
144
        }
145
    }
146
    $valgrind = validate_program($tests_dir, $valgrind, 0);
147
148
    if ($alldirs) {
149
        @fs = ();
150
        foreach my $f (glob "*") {
151
            push(@fs, $f) if (-d $f);
152
        }
153
    }
154
155
    (0 != @fs) or die "No test files or directories specified\n";
156
157
    return @fs;
158
}
159
160
#----------------------------------------------------------------------------
161
# Read a .vgtest file
162
#----------------------------------------------------------------------------
163
sub read_vgtest_file($)
164
{
165
    my ($f) = @_;
166
167
    # Defaults.
168
    ($vgopts, $prog, $args, $stdout_filter, $stderr_filter) = 
169
        ("", undef, "", undef, undef);
170
171
    # Every test directory must have a "filter_stderr"
172
    $stderr_filter = validate_program(".", $default_stderr_filter, 1);
173
174
    open(INPUTFILE, "< $f") || die "File $f not openable\n";
175
176
    while (my $line = <INPUTFILE>) {
177
        if      ($line =~ /^\s*vgopts:\s*(.*)$/) {
178
            $vgopts = $1;
179
        } elsif ($line =~ /^\s*prog:\s*(.*)$/) {
180
            $prog = validate_program(".", $1, 1);
181
        } elsif ($line =~ /^\s*args:\s*(.*)$/) {
182
            $args = $1;
183
        } elsif ($line =~ /^\s*stdout_filter:\s*(.*)$/) {
184
            $stdout_filter = validate_program(".", $1, 1);
185
        } elsif ($line =~ /^\s*stderr_filter:\s*(.*)$/) {
186
            $stderr_filter = validate_program(".", $1, 1);
187
        } else {
188
            die "Bad line in $f: $line\n";
189
        }
190
    }
191
    close(INPUTFILE);
192
193
    if (!defined $prog) {
194
        die "no `prog:' line in `$f'\n";
195
    }
196
}
197
198
#----------------------------------------------------------------------------
199
# Do one test
200
#----------------------------------------------------------------------------
201
# Since most of the program time is spent in system() calls, need this to
202
# propagate a Ctrl-C enabling us to quit.
203
sub mysystem($) 
204
{
205
    (system($_[0]) != 2) or exit 1;      # 2 is SIGINT
206
}
207
208
# from a directory name like "/foo/cachesim/tests/" determine the tool name
209
sub determine_tool()
210
{
211
    my $dir = `pwd`;
212
    $dir =~ /.*\/([^\/]+)\/tests.*/;   # foo/tool_name/tests/foo
213
    return $1;
214
}
215
216
sub do_one_test($$) 
217
{
218
    my ($dir, $vgtest) = @_;
219
    $vgtest =~ /^(.*)\.vgtest/;
220
    my $name = $1;
221
    my $fullname = "$dir/$name"; 
222
223
    read_vgtest_file($vgtest);
224
225
    printf("%-16s valgrind $vgopts $prog $args\n", "$name:");
226
227
    # Pass the appropriate --tool option for the directory (can be overridden
228
    # by an "args:" or "args.dev:" line, though).  
229
    # Also, because the default valgrind is coregrind/valgrind which isn't
230
    # executable, prepend `sh'.
231
    my $tool=determine_tool();
232
    mysystem("sh $valgrind --tool=$tool --in-place=$tests_dir $vgopts $prog $args > $name.stdout.out 2> $name.stderr.out");
233
234
    if (defined $stdout_filter) {
235
        mysystem("$stdout_filter < $name.stdout.out > $tmp");
236
        rename($tmp, "$name.stdout.out");
237
    }
238
239
    mysystem("$stderr_filter < $name.stderr.out > $tmp");
240
    rename($tmp, "$name.stderr.out");
241
242
    # If stdout expected empty, .exp file might be missing so diff with 
243
    # /dev/null
244
    my $stdout_exp = ( -r "$name.stdout.exp" 
245
                     ? "$name.stdout.exp" 
246
                     : "/dev/null" );
247
248
    my $stderr_exp = "$name.stderr.exp";
249
    (-r $stderr_exp) or die "Could not read `$stderr_exp'\n";
250
251
    mysystem("diff -C0 $stdout_exp $name.stdout.out > $name.stdout.diff");
252
    mysystem("diff -C0 $stderr_exp $name.stderr.out > $name.stderr.diff");
253
254
    for my $ext ("stdout", "stderr") {
255
        if (-s "$name.$ext.diff") {
256
            print "*** $name failed ($ext) ***\n";
257
            push(@failures, sprintf("%-40s ($ext)", "$fullname"));
258
            $num_failures{$ext}++;
259
        } else {
260
            unlink("$name.$ext.out", "$name.$ext.diff");
261
        }
262
    }
263
    $num_tests_done++;
264
}
265
266
#----------------------------------------------------------------------------
267
# Test one directory (and any subdirs)
268
#----------------------------------------------------------------------------
269
sub test_one_dir($$);    # forward declaration
270
271
sub test_one_dir($$) 
272
{
273
    my ($dir, $prev_dirs) = @_;
274
    $dir =~ s/\/$//;    # trim a trailing '/'
275
276
    # ignore dirs into which we should not recurse
277
    if ($dir =~ /^(BitKeeper|CVS|SCCS|docs|doc)$/) { return; }
278
279
    chdir($dir) or die "Could not change into $dir\n";
280
281
    # Nb: Don't prepend a '/' to the base directory
282
    my $full_dir = $prev_dirs . ($prev_dirs eq "" ? "" : "/") . $dir;
283
    my $dashes = "-" x (50 - length $full_dir);
284
285
    my @fs = glob "*";
286
    my @vgtests = grep { $_ =~ /\.vgtest$/ } @fs;
287
    my $found_tests = (0 != (grep { $_ =~ /\.vgtest$/ } @fs));
288
289
    if ($found_tests) {
290
        print "-- Running  tests in $full_dir $dashes\n";
291
    }
292
    foreach my $f (@fs) {
293
        if (-d $f) {
294
            test_one_dir($f, $full_dir);
295
        } elsif ($f =~ /\.vgtest$/) {
296
            do_one_test($full_dir, $f);
297
        }
298
    }
299
    if ($found_tests) {
300
        print "-- Finished tests in $full_dir $dashes\n";
301
    }
302
303
    chdir("..");
304
}
305
306
#----------------------------------------------------------------------------
307
# Summarise results
308
#----------------------------------------------------------------------------
309
sub plural($)
310
{
311
   return ( $_[0] == 1 ? "" : "s" );
312
}
313
314
sub summarise_results 
315
{
316
    my $x = ( $num_tests_done == 1 ? "test" : "tests" );
317
    
318
    printf("\n== %d test%s, %d stderr failure%s, %d stdout failure%s =================\n", 
319
           $num_tests_done, plural($num_tests_done),
320
           $num_failures{"stderr"}, plural($num_failures{"stderr"}),
321
           $num_failures{"stdout"}, plural($num_failures{"stdout"}));
322
323
    foreach my $failure (@failures) {
324
        print "$failure\n";
325
    }
326
    print "\n";
327
}
328
329
#----------------------------------------------------------------------------
330
# main(), sort of
331
#----------------------------------------------------------------------------
332
333
# nuke VALGRIND_OPTS
334
$ENV{"VALGRIND_OPTS"} = "";
335
336
my @fs = process_command_line();
337
foreach my $f (@fs) {
338
    if (-d $f) {
339
        test_one_dir($f, "");
340
    } else { 
341
        # Allow the .vgtest suffix to be given or omitted
342
        if ($f =~ /.vgtest$/ && -r $f) {
343
            # do nothing
344
        } elsif (-r "$f.vgtest") {
345
            $f = "$f.vgtest";
346
        } else {
347
            die "`$f' neither a directory nor a readable test file/name\n"
348
        }
349
        my $dir  = `dirname  $f`;   chomp $dir;
350
        my $file = `basename $f`;   chomp $file;
351
        chdir($dir) or die "Could not change into $dir\n";
352
        do_one_test($dir, $file);
353
        chdir($tests_dir);
354
    }
355
}
356
summarise_results();
357
358
##--------------------------------------------------------------------##
359
##--- end                                               vg_regtest ---##
360
##--------------------------------------------------------------------##
(-)valgrind-2.1.0/tests/vg_regtest.in (-5 / +11 lines)
Lines 49-54 Link Here
49
#   - vgopts: <Valgrind options>                    (default: none)
49
#   - vgopts: <Valgrind options>                    (default: none)
50
#   - stdout_filter: <filter to run stdout through> (default: none)
50
#   - stdout_filter: <filter to run stdout through> (default: none)
51
#   - stderr_filter: <filter to run stderr through> (default: ./filter_stderr)
51
#   - stderr_filter: <filter to run stderr through> (default: ./filter_stderr)
52
#   - cpu_test: <cpu feature required for test>     (default: none)
52
#
53
#
53
# Note that filters are necessary for stderr results to filter out things that
54
# Note that filters are necessary for stderr results to filter out things that
54
# always change, eg. process id numbers.
55
# always change, eg. process id numbers.
Lines 80-85 Link Here
80
my $args;               # test prog args
81
my $args;               # test prog args
81
my $stdout_filter;      # filter program to run stdout results file through
82
my $stdout_filter;      # filter program to run stdout results file through
82
my $stderr_filter;      # filter program to run stderr results file through
83
my $stderr_filter;      # filter program to run stderr results file through
84
my $cpu_test;           # cpu feature to check for before running test
83
85
84
my @failures;           # List of failed tests
86
my @failures;           # List of failed tests
85
87
Lines 165-172 Link Here
165
    my ($f) = @_;
167
    my ($f) = @_;
166
168
167
    # Defaults.
169
    # Defaults.
168
    ($vgopts, $prog, $args, $stdout_filter, $stderr_filter) = 
170
    ($vgopts, $prog, $args, $stdout_filter, $stderr_filter, $cpu_test) = 
169
        ("", undef, "", undef, undef);
171
        ("", undef, "", undef, undef, undef);
170
172
171
    # Every test directory must have a "filter_stderr"
173
    # Every test directory must have a "filter_stderr"
172
    $stderr_filter = validate_program(".", $default_stderr_filter, 1);
174
    $stderr_filter = validate_program(".", $default_stderr_filter, 1);
Lines 184-189 Link Here
184
            $stdout_filter = validate_program(".", $1, 1);
186
            $stdout_filter = validate_program(".", $1, 1);
185
        } elsif ($line =~ /^\s*stderr_filter:\s*(.*)$/) {
187
        } elsif ($line =~ /^\s*stderr_filter:\s*(.*)$/) {
186
            $stderr_filter = validate_program(".", $1, 1);
188
            $stderr_filter = validate_program(".", $1, 1);
189
        } elsif ($line =~ /^\s*cpu_test:\s*(.*)$/) {
190
            $cpu_test = $1;
187
        } else {
191
        } else {
188
            die "Bad line in $f: $line\n";
192
            die "Bad line in $f: $line\n";
189
        }
193
        }
Lines 222-235 Link Here
222
226
223
    read_vgtest_file($vgtest);
227
    read_vgtest_file($vgtest);
224
228
229
    if (defined $cpu_test) {
230
        return unless system("../../tests/cputest $cpu_test") == 0;
231
    }
232
225
    printf("%-16s valgrind $vgopts $prog $args\n", "$name:");
233
    printf("%-16s valgrind $vgopts $prog $args\n", "$name:");
226
234
227
    # Pass the appropriate --tool option for the directory (can be overridden
235
    # Pass the appropriate --tool option for the directory (can be overridden
228
    # by an "args:" or "args.dev:" line, though).  
236
    # by an "args:" or "args.dev:" line, though).  
229
    # Also, because the default valgrind is coregrind/valgrind which isn't
230
    # executable, prepend `sh'.
231
    my $tool=determine_tool();
237
    my $tool=determine_tool();
232
    mysystem("sh $valgrind --tool=$tool --in-place=$tests_dir $vgopts $prog $args > $name.stdout.out 2> $name.stderr.out");
238
    mysystem("VALGRINDLIB=$tests_dir/.in_place $valgrind --tool=$tool $vgopts $prog $args > $name.stdout.out 2> $name.stderr.out");
233
239
234
    if (defined $stdout_filter) {
240
    if (defined $stdout_filter) {
235
        mysystem("$stdout_filter < $name.stdout.out > $tmp");
241
        mysystem("$stdout_filter < $name.stdout.out > $tmp");
(-)valgrind-2.1.0/valgrind.spec (-51 lines)
Lines 1-51 Link Here
1
Summary: Valgrind Memory Debugger
2
Name: valgrind
3
Version: 2.1.0
4
Release: 1
5
Copyright: GPL
6
Group: Development/Debuggers
7
Packager: Jeremy Fitzhardinge <jeremy@goop.org>
8
Source: valgrind-2.1.0.tar.bz2
9
10
Buildroot: %{_tmppath}/valgrind
11
12
%description 
13
14
Valgrind is a GPL'd system for debugging and profiling x86-Linux programs.
15
With the tools that come with Valgrind, you can automatically detect
16
many memory management and threading bugs, avoiding hours of frustrating
17
bug-hunting, making your programs more stable. You can also perform
18
detailed profiling to help speed up your programs.
19
20
The Valgrind distribution includes four tools: two memory error
21
detectors, a thread error detector, and a cache profiler.  Several other
22
tools have been built with Valgrind.
23
24
%prep
25
%setup -n valgrind-2.1.0
26
27
%build
28
./configure --prefix=/usr
29
make
30
31
%install
32
make install prefix=$RPM_BUILD_ROOT/usr
33
34
%files
35
%defattr(-,root,root)
36
/usr/include/valgrind/valgrind.h
37
/usr/include/valgrind/memcheck.h
38
/usr/include/valgrind/helgrind.h
39
/usr/include/valgrind/vg_constants_skin.h
40
/usr/include/valgrind/vg_kerneliface.h
41
/usr/include/valgrind/vg_skin.h
42
/usr/bin/valgrind
43
/usr/bin/cg_annotate
44
/usr/lib/valgrind/*
45
/usr/bin/valgrind-listener
46
47
%doc
48
/usr/share/doc/valgrind/*
49
50
%clean
51
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
(-)valgrind-2.1.0/valgrind.spec.in (-1 / +3 lines)
Lines 29-35 Link Here
29
make
29
make
30
30
31
%install
31
%install
32
make install prefix=$RPM_BUILD_ROOT/usr
32
make install DESTDIR=$RPM_BUILD_ROOT
33
33
34
%files
34
%files
35
%defattr(-,root,root)
35
%defattr(-,root,root)
Lines 41-48 Link Here
41
/usr/include/valgrind/vg_skin.h
41
/usr/include/valgrind/vg_skin.h
42
/usr/bin/valgrind
42
/usr/bin/valgrind
43
/usr/bin/cg_annotate
43
/usr/bin/cg_annotate
44
/usr/lib/valgrind
44
/usr/lib/valgrind/*
45
/usr/lib/valgrind/*
45
/usr/bin/valgrind-listener
46
/usr/bin/valgrind-listener
47
/usr/lib/pkgconfig/valgrind.pc
46
48
47
%doc
49
%doc
48
/usr/share/doc/valgrind/*
50
/usr/share/doc/valgrind/*

Return to bug 32966