コード例 #1
0
        } // 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()
コード例 #2
0
        /// <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()
コード例 #3
0
            public Architecture GetArchitecture()
            {
                _CheckClosed();
                using (new DbgEngContextSaver(m_umd, m_target.Context))
                {
                    IMAGE_FILE_MACHINE machineType = m_umd.GetEffectiveProcessorType();
                    switch (machineType)
                    {
                    case IMAGE_FILE_MACHINE.I386:
                        return(Architecture.X86);

                    case IMAGE_FILE_MACHINE.AMD64:
                        return(Architecture.Amd64);

                    case IMAGE_FILE_MACHINE.ARM:
                    case IMAGE_FILE_MACHINE.THUMB:
                    case IMAGE_FILE_MACHINE.THUMB2:
                        return(Architecture.Arm);

                    default:
                        return(Architecture.Unknown);
                    }
                } // end using( ctx )
            }     // end GetArchitecture()