File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 1010#include " common/BackTrace.h"
1111#include " common/version.h"
1212
13+ #ifndef __has_feature
14+ #define __has_feature (x ) 0
15+ #endif
16+
1317// a dummy function, so we can check "foo" in the backtrace.
1418// do not mark this function as static or put it into an anonymous namespace,
1519// otherwise it's function name will be removed in the backtrace.
1620std::string foo ()
1721{
1822 std::ostringstream oss;
23+ // but if ASan is enabled, backtrace() returns one more frame, and the
24+ // backtrace would look like:
25+ //
26+ // ceph version Development (no_version)
27+ // 1: (ceph::ClibBackTrace::ClibBackTrace(int)+0xf5) [0x555555722bf5]
28+ // 2: (foo[abi:cxx11]()+0x1fc) [0x555555721b5c]
29+ // 3: (BackTrace_Basic_Test::TestBody()+0x2db) [0x55555572208b]
30+ //
31+ // so we need to skip one more frame
32+ #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
33+ oss << ceph::ClibBackTrace (2 );
34+ #else
1935 oss << ceph::ClibBackTrace (1 );
36+ #endif
2037 return oss.str ();
2138}
2239
You can’t perform that action at this time.
0 commit comments