summaryrefslogtreecommitdiffstats
path: root/libs/utils
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2013-03-18 20:31:18 -0700
committerMathias Agopian <mathias@google.com>2013-03-18 22:59:40 -0700
commit19437cb84c8352669c3ccfdec8b8bf6a6a08f3d3 (patch)
tree013f08e118f826442f99cf985555f0d962a86cb0 /libs/utils
parent79fb99d0dea4d301d1bf25273c6af4907ca124bc (diff)
downloadframeworks_native-19437cb84c8352669c3ccfdec8b8bf6a6a08f3d3.zip
frameworks_native-19437cb84c8352669c3ccfdec8b8bf6a6a08f3d3.tar.gz
frameworks_native-19437cb84c8352669c3ccfdec8b8bf6a6a08f3d3.tar.bz2
A few tweaks to RefBase debugging
- stacks are now saved in /data/debug which must be created and writable by the user. - removed "always fatal" DEBUG_REFS option, it wasn't really needed. - DEBUG_REFS_ENABLED_BY_DEFAULT is not the default anymore (usually people want to target which refs they're tracking) Change-Id: I37fae72e9dacde6ce1fa8f7dbe2bc01b1a1b95e5
Diffstat (limited to 'libs/utils')
-rw-r--r--libs/utils/RefBase.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/libs/utils/RefBase.cpp b/libs/utils/RefBase.cpp
index 0623f46..ef87131 100644
--- a/libs/utils/RefBase.cpp
+++ b/libs/utils/RefBase.cpp
@@ -35,10 +35,18 @@
// compile with refcounting debugging enabled
#define DEBUG_REFS 0
-#define DEBUG_REFS_FATAL_SANITY_CHECKS 0
-#define DEBUG_REFS_ENABLED_BY_DEFAULT 1
+
+// whether ref-tracking is enabled by default, if not, trackMe(true, false)
+// needs to be called explicitly
+#define DEBUG_REFS_ENABLED_BY_DEFAULT 0
+
+// whether callstack are collected (significantly slows things down)
#define DEBUG_REFS_CALLSTACK_ENABLED 1
+// folder where stack traces are saved when DEBUG_REFS is enabled
+// this folder needs to exist and be writable
+#define DEBUG_REFS_CALLSTACK_PATH "/data/debug"
+
// log all reference counting operations
#define PRINT_REFS 0
@@ -96,11 +104,7 @@ public:
bool dumpStack = false;
if (!mRetain && mStrongRefs != NULL) {
dumpStack = true;
-#if DEBUG_REFS_FATAL_SANITY_CHECKS
- LOG_ALWAYS_FATAL("Strong references remain!");
-#else
ALOGE("Strong references remain:");
-#endif
ref_entry* refs = mStrongRefs;
while (refs) {
char inc = refs->ref >= 0 ? '+' : '-';
@@ -114,11 +118,7 @@ public:
if (!mRetain && mWeakRefs != NULL) {
dumpStack = true;
-#if DEBUG_REFS_FATAL_SANITY_CHECKS
- LOG_ALWAYS_FATAL("Weak references remain:");
-#else
ALOGE("Weak references remain!");
-#endif
ref_entry* refs = mWeakRefs;
while (refs) {
char inc = refs->ref >= 0 ? '+' : '-';
@@ -199,7 +199,7 @@ public:
{
char name[100];
- snprintf(name, 100, "/data/%p.stack", this);
+ snprintf(name, 100, DEBUG_REFS_CALLSTACK_PATH "/%p.stack", this);
int rc = open(name, O_RDWR | O_CREAT | O_APPEND, 644);
if (rc >= 0) {
write(rc, text.string(), text.length());
@@ -258,12 +258,6 @@ private:
ref = *refs;
}
-#if DEBUG_REFS_FATAL_SANITY_CHECKS
- LOG_ALWAYS_FATAL("RefBase: removing id %p on RefBase %p"
- "(weakref_type %p) that doesn't exist!",
- id, mBase, this);
-#endif
-
ALOGE("RefBase: removing id %p on RefBase %p"
"(weakref_type %p) that doesn't exist!",
id, mBase, this);