Пример #1
0
        string GetArgValue(string arg, EnvDTE.Debugger debugger)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (arg.StartsWith("$"))
            {
                if (!SavedResults.ContainsKey(arg))
                {
                    throw new Exception(String.Format("Using unknown variable {0}", arg));
                }
                var indexResult = SavedResults[arg].GetResults()[0];
                if (indexResult.IsLiteral)
                {
                    return(indexResult.Expression);
                }
                else
                {
                    var expr = debugger.GetExpression(indexResult.Expression + ",d");
                    return(expr.Value);
                }
            }
            else
            {
                return(arg);
            }
        }
Пример #2
0
        private void OnTextViewMouseHover(object sender, MouseHoverEventArgs ee)
        {
            ITextBuffer buff = null;
            //find the mouse position by mapping down to the subject buffer
            SnapshotPoint?point = m_textView.BufferGraph.MapDownToFirstMatch
                                      (new SnapshotPoint(m_textView.TextSnapshot, ee.Position),
                                      PointTrackingMode.Positive,
                                      snapshot => m_subjectBuffers.Contains(buff = snapshot.TextBuffer),
                                      PositionAffinity.Predecessor);

            if (point != null)
            {
                ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position,
                                                                                       PointTrackingMode.Positive);

                EnvDTE.DTE      dte = SQVSUtils.GetService <EnvDTE.DTE>();
                EnvDTE.Debugger dbg = dte.Debugger as EnvDTE.Debugger;

                if (dbg != null && dte.Debugger.CurrentMode == dbgDebugMode.dbgBreakMode)
                {
                    string filename = SQLanguageServiceEX.GetFileName(buff);

                    SQProjectFileNode node = _languageService.GetNode(filename);
                    SQVSUtils.CreateDataTipViewFilter(_serviceProvider, node);
                }
                else if (!m_provider.QuickInfoBroker.IsQuickInfoActive(m_textView))
                {
                    //m_session = m_provider.QuickInfoBroker.TriggerQuickInfo(m_textView, triggerPoint, true);
                    /*Setting DEBUG_PROPERTY_INFO.bstrFullName enables the button. I think it uses that name to persist the data tip to a file. It sure would be nice if the documentation gets enhanced one of these days!*/
                }
            }
        }
Пример #3
0
        Expression FindUnderMousePointer(EnvDTE.Debugger debugger, MouseHoverEventArgs e)
        {
            var point = e.TextPosition.GetPoint(e.TextPosition.AnchorBuffer, PositionAffinity.Predecessor);

            if (!point.HasValue)
            {
                return(null);
            }

            SnapshotSpan span;
            var          name = GetVariableNameAndSpan(point.Value, out span);

            if (name == null)
            {
                return(null);
            }

            var expression = debugger.GetExpression(name);

            if (!expression.IsValidValue)
            {
                return(null);
            }
            return(expression);
        }
Пример #4
0
 public GraphRenderer(GraphConfig config, Debugger debugger)
 {
     _config   = config;
     _debugger = debugger;
     _graph    = new Graph();
     _edges    = new Dictionary <string, Edge>();
 }
Пример #5
0
 private void SetBreakpointAtLine(int lineNumber)
 {
     EnvDTE.Debugger debugger = (EnvDTE.Debugger)DTE.Debugger;
     debugger.Breakpoints.Add("", MethodInspector.FileName, lineNumber, 1, "",
                              EnvDTE.dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue,
                              "C#", "", 0, "", 0, EnvDTE.dbgHitCountType.dbgHitCountTypeNone);
 }
Пример #6
0
        /// <summary>
        /// </summary>
        private void onAttachToDebugee(object sender, EventArgs e)
        {
            DTE dte = (DTE)GetService(typeof(DTE));

            EnvDTE.Debugger debugger = dte.Debugger;
            if (debugger.DebuggedProcesses.Count > 0)
            {
                EnvDTE.Process process = debugger.DebuggedProcesses.Item(1);
                if (AlcantareaHelper.InjectCoreDLL((uint)process.ProcessID, m_addindir))
                {
                    onUIContext((int)UIContext.AlcDebugging, 1);
                }
            }
        }
