| OLD | NEW |
| 1 // Copyright (c) 2010, Google Inc. | 1 // Copyright (c) 2010, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #endif | 57 #endif |
| 58 #include <sys/types.h> | 58 #include <sys/types.h> |
| 59 #include <sys/ucontext.h> | 59 #include <sys/ucontext.h> |
| 60 #include <sys/user.h> | 60 #include <sys/user.h> |
| 61 #include <sys/utsname.h> | 61 #include <sys/utsname.h> |
| 62 #include <time.h> | 62 #include <time.h> |
| 63 #include <unistd.h> | 63 #include <unistd.h> |
| 64 | 64 |
| 65 #include <algorithm> | 65 #include <algorithm> |
| 66 | 66 |
| 67 #include "client/linux/dump_writer_common/seccomp_unwinder.h" | |
| 68 #include "client/linux/dump_writer_common/thread_info.h" | 67 #include "client/linux/dump_writer_common/thread_info.h" |
| 69 #include "client/linux/dump_writer_common/ucontext_reader.h" | 68 #include "client/linux/dump_writer_common/ucontext_reader.h" |
| 70 #include "client/linux/handler/exception_handler.h" | 69 #include "client/linux/handler/exception_handler.h" |
| 71 #include "client/linux/minidump_writer/cpu_set.h" | 70 #include "client/linux/minidump_writer/cpu_set.h" |
| 72 #include "client/linux/minidump_writer/line_reader.h" | 71 #include "client/linux/minidump_writer/line_reader.h" |
| 73 #include "client/linux/minidump_writer/linux_dumper.h" | 72 #include "client/linux/minidump_writer/linux_dumper.h" |
| 74 #include "client/linux/minidump_writer/linux_ptrace_dumper.h" | 73 #include "client/linux/minidump_writer/linux_ptrace_dumper.h" |
| 75 #include "client/linux/minidump_writer/proc_cpuinfo_reader.h" | 74 #include "client/linux/minidump_writer/proc_cpuinfo_reader.h" |
| 76 #include "client/minidump_file_writer.h" | 75 #include "client/minidump_file_writer.h" |
| 77 #include "common/linux/linux_libc_support.h" | 76 #include "common/linux/linux_libc_support.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 88 using google_breakpad::LinuxDumper; | 87 using google_breakpad::LinuxDumper; |
| 89 using google_breakpad::LinuxPtraceDumper; | 88 using google_breakpad::LinuxPtraceDumper; |
| 90 using google_breakpad::MDTypeHelper; | 89 using google_breakpad::MDTypeHelper; |
| 91 using google_breakpad::MappingEntry; | 90 using google_breakpad::MappingEntry; |
| 92 using google_breakpad::MappingInfo; | 91 using google_breakpad::MappingInfo; |
| 93 using google_breakpad::MappingList; | 92 using google_breakpad::MappingList; |
| 94 using google_breakpad::MinidumpFileWriter; | 93 using google_breakpad::MinidumpFileWriter; |
| 95 using google_breakpad::PageAllocator; | 94 using google_breakpad::PageAllocator; |
| 96 using google_breakpad::ProcCpuInfoReader; | 95 using google_breakpad::ProcCpuInfoReader; |
| 97 using google_breakpad::RawContextCPU; | 96 using google_breakpad::RawContextCPU; |
| 98 using google_breakpad::SeccompUnwinder; | |
| 99 using google_breakpad::ThreadInfo; | 97 using google_breakpad::ThreadInfo; |
| 100 using google_breakpad::TypedMDRVA; | 98 using google_breakpad::TypedMDRVA; |
| 101 using google_breakpad::UContextReader; | 99 using google_breakpad::UContextReader; |
| 102 using google_breakpad::UntypedMDRVA; | 100 using google_breakpad::UntypedMDRVA; |
| 103 using google_breakpad::wasteful_vector; | 101 using google_breakpad::wasteful_vector; |
| 104 | 102 |
| 105 typedef MDTypeHelper<sizeof(void*)>::MDRawDebug MDRawDebug; | 103 typedef MDTypeHelper<sizeof(void*)>::MDRawDebug MDRawDebug; |
| 106 typedef MDTypeHelper<sizeof(void*)>::MDRawLinkMap MDRawLinkMap; | 104 typedef MDTypeHelper<sizeof(void*)>::MDRawLinkMap MDRawLinkMap; |
| 107 | 105 |
| 108 class MinidumpWriter { | 106 class MinidumpWriter { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 374 |
| 377 TypedMDRVA<RawContextCPU> cpu(&minidump_writer_); | 375 TypedMDRVA<RawContextCPU> cpu(&minidump_writer_); |
| 378 if (!cpu.Allocate()) | 376 if (!cpu.Allocate()) |
| 379 return false; | 377 return false; |
| 380 my_memset(cpu.get(), 0, sizeof(RawContextCPU)); | 378 my_memset(cpu.get(), 0, sizeof(RawContextCPU)); |
| 381 #if !defined(__ARM_EABI__) && !defined(__mips__) | 379 #if !defined(__ARM_EABI__) && !defined(__mips__) |
| 382 UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_); | 380 UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_); |
| 383 #else | 381 #else |
| 384 UContextReader::FillCPUContext(cpu.get(), ucontext_); | 382 UContextReader::FillCPUContext(cpu.get(), ucontext_); |
| 385 #endif | 383 #endif |
| 386 if (stack_copy) | |
| 387 SeccompUnwinder::PopSeccompStackFrame(cpu.get(), thread, stack_copy); | |
| 388 thread.thread_context = cpu.location(); | 384 thread.thread_context = cpu.location(); |
| 389 crashing_thread_context_ = cpu.location(); | 385 crashing_thread_context_ = cpu.location(); |
| 390 } else { | 386 } else { |
| 391 ThreadInfo info; | 387 ThreadInfo info; |
| 392 if (!dumper_->GetThreadInfoByIndex(i, &info)) | 388 if (!dumper_->GetThreadInfoByIndex(i, &info)) |
| 393 return false; | 389 return false; |
| 394 | 390 |
| 395 uint8_t* stack_copy; | 391 uint8_t* stack_copy; |
| 396 int max_stack_len = -1; // default to no maximum for this thread | 392 int max_stack_len = -1; // default to no maximum for this thread |
| 397 if (minidump_size_limit_ >= 0 && i >= kLimitBaseThreadCount) | 393 if (minidump_size_limit_ >= 0 && i >= kLimitBaseThreadCount) |
| 398 max_stack_len = extra_thread_stack_len; | 394 max_stack_len = extra_thread_stack_len; |
| 399 if (!FillThreadStack(&thread, info.stack_pointer, max_stack_len, | 395 if (!FillThreadStack(&thread, info.stack_pointer, max_stack_len, |
| 400 &stack_copy)) | 396 &stack_copy)) |
| 401 return false; | 397 return false; |
| 402 | 398 |
| 403 TypedMDRVA<RawContextCPU> cpu(&minidump_writer_); | 399 TypedMDRVA<RawContextCPU> cpu(&minidump_writer_); |
| 404 if (!cpu.Allocate()) | 400 if (!cpu.Allocate()) |
| 405 return false; | 401 return false; |
| 406 my_memset(cpu.get(), 0, sizeof(RawContextCPU)); | 402 my_memset(cpu.get(), 0, sizeof(RawContextCPU)); |
| 407 info.FillCPUContext(cpu.get()); | 403 info.FillCPUContext(cpu.get()); |
| 408 if (stack_copy) | |
| 409 SeccompUnwinder::PopSeccompStackFrame(cpu.get(), thread, stack_copy); | |
| 410 thread.thread_context = cpu.location(); | 404 thread.thread_context = cpu.location(); |
| 411 if (dumper_->threads()[i] == GetCrashThread()) { | 405 if (dumper_->threads()[i] == GetCrashThread()) { |
| 412 crashing_thread_context_ = cpu.location(); | 406 crashing_thread_context_ = cpu.location(); |
| 413 if (!dumper_->IsPostMortem()) { | 407 if (!dumper_->IsPostMortem()) { |
| 414 // This is the crashing thread of a live process, but | 408 // This is the crashing thread of a live process, but |
| 415 // no context was provided, so set the crash address | 409 // no context was provided, so set the crash address |
| 416 // while the instruction pointer is already here. | 410 // while the instruction pointer is already here. |
| 417 dumper_->set_crash_address(info.GetInstructionPointer()); | 411 dumper_->set_crash_address(info.GetInstructionPointer()); |
| 418 } | 412 } |
| 419 } | 413 } |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 const MappingList& mappings, | 1358 const MappingList& mappings, |
| 1365 const AppMemoryList& appmem, | 1359 const AppMemoryList& appmem, |
| 1366 LinuxDumper* dumper) { | 1360 LinuxDumper* dumper) { |
| 1367 MinidumpWriter writer(filename, -1, NULL, mappings, appmem, dumper); | 1361 MinidumpWriter writer(filename, -1, NULL, mappings, appmem, dumper); |
| 1368 if (!writer.Init()) | 1362 if (!writer.Init()) |
| 1369 return false; | 1363 return false; |
| 1370 return writer.Dump(); | 1364 return writer.Dump(); |
| 1371 } | 1365 } |
| 1372 | 1366 |
| 1373 } // namespace google_breakpad | 1367 } // namespace google_breakpad |
| OLD | NEW |