cuitao2046 / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

ARMv6 compatibility issue #575

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I've been using gperftools on the Raspberry Pi, which is based on ARMv6 
(ARM1176JZF-S). Some earlier fixes I provided to make gperftools work on this 
architecture were accepted in issue #493.

I found an additional problem later on, when I first tried profiling a 
multi-threaded application. It manifested itself as a SIGILL.

The problem turned out to be an incorrect assumption about the presence of the 
cycle counter registers in CP15. It's true that there is standardisation by ARM 
of cycle counters since ARMv6, but crucially they changed their minds about the 
location and operation of the cycle counters between v6 and v7, so the code in 
gperftools which was written for the ARMv7 cycle counter won't work on ARMv6.

The simple fix presented here is to drop back to the default implementation 
(using gettimeofday) for ARMv6.

diff --git a/src/base/cycleclock.h b/src/base/cycleclock.h
index fbf6dfc..9fea189 100644
--- a/src/base/cycleclock.h
+++ b/src/base/cycleclock.h
@@ -133,7 +133,7 @@ struct CycleClock {
 #elif defined(_MSC_VER)
     return __rdtsc();
 #elif defined(ARMV3)
-#if defined(ARMV6)  // V6 is the earliest arch that has a standard cyclecount
+#if defined(ARMV7)  // V7 is the earliest arch that has a standard cyclecount
     uint32 pmccntr;
     uint32 pmuseren;
     uint32 pmcntenset;

Original issue reported on code.google.com by googlec...@piccolosystems.com on 26 Sep 2013 at 2:56

GoogleCodeExporter commented 9 years ago
Thanks. Applied.

Original comment by alkondratenko on 29 Sep 2013 at 2:37