-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstack_trace_posix.patch
64 lines (56 loc) · 1.78 KB
/
stack_trace_posix.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--- a/src/third_party/chromium/src/base/debug/stack_trace_posix.cc
+++ b/src/third_party/chromium/src/base/debug/stack_trace_posix.cc
@@ -5,7 +5,9 @@
#include "base/debug/stack_trace.h"
#include <errno.h>
+#if defined(HAVE_BACKTRACE)
#include <execinfo.h>
+#endif
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
@@ -64,7 +66,7 @@
// Note: code in this function is NOT async-signal safe (std::string uses
// malloc internally).
-#if defined(__GLIBCXX__)
+#if defined(__GLIBCXX__) && defined(HAVE_BACKTRACE)
std::string::size_type search_from = 0;
while (search_from < text->size()) {
@@ -145,7 +147,7 @@
handler->HandleOutput("\n");
}
-#else
+#elif defined(HAVE_BACKTRACE)
bool printed = false;
// Below part is async-signal unsafe (uses malloc), so execute it only
@@ -469,23 +471,31 @@
StackTrace::StackTrace() {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-
+#if defined(HAVE_BACKTRACE)
// Though the backtrace API man page does not list any possible negative
// return values, we take no chance.
count_ = std::max(backtrace(trace_, arraysize(trace_)), 0);
+#else
+ count_ = 0;
+#endif
}
void StackTrace::Print() const {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
-
+#if defined(HAVE_BACKTRACE)
PrintBacktraceOutputHandler handler;
ProcessBacktrace(trace_, count_, &handler);
+#endif
}
void StackTrace::OutputToStream(std::ostream* os) const {
+#if !defined(HAVE_BACKTRACE)
+(*os) << "(stack trace not supported)\n";
+#else
StreamBacktraceOutputHandler handler(os);
ProcessBacktrace(trace_, count_, &handler);
+#endif
}
namespace internal {