Exemple #1
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();
            }
        }