Ejemplo n.º 1
0
        public SymbolGroup GetSymbolGroup(int levels)
        {
            var  count      = GetSymbolCount();
            uint start      = 0;
            var  parameters = GetSymbolParameters(start, count);

            start = count;
            var entries     = new DEBUG_SYMBOL_ENTRY[count];
            var symbolGroup = new SymbolGroup();


            for (uint j = 0; j < GetSymbolCount(); j++)
            {
                var entry     = GetSymbolEntryInformation(j);
                var parameter = parameters[j];
                entries[j] = entry;

                var nameSize = entry.NameSize;
                var name     = GetSymbolName(j, nameSize == 0 ? 50 : nameSize);
                var typeName = GetSymbolTypeName(j);
                var strValue = GetSymbolStringValue(j);
                var size     = GetSymbolSize(j);

                var sym = new SymbolValue(name, typeName, strValue, size, entry, parameters[j]);
                symbolGroup.AddSymbol(sym);
                if (sym.ExpansionDepth < levels - 1)
                {
                    ExpandSymbol(j);
                }
            }

            return(symbolGroup);
        }
Ejemplo n.º 2
0
 public SymbolValue(string name, string typeName, string strValue, uint size, DEBUG_SYMBOL_ENTRY debugSymbolEntry, DEBUG_SYMBOL_PARAMETERS debugSymbolParameters)
 {
     Name                  = name;
     TypeName              = typeName;
     StrValue              = strValue;
     Size                  = size;
     DebugSymbolEntry      = debugSymbolEntry;
     DebugSymbolParameters = debugSymbolParameters;
 }
Ejemplo n.º 3
0
 public void AddSymbol(string name, string typeName, string strValue, uint size, DEBUG_SYMBOL_ENTRY debugSymbolEntry, DEBUG_SYMBOL_PARAMETERS debugSymbolParameters)
 {
     _symbols.Add(new SymbolValue(name, typeName, strValue, size, debugSymbolEntry, debugSymbolParameters));
 }
Ejemplo n.º 4
0
        private static void _GenerateSyntheticTypeToMatchDbgEngGeneratedType(string localSymName,
                                                                             DbgEngDebugger debugger,
                                                                             DEBUG_SYMBOL_ENTRY dse)
        {
            if (dse.Tag != SymTag.PointerType)
            {
                LogManager.Trace("It's a dbgeng-generated type that isn't a pointer! It's a {0} (id 0x{1:x}).",
                                 dse.Tag,
                                 dse.TypeId);
                return;
            }

            if (DbgHelp.PeekSyntheticTypeExists(debugger.DebuggerInterface,
                                                dse.ModuleBase,
                                                dse.TypeId))
            {
                return;
            }

            // We'll run a command like this:
            //
            //    dv /t "varname"
            //
            // And here's some sample output:
            //
            //    struct Microsoft::CoreUI::Support::BufferInfo * message = 0x0000006f`81edd570
            //

            string output = String.Empty;

            using (debugger.HandleDbgEngOutput(
                       (x) =>
            {
                x = x.Trim();
                if (!String.IsNullOrEmpty(x))
                {
                    Util.Assert(String.IsNullOrEmpty(output));
                    output = x;
                }
            }))
            {
                debugger.InvokeDbgEngCommand(Util.Sprintf("dv /t \"{0}\"", localSymName),
                                             DEBUG_OUTCTL.THIS_CLIENT);
            }

            int matchCount = 0;

            foreach (Match match in sm_vartypeRegex.Matches(output))
            {
                matchCount++;
                string typename = match.Groups["typename"].Value;
                // Console.WriteLine( "output: {0}", output );
                // Console.WriteLine( "typename: {0}", typename );
                // Console.WriteLine( "varname: {0}", match.Groups[ "varname" ].Value );
                LogManager.Trace("DbgEng-generated type is a pointer, pointing to type: {0}", typename);

                var mod = debugger.GetModuleByAddress(dse.ModuleBase);

                DbgTypeInfo ti = debugger.GetTypeInfoByName(mod.Name + "!" + typename).FirstOrDefault();
                if (null != ti)
                {
                    Util.Assert(ti is DbgNamedTypeInfo);
                    var nti = ti as DbgNamedTypeInfo;
                    Util.Assert(nti.Module.BaseAddress == dse.ModuleBase);
                    // We don't need to TryGetSynthPointerTypeIdByPointeeTypeId, because
                    // we already know it's not there (because we did
                    // PeekSyntheticTypeExists earlier).
                    DbgHelp.AddSyntheticPointerTypeInfo(debugger.DebuggerInterface,
                                                        nti.Module.BaseAddress,
                                                        nti.TypeId,
                                                        //debugger.TargetIs32Bit ? 4UL : 8UL,
                                                        dse.Size,
                                                        dse.TypeId);
                } // end if( we found the pointee type )
                else
                {
                    LogManager.Trace("(but we couldn't find the type!)");
                }
            } // end foreach( match )

            Util.Assert(matchCount <= 1);

            if (0 == matchCount)
            {
                LogManager.Trace("Failed to parse out type name from: {0}", output);
            }
        } // end _GenerateSyntheticTypeToMatchDbgEngGeneratedType()