From: Mikhail Kurinnoi Date: Wed, 4 Mar 2020 12:12:56 +0000 (+0300) Subject: Fix PDB load logic. X-Git-Tag: submit/tizen_5.5/20200313.020225^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c4024f148dceaedfb6ec206e29ebc0f9e1cefa6b;p=sdk%2Ftools%2Fnetcoredbg.git Fix PDB load logic. Allow system and framework assemblies debugging in case of Just My Code feature enabled and PDBs are available. --- diff --git a/src/debug/netcoredbg/jmc.cpp b/src/debug/netcoredbg/jmc.cpp index 7041474..dc74708 100644 --- a/src/debug/netcoredbg/jmc.cpp +++ b/src/debug/netcoredbg/jmc.cpp @@ -71,14 +71,6 @@ static const std::unordered_set g_operatorMethodNames "op_DivisionAssignment" // /= }; -bool Modules::ShouldLoadSymbolsForModule(const std::string &moduleName) -{ - std::string name = GetFileName(moduleName); - if (name.find("System.") == 0 || name.find("SOS.") == 0) - return false; - return true; -} - static bool HasAttribute(IMetaDataImport *pMD, mdToken tok, const std::string &attrName) { bool found = false; diff --git a/src/debug/netcoredbg/manageddebugger.cpp b/src/debug/netcoredbg/manageddebugger.cpp index 1fedc47..4154348 100644 --- a/src/debug/netcoredbg/manageddebugger.cpp +++ b/src/debug/netcoredbg/manageddebugger.cpp @@ -568,7 +568,7 @@ public: Module module; - m_debugger.m_modules.TryLoadModuleSymbols(pModule, module); + m_debugger.m_modules.TryLoadModuleSymbols(pModule, module, m_debugger.IsJustMyCode()); m_debugger.m_protocol->EmitModuleEvent(ModuleEvent(ModuleNew, module)); if (module.symbolStatus == SymbolsLoaded) diff --git a/src/debug/netcoredbg/modules.cpp b/src/debug/netcoredbg/modules.cpp index edb4eb4..fa88587 100644 --- a/src/debug/netcoredbg/modules.cpp +++ b/src/debug/netcoredbg/modules.cpp @@ -438,7 +438,8 @@ HRESULT Modules::GetModuleId(ICorDebugModule *pModule, std::string &id) HRESULT Modules::TryLoadModuleSymbols( ICorDebugModule *pModule, - Module &module + Module &module, + bool needJMC ) { HRESULT Status; @@ -453,23 +454,24 @@ HRESULT Modules::TryLoadModuleSymbols( std::unique_ptr symbolReader(new SymbolReader()); - if (ShouldLoadSymbolsForModule(module.path)) - { - symbolReader->LoadSymbols(pMDImport, pModule); - module.symbolStatus = symbolReader->SymbolsLoaded() ? SymbolsLoaded : SymbolsNotFound; - } - else - { - module.symbolStatus = SymbolsSkipped; - } + symbolReader->LoadSymbols(pMDImport, pModule); + module.symbolStatus = symbolReader->SymbolsLoaded() ? SymbolsLoaded : SymbolsNotFound; - // JMC stuff - ToRelease pModule2; - if (SUCCEEDED(pModule->QueryInterface(IID_ICorDebugModule2, (LPVOID *)&pModule2))) + if (needJMC && module.symbolStatus == SymbolsLoaded) { - pModule2->SetJMCStatus(module.symbolStatus == SymbolsLoaded, 0, nullptr); - if (module.symbolStatus == SymbolsLoaded) + // https://docs.microsoft.com/en-us/visualstudio/debugger/just-my-code + // The .NET debugger considers optimized binaries and non-loaded .pdb files to be non-user code. + // Three compiler attributes also affect what the .NET debugger considers to be user code: + // * DebuggerNonUserCodeAttribute tells the debugger that the code it's applied to isn't user code. + // * DebuggerHiddenAttribute hides the code from the debugger, even if Just My Code is turned off. + // * DebuggerStepThroughAttribute tells the debugger to step through the code it's applied to, rather than step into the code. + // The .NET debugger considers all other code to be user code. + ToRelease pModule2; + if (SUCCEEDED(pModule->QueryInterface(IID_ICorDebugModule2, (LPVOID *)&pModule2))) + { + pModule2->SetJMCStatus(true, 0, nullptr); SetJMCFromAttributes(pModule, symbolReader.get()); + } } IfFailRet(GetModuleId(pModule, module.id)); diff --git a/src/debug/netcoredbg/modules.h b/src/debug/netcoredbg/modules.h index 063596d..c747196 100644 --- a/src/debug/netcoredbg/modules.h +++ b/src/debug/netcoredbg/modules.h @@ -33,7 +33,6 @@ class Modules std::mutex m_modulesInfoMutex; std::unordered_map m_modulesInfo; - static bool ShouldLoadSymbolsForModule(const std::string &moduleName); static HRESULT SetJMCFromAttributes(ICorDebugModule *pModule, SymbolReader *symbolReader); static HRESULT ResolveMethodInModule( ICorDebugModule *pModule, @@ -94,7 +93,8 @@ public: HRESULT TryLoadModuleSymbols( ICorDebugModule *pModule, - Module &module); + Module &module, + bool needJMC); void CleanupAllModules();