From 9b0c0c0a997139b8b1da58bd72ca496e1ab6de1a Mon Sep 17 00:00:00 2001 From: "Dan Thompson (SBS)" Date: Tue, 23 Apr 2019 19:38:07 -0700 Subject: [PATCH] Detect and display 'stripped' PDB symbol type. --- DbgProvider/internal/Native/DbgHelp.cs | 26 ++++++++++++++++++++ DbgProvider/public/Debugger/DbgModuleInfo.cs | 15 +++++++++++ 2 files changed, 41 insertions(+) diff --git a/DbgProvider/internal/Native/DbgHelp.cs b/DbgProvider/internal/Native/DbgHelp.cs index 3a9e9f7..22eafe7 100644 --- a/DbgProvider/internal/Native/DbgHelp.cs +++ b/DbgProvider/internal/Native/DbgHelp.cs @@ -3764,6 +3764,32 @@ namespace MS.Dbg } return 0; } + + + public static IMAGEHLP_MODULEW64 GetModuleInfo( WDebugClient debugClient, + ulong address ) + { + return DbgEngDebugger._GlobalDebugger.ExecuteOnDbgEngThread( () => + { + return GetModuleInfo_naked( debugClient, address ); + } ); + } + + + private static unsafe IMAGEHLP_MODULEW64 GetModuleInfo_naked( WDebugClient debugClient, ulong address ) + { + IntPtr hProcess = _GetHProcForDebugClient( debugClient ); + + IMAGEHLP_MODULEW64 modInfo = new IMAGEHLP_MODULEW64(); + modInfo.SizeOfStruct = (uint) Marshal.SizeOf( modInfo ); + + bool itWorked = NativeMethods.SymGetModuleInfo64( hProcess, address, &modInfo ); + + if( !itWorked ) + throw new DbgEngException( Marshal.GetLastWin32Error() ); + + return modInfo; + } // end GetModuleInfo_naked() } // end class DbgHelp diff --git a/DbgProvider/public/Debugger/DbgModuleInfo.cs b/DbgProvider/public/Debugger/DbgModuleInfo.cs index e6feade..19e4b59 100644 --- a/DbgProvider/public/Debugger/DbgModuleInfo.cs +++ b/DbgProvider/public/Debugger/DbgModuleInfo.cs @@ -570,8 +570,23 @@ namespace MS.Dbg { DEBUG_SYMTYPE.SYM, new ColorString( "('sym' symbols)" ) .MakeReadOnly() }, }; + private static readonly ColorString s_strippedPdbStatusString = new ColorString( ConsoleColor.DarkGreen, "(pdb " ) + .AppendFg( ConsoleColor.DarkYellow ).Append( "(stripped)" ) + .AppendFg( ConsoleColor.DarkGreen ).Append( ")" ) + .MakeReadOnly(); + private ColorString _GetSymbolTypeString() { + if( SymbolType == DEBUG_SYMTYPE.PDB ) + { + var modInfo = DbgHelp.GetModuleInfo( Debugger.DebuggerInterface, BaseAddress ); + if( modInfo.GlobalSymbols == 0 ) + { + // Looks like a "stripped" PDB. + return s_strippedPdbStatusString; + } + } + ColorString cs; if( !sm_symStatusStrings.TryGetValue( SymbolType, out cs ) ) {