summaryrefslogtreecommitdiffstats
path: root/libbacktrace/backtrace_test.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2015-03-31 17:28:22 -0700
committerChristopher Ferris <cferris@google.com>2015-04-01 15:58:20 -0700
commitca09ce902c17c2bffc02bfafaf0844204ac13333 (patch)
treeb2e3d6aee81be584523cc67b8117edb28276e961 /libbacktrace/backtrace_test.cpp
parent9dc41d5d34c792e7a05e1ddfeea99c6cfc02fffd (diff)
downloadsystem_core-ca09ce902c17c2bffc02bfafaf0844204ac13333.zip
system_core-ca09ce902c17c2bffc02bfafaf0844204ac13333.tar.gz
system_core-ca09ce902c17c2bffc02bfafaf0844204ac13333.tar.bz2
Discards frames for code within library.
When doing a local unwind, do not include the frames that come from either libunwind or libbacktrace. Bug: 11518609 Change-Id: I0ec8d823aebbfa0903e61b16b7e5663f3fd65e78
Diffstat (limited to 'libbacktrace/backtrace_test.cpp')
-rw-r--r--libbacktrace/backtrace_test.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/libbacktrace/backtrace_test.cpp b/libbacktrace/backtrace_test.cpp
index d408856..5de80b1 100644
--- a/libbacktrace/backtrace_test.cpp
+++ b/libbacktrace/backtrace_test.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#define _GNU_SOURCE 1
#include <dirent.h>
#include <errno.h>
#include <inttypes.h>
@@ -200,6 +201,23 @@ bool WaitForNonZero(int32_t* value, uint64_t seconds) {
return false;
}
+TEST(libbacktrace, local_no_unwind_frames) {
+ // Verify that a local unwind does not include any frames within
+ // libunwind or libbacktrace.
+ std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), getpid()));
+ ASSERT_TRUE(backtrace->Unwind(0));
+
+ ASSERT_TRUE(backtrace->NumFrames() != 0);
+ for (const auto& frame : *backtrace ) {
+ if (BacktraceMap::IsValid(frame.map)) {
+ const std::string name = basename(frame.map.name.c_str());
+ ASSERT_TRUE(name != "libunwind.so" && name != "libbacktrace.so")
+ << DumpFrames(backtrace.get());
+ }
+ break;
+ }
+}
+
TEST(libbacktrace, local_trace) {
ASSERT_NE(test_level_one(1, 2, 3, 4, VerifyLevelBacktrace, nullptr), 0);
}