Пример #7
0
        public override string GetDataTipText(int line, int col, out TextSpan span)
        {
            span = new TextSpan();

            EnvDTE.DTE      dte = (EnvDTE.DTE)_ls.GetService(typeof(EnvDTE.DTE));
            EnvDTE.Debugger dbg = dte.Debugger as EnvDTE.Debugger;
            if (dbg != null && dte.Debugger.CurrentMode == dbgDebugMode.dbgBreakMode)
            {
                StringBuilder sb  = new StringBuilder();
                int           n   = 0;
                int           len = _origcasetargets.Length;
                foreach (string s in _origcasetargets)
                {
                    n++;
                    sb.Append(s);
                    if (n < len)
                    {
                        sb.Append('.');
                    }
                }
                string txt = sb.ToString();
                //HACK WARNING!! :DD
                //I put a $ in front of the expression so I know that is not a watch in
                //ze function IDebugExpressionContext2.ParseText (alberto)
                string     taggedtxt = "$" + txt;
                Expression e;
                try
                {
                    Debug.WriteLine("GetExpression(" + taggedtxt + ")");
                    e = dbg.GetExpression(taggedtxt, false, 500);
                }
                catch (Exception)
                {
                    return(null);
                }
                if (e == null || !e.IsValidValue)
                {
                    return(null);
                }

                span.iStartLine  = _line;
                span.iEndLine    = _line;
                span.iStartIndex = _start;
                span.iEndIndex   = _end;

                return(txt);
            }

            return(null);
        }
Пример #8
0
        void Import(string file, EnvDTE.Debugger debugger)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            string fullPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\DebuggerScript\\" + file;

            using (StreamReader stream = File.OpenText(fullPath))
            {
                while (!stream.EndOfStream)
                {
                    string line = stream.ReadLine();
                    ExecuteLine(line, debugger);
                }
            }
        }
Пример #9
0
        public virtual DebuggerScriptResultList Execute(string script, EnvDTE.Debugger debugger)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            DebuggerScriptResultList results = null;

            foreach (string line in script.Split('\r', '\n'))
            {
                if (!String.IsNullOrEmpty(line) && !line.StartsWith("//"))
                {
                    results = ExecuteLine(line, debugger);
                }
            }

            return(results);
        }
Пример #10
0
        public SQTextViewFilter(IServiceProvider serviceProvider, IVsTextView vsTextView)
        {
            var compModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));

            _vsEditorAdaptersFactoryService = compModel.GetService <IVsEditorAdaptersFactoryService>();
            _serviceProvider = serviceProvider;
            _vsdebugger      = (IVsDebugger)serviceProvider.GetService(typeof(IVsDebugger));

            EnvDTE.DTE dte = (EnvDTE.DTE)serviceProvider.GetService(typeof(EnvDTE.DTE));
            _debugger = dte.Debugger as EnvDTE.Debugger;

            vsTextView.GetBuffer(out _vsTextLines);

            _wpfTextView = _vsEditorAdaptersFactoryService.GetWpfTextView(vsTextView);
            TextView     = vsTextView;
            ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next));
        }
Пример #11
0
        public ProgressiveScroll(
            IWpfTextViewMargin containerMargin,
            IWpfTextView textView,
            IOutliningManager outliningManager,
            ITagAggregator <ChangeTag> changeTagAggregator,
            ITagAggregator <IVsVisibleTextMarkerTag> markerTagAggregator,
            ITagAggregator <IErrorTag> errorTagAggregator,
            EnvDTE.Debugger debugger,
            SimpleScrollBar scrollBar,
            ColorSet colors)
        {
            _containerMargin = containerMargin;

            ProgressiveScrollDict.Add(this);

            Colors               = colors;
            _textView            = textView;
            _scrollBar           = scrollBar;
            _markerTagAggregator = markerTagAggregator;
            _errorTagAggregator  = errorTagAggregator;

            RegisterEvents();
            InitSettings();

            _textRenderer = new TextRenderer(this, _textView, outliningManager);
            if (Options.RenderTextEnabled)
            {
                Visuals.Add(_textRenderer.TextVisual);
            }

            MarksVisual = new DrawingVisual();
            Visuals.Add(MarksVisual);

            _changeRenderer    = new ChangeRenderer(_textView, changeTagAggregator, scrollBar);
            _highlightRenderer = new HighlightRenderer(_textView, scrollBar);
            _markerRenderer    = new MarkerRenderer(_textView, markerTagAggregator, errorTagAggregator, debugger, scrollBar);

            foreach (var visual in Visuals)
            {
                AddVisualChild(visual);
            }
        }
