Exemplo n.º 1
0
        /// <summary>
        /// Parses the specified data for all common information entries and frame description entries.
        /// </summary>
        /// <param name="data">The data memory reader.</param>
        /// <param name="defaultAddressSize">Default size of the address.</param>
        /// <returns>All the parsed common information entries</returns>
        public static DwarfCommonInformationEntry[] ParseAll(DwarfMemoryReader data, byte defaultAddressSize)
        {
            Dictionary <int, DwarfCommonInformationEntry> entries = new Dictionary <int, DwarfCommonInformationEntry>();

            while (!data.IsEnd)
            {
                bool  is64bit;
                int   startPosition = data.Position;
                ulong length        = data.ReadLength(out is64bit);
                int   endPosition   = data.Position + (int)length;
                int   offset        = data.ReadOffset(is64bit);
                DwarfCommonInformationEntry entry;

                if (offset == -1)
                {
                    entry = new DwarfCommonInformationEntry(data, defaultAddressSize, endPosition);
                    entries.Add(startPosition, entry);
                }
                else
                {
                    if (!entries.TryGetValue(offset, out entry))
                    {
                        entry = ParseEntry(data, defaultAddressSize, offset);
                        entries.Add(offset, entry);
                    }

                    DwarfFrameDescriptionEntry description = new DwarfFrameDescriptionEntry(data, entry, endPosition);

                    entry.FrameDescriptionEntries.Add(description);
                }
            }

            return(entries.Values.ToArray());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parses the common information entries.
        /// </summary>
        /// <param name="debugFrame">The debug frame.</param>
        /// <param name="ehFrame">The exception handling frames.</param>
        /// <param name="input">The input data for parsing configuration.</param>
        private static DwarfCommonInformationEntry[] ParseCommonInformationEntries(byte[] debugFrame, byte[] ehFrame, DwarfExceptionHandlingFrameParsingInput input)
        {
            List <DwarfCommonInformationEntry> entries = new List <DwarfCommonInformationEntry>();

            using (DwarfMemoryReader debugFrameReader = new DwarfMemoryReader(debugFrame))
            {
                entries.AddRange(DwarfCommonInformationEntry.ParseAll(debugFrameReader, input.DefaultAddressSize));
            }

            using (DwarfMemoryReader ehFrameReader = new DwarfMemoryReader(ehFrame))
            {
                entries.AddRange(DwarfExceptionHandlingCommonInformationEntry.ParseAll(ehFrameReader, input));
            }

            return(entries.ToArray());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parses the single entry from the specified data.
        /// </summary>
        /// <param name="data">The data memory reader.</param>
        /// <param name="defaultAddressSize">Default size of the address.</param>
        /// <param name="startPosition">The start position.</param>
        /// <returns>Parsed common information entry.</returns>
        private static DwarfCommonInformationEntry ParseEntry(DwarfMemoryReader data, byte defaultAddressSize, int startPosition)
        {
            int position = data.Position;

            data.Position = startPosition;

            bool  is64bit;
            ulong length      = data.ReadLength(out is64bit);
            int   endPosition = data.Position + (int)length;
            int   offset      = data.ReadOffset(is64bit);

            if (offset != -1)
            {
                throw new Exception("Expected CommonInformationEntry");
            }

            DwarfCommonInformationEntry entry = new DwarfCommonInformationEntry(data, defaultAddressSize, endPosition);

            data.Position = position;
            return(entry);
        }