Cachegrind was aborting if it hit a client request. Now it doesn't.
This fixes #116057, I think. I added a regtest so it won't regress again.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5072 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c
index ec493c7..99d7069 100644
--- a/cachegrind/cg_main.c
+++ b/cachegrind/cg_main.c
@@ -800,8 +800,9 @@
// Pretend otherwise.
if (isize == 0) isize = VG_MIN_INSTR_SZB;
- // Check size. XXX: broken for client requests!
- tl_assert(VG_MIN_INSTR_SZB <= isize && isize <= VG_MAX_INSTR_SZB);
+ // Sanity-check size.
+ tl_assert( (VG_MIN_INSTR_SZB <= isize && isize <= VG_MAX_INSTR_SZB)
+ || VG_CLREQ_SZB == isize );
// Get space for and init the inode, record it as the current one.
// Subsequent Dr/Dw/Dm events from the same instruction will
diff --git a/cachegrind/tests/Makefile.am b/cachegrind/tests/Makefile.am
index 58e6216..480c039 100644
--- a/cachegrind/tests/Makefile.am
+++ b/cachegrind/tests/Makefile.am
@@ -5,10 +5,11 @@
EXTRA_DIST = $(noinst_SCRIPTS) \
chdir.vgtest chdir.stderr.exp \
+ clreq.vgtest clreq.stderr.exp \
dlclose.vgtest dlclose.stderr.exp dlclose.stdout.exp
check_PROGRAMS = \
- chdir dlclose myprint.so
+ chdir clreq dlclose myprint.so
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g
diff --git a/cachegrind/tests/clreq.c b/cachegrind/tests/clreq.c
new file mode 100644
index 0000000..0f2bc2e
--- /dev/null
+++ b/cachegrind/tests/clreq.c
@@ -0,0 +1,11 @@
+
+// Prior to 3.0.1, Cachegrind was failing if run on a program that uses
+// client requests. It was fixed in 3.0.1, but then reintroduced
+// afterwards (reported as bug #116057). So here we test it.
+
+#include "../../include/valgrind.h"
+
+int main(void)
+{
+ return RUNNING_ON_VALGRIND;
+}
diff --git a/cachegrind/tests/clreq.stderr.exp b/cachegrind/tests/clreq.stderr.exp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cachegrind/tests/clreq.stderr.exp
diff --git a/cachegrind/tests/clreq.vgtest b/cachegrind/tests/clreq.vgtest
new file mode 100644
index 0000000..c0cf5fa
--- /dev/null
+++ b/cachegrind/tests/clreq.vgtest
@@ -0,0 +1,3 @@
+prog: clreq
+vgopts: -q
+cleanup: rm cachegrind.out.*
diff --git a/include/pub_tool_machine.h b/include/pub_tool_machine.h
index 1b24f0f..b569e85 100644
--- a/include/pub_tool_machine.h
+++ b/include/pub_tool_machine.h
@@ -31,19 +31,21 @@
#ifndef __PUB_TOOL_MACHINE_H
#define __PUB_TOOL_MACHINE_H
-/* VG_STACK_REDZONE_SZB: how many bytes below the stack pointer are validly
- * addressible? */
#if defined(VGA_x86)
-# define VG_MIN_INSTR_SZB 1
-# define VG_MAX_INSTR_SZB 16
-# define VG_STACK_REDZONE_SZB 0
+# define VG_MIN_INSTR_SZB 1 // min length of native instruction
+# define VG_MAX_INSTR_SZB 16 // max length of native instruction
+# define VG_CLREQ_SZB 18 // length of a client request, may
+ // be larger than VG_MAX_INSTR_SZB
+# define VG_STACK_REDZONE_SZB 0 // number of addressable bytes below SP
#elif defined(VGA_amd64)
# define VG_MIN_INSTR_SZB 1
# define VG_MAX_INSTR_SZB 16
+# define VG_CLREQ_SZB 18
# define VG_STACK_REDZONE_SZB 128
#elif defined(VGA_ppc32)
# define VG_MIN_INSTR_SZB 4
# define VG_MAX_INSTR_SZB 4
+# define VG_CLREQ_SZB 24
# define VG_STACK_REDZONE_SZB 0
#else
# error Unknown arch