Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: base/debug/stack_trace_posix.cc

Issue 354873002: stub out debug::StackTrace().Print() when using uclibc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: stub out StackTrace::Print instead Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/debug/stack_trace.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 PrintToStderr(" <unknown> "); 274 PrintToStderr(" <unknown> ");
275 } 275 }
276 if (signal == SIGBUS || signal == SIGFPE || 276 if (signal == SIGBUS || signal == SIGFPE ||
277 signal == SIGILL || signal == SIGSEGV) { 277 signal == SIGILL || signal == SIGSEGV) {
278 internal::itoa_r(reinterpret_cast<intptr_t>(info->si_addr), 278 internal::itoa_r(reinterpret_cast<intptr_t>(info->si_addr),
279 buf, sizeof(buf), 16, 12); 279 buf, sizeof(buf), 16, 12);
280 PrintToStderr(buf); 280 PrintToStderr(buf);
281 } 281 }
282 PrintToStderr("\n"); 282 PrintToStderr("\n");
283 283
284 #if !defined(__UCLIBC__)
285 debug::StackTrace().Print(); 284 debug::StackTrace().Print();
286 #endif
287 285
288 #if defined(OS_LINUX) 286 #if defined(OS_LINUX)
289 #if ARCH_CPU_X86_FAMILY 287 #if ARCH_CPU_X86_FAMILY
290 ucontext_t* context = reinterpret_cast<ucontext_t*>(void_context); 288 ucontext_t* context = reinterpret_cast<ucontext_t*>(void_context);
291 const struct { 289 const struct {
292 const char* label; 290 const char* label;
293 greg_t value; 291 greg_t value;
294 } registers[] = { 292 } registers[] = {
295 #if ARCH_CPU_32_BITS 293 #if ARCH_CPU_32_BITS
296 { " gs: ", context->uc_mcontext.gregs[REG_GS] }, 294 { " gs: ", context->uc_mcontext.gregs[REG_GS] },
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 742
745 #if !defined(__UCLIBC__) 743 #if !defined(__UCLIBC__)
746 // Though the backtrace API man page does not list any possible negative 744 // Though the backtrace API man page does not list any possible negative
747 // return values, we take no chance. 745 // return values, we take no chance.
748 count_ = base::saturated_cast<size_t>(backtrace(trace_, arraysize(trace_))); 746 count_ = base::saturated_cast<size_t>(backtrace(trace_, arraysize(trace_)));
749 #else 747 #else
750 count_ = 0; 748 count_ = 0;
751 #endif 749 #endif
752 } 750 }
753 751
752 void StackTrace::Print() const {
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.
755
756 #if !defined(__UCLIBC__)
757 PrintBacktraceOutputHandler handler;
758 ProcessBacktrace(trace_, count_, &handler);
759 #endif
760 }
761
754 #if !defined(__UCLIBC__) 762 #if !defined(__UCLIBC__)
755 void StackTrace::Print() const {
756 // NOTE: This code MUST be async-signal safe (it's used by in-process
757 // stack dumping signal handler). NO malloc or stdio is allowed here.
758
759 PrintBacktraceOutputHandler handler;
760 ProcessBacktrace(trace_, count_, &handler);
761 }
762
763 void StackTrace::OutputToStream(std::ostream* os) const { 763 void StackTrace::OutputToStream(std::ostream* os) const {
764 StreamBacktraceOutputHandler handler(os); 764 StreamBacktraceOutputHandler handler(os);
765 ProcessBacktrace(trace_, count_, &handler); 765 ProcessBacktrace(trace_, count_, &handler);
766 } 766 }
767 #endif 767 #endif
768 768
769 namespace internal { 769 namespace internal {
770 770
771 // NOTE: code from sandbox/linux/seccomp-bpf/demo.cc. 771 // 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) { 772 char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 *ptr = *start; 826 *ptr = *start;
827 *start++ = ch; 827 *start++ = ch;
828 } 828 }
829 return buf; 829 return buf;
830 } 830 }
831 831
832 } // namespace internal 832 } // namespace internal
833 833
834 } // namespace debug 834 } // namespace debug
835 } // namespace base 835 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/stack_trace.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698