Пример #1
0
        public IEnumerable <SFieldResult> Fields(bool includeBaseTypes)
        {
            if (includeBaseTypes && this.baseTypes != null)
            {
                foreach (SBaseType baseType in this.baseTypes)
                {
                    foreach (SFieldResult innerBaseField in baseType.Type.Fields(includeBaseTypes: true))
                    {
                        SFieldResult baseField = innerBaseField;
                        baseField.Offset = (uint)(baseField.Offset + baseType.Offset);
                        yield return(baseField);
                    }
                }
            }

            if (this.fields != null)
            {
                foreach (string fieldName in this.fields.Keys)
                {
                    SField       innerField = this.fields[fieldName];
                    SFieldResult field      = new SFieldResult();
                    field.FieldName = fieldName;
                    field.Module    = innerField.Module;
                    field.TypeName  = innerField.TypeName;
                    field.Offset    = innerField.Offset;
                    field.Size      = innerField.Size;
                    field.BitCount  = innerField.BitCount;
                    field.BitOffset = innerField.BitOffset;
                    yield return(field);
                }
            }

            yield break;
        }
Пример #2
0
        public async Task <IEnumerable <SFieldResult> > GetAllFields(string module, string typename, bool includeBaseTypes)
        {
            NotifyDebuggerMessage(String.Format("Looking up fields for {0}...", typename));

            string pythonResult = await this.QueryDebuggerPython(String.Format("GetAllFields(\"{0}\",\"{1}\",{2})", module, typename, includeBaseTypes ? "True" : "False"));

            if (pythonResult == "None")
            {
                throw new DebuggerException(String.Format("No type {0}!{1}", module, typename));
            }

            List <string>       objects = ParsePythonObjectArrayToStrings(pythonResult);
            List <SFieldResult> result  = new List <SFieldResult>();

            foreach (string fieldString in objects)
            {
                // '{%d#%d#%d#%d#%s#%s}' % (self.offset, self.size, self.bitOffset, self.bitCount, self.fieldName, self.typeName)
                string[] properties = fieldString.Split('#');
                Debug.Assert(properties.Length == 6);
                SFieldResult field = new SFieldResult();
                field.Offset    = UInt32.Parse(properties[0]);
                field.Size      = UInt32.Parse(properties[1]);
                field.BitOffset = Byte.Parse(properties[2]);
                field.BitCount  = Byte.Parse(properties[3]);
                field.FieldName = properties[4];
                field.TypeName  = properties[5];
                field.Module    = module;
                result.Add(field);
            }

            return(result);
        }
Пример #3
0
        public async Task <SFieldResult> LookupField(string module, string typename, string fieldName)
        {
            NotifyDebuggerMessage(String.Format("Looking up field {0}::{1}...", typename, fieldName));

            string pythonResult = await this.QueryDebuggerPython(String.Format("LookupField(\"{0}\",\"{1}\", \"{2}\")", module, typename, fieldName));

            // '{%d#%d#%d#%d#%s#%s}' % (self.offset, self.size, self.bitOffset, self.bitCount, self.fieldName, self.typeName)

            if (pythonResult == "None")
            {
                throw new DebuggerException(String.Format("No field {0} in type {1}!{2}", fieldName, module, typename));
            }

            Debug.Assert(pythonResult[0] == '{');
            int    fieldEndIndex = pythonResult.IndexOf('}');
            string fieldString   = pythonResult.Substring(1, fieldEndIndex - 1);

            string[] properties = fieldString.Split('#');

            SFieldResult field = new SFieldResult();

            field.Offset    = UInt32.Parse(properties[0]);
            field.Size      = UInt32.Parse(properties[1]);
            field.BitOffset = Byte.Parse(properties[2]);
            field.BitCount  = Byte.Parse(properties[3]);
            field.FieldName = properties[4];
            field.TypeName  = properties[5];
            field.Module    = module;

            return(field);
        }
Пример #4
0
        public async Task <SFieldResult> LookupField(string module, string typename, string fieldName)
        {
            SFieldResult result = new SFieldResult();

            var type = await this.LoadType(module, typename);

            SField field;

            if (type.GetField(fieldName, out field))
            {
                result.Offset   += field.Offset;
                result.BitCount  = field.BitCount;
                result.BitOffset = field.BitOffset;
                result.Module    = field.Module;
                result.TypeName  = field.TypeName;
                result.Size      = field.Size;
            }
            else
            {
                throw new DebuggerException(String.Format("Unknown field {0} in type: {1}", fieldName, typename));
            }

            return(result);
        }