public object[] pop() { object[] ReturnValue = { null, null }; if (PseudoQueue.Count > 0) { ReturnValue[0] = PseudoQueue.GetKey(0); ReturnValue[1] = PseudoQueue.GetByIndex(0); PseudoQueue.RemoveAt(0); } return(ReturnValue); }
CCallStack AnalyzeMap(string bugtrapfile, string mapfile) { CCallStack callstack = new CCallStack(); System.Collections.SortedList address_list = new System.Collections.SortedList(); System.Collections.SortedList find_address_list = new System.Collections.SortedList(); System.IO.StreamReader reader = new System.IO.StreamReader(bugtrapfile); string xmlstring = reader.ReadToEnd(); reader.Close(); System.Xml.XmlDocument document = new System.Xml.XmlDocument(); document.LoadXml(xmlstring); System.Xml.XPath.XPathNavigator nav = document.CreateNavigator(); System.Xml.XPath.XPathNodeIterator i; string what = System.Convert.ToString(nav.SelectSingleNode("/report/error/what/text()")); string module = System.IO.Path.GetFileName(System.Convert.ToString(nav.SelectSingleNode("/report/error/module/text()"))); string tmp = System.Convert.ToString(nav.SelectSingleNode("/report/error/address/text()")); if (tmp == "" || tmp.Trim().Length < 1) { return(null); } UInt32 address = System.Convert.ToUInt32(tmp.Substring(tmp.Length - 8), 16); i = nav.Select("/report/threads/thread/status[text()='interrupted']/../stack/frame"); System.Collections.ArrayList frame_list = new System.Collections.ArrayList(); while (i.MoveNext() == true) { Frame frame = new Frame(); frame.module = System.IO.Path.GetFileName(System.Convert.ToString(i.Current.SelectSingleNode("module/text()"))); string frame_address = System.Convert.ToString(i.Current.SelectSingleNode("address/text()")); string function_name = null; string function_offset = null; if (i.Current.SelectSingleNode("function/name/text()") != null) { function_name = System.Convert.ToString(i.Current.SelectSingleNode("function/name/text()")); } if (i.Current.SelectSingleNode("function/offset/text()") != null) { function_offset = System.Convert.ToString(i.Current.SelectSingleNode("function/offset/text()")); } frame.address = System.Convert.ToUInt32(frame_address.Substring(frame_address.Length - 8), 16); if (address_list.Contains(frame.address) == false && find_address_list.Contains(frame.address) == false) { if (function_name == null) { address_list.Add(frame.address, null); } else { if (function_offset == null) { find_address_list.Add(frame.address, function_name); } else { find_address_list.Add(frame.address, string.Format("{0}+0x{1:x}", function_name, function_offset)); } } } frame_list.Add(frame); } if (address_list.Contains(address) == false && find_address_list.Contains(address) == false) { address_list.Add(address, null); } UInt32 baseaddress = 0; reader = new System.IO.StreamReader(mapfile); while (reader.EndOfStream == false) { string line = reader.ReadLine(); string[] e = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (e.Length >= 5 && e[0] == "Preferred") { baseaddress = System.Convert.ToUInt32(e[4], 16); break; } } while (reader.EndOfStream == false) { string line = reader.ReadLine(); string[] e = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (e.Length >= 5 && e[0] == "Address") { break; } } string old_name = ""; UInt32 old_address = 0; while (reader.EndOfStream == false && address_list.Count > 0) { string line = reader.ReadLine(); string[] e = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); UInt32 map_address = System.Convert.ToUInt32(e[2], 16); UInt32 list_address = (UInt32)address_list.GetKey(0); if (list_address <= map_address) { address_list.RemoveAt(0); e[1] = ConvertUname(old_name); find_address_list.Add(list_address, string.Format("{0}+0x{1:x}", e[1], list_address - old_address)); } old_name = e[1]; old_address = map_address; } reader.Close(); if (find_address_list.Contains(address) == true) { string fcs = find_address_list[address].ToString(); int pi = fcs.IndexOf("+"); if (pi > 0) { callstack.FinalCallstack = String.Format("{0}!{1}", module.ToLower(), fcs.Substring(0, pi)); } else { callstack.FinalCallstack = String.Format("{0}!{1}", module.ToLower(), fcs); } } else { callstack.FinalCallstack = "Unknown Address"; } foreach (Frame frame in frame_list) { if (find_address_list.Contains(frame.address) == true) { callstack.CallStack += string.Format("{0:x8} {1} {2}\n", frame.address, frame.module.ToLower(), find_address_list[frame.address]); } else { callstack.CallStack += string.Format("{0:x8} {1}\n", frame.address, frame.module.ToLower()); } } return(callstack); }