Chromium Code Reviews| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(CFI_ENFORCEMENT) | |
| 285 if (signal == SIGILL && info->si_code == ILL_ILLOPN) { | |
| 286 PrintToStderr( | |
| 287 "CFI: Most likely a control flow integrity violation; for more " | |
| 288 "information see:\n"); | |
| 289 PrintToStderr( | |
| 290 "https://www.chromium.org/developers/testing/control-flow-integrity\n"); | |
| 291 } | |
| 292 #endif | |
| 293 | |
| 284 debug::StackTrace().Print(); | 294 debug::StackTrace().Print(); |
| 285 | 295 |
| 286 #if defined(OS_LINUX) | 296 #if defined(OS_LINUX) |
| 287 #if ARCH_CPU_X86_FAMILY | 297 #if ARCH_CPU_X86_FAMILY |
| 288 ucontext_t* context = reinterpret_cast<ucontext_t*>(void_context); | 298 ucontext_t* context = reinterpret_cast<ucontext_t*>(void_context); |
| 289 const struct { | 299 const struct { |
| 290 const char* label; | 300 const char* label; |
| 291 greg_t value; | 301 greg_t value; |
| 292 } registers[] = { | 302 } registers[] = { |
| 293 #if ARCH_CPU_32_BITS | 303 #if ARCH_CPU_32_BITS |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 "ip: %x, cs: %x, ds: %x, es: %x, fs: %x, gs: %x\n", | 398 "ip: %x, cs: %x, ds: %x, es: %x, fs: %x, gs: %x\n", |
| 389 context->uc_mcontext->__ss.__eip, | 399 context->uc_mcontext->__ss.__eip, |
| 390 context->uc_mcontext->__ss.__cs, | 400 context->uc_mcontext->__ss.__cs, |
| 391 context->uc_mcontext->__ss.__ds, | 401 context->uc_mcontext->__ss.__ds, |
| 392 context->uc_mcontext->__ss.__es, | 402 context->uc_mcontext->__ss.__es, |
| 393 context->uc_mcontext->__ss.__fs, | 403 context->uc_mcontext->__ss.__fs, |
| 394 context->uc_mcontext->__ss.__gs)); | 404 context->uc_mcontext->__ss.__gs)); |
| 395 write(STDERR_FILENO, buf, std::min(len, sizeof(buf) - 1)); | 405 write(STDERR_FILENO, buf, std::min(len, sizeof(buf) - 1)); |
| 396 #endif // ARCH_CPU_32_BITS | 406 #endif // ARCH_CPU_32_BITS |
| 397 #endif // defined(OS_MACOSX) | 407 #endif // defined(OS_MACOSX) |
| 408 | |
| 409 #if defined(CFI_ENFORCEMENT) | |
| 410 if (signal == SIGILL && info->si_code == ILL_ILLOPN) { | |
| 411 PrintToStderr("CFI: Aborting\n"); | |
| 412 } | |
| 413 #endif | |
|
Nico
2015/08/05 20:59:07
this block seems to not add anything useful
pcc1
2015/08/05 21:00:30
It acts as an end marker for the problem report. C
| |
| 414 | |
| 398 _exit(1); | 415 _exit(1); |
| 399 } | 416 } |
| 400 | 417 |
| 401 class PrintBacktraceOutputHandler : public BacktraceOutputHandler { | 418 class PrintBacktraceOutputHandler : public BacktraceOutputHandler { |
| 402 public: | 419 public: |
| 403 PrintBacktraceOutputHandler() {} | 420 PrintBacktraceOutputHandler() {} |
| 404 | 421 |
| 405 void HandleOutput(const char* output) override { | 422 void HandleOutput(const char* output) override { |
| 406 // NOTE: This code MUST be async-signal safe (it's used by in-process | 423 // NOTE: This code MUST be async-signal safe (it's used by in-process |
| 407 // stack dumping signal handler). NO malloc or stdio is allowed here. | 424 // stack dumping signal handler). NO malloc or stdio is allowed here. |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 825 *ptr = *start; | 842 *ptr = *start; |
| 826 *start++ = ch; | 843 *start++ = ch; |
| 827 } | 844 } |
| 828 return buf; | 845 return buf; |
| 829 } | 846 } |
| 830 | 847 |
| 831 } // namespace internal | 848 } // namespace internal |
| 832 | 849 |
| 833 } // namespace debug | 850 } // namespace debug |
| 834 } // namespace base | 851 } // namespace base |
| OLD | NEW |