Esempio n. 1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is MemoryTypeAdapter))
            {
                return("Failed to convert");
            }
            MemoryTypeAdapter p = (MemoryTypeAdapter)value;

            return(string.Format("{0} [{1} bytes] ", p.Name, p.TotalSize));
        }
Esempio n. 2
0
        public void Reload(string elfFilePath, string linkerScrintFilePath)
        {
            _elfUri = new Uri(elfFilePath);
            try {
                File = new ElfFile(System.IO.File.ReadAllBytes(elfFilePath));
            }
            catch (Exception ex) {
                Debug.WriteLine(ex.Message);
                return;
            }

            _dwarf = new DwarfData(_elfFile);

            _memoryDescriptor = System.IO.File.Exists(linkerScrintFilePath) ? MemoryDescriptor.FromLinkerScript(linkerScrintFilePath) : null;

            Profile = new MemoryProfile(_dwarf, _memoryDescriptor);
            Symbols.Clear();
            foreach (var memoryName in Profile.MemoryNames)
            {
                var adapter = new MemoryTypeAdapter(Profile, memoryName);
                foreach (var section in adapter.Sections)
                {
                    foreach (var symbol in section.Symbols)
                    {
                        if (symbol.Header.Info.SymbolType == Elf32SymbolType.STT_SECTION)
                        {
                            continue;
                        }
                        SymbolDescriptor desc = new SymbolDescriptor();
                        desc.Section = section;
                        desc.Memory  = adapter;
                        desc.Symbol  = symbol;

                        desc.DwarfUnitItem =
                            _dwarf.globalItems.FirstOrDefault(v => v.Name == symbol.Name);

                        /*Uri address1 = new Uri("http://www.contoso.com/");
                         *
                         * // Create a new Uri from a string.
                         * Uri address2 = new Uri("http://www.contoso.com/index.htm?date=today");
                         *
                         * // Determine the relative Uri.
                         * Console.WriteLine("The difference is {0}", address1.MakeRelativeUri(address2));*/

                        if (!string.IsNullOrEmpty(desc.DwarfUnitItem?.FileStr))
                        {
                            if (System.IO.File.Exists(desc.DwarfUnitItem.FileStr))
                            {
                                Uri elfUri       = new Uri(elfFilePath);
                                Uri symbolUri    = new Uri(desc.DwarfUnitItem.FileStr);
                                Uri relativePath = elfUri.MakeRelativeUri(symbolUri);
                                desc.DwarfUnitItem.FileStr = relativePath.ToString();
                            }
                        }

                        Symbols.Add(desc);
                    }
                }
            }
            UpdateTitle();
        }