summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2014-01-09 23:55:52 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-01-09 23:55:52 +0000
commit6e25786914d5f8c50040471c8b1a950d2efb32a1 (patch)
tree96d33d5d58831f271a8b60aae666cb55f71bd660
parentb18f93ea5d57b8dff31c6cc706c6b4f32180c0c8 (diff)
parentbc12d6329ef72147da93881a34aab763905b1039 (diff)
downloadsystem_core-6e25786914d5f8c50040471c8b1a950d2efb32a1.zip
system_core-6e25786914d5f8c50040471c8b1a950d2efb32a1.tar.gz
system_core-6e25786914d5f8c50040471c8b1a950d2efb32a1.tar.bz2
Merge "Move BACKTRACE_NO_TID to BACKTRACE_CURRENT_THREAD."
-rw-r--r--include/backtrace/backtrace.h4
-rw-r--r--include/utils/CallStack.h2
-rw-r--r--libbacktrace/Backtrace.cpp4
-rw-r--r--libbacktrace/backtrace_test.cpp31
4 files changed, 24 insertions, 17 deletions
diff --git a/include/backtrace/backtrace.h b/include/backtrace/backtrace.h
index 186d327..fa81f21 100644
--- a/include/backtrace/backtrace.h
+++ b/include/backtrace/backtrace.h
@@ -28,8 +28,8 @@ __BEGIN_DECLS
// 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
+// current thread of the specified pid.
+#define BACKTRACE_CURRENT_THREAD -1
#define MAX_BACKTRACE_FRAMES 64
diff --git a/include/utils/CallStack.h b/include/utils/CallStack.h
index 5836037..bfe2ddb 100644
--- a/include/utils/CallStack.h
+++ b/include/utils/CallStack.h
@@ -44,7 +44,7 @@ public:
// Immediately collect the stack traces for the specified thread.
// The default is to dump the stack of the current call.
- void update(int32_t ignoreDepth=1, pid_t tid=BACKTRACE_NO_TID);
+ void update(int32_t ignoreDepth=1, pid_t tid=BACKTRACE_CURRENT_THREAD);
// Dump a stack trace to the log using the supplied logtag.
void log(const char* logtag,
diff --git a/libbacktrace/Backtrace.cpp b/libbacktrace/Backtrace.cpp
index ccfce81..a7568e0 100644
--- a/libbacktrace/Backtrace.cpp
+++ b/libbacktrace/Backtrace.cpp
@@ -219,12 +219,12 @@ bool BacktracePtrace::ReadWord(uintptr_t ptr, uint32_t* out_value) {
Backtrace* Backtrace::Create(pid_t pid, pid_t tid, backtrace_map_info_t* map_info) {
if (pid == BACKTRACE_CURRENT_PROCESS || pid == getpid()) {
- if (tid == BACKTRACE_NO_TID || tid == gettid()) {
+ if (tid == BACKTRACE_CURRENT_THREAD || tid == gettid()) {
return CreateCurrentObj(map_info);
} else {
return CreateThreadObj(tid, map_info);
}
- } else if (tid == BACKTRACE_NO_TID) {
+ } else if (tid == BACKTRACE_CURRENT_THREAD) {
return CreatePtraceObj(pid, pid, map_info);
} else {
return CreatePtraceObj(pid, tid, map_info);
diff --git a/libbacktrace/backtrace_test.cpp b/libbacktrace/backtrace_test.cpp
index 2603e1f..b894446 100644
--- a/libbacktrace/backtrace_test.cpp
+++ b/libbacktrace/backtrace_test.cpp
@@ -143,7 +143,8 @@ void VerifyLevelDump(const backtrace_t* backtrace) {
void VerifyLevelBacktrace(void*) {
backtrace_context_t context;
- ASSERT_TRUE(backtrace_create_context(&context, BACKTRACE_CURRENT_PROCESS, BACKTRACE_NO_TID, 0));
+ ASSERT_TRUE(backtrace_create_context(&context, BACKTRACE_CURRENT_PROCESS,
+ BACKTRACE_CURRENT_THREAD, 0));
VerifyLevelDump(context.backtrace);
@@ -165,7 +166,8 @@ void VerifyMaxDump(const backtrace_t* backtrace) {
void VerifyMaxBacktrace(void*) {
backtrace_context_t context;
- ASSERT_TRUE(backtrace_create_context(&context, BACKTRACE_CURRENT_PROCESS, BACKTRACE_NO_TID, 0));
+ ASSERT_TRUE(backtrace_create_context(&context, BACKTRACE_CURRENT_PROCESS,
+ BACKTRACE_CURRENT_THREAD, 0));
VerifyMaxDump(context.backtrace);
@@ -232,15 +234,18 @@ void VerifyIgnoreFrames(
void VerifyLevelIgnoreFrames(void*) {
backtrace_context_t all;
- ASSERT_TRUE(backtrace_create_context(&all, BACKTRACE_CURRENT_PROCESS, BACKTRACE_NO_TID, 0));
+ ASSERT_TRUE(backtrace_create_context(&all, BACKTRACE_CURRENT_PROCESS,
+ BACKTRACE_CURRENT_THREAD, 0));
ASSERT_TRUE(all.backtrace != NULL);
backtrace_context_t ign1;
- ASSERT_TRUE(backtrace_create_context(&ign1, BACKTRACE_CURRENT_PROCESS, BACKTRACE_NO_TID, 1));
+ ASSERT_TRUE(backtrace_create_context(&ign1, BACKTRACE_CURRENT_PROCESS,
+ BACKTRACE_CURRENT_THREAD, 1));
ASSERT_TRUE(ign1.backtrace != NULL);
backtrace_context_t ign2;
- ASSERT_TRUE(backtrace_create_context(&ign2, BACKTRACE_CURRENT_PROCESS, BACKTRACE_NO_TID, 2));
+ ASSERT_TRUE(backtrace_create_context(&ign2, BACKTRACE_CURRENT_PROCESS,
+ BACKTRACE_CURRENT_THREAD, 2));
ASSERT_TRUE(ign2.backtrace != NULL);
VerifyIgnoreFrames(all.backtrace, ign1.backtrace, ign2.backtrace,
@@ -296,7 +301,7 @@ TEST(libbacktrace, ptrace_trace) {
ASSERT_NE(test_level_one(1, 2, 3, 4, NULL, NULL), 0);
exit(1);
}
- VerifyProcTest(pid, BACKTRACE_NO_TID, ReadyLevelBacktrace, VerifyLevelDump);
+ VerifyProcTest(pid, BACKTRACE_CURRENT_THREAD, ReadyLevelBacktrace, VerifyLevelDump);
kill(pid, SIGKILL);
int status;
@@ -309,7 +314,7 @@ TEST(libbacktrace, ptrace_max_trace) {
ASSERT_NE(test_recursive_call(MAX_BACKTRACE_FRAMES+10, NULL, NULL), 0);
exit(1);
}
- VerifyProcTest(pid, BACKTRACE_NO_TID, ReadyMaxBacktrace, VerifyMaxDump);
+ VerifyProcTest(pid, BACKTRACE_CURRENT_THREAD, ReadyMaxBacktrace, VerifyMaxDump);
kill(pid, SIGKILL);
int status;
@@ -320,11 +325,11 @@ void VerifyProcessIgnoreFrames(const backtrace_t* bt_all) {
pid_t pid = bt_all->pid;
backtrace_context_t ign1;
- ASSERT_TRUE(backtrace_create_context(&ign1, pid, BACKTRACE_NO_TID, 1));
+ ASSERT_TRUE(backtrace_create_context(&ign1, pid, BACKTRACE_CURRENT_THREAD, 1));
ASSERT_TRUE(ign1.backtrace != NULL);
backtrace_context_t ign2;
- ASSERT_TRUE(backtrace_create_context(&ign2, pid, BACKTRACE_NO_TID, 2));
+ ASSERT_TRUE(backtrace_create_context(&ign2, pid, BACKTRACE_CURRENT_THREAD, 2));
ASSERT_TRUE(ign2.backtrace != NULL);
VerifyIgnoreFrames(bt_all, ign1.backtrace, ign2.backtrace, NULL);
@@ -339,7 +344,7 @@ TEST(libbacktrace, ptrace_ignore_frames) {
ASSERT_NE(test_level_one(1, 2, 3, 4, NULL, NULL), 0);
exit(1);
}
- VerifyProcTest(pid, BACKTRACE_NO_TID, ReadyLevelBacktrace, VerifyProcessIgnoreFrames);
+ VerifyProcTest(pid, BACKTRACE_CURRENT_THREAD, ReadyLevelBacktrace, VerifyProcessIgnoreFrames);
kill(pid, SIGKILL);
int status;
@@ -614,10 +619,12 @@ TEST(libbacktrace, thread_multiple_dump) {
TEST(libbacktrace, format_test) {
backtrace_context_t context;
- ASSERT_TRUE(backtrace_create_context(&context, BACKTRACE_CURRENT_PROCESS, BACKTRACE_NO_TID, 0));
+ ASSERT_TRUE(backtrace_create_context(&context, BACKTRACE_CURRENT_PROCESS,
+ BACKTRACE_CURRENT_THREAD, 0));
ASSERT_TRUE(context.backtrace != NULL);
- backtrace_frame_data_t* frame = const_cast<backtrace_frame_data_t*>(&context.backtrace->frames[1]);
+ backtrace_frame_data_t* frame =
+ const_cast<backtrace_frame_data_t*>(&context.backtrace->frames[1]);
backtrace_frame_data_t save_frame = *frame;
memset(frame, 0, sizeof(backtrace_frame_data_t));