예제 #1
0
        public void dumpSymbolInfo(System.IO.TextWriter tw, CruncherSymbol info)
        {
            tw.WriteLine("Symbol: " + info.Name);
            tw.WriteLine("Size: " + info.Size.ToString());
            tw.WriteLine("Total padding: " + info.CalcTotalPadding().ToString());
            tw.WriteLine("Members");
            tw.WriteLine("-------");

            foreach (CruncherSymbol child in info.m_children)
            {
                if (child.Padding > 0)
                {
                    long paddingOffset = child.Offset - child.Padding;
                    tw.WriteLine(String.Format("{0,-40} {1,5} {2,5}", "****Padding", paddingOffset, child.Padding));
                }

                tw.WriteLine(String.Format("{0,-40} {1,5} {2,5}", child.Name, child.Offset, child.Size));
            }
            // Final structure padding.
            if (info.Padding > 0)
            {
                long paddingOffset = (long)info.Size - info.Padding;
                tw.WriteLine(String.Format("{0,-40} {1,5} {2,5}", "****Padding", paddingOffset, info.Padding));
            }
        }
예제 #2
0
        void PopulateDataTable(DataTable table, IDiaEnumSymbols symbols, BackgroundWorker LoadingWorker)
        {
            int TotalSymbolCount = symbols.count;
            int CurSymIndex      = 0;

            string msg = String.Format("Loading {0} symbols...", TotalSymbolCount);

            Console.WriteLine(msg);
            LoadingWorker?.ReportProgress(0, msg);

            System.Diagnostics.Stopwatch watch = new Stopwatch();
            watch.Start();

            table.BeginLoadData();
            foreach (IDiaSymbol sym in symbols)
            {
                if (sym.length > 0 && !HasSymbol(sym.name))
                {
                    CruncherSymbol info = new CruncherSymbol(sym.name, "", sym.length, 0);
                    info.ProcessChildren(sym);

                    long totalPadding = info.CalcTotalPadding();

                    DataRow row        = table.NewRow();
                    string  symbolName = sym.name;
                    row["Symbol"]       = symbolName;
                    row["Size"]         = info.Size;
                    row["Padding"]      = totalPadding;
                    row["Padding/Size"] = (double)totalPadding / info.Size;
                    table.Rows.Add(row);

                    m_SymbolMap.Add(info.Name, info);

                    // Report progress to loading bar
                    int percentProgress = (int)Math.Round((double)(100 * CurSymIndex++) / TotalSymbolCount);
                    percentProgress = Math.Max(Math.Min(percentProgress, 99), 1);
                    LoadingWorker?.ReportProgress(percentProgress, String.Format("Adding symbol {0} of {1}", CurSymIndex, TotalSymbolCount));
                }
            }
            table.EndLoadData();
            watch.Stop();

            // Format and display the TimeSpan value.
            TimeSpan ts          = watch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 ts.Hours, ts.Minutes, ts.Seconds,
                                                 ts.Milliseconds / 10);
            string CompleteMessage = String.Format("Finished processing {0} symbols in {1}", TotalSymbolCount, elapsedTime);

            Console.WriteLine(CompleteMessage);
            LoadingWorker?.ReportProgress(100, CompleteMessage);
        }