Пример #12
0
        /// <summary>
        /// Constructor for the data tip controller.
        /// </summary>
        /// <param name="view">Visual Studio editor view</param>
        public CustomDataTip(IWpfTextView view)
        {
            this.view = view;
            root      = new CustomDataTipControl();
            curMax    = 0;
            start     = DateTime.UtcNow;
            dte       = ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE;
            debugger  = dte?.Debugger;
            TreeViewBuilder.TextColorBrush = root.ForeBrush;

            // Grab a reference to the adornment layer that this adornment should be added to
            adornmentLayer = view.GetAdornmentLayer("CustomDataTip");

            // Reposition the adornment whenever the editor window is resized
            this.view.ViewportHeightChanged += delegate { OnSizeChange(); };
            this.view.ViewportWidthChanged  += delegate { OnSizeChange(); };
            this.view.MouseHover            += UpdateAdornment;
            root.MouseEnter         += _root_MouseEnter;
            root.MouseLeave         += _root_MouseLeave;
            root.ExportButton.Click += _root_Export;
        }
Пример #13
0
        DebuggerScriptResultList RunFunction(string name, DebuggerScriptResultList input, List <string> args, EnvDTE.Debugger debugger)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            foreach (Function function in Functions)
            {
                if (function.Name == name && function.Args.Count == args.Count)
                {
                    DebuggerScriptRunner functionRunner = new DebuggerScriptRunner();
                    functionRunner.AddFunctions(Functions);
                    functionRunner.AddResult("$this", input);
                    for (int i = 0; i < args.Count; ++i)
                    {
                        if (args[i].StartsWith("$"))
                        {
                            functionRunner.AddResult(function.Args[i], SavedResults[args[i]]);
                        }
                        else
                        {
                            DebuggerScriptResultList argResult = new DebuggerScriptResultList();
                            argResult.AddLiteral(args[i], args[i]);
                            functionRunner.AddResult(function.Args[i], argResult);
                        }
                    }
                    return(functionRunner.Execute(function.Script, debugger));
                }
            }
            throw new Exception("No matching function: " + name);
        }
 public DebuggerOperations(Debugger debugger, OutputWindowPane log)
 {
     _debugger = debugger;
     _log      = log;
 }
Пример #15
0
 private Debugger_InProc()
 {
     _debugger = GetDTE().Debugger;
 }
