public async Task <SSymbolResult> LookupGlobalSymbol(string module, string symbol, string typename, string[] scopes) { NotifyDebuggerMessage(String.Format("Looking up value of global {0}...", symbol)); // For GDB, we use scope instead of typename to disambiguate globals. string symbolName = GetScopePrefix(scopes) + symbol; string pythonResult = await this.QueryDebuggerPython(String.Format("LookupGlobalSymbol(\"{0}\",\"{1}\")", module, symbolName)); // '{%s#%d}' % (self.type, self.pointer) if (pythonResult == "None") { throw new DebuggerException(String.Format("Global symbol {0}!{1} with type {2} not found", module, symbol, typename)); } Debug.Assert(pythonResult[0] == '{'); int fieldEndIndex = pythonResult.IndexOf('}'); string fieldString = pythonResult.Substring(1, fieldEndIndex - 1); string[] properties = fieldString.Split("#"); SSymbolResult result = new SSymbolResult(); result.Module = module; result.Type = properties[0]; result.Pointer = UInt64.Parse(properties[1]); return(result); }
public Task <SSymbolResult> LookupGlobalSymbol(string module, string symbol) { return(this.runner.AttemptOperation <SSymbolResult>(() => { SSymbolResult result = new SSymbolResult(); uint typeId = 0; ulong moduleBase = 0; string fullyQualifiedSymbolName = module + "!" + symbol; try { this.symbols.GetSymbolTypeId(fullyQualifiedSymbolName, out typeId, out moduleBase); this.symbols.GetOffsetByName(fullyQualifiedSymbolName, out result.Pointer); } catch { throw new DebuggerException(String.Format("Invalid symbol: {0}", fullyQualifiedSymbolName)); } // Now that we have type ids and an offset, we can resolve the names. try { result.Type = this.symbolCache.GetTypeName(moduleBase, typeId); result.Module = this.symbols.GetModuleNameStringByBaseAddress(ModuleName.Module, moduleBase); return result; } catch { throw new DebuggerException(String.Format("Internal error with symbol: {0}", fullyQualifiedSymbolName)); } }, String.Format("Unable to lookup global symbol: {0}!{1}", module, symbol))); }
public async Task <SSymbolResult> LookupGlobalSymbol(string moduleName, string symbolName, string typeName, string scope) { // The scope is not needed to lookup global symbols with DIA. Dia2Lib.IDiaSession session = await this.debuggerEngine.DiaLoader.LoadDiaSession(moduleName); if (session != null) { // We have a DIA session, use that. try { Dia2Lib.IDiaEnumSymbols symbols; session.globalScope.findChildren(Dia2Lib.SymTagEnum.SymTagNull, symbolName, (uint)DiaHelpers.NameSearchOptions.nsCaseSensitive, out symbols); foreach (Dia2Lib.IDiaSymbol diaSymbol in symbols) { if (((DiaHelpers.LocationType)diaSymbol.locationType) == DiaHelpers.LocationType.LocIsTLS) { // For TLS-relative symbols, fall back to the debugger. return(await this.debuggerEngine.LookupGlobalSymbol(moduleName, symbolName, typeName)); } string resultTypeName = DiaHelpers.GetTypeName(diaSymbol.type); if ((typeName == null) || resultTypeName.Equals(typeName)) { SSymbolResult result = new SSymbolResult(); result.Module = moduleName; result.Pointer = (await this.debuggerEngine.GetModuleForName(moduleName)).BaseAddress + diaSymbol.relativeVirtualAddress; result.Type = resultTypeName; return(result); } } } catch { } if (typeName != null) { throw new DebuggerException(String.Format("No symbol {0}!{1} with type name {2}", moduleName, symbolName, typeName)); } else { throw new DebuggerException(String.Format("Invalid symbol: {0}!{1}", moduleName, symbolName)); } } else { return(await this.debuggerEngine.LookupGlobalSymbol(moduleName, symbolName, typeName)); } }