| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/debug/stack_trace.h" | 5 #include "base/debug/stack_trace.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <signal.h> | 9 #include <signal.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 void StackTrace::Print() const { | 752 void StackTrace::Print() const { |
| 753 // NOTE: This code MUST be async-signal safe (it's used by in-process | 753 // NOTE: This code MUST be async-signal safe (it's used by in-process |
| 754 // stack dumping signal handler). NO malloc or stdio is allowed here. | 754 // stack dumping signal handler). NO malloc or stdio is allowed here. |
| 755 | 755 |
| 756 #if !defined(__UCLIBC__) && !defined(FNL_MUSL) | 756 #if !defined(__UCLIBC__) && !defined(FNL_MUSL) |
| 757 PrintBacktraceOutputHandler handler; | 757 PrintBacktraceOutputHandler handler; |
| 758 ProcessBacktrace(trace_, count_, &handler); | 758 ProcessBacktrace(trace_, count_, &handler); |
| 759 #endif | 759 #endif |
| 760 } | 760 } |
| 761 | 761 |
| 762 #if !defined(__UCLIBC__) && !defined(FNL_MUSL) | |
| 763 void StackTrace::OutputToStream(std::ostream* os) const { | 762 void StackTrace::OutputToStream(std::ostream* os) const { |
| 763 #if defined(__UCLIBC__) || defined(FNL_MUSL) |
| 764 (*os) << "(stack trace not supported)\n"; |
| 765 #else |
| 764 StreamBacktraceOutputHandler handler(os); | 766 StreamBacktraceOutputHandler handler(os); |
| 765 ProcessBacktrace(trace_, count_, &handler); | 767 ProcessBacktrace(trace_, count_, &handler); |
| 768 #endif |
| 766 } | 769 } |
| 767 #endif | |
| 768 | 770 |
| 769 namespace internal { | 771 namespace internal { |
| 770 | 772 |
| 771 // NOTE: code from sandbox/linux/seccomp-bpf/demo.cc. | 773 // NOTE: code from sandbox/linux/seccomp-bpf/demo.cc. |
| 772 char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) { | 774 char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) { |
| 773 // Make sure we can write at least one NUL byte. | 775 // Make sure we can write at least one NUL byte. |
| 774 size_t n = 1; | 776 size_t n = 1; |
| 775 if (n > sz) | 777 if (n > sz) |
| 776 return NULL; | 778 return NULL; |
| 777 | 779 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 *ptr = *start; | 828 *ptr = *start; |
| 827 *start++ = ch; | 829 *start++ = ch; |
| 828 } | 830 } |
| 829 return buf; | 831 return buf; |
| 830 } | 832 } |
| 831 | 833 |
| 832 } // namespace internal | 834 } // namespace internal |
| 833 | 835 |
| 834 } // namespace debug | 836 } // namespace debug |
| 835 } // namespace base | 837 } // namespace base |
| OLD | NEW |