summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2013-11-05 19:29:36 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-11-05 19:29:36 +0000
commitc2945850e58f4ef50f3e3534ce50306262375d37 (patch)
treed6330895d0092a10f03c8449f892659151a48f06
parentc8626ba480c0e2cab4f4d2fe43bd8f741320b404 (diff)
parentcbfc7302fb3b5d5c77d2aa7974b26983ce479aa0 (diff)
downloadsystem_core-c2945850e58f4ef50f3e3534ce50306262375d37.zip
system_core-c2945850e58f4ef50f3e3534ce50306262375d37.tar.gz
system_core-c2945850e58f4ef50f3e3534ce50306262375d37.tar.bz2
Merge "Add some clarifying defines."
-rw-r--r--include/backtrace/backtrace.h8
-rw-r--r--libbacktrace/Backtrace.cpp6
2 files changed, 11 insertions, 3 deletions
diff --git a/include/backtrace/backtrace.h b/include/backtrace/backtrace.h
index b35a6d5..a833982 100644
--- a/include/backtrace/backtrace.h
+++ b/include/backtrace/backtrace.h
@@ -23,6 +23,14 @@
__BEGIN_DECLS
+// When the pid to be traced is set to this value, then trace the current
+// process. If the tid value is not BACKTRACE_NO_TID, then the specified
+// thread from the current process will be traced.
+#define BACKTRACE_CURRENT_PROCESS -1
+// When the tid to be traced is set to this value, then trace the specified
+// pid.
+#define BACKTRACE_NO_TID -1
+
#define MAX_BACKTRACE_FRAMES 64
typedef struct backtrace_map_info {
diff --git a/libbacktrace/Backtrace.cpp b/libbacktrace/Backtrace.cpp
index 17d9e1d..b22d301 100644
--- a/libbacktrace/Backtrace.cpp
+++ b/libbacktrace/Backtrace.cpp
@@ -213,13 +213,13 @@ bool BacktracePtrace::ReadWord(uintptr_t ptr, uint32_t* out_value) {
}
Backtrace* Backtrace::Create(pid_t pid, pid_t tid) {
- if (pid < 0 || pid == getpid()) {
- if (tid < 0 || tid == gettid()) {
+ if (pid == BACKTRACE_CURRENT_PROCESS || pid == getpid()) {
+ if (tid == BACKTRACE_NO_TID || tid == gettid()) {
return CreateCurrentObj();
} else {
return CreateThreadObj(tid);
}
- } else if (tid < 0) {
+ } else if (tid == BACKTRACE_NO_TID) {
return CreatePtraceObj(pid, pid);
} else {
return CreatePtraceObj(pid, tid);