| OLD | NEW |
| 1 // Copyright (c) 2009, Google Inc. | 1 // Copyright (c) 2009, 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 505 |
| 506 for (unsigned i = 0, j = 0; i < num_mappings; ++i) { | 506 for (unsigned i = 0, j = 0; i < num_mappings; ++i) { |
| 507 const MappingInfo& mapping = *dumper_.mappings()[i]; | 507 const MappingInfo& mapping = *dumper_.mappings()[i]; |
| 508 if (!ShouldIncludeMapping(mapping)) | 508 if (!ShouldIncludeMapping(mapping)) |
| 509 continue; | 509 continue; |
| 510 | 510 |
| 511 MDRawModule mod; | 511 MDRawModule mod; |
| 512 my_memset(&mod, 0, sizeof(mod)); | 512 my_memset(&mod, 0, sizeof(mod)); |
| 513 mod.base_of_image = mapping.start_addr; | 513 mod.base_of_image = mapping.start_addr; |
| 514 mod.size_of_image = mapping.size; | 514 mod.size_of_image = mapping.size; |
| 515 UntypedMDRVA memory(&minidump_writer_); | 515 const size_t filepath_len = my_strlen(mapping.name); |
| 516 const size_t filename_len = my_strlen(mapping.name); | |
| 517 | 516 |
| 518 TypedMDRVA<MDCVInfoPDB70> cv(&minidump_writer_); | 517 // Figure out file name from path |
| 519 if (!cv.Allocate()) | 518 const char* filename_ptr = mapping.name + filepath_len - 1; |
| 519 while (filename_ptr >= mapping.name) { |
| 520 if (*filename_ptr == '/') |
| 521 break; |
| 522 filename_ptr--; |
| 523 } |
| 524 filename_ptr++; |
| 525 const size_t filename_len = mapping.name + filepath_len - filename_ptr; |
| 526 |
| 527 uint8_t cv_buf[MDCVInfoPDB70_minsize + NAME_MAX]; |
| 528 uint8_t* cv_ptr = cv_buf; |
| 529 UntypedMDRVA cv(&minidump_writer_); |
| 530 if (!cv.Allocate(MDCVInfoPDB70_minsize + filename_len + 1)) |
| 520 return false; | 531 return false; |
| 521 my_memset(cv.get(), 0, sizeof(MDCVInfoPDB70)); | 532 |
| 522 cv.get()->cv_signature = MD_CVINFOPDB70_SIGNATURE; | 533 const uint32_t cv_signature = MD_CVINFOPDB70_SIGNATURE; |
| 534 memcpy(cv_ptr, &cv_signature, sizeof(cv_signature)); |
| 535 cv_ptr += sizeof(cv_signature); |
| 523 | 536 |
| 524 { | 537 { |
| 525 // We XOR the first page of the file to get a signature for it. | 538 // We XOR the first page of the file to get a signature for it. |
| 526 uint8_t xor_buf[sizeof(MDGUID)]; | 539 uint8_t xor_buf[sizeof(MDGUID)]; |
| 527 size_t done = 0; | 540 size_t done = 0; |
| 528 uint8_t* const signature = (uint8_t*) &cv.get()->signature; | 541 uint8_t* signature = cv_ptr; |
| 542 cv_ptr += sizeof(xor_buf); |
| 529 | 543 |
| 544 my_memset(signature, 0, sizeof(xor_buf)); |
| 530 while (done < 4096) { | 545 while (done < 4096) { |
| 531 dumper_.CopyFromProcess(xor_buf, crashing_tid_, | 546 dumper_.CopyFromProcess(xor_buf, crashing_tid_, |
| 532 (void *) (mod.base_of_image + done), | 547 (void *) (mod.base_of_image + done), |
| 533 sizeof(xor_buf)); | 548 sizeof(xor_buf)); |
| 534 for (unsigned i = 0; i < sizeof(xor_buf); ++i) | 549 for (unsigned i = 0; i < sizeof(xor_buf); ++i) |
| 535 signature[i] ^= xor_buf[i]; | 550 signature[i] ^= xor_buf[i]; |
| 536 done += sizeof(xor_buf); | 551 done += sizeof(xor_buf); |
| 537 } | 552 } |
| 553 cv_ptr += sizeof(uint32_t); // Skip age field |
| 538 } | 554 } |
| 539 | 555 |
| 556 // Write pdb_file_name |
| 557 memcpy(cv_ptr, filename_ptr, filename_len + 1); |
| 558 cv.Copy(cv_buf, MDCVInfoPDB70_minsize + filename_len + 1); |
| 559 |
| 540 mod.cv_record = cv.location(); | 560 mod.cv_record = cv.location(); |
| 541 | 561 |
| 542 if (filename_len) { | 562 MDLocationDescriptor ld; |
| 543 MDLocationDescriptor ld; | 563 if (!minidump_writer_.WriteString(mapping.name, filepath_len, &ld)) |
| 544 if (!minidump_writer_.WriteString(mapping.name, filename_len, &ld)) | 564 return false; |
| 545 return false; | 565 mod.module_name_rva = ld.rva; |
| 546 mod.module_name_rva = ld.rva; | |
| 547 } | |
| 548 | 566 |
| 549 list.CopyIndexAfterObject(j++, &mod, sizeof(mod)); | 567 list.CopyIndexAfterObject(j++, &mod, sizeof(mod)); |
| 550 } | 568 } |
| 551 | 569 |
| 552 return true; | 570 return true; |
| 553 } | 571 } |
| 554 | 572 |
| 555 bool WriteExceptionStream(MDRawDirectory* dirent) { | 573 bool WriteExceptionStream(MDRawDirectory* dirent) { |
| 556 TypedMDRVA<MDRawExceptionStream> exc(&minidump_writer_); | 574 TypedMDRVA<MDRawExceptionStream> exc(&minidump_writer_); |
| 557 if (!exc.Allocate()) | 575 if (!exc.Allocate()) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 return false; | 687 return false; |
| 670 const ExceptionHandler::CrashContext* context = | 688 const ExceptionHandler::CrashContext* context = |
| 671 reinterpret_cast<const ExceptionHandler::CrashContext*>(blob); | 689 reinterpret_cast<const ExceptionHandler::CrashContext*>(blob); |
| 672 MinidumpWriter writer(filename, crashing_process, context); | 690 MinidumpWriter writer(filename, crashing_process, context); |
| 673 if (!writer.Init()) | 691 if (!writer.Init()) |
| 674 return false; | 692 return false; |
| 675 return writer.Dump(); | 693 return writer.Dump(); |
| 676 } | 694 } |
| 677 | 695 |
| 678 } // namespace google_breakpad | 696 } // namespace google_breakpad |
| OLD | NEW |