using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; using System.IO; namespace Cosmos.Debug.Common { public class ObjDump { [Obsolete("We're not using ELF Format anymore")] public static SortedList GetLabelByAddressMapping(string aKernel, string aObjDumpExe) { string[] xSymbolsContents; #region Run ObjDump string xTempFile = Path.GetTempFileName(); var xRandom = new Random(78367); string xBatFile = String.Empty; do { xBatFile = Path.GetTempPath(); xBatFile = Path.Combine(xBatFile, BitConverter.GetBytes(xRandom.NextDouble()).Aggregate("", (r, b) => r += b.ToString("X2").ToUpper()) + ".bat"); } while (File.Exists(xBatFile)); string xObjDumpFile = aObjDumpExe; File.WriteAllText(xBatFile, String.Format("@ECHO OFF\r\n\"{0}\" --syms --wide \"{1}\" > \"{2}\"", xObjDumpFile, aKernel, xTempFile)); using (var xProcess = Process.Start(xBatFile)) { xProcess.WaitForExit(); } xSymbolsContents = File.ReadAllLines(xTempFile); File.Delete(xTempFile); File.Delete(xBatFile); #endregion var xResult = new SortedList(); foreach (var xLabel in ExtractMapSymbolsForElfFile(xSymbolsContents)) { xResult.Add((uint)xLabel.Address, xLabel.Name); } return xResult; } /// /// Sequentially parse symbols from the lines sequence. /// /// Sequence of lines which contain map files. /// Sequence of parsed label. public static IEnumerable