You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(32) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
(30) |
2
(8) |
3
(5) |
4
(5) |
|
5
(3) |
6
(9) |
7
(5) |
8
(14) |
9
(17) |
10
(27) |
11
(10) |
|
12
(6) |
13
(10) |
14
(7) |
15
(16) |
16
(9) |
17
(14) |
18
(8) |
|
19
(5) |
20
(13) |
21
(21) |
22
(13) |
23
(4) |
24
(1) |
25
(4) |
|
26
(2) |
27
(7) |
28
(4) |
29
(5) |
30
(12) |
|
|
|
From: Florian K. <fl...@ei...> - 2015-04-20 21:46:51
|
On 20.04.2015 23:28, Philippe Waroquiers wrote: > Nice cleanup. > One small comment: wouldn't the description of VG_(sr_as_string)() > better be put in the .h rather than in the .c file ? > The fact that the memory is static (or must be freed by the caller) > is better described there ? I tend to favour small comments in header files and put noteworthy details next to the implementation. But I have no strong feelings and we don't have a policy for this either. So if you want to change it please feel free. Florian |
|
From: <sv...@va...> - 2015-04-20 21:33:26
|
Author: philippe
Date: Mon Apr 20 22:33:16 2015
New Revision: 15119
Log:
This patch changes the policy that does the GC of OldRef and RCEC
conflict cache size.
The current policy is:
A 'more or less' LRU policy is implemented by giving
to each OldRef a generation nr in which it was last touched.
A new generation is created every 50000 new access.
GC is done when the nr of OldRef reaches --conflict-cache-size.
The GC consists in removing enough generations to free
half of the entries.
After GC of OldRef, the RCEC (Ref Counted Exe Contexts)
not referenced anymore are GC-ed.
The new policy is:
An exact LRU policy is implemented using a doubly linked list
of OldRef.
When reaching --conflict-cache-size, the LRU entry is re-used.
The not referenced RCEC are GC-ed when less than 75% of the RCEC
are referenced, and the nr of RCEC is 'big' (at least half the
size of the contextTab, and at least the max nr of RCEC reached
previously).
(note: tried to directly recover a unref'ed RCEC when recovering
the LRU oldref, but that gives a lot of re-creation of RCEC).
new policy has the following advantages/disadvantages:
1. It is faster (at least for big applications)
On a firefox startup/exit, we gain about 1m30 second on 11m.
Similar 5..10% speed up encountered on other big applications
or on the new perf/memrw test.
The speed increase depends on the amount of memory
touched by the application. For applications with a
working set fitting in conflict-cache-size, the new policy
might be marginally slower than previous policy on platforms
having a small cache : the current policy only sets a generation
nr when an address is re-accessed, while the new policy
has to unchain and rechain the OldRef access in the LRU
doubly linked list.
2. It uses less memory (at least for big applications)
Firefox startup/exit "core" arena max use decreases from
1175MB mmap-ed/1060MB alloc-ed
to
994MB mmap-ed/913MB alloc-ed
The decrease in memory is the result of having a lot less RCEC:
The current policy let the nr of RCEC grow till the conflict
cache size is GC-ed.
The new policy limits the nr of RCEC to 133% of the RCEC
really referenced. So, we end up with a max nr of RCEC
a lot smaller with the new policy : max RCEC 191000
versus 1317000, for a total nr of discard RCEC operations
almost the same: 33M versus 32M.
Also, the current policy allocates a big temporary array
to do the GC of OldRef.
With the new policy, size of an OldRef increases because
we need 2 pointers for the LRU doubly linked list, and
we need the accessed address.
In total, the OldRef increase is limited to one Word,
as we do not need anymore the gen, and the 'magic'
for sanity check was removed (the check somewhat
becomes less needed, because an OldRef is never freed
anymore. Also, we do a new cross-check between
the ga in the OldRef and the sparseWA key).
For applications using small memory and having
a small nr of different stack traces accessing memory,
the new policy causes an increase in memory (one Word
per OldRef).
3. Functionally, the new policy gives better past information:
once the steady state is reached (i.e. the conflict cache
is full), the new policy has always --conflict-cache-size
entries of past information.
The current policy has a nr of past information varying
between --conflict-cache-size/2 and --conflict-cache-size
(so in average, 75% of conflict-cache-size).
4. The new code is a little bit smaller/simpler:
The generation based GC is replaced by a simpler LRU policy.
So, in summary, this patch should allow big applications
to use less cpu/memory, while having very little
or no impact on memory/cpu of small applications.
Note that the OldRef data structure LRU policy
is not really explicitely tested by a regtest.
Not easy at first sight to make such a test portable
between platforms/OS/compilers/....
Added:
trunk/perf/memrw.c
trunk/perf/memrw.vgperf
Modified:
trunk/helgrind/libhb_core.c
trunk/perf/Makefile.am
Modified: trunk/helgrind/libhb_core.c
==============================================================================
--- trunk/helgrind/libhb_core.c (original)
+++ trunk/helgrind/libhb_core.c Mon Apr 20 22:33:16 2015
@@ -3818,8 +3818,6 @@
// //
/////////////////////////////////////////////////////////
-#define EVENT_MAP_GC_DISCARD_FRACTION 0.5
-
/* This is in two parts:
1. A hash table of RCECs. This is a set of reference-counted stack
@@ -3832,8 +3830,9 @@
2. A SparseWA of OldRefs. These store information about each old
ref that we need to record. It is indexed by address of the
location for which the information is recorded. For LRU
- purposes, each OldRef also contains a generation number,
- indicating when it was most recently accessed.
+ purposes, each OldRef in the SparseWA is also on a doubly
+ linked list maintaining the order in which the OldRef were most
+ recently accessed.
The important part of an OldRef is, however, its accs[] array.
This is an array of N_OLDREF_ACCS which binds (thread, R/W,
@@ -3843,9 +3842,8 @@
falls off the end, that's too bad -- we will lose info about
that triple's access to this location.
- When the SparseWA becomes too big, we can throw away the OldRefs
- whose generation numbers are below some threshold; hence doing
- approximate LRU discarding. For each discarded OldRef we must
+ We allocate a maximum of VG_(clo_conflict_cache_size) OldRef.
+ Then we do exact LRU discarding. For each discarded OldRef we must
of course decrement the reference count on the all RCECs it
refers to, in order that entries from (1) eventually get
discarded too.
@@ -3903,8 +3901,22 @@
}
RCEC;
+//////////// BEGIN RCEC pool allocator
+static PoolAlloc* rcec_pool_allocator;
+static RCEC* alloc_RCEC ( void ) {
+ return VG_(allocEltPA) ( rcec_pool_allocator );
+}
+
+static void free_RCEC ( RCEC* rcec ) {
+ tl_assert(rcec->magic == RCEC_MAGIC);
+ VG_(freeEltPA)( rcec_pool_allocator, rcec );
+}
+//////////// END RCEC pool allocator
+
static RCEC** contextTab = NULL; /* hash table of RCEC*s */
+/* Count of allocated RCEC having ref count > 0 */
+static UWord RCEC_referenced = 0;
/* Gives an arbitrary total order on RCEC .frames fields */
static Word RCEC__cmp_by_frames ( RCEC* ec1, RCEC* ec2 ) {
@@ -3928,29 +3940,19 @@
tl_assert(ec && ec->magic == RCEC_MAGIC);
tl_assert(ec->rc > 0);
ec->rc--;
+ if (ec->rc == 0)
+ RCEC_referenced--;
}
static void ctxt__rcinc ( RCEC* ec )
{
tl_assert(ec && ec->magic == RCEC_MAGIC);
+ if (ec->rc == 0)
+ RCEC_referenced++;
ec->rc++;
}
-//////////// BEGIN RCEC pool allocator
-static PoolAlloc* rcec_pool_allocator;
-
-static RCEC* alloc_RCEC ( void ) {
- return VG_(allocEltPA) ( rcec_pool_allocator );
-}
-
-static void free_RCEC ( RCEC* rcec ) {
- tl_assert(rcec->magic == RCEC_MAGIC);
- VG_(freeEltPA)( rcec_pool_allocator, rcec );
-}
-//////////// END RCEC pool allocator
-
-
/* Find 'ec' in the RCEC list whose head pointer lives at 'headp' and
move it one step closer the the front of the list, so as to make
subsequent searches for it cheaper. */
@@ -4072,9 +4074,6 @@
/// A SparseWA guest-addr -> OldRef, that refers to (1)
///
-// (UInt) `echo "Old Reference Information" | md5sum`
-#define OldRef_MAGIC 0x30b1f075UL
-
/* Records an access: a thread, a context (size & writeness) and the
number of held locks. The size (1,2,4,8) is encoded as 00 = 1, 01 =
2, 10 = 4, 11 = 8.
@@ -4092,34 +4091,98 @@
#define N_OLDREF_ACCS 5
typedef
- struct {
- UWord magic; /* sanity check only */
- UWord gen; /* when most recently accessed */
- /* or free list when not in use */
+ struct OldRef {
+ struct OldRef *prev; // to refs older than this one
+ struct OldRef *next; // to refs newer that this one
+ Addr ga; // Address for which we record up to N_OLDREF_ACCS accesses.
/* unused slots in this array have .thrid == 0, which is invalid */
Thr_n_RCEC accs[N_OLDREF_ACCS];
}
OldRef;
-
+/* We need ga in OldRef in order to remove OldRef from the sparsewa
+ by key (i.e. ga) when re-using the lru OldRef. */
//////////// BEGIN OldRef pool allocator
static PoolAlloc* oldref_pool_allocator;
-
-static OldRef* alloc_OldRef ( void ) {
- return VG_(allocEltPA) ( oldref_pool_allocator );
-}
-
-static void free_OldRef ( OldRef* r ) {
- tl_assert(r->magic == OldRef_MAGIC);
- VG_(freeEltPA)( oldref_pool_allocator, r );
-}
+// Note: We only allocate elements in this pool allocator, we never free them.
+// We stop allocating elements at VG_(clo_conflict_cache_size).
//////////// END OldRef pool allocator
+static OldRef mru;
+static OldRef lru;
+// A double linked list, chaining all OldREf in a mru/lru order.
+// mru/lru are sentinel nodes.
+// Whenever an oldref is re-used, its position is changed as the most recently
+// used (i.e. pointed to by mru.prev).
+// When a new oldref is needed, it is allocated from the pool
+// if we have not yet reached --conflict-cache-size.
+// Otherwise, if all oldref have already been allocated,
+// the least recently used (i.e. pointed to by lru.next) is re-used.
+// When an OldRef is used, it is moved as the most recently used entry
+// (i.e. pointed to by mru.prev).
+
+// Removes r from the double linked list
+// Note: we do not need to test for special cases such as
+// NULL next or prev pointers, because we have sentinel nodes
+// at both sides of the list. So, a node is always forward and
+// backward linked.
+static inline void OldRef_unchain(OldRef *r)
+{
+ r->next->prev = r->prev;
+ r->prev->next = r->next;
+}
+
+// Insert new as the newest OldRef
+// Similarly to OldRef_unchain, no need to test for NULL
+// pointers, as e.g. mru.prev is always guaranteed to point
+// to a non NULL node (lru when the list is empty).
+static inline void OldRef_newest(OldRef *new)
+{
+ new->next = &mru;
+ new->prev = mru.prev;
+ mru.prev = new;
+ new->prev->next = new;
+}
static SparseWA* oldrefTree = NULL; /* SparseWA* OldRef* */
-static UWord oldrefGen = 0; /* current LRU generation # */
static UWord oldrefTreeN = 0; /* # elems in oldrefTree */
-static UWord oldrefGenIncAt = 0; /* inc gen # when size hits this */
+/* Note: the nr of ref in the oldrefTree will always be equal to
+ the nr of elements that were allocated from the OldRef pool allocator
+ as we never free an OldRef : we just re-use them. */
+
+
+/* allocates a new OldRef or re-use the lru one if all allowed OldRef
+ have already been allocated. */
+static OldRef* alloc_or_reuse_OldRef ( void )
+{
+ if (oldrefTreeN < HG_(clo_conflict_cache_size)) {
+ oldrefTreeN++;
+ return VG_(allocEltPA) ( oldref_pool_allocator );
+ } else {
+ Bool b;
+ UWord valW;
+ OldRef *oldref = lru.next;
+
+ OldRef_unchain(oldref);
+ b = VG_(delFromSWA)( oldrefTree, &valW, oldref->ga );
+ tl_assert(b);
+ tl_assert (oldref == (OldRef*)valW);
+
+ for (UInt i = 0; i < N_OLDREF_ACCS; i++) {
+ ThrID aThrID = oldref->accs[i].thrid;
+ RCEC* aRef = oldref->accs[i].rcec;
+ if (aRef) {
+ tl_assert(aThrID != 0);
+ stats__ctxt_rcdec3++;
+ ctxt__rcdec( aRef );
+ } else {
+ tl_assert(aThrID == 0);
+ }
+ }
+ return oldref;
+ }
+}
+
inline static UInt min_UInt ( UInt a, UInt b ) {
return a < b ? a : b;
@@ -4181,7 +4244,8 @@
see if we have a stack trace pertaining to this (thrid, R/W,
size) triple. */
ref = (OldRef*)valW;
- tl_assert(ref->magic == OldRef_MAGIC);
+
+ tl_assert (ref->ga == a);
for (i = 0; i < N_OLDREF_ACCS; i++) {
if (ref->accs[i].thrid != thrid)
@@ -4236,21 +4300,14 @@
/* tl_assert(thrid != 0); */ /* There's a dominating assert above. */
}
- ref->gen = oldrefGen;
+ OldRef_unchain(ref);
+ OldRef_newest(ref);
} else {
/* We don't have a record for this address. Create a new one. */
- if (oldrefTreeN >= oldrefGenIncAt) {
- oldrefGen++;
- oldrefGenIncAt = oldrefTreeN + 50000;
- if (0) VG_(printf)("oldrefTree: new gen %lu at size %lu\n",
- oldrefGen, oldrefTreeN );
- }
-
- ref = alloc_OldRef();
- ref->magic = OldRef_MAGIC;
- ref->gen = oldrefGen;
+ ref = alloc_or_reuse_OldRef();
+ ref->ga = a;
ref->accs[0].thrid = thrid;
ref->accs[0].szLg2B = szLg2B;
ref->accs[0].isW = (UInt)(isW & 1);
@@ -4270,8 +4327,7 @@
ref->accs[j].locksHeldW = 0;
}
VG_(addToSWA)( oldrefTree, a, (UWord)ref );
- oldrefTreeN++;
-
+ OldRef_newest (ref);
}
}
@@ -4323,7 +4379,6 @@
continue;
ref = (OldRef*)valW;
- tl_assert(ref->magic == OldRef_MAGIC);
tl_assert(ref->accs[0].thrid != 0); /* first slot must always be used */
cand_thrid = 0; /* invalid; see comments in event_map_bind */
@@ -4429,12 +4484,22 @@
HG_(free)
);
- oldrefGen = 0;
- oldrefGenIncAt = 0;
oldrefTreeN = 0;
+ mru.prev = &lru;
+ mru.next = NULL;
+ lru.prev = NULL;
+ lru.next = &mru;
+ for (i = 0; i < N_OLDREF_ACCS; i++) {
+ mru.accs[i] = (Thr_n_RCEC) {.rcec = NULL,
+ .locksHeldW = 0,
+ .thrid = 0,
+ .szLg2B = 0,
+ .isW = 0};
+ lru.accs[i] = mru.accs[i];
+ }
}
-static void event_map__check_reference_counts ( Bool before )
+static void event_map__check_reference_counts ( void )
{
RCEC* rcec;
OldRef* oldref;
@@ -4452,8 +4517,6 @@
nEnts++;
tl_assert(rcec);
tl_assert(rcec->magic == RCEC_MAGIC);
- if (!before)
- tl_assert(rcec->rc > 0);
rcec->rcX = 0;
}
}
@@ -4466,7 +4529,6 @@
VG_(initIterSWA)( oldrefTree );
while (VG_(nextIterSWA)( oldrefTree, &keyW, &valW )) {
oldref = (OldRef*)valW;
- tl_assert(oldref->magic == OldRef_MAGIC);
for (i = 0; i < N_OLDREF_ACCS; i++) {
ThrID aThrID = oldref->accs[i].thrid;
RCEC* aRef = oldref->accs[i].rcec;
@@ -4489,244 +4551,22 @@
}
__attribute__((noinline))
-static void event_map_GC ( void )
+static void do_RCEC_GC ( void )
{
- OldRef* oldref;
- UWord keyW, valW, retained, maxGen;
- XArray* refs2del;
- Word i, j, n2del;
-
- UWord* genMap = NULL;
- UWord genMap_min = 0;
- UWord genMap_size = 0;
-
- if (0)
- VG_(printf)("libhb: event_map GC at size %lu\n", oldrefTreeN);
-
- /* Check for sane command line params. Limit values must match
- those in hg_process_cmd_line_option. */
- tl_assert( HG_(clo_conflict_cache_size) >= 10*1000 );
- tl_assert( HG_(clo_conflict_cache_size) <= 30*1000*1000 );
-
- /* Check our counting is sane (expensive) */
- if (CHECK_CEM)
- tl_assert(oldrefTreeN == VG_(sizeSWA)( oldrefTree ));
-
- /* Check the reference counts (expensive) */
- if (CHECK_CEM)
- event_map__check_reference_counts( True/*before*/ );
-
- /* Compute the distribution of generation values in the ref tree.
- There are likely only to be a few different generation numbers
- in the whole tree, but we don't know what they are. Hence use a
- dynamically resized array of counters. The array is genMap[0
- .. genMap_size-1], where genMap[0] is the count for the
- generation number genMap_min, genMap[1] is the count for
- genMap_min+1, etc. If a new number is seen outside the range
- [genMap_min .. genMap_min + genMap_size - 1] then the array is
- copied into a larger array, and genMap_min and genMap_size are
- adjusted accordingly. */
-
- /* genMap :: generation-number -> count-of-nodes-with-that-number */
-
- VG_(initIterSWA)( oldrefTree );
- while ( VG_(nextIterSWA)( oldrefTree, &keyW, &valW )) {
-
- UWord ea, key;
- oldref = (OldRef*)valW;
- key = oldref->gen;
-
- /* BEGIN find 'ea', which is the index in genMap holding the
- count for generation number 'key'. */
- if (UNLIKELY(genMap == NULL)) {
- /* deal with the first key to be seen, so that the following
- cases don't need to handle the complexity of a NULL count
- array. */
- genMap_min = key;
- genMap_size = 1;
- genMap = HG_(zalloc)( "libhb.emmG.1a",
- genMap_size * sizeof(UWord) );
- ea = 0;
- if (0) VG_(printf)("(%lu) case 1 [%lu .. %lu]\n",
- key, genMap_min, genMap_min+genMap_size- 1 );
- }
- else
- if (LIKELY(key >= genMap_min && key < genMap_min + genMap_size)) {
- /* this is the expected (almost-always-happens) case: 'key'
- is already mapped in the array. */
- ea = key - genMap_min;
- }
- else
- if (key < genMap_min) {
- /* 'key' appears before the start of the current array.
- Extend the current array by allocating a larger one and
- copying the current one to the upper end of it. */
- Word more;
- UWord* map2;
- more = genMap_min - key;
- tl_assert(more > 0);
- map2 = HG_(zalloc)( "libhb.emmG.1b",
- (genMap_size + more) * sizeof(UWord) );
- VG_(memcpy)( &map2[more], genMap, genMap_size * sizeof(UWord) );
- HG_(free)( genMap );
- genMap = map2;
- genMap_size += more;
- genMap_min -= more;
- ea = 0;
- tl_assert(genMap_min == key);
- if (0) VG_(printf)("(%lu) case 2 [%lu .. %lu]\n",
- key, genMap_min, genMap_min+genMap_size- 1 );
- }
- else {
- /* 'key' appears after the end of the current array. Extend
- the current array by allocating a larger one and copying
- the current one to the lower end of it. */
- Word more;
- UWord* map2;
- tl_assert(key >= genMap_min + genMap_size);
- more = key - (genMap_min + genMap_size) + 1;
- tl_assert(more > 0);
- map2 = HG_(zalloc)( "libhb.emmG.1c",
- (genMap_size + more) * sizeof(UWord) );
- VG_(memcpy)( &map2[0], genMap, genMap_size * sizeof(UWord) );
- HG_(free)( genMap );
- genMap = map2;
- genMap_size += more;
- ea = genMap_size - 1;;
- tl_assert(genMap_min + genMap_size - 1 == key);
- if (0) VG_(printf)("(%lu) case 3 [%lu .. %lu]\n",
- key, genMap_min, genMap_min+genMap_size- 1 );
- }
- /* END find 'ea' from 'key' */
-
- tl_assert(ea >= 0 && ea < genMap_size);
- /* and the whole point of this elaborate computation of 'ea' is .. */
- genMap[ea]++;
- }
-
- tl_assert(genMap);
- tl_assert(genMap_size > 0);
-
- /* Sanity check what we just computed */
- { UWord sum = 0;
- for (i = 0; i < genMap_size; i++) {
- if (0) VG_(printf)(" xxx: gen %ld has %lu\n",
- i + genMap_min, genMap[i] );
- sum += genMap[i];
- }
- tl_assert(sum == oldrefTreeN);
- }
-
- /* Figure out how many generations to throw away */
- retained = oldrefTreeN;
- maxGen = 0;
-
- for (i = 0; i < genMap_size; i++) {
- keyW = i + genMap_min;
- valW = genMap[i];
- tl_assert(keyW > 0); /* can't allow a generation # 0 */
- if (0) VG_(printf)(" XXX: gen %lu has %lu\n", keyW, valW );
- tl_assert(keyW >= maxGen);
- tl_assert(retained >= valW);
- if (retained - valW
- > (UWord)(HG_(clo_conflict_cache_size)
- * EVENT_MAP_GC_DISCARD_FRACTION)) {
- retained -= valW;
- maxGen = keyW;
- } else {
- break;
- }
- }
-
- HG_(free)(genMap);
+ UInt i;
- tl_assert(retained >= 0 && retained <= oldrefTreeN);
-
- /* Now make up a big list of the oldrefTree entries we want to
- delete. We can't simultaneously traverse the tree and delete
- stuff from it, so first we need to copy them off somewhere
- else. (sigh) */
- refs2del = VG_(newXA)( HG_(zalloc), "libhb.emmG.2",
- HG_(free), sizeof(Addr) );
-
- if (retained < oldrefTreeN) {
-
- /* This is the normal (expected) case. We discard any ref whose
- generation number <= maxGen. */
- VG_(initIterSWA)( oldrefTree );
- while (VG_(nextIterSWA)( oldrefTree, &keyW, &valW )) {
- oldref = (OldRef*)valW;
- tl_assert(oldref->magic == OldRef_MAGIC);
- if (oldref->gen <= maxGen) {
- VG_(addToXA)( refs2del, &keyW );
- }
- }
- if (VG_(clo_stats)) {
- VG_(message)(Vg_DebugMsg,
- "libhb: EvM GC: delete generations %lu and below, "
- "retaining %lu entries\n",
- maxGen, retained );
- }
-
- } else {
-
- static UInt rand_seed = 0; /* leave as static */
-
- /* Degenerate case: there's only one generation in the entire
- tree, so we need to have some other way of deciding which
- refs to throw away. Just throw out half of them randomly. */
- tl_assert(retained == oldrefTreeN);
- VG_(initIterSWA)( oldrefTree );
- while (VG_(nextIterSWA)( oldrefTree, &keyW, &valW )) {
- UInt n;
- oldref = (OldRef*)valW;
- tl_assert(oldref->magic == OldRef_MAGIC);
- n = VG_(random)( &rand_seed );
- if ((n & 0xFFF) < 0x800) {
- VG_(addToXA)( refs2del, &keyW );
- retained--;
- }
- }
- if (VG_(clo_stats)) {
- VG_(message)(Vg_DebugMsg,
- "libhb: EvM GC: randomly delete half the entries, "
- "retaining %lu entries\n",
- retained );
- }
-
- }
-
- n2del = VG_(sizeXA)( refs2del );
- tl_assert(n2del == (Word)(oldrefTreeN - retained));
-
- if (0) VG_(printf)("%s","deleting entries\n");
- for (i = 0; i < n2del; i++) {
- Bool b;
- Addr ga2del = *(Addr*)VG_(indexXA)( refs2del, i );
- b = VG_(delFromSWA)( oldrefTree, &valW, ga2del );
- tl_assert(b);
- oldref = (OldRef*)valW;
- for (j = 0; j < N_OLDREF_ACCS; j++) {
- ThrID aThrID = oldref->accs[j].thrid;
- RCEC* aRef = oldref->accs[j].rcec;
- if (aRef) {
- tl_assert(aThrID != 0);
- stats__ctxt_rcdec3++;
- ctxt__rcdec( aRef );
- } else {
- tl_assert(aThrID == 0);
- }
- }
-
- free_OldRef( oldref );
+ if (VG_(clo_stats)) {
+ static UInt ctr = 1;
+ VG_(message)(Vg_DebugMsg,
+ "libhb: RCEC GC: #%u %lu slots,"
+ " %lu cur ents(ref'd %lu),"
+ " %lu max ents\n",
+ ctr++,
+ (UWord)N_RCEC_TAB,
+ stats__ctxt_tab_curr, RCEC_referenced,
+ stats__ctxt_tab_max );
}
-
- VG_(deleteXA)( refs2del );
-
- tl_assert( VG_(sizeSWA)( oldrefTree ) == retained );
-
- oldrefTreeN = retained;
- oldrefGenIncAt = oldrefTreeN; /* start new gen right away */
+ tl_assert (stats__ctxt_tab_curr > RCEC_referenced);
/* Throw away all RCECs with zero reference counts */
for (i = 0; i < N_RCEC_TAB; i++) {
@@ -4747,17 +4587,9 @@
}
}
- /* Check the reference counts (expensive) */
- if (CHECK_CEM)
- event_map__check_reference_counts( False/*after*/ );
-
- //if (0)
- //VG_(printf)("XXXX final sizes: oldrefTree %ld, contextTree %ld\n\n",
- // VG_(OSetGen_Size)(oldrefTree), VG_(OSetGen_Size)(contextTree));
-
+ tl_assert (stats__ctxt_tab_curr == RCEC_referenced);
}
-
/////////////////////////////////////////////////////////
// //
// Core MSM //
@@ -6294,10 +6126,12 @@
stats__ctxt_rcdec3 );
VG_(printf)( " libhb: ctxt__rcdec: calls %lu, discards %lu\n",
stats__ctxt_rcdec_calls, stats__ctxt_rcdec_discards);
- VG_(printf)( " libhb: contextTab: %lu slots, %lu cur ents,"
+ VG_(printf)( " libhb: contextTab: %lu slots,"
+ " %lu cur ents(ref'd %lu),"
" %lu max ents\n",
(UWord)N_RCEC_TAB,
- stats__ctxt_tab_curr, stats__ctxt_tab_max );
+ stats__ctxt_tab_curr, RCEC_referenced,
+ stats__ctxt_tab_max );
VG_(printf)( " libhb: contextTab: %lu queries, %lu cmps\n",
stats__ctxt_tab_qs,
stats__ctxt_tab_cmps );
@@ -6581,8 +6415,16 @@
void libhb_maybe_GC ( void )
{
- if (UNLIKELY(oldrefTreeN >= HG_(clo_conflict_cache_size)))
- event_map_GC();
+ /* GC the unreferenced (zero rc) RCECs when
+ (1) reaching a significant nr of RCECs (to avoid scanning a contextTab
+ with mostly NULL ptr)
+ and (2) reaching at least the max nr of RCEC (as we have in any case
+ at least that amount of RCEC in the pool allocator)
+ and (3) the nr of referenced RCECs is less than 75% than total nr RCECs. */
+ if (UNLIKELY(stats__ctxt_tab_curr > N_RCEC_TAB/2
+ && stats__ctxt_tab_curr >= stats__ctxt_tab_max
+ && stats__ctxt_tab_curr * 0.75 > RCEC_referenced))
+ do_RCEC_GC();
/* If there are still freelist entries available, no need for a
GC. */
@@ -6593,6 +6435,10 @@
if (VG_(sizeXA)( vts_tab ) < vts_next_GC_at)
return;
vts_tab__do_GC( False/*don't show stats*/ );
+
+ /* Check the reference counts (expensive) */
+ if (CHECK_CEM)
+ event_map__check_reference_counts();
}
Modified: trunk/perf/Makefile.am
==============================================================================
--- trunk/perf/Makefile.am (original)
+++ trunk/perf/Makefile.am Mon Apr 20 22:33:16 2015
@@ -13,12 +13,14 @@
heap_pdb4.vgperf \
many-loss-records.vgperf \
many-xpts.vgperf \
+ memrw.vgperf \
sarp.vgperf \
tinycc.vgperf \
test_input_for_tinycc.c
check_PROGRAMS = \
- bigcode bz2 fbench ffbench heap many-loss-records many-xpts sarp tinycc
+ bigcode bz2 fbench ffbench heap many-loss-records many-xpts \
+ memrw sarp tinycc
AM_CFLAGS += -O $(AM_FLAG_M3264_PRI)
AM_CXXFLAGS += -O $(AM_FLAG_M3264_PRI)
@@ -29,6 +31,7 @@
fbench_CFLAGS = $(AM_CFLAGS) -O2
ffbench_LDADD = -lm
+memrw_LDADD = -lpthread
tinycc_CFLAGS = $(AM_CFLAGS) -Wno-shadow -Wno-inline
if HAS_POINTER_SIGN_WARNING
Added: trunk/perf/memrw.c
==============================================================================
--- trunk/perf/memrw.c (added)
+++ trunk/perf/memrw.c Mon Apr 20 22:33:16 2015
@@ -0,0 +1,128 @@
+#define _GNU_SOURCE
+#include <string.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+// memrw provides a simulation of an application
+// reading and writing memory, for the sake of tuning helgrind.
+// It is a very simple (simplistic) model:
+// * only one thread
+// * only one exe context reading or writing the memory
+// * the working set of the application is unrealistically
+// concentrated on a consecutive nr of MB.
+// At this moment, it was just used to tune the EvM data structure
+// of helgrind.
+// It would be nice to enhance this program to cope with a richer
+// model e.g. multiple threads, many different stack traces touching
+// the memory, better working set distribution, ...
+
+static int nr_mb = 0; // total nr of mb used by the program
+static int nr_mb_ws = 0; // nr_mb in program working set
+static int nr_loops = 0; // nr of loops reading or writing the ws
+static int nr_thr; // nr of threads (hardcoded to 1 currently)
+
+// Note: the total nr of mb is what is explicitely allocated.
+// On top of that, we have the stacks, local vars, lib vars, ...
+// The working set is just the first nr_mb_ws of nr_mb.
+
+static int verbose = 0;
+static unsigned char **mb;
+
+static void *memrw_fn(void *v)
+{
+ int loops, m, b;
+ int write;
+ int differs = 0;
+ unsigned char prev = 0;
+
+ for (loops = 0; loops < nr_loops; loops++) {
+ // printf("loop %d write %d\n", loops, write);
+ // Note: in case of multiple threads, we will have
+ // to add lock/unlock somewhere in the below, maybe to lock
+ // the MB we are reading or writing.
+ for (m = 0; m < nr_mb_ws; m++) {
+ for (b = 0; b < 1024 * 1024; b++) {
+ write = b % 5 == 0;
+ // Do some write or read operations.
+ if (write) {
+ if (mb[m][b] < 255)
+ mb[m][b] += differs;
+ else
+ mb[m][b] = 0;
+ } else {
+ differs = mb[m][b] != prev;
+ prev = mb[m][b];
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+int main (int argc, char *argv[])
+{
+ int a;
+ int ret;
+ int i;
+ pthread_t thr;
+
+ // usage: memrw [-t nr_mb default 10] [-w nr_mb_ws default 10]
+ // [-l nr_loops_on_ws default 3]
+ // [-f fan_out default 0]
+ // [-v verbosity default 0]
+ nr_mb = 10;
+ nr_mb_ws = 10;
+ nr_loops = 3;
+ verbose = 0;
+ for (a = 1; a < argc; a+=2) {
+ if (strcmp(argv[a], "-t") == 0) {
+ nr_mb = atoi(argv[a+1]);
+ } else if (strcmp(argv[a], "-w") == 0) {
+ nr_mb_ws = atoi(argv[a+1]);
+ } else if (strcmp(argv[a], "-l") == 0) {
+ nr_loops = atoi(argv[a+1]);
+ } else if (strcmp(argv[a], "-v") == 0) {
+ verbose = atoi(argv[a+1]);
+ } else {
+ printf("unknown arg %s\n", argv[a]);
+ }
+ }
+ if (nr_mb_ws > nr_mb)
+ nr_mb_ws = nr_mb; // to make it easy to do loops combining values
+
+ nr_thr = 1;
+
+ printf ("total program memory -t %d MB"
+ " working set -w %d MB"
+ " working set R or W -l %d times"
+ "\n",
+ nr_mb,
+ nr_mb_ws,
+ nr_loops);
+
+ printf ("creating and initialising the total program memory\n");
+ mb = malloc(nr_mb * sizeof(char*));
+ if (mb == NULL)
+ perror("malloc mb");
+ for (i = 0; i < nr_mb; i++) {
+ mb[i] = calloc(1024*1024, 1);
+ if (mb[i] == NULL)
+ perror("malloc mb[i]");
+ }
+
+ printf("starting thread that will read or write the working set\n");
+ ret = pthread_create(&thr, NULL, memrw_fn, &nr_thr);
+ if (ret != 0)
+ perror("pthread_create");
+ printf("waiting for thread termination\n");
+
+ ret = pthread_join(thr, NULL);
+ if (ret != 0)
+ perror("pthread_join");
+ printf("thread terminated\n");
+
+ return 0;
+}
Added: trunk/perf/memrw.vgperf
==============================================================================
--- trunk/perf/memrw.vgperf (added)
+++ trunk/perf/memrw.vgperf Mon Apr 20 22:33:16 2015
@@ -0,0 +1,2 @@
+prog: memrw
+
|
|
From: Philippe W. <phi...@sk...> - 2015-04-20 21:26:59
|
Nice cleanup.
One small comment: wouldn't the description of VG_(sr_as_string)()
better be put in the .h rather than in the .c file ?
The fact that the memory is static (or must be freed by the caller)
is better described there ?
Philippe
On Mon, 2015-04-20 at 20:42 +0000, sv...@va... wrote:
> +/* ---------------------------------------------------------------------
> + VG_(sr_as_string)()
> + ------------------------------------------------------------------ */
> +
> +/* Return a textual representation of a SysRes value in a statically
> + allocated buffer. The buffer will be overwritten with the next
> + invocation. */
> +#if defined(VGO_linux)
> +// FIXME: Does this function need to be adjusted for MIPS's _valEx ?
> +const HChar *VG_(sr_as_string) ( SysRes sr )
> +{
....
> Modified: trunk/include/pub_tool_libcprint.h
> ==============================================================================
> --- trunk/include/pub_tool_libcprint.h (original)
> +++ trunk/include/pub_tool_libcprint.h Mon Apr 20 21:42:42 2015
> @@ -154,6 +154,9 @@
> /* Flush any output cached by previous calls to VG_(message) et al. */
> extern void VG_(message_flush) ( void );
>
> +/* Return a SysRes value as a character string. */
> +extern const HChar *VG_(sr_as_string) ( SysRes sr );
> +
> #endif // __PUB_TOOL_LIBCPRINT_H
>
> /*--------------------------------------------------------------------*/
>
>
> ------------------------------------------------------------------------------
> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> Develop your own process in accordance with the BPMN 2 standard
> Learn Process modeling best practices with Bonita BPM through live exercises
> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
> _______________________________________________
> Valgrind-developers mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-developers
|
|
From: <sv...@va...> - 2015-04-20 21:13:10
|
Author: florian
Date: Mon Apr 20 22:13:03 2015
New Revision: 15118
Log:
Use the proper function.
Modified:
trunk/coregrind/m_signals.c
Modified: trunk/coregrind/m_signals.c
==============================================================================
--- trunk/coregrind/m_signals.c (original)
+++ trunk/coregrind/m_signals.c Mon Apr 20 22:13:03 2015
@@ -574,7 +574,7 @@
# define VG_UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.gregs[10])
# define VG_UCONTEXT_SYSCALL_SYSRES(uc) \
/* Convert the value in uc_mcontext.rax into a SysRes. */ \
- VG_(mk_SysRes_amd64_linux)((uc)->uc_mcontext.gregs[0])
+ VG_(mk_SysRes_tilegx_linux)((uc)->uc_mcontext.gregs[0])
# define VG_UCONTEXT_TO_UnwindStartRegs(srP, uc) \
{ (srP)->r_pc = (uc)->uc_mcontext.pc; \
(srP)->r_sp = (uc)->uc_mcontext.sp; \
|
|
From: Florian K. <fl...@ei...> - 2015-04-20 21:10:33
|
On 20.04.2015 15:05, Julian Seward wrote: > >>> Your yesterday's change r15060 breaks MIPS port in general, >> as comparing _valEx will fail immediately. >> >> MIPS support has been broken in trunk for two weeks. Does anyone >> have a fix for this incoming? Maybe it should be posted as a bug >> in the tracker. > > Perhaps it would be wise to back out 15060 until such time as it > gets fixed properly, and at the same time file a bug in the tracker > for the underlying problem. It would be even better if the issue was fixed. I've made some adjustments. In particular, I removed _valEx from the common code. We don't want it there. https://bugs.kde.org/show_bug.cgi?id=346411 Florian |
|
From: <sv...@va...> - 2015-04-20 21:02:25
|
Author: florian
Date: Mon Apr 20 22:02:18 2015
New Revision: 15117
Log:
Remove SysRes::_valEx from common code as it is specific to mips.
ifdef'ed accordingly.
Modified:
trunk/coregrind/m_syscall.c
trunk/include/pub_tool_basics.h
Modified: trunk/coregrind/m_syscall.c
==============================================================================
--- trunk/coregrind/m_syscall.c (original)
+++ trunk/coregrind/m_syscall.c Mon Apr 20 22:02:18 2015
@@ -62,7 +62,6 @@
SysRes VG_(mk_SysRes_x86_linux) ( Int val ) {
SysRes res;
- res._valEx = 0; /* unused except on mips-linux */
res._isError = val >= -4095 && val <= -1;
if (res._isError) {
res._val = (UInt)(-val);
@@ -75,7 +74,6 @@
/* Similarly .. */
SysRes VG_(mk_SysRes_amd64_linux) ( Long val ) {
SysRes res;
- res._valEx = 0; /* unused except on mips-linux */
res._isError = val >= -4095 && val <= -1;
if (res._isError) {
res._val = (ULong)(-val);
@@ -87,7 +85,6 @@
SysRes VG_(mk_SysRes_tilegx_linux) ( Long val ) {
SysRes res;
- res._valEx = 0; /* unused except on mips-linux */
res._isError = val >= -4095 && val <= -1;
if (res._isError) {
res._val = (ULong)(-val);
@@ -101,7 +98,6 @@
/* Note this must be in the bottom bit of the second arg */
SysRes VG_(mk_SysRes_ppc32_linux) ( UInt val, UInt cr0so ) {
SysRes res;
- res._valEx = 0; /* unused except on mips-linux */
res._isError = (cr0so & 1) != 0;
res._val = val;
return res;
@@ -110,7 +106,6 @@
/* As per ppc32 version, cr0.so must be in l.s.b. of 2nd arg */
SysRes VG_(mk_SysRes_ppc64_linux) ( ULong val, ULong cr0so ) {
SysRes res;
- res._valEx = 0; /* unused except on mips-linux */
res._isError = (cr0so & 1) != 0;
res._val = val;
return res;
@@ -118,7 +113,6 @@
SysRes VG_(mk_SysRes_s390x_linux) ( Long val ) {
SysRes res;
- res._valEx = 0; /* unused except on mips-linux */
res._isError = val >= -4095 && val <= -1;
if (res._isError) {
res._val = -val;
@@ -130,7 +124,6 @@
SysRes VG_(mk_SysRes_arm_linux) ( Int val ) {
SysRes res;
- res._valEx = 0; /* unused except on mips-linux */
res._isError = val >= -4095 && val <= -1;
if (res._isError) {
res._val = (UInt)(-val);
@@ -142,7 +135,6 @@
SysRes VG_(mk_SysRes_arm64_linux) ( Long val ) {
SysRes res;
- res._valEx = 0; /* unused except on mips-linux */
res._isError = val >= -4095 && val <= -1;
if (res._isError) {
res._val = (ULong)(-val);
@@ -152,6 +144,7 @@
return res;
}
+#if defined(VGA_mips64) || defined(VGA_mips32)
/* MIPS uses a3 != 0 to flag an error */
SysRes VG_(mk_SysRes_mips32_linux) ( UWord v0, UWord v1, UWord a3 ) {
SysRes res;
@@ -169,11 +162,14 @@
res._valEx = v1;
return res;
}
+#endif
/* Generic constructors. */
SysRes VG_(mk_SysRes_Error) ( UWord err ) {
SysRes r;
- r._valEx = 0; /* unused except on mips-linux */
+#if defined(VGA_mips64) || defined(VGA_mips32)
+ r._valEx = 0;
+#endif
r._isError = True;
r._val = err;
return r;
@@ -181,7 +177,9 @@
SysRes VG_(mk_SysRes_Success) ( UWord res ) {
SysRes r;
- r._valEx = 0; /* unused except on mips-linux */
+#if defined(VGA_mips64) || defined(VGA_mips32)
+ r._valEx = 0;
+#endif
r._isError = False;
r._val = res;
return r;
Modified: trunk/include/pub_tool_basics.h
==============================================================================
--- trunk/include/pub_tool_basics.h (original)
+++ trunk/include/pub_tool_basics.h Mon Apr 20 22:02:18 2015
@@ -153,9 +153,11 @@
#if defined(VGO_linux)
typedef
struct {
- UWord _val;
- UWord _valEx; // only used on mips-linux
Bool _isError;
+ UWord _val;
+#if defined(VGA_mips64) || defined(VGA_mips32)
+ UWord _valEx;
+#endif
}
SysRes;
#elif defined(VGO_darwin)
@@ -189,15 +191,17 @@
static inline UWord sr_Res ( SysRes sr ) {
return sr._isError ? 0 : sr._val;
}
+#if defined(VGA_mips64) || defined(VGA_mips32)
static inline UWord sr_ResEx ( SysRes sr ) {
return sr._isError ? 0 : sr._valEx;
}
+#endif
static inline UWord sr_Err ( SysRes sr ) {
return sr._isError ? sr._val : 0;
}
+// FIXME: this function needs to be fixed for MIPS
static inline Bool sr_EQ ( SysRes sr1, SysRes sr2 ) {
return sr1._val == sr2._val
- && sr1._valEx == sr2._valEx
&& sr1._isError == sr2._isError;
}
|
Author: florian
Date: Mon Apr 20 21:42:42 2015
New Revision: 15116
Log:
Remove function sr_ResHI from Linux specific code.
Add function VG_(sr_as_string).
Modified:
trunk/coregrind/m_libcprint.c
trunk/coregrind/m_syswrap/priv_types_n_macros.h
trunk/coregrind/m_syswrap/syswrap-main.c
trunk/include/pub_tool_basics.h
trunk/include/pub_tool_libcprint.h
Modified: trunk/coregrind/m_libcprint.c
==============================================================================
--- trunk/coregrind/m_libcprint.c (original)
+++ trunk/coregrind/m_libcprint.c Mon Apr 20 21:42:42 2015
@@ -643,6 +643,44 @@
VG_(exit)(1);
}
+/* ---------------------------------------------------------------------
+ VG_(sr_as_string)()
+ ------------------------------------------------------------------ */
+
+/* Return a textual representation of a SysRes value in a statically
+ allocated buffer. The buffer will be overwritten with the next
+ invocation. */
+#if defined(VGO_linux)
+// FIXME: Does this function need to be adjusted for MIPS's _valEx ?
+const HChar *VG_(sr_as_string) ( SysRes sr )
+{
+ static HChar buf[7+1+2+16+1+1]; // large enough
+
+ if (sr_isError(sr))
+ VG_(sprintf)(buf, "Failure(0x%lx)", sr_Err(sr));
+ else
+ VG_(sprintf)(buf, "Success(0x%lx)", sr_Res(sr));
+ return buf;
+}
+
+#elif defined(VGO_darwin)
+
+const HChar *VG_(sr_as_string) ( SysRes sr )
+{
+ static HChar buf[7+1+2+16+1+2+16+1+1]; // large enough
+
+ if (sr_isError(sr))
+ VG_(sprintf)(buf, "Failure(0x%lx)", sr_Err(sr));
+ else
+ VG_(sprintf)(buf, "Success(0x%lx:0x%lx)", sr_ResHI(sr), sr_Res(sr));
+ return buf;
+}
+
+#else
+
+#error unknown OS
+
+#endif
/*--------------------------------------------------------------------*/
/*--- end ---*/
Modified: trunk/coregrind/m_syswrap/priv_types_n_macros.h
==============================================================================
--- trunk/coregrind/m_syswrap/priv_types_n_macros.h (original)
+++ trunk/coregrind/m_syswrap/priv_types_n_macros.h Mon Apr 20 21:42:42 2015
@@ -331,11 +331,13 @@
return sr_Res(st->sres);
}
+#if defined(VGO_darwin)
static inline UWord getRESHI ( SyscallStatus* st ) {
vg_assert(st->what == SsComplete);
vg_assert(!sr_isError(st->sres));
return sr_ResHI(st->sres);
}
+#endif
static inline UWord getERR ( SyscallStatus* st ) {
vg_assert(st->what == SsComplete);
Modified: trunk/coregrind/m_syswrap/syswrap-main.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-main.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-main.c Mon Apr 20 21:42:42 2015
@@ -1669,9 +1669,7 @@
if (sci->flags & SfNoWriteResult) {
PRINT(" --> [pre-success] NoWriteResult");
} else {
- PRINT(" --> [pre-success] Success(0x%llx:0x%llx)",
- (ULong)sr_ResHI(sci->status.sres),
- (ULong)sr_Res(sci->status.sres));
+ PRINT(" --> [pre-success] %s", VG_(sr_as_string)(sci->status.sres));
}
/* In this case the allowable flags are to ask for a signal-poll
and/or a yield after the call. Changing the args isn't
@@ -1684,7 +1682,7 @@
else
if (sci->status.what == SsComplete && sr_isError(sci->status.sres)) {
/* The pre-handler decided to fail syscall itself. */
- PRINT(" --> [pre-fail] Failure(0x%llx)", (ULong)sr_Err(sci->status.sres));
+ PRINT(" --> [pre-fail] %s", VG_(sr_as_string)(sci->status.sres));
/* In this case, the pre-handler is also allowed to ask for the
post-handler to be run anyway. Changing the args is not
allowed. */
@@ -1769,18 +1767,9 @@
/* Be decorative, if required. */
if (VG_(clo_trace_syscalls)) {
- Bool failed = sr_isError(sci->status.sres);
- if (failed) {
- PRINT("SYSCALL[%d,%d](%s) ... [async] --> Failure(0x%llx)",
- VG_(getpid)(), tid, VG_SYSNUM_STRING(sysno),
- (ULong)sr_Err(sci->status.sres));
- } else {
- PRINT("SYSCALL[%d,%d](%s) ... [async] --> "
- "Success(0x%llx:0x%llx)",
- VG_(getpid)(), tid, VG_SYSNUM_STRING(sysno),
- (ULong)sr_ResHI(sci->status.sres),
- (ULong)sr_Res(sci->status.sres) );
- }
+ PRINT("SYSCALL[%d,%d](%s) ... [async] --> %s",
+ VG_(getpid)(), tid, VG_SYSNUM_STRING(sysno),
+ VG_(sr_as_string)(sci->status.sres));
}
} else {
@@ -1800,15 +1789,7 @@
/* Be decorative, if required. */
if (VG_(clo_trace_syscalls)) {
- Bool failed = sr_isError(sci->status.sres);
- if (failed) {
- PRINT("[sync] --> Failure(0x%llx)",
- (ULong)sr_Err(sci->status.sres) );
- } else {
- PRINT("[sync] --> Success(0x%llx:0x%llx)",
- (ULong)sr_ResHI(sci->status.sres),
- (ULong)sr_Res(sci->status.sres) );
- }
+ PRINT("[sync] --> %s", VG_(sr_as_string)(sci->status.sres));
}
}
}
Modified: trunk/include/pub_tool_basics.h
==============================================================================
--- trunk/include/pub_tool_basics.h (original)
+++ trunk/include/pub_tool_basics.h Mon Apr 20 21:42:42 2015
@@ -192,9 +192,6 @@
static inline UWord sr_ResEx ( SysRes sr ) {
return sr._isError ? 0 : sr._valEx;
}
-static inline UWord sr_ResHI ( SysRes sr ) {
- return 0;
-}
static inline UWord sr_Err ( SysRes sr ) {
return sr._isError ? sr._val : 0;
}
Modified: trunk/include/pub_tool_libcprint.h
==============================================================================
--- trunk/include/pub_tool_libcprint.h (original)
+++ trunk/include/pub_tool_libcprint.h Mon Apr 20 21:42:42 2015
@@ -154,6 +154,9 @@
/* Flush any output cached by previous calls to VG_(message) et al. */
extern void VG_(message_flush) ( void );
+/* Return a SysRes value as a character string. */
+extern const HChar *VG_(sr_as_string) ( SysRes sr );
+
#endif // __PUB_TOOL_LIBCPRINT_H
/*--------------------------------------------------------------------*/
|
|
From: <sv...@va...> - 2015-04-20 17:00:10
|
Author: florian
Date: Mon Apr 20 18:00:02 2015
New Revision: 15115
Log:
Update tilegx's do_clone function adopting the stack bound changes
made in r14392.
Modified:
trunk/coregrind/m_syswrap/syswrap-tilegx-linux.c
Modified: trunk/coregrind/m_syswrap/syswrap-tilegx-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-tilegx-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-tilegx-linux.c Mon Apr 20 18:00:02 2015
@@ -337,7 +337,6 @@
ThreadState * ctst = VG_ (get_ThreadState) (ctid);
Long ret = 0;
Long * stack;
- NSegment const *seg;
SysRes res;
vki_sigset_t blockall, savedmask;
@@ -372,22 +371,7 @@
See #226116. */
ctst->os_state.threadgroup = ptst->os_state.threadgroup;
- seg = VG_ (am_find_nsegment) ((Addr) sp);
-
- if (seg && seg->kind != SkResvn) {
- ctst->client_stack_highest_byte = (Addr) VG_PGROUNDUP (sp);
- ctst->client_stack_szB = ctst->client_stack_highest_byte - seg->start;
- VG_ (register_stack) (seg->start, ctst->client_stack_highest_byte);
- if (debug)
- VG_ (printf) ("tid %d: guessed client stack range %#lx-%#lx\n",
-
- ctid, seg->start, VG_PGROUNDUP (sp));
- } else {
- VG_ (message) (Vg_UserMsg,
- "!? New thread %d starts with sp+%#lx) unmapped\n",
- ctid, sp);
- ctst->client_stack_szB = 0;
- }
+ ML_(guess_and_register_stack) (sp, ctst);
VG_TRACK (pre_thread_ll_create, ptid, ctid);
if (flags & VKI_CLONE_SETTLS) {
|
|
From: Julian S. <js...@ac...> - 2015-04-20 13:05:34
|
>> Your yesterday's change r15060 breaks MIPS port in general, > as comparing _valEx will fail immediately. > > MIPS support has been broken in trunk for two weeks. Does anyone > have a fix for this incoming? Maybe it should be posted as a bug > in the tracker. Perhaps it would be wise to back out 15060 until such time as it gets fixed properly, and at the same time file a bug in the tracker for the underlying problem. J |
|
From: Crestez D. L. <cdl...@gm...> - 2015-04-20 12:34:02
|
On 04/03/2015 05:14 AM, Petar Jovanovic wrote: > Hi Florian, > > Sorry for not responding to this earlier. > Field _valEx is used on MIPS only for pipe system call when kernel can return an array of two file descriptors. Otherwise, this field is undefined (actually, it has a value that happened to be in v1 register, which can be an arbitrary value and it is not deterministic). Thus, comparing _valEx does not make sense for an arbitrary SysRes. > > Your yesterday's change r15060 breaks MIPS port in general, as comparing _valEx will fail immediately. MIPS support has been broken in trunk for two weeks. Does anyone have a fix for this incoming? Maybe it should be posted as a bug in the tracker. It's not clear how valEx should be treated for syscalls other than pipe() since it's left undefined by the linux syscall ABI. I think that simply defining that all other syscalls return zero in valEx would be an acceptable solution. Regards, Leonard |
|
From: Liming S. <ls...@ez...> - 2015-04-20 01:01:01
|
I ran a quick test. The regression result is about the same as before. It looks safe to check in the patch...
Thanks,
Liming
________________________________________
From: Florian Krohm <fl...@ei...>
Sent: Saturday, April 18, 2015 2:30 PM
To: Zhigang Liu
Cc: Valgrind Developers
Subject: [Valgrind-developers] tilegx: do_clone() stack guessing and registration
I noticed that the do_clone function in syswrap-tilegx-linux.c
does its own stack guessing and registration instead of using
the generic ML_(guess_and_register_stack) function which is
used by all other archs for that purpose. If at all possible
we should strive to use the generic code unless there is a *really*
good reason not to..
Looking at your code I see some subtle differences and am wondering
whether those are correct:
tilegx code:
ctst->client_stack_highest_byte = (Addr) VG_PGROUNDUP (sp);
ctst->client_stack_szB = ctst->client_stack_highest_byte - seg->start;
generic code:
tst->client_stack_highest_byte = (Addr)VG_PGROUNDUP(sp)-1;
tst->client_stack_szB = tst->client_stack_highest_byte - seg->start + 1;
That looks like an off-by-one error to me. Could you elaborate?
I'm thinking about the patch below.
Florian
Index: coregrind/m_syswrap/syswrap-tilegx-linux.c
===================================================================
--- coregrind/m_syswrap/syswrap-tilegx-linux.c (revision 15111)
+++ coregrind/m_syswrap/syswrap-tilegx-linux.c (working copy)
@@ -337,7 +337,6 @@
ThreadState * ctst = VG_ (get_ThreadState) (ctid);
Long ret = 0;
Long * stack;
- NSegment const *seg;
SysRes res;
vki_sigset_t blockall, savedmask;
@@ -372,23 +371,8 @@
See #226116. */
ctst->os_state.threadgroup = ptst->os_state.threadgroup;
- seg = VG_ (am_find_nsegment) ((Addr) sp);
+ ML_(guess_and_register_stack) (sp, ctst);
- if (seg && seg->kind != SkResvn) {
- ctst->client_stack_highest_byte = (Addr) VG_PGROUNDUP (sp);
- ctst->client_stack_szB = ctst->client_stack_highest_byte - seg->start;
- VG_ (register_stack) (seg->start, ctst->client_stack_highest_byte);
- if (debug)
- VG_ (printf) ("tid %d: guessed client stack range %#lx-%#lx\n",
-
- ctid, seg->start, VG_PGROUNDUP (sp));
- } else {
- VG_ (message) (Vg_UserMsg,
- "!? New thread %d starts with sp+%#lx) unmapped\n",
- ctid, sp);
- ctst->client_stack_szB = 0;
- }
-
VG_TRACK (pre_thread_ll_create, ptid, ctid);
if (flags & VKI_CLONE_SETTLS) {
if (debug)
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Valgrind-developers mailing list
Val...@li...
https://lists.sourceforge.net/lists/listinfo/valgrind-developers
|
|
From: <sv...@va...> - 2015-04-19 17:56:50
|
Author: philippe
Date: Sun Apr 19 18:56:42 2015
New Revision: 15114
Log:
Ensure we print the memory statistics with the default verbosity,
when giving --stats=yes
Modified:
trunk/coregrind/m_main.c
Modified: trunk/coregrind/m_main.c
==============================================================================
--- trunk/coregrind/m_main.c (original)
+++ trunk/coregrind/m_main.c Sun Apr 19 18:56:42 2015
@@ -2628,7 +2628,7 @@
VG_(sanity_check_general)( True /*include expensive checks*/ );
if (VG_(clo_stats))
- VG_(print_all_stats)(VG_(clo_verbosity) > 2, /* Memory stats */
+ VG_(print_all_stats)(VG_(clo_verbosity) >= 1, /* Memory stats */
False /* tool prints stats in the tool fini */);
/* Show a profile of the heap(s) at shutdown. Optionally, first
|
|
From: <sv...@va...> - 2015-04-19 15:44:01
|
Author: philippe
Date: Sun Apr 19 16:43:53 2015
New Revision: 15113
Log:
For ppc64, use the endianess of the running program, rather
than an harcoded endness.
(this is because ppc64 supports 2 endness, decided at runtime)
For mips, use BE if running on a non mips system, otherwise
use the endness of the running program
(this is because mips supports 2 endness, but decided at compile time).
Modified:
trunk/none/tests/libvex_test.c
Modified: trunk/none/tests/libvex_test.c
==============================================================================
--- trunk/none/tests/libvex_test.c (original)
+++ trunk/none/tests/libvex_test.c Sun Apr 19 16:43:53 2015
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <endian.h>
#include "../../VEX/pub/libvex.h"
Bool return_false(void*cb, Addr ad)
@@ -33,6 +34,49 @@
printf("%*s", (int)nbytes, chars);
}
+// Returns the endness of the system we are running on.
+// We use that as the endness of arch that supports both
+// little and big endian.
+static VexEndness running_endness (void)
+{
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ return VexEndnessLE;
+#elif __BYTE_ORDER == __BIG_ENDIAN
+ return VexEndnessBE;
+#else
+ fprintf(stderr, "cannot determine endianess\n");
+ exit(1);
+#endif
+}
+
+// noinline, as this function is also the one we decode.
+__attribute__((noinline)) static void get_guest_arch(VexArch *ga)
+{
+#if defined(VGA_x86)
+ *ga = VexArchX86;
+#elif defined(VGA_amd64)
+ *ga = VexArchAMD64;
+#elif defined(VGA_arm)
+ *ga = VexArchARM;
+#elif defined(VGA_arm64)
+ *ga = VexArchARM64;
+#elif defined(VGA_ppc32)
+ *ga = VexArchPPC32;
+#elif defined(VGA_ppc64be) || defined(VGA_ppc64le)
+ *ga = VexArchPPC64;
+#elif defined(VGA_s390x)
+ *ga = VexArchS390X;
+#elif defined(VGA_mips32)
+ *ga = VexArchMIPS32;
+#elif defined(VGA_mips64)
+ *ga = VexArchMIPS64;
+#elif defined(VGA_tilegx)
+ *ga = VexArchTILEGX;
+#else
+ missing arch;
+#endif
+}
+
static VexEndness arch_endness (VexArch va) {
switch (va) {
case VexArch_INVALID: failure_exit();
@@ -41,10 +85,29 @@
case VexArchARM: return VexEndnessLE;
case VexArchARM64: return VexEndnessLE;
case VexArchPPC32: return VexEndnessBE;
- case VexArchPPC64: return VexEndnessBE;
+ case VexArchPPC64:
+ /* ppc64 supports BE or LE at run time. So, on a LE system,
+ returns LE, on a BE system, return BE. */
+ return running_endness();
case VexArchS390X: return VexEndnessBE;
- case VexArchMIPS32: return VexEndnessBE;
- case VexArchMIPS64: return VexEndnessBE;
+ case VexArchMIPS32:
+ case VexArchMIPS64:
+ /* mips32/64 supports BE or LE, but at compile time.
+ If mips64 is compiled on a non mips system, the VEX lib
+ is missing bit and pieces of code related to endianess.
+ The mandatory code for this test is then compiled as BE.
+ So, if this test runs on a mips system, returns the
+ running endianess. Otherwise, returns BE as this one
+ has the more chances to work. */
+ {
+ VexArch ga;
+ get_guest_arch( &ga);
+
+ if (ga == VexArchMIPS64 || ga == VexArchMIPS32)
+ return running_endness();
+ else
+ return VexEndnessBE;
+ }
case VexArchTILEGX: return VexEndnessLE;
default: failure_exit();
}
@@ -86,34 +149,6 @@
}
}
-// noinline, as this function is also the one we decode.
-__attribute__((noinline)) void get_guest_arch(VexArch *ga)
-{
-#if defined(VGA_x86)
- *ga = VexArchX86;
-#elif defined(VGA_amd64)
- *ga = VexArchAMD64;
-#elif defined(VGA_arm)
- *ga = VexArchARM;
-#elif defined(VGA_arm64)
- *ga = VexArchARM64;
-#elif defined(VGA_ppc32)
- *ga = VexArchPPC32;
-#elif defined(VGA_ppc64be) || defined(VGA_ppc64le)
- *ga = VexArchPPC64;
-#elif defined(VGA_s390x)
- *ga = VexArchS390X;
-#elif defined(VGA_mips32)
- *ga = VexArchMIPS32;
-#elif defined(VGA_mips64)
- *ga = VexArchMIPS64;
-#elif defined(VGA_tilegx)
- *ga = VexArchTILEGX;
-#else
- missing arch;
-#endif
-}
-
static void show_vta(char *msg, VexTranslateArgs *vta)
{
printf("//// %s translating guest %s(%d) %s %dbits to host %s(%d)"
|
|
From: Patrick J. L. <lop...@gm...> - 2015-04-19 14:58:04
|
On Sat, Apr 18, 2015 at 3:47 AM, Florian Krohm <fl...@ei...> wrote: > > What you describe would work but require additional configury. And that > is something I would like to avoid. We already have 3000 lines of it. > If will be less work to simply modify the test to not pass these values > as function arguments. Assuming that is possible, I agree. Although even that demands cluttering the source with a long comment if the needed approach is unnatural. When it is impossible or inconvenient to modify the source, the approach I have seen is to place all such warning suppressions in one header file. And then dispatch on the compiler version in that header (not in the configure script). Something like <http://stackoverflow.com/a/18463996/768469>. This approach keeps the source uncluttered, and it adds little to the testing burden since (a) it is simple enough to get right every time and (b) these are just warning suppressions. This is part of the cost of keeping everything "-Wall clean" across multiple platforms. But it is not a large cost compared to the benefits. - Pat |
|
From: <sv...@va...> - 2015-04-19 12:39:41
|
Author: philippe
Date: Sun Apr 19 13:39:33 2015
New Revision: 15112
Log:
fix 346307 fuse filesystem syscall deadlocks
Mark 2 additional syscalls as 'mayblock' when fuse-compatible hint
is given.
Patch from aoz...@ra...
Modified:
trunk/NEWS
trunk/coregrind/m_syswrap/syswrap-generic.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sun Apr 19 13:39:33 2015
@@ -149,6 +149,7 @@
345016 helgrind/tests/locked_vs_unlocked2 is failing sometimes
345394 Fix memcheck/tests/strchr on OS X
345637 Fix memcheck/tests/sendmsg on OS X
+346307 fuse filesystem syscall deadlocks
n-i-bz Provide implementations of certain compiler builtins to support
compilers who may not provide those
n-i-bz Old STABS code is still being compiled, but never used. Remove it.
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-generic.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c Sun Apr 19 13:39:33 2015
@@ -4175,6 +4175,7 @@
PRE(sys_newstat)
{
+ FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_newstat ( %#lx(%s), %#lx )", ARG1,(char*)ARG1,ARG2);
PRE_REG_READ2(long, "stat", char *, file_name, struct stat *, buf);
PRE_MEM_RASCIIZ( "stat(file_name)", ARG1 );
@@ -4188,6 +4189,7 @@
PRE(sys_statfs)
{
+ FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_statfs ( %#lx(%s), %#lx )",ARG1,(char*)ARG1,ARG2);
PRE_REG_READ2(long, "statfs", const char *, path, struct statfs *, buf);
PRE_MEM_RASCIIZ( "statfs(path)", ARG1 );
|
|
From: Philippe W. <phi...@sk...> - 2015-04-19 12:29:25
|
On Sat, 2015-04-18 at 20:30 +0200, Florian Krohm wrote:
> I noticed that the do_clone function in syswrap-tilegx-linux.c
> does its own stack guessing and registration instead of using
> the generic ML_(guess_and_register_stack) function which is
> used by all other archs for that purpose. If at all possible
> we should strive to use the generic code unless there is a *really*
> good reason not to..
As I understood, the tilegx arch development was done
in the era of valgrind 3.7 or so. At that time
the semantic of stack boundary (bound included or not)
was not consistent/documented.
The semantic was documented and made systematic in r14392 in 2014.
I guess this change was not tracked in the tilegx.
The common/consistent/documented semantic should also be used
for tilegx.
So, the patch below looks a good idea.
Philippe
>
> Looking at your code I see some subtle differences and am wondering
> whether those are correct:
>
> tilegx code:
>
> ctst->client_stack_highest_byte = (Addr) VG_PGROUNDUP (sp);
> ctst->client_stack_szB = ctst->client_stack_highest_byte - seg->start;
>
> generic code:
>
> tst->client_stack_highest_byte = (Addr)VG_PGROUNDUP(sp)-1;
> tst->client_stack_szB = tst->client_stack_highest_byte - seg->start + 1;
>
> That looks like an off-by-one error to me. Could you elaborate?
>
> I'm thinking about the patch below.
>
> Florian
>
> Index: coregrind/m_syswrap/syswrap-tilegx-linux.c
> ===================================================================
> --- coregrind/m_syswrap/syswrap-tilegx-linux.c (revision 15111)
> +++ coregrind/m_syswrap/syswrap-tilegx-linux.c (working copy)
> @@ -337,7 +337,6 @@
> ThreadState * ctst = VG_ (get_ThreadState) (ctid);
> Long ret = 0;
> Long * stack;
> - NSegment const *seg;
> SysRes res;
> vki_sigset_t blockall, savedmask;
>
> @@ -372,23 +371,8 @@
> See #226116. */
>
> ctst->os_state.threadgroup = ptst->os_state.threadgroup;
> - seg = VG_ (am_find_nsegment) ((Addr) sp);
> + ML_(guess_and_register_stack) (sp, ctst);
>
> - if (seg && seg->kind != SkResvn) {
> - ctst->client_stack_highest_byte = (Addr) VG_PGROUNDUP (sp);
> - ctst->client_stack_szB = ctst->client_stack_highest_byte - seg->start;
> - VG_ (register_stack) (seg->start, ctst->client_stack_highest_byte);
> - if (debug)
> - VG_ (printf) ("tid %d: guessed client stack range %#lx-%#lx\n",
> -
> - ctid, seg->start, VG_PGROUNDUP (sp));
> - } else {
> - VG_ (message) (Vg_UserMsg,
> - "!? New thread %d starts with sp+%#lx) unmapped\n",
> - ctid, sp);
> - ctst->client_stack_szB = 0;
> - }
> -
> VG_TRACK (pre_thread_ll_create, ptid, ctid);
> if (flags & VKI_CLONE_SETTLS) {
> if (debug)
>
> ------------------------------------------------------------------------------
> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> Develop your own process in accordance with the BPMN 2 standard
> Learn Process modeling best practices with Bonita BPM through live exercises
> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
> _______________________________________________
> Valgrind-developers mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-developers
|
|
From: Florian K. <fl...@ei...> - 2015-04-18 18:30:24
|
I noticed that the do_clone function in syswrap-tilegx-linux.c
does its own stack guessing and registration instead of using
the generic ML_(guess_and_register_stack) function which is
used by all other archs for that purpose. If at all possible
we should strive to use the generic code unless there is a *really*
good reason not to..
Looking at your code I see some subtle differences and am wondering
whether those are correct:
tilegx code:
ctst->client_stack_highest_byte = (Addr) VG_PGROUNDUP (sp);
ctst->client_stack_szB = ctst->client_stack_highest_byte - seg->start;
generic code:
tst->client_stack_highest_byte = (Addr)VG_PGROUNDUP(sp)-1;
tst->client_stack_szB = tst->client_stack_highest_byte - seg->start + 1;
That looks like an off-by-one error to me. Could you elaborate?
I'm thinking about the patch below.
Florian
Index: coregrind/m_syswrap/syswrap-tilegx-linux.c
===================================================================
--- coregrind/m_syswrap/syswrap-tilegx-linux.c (revision 15111)
+++ coregrind/m_syswrap/syswrap-tilegx-linux.c (working copy)
@@ -337,7 +337,6 @@
ThreadState * ctst = VG_ (get_ThreadState) (ctid);
Long ret = 0;
Long * stack;
- NSegment const *seg;
SysRes res;
vki_sigset_t blockall, savedmask;
@@ -372,23 +371,8 @@
See #226116. */
ctst->os_state.threadgroup = ptst->os_state.threadgroup;
- seg = VG_ (am_find_nsegment) ((Addr) sp);
+ ML_(guess_and_register_stack) (sp, ctst);
- if (seg && seg->kind != SkResvn) {
- ctst->client_stack_highest_byte = (Addr) VG_PGROUNDUP (sp);
- ctst->client_stack_szB = ctst->client_stack_highest_byte - seg->start;
- VG_ (register_stack) (seg->start, ctst->client_stack_highest_byte);
- if (debug)
- VG_ (printf) ("tid %d: guessed client stack range %#lx-%#lx\n",
-
- ctid, seg->start, VG_PGROUNDUP (sp));
- } else {
- VG_ (message) (Vg_UserMsg,
- "!? New thread %d starts with sp+%#lx) unmapped\n",
- ctid, sp);
- ctst->client_stack_szB = 0;
- }
-
VG_TRACK (pre_thread_ll_create, ptid, ctid);
if (flags & VKI_CLONE_SETTLS) {
if (debug)
|
|
From: <sv...@va...> - 2015-04-18 17:45:42
|
Author: florian
Date: Sat Apr 18 18:45:34 2015
New Revision: 15111
Log:
Remove a few unneeded header files.
Modified:
trunk/coregrind/m_syswrap/syswrap-amd64-darwin.c
trunk/coregrind/m_syswrap/syswrap-amd64-linux.c
trunk/coregrind/m_syswrap/syswrap-arm-linux.c
trunk/coregrind/m_syswrap/syswrap-arm64-linux.c
trunk/coregrind/m_syswrap/syswrap-darwin.c
trunk/coregrind/m_syswrap/syswrap-generic.c
trunk/coregrind/m_syswrap/syswrap-linux-variants.c
trunk/coregrind/m_syswrap/syswrap-linux.c
trunk/coregrind/m_syswrap/syswrap-main.c
trunk/coregrind/m_syswrap/syswrap-mips32-linux.c
trunk/coregrind/m_syswrap/syswrap-mips64-linux.c
trunk/coregrind/m_syswrap/syswrap-ppc32-linux.c
trunk/coregrind/m_syswrap/syswrap-ppc64-linux.c
trunk/coregrind/m_syswrap/syswrap-s390x-linux.c
trunk/coregrind/m_syswrap/syswrap-tilegx-linux.c
trunk/coregrind/m_syswrap/syswrap-x86-darwin.c
trunk/coregrind/m_syswrap/syswrap-x86-linux.c
trunk/coregrind/m_syswrap/syswrap-xen.c
Modified: trunk/coregrind/m_syswrap/syswrap-amd64-darwin.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-amd64-darwin.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-amd64-darwin.c Sat Apr 18 18:45:34 2015
@@ -33,7 +33,6 @@
#include "config.h" // DARWIN_VERS
#include "pub_core_basics.h"
#include "pub_core_vki.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_xarray.h"
Modified: trunk/coregrind/m_syswrap/syswrap-amd64-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-amd64-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-amd64-linux.c Sat Apr 18 18:45:34 2015
@@ -33,7 +33,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
@@ -49,7 +48,6 @@
#include "pub_core_syscall.h"
#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
-#include "pub_core_stacks.h" // VG_(register_stack)
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h" /* for decls of generic wrappers */
Modified: trunk/coregrind/m_syswrap/syswrap-arm-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-arm-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-arm-linux.c Sat Apr 18 18:45:34 2015
@@ -35,7 +35,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
@@ -51,7 +50,6 @@
#include "pub_core_syscall.h"
#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
-#include "pub_core_stacks.h" // VG_(register_stack)
#include "pub_core_transtab.h" // VG_(discard_translations)
#include "priv_types_n_macros.h"
Modified: trunk/coregrind/m_syswrap/syswrap-arm64-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-arm64-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-arm64-linux.c Sat Apr 18 18:45:34 2015
@@ -33,29 +33,22 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
-//ZZ #include "pub_core_debuglog.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcprint.h"
-//ZZ #include "pub_core_libcproc.h"
#include "pub_core_libcsignal.h"
#include "pub_core_options.h"
#include "pub_core_scheduler.h"
#include "pub_core_sigframe.h" // For VG_(sigframe_destroy)()
-//ZZ #include "pub_core_signals.h"
#include "pub_core_syscall.h"
#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
-#include "pub_core_stacks.h" // VG_(register_stack)
-//ZZ #include "pub_core_transtab.h" // VG_(discard_translations)
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h" /* for decls of generic wrappers */
#include "priv_syswrap-linux.h" /* for decls of linux-ish wrappers */
-//ZZ #include "priv_syswrap-main.h"
/* ---------------------------------------------------------------------
Modified: trunk/coregrind/m_syswrap/syswrap-darwin.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-darwin.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-darwin.c Sat Apr 18 18:45:34 2015
@@ -33,7 +33,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_xarray.h"
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-generic.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c Sat Apr 18 18:45:34 2015
@@ -35,7 +35,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_debuginfo.h" // VG_(di_notify_*)
#include "pub_core_aspacemgr.h"
Modified: trunk/coregrind/m_syswrap/syswrap-linux-variants.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-linux-variants.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-linux-variants.c Sat Apr 18 18:45:34 2015
@@ -48,7 +48,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuginfo.h" // VG_(di_notify_*)
Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c Sat Apr 18 18:45:34 2015
@@ -33,7 +33,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuginfo.h" // VG_(di_notify_*)
Modified: trunk/coregrind/m_syswrap/syswrap-main.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-main.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-main.c Sat Apr 18 18:45:34 2015
@@ -34,7 +34,6 @@
#include "pub_core_aspacemgr.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
Modified: trunk/coregrind/m_syswrap/syswrap-mips32-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-mips32-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-mips32-linux.c Sat Apr 18 18:45:34 2015
@@ -32,7 +32,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
@@ -48,7 +47,6 @@
#include "pub_core_syscall.h"
#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
-#include "pub_core_stacks.h" // VG_(register_stack)
#include "pub_core_transtab.h" // VG_(discard_translations)
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h" /* for decls of generic wrappers */
Modified: trunk/coregrind/m_syswrap/syswrap-mips64-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-mips64-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-mips64-linux.c Sat Apr 18 18:45:34 2015
@@ -32,7 +32,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" /* to keep _threadstate.h happy */
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
@@ -48,7 +47,6 @@
#include "pub_core_syscall.h"
#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
-#include "pub_core_stacks.h" /* VG_(register_stack) */
#include "pub_core_transtab.h" /* VG_(discard_translations) */
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h" /* for decls of generic wrappers */
Modified: trunk/coregrind/m_syswrap/syswrap-ppc32-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-ppc32-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-ppc32-linux.c Sat Apr 18 18:45:34 2015
@@ -33,7 +33,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
@@ -49,7 +48,6 @@
#include "pub_core_syscall.h"
#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
-#include "pub_core_stacks.h" // VG_(register_stack)
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h" /* for decls of generic wrappers */
Modified: trunk/coregrind/m_syswrap/syswrap-ppc64-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-ppc64-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-ppc64-linux.c Sat Apr 18 18:45:34 2015
@@ -33,7 +33,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
@@ -49,7 +48,6 @@
#include "pub_core_syscall.h"
#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
-#include "pub_core_stacks.h" // VG_(register_stack)
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h" /* for decls of generic wrappers */
Modified: trunk/coregrind/m_syswrap/syswrap-s390x-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-s390x-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-s390x-linux.c Sat Apr 18 18:45:34 2015
@@ -34,7 +34,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
@@ -51,7 +50,6 @@
#include "pub_core_syscall.h"
#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
-#include "pub_core_stacks.h" // VG_(register_stack)
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h" /* for decls of generic wrappers */
Modified: trunk/coregrind/m_syswrap/syswrap-tilegx-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-tilegx-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-tilegx-linux.c Sat Apr 18 18:45:34 2015
@@ -33,7 +33,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
Modified: trunk/coregrind/m_syswrap/syswrap-x86-darwin.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-x86-darwin.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-x86-darwin.c Sat Apr 18 18:45:34 2015
@@ -32,7 +32,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_xarray.h"
Modified: trunk/coregrind/m_syswrap/syswrap-x86-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-x86-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-x86-linux.c Sat Apr 18 18:45:34 2015
@@ -38,7 +38,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
@@ -55,7 +54,6 @@
#include "pub_core_syscall.h"
#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
-#include "pub_core_stacks.h" // VG_(register_stack)
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h" /* for decls of generic wrappers */
Modified: trunk/coregrind/m_syswrap/syswrap-xen.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-xen.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-xen.c Sat Apr 18 18:45:34 2015
@@ -34,7 +34,6 @@
#if defined(ENABLE_XEN)
#include "pub_core_vkiscnums.h"
-#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuginfo.h" // VG_(di_notify_*)
|
|
From: <sv...@va...> - 2015-04-18 17:41:38
|
Author: florian
Date: Sat Apr 18 18:41:31 2015
New Revision: 15110
Log:
Fix a comment.
Modified:
trunk/coregrind/pub_core_threadstate.h
Modified: trunk/coregrind/pub_core_threadstate.h
==============================================================================
--- trunk/coregrind/pub_core_threadstate.h (original)
+++ trunk/coregrind/pub_core_threadstate.h Sat Apr 18 18:41:31 2015
@@ -42,7 +42,7 @@
#include "pub_tool_threadstate.h"
#include "pub_core_libcsetjmp.h" // VG_MINIMAL_JMP_BUF
#include "pub_core_vki.h" // vki_sigset_t
-#include "pub_core_guest.h" // VexGuestAMD64State etc.
+#include "pub_core_guest.h" // VexGuestArchState
#include "libvex.h" // LibVEX_N_SPILL_BYTES
|
|
From: Florian K. <fl...@ei...> - 2015-04-18 10:47:29
|
On 17.04.2015 17:57, Patrick J. LoPresti wrote: > On Thu, Apr 16, 2015 at 11:31 AM, Carl E. Love <ce...@us...> wrote: >> >> >> There is nothing that can be done at the source code level to eliminate the notice from the compiler. > > Really? Glancing through the GCC source, it looks like: > > #pragma GCC diagnostic ignored "-Wpsabi" > > ...should do the trick. Or just pass "-Wno-psabi" on the command line. > (Or am I missing something?) > > Probably should be conditional on GCC version, of course. What you describe would work but require additional configury. And that is something I would like to avoid. We already have 3000 lines of it. If will be less work to simply modify the test to not pass these values as function arguments. Perhaps just pass a pointer instead or bundle the function arguments in a struct and pass a pointer to that or ..... Florian |
|
From: Florian K. <fl...@ei...> - 2015-04-18 10:35:36
|
On 17.04.2015 12:57, Julian Seward wrote: > On 17/04/15 12:47, Florian Krohm wrote: > >> Now, looking at the linux side of things: >> >> VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB, >> size + VG_STACK_REDZONE_SZB, tid ); >> >> With your above argument (which is platform neutral), this does not look >> right either. > > I agree. It might be one of those things which has always been wrong, but > which nobody really noticed until now. > > If you're amenable to it, I'd suggest to use simply |size| in the new > merged-up version. If we get it wrong somehow, the worst that can happen > is that we'll get flooded with false positive errors in signal handlers > and we'll soon know something isn't right. So it's a low-risk change IMO. > r15109. Regtested on x86-64, s390, ppc64 Florian |
|
From: <sv...@va...> - 2015-04-18 10:34:03
|
Author: florian
Date: Sat Apr 18 11:33:54 2015
New Revision: 15109
Log:
Factor out the 'extend' function. We only need one version for Linux and
one for Darwin. Down from 11.
Carve out a new function 'track_frame_memory' that communicates to the
tool the allocation of a new stack frame. This was slightly different on
Linux and Darwin but should be the same on both platforms.
New files: priv_sigframe.h and sigframe-common.c
Added:
trunk/coregrind/m_sigframe/priv_sigframe.h
trunk/coregrind/m_sigframe/sigframe-common.c
Modified:
trunk/coregrind/Makefile.am
trunk/coregrind/m_sigframe/sigframe-amd64-darwin.c
trunk/coregrind/m_sigframe/sigframe-amd64-linux.c
trunk/coregrind/m_sigframe/sigframe-arm-linux.c
trunk/coregrind/m_sigframe/sigframe-arm64-linux.c
trunk/coregrind/m_sigframe/sigframe-mips32-linux.c
trunk/coregrind/m_sigframe/sigframe-mips64-linux.c
trunk/coregrind/m_sigframe/sigframe-ppc32-linux.c
trunk/coregrind/m_sigframe/sigframe-ppc64-linux.c
trunk/coregrind/m_sigframe/sigframe-s390x-linux.c
trunk/coregrind/m_sigframe/sigframe-tilegx-linux.c
trunk/coregrind/m_sigframe/sigframe-x86-darwin.c
trunk/coregrind/m_sigframe/sigframe-x86-linux.c
Modified: trunk/coregrind/Makefile.am
==============================================================================
--- trunk/coregrind/Makefile.am (original)
+++ trunk/coregrind/Makefile.am Sat Apr 18 11:33:54 2015
@@ -243,6 +243,7 @@
m_scheduler/priv_sema.h \
m_scheduler/priv_sched-lock.h \
m_scheduler/priv_sched-lock-impl.h \
+ m_sigframe/priv_sigframe.h \
m_syswrap/priv_types_n_macros.h \
m_syswrap/priv_syswrap-generic.h \
m_syswrap/priv_syswrap-linux.h \
@@ -377,6 +378,7 @@
m_scheduler/sema.c \
m_scheduler/sched-lock.c \
m_scheduler/sched-lock-generic.c \
+ m_sigframe/sigframe-common.c \
m_sigframe/sigframe-x86-linux.c \
m_sigframe/sigframe-amd64-linux.c \
m_sigframe/sigframe-ppc32-linux.c \
Added: trunk/coregrind/m_sigframe/priv_sigframe.h
==============================================================================
--- trunk/coregrind/m_sigframe/priv_sigframe.h (added)
+++ trunk/coregrind/m_sigframe/priv_sigframe.h Sat Apr 18 11:33:54 2015
@@ -0,0 +1,46 @@
+/* -*- mode: C; c-basic-offset: 3; -*- */
+
+/*--------------------------------------------------------------------*/
+/*--- Module-local header file for m_sigframe. ---*/
+/*--- priv_sigframe.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2015-2015 Florian Krohm
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PRIV_SIGFRAME_H
+#define __PRIV_SIGFRAME_H
+
+#include "pub_core_basics.h" // types
+#include "pub_core_threadstate.h" // ThreadState
+
+/* --------------- Implemented in sigframe-common.c ---------------*/
+
+Bool ML_(sf_extend_stack)( const ThreadState *tst, Addr addr, SizeT size );
+
+#endif // __PRIV_SIGFRAME_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/m_sigframe/sigframe-amd64-darwin.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-amd64-darwin.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-amd64-darwin.c Sat Apr 18 11:33:54 2015
@@ -82,19 +82,6 @@
};
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
- return True;
-}
-
-
/* Create a signal frame for thread 'tid'. Make a 3-arg frame
regardless of whether the client originally requested a 1-arg
version (no SA_SIGINFO) or a 3-arg one (SA_SIGINFO) since in the
@@ -122,7 +109,7 @@
entry to a function. */
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, rsp, sp_top_of_frame - rsp))
+ if (! ML_(sf_extend_stack)(tst, rsp, sp_top_of_frame - rsp))
return;
vg_assert(VG_IS_16_ALIGNED(rsp+8));
Modified: trunk/coregrind/m_sigframe/sigframe-amd64-linux.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-amd64-linux.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-amd64-linux.c Sat Apr 18 11:33:54 2015
@@ -45,6 +45,7 @@
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
#include "pub_core_sigframe.h" /* self */
+#include "priv_sigframe.h"
/* This module creates and removes signal frames for signal deliveries
on amd64-linux.
@@ -372,50 +373,6 @@
}
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
-
-
/* Build the Valgrind-specific part of a signal frame. */
static void build_vg_sigframe(struct vg_sigframe *frame,
@@ -455,7 +412,7 @@
rsp = VG_ROUNDDN(rsp, 16) - 8;
frame = (struct rt_sigframe *)rsp;
- if (!extend(tst, rsp, sizeof(*frame)))
+ if (! ML_(sf_extend_stack)(tst, rsp, sizeof(*frame)))
return rsp_top_of_frame;
/* retaddr, siginfo, uContext fields are to be written */
Modified: trunk/coregrind/m_sigframe/sigframe-arm-linux.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-arm-linux.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-arm-linux.c Sat Apr 18 11:33:54 2015
@@ -50,7 +50,7 @@
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
-#include "pub_core_transtab.h" // VG_(discard_translations)
+#include "priv_sigframe.h"
/* This uses the hack of dumping the vex guest state along with both
@@ -81,44 +81,6 @@
struct sigframe sig;
};
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
static void synth_ucontext( ThreadId tid, const vki_siginfo_t *si,
UWord trapno, UWord err, const vki_sigset_t *set,
@@ -223,7 +185,7 @@
sp -= size;
sp = VG_ROUNDDN(sp, 16);
- if(!extend(tst, sp, size))
+ if(! ML_(sf_extend_stack)(tst, sp, size))
I_die_here; // XXX Incorrect behavior
Modified: trunk/coregrind/m_sigframe/sigframe-arm64-linux.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-arm64-linux.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-arm64-linux.c Sat Apr 18 11:33:54 2015
@@ -33,7 +33,6 @@
#include "pub_core_basics.h"
#include "pub_core_vki.h"
-//ZZ #include "pub_core_vkiscnums.h"
#include "pub_core_libcsetjmp.h" // to keep _threadstate.h happy
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
@@ -46,7 +45,7 @@
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
-//ZZ #include "pub_core_transtab.h" // VG_(discard_translations)
+#include "priv_sigframe.h"
/* This uses the hack of dumping the vex guest state along with both
@@ -79,44 +78,6 @@
struct sigframe sig;
};
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
static void synth_ucontext( ThreadId tid, const vki_siginfo_t *si,
UWord trapno, UWord err, const vki_sigset_t *set,
@@ -212,7 +173,7 @@
sp -= size;
sp = VG_ROUNDDN(sp, 16);
- if (!extend(tst, sp, size))
+ if (! ML_(sf_extend_stack)(tst, sp, size))
return; // Give up. No idea if this is correct
struct rt_sigframe *rsf = (struct rt_sigframe *)sp;
Added: trunk/coregrind/m_sigframe/sigframe-common.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-common.c (added)
+++ trunk/coregrind/m_sigframe/sigframe-common.c Sat Apr 18 11:33:54 2015
@@ -0,0 +1,110 @@
+/* -*- mode: C; c-basic-offset: 3; -*- */
+
+/*--------------------------------------------------------------------*/
+/*--- Signal frames handling: stuff common to most/all platforms ---*/
+/*--- ---*/
+/*--- sigframe-common.c ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2013 Nicholas Nethercote
+ nj...@va...
+ Copyright (C) 2006-2013 OpenWorks Ltd
+ in...@op...
+
+ 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.
+*/
+
+#include "pub_core_aspacemgr.h" // VG_(am_find_nsegment)
+#include "pub_core_signals.h" // VG_(extend_stack)
+#include "pub_core_libcprint.h" // VG_(umsg)
+#include "pub_core_tooliface.h" // VG_TRACK
+#include "pub_core_machine.h" // VG_STACK_REDZONE_SZB
+#include "priv_sigframe.h" // self
+
+
+/* For tracking memory events, indicate the entire frame has been
+ allocated. Except, don't mess with the area which
+ overlaps the previous frame's redzone. */
+static void track_frame_memory ( Addr addr, SizeT size, ThreadId tid )
+{
+ VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB, size, tid );
+}
+
+#if defined(VGO_linux)
+
+/* Extend the stack segment downwards if needed so as to ensure the
+ new signal frames are mapped to something. Return a Bool
+ indicating whether or not the operation was successful. */
+Bool ML_(sf_extend_stack) ( const ThreadState *tst, Addr addr, SizeT size )
+{
+ ThreadId tid = tst->tid;
+ const NSegment *stackseg = NULL;
+
+ if (VG_(extend_stack)(tid, addr)) {
+ stackseg = VG_(am_find_nsegment)(addr);
+ if (0 && stackseg)
+ VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
+ addr, stackseg->start, stackseg->end);
+ }
+
+ if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
+ VG_(umsg)("Can't extend stack to %#lx during signal delivery for "
+ "thread %d:\n", addr, tid);
+ if (stackseg == NULL)
+ VG_(umsg)(" no stack segment\n");
+ else
+ VG_(umsg)(" too small or bad protection modes\n");
+
+ /* set SIGSEGV to default handler */
+ VG_(set_default_handler)(VKI_SIGSEGV);
+ VG_(synth_fault_mapping)(tid, addr);
+
+ /* The whole process should be about to die, since the default
+ action of SIGSEGV to kill the whole process. */
+ return False;
+ }
+
+ /* Tell the tool about the new memory */
+ track_frame_memory(addr, size, tid);
+
+ return True;
+}
+
+#elif defined(VGO_darwin)
+
+/* Extend the stack segment downwards if needed so as to ensure the
+ new signal frames are mapped to something. Return a Bool
+ indicating whether or not the operation was successful. */
+Bool ML_(sf_extend_stack) ( const ThreadState *tst, Addr addr, SizeT size )
+{
+ /* Tell the tool about the new memory */
+ track_frame_memory(addr, size, tst->tid);
+ return True;
+}
+
+#else
+#error unknown OS
+#endif
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/m_sigframe/sigframe-mips32-linux.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-mips32-linux.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-mips32-linux.c Sat Apr 18 11:33:54 2015
@@ -46,7 +46,7 @@
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
-#include "pub_core_transtab.h" // VG_(discard_translations)
+#include "priv_sigframe.h"
struct vg_sig_private
{
@@ -74,45 +74,6 @@
struct vg_sig_private priv;
};
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW)
- {
- VG_(message)(Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid );
- if (stackseg == NULL)
- VG_(message)( Vg_UserMsg, " no stack segment\n" );
- else
- VG_(message)( Vg_UserMsg, " too small or bad protection modes\n" );
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)( VKI_SIGSEGV );
- VG_(synth_fault_mapping)( tid, addr );
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
static
void setup_sigcontext2 ( ThreadState* tst, struct vki_sigcontext **sc1,
@@ -187,7 +148,7 @@
}
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, sp, sp_top_of_frame - sp))
+ if (! ML_(sf_extend_stack)(tst, sp, sp_top_of_frame - sp))
return;
vg_assert(VG_IS_8_ALIGNED(sp));
Modified: trunk/coregrind/m_sigframe/sigframe-mips64-linux.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-mips64-linux.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-mips64-linux.c Sat Apr 18 11:33:54 2015
@@ -46,7 +46,7 @@
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
-#include "pub_core_transtab.h" /* VG_(discard_translations) */
+#include "priv_sigframe.h"
struct vg_sig_private {
UInt magicPI;
@@ -71,44 +71,6 @@
struct vg_sig_private priv;
};
-/* Extend the stack segment downwards if needed so as to ensure the new signal
- frames are mapped to something. Return a Bool indicating whether or not the
- operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK(new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid);
-
- return True;
-}
static void setup_sigcontext ( ThreadState* tst, struct vki_sigcontext **sc1,
const vki_siginfo_t *si)
@@ -173,7 +135,7 @@
sp = sp_top_of_frame - sizeof(struct rt_sigframe);
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, sp, sp_top_of_frame - sp))
+ if (! ML_(sf_extend_stack)(tst, sp, sp_top_of_frame - sp))
return;
sp = VG_ROUNDDN(sp, 16);
Modified: trunk/coregrind/m_sigframe/sigframe-ppc32-linux.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-ppc32-linux.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-ppc32-linux.c Sat Apr 18 11:33:54 2015
@@ -49,7 +49,7 @@
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
#include "pub_core_transtab.h" // VG_(discard_translations)
-
+#include "priv_sigframe.h"
/* This module creates and removes signal frames for signal deliveries
on ppc32-linux.
@@ -502,48 +502,6 @@
//.. Vg_CoreSignal, zztid, VG_O_STACK_PTR, sizeof(Addr))
*/
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
//.. /* Build the Valgrind-specific part of a signal frame. */
//..
@@ -692,7 +650,7 @@
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, sp, sp_top_of_frame - sp))
+ if (! ML_(sf_extend_stack)(tst, sp, sp_top_of_frame - sp))
return;
vg_assert(VG_IS_16_ALIGNED(sp));
Modified: trunk/coregrind/m_sigframe/sigframe-ppc64-linux.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-ppc64-linux.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-ppc64-linux.c Sat Apr 18 11:33:54 2015
@@ -49,7 +49,7 @@
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
#include "pub_core_transtab.h" // VG_(discard_translations)
-
+#include "priv_sigframe.h"
/* This module creates and removes signal frames for signal deliveries
on ppc64-linux.
@@ -132,49 +132,6 @@
} while (0)
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
-
/* EXPORTED */
void VG_(sigframe_create)( ThreadId tid,
@@ -201,7 +158,7 @@
sp = sp_top_of_frame - sizeof(struct rt_sigframe);
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, sp, sp_top_of_frame - sp))
+ if (! ML_(sf_extend_stack)(tst, sp, sp_top_of_frame - sp))
return;
vg_assert(VG_IS_16_ALIGNED(sp));
Modified: trunk/coregrind/m_sigframe/sigframe-s390x-linux.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-s390x-linux.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-s390x-linux.c Sat Apr 18 11:33:54 2015
@@ -45,6 +45,7 @@
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
+#include "priv_sigframe.h"
#if defined(VGA_s390x)
@@ -258,49 +259,6 @@
tst->arch.vex.guest_IA = sigregs->regs.psw.addr;
}
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
-
/* Build the Valgrind-specific part of a signal frame. */
@@ -340,7 +298,7 @@
sp -= sizeof(*frame);
frame = (struct sigframe *)sp;
- if (!extend(tst, sp, sizeof(*frame)))
+ if (! ML_(sf_extend_stack)(tst, sp, sizeof(*frame)))
return sp_top_of_frame;
/* retcode, sigNo, sc, sregs fields are to be written */
@@ -400,7 +358,7 @@
sp -= sizeof(*frame);
frame = (struct rt_sigframe *)sp;
- if (!extend(tst, sp, sizeof(*frame)))
+ if (! ML_(sf_extend_stack)(tst, sp, sizeof(*frame)))
return sp_top_of_frame;
/* retcode, sigNo, sc, sregs fields are to be written */
Modified: trunk/coregrind/m_sigframe/sigframe-tilegx-linux.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-tilegx-linux.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-tilegx-linux.c Sat Apr 18 11:33:54 2015
@@ -47,7 +47,7 @@
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
-#include "pub_core_transtab.h" // VG_(discard_translations)
+#include "priv_sigframe.h"
struct vg_sig_private
{
@@ -67,44 +67,6 @@
struct vg_sig_private priv;
};
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr))
- stackseg = VG_(am_find_nsegment)(addr);
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW)
- {
- VG_(message)(Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid );
- if (stackseg == NULL)
- VG_(message)( Vg_UserMsg, " no stack segment\n" );
- else
- VG_(message)( Vg_UserMsg, " too small or bad protection modes\n" );
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)( VKI_SIGSEGV );
- VG_(synth_fault_mapping)( tid, addr );
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
static
void setup_sigcontext2 ( ThreadState* tst, struct vki_sigcontext **sc1,
@@ -196,7 +158,7 @@
sp = sp_top_of_frame - sizeof(struct rt_sigframe);
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, sp, sizeof(struct rt_sigframe)))
+ if (! ML_(sf_extend_stack)(tst, sp, sizeof(struct rt_sigframe)))
return;
vg_assert(VG_IS_8_ALIGNED(sp));
Modified: trunk/coregrind/m_sigframe/sigframe-x86-darwin.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-x86-darwin.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-x86-darwin.c Sat Apr 18 11:33:54 2015
@@ -85,25 +85,6 @@
};
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- /* For tracking memory events, indicate the entire frame has been
- allocated. Except, don't mess with the area which
- overlaps the previous frame's redzone. */
- /* XXX is the following call really right? compared with the
- amd64-linux version, this doesn't appear to handle the redzone
- in the same way. */
- VG_TRACK( new_mem_stack_signal,
- addr - VG_STACK_REDZONE_SZB, size, tid );
- return True;
-}
-
-
/* Create a signal frame for thread 'tid'. Make a 3-arg frame
regardless of whether the client originally requested a 1-arg
version (no SA_SIGINFO) or a 3-arg one (SA_SIGINFO) since in the
@@ -131,7 +112,7 @@
entry to a function. */
tst = VG_(get_ThreadState)(tid);
- if (!extend(tst, esp, sp_top_of_frame - esp))
+ if (! ML_(sf_extend_stack)(tst, esp, sp_top_of_frame - esp))
return;
vg_assert(VG_IS_16_ALIGNED(esp+4));
Modified: trunk/coregrind/m_sigframe/sigframe-x86-linux.c
==============================================================================
--- trunk/coregrind/m_sigframe/sigframe-x86-linux.c (original)
+++ trunk/coregrind/m_sigframe/sigframe-x86-linux.c Sat Apr 18 11:33:54 2015
@@ -45,7 +45,7 @@
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
#include "pub_core_sigframe.h" /* self */
-
+#include "priv_sigframe.h"
/* This module creates and removes signal frames for signal deliveries
on x86-linux.
@@ -393,50 +393,6 @@
}
-/* Extend the stack segment downwards if needed so as to ensure the
- new signal frames are mapped to something. Return a Bool
- indicating whether or not the operation was successful.
-*/
-static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
-{
- ThreadId tid = tst->tid;
- NSegment const* stackseg = NULL;
-
- if (VG_(extend_stack)(tid, addr)) {
- stackseg = VG_(am_find_nsegment)(addr);
- if (0 && stackseg)
- VG_(printf)("frame=%#lx seg=%#lx-%#lx\n",
- addr, stackseg->start, stackseg->end);
- }
-
- if (stackseg == NULL || !stackseg->hasR || !stackseg->hasW) {
- VG_(message)(
- Vg_UserMsg,
- "Can't extend stack to %#lx during signal delivery for thread %d:\n",
- addr, tid);
- if (stackseg == NULL)
- VG_(message)(Vg_UserMsg, " no stack segment\n");
- else
- VG_(message)(Vg_UserMsg, " too small or bad protection modes\n");
-
- /* set SIGSEGV to default handler */
- VG_(set_default_handler)(VKI_SIGSEGV);
- VG_(synth_fault_mapping)(tid, addr);
-
- /* The whole process should be about to die, since the default
- action of SIGSEGV to kill the whole process. */
- return False;
- }
-
- /* For tracking memory events, indicate the entire frame has been
- allocated. */
- VG_TRACK( new_mem_stack_signal, addr - VG_STACK_REDZONE_SZB,
- size + VG_STACK_REDZONE_SZB, tid );
-
- return True;
-}
-
-
/* Build the Valgrind-specific part of a signal frame. */
static void build_vg_sigframe(struct vg_sigframe *frame,
@@ -478,7 +434,7 @@
esp = VG_ROUNDDN(esp, 16);
frame = (struct sigframe *)esp;
- if (!extend(tst, esp, sizeof(*frame)))
+ if (! ML_(sf_extend_stack)(tst, esp, sizeof(*frame)))
return esp_top_of_frame;
/* retaddr, sigNo, siguContext fields are to be written */
@@ -535,7 +491,7 @@
esp = VG_ROUNDDN(esp, 16);
frame = (struct rt_sigframe *)esp;
- if (!extend(tst, esp, sizeof(*frame)))
+ if (! ML_(sf_extend_stack)(tst, esp, sizeof(*frame)))
return esp_top_of_frame;
/* retaddr, sigNo, pSiginfo, puContext fields are to be written */
|
|
From: <sv...@va...> - 2015-04-18 09:15:55
|
Author: florian
Date: Sat Apr 18 10:15:47 2015
New Revision: 15108
Log:
Add missing header file.
Modified:
trunk/Makefile.vex.am
Modified: trunk/Makefile.vex.am
==============================================================================
--- trunk/Makefile.vex.am (original)
+++ trunk/Makefile.vex.am Sat Apr 18 10:15:47 2015
@@ -57,6 +57,7 @@
priv/host_arm_defs.h \
priv/host_arm64_defs.h \
priv/host_s390_defs.h \
+ priv/host_tilegx_defs.h \
priv/s390_disasm.h \
priv/s390_defs.h \
priv/host_mips_defs.h \
|
|
From: <sv...@va...> - 2015-04-18 00:02:08
|
Author: carll
Date: Sat Apr 18 01:01:58 2015
New Revision: 15107
Log:
Forgot to add the new files in memcheck/tests/ppc32 and memcheck/tests/ppc32.
They should have been part of the previous commit 15106.
--------------------------------------------------------------------
Add support for the lbarx, lharx, stbcx and sthcs instructions.
The instructions are part of the ISA 2.06 but were not implemented
in all versions of hardware. The four instructions are all supported
in ISA 2.07. The instructions were put under the ISA 2.07 category
of supported instructions in this patch.
The VEX commit for this fix is r3137.
The bugzilla for this issue is 346324.
Added:
trunk/memcheck/tests/ppc32/power_ISA2_07.c
trunk/memcheck/tests/ppc32/power_ISA2_07.stderr.exp
trunk/memcheck/tests/ppc32/power_ISA2_07.stdout.exp
trunk/memcheck/tests/ppc32/power_ISA2_07.stdout.exp-LE
trunk/memcheck/tests/ppc32/power_ISA2_07.vgtest
trunk/memcheck/tests/ppc64/power_ISA2_07.c
trunk/memcheck/tests/ppc64/power_ISA2_07.stderr.exp
trunk/memcheck/tests/ppc64/power_ISA2_07.stdout.exp
trunk/memcheck/tests/ppc64/power_ISA2_07.stdout.exp-LE
trunk/memcheck/tests/ppc64/power_ISA2_07.vgtest
Added: trunk/memcheck/tests/ppc32/power_ISA2_07.c
==============================================================================
--- trunk/memcheck/tests/ppc32/power_ISA2_07.c (added)
+++ trunk/memcheck/tests/ppc32/power_ISA2_07.c Sat Apr 18 01:01:58 2015
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <config.h>
+
+double foo = -1.0;
+double FRT1;
+double FRT2;
+
+#ifdef HAS_ISA_2_07
+
+/* b0 may be non-zero in lwarx/ldarx Power6 instrs */
+void test_reservation()
+{
+
+ unsigned RT;
+ unsigned base;
+ unsigned offset;
+ unsigned arrB[] = { 0x00112233U, 0x44556677U, 0x8899aabbU, 0xccddeeffU };
+ int arrH[] __attribute__ ((aligned (2))) = { 0xdeadbeef, 0xbad0beef, 0xbeefdead, 0xbeef0bad };
+
+ /* The lbarx and lharx instructions were "phased in" in ISA 2.06. That
+ * means it they may show up in some implementations but not others. They
+ * are in all ISA 2.08 implementations.
+ */
+ base = (unsigned) &arrB;
+ offset = ((unsigned ) &arrB[1]) - base;
+ __asm__ volatile ("ori 20, %0, 0"::"r" (base));
+ __asm__ volatile ("ori 21, %0, 0"::"r" (offset));
+ __asm__ volatile ("lbarx %0, 20, 21, 1":"=r" (RT));
+ printf("lbarx => 0x%x\n", RT);
+
+ base = (unsigned) &arrH;
+ offset = ((unsigned) &arrH[1]) - base;
+ __asm__ volatile ("ori 20, %0, 0"::"r" (base));
+ __asm__ volatile ("ori 21, %0, 0"::"r" (offset));
+ __asm__ volatile ("lharx %0, 20, 21, 1":"=r" (RT));
+ printf("lharx => 0x%x\n", RT);
+
+}
+#endif
+
+int main(void)
+{
+#ifdef HAS_ISA_2_07
+ (void) test_reservation();
+#endif
+
+ return 0;
+}
Added: trunk/memcheck/tests/ppc32/power_ISA2_07.stderr.exp
==============================================================================
--- trunk/memcheck/tests/ppc32/power_ISA2_07.stderr.exp (added)
+++ trunk/memcheck/tests/ppc32/power_ISA2_07.stderr.exp Sat Apr 18 01:01:58 2015
@@ -0,0 +1,10 @@
+
+
+HEAP SUMMARY:
+ in use at exit: 0 bytes in 0 blocks
+ total heap usage: 0 allocs, 0 frees, 0 bytes allocated
+
+For a detailed leak analysis, rerun with: --leak-check=full
+
+For counts of detected and suppressed errors, rerun with: -v
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Added: trunk/memcheck/tests/ppc32/power_ISA2_07.stdout.exp
==============================================================================
--- trunk/memcheck/tests/ppc32/power_ISA2_07.stdout.exp (added)
+++ trunk/memcheck/tests/ppc32/power_ISA2_07.stdout.exp Sat Apr 18 01:01:58 2015
@@ -0,0 +1,2 @@
+lbarx => 0x44
+lharx => 0xbad0
Added: trunk/memcheck/tests/ppc32/power_ISA2_07.stdout.exp-LE
==============================================================================
--- trunk/memcheck/tests/ppc32/power_ISA2_07.stdout.exp-LE (added)
+++ trunk/memcheck/tests/ppc32/power_ISA2_07.stdout.exp-LE Sat Apr 18 01:01:58 2015
@@ -0,0 +1,2 @@
+lbarx => 0x77
+lharx => 0xbeef
Added: trunk/memcheck/tests/ppc32/power_ISA2_07.vgtest
==============================================================================
--- trunk/memcheck/tests/ppc32/power_ISA2_07.vgtest (added)
+++ trunk/memcheck/tests/ppc32/power_ISA2_07.vgtest Sat Apr 18 01:01:58 2015
@@ -0,0 +1,3 @@
+prereq: ../../../tests/check_isa-2_07_cap
+prog: power_ISA2_07
+vgopts:
Added: trunk/memcheck/tests/ppc64/power_ISA2_07.c
==============================================================================
--- trunk/memcheck/tests/ppc64/power_ISA2_07.c (added)
+++ trunk/memcheck/tests/ppc64/power_ISA2_07.c Sat Apr 18 01:01:58 2015
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <config.h>
+
+double foo = -1.0;
+double FRT1;
+double FRT2;
+
+#ifdef HAS_ISA_2_07
+
+/* b0 may be non-zero in lwarx/ldarx Power6 instrs */
+void test_reservation()
+{
+
+ unsigned long RT;
+ unsigned long base;
+ unsigned long offset;
+ unsigned arrB[] = { 0x00112233U, 0x44556677U, 0x8899aabbU, 0xccddeeffU };
+ int arrH[] __attribute__ ((aligned (2))) = { 0xdeadbeef, 0xbad0beef, 0xbeefdead, 0xbeef0bad };
+
+ /* The lbarx and lharx instructions were "phased in" in ISA 2.06. That
+ * means it they may show up in some implementations but not others. They
+ * are in all ISA 2.08 implementations.
+ */
+ base = (unsigned long) &arrB;
+ offset = ((unsigned long) &arrB[1]) - base;
+ __asm__ volatile ("ori 20, %0, 0"::"r" (base));
+ __asm__ volatile ("ori 21, %0, 0"::"r" (offset));
+ __asm__ volatile ("lbarx %0, 20, 21, 1":"=r" (RT));
+ printf("lbarx => 0x%lx\n", RT);
+
+ base = (unsigned long) &arrH;
+ offset = ((unsigned long) &arrH[1]) - base;
+ __asm__ volatile ("ori 20, %0, 0"::"r" (base));
+ __asm__ volatile ("ori 21, %0, 0"::"r" (offset));
+ __asm__ volatile ("lharx %0, 20, 21, 1":"=r" (RT));
+ printf("lharx => 0x%lx\n", RT);
+}
+#endif
+
+int main(void)
+{
+#ifdef HAS_ISA_2_07
+ (void) test_reservation();
+#endif
+
+ return 0;
+}
Added: trunk/memcheck/tests/ppc64/power_ISA2_07.stderr.exp
==============================================================================
--- trunk/memcheck/tests/ppc64/power_ISA2_07.stderr.exp (added)
+++ trunk/memcheck/tests/ppc64/power_ISA2_07.stderr.exp Sat Apr 18 01:01:58 2015
@@ -0,0 +1,10 @@
+
+
+HEAP SUMMARY:
+ in use at exit: 0 bytes in 0 blocks
+ total heap usage: 0 allocs, 0 frees, 0 bytes allocated
+
+For a detailed leak analysis, rerun with: --leak-check=full
+
+For counts of detected and suppressed errors, rerun with: -v
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Added: trunk/memcheck/tests/ppc64/power_ISA2_07.stdout.exp
==============================================================================
--- trunk/memcheck/tests/ppc64/power_ISA2_07.stdout.exp (added)
+++ trunk/memcheck/tests/ppc64/power_ISA2_07.stdout.exp Sat Apr 18 01:01:58 2015
@@ -0,0 +1,2 @@
+lbarx => 0x44
+lharx => 0xbad0
Added: trunk/memcheck/tests/ppc64/power_ISA2_07.stdout.exp-LE
==============================================================================
--- trunk/memcheck/tests/ppc64/power_ISA2_07.stdout.exp-LE (added)
+++ trunk/memcheck/tests/ppc64/power_ISA2_07.stdout.exp-LE Sat Apr 18 01:01:58 2015
@@ -0,0 +1,2 @@
+lbarx => 0x77
+lharx => 0xbeef
Added: trunk/memcheck/tests/ppc64/power_ISA2_07.vgtest
==============================================================================
--- trunk/memcheck/tests/ppc64/power_ISA2_07.vgtest (added)
+++ trunk/memcheck/tests/ppc64/power_ISA2_07.vgtest Sat Apr 18 01:01:58 2015
@@ -0,0 +1,3 @@
+prereq: ../../../tests/check_isa-2_07_cap
+prog: power_ISA2_07
+vgopts:
|
|
From: <sv...@va...> - 2015-04-17 23:43:43
|
Author: carll
Date: Sat Apr 18 00:43:36 2015
New Revision: 15106
Log:
Add support for the lbarx, lharx, stbcx and sthcs instructions.
The instructions are part of the ISA 2.06 but were not implemented
in all versions of hardware. The four instructions are all supported
in ISA 2.07. The instructions were put under the ISA 2.07 category
of supported instructions in this patch.
The VEX commit for this fix is r3137.
The bugzilla for this issue is 346324.
Modified:
trunk/memcheck/tests/ppc32/Makefile.am
trunk/memcheck/tests/ppc64/Makefile.am
trunk/none/tests/ppc32/Makefile.am
trunk/none/tests/ppc32/jm_int_isa_2_07.stdout.exp
trunk/none/tests/ppc64/Makefile.am
trunk/none/tests/ppc64/jm_int_isa_2_07.stdout.exp
trunk/none/tests/ppc64/test_isa_2_07_part1.c
Modified: trunk/memcheck/tests/ppc32/Makefile.am
==============================================================================
--- trunk/memcheck/tests/ppc32/Makefile.am (original)
+++ trunk/memcheck/tests/ppc32/Makefile.am Sat Apr 18 00:43:36 2015
@@ -5,10 +5,23 @@
EXTRA_DIST = $(noinst_SCRIPTS) \
power_ISA2_05.stderr.exp power_ISA2_05.stdout.exp power_ISA2_05.vgtest \
- power_ISA2_05.stdout.exp_Without_FPPO
+ power_ISA2_05.stdout.exp_Without_FPPO \
+ power_ISA2_07.stdout.exp power_ISA2_07.stdout.exp-LE \
+ power_ISA2_07.stderr.exp power_ISA2_07.vgtest
check_PROGRAMS = \
- power_ISA2_05
+ power_ISA2_05 power_ISA2_07
power_ISA2_05_CFLAGS = $(AM_CFLAGS) $(WERROR) -Winline -Wall -Wshadow -g \
-I$(top_srcdir)/include @FLAG_M32@
+
+if HAS_ISA_2_07
+ BUILD_FLAGS_ISA_2_07 = -mhtm -mcpu=power8
+ ISA_2_07_FLAG = -DHAS_ISA_2_07
+else
+ BUILD_FLAGS_ISA_2_07 =
+ ISA_2_07_FLAG =
+endif
+
+power_ISA2_07_CFLAGS = $(AM_CFLAGS) $(WERROR) -Winline -Wall -Wshadow -g \
+ $(ISA_2_07_FLAG) -I$(top_srcdir)/include @FLAG_M32@
Modified: trunk/memcheck/tests/ppc64/Makefile.am
==============================================================================
--- trunk/memcheck/tests/ppc64/Makefile.am (original)
+++ trunk/memcheck/tests/ppc64/Makefile.am Sat Apr 18 00:43:36 2015
@@ -5,10 +5,24 @@
EXTRA_DIST = $(noinst_SCRIPTS) \
power_ISA2_05.stderr.exp power_ISA2_05.stdout.exp power_ISA2_05.vgtest \
- power_ISA2_05.stdout.exp_Without_FPPO
+ power_ISA2_05.stdout.exp_Without_FPPO \
+ power_ISA2_07.stdout.exp power_ISA2_07.stdout.exp-LE \
+ power_ISA2_07.stderr.exp power_ISA2_07.vgtest
+
check_PROGRAMS = \
- power_ISA2_05
+ power_ISA2_05 power_ISA2_07
power_ISA2_05_CFLAGS = $(AM_CFLAGS) $(WERROR) -Winline -Wall -Wshadow -g \
-I$(top_srcdir)/include @FLAG_M64@
+
+if HAS_ISA_2_07
+ BUILD_FLAGS_ISA_2_07 = -mhtm -mcpu=power8
+ ISA_2_07_FLAG = -DHAS_ISA_2_07
+else
+ BUILD_FLAGS_ISA_2_07 =
+ ISA_2_07_FLAG =
+endif
+
+power_ISA2_07_CFLAGS = $(AM_CFLAGS) $(WERROR) -Winline -Wall -Wshadow -g \
+ $(ISA_2_07_FLAG) -I$(top_srcdir)/include @FLAG_M64@
Modified: trunk/none/tests/ppc32/Makefile.am
==============================================================================
--- trunk/none/tests/ppc32/Makefile.am (original)
+++ trunk/none/tests/ppc32/Makefile.am Sat Apr 18 00:43:36 2015
@@ -40,7 +40,8 @@
test_dfp5.stderr.exp test_dfp5.stdout.exp test_dfp5.vgtest \
jm_vec_isa_2_07.stderr.exp jm_vec_isa_2_07.stdout.exp jm_vec_isa_2_07.vgtest \
jm_fp_isa_2_07.stderr.exp jm_fp_isa_2_07.stdout.exp jm_fp_isa_2_07.vgtest \
- jm_int_isa_2_07.stderr.exp jm_int_isa_2_07.stdout.exp jm_int_isa_2_07.vgtest \
+ jm_int_isa_2_07.stdout.exp jm_int_isa_2_07.stdout.exp-LE \
+ jm_int_isa_2_07.stderr.exp jm_int_isa_2_07.vgtest \
test_isa_2_07_part2.stderr.exp test_isa_2_07_part2.stdout.exp test_isa_2_07_part2.vgtest \
test_tm.stderr.exp test_tm.stdout.exp test_tm.vgtest \
test_touch_tm.stderr.exp test_touch_tm.stdout.exp test_touch_tm.vgtest \
Modified: trunk/none/tests/ppc32/jm_int_isa_2_07.stdout.exp
==============================================================================
--- trunk/none/tests/ppc32/jm_int_isa_2_07.stdout.exp (original)
+++ trunk/none/tests/ppc32/jm_int_isa_2_07.stdout.exp Sat Apr 18 00:43:36 2015
@@ -2,8 +2,16 @@
lq (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 11335577,23456789)
+lbarx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0x000000aa, 0x00000000)
+
+lharx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0x0000aacc, 0x00000000)
+
lqarx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0x11335577, 0x23456789)
+stbcx. 45236789,44226688, => 8900000000000000,0000000000000001; CR=20000000
+
+sthcx. 45236789,44226688, => 6789000000000000,0000000000000001; CR=20000000
+
stqcx. 45236789,44226688, => 0000000045236789,0000000044226688; CR=20000000
-All done. Tested 4 different instructions
+All done. Tested 8 different instructions
Modified: trunk/none/tests/ppc64/Makefile.am
==============================================================================
--- trunk/none/tests/ppc64/Makefile.am (original)
+++ trunk/none/tests/ppc64/Makefile.am Sat Apr 18 00:43:36 2015
@@ -28,7 +28,8 @@
test_dfp5.stderr.exp test_dfp5.stdout.exp test_dfp5.vgtest \
jm_vec_isa_2_07.stderr.exp jm_vec_isa_2_07.stdout.exp jm_vec_isa_2_07.vgtest \
jm_fp_isa_2_07.stderr.exp jm_fp_isa_2_07.stdout.exp jm_fp_isa_2_07.vgtest \
- jm_int_isa_2_07.stderr.exp jm_int_isa_2_07.stdout.exp jm_int_isa_2_07.vgtest \
+ jm_int_isa_2_07.stderr.exp jm_int_isa_2_07.vgtest \
+ jm_int_isa_2_07.stdout.exp jm_int_isa_2_07.stdout.exp-LE \
test_isa_2_07_part2.stderr.exp test_isa_2_07_part2.stdout.exp test_isa_2_07_part2.vgtest \
test_tm.stderr.exp test_tm.stdout.exp test_tm.vgtest \
test_touch_tm.stderr.exp test_touch_tm.stdout.exp test_touch_tm.vgtest \
Modified: trunk/none/tests/ppc64/jm_int_isa_2_07.stdout.exp
==============================================================================
--- trunk/none/tests/ppc64/jm_int_isa_2_07.stdout.exp (original)
+++ trunk/none/tests/ppc64/jm_int_isa_2_07.stdout.exp Sat Apr 18 00:43:36 2015
@@ -2,8 +2,16 @@
lq (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0xaaccee0011335577, 0xabcdef0123456789)
+lbarx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0x00000000000000aa, 0x0000000000000000)
+
+lharx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0x000000000000aacc, 0x0000000000000000)
+
lqarx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0xaaccee0011335577, 0xabcdef0123456789)
+stbcx. abefcd0145236789,1155337744226688 => 8900000000000000,0000000000000001; CR=20000000
+
+sthcx. abefcd0145236789,1155337744226688 => 6789000000000000,0000000000000001; CR=20000000
+
stqcx. abefcd0145236789,1155337744226688 => abefcd0145236789,1155337744226688; CR=20000000
-All done. Tested 4 different instructions
+All done. Tested 8 different instructions
Modified: trunk/none/tests/ppc64/test_isa_2_07_part1.c
==============================================================================
--- trunk/none/tests/ppc64/test_isa_2_07_part1.c (original)
+++ trunk/none/tests/ppc64/test_isa_2_07_part1.c Sat Apr 18 00:43:36 2015
@@ -301,8 +301,31 @@
{ NULL, NULL, },
};
-
+#ifdef HAS_ISA_2_07
Word_t * mem_resv;
+static void test_stbcx(void)
+{
+ /* Have to do the lbarx to the memory address to create the reservation
+ * or the store will not occur.
+ */
+ __asm__ __volatile__ ("lbarx %0, %1, %2" : :"r" (r14), "r" (r16),"r" (r17));
+ r14 = (HWord_t) 0xABEFCD0145236789ULL;
+ r15 = (HWord_t) 0x1155337744226688ULL;
+ __asm__ __volatile__ ("stbcx. %0, %1, %2" : :"r" (r14), "r" (r16),"r" (r17));
+}
+
+static void test_sthcx(void)
+{
+ /* Have to do the lharx to the memory address to create the reservation
+ * or the store will not occur.
+ */
+ __asm__ __volatile__ ("lharx %0, %1, %2" : :"r" (r14), "r" (r16),"r" (r17));
+ r14 = (HWord_t) 0xABEFCD0145236789ULL;
+ r15 = (HWord_t) 0x1155337744226688ULL;
+ __asm__ __volatile__ ("sthcx. %0, %1, %2" : :"r" (r14), "r" (r16),"r" (r17));
+}
+#endif
+
static void test_stqcx(void)
{
/* Have to do the lqarx to the memory address to create the reservation
@@ -315,16 +338,34 @@
}
static test_t tests_stq_ops_three[] = {
+#ifdef HAS_ISA_2_07
+ { &test_stbcx , "stbcx.", },
+ { &test_sthcx , "sthcx.", },
+#endif
{ &test_stqcx , "stqcx.", },
{ NULL, NULL, },
};
+#ifdef HAS_ISA_2_07
+static void test_lbarx(void)
+{
+ __asm__ __volatile__ ("lbarx %0, %1, %2, 0" : :"r" (r14), "r" (r16),"r" (r17));
+}
+static void test_lharx(void)
+{
+ __asm__ __volatile__ ("lharx %0, %1, %2, 0" : :"r" (r14), "r" (r16),"r" (r17));
+}
+#endif
static void test_lqarx(void)
{
__asm__ __volatile__ ("lqarx %0, %1, %2, 0" : :"r" (r14), "r" (r16),"r" (r17));
}
static test_t tests_ldq_ops_three[] = {
+#ifdef HAS_ISA_2_07
+ { &test_lbarx , "lbarx", },
+ { &test_lharx , "lharx", },
+#endif
{ &test_lqarx , "lqarx", },
{ NULL, NULL, },
};
|