private void EnableLogging(bool sendToOutputWindow, string logFile)
 {
     try
     {
         MIDebugCommandDispatcher.EnableLogging(sendToOutputWindow, logFile);
     }
     catch (Exception e)
     {
         var commandWindow = (IVsCommandWindow)GetService(typeof(SVsCommandWindow));
         commandWindow.Print(string.Format(CultureInfo.CurrentCulture, "Error: {0}\r\n", e.Message));
     }
 }
Beispiel #2
0
        private async void VRDebugExecAsync(string command)
        {
            var commandWindow = (IVsCommandWindow)GetService(typeof(SVsCommandWindow));

            string results = null;

            try
            {
                results = await MIDebugCommandDispatcher.ExecuteCommand(command);
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    e = e.InnerException;
                }

                UnexpectedMIResultException miException = e as UnexpectedMIResultException;
                string message;
                if (miException != null && miException.MIError != null)
                {
                    message = miException.MIError;
                }
                else
                {
                    message = e.Message;
                }

                commandWindow.Print(string.Format("Error: {0}\r\n", message));
                return;
            }

            if (results.Length > 0)
            {
                // Make sure that we are printing whole lines
                if (!results.EndsWith("\n") && !results.EndsWith("\r\n"))
                {
                    results = results + "\n";
                }

                commandWindow.Print(results);
            }
        }
 private void EnableLogging(bool sendToOutputWindow, string logFile)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     try
     {
         MIDebugCommandDispatcher.EnableLogging(sendToOutputWindow, logFile);
     }
     catch (Exception e)
     {
         var commandWindow = (IVsCommandWindow)GetService(typeof(SVsCommandWindow));
         if (commandWindow != null)
         {
             commandWindow.Print(string.Format(CultureInfo.CurrentCulture, "Error: {0}\r\n", e.Message));
         }
         else
         {
             throw new InvalidOperationException("Why is IVsCommandWindow null?");
         }
     }
 }
        // request all register names and ids, validate that all core registers
        // have a matching view model
        private async Task VerifyRegisterIds( )
        {
            if (VerifiedRegisterIds)
            {
                return;
            }

            string cmdResult = await MIDebugCommandDispatcher.ExecuteCommand(RegisterNamesResult.Command);

            var result = await RegisterNamesResult.ParseAsync(cmdResult);

            if (result.Status != ResultStatus.Done)
            {
                return;
            }

            foreach (var regNameId in result.Names)
            {
                Debug.Assert(RegIdToViewModelMap.ContainsKey(regNameId.Id));
            }
            VerifiedRegisterIds = true;
        }
        internal async Task <IReadOnlyList <RegisterIdValuePair> > GetUpdatedRegistersAsync( )
        {
#if DEBUG
            await VerifyRegisterIds( );
#endif
            string cmdResult = await MIDebugCommandDispatcher.ExecuteCommand(ChangedRegistersResult.Command);

            var regChangedResult = await ChangedRegistersResult.ParseAsync(cmdResult);

            // if( regChangedResult.Status != ResultStatus.Done )
            //     TODO: How should errors be reported?

            // send a request for the values of the changed registers
            var cmd = RegisterValuesResult.GetCommand(regChangedResult.Registers);
            cmdResult = await MIDebugCommandDispatcher.ExecuteCommand(cmd);

            var regValues = await RegisterValuesResult.ParseAsync(cmdResult);

            //if( regValues.Status != ResultStatus.Done )
            //    TODO: How should errors be reported?

            return(regValues.Registers);
        }
        private async void MIDebugExecAsync(string command)
        {
            var  commandWindow = (IVsCommandWindow)GetService(typeof(SVsCommandWindow));
            bool atBreak       = false;
            var  debugger      = GetService(typeof(SVsShellDebugger)) as IVsDebugger;

            if (debugger != null)
            {
                DBGMODE[] mode = new DBGMODE[1];
                if (debugger.GetMode(mode) == MIDebugEngine.Constants.S_OK)
                {
                    atBreak = mode[0] == DBGMODE.DBGMODE_Break;
                }
            }

            string results = null;

            try
            {
                if (atBreak)
                {
                    commandWindow.ExecuteCommand(String.Format(CultureInfo.InvariantCulture, "Debug.EvaluateStatement -exec {0}", command));
                }
                else
                {
                    results = await MIDebugCommandDispatcher.ExecuteCommand(command);
                }
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    e = e.InnerException;
                }

                UnexpectedMIResultException miException = e as UnexpectedMIResultException;
                string message;
                if (miException != null && miException.MIError != null)
                {
                    message = miException.MIError;
                }
                else
                {
                    message = e.Message;
                }

                commandWindow.Print(string.Format("Error: {0}\r\n", message));
                return;
            }

            if (results != null && results.Length > 0)
            {
                // Make sure that we are printing whole lines
                if (!results.EndsWith("\n") && !results.EndsWith("\r\n"))
                {
                    results = results + "\n";
                }

                commandWindow.Print(results);
            }
        }