Fix PDB load logic. accepted/tizen/5.5/unified/20200316.155154 accepted/tizen/unified/20200315.214839 submit/tizen/20200313.020235 submit/tizen_5.5/20200313.020225
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Wed, 4 Mar 2020 12:12:56 +0000 (15:12 +0300)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Fri, 13 Mar 2020 01:53:52 +0000 (10:53 +0900)
Allow system and framework assemblies debugging in case of Just My Code feature enabled and PDBs are available.

src/debug/netcoredbg/jmc.cpp
src/debug/netcoredbg/manageddebugger.cpp
src/debug/netcoredbg/modules.cpp
src/debug/netcoredbg/modules.h

index 7041474923dcd2f15ab295fc97c1e932718372b4..dc7470875477049dce2c270f7f6b12efbad238a3 100644 (file)
@@ -71,14 +71,6 @@ static const std::unordered_set<std::string> 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;
index 1fedc47cdc7343cd54f7f6797ed17ffafe4e860f..41543480ae5ae74fcec8e032d42115cd8452a03d 100644 (file)
@@ -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)
index edb4eb411ae7cf27f8ec7c74ffd01936eefbbe4e..fa885879532be94c8a48ac2a1159fd6059937c73 100644 (file)
@@ -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> 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<ICorDebugModule2> 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<ICorDebugModule2> pModule2;
+        if (SUCCEEDED(pModule->QueryInterface(IID_ICorDebugModule2, (LPVOID *)&pModule2)))
+        {
+            pModule2->SetJMCStatus(true, 0, nullptr);
             SetJMCFromAttributes(pModule, symbolReader.get());
+        }
     }
 
     IfFailRet(GetModuleId(pModule, module.id));
index 063596db7a8dd06dc6b084bedf5a229f07153557..c747196d4efe4a086213a83f256b20d21168a946 100644 (file)
@@ -33,7 +33,6 @@ class Modules
     std::mutex m_modulesInfoMutex;
     std::unordered_map<CORDB_ADDRESS, ModuleInfo> 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();