Example #1
0
        void DebuggerEvents_OnEnterBreakMode(EnvDTE.dbgEventReason Reason, ref EnvDTE.dbgExecutionAction ExecutionAction)
        {
            try
            {
                traceSessionInProgress = true;
                Debugger debugger;
                lock (dte)
                {
                    //Don't lock too much, just what is required.
                    debugger = dte.Debugger;
                }

                if (Reason == dbgEventReason.dbgEventReasonBreakpoint)
                {
                    string[] symbols;
                    lock (this.symbols)
                    {
                        //Clone the list to be used locally.
                        symbols = new string[this.symbols.Count];
                        this.symbols.CopyTo(symbols);
                    }
                    foreach (var symbol in symbols)
                    {
                        if (!string.IsNullOrEmpty(symbol))
                        {
                            try
                            {
                                var expression = debugger.GetExpression(symbol);
                                if (expression.IsValidValue)
                                {
                                    var breakpoint         = debugger.BreakpointLastHit;
                                    var stackFrame         = debugger.CurrentStackFrame;
                                    var traceMessageSource = new TraceMessageSourceEntry()
                                    {
                                        Expression = expression, Breakpoint = breakpoint, StackFrame = stackFrame
                                    };
                                    lock (messages)
                                    {
                                        messages.Enqueue(traceMessageSource);
                                    }
                                }
                                else
                                {
                                    string breakpointContext;
                                    var    bp = dte.Debugger.BreakpointLastHit;
                                    breakpointContext = string.Format(Resources.MsgBreakpointContextFormat, expression.Name, bp.FunctionName, bp.FileLine);
                                    StatusReporter.Report(string.Format(Resources.ErrTraceSymbolInvalid, breakpointContext), Status.WARNING);
                                }
                            }
                            catch (Exception ex)
                            {
                                StatusReporter.Report(string.Format(Resources.ErrorEvaulatingSymbol, symbol + ex.ToString()), Status.WARNING);
                            }
                        }
                    }
                }
            }
            finally
            {
                //This step makes sure that the execution continues after tracing this value;
                ExecutionAction = dbgExecutionAction.dbgExecutionActionGo;
            }
        }
Example #2
0
 public void OnEnterBreakMode(EnvDTE.dbgEventReason reason, ref EnvDTE.dbgExecutionAction executionAction)
 {
     executionAction = EnvDTE.dbgExecutionAction.dbgExecutionActionDefault;
     _outputWindowPane.OutputString("DebuggerEvents, OnEnterBreakMode\n");
 }