| 5738 | } |
| 5739 | |
| 5740 | bool DbgModule::ReadCOFF(DataStream* stream, DbgModuleKind moduleKind) |
| 5741 | { |
| 5742 | BP_ZONE("DbgModule::ReadCOFF"); |
| 5743 | |
| 5744 | //if (this == mDebugTarget->mTargetBinary) |
| 5745 | //mMemReporter = new MemReporter(); |
| 5746 | |
| 5747 | BfLogDbg("DbgModule::ReadCOFF %p %s\n", this, mFilePath.c_str()); |
| 5748 | |
| 5749 | if (mMemReporter != NULL) |
| 5750 | { |
| 5751 | mMemReporter->BeginSection(StrFormat("Module: %s", mFilePath.c_str())); |
| 5752 | mMemReporter->Add(mImageSize); |
| 5753 | } |
| 5754 | defer |
| 5755 | ( |
| 5756 | if (mMemReporter != NULL) |
| 5757 | mMemReporter->EndSection(); |
| 5758 | ); |
| 5759 | |
| 5760 | DbgModule* mainModule = mDebugTarget->mTargetBinary; |
| 5761 | |
| 5762 | MiniDumpDebugger* miniDumpDebugger = NULL; |
| 5763 | if (mDebugger->IsMiniDumpDebugger()) |
| 5764 | { |
| 5765 | miniDumpDebugger = (MiniDumpDebugger*)mDebugger; |
| 5766 | } |
| 5767 | |
| 5768 | mModuleKind = moduleKind; |
| 5769 | bool isHotSwap = mModuleKind == DbgModuleKind_HotObject; |
| 5770 | bool isObjectFile = mModuleKind != DbgModuleKind_Module; |
| 5771 | |
| 5772 | auto linkedModule = GetLinkedModule(); |
| 5773 | |
| 5774 | if (isObjectFile) |
| 5775 | linkedModule->PopulateStaticVariableMap(); |
| 5776 | |
| 5777 | mStartTypeIdx = (int)linkedModule->mTypes.size(); |
| 5778 | int startSrcFile = (int)mDebugTarget->mSrcFiles.size(); |
| 5779 | mStartSubprogramIdx = (int)mSubprograms.size(); |
| 5780 | |
| 5781 | PEHeader hdr; |
| 5782 | memset(&hdr, 0, sizeof(hdr)); |
| 5783 | |
| 5784 | PE_NTHeaders ntHdr; |
| 5785 | memset(&ntHdr, 0, sizeof(ntHdr)); |
| 5786 | |
| 5787 | if (!isObjectFile) |
| 5788 | { |
| 5789 | stream->Read(&hdr, sizeof(PEHeader)); |
| 5790 | stream->SetPos(hdr.e_lfanew); |
| 5791 | |
| 5792 | stream->Read(&ntHdr, sizeof(PE_NTHeaders)); |
| 5793 | |
| 5794 | mPreferredImageBase = ntHdr.mOptionalHeader.mImageBase; |
| 5795 | if (mImageBase == 0) |
| 5796 | { |
| 5797 | BF_ASSERT(this == mainModule); |
no test coverage detected