예제 #1
0
        private void ShowCodeObject()
        {
            if (callStackView.SelectedItems.Count == 1)
            {
                ListViewItem          selectedItem     = callStackView.SelectedItems[0];
                NuGenFrameInformation frameInformation = selectedItem.Tag as NuGenFrameInformation;

                if (frameInformation != null)
                {
                    frameInformation.RefreshFrame();
                    List <NuGenBaseLineDescriptor> specialLines   = null;
                    NuGenCodeObjectDisplayOptions  displayOptions = new NuGenCodeObjectDisplayOptions();

                    if (frameInformation.IsActiveFrame)
                    {
                        if (frameInformation.IsExactLocation)
                        {
                            displayOptions.CurrentLine = new NuGenCurrentLine(frameInformation.Offset);
                        }
                        else
                        {
                            displayOptions.CurrentLine = new NuGenCallerLine(frameInformation.Offset);
                        }
                    }
                    else
                    {
                        NuGenBaseLineDescriptor lineDescriptor = null;
                        specialLines = new List <NuGenBaseLineDescriptor>(1);

                        if (frameInformation.IsExactLocation)
                        {
                            lineDescriptor = new NuGenExactCallerLine(frameInformation.Offset);
                        }
                        else
                        {
                            lineDescriptor = new NuGenCallerLine(frameInformation.Offset);
                        }

                        specialLines.Add(lineDescriptor);
                    }

                    displayOptions.SpecialLinesToAdd = specialLines;

                    NuGenUIHandler.Instance.ShowCodeObject(frameInformation.MethodDefinition, displayOptions);
                    NuGenUIHandler.Instance.FrameChangedUpdate(frameInformation.Refresher, frameInformation.Frame, false);
                }
            }
        }
		public void DisplayCallStack(List<FrameWrapper> callStack)
		{
			if (callStack != null)
			{
				callStackView.BeginUpdate();
				callStackView.Items.Clear();

				for (int index = 0; index < callStack.Count; index++)
				{
					FrameWrapper frame = callStack[index];
					ListViewItem item = new ListViewItem();
					bool isCodeAvailable = false;
					FunctionWrapper function = null;

					try
					{
						function = frame.GetFunction();
						isCodeAvailable = true;
					}
					catch(COMException comException)
					{
						//0x80131309 == CORDBG_E_CODE_NOT_AVAILABLE
						if ((uint)comException.ErrorCode == 0x80131309)
						{
							isCodeAvailable = false;
						}
						else
						{
							throw;
						}
					}

					if (isCodeAvailable)
					{
						ModuleWrapper module = function.GetModule();
						uint functionToken = function.GetToken();
						
						NuGenTokenBase tokenObject = NuGenHelperFunctions.FindObjectByToken(functionToken, module);
						NuGenMethodDefinition methodDefinition = tokenObject as NuGenMethodDefinition;

						if (methodDefinition != null)
						{
							bool activeFrame = (index == 0);
							NuGenFrameInformation frameInformation = new NuGenFrameInformation(NuGenDebugEventHandler.Instance.EventObjects.Thread, methodDefinition, activeFrame, frame);
							item.Tag = frameInformation;
							item.Text = string.Format("{0}::{1}", methodDefinition.BaseTypeDefinition.FullName, methodDefinition.DisplayName);

							if (!frameInformation.IsExactLocation)
							{
								item.Text += " - not exact offset";
							}
						}
						else
						{
							string moduleName = module.GetName();

							if (module.IsInMemory())
							{
								item.Tag = new NuGenMissingModule(module);
							}
							else
							{
								item.Tag = new NuGenMissingModule(moduleName);
							}

							item.Text = "Unknown method (perhaps a reference is not loaded). Module name: " + moduleName;
						}
					}

					if (!frame.IsILFrame())
					{
						if (isCodeAvailable)
						{
							item.Text = "Native frame, IP offset is not available (" + item.Text + ")";
						}
						else
						{
							item.Text = "Native frame, IP offset is not available (code is unavailable).";
						}
					}

					item.ToolTipText = item.Text;
					callStackView.Items.Add(item);
				}

				callStackView.EndUpdate();
			}
		}
예제 #3
0
        public void DisplayCallStack(List <FrameWrapper> callStack)
        {
            if (callStack != null)
            {
                callStackView.BeginUpdate();
                callStackView.Items.Clear();

                for (int index = 0; index < callStack.Count; index++)
                {
                    FrameWrapper    frame           = callStack[index];
                    ListViewItem    item            = new ListViewItem();
                    bool            isCodeAvailable = false;
                    FunctionWrapper function        = null;

                    try
                    {
                        function        = frame.GetFunction();
                        isCodeAvailable = true;
                    }
                    catch (COMException comException)
                    {
                        //0x80131309 == CORDBG_E_CODE_NOT_AVAILABLE
                        if ((uint)comException.ErrorCode == 0x80131309)
                        {
                            isCodeAvailable = false;
                        }
                        else
                        {
                            throw;
                        }
                    }

                    if (isCodeAvailable)
                    {
                        ModuleWrapper module        = function.GetModule();
                        uint          functionToken = function.GetToken();

                        NuGenTokenBase        tokenObject      = NuGenHelperFunctions.FindObjectByToken(functionToken, module);
                        NuGenMethodDefinition methodDefinition = tokenObject as NuGenMethodDefinition;

                        if (methodDefinition != null)
                        {
                            bool activeFrame = (index == 0);
                            NuGenFrameInformation frameInformation = new NuGenFrameInformation(NuGenDebugEventHandler.Instance.EventObjects.Thread, methodDefinition, activeFrame, frame);
                            item.Tag  = frameInformation;
                            item.Text = string.Format("{0}::{1}", methodDefinition.BaseTypeDefinition.FullName, methodDefinition.DisplayName);

                            if (!frameInformation.IsExactLocation)
                            {
                                item.Text += " - not exact offset";
                            }
                        }
                        else
                        {
                            string moduleName = module.GetName();

                            if (module.IsInMemory())
                            {
                                item.Tag = new NuGenMissingModule(module);
                            }
                            else
                            {
                                item.Tag = new NuGenMissingModule(moduleName);
                            }

                            item.Text = "Unknown method (perhaps a reference is not loaded). Module name: " + moduleName;
                        }
                    }

                    if (!frame.IsILFrame())
                    {
                        if (isCodeAvailable)
                        {
                            item.Text = "Native frame, IP offset is not available (" + item.Text + ")";
                        }
                        else
                        {
                            item.Text = "Native frame, IP offset is not available (code is unavailable).";
                        }
                    }

                    item.ToolTipText = item.Text;
                    callStackView.Items.Add(item);
                }

                callStackView.EndUpdate();
            }
        }