|
From: Christian B. <bor...@de...> - 2010-12-16 13:47:15
|
This patch wires up memcheck, cachgrind and drd to work with s390x.
exp-ptrcheck is disabled. lackey, none, dhat, helgrind work without
any change.
---
cachegrind/cg-s390x.c | 73 +++++++++++++++++++++++++++++++++++++++++++++
cachegrind/cg_branchpred.c | 2 +
drd/drd_bitmap.h | 2 -
drd/drd_load_store.c | 2 +
exp-ptrcheck/h_main.c | 24 ++++++++++++++
exp-ptrcheck/pc_main.c | 4 ++
memcheck/mc_machine.c | 58 +++++++++++++++++++++++++++++++++++
7 files changed, 163 insertions(+), 2 deletions(-)
--- /dev/null
+++ valgrind-upstream/cachegrind/cg-s390x.c
@@ -0,0 +1,73 @@
+
+/*--------------------------------------------------------------------*/
+/*--- s390x-specific definitions. cg-s390x.c ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Cachegrind, a Valgrind tool for cache
+ profiling programs.
+
+ Copyright IBM Corp. 2010
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+/* Contributed by Christian Borntraeger */
+
+#if defined(VGA_s390x)
+
+#include "pub_tool_basics.h"
+#include "pub_tool_libcbase.h"
+#include "pub_tool_libcassert.h"
+#include "pub_tool_libcprint.h"
+
+#include "cg_arch.h"
+
+void VG_(configure_caches)(cache_t* I1c, cache_t* D1c, cache_t* L2c,
+ Bool all_caches_clo_defined)
+{
+ // Set caches to z10 default.
+ // See IBM Journal of Research and Development
+ // Issue Date: Jan. 2009
+ // Volume: 53 Issue:1
+ // fixs390: have a table for all available models and check /proc/cpuinfo
+ *I1c = (cache_t) { 65536, 4, 256 };
+ *D1c = (cache_t) { 131072, 8, 256 };
+ *L2c = (cache_t) { 3145728, 12, 256 };
+
+ // Warn if config not completely specified from cmd line. Note that
+ // this message is slightly different from the one we give on x86/AMD64
+ // when auto-detection fails; this lets us filter out this one (which is
+ // not important) in the regression test suite without filtering the
+ // x86/AMD64 one (which we want to see if it ever occurs in the
+ // regression test suite).
+ //
+ // If you change this message, please update
+ // cachegrind/tests/filter_stderr!
+ //
+ if (!all_caches_clo_defined) {
+ VG_(dmsg)("Warning: Cannot auto-detect cache config on s390x, using one "
+ "or more defaults \n");
+ }
+}
+
+#endif
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
--- valgrind-upstream.orig/cachegrind/cg_branchpred.c
+++ valgrind-upstream/cachegrind/cg_branchpred.c
@@ -48,6 +48,8 @@
# define N_IADDR_LO_ZERO_BITS 2
#elif defined(VGA_x86) || defined(VGA_amd64)
# define N_IADDR_LO_ZERO_BITS 0
+#elif defined(VGA_s390x)
+# define N_IADDR_LO_ZERO_BITS 1
#else
# error "Unsupported architecture"
#endif
--- valgrind-upstream.orig/drd/drd_bitmap.h
+++ valgrind-upstream/drd/drd_bitmap.h
@@ -139,7 +139,7 @@ Addr make_address(const UWord a1, const
/** Log2 of BITS_PER_UWORD. */
#if defined(VGA_x86) || defined(VGA_ppc32) || defined(VGA_arm)
#define BITS_PER_BITS_PER_UWORD 5
-#elif defined(VGA_amd64) || defined(VGA_ppc64)
+#elif defined(VGA_amd64) || defined(VGA_ppc64) || defined(VGA_s390x)
#define BITS_PER_BITS_PER_UWORD 6
#else
#error Unknown platform.
--- valgrind-upstream.orig/drd/drd_load_store.c
+++ valgrind-upstream/drd/drd_load_store.c
@@ -48,6 +48,8 @@
#define STACK_POINTER_OFFSET OFFSET_ppc64_GPR1
#elif defined(VGA_arm)
#define STACK_POINTER_OFFSET OFFSET_arm_R13
+#elif defined(VGA_s390x)
+#define STACK_POINTER_OFFSET OFFSET_s390x_r15
#else
#error Unknown architecture.
#endif
--- valgrind-upstream.orig/exp-ptrcheck/h_main.c
+++ valgrind-upstream/exp-ptrcheck/h_main.c
@@ -564,7 +564,7 @@ static void pp_curr_ExeContext(void)
# define SHMEM_SECMAP_SHIFT 2
# define SHMEM_IS_WORD_ALIGNED(_a) VG_IS_4_ALIGNED(_a)
# define SEC_MAP_WORDS (0x10000UL / 4UL) /* 16k */
-#elif defined(VGA_amd64) || defined(VGA_ppc64)
+#elif defined(VGA_amd64) || defined(VGA_ppc64) || defined(VGA_s390x)
# define SHMEM_SECMAP_MASK 0xFFF8
# define SHMEM_SECMAP_SHIFT 3
# define SHMEM_IS_WORD_ALIGNED(_a) VG_IS_8_ALIGNED(_a)
@@ -1296,6 +1296,11 @@ typedef
# define PC_SIZEOF_GUEST_STATE sizeof(VexGuestARMState)
#endif
+#if defined(VGA_s390x)
+# include "libvex_guest_s390x.h"
+# define PC_SIZEOF_GUEST_STATE sizeof(VexGuestS390XState)
+#endif
+
/* See description on definition of type IntRegInfo. */
static void get_IntRegInfo ( /*OUT*/IntRegInfo* iii, Int offset, Int szB )
@@ -1833,6 +1838,14 @@ static void get_IntRegInfo ( /*OUT*/IntR
tl_assert(0);
+ /* -------------------- s390x -------------------- */
+
+# elif defined(VGA_s390x)
+
+ Int o = offset;
+
+ VG_(tool_panic)("not implemented for s390x");
+
# else
# error "FIXME: not implemented for this architecture"
# endif
@@ -1914,6 +1927,11 @@ static Bool is_integer_guest_reg_array (
VG_(printf)("\n");
tl_assert(0);
+ /* -------------------- s390x -------------------- */
+# elif defined(VGA_s390x)
+
+ tl_assert(0);
+
/* -------------------- arm -------------------- */
# elif defined(VGA_arm)
/* There are no rotating register sections on ARM. */
@@ -2472,7 +2490,9 @@ static void setup_post_syscall_table ( v
ADD(0, __NR_symlink);
ADD(0, __NR_sysinfo);
ADD(0, __NR_tgkill);
+#if defined(__NR_time)
ADD(0, __NR_time);
+# endif
ADD(0, __NR_times);
ADD(0, __NR_truncate);
# if defined(__NR_truncate64)
@@ -2754,6 +2774,8 @@ static inline Bool looks_like_a_pointer(
tl_assert(sizeof(UWord) == 4);
return (a >= 0x00008000UL && a < 0xFF000000UL);
+# elif defined(VGA_s390x)
+ tl_assert(0);
# else
# error "Unsupported architecture"
# endif
--- valgrind-upstream.orig/exp-ptrcheck/pc_main.c
+++ valgrind-upstream/exp-ptrcheck/pc_main.c
@@ -140,6 +140,10 @@ static void pc_post_clo_init ( void )
"(like --enable-sg-checks=no).\n");
}
sg_clo_enable_sg_checks = False;
+# elif defined(VGA_s390x)
+ /* fixs390: to be done. */
+ VG_(message)(Vg_UserMsg,
+ "ERROR: exp-ptrcheck on s390x platform is not supported yet.\n");
# else
# error "Unsupported architecture"
# endif
--- valgrind-upstream.orig/memcheck/mc_machine.c
+++ valgrind-upstream/memcheck/mc_machine.c
@@ -65,6 +65,11 @@
# define MC_SIZEOF_GUEST_STATE sizeof(VexGuestPPC64State)
#endif
+#if defined(VGA_s390x)
+# include "libvex_guest_s390x.h"
+# define MC_SIZEOF_GUEST_STATE sizeof(VexGuestS390XState)
+#endif
+
#if defined(VGA_arm)
# include "libvex_guest_arm.h"
# define MC_SIZEOF_GUEST_STATE sizeof(VexGuestARMState)
@@ -681,6 +686,54 @@ static Int get_otrack_shadow_offset_wrk
# undef GOF
# undef SZB
+ /* -------------------- s390x -------------------- */
+
+# elif defined(VGA_s390x)
+# define GOF(_fieldname) \
+ (offsetof(VexGuestS390XState,guest_##_fieldname))
+ Int o = offset;
+ Int sz = szB;
+ tl_assert(sz > 0);
+ tl_assert(host_is_big_endian());
+
+ /* no matter what byte(s) we change, we have changed the full 8 byte value
+ and need to track this change for the whole register */
+ if (o >= GOF(r0) && sz <= 8 && o <= (GOF(r15) + 8 - sz))
+ return GOF(r0) + ((o-GOF(r0)) & -8) ;
+
+
+ /* fprs are accesses 4 or 8 byte at once. Again, we track that change for
+ the full register */
+ if ((sz == 8 || sz == 4) && o >= GOF(f0) && o <= GOF(f15)+8-sz)
+ return GOF(f0) + ((o-GOF(f0)) & -8) ;
+
+ /* access registers are accessed 4 bytes at once */
+ if (sz == 4 && o >= GOF(a0) && o <= GOF(a15))
+ return o;
+
+ /* we access the guest counter either fully or one of the 4byte words */
+ if (o == GOF(counter) && (sz == 8 || sz ==4))
+ return o;
+ if (o == GOF(counter) + 4 && sz == 4)
+ return o;
+
+ if (o == GOF(CC_OP)) return -1;
+ if (o == GOF(CC_DEP1)) return o;
+ if (o == GOF(CC_DEP2)) return o;
+ if (o == GOF(CC_NDEP)) return -1;
+ if (o == GOF(TISTART)) return -1;
+ if (o == GOF(TILEN)) return -1;
+ if (o == GOF(NRADDR)) return -1;
+ if (o == GOF(IP_AT_SYSCALL)) return -1;
+ if (o == GOF(fpc)) return -1;
+ if (o == GOF(IA)) return -1;
+ if (o == GOF(SYSNO)) return -1;
+ VG_(printf)("MC_(get_otrack_shadow_offset)(s390x)(off=%d,sz=%d)\n",
+ offset,szB);
+ tl_assert(0);
+# undef GOF
+
+
/* --------------------- arm --------------------- */
# elif defined(VGA_arm)
@@ -888,6 +941,11 @@ IRType MC_(get_otrack_reg_array_equiv_in
VG_(printf)("\n");
tl_assert(0);
+ /* --------------------- s390x --------------------- */
+# elif defined(VGA_s390x)
+ /* Should never het here because s390x does not use Ist_PutI
+ and Iex_GetI. */
+ tl_assert(0);
# else
# error "FIXME: not implemented for this architecture"
# endif
|