Пример #16
0
        public DebuggerScriptResultList ExecuteLine(string script, EnvDTE.Debugger debugger)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            string        token;
            List <string> args;
            bool          isFunction;
            string        saveTo = null;

            DebuggerScriptResultList results = new DebuggerScriptResultList();

            string functionDeclStart = "function ";

            if (script.ToLower().StartsWith(functionDeclStart))
            {
                string functionDecl = script.Substring(functionDeclStart.Length);
                string restOfScript;
                GetNextToken(functionDecl, out FunctionBeingAdded.Name, out FunctionBeingAdded.Args, out isFunction, out restOfScript);
                if (!FunctionBeingAdded.Name.StartsWith("#"))
                {
                    throw new Exception("Function names must start with #");
                }
                FunctionBeingAdded.Script = "";
                IsAddingFunction          = true;
                return(null);
            }
            else if (IsAddingFunction)
            {
                if (script.ToLower() == "end")
                {
                    IsAddingFunction = false;
                    Functions.Add(FunctionBeingAdded);
                }
                else
                {
                    FunctionBeingAdded.Script = FunctionBeingAdded.Script + script + "\n";
                }
                return(null);
            }

            GetNextToken(script, out token, out args, out isFunction, out script);

            do
            {
                if (isFunction)
                {
                    switch (token.ToLower())
                    {
                    case ".array":
                        results = results.Array(int.Parse(GetArgValue(args[0], debugger)));
                        break;

                    case ".arrayrange":
                        results = results.ArrayRange(int.Parse(GetArgValue(args[0], debugger)), int.Parse(GetArgValue(args[1], debugger)));
                        break;

                    case ".cast":
                        results = results.Cast(args[0]);
                        break;

                    case "concat":
                    case ".concat":
                        results = Concat(args.ToArray());
                        break;

                    case ".filter":
                        if (args.Count != 1)
                        {
                            throw new Exception("filter requires 1 argument");
                        }
                        results = results.Filter(GetArgValue(args[0], debugger), debugger);
                        break;

                    case ".filterstring":
                        if (args.Count != 2)
                        {
                            throw new Exception("filterstring requires 2 arguments");
                        }
                        results = results.FilterString(GetArgValue(args[0], debugger), GetArgValue(args[1], debugger), debugger);
                        break;

                    case ".filternotstring":
                        if (args.Count != 2)
                        {
                            throw new Exception("filternotstring requires 2 arguments");
                        }
                        results = results.FilterNotString(GetArgValue(args[0], debugger), GetArgValue(args[1], debugger), debugger);
                        break;

                    case ".fold":
                        if (args.Count != 1)
                        {
                            throw new Exception("fold requires 1 argument");
                        }
                        results = results.Fold(args[0]);
                        break;

                    case ".index":
                        results = results.ArrayIndex(int.Parse(GetArgValue(args[0], debugger)));
                        break;

                    case ".members":
                        results = results.Members(args.ToArray());
                        break;

                    case ".memory":
                        results = Memory(args, results);
                        break;

                    case ".pointer":
                        results = results.Pointer();
                        break;

                    case ".reference":
                        results = results.Reference();
                        break;

                    case ".reinterpretcast":
                        results = results.ReinterpretCast(GetArgValue(args[0], debugger));
                        break;

                    case ".rename":
                        results = results.Rename(GetArgValue(args[0], debugger));
                        break;

                    case ".renamewithindex":
                        results = results.RenameWithIndex(GetArgValue(args[0], debugger));
                        break;

                    case "zip":
                    case ".zip":
                        results = Zip(args.ToArray());
                        break;

                    case "zipwith":
                    case ".zipwith":
                        results = ZipWith(args.ToArray());
                        break;

                    case "import":
                        Import(args[0], debugger);
                        break;

                    case "=":
                        saveTo = args[0];
                        if (!saveTo.StartsWith("$"))
                        {
                            throw new Exception("Variables must begin with '$'");
                        }
                        break;

                    default:
                        if (token.StartsWith("#"))
                        {
                            results = RunFunction(token, results, args, debugger);
                        }
                        else if (token.StartsWith(".#"))
                        {
                            results = RunFunction(token.Substring(1), results, args, debugger);
                        }
                        else
                        {
                            throw new Exception("Unknown function");
                        }
                        break;
                    }
                }
                else if (token.StartsWith(".") || token.StartsWith("->"))
                {
                    results = results.Members(token);
                }
                else if (token.StartsWith("$"))
                {
                    if (!SavedResults.ContainsKey(token))
                    {
                        throw new Exception(String.Format("Using unknown variable {0}", token));
                    }
                    results = SavedResults[token];
                }
                else
                {
                    results = GetVariable(token);
                }
            } while (GetNextToken(script, out token, out args, out isFunction, out script));

            if (saveTo != null)
            {
                SavedResults.Add(saveTo, results);
            }
            return(results);
        }
Пример #17
0
 public DebuggerHandler(EnvDTE.Debugger debugger, IWpfTextView view)
 {
     m_debugger = debugger;
     m_view = view;
     m_view.MouseHover += OnMouseHover;
 }
Пример #18
0
 public DebuggerHandler(EnvDTE.Debugger debugger, IWpfTextView view)
 {
     m_debugger         = debugger;
     m_view             = view;
     m_view.MouseHover += OnMouseHover;
 }
