Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, Google Inc. | 1 // Copyright (c) 2014, 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 14 matching lines...) Expand all Loading... | |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | 29 |
| 30 // This translation unit generates microdumps into the console (logcat on | 30 // This translation unit generates microdumps into the console (logcat on |
| 31 // Android). See crbug.com/410294 for more info and design docs. | 31 // Android). See crbug.com/410294 for more info and design docs. |
| 32 | 32 |
| 33 #include "client/linux/microdump_writer/microdump_writer.h" | 33 #include "client/linux/microdump_writer/microdump_writer.h" |
| 34 | 34 |
| 35 #include <algorithm> | |
|
Lei Zhang
2016/02/10 23:08:50
nit: C headers before C++ headers.
| |
| 35 #include <sys/utsname.h> | 36 #include <sys/utsname.h> |
| 36 | 37 |
| 37 #include "client/linux/dump_writer_common/thread_info.h" | 38 #include "client/linux/dump_writer_common/thread_info.h" |
| 38 #include "client/linux/dump_writer_common/ucontext_reader.h" | 39 #include "client/linux/dump_writer_common/ucontext_reader.h" |
| 39 #include "client/linux/handler/exception_handler.h" | 40 #include "client/linux/handler/exception_handler.h" |
| 40 #include "client/linux/handler/microdump_extra_info.h" | 41 #include "client/linux/handler/microdump_extra_info.h" |
| 41 #include "client/linux/log/log.h" | 42 #include "client/linux/log/log.h" |
| 42 #include "client/linux/minidump_writer/linux_ptrace_dumper.h" | 43 #include "client/linux/minidump_writer/linux_ptrace_dumper.h" |
| 44 #include "common/linux/file_id.h" | |
| 43 #include "common/linux/linux_libc_support.h" | 45 #include "common/linux/linux_libc_support.h" |
| 44 | 46 |
| 45 namespace { | 47 namespace { |
| 46 | 48 |
| 47 using google_breakpad::ExceptionHandler; | 49 using google_breakpad::ExceptionHandler; |
| 50 using google_breakpad::kMaxBuildID; | |
| 48 using google_breakpad::LinuxDumper; | 51 using google_breakpad::LinuxDumper; |
| 49 using google_breakpad::LinuxPtraceDumper; | 52 using google_breakpad::LinuxPtraceDumper; |
| 50 using google_breakpad::MappingInfo; | 53 using google_breakpad::MappingInfo; |
| 51 using google_breakpad::MappingList; | 54 using google_breakpad::MappingList; |
| 52 using google_breakpad::MicrodumpExtraInfo; | 55 using google_breakpad::MicrodumpExtraInfo; |
| 53 using google_breakpad::RawContextCPU; | 56 using google_breakpad::RawContextCPU; |
| 54 using google_breakpad::ThreadInfo; | 57 using google_breakpad::ThreadInfo; |
| 55 using google_breakpad::UContextReader; | 58 using google_breakpad::UContextReader; |
| 56 | 59 |
| 57 const size_t kLineBufferSize = 2048; | 60 const size_t kLineBufferSize = 2048; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 } | 332 } |
| 330 return false; | 333 return false; |
| 331 } | 334 } |
| 332 | 335 |
| 333 // Dump information about the provided |mapping|. If |identifier| is non-NULL, | 336 // Dump information about the provided |mapping|. If |identifier| is non-NULL, |
| 334 // use it instead of calculating a file ID from the mapping. | 337 // use it instead of calculating a file ID from the mapping. |
| 335 void DumpModule(const MappingInfo& mapping, | 338 void DumpModule(const MappingInfo& mapping, |
| 336 bool member, | 339 bool member, |
| 337 unsigned int mapping_id, | 340 unsigned int mapping_id, |
| 338 const uint8_t* identifier) { | 341 const uint8_t* identifier) { |
| 339 MDGUID module_identifier; | 342 uint8_t identifier_bytes[kMaxBuildID]; |
| 343 size_t identifier_length = 0; | |
| 340 if (identifier) { | 344 if (identifier) { |
| 341 // GUID was provided by caller. | 345 // GUID was provided by caller. |
| 342 my_memcpy(&module_identifier, identifier, sizeof(MDGUID)); | 346 my_memcpy(&identifier_bytes, identifier, sizeof(MDGUID)); |
| 347 identifier_length = sizeof(MDGUID); | |
| 343 } else { | 348 } else { |
| 344 dumper_->ElfFileIdentifierForMapping( | 349 dumper_->ElfFileIdentifierForMapping( |
| 345 mapping, | 350 mapping, |
| 346 member, | 351 member, |
| 347 mapping_id, | 352 mapping_id, |
| 348 reinterpret_cast<uint8_t*>(&module_identifier)); | 353 identifier_bytes, |
| 354 &identifier_length); | |
| 349 } | 355 } |
| 350 | 356 |
| 357 // Copy as many bytes of |identifier| as will fit into a MDGUID | |
| 358 MDGUID module_identifier = {0}; | |
| 359 memcpy(&module_identifier, identifier_bytes, | |
| 360 std::min(sizeof(MDGUID), identifier_length)); | |
| 361 | |
| 351 char file_name[NAME_MAX]; | 362 char file_name[NAME_MAX]; |
| 352 char file_path[NAME_MAX]; | 363 char file_path[NAME_MAX]; |
| 353 LinuxDumper::GetMappingEffectiveNameAndPath( | 364 LinuxDumper::GetMappingEffectiveNameAndPath( |
| 354 mapping, file_path, sizeof(file_path), file_name, sizeof(file_name)); | 365 mapping, file_path, sizeof(file_path), file_name, sizeof(file_name)); |
| 355 | 366 |
| 356 LogAppend("M "); | 367 LogAppend("M "); |
| 357 LogAppend(static_cast<uintptr_t>(mapping.start_addr)); | 368 LogAppend(static_cast<uintptr_t>(mapping.start_addr)); |
| 358 LogAppend(" "); | 369 LogAppend(" "); |
| 359 LogAppend(mapping.offset); | 370 LogAppend(mapping.offset); |
| 360 LogAppend(" "); | 371 LogAppend(" "); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 dumper.set_crash_signal(context->siginfo.si_signo); | 441 dumper.set_crash_signal(context->siginfo.si_signo); |
| 431 dumper.set_crash_thread(context->tid); | 442 dumper.set_crash_thread(context->tid); |
| 432 } | 443 } |
| 433 MicrodumpWriter writer(context, mappings, microdump_extra_info, &dumper); | 444 MicrodumpWriter writer(context, mappings, microdump_extra_info, &dumper); |
| 434 if (!writer.Init()) | 445 if (!writer.Init()) |
| 435 return false; | 446 return false; |
| 436 return writer.Dump(); | 447 return writer.Dump(); |
| 437 } | 448 } |
| 438 | 449 |
| 439 } // namespace google_breakpad | 450 } // namespace google_breakpad |
| OLD | NEW |