]> git.cworth.org Git - apitrace/blobdiff - common/os_backtrace.cpp
backtrace: Allow to build without libbacktrace.
[apitrace] / common / os_backtrace.cpp
index 1a555900b2c89f02c386b107757df4f340ce3ed5..c95692bd11a54b6e4bb7d2e7ea44c8b1accef767 100644 (file)
  */
 
 
-
 #include "os_backtrace.hpp"
 
-#if defined(ANDROID) || defined(__ELF__)
-
 #include <set>
+#include <vector>
 #include "os.hpp"
 
+#if defined(ANDROID)
+#  include <dlfcn.h>
+#elif HAVE_BACKTRACE
+#  include <stdint.h>
+#  include <dlfcn.h>
+#  include <unistd.h>
+#  include <map>
+#  include <vector>
+#  include <cxxabi.h>
+#  include <backtrace.h>
+#endif
+
+
 using trace::Id;
 
 namespace os {
@@ -111,16 +122,8 @@ bool backtrace_is_needed(const char* fname) {
     return backtraceFunctionNamePrefixes.contain(fname);
 }
 
-} /* namespace os */
-
 #if defined(ANDROID)
 
-#include <dlfcn.h>
-#include "os.hpp"
-#include <vector>
-
-namespace os {
-
 /* The following two declarations are copied from Android sources */
 
 enum DebugTargetKind {
@@ -274,21 +277,9 @@ void dump_backtrace() {
     /* TODO */
 }
 
-} /* namespace os */
 
-/* end ANDROID */
-#elif defined(__ELF__)
+#elif HAVE_BACKTRACE
 
-#include <stdint.h>
-#include <dlfcn.h>
-#include <unistd.h>
-#include <map>
-#include <vector>
-#include <cxxabi.h>
-
-#include <backtrace.h>
-
-namespace os {
 
 static char* format(uintptr_t num, int base, char *buf, int maxlen)
 {
@@ -480,8 +471,16 @@ void dump_backtrace() {
 }
 
 
-} /* namespace os */
+#else /* !HAVE_BACKTRACE */
 
-#endif /* __ELF__ */
+std::vector<RawStackFrame> get_backtrace() {
+    return std::vector<RawStackFrame>();
+}
 
-#endif /* ANDROID or LINUX */
+void dump_backtrace() {
+}
+
+#endif
+
+
+} /* namespace os */