Пример #19
0
        unsafe public bool ReadProcessM(uint address, uint point_num, uint bytes_per_point, IntPtr result, ref uint point_num_read)
        {
            //detecting how many points we can read
            //detecting how many pages age commitied
            //reading them
            //truncating point_num if necessary
            point_num_read = 0;
            // here we must check if the process is available for debugging
            DTE dte = (DTE)Package.GetGlobalService(typeof(DTE));

            EnvDTE.Debugger dbg             = dte.Debugger;
            EnvDTE.Process  current_process = dbg.CurrentProcess;
            if (current_process == null)
            {
                return(false);
            }

            int    process_id = ((DTE)Package.GetGlobalService(typeof(DTE))).Debugger.CurrentProcess.ProcessID;
            IntPtr handle     = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, false, process_id);

            if (handle.ToInt32() == 0)
            {
                return(false);
            }

            uint   variable_address = address;
            uint   tmp                    = address / PAGE_SIZE; //avoiding optimisation
            uint   base_address           = tmp * PAGE_SIZE;
            IntPtr base_address_param     = new IntPtr(base_address);
            MEMORY_BASIC_INFORMATION info = new MEMORY_BASIC_INFORMATION();
            uint err = VirtualQueryEx(handle, base_address_param, ref info, sizeof(MEMORY_BASIC_INFORMATION));

            if (err == 0)
            {
                return(false);
            }
            if (info.State != MEM_COMMIT)
            {
                return(false);
            }
            //calculating number of points commited
            uint region_size             = info.RegionSize;
            uint variable_address_offset = variable_address - base_address;
            uint bytes_available         = info.RegionSize - variable_address_offset;
            uint point_num_available     = bytes_available / bytes_per_point;

            if (point_num > point_num_available)
            {
                point_num = point_num_available;
            }
            //reading available data
            uint   bytes_requested        = point_num * bytes_per_point;
            int    result_size            = 0x00;
            IntPtr result_size_param      = new IntPtr(&result_size);
            IntPtr variable_address_param = new IntPtr(variable_address);
            bool   r = ReadProcessMemory(handle, variable_address_param, result, bytes_requested, result_size_param);

            if (r == false)
            {
                return(false);
            }
            if (result_size != bytes_requested)
            {
                return(false);
            }
            point_num_read = point_num;
            CloseHandle(handle);
            return(true);
        }
Пример #20
0
        private void parse_watch(String input, ref StringBuilder name, ref StringBuilder value, ref StringBuilder type)
        {
            //This fuction extracts variable name and type from the Clipboard on CtrC command
            //on a selected item in the Watch window
            //input looks like this
            //            size	-858993460	const int\r
            //\t as delimiters
            //sometimes there is "" for char pointers so " is delimieter also
            //space is also delimiter
            //const int is a type
            //size is variable name

            OutputMessage("Input String: " + input);

            int  words      = 0;
            char delimiter  = (char)(0x09); // \t
            char delimiter1 = (char)(0x22); //"
            char delimiter2 = (char)(0x00); // space is not delimiter
            char endline    = '\r';

            for (int i = 0; i < input.Length; ++i)
            {
                if (input[i] == endline)
                {
                    break;
                }
                if (((input[i] == delimiter) || (input[i] == delimiter1) || (input[i] == delimiter2)) && ((input[i + 1] != delimiter) && (input[i + 1] != delimiter1) && (input[i + 1] != delimiter2)))
                {
                    ++words;
                }
                if ((input[i] != delimiter) && (input[i] != delimiter1) && (input[i] != delimiter2) && (words == 1))
                {
                    name.Append(input[i]);
                }
                if ((input[i] != delimiter) && (input[i] != delimiter1) && (input[i] != delimiter2) && (words == 2))
                {
                    value.Append(input[i]);
                }
                if ((input[i] != delimiter) && (input[i] != delimiter1) && (input[i] != delimiter2) && (words == 3))
                {
                    type.Append(input[i]);
                }
            }

            //also there must be numbers
            //like 0x01020304 {1.7800000}
            //in vs1023
            //removing averything except
            //first 10 symbols
            {
                int value_length = value.Length;

                value.Remove(10, value_length - 1 - 9);
            }
            //the type may contain [] like
            //float[num]
            //in this case we removing num]
            //float [256] -> float [
            int length = type.Length;
            int idx    = 0;

            for (idx = 0; idx < length; ++idx)
            {
                if (type[idx] == '[')
                {
                    break;
                }
            }
            if (idx != length)
            {
                type.Remove(idx + 1, length - idx - 1);
            }

            OutputMessage("Parse Result: " + name.ToString() + " " + value.ToString() + " " + type.ToString());

            //new feature
            //trying to get address from debugger
            string var_name = "signal";
            DTE    dte      = (DTE)Package.GetGlobalService(typeof(DTE));

            EnvDTE.Debugger dbg = dte.Debugger;
            Expression      exp = dbg.GetExpression(var_name, false, 1000);
            string          v   = exp.Value;
            string          t   = exp.Type;
        }