コード例 #1
0
        internal PDB LoadSymbols(string executablePath)
        {
            if (!symbolInformation.ContainsKey(executablePath))
            {
                symbolInformation[executablePath] = PDB.Create(executablePath);
            }

            return(symbolInformation[executablePath]);
        }
コード例 #2
0
        internal PdbEntry ProjectStarted(ProjectStartedEventArgs e)
        {
            // Load symbol information for the project
            PDB pdb = SymbolStore.Instance[e.ProjectFile];

            // Create a new stack frame
            projectStack.Push(new ProjectStackFrame(pdb));

            // Return the symbol for the project
            return(pdb.ProjectPdbEntry);
        }
コード例 #3
0
ファイル: PDB.cs プロジェクト: schifflee/MSBuildDebugger
        internal static PDB Create(string executablePath)
        {
            Debug.Assert(File.Exists(executablePath));

            PDB sdb = new PDB();

            sdb.ExecutablePath      = executablePath;
            sdb.ProjectPdbEntry     = new PdbEntry(Path.GetFileName(executablePath), executablePath);
            sdb.TargetSymbolEntries = new Dictionary <string, PdbEntry>(StringComparer.OrdinalIgnoreCase);
            sdb.PopulateSymbolInformation();

            return(sdb);
        }
コード例 #4
0
        internal BreakPoint BindBreakPoint(BreakPoint unboundBreakPoint)
        {
            BreakPoint boundBreakPoint = null;

            // Load the symbols, if not loaded already
            SymbolStore.Instance.LoadSymbols(unboundBreakPoint.ExecutablePath);

            PDB      pdb      = SymbolStore.Instance[unboundBreakPoint.ExecutablePath];
            PdbEntry bpSymbol = null;

            // First determine the target
            PdbEntry targetSymbol = null;

            PdbEntry[] targetSymbolEntries = pdb.TargetSymbolEntries.Values.ToArray();
            for (int i = 0; i < targetSymbolEntries.Length - 1; i++)
            {
                PdbEntry currEntry = targetSymbolEntries[i];
                PdbEntry nextEntry = targetSymbolEntries[i + 1];

                if (
                    currEntry.StartLocation.Y <= unboundBreakPoint.Location.Y &&
                    unboundBreakPoint.Location.Y < nextEntry.StartLocation.Y
                    )
                {
                    targetSymbol = currEntry;
                    break;
                }
            }

            // Project with no targets
            if (0 == targetSymbolEntries.Length)
            {
                targetSymbol = pdb.ProjectPdbEntry;
            }

            if ((0 != targetSymbolEntries.Length) && (null == targetSymbol))
            {
                // Ok so the break point is not between targets 1-2, 2-3, 3-4, 4-5
                // So it can be either before 1 or after 5
                // Before 1 => The BP is at project start
                // After 5 => BP at the last target
                if (targetSymbolEntries[0].StartLocation.Y >= unboundBreakPoint.Location.Y)
                {
                    targetSymbol = pdb.ProjectPdbEntry;
                }
                else
                {
                    targetSymbol = targetSymbolEntries[targetSymbolEntries.Length - 1];
                }
            }

            if (null == targetSymbol)
            {
                goto Done;
            }

            // Second determine the task
            PdbEntry taskSymbol = null;

            for (int i = 0; i < targetSymbol.Children.Count - 1; i++)
            {
                PdbEntry currEntry = targetSymbol.Children[i];
                PdbEntry nextEntry = targetSymbol.Children[i + 1];

                if (
                    currEntry.StartLocation.Y <= unboundBreakPoint.Location.Y &&
                    unboundBreakPoint.Location.Y < nextEntry.StartLocation.Y
                    )
                {
                    taskSymbol = currEntry;
                    break;
                }
            }

            if ((0 != targetSymbol.Children.Count) && (null == taskSymbol))
            {
                // Ok so the break point is not between tasks 1-2, 2-3, 3-4, 4-5
                // So it can be either before 1 or after 5
                // Before 1 => The BP is at target start
                // After 5 => BP at the last task
                // Take care of only 'after 5' case since not getting the symbol means 'before 1' case
                if (targetSymbol.Children[targetSymbol.Children.Count - 1].StartLocation.Y <= unboundBreakPoint.Location.Y)
                {
                    taskSymbol = targetSymbol.Children[targetSymbol.Children.Count - 1];
                }
            }

            // If we didnt get a task, no issues, set BP on the target
            bpSymbol = taskSymbol ?? targetSymbol;

            // Third create and note down the bound bp
            boundBreakPoint = _breakPoints.Find(bp => (bp.Location == bpSymbol.StartLocation));
            if (null == boundBreakPoint)
            {
                boundBreakPoint = new BreakPoint
                {
                    ExecutablePath = unboundBreakPoint.ExecutablePath,
                    Location       = bpSymbol.StartLocation
                };
                _breakPoints.Add(boundBreakPoint);
            }

Done:
            return(boundBreakPoint);
        }
コード例 #5
0
 internal ProjectStackFrame(PDB pdb)
 {
     PDB         = pdb;
     TargetStack = new Stack <TargetStackFrame>();
 }