1. seandroid
  2. Untitled project
  3. system/core

Commits

Christopher Ferris  committed cbfc730

Add some clarifying defines.

In order to be explicit in the Backtrace::Create() calls, adding a couple
of defines and some comments to describe what they mean.

Change-Id: I6ad08c529791821496a95fa33cea1c95b0a7eada

  • Participants
  • Parent commits c8626ba
  • Branches master

Comments (0)

Files changed (2)

File include/backtrace/backtrace.h

View file
  • Ignore whitespace
 
 __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 {

File libbacktrace/Backtrace.cpp

View file
  • Ignore whitespace
 }
 
 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);