Inheritance: IDebugEngine2, IDebugEngineLaunch2, IDebugProgram3, IDebugEngineProgram2, IDebugSymbolSettings100
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="pBPRequest"> The breakpoint request used to create this pending breakpoint. </param>
        /// <param name="engine"> The AD7Engine object that represents the DE. </param>
        /// <param name="bpManager"> The breakpoint manager. </param>
        public AD7PendingBreakpoint(IDebugBreakpointRequest2 pBPRequest, AD7Engine engine, BreakpointManager bpManager)
        {
            m_pBPRequest = pBPRequest;
            BP_REQUEST_INFO[] requestInfo = new BP_REQUEST_INFO[1];
            m_pBPRequest.GetRequestInfo(enum_BPREQI_FIELDS.BPREQI_BPLOCATION, requestInfo);
            m_bpRequestInfo = requestInfo[0];
            m_pBPRequest.GetRequestInfo(enum_BPREQI_FIELDS.BPREQI_CONDITION, requestInfo);
            if (requestInfo[0].dwFields != 0)
            {
                m_bpRequestInfo.bpCondition = requestInfo[0].bpCondition;
                m_bpRequestInfo.dwFields |= requestInfo[0].dwFields;
            }
            m_pBPRequest.GetRequestInfo(enum_BPREQI_FIELDS.BPREQI_PASSCOUNT, requestInfo);
            if (requestInfo[0].dwFields != 0)
            {
                m_bpRequestInfo.bpPassCount = requestInfo[0].bpPassCount;
                m_bpRequestInfo.dwFields |= requestInfo[0].dwFields;
            }

            m_engine = engine;
            m_bpManager = bpManager;
            m_boundBreakpoints = new System.Collections.Generic.List<AD7BoundBreakpoint>();

            m_enabled = true;
            m_deleted = false;
        }
Example #2
0
        //, DebuggedThread debuggedThread)
        //        public AD7Thread(AD7Engine aEngine, bool current, string id, string targetID, string state, string priority, string name)//, DebuggedThread debuggedThread)
        public AD7Thread(AD7Engine aEngine, bool current, string id, string targetID, string state, string priority, string name, string fullname, string line)
        {
            _engine = aEngine;
            _suspendCount = 0;
            if (id == "1")
                _threadDisplayName = "Main Thread";
            else
                _threadDisplayName = (name != "") ? name : "<No Name>";

            if (fullname.Contains("~"))
            {
                // Need to lengthen the path used by Visual Studio.
                StringBuilder longPathName = new StringBuilder(1024);
                GetLongPathName(fullname, longPathName, longPathName.Capacity);
                _filename = longPathName.ToString();
            }
            else
                _filename = fullname;

            try
            {
                _line = Convert.ToUInt32(line);
            }
            catch
            {
                _line = 0;
            }

            _current = current;
            _id = id;
            _state = state;
            _targetID = targetID;
            _priority = priority;
        }
Example #3
0
        string _sessionName; // has no value assigned because the method that uses it is "[DEPRECATED. SHOULD ALWAYS RETURN E_NOTIMPL.]"

        #endregion Fields

        #region Constructors

        public AD7Process(EngineCallback aCallback, AD7Engine aEngine, IDebugPort2 aPort)
        {
            _callback = aCallback;
            _engine = aEngine;
            _port = aPort;
            m_program = aEngine.m_program;
            //                m_program = new AD7Program(this, _callback, _engine.eDispatcher);
        }
Example #4
0
        public EventDispatcher(AD7Engine engine, AD7Process process)
        {
            m_engine = engine;
            m_process = process;

            m_gdbOutput = new GDBOutput(this);
            m_processingThread = new Thread(m_gdbOutput.processingGDBOutput);
            m_processingThread.Start();

            //            myWriter = new TextWriterTraceListener(System.Console.Out);
            //            Debug.Listeners.Add(myWriter);
        }
Example #5
0
 /// <summary>
 /// Breakpoint manager constructor.
 /// </summary>
 /// <param name="engine"> Associated Debug Engine. </param>
 public BreakpointManager(AD7Engine engine)
 {
     m_engine = engine;
     m_pendingBreakpoints = new System.Collections.Generic.List<AD7PendingBreakpoint>();
     m_activeBPs = new System.Collections.Generic.List<AD7BoundBreakpoint>();
 }
Example #6
0
 internal static void Send(AD7Engine engine, uint exitCode, AD7Thread thread)
 {
     var eventObject = new AD7ThreadDestroyEvent(exitCode);
     if (thread == null)
     {
         foreach (AD7Thread t in engine.thread)
         {
             engine.Callback.Send(eventObject, IID, t);
         }
         engine._currentThreadIndex = -1;
     }
     else
     {
         engine.Callback.Send(eventObject, IID, thread);
     }
     //            engine.Callback.Send(eventObject, IID, null);
 }
Example #7
0
 public static void Send(AD7Engine engine)
 {
     var xEvent = new AD7StepCompletedEvent();
     engine.Callback.Send(xEvent, IID, engine.currentThread());
 }
Example #8
0
 internal static void Send(AD7Engine engine, uint exitCode)
 {
     var eventObject = new AD7ProgramDestroyEvent(exitCode);
     engine.Callback.Send(eventObject, IID, null);
 }
Example #9
0
 internal static void Send(AD7Engine engine)
 {
     AD7ProgramCreateEvent eventObject = new AD7ProgramCreateEvent();
     engine.Callback.Send(eventObject, IID, null);
 }
Example #10
0
 internal static void Send(AD7Engine engine, AD7Module aModule, bool fLoad)
 {
     var eventObject = new AD7ModuleLoadEvent(aModule, fLoad);
     engine.Callback.Send(eventObject, IID, null);
 }
Example #11
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="aEngine"> The AD7Engine object that represents the DE. </param>
 /// <param name="aPort"> The IDebugPort2 object that represents the port on which the process was launched. </param>
 public AD7Process(AD7Engine aEngine, IDebugPort2 aPort)
 {
     _engine = aEngine;
     _port = aPort;
     m_program = aEngine.m_program;
 }
Example #12
0
        /// <summary>
        /// Constructor. Starts the thread responsible for handling asynchronous GDB output.
        /// </summary>
        /// <param name="engine"> The AD7Engine object that represents the DE. </param>
        public EventDispatcher(AD7Engine engine)
        {
            m_engine = engine;

            m_gdbOutput = new GDBOutput(this);
            m_processingThread = new Thread(m_gdbOutput.processingGDBOutput);
            m_processingThread.Start();
        }
Example #13
0
 public int Detach()
 {
     _enumDebugPrograms = null;
     _enumDebugThreads = null;
     _port = null;
     _callback = null;
     _engine = null;
     m_program = null;
     return VSConstants.S_OK;
 }
Example #14
0
 AD7EngineCreateEvent(AD7Engine engine)
 {
     m_engine = engine;
 }
Example #15
0
        public AD7StackFrame(AD7Engine engine, AD7Thread thread, string[] frameInfo)
        {
            m_engine = engine;
            m_thread = thread;
            m_dispatcher = m_engine.eDispatcher;

            uint level = Convert.ToUInt32(frameInfo[0]);
            string address = frameInfo[1];
            m_addressString = address;
            m_functionName = frameInfo[2];
            m_documentName = frameInfo[3];
            try
            {
                m_lineNum = Convert.ToUInt32(frameInfo[4]);
            }
            catch (Exception e)
            {
                m_lineNum = 0;
            }

            _locals = new ArrayList();
            _arguments = new ArrayList();
            m_hasSource = (m_lineNum == 0) ? false : true;
            ArrayList evaluatedVars = new ArrayList();

            // Add the variable filter list to the evaluatedVars list.
            // Causes named variables to be ignored.
            evaluatedVars.AddRange(m_variableFilter);

            if (address.StartsWith("0x"))
                address = address.Remove(0, 2);
            m_address = uint.Parse(address, System.Globalization.NumberStyles.AllowHexSpecifier);

            // Query GDB for parameters and locals.
            string variablesResponse = m_engine.eDispatcher.getVariablesForFrame(level, m_thread._id).Replace("#;;;", "");
            if (variablesResponse == null || variablesResponse == "ERROR" || variablesResponse == "")
                return;
            variablesResponse = variablesResponse.Substring(3);

            string[] variableStrings = variablesResponse.Split('#');

            foreach (string variableString in variableStrings)
            {
                string name = null;
                bool arg = false;
                string type = null;
                string value = null;

                string[] variableProperties = variableString.Split(';');

                if (variableProperties[0] != "")
                {
                    if (!evaluatedVars.Contains(variableProperties[0]))
                    {
                        name = variableProperties[0];
                        evaluatedVars.Add(variableProperties[0]);
                        if (variableProperties[1] != "")
                            arg = true;
                        if (variableProperties[2] != "")
                            type = variableProperties[2];
                        if (variableProperties[3] != "")
                            value = variableProperties[3];
                        if (arg)
                            _arguments.Add(VariableInfo.create(name, type, value, m_engine.eDispatcher));
                        else
                            _locals.Add(VariableInfo.create(name, type, value, m_engine.eDispatcher));
                    }
                }
            }
        }
Example #16
0
        public static AD7StackFrame create(AD7Engine engine, AD7Thread thread, string[] frameInfo, ref bool created)
        {
            created = false;
            if (thread.__stackFrames != null)
            {
                foreach (AD7StackFrame frame in thread.__stackFrames)
                {
                    if (frame.m_documentName != null && frame.m_functionName != null)
                    {
                        if (frame.m_documentName == frameInfo[3] && frame.m_functionName == frameInfo[2])// && frame.m_addressString == frameInfo[1]) // frameInfo[2] = func, frameInfo[3] = file
                            return frame;
                    }
                }
            }
            else
                thread.__stackFrames = new ArrayList();

            AD7StackFrame newFrame = new AD7StackFrame(engine, thread, frameInfo);
            if (thread.__stackFrames == null) // that's weird, but sometimes VS is not initializing __stackFrames, so I added this loop to avoid other problems.
                thread.__stackFrames = new ArrayList() { newFrame };
            else
                thread.__stackFrames.Add(newFrame);
            created = true;
            return newFrame;
        }
Example #17
0
 /// <summary>
 /// Detaches the debugger from this process by detaching all of the programs in the process. 
 /// (http://msdn.microsoft.com/en-us/library/bb162197.aspx)
 /// </summary>
 /// <returns> VSConstants.S_OK. </returns>
 public int Detach()
 {
     _port = null;
     _portAttach = null;
     _engine = null;
     m_program = null;
     return VSConstants.S_OK;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="engine"> AD7 Engine. </param>
 /// <param name="address"> GDB Address. </param>
 /// <param name="documentContext"> The document context to the debugger. A document context represents a location within a 
 /// source file. </param>
 public AD7BreakpointResolution(AD7Engine engine, uint address, AD7DocumentContext documentContext)
 {
     m_engine = engine;
     m_address = address;
     m_documentContext = documentContext;
 }
Example #19
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="engine"> The AD7Engine object that represents the DE. </param>
 /// <param name="ad7Callback"> The IDebugEventCallback2 object that receives debugger events. </param>
 public EngineCallback(AD7Engine engine, IDebugEventCallback2 ad7Callback)
 {
     m_ad7Callback = ad7Callback;
     m_engine = engine;
 }
Example #20
0
 public static void Send(AD7Engine engine)
 {
     AD7EngineCreateEvent eventObject = new AD7EngineCreateEvent(engine);
     engine.Callback.Send(eventObject, IID, null, null);
 }
Example #21
0
        /// <summary>
        /// Search the __stackframes cache for the internal representation of the stack frame associated to the GDB frameInfo 
        /// information. If successful, returns the stack frame; otherwise, creates a new one and return it.
        /// </summary>
        /// <param name="engine"> The AD7Engine object that represents the DE. </param>
        /// <param name="thread"> Represents the thread for this stack frame. </param>
        /// <param name="frameInfo">  Array of strings with the information provided by GDB about this stack frame. </param>
        /// <param name="created"> Boolean value that indicates if a new object for this stack frame was created or not. </param>
        /// <returns> Returns the created/found stack frame. </returns>
        public static AD7StackFrame create(AD7Engine engine, AD7Thread thread, string[] frameInfo, ref bool created)
        {
            created = false;
            if (thread.__stackFrames != null)
            {
                foreach (AD7StackFrame frame in thread.__stackFrames)
                {
                    if (frame.m_documentName != null && frame.m_functionName != null)
                    {
                        if (frame.m_documentName == frameInfo[3] && frame.m_functionName == frameInfo[2]) // frameInfo[2] = func, frameInfo[3] = file
                            return frame;
                    }
                }
            }
            else
                thread.__stackFrames = new ArrayList();

            AD7StackFrame newFrame = new AD7StackFrame(engine, thread, frameInfo);
            thread.__stackFrames.Add(newFrame);
            created = true;
            return newFrame;
        }
Example #22
0
        /// <summary> 
        /// AD7BoundBreakpoint constructor for file/line breaks. 
        /// </summary>
        /// <param name="engine"> AD7 Engine. </param>
        /// <param name="bpReqInfo"> Contains the information required to implement a breakpoint. </param>
        /// <param name="pendingBreakpoint"> Associated pending breakpoint. </param>
        public AD7BoundBreakpoint(AD7Engine engine, BP_REQUEST_INFO bpReqInfo, AD7PendingBreakpoint pendingBreakpoint)
        {
            if (bpReqInfo.bpLocation.bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE)
            {
                string documentName;

                // Get Decument Position and File Name
                IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(bpReqInfo.bpLocation.unionmember2));
                docPosition.GetFileName(out documentName);

                // Need to shorten the path we send to GDB.
                StringBuilder shortPath = new StringBuilder(1024);
                GetShortPathName(documentName, shortPath, shortPath.Capacity);

                // Get the location in the document that the breakpoint is in.
                TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
                TEXT_POSITION[] endPosition = new TEXT_POSITION[1];
                docPosition.GetRange(startPosition, endPosition);

                m_engine = engine;
                m_bpLocationType = (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE;
                m_filename = shortPath.ToString();
                m_line = startPosition[0].dwLine + 1;

                m_pendingBreakpoint = pendingBreakpoint;
                m_enabled = true;
                m_deleted = false;
                m_hitCount = 0;
                m_remoteID = m_engine.BPMgr.RemoteAdd(this);
            }
            else if (bpReqInfo.bpLocation.bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET)
            {
                string func;

                IDebugFunctionPosition2 funcPosition = (IDebugFunctionPosition2)(Marshal.GetObjectForIUnknown(bpReqInfo.bpLocation.unionmember2));
                funcPosition.GetFunctionName(out func);

                m_engine = engine;
                m_func = func;
                m_enabled = true;
                m_deleted = false;
                m_hitCount = 0;
                m_bpLocationType = (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET;
                m_pendingBreakpoint = pendingBreakpoint;
                m_remoteID = m_engine.BPMgr.RemoteAdd(this);
            }

            //            if ((m_remoteID == 0) && (VSNDK.AddIn.VSNDKAddIn.isDebugEngineRunning == false))
            if (m_remoteID == 0)
            {
                return;
            }

            // Set the hit count and condition
            if (bpReqInfo.bpPassCount.stylePassCount != enum_BP_PASSCOUNT_STYLE.BP_PASSCOUNT_NONE)
                SetPassCount(bpReqInfo.bpPassCount);
            if (bpReqInfo.bpCondition.styleCondition != enum_BP_COND_STYLE.BP_COND_NONE)
                SetCondition(bpReqInfo.bpCondition);

            // Get the Line Position sent back from GDB
            TEXT_POSITION tpos = new TEXT_POSITION();
            tpos.dwLine = m_GDB_linePos - 1;

            uint xAddress = UInt32.Parse(m_GDB_Address.Substring(2), System.Globalization.NumberStyles.HexNumber);

            AD7MemoryAddress codeContext = new AD7MemoryAddress(m_engine, xAddress);
            AD7DocumentContext documentContext = new AD7DocumentContext(m_GDB_filename, tpos, tpos, codeContext);

            m_breakpointResolution = new AD7BreakpointResolution(m_engine, xAddress, documentContext);

            m_engine.Callback.OnBreakpointBound(this, 0);
        }
Example #23
0
 public static void Send(AD7Engine engine)
 {
     var xEvent = new AD7EntryPointEvent();
     engine.Callback.Send(xEvent, IID, engine.currentThread());
 }
Example #24
0
 internal static void Send(AD7Engine aEngine, AD7Thread aThread)
 {
     var xMessage = new AD7LoadCompleteEvent();
     aEngine.Callback.Send(xMessage, IID, aThread);
 }
Example #25
0
 public AD7MemoryAddress(AD7Engine engine, uint address)
 {
     m_engine = engine;
     m_address = address;
 }