} // end TryMapCvToDbgEngIndex() // Returns a dictionary that maps CV_HREG_e values to dbgeng register indexes (as // best we know). private static IReadOnlyDictionary <uint, uint> _GetLookupMap(DbgEngDebugger debugger, IMAGE_FILE_MACHINE machineType) { IReadOnlyDictionary <uint, uint> map; if (!s_LookupMaps.TryGetValue(machineType, out map)) { // Need to build the map. var tmpMap = new Dictionary <uint, uint>(); IReadOnlyDictionary <string, CV_HREG_e> nameMap; if (!s_NameTo_CV_HREG_e_Maps.TryGetValue(machineType, out nameMap)) { throw new NotSupportedException(Util.Sprintf("Machine type not supported: {0}", machineType)); } var regSet = DbgRegisterSetBase.GetRegisterSet(debugger); var curMachineType = debugger.GetEffectiveProcessorType(); if (curMachineType != machineType) { throw new InvalidOperationException(Util.Sprintf("Can't map registers for machine type {0} when current machine type is {1}", machineType, curMachineType)); } foreach (var regInfo in regSet.EnumerateRegisters()) { Util.Assert(regInfo.DbgEngIndex != DebuggerObject.DEBUG_ANY_ID); CV_HREG_e cv_hreg_e_val; if (nameMap.TryGetValue(regInfo.Name, out cv_hreg_e_val)) { tmpMap.Add((uint)cv_hreg_e_val, regInfo.DbgEngIndex); } } map = tmpMap; s_LookupMaps.Add(machineType, map); } return(map); } // end _GetLookupMap()
/// <summary> /// Gets the platform-specific RegisterSet object for the specified stack frame, /// using the baseline RegisterSet to compare to when creatin a colorized string. /// </summary> public static DbgRegisterSetBase GetRegisterSet(DbgEngDebugger debugger, DbgStackFrameInfo stackFrame, DbgRegisterSetBase baseline) { if (null == debugger) { throw new ArgumentNullException("debugger"); } var procType = debugger.GetEffectiveProcessorType(); if (debugger.TargetIs32Bit) { if (IMAGE_FILE_MACHINE.THUMB2 == procType) { return(new Arm32RegisterSet(debugger, stackFrame, baseline)); } else if (IMAGE_FILE_MACHINE.I386 == procType) { return(new x86RegisterSet(debugger, stackFrame, baseline)); } else { throw new NotImplementedException(Util.Sprintf("Need to support effective processor type: {0} (32-bit)", procType)); } } else { if (IMAGE_FILE_MACHINE.AMD64 == procType) { return(new x64RegisterSet(debugger, stackFrame, baseline)); } else if (IMAGE_FILE_MACHINE.I386 == procType) { // 64-bit dump of a 32-bit process. return(new x86RegisterSet(debugger, stackFrame, baseline)); } else { throw new NotImplementedException(Util.Sprintf("Need to support effective processor type: {0} (64-bit)", procType)); } } } // end GetRegisterSet()
protected DbgRegisterSetBase(DbgEngDebugger debugger, DbgStackFrameInfo stackFrame, DbgRegisterSetBase baseline) : base(debugger) { if (null == stackFrame) { throw new ArgumentNullException("stackFrame"); } StackFrame = stackFrame; Debugger.ExecuteOnDbgEngThread(() => { m_debugSymbols = (WDebugSymbols)Debugger.DebuggerInterface; m_debugRegisters = (WDebugRegisters)Debugger.DebuggerInterface; m_debugControl = (WDebugControl)Debugger.DebuggerInterface; }); Baseline = baseline; // We used to lazily retrieve values, but that's no good when the context // changes (such as when stepping through code). _GetRegisterInfo(); } // end constructor
public Arm32RegisterSet(DbgEngDebugger debugger, DbgStackFrameInfo stackFrame, DbgRegisterSetBase baseline) : base(debugger, stackFrame, baseline) { } // end constructor
internal PseudoRegisters(DbgRegisterSetBase rsb) { m_rsb = rsb; }
} // end GetColorForDiffAgainstBaseline() // TODO: I'm not sure that I like this mutation... On the other hand, // register values on live targets will be mutable... internal DbgRegisterSetBase WithBaseline(DbgRegisterSetBase baseline) { Baseline = baseline; return(this); }