Exemplo n.º 1
0
        public void OnDoubleClick([CanBeNull] SymbolDescriptor target)
        {
            if (target?.DwarfUnitItem != null)
            {
                Uri fullSourcePath = new Uri(_elfUri, target.DwarfUnitItem.FileStr);

                var editor = FindFileEditor(fullSourcePath);
                if (editor != null)
                {
                    editor.RowID    = (int)target.DwarfUnitItem.Line;
                    editor.ColumnId = 0;
                    editor.Launch(fullSourcePath);
                }
            }
        }
Exemplo 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();
        }