Beispiel #1
0
        void FillTreeScript(TreeViewItem treeitem, ThinNeo.SmartContract.Debug.LogScript script)
        {
            treeitem.Tag    = script;
            treeitem.Header = "script:" + script.hash;
            foreach (var op in script.ops)
            {
                TreeViewItem itemop = new TreeViewItem();

                itemop.Header = op.GetHeader();
                if (op.op == ThinNeo.VM.OpCode.SYSCALL && op.param != null)
                {
                    string p = System.Text.Encoding.ASCII.GetString(op.param);
                    itemop.Header = op.GetHeader() + " " + p;
                }
                if (op.error)
                {
                    itemop.Background = new SolidColorBrush(Color.FromRgb(255, 127, 127));
                }
                itemop.Tag = op;
                treeitem.Items.Add(itemop);
                if (op.subScript != null)
                {
                    TreeViewItem subscript = new TreeViewItem();
                    itemop.Items.Add(subscript);
                    FillTreeScript(subscript, op.subScript);
                }
            }
        }
Beispiel #2
0
        private void treeCode_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            ThinNeo.SmartContract.Debug.LogScript script = null;
            ThinNeo.SmartContract.Debug.LogOp     logop  = null;
            if (treeCode.SelectedItem != null)
            {
                var treenode  = treeCode.SelectedItem as TreeViewItem;
                var treenodep = treenode != null ? treenode.Parent as TreeViewItem : null;
                script = treenode.Tag as ThinNeo.SmartContract.Debug.LogScript;
                logop  = treenode.Tag as ThinNeo.SmartContract.Debug.LogOp;
                if (script == null && treenodep != null)
                {
                    script = treenodep.Tag as ThinNeo.SmartContract.Debug.LogScript;
                }
            }
            listStack.Items.Clear();
            listAltStack.Items.Clear();
            var stateid = -1;

            if (logop != null)
            {
                if (this.debugtool.simvm.mapState.ContainsKey(logop))
                {
                    stateid = debugtool.simvm.mapState[logop];
                    if (debugtool.simvm.stateClone.ContainsKey(stateid))
                    {
                        var state = debugtool.simvm.stateClone[stateid];
                        foreach (var l in state.CalcStack)
                        {
                            listStack.Items.Add(l);
                        }
                        foreach (var l in state.AltStack)
                        {
                            listAltStack.Items.Add(l);
                        }
                    }
                }
            }
            if (script == null)
            {
                selectScript.Content = "未选中脚本";
            }
            else
            {
                selectScript.Content = "选中脚本" + script.hash;
                if (debugtool.scripts.ContainsKey(script.hash))
                {
                    selectScriptDebug.Content = "有调试信息";
                    var debugscript = debugtool.scripts[script.hash];

                    if (debugscript != this.listBoxASM.Tag)
                    {
                        this.listBoxASM.Tag = debugscript;
                        this.listBoxASM.Items.Clear();
                        foreach (var op in debugscript.codes)
                        {
                            this.listBoxASM.Items.Add(op);
                        }

                        this.codeEdit.Text = debugscript.srcfile;
                    }
                    if (logop != null)
                    {
                        foreach (ThinNeo.Compiler.Op op in listBoxASM.Items)
                        {
                            if (op.addr == (ushort)logop.addr)
                            {
                                listBoxASM.SelectedItem = op;
                                listBoxASM.ScrollIntoView(op);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    selectScriptDebug.Content = "没有调试信息";
                    this.listBoxASM.Tag       = null;
                    this.listBoxASM.Items.Clear();
                    this.codeEdit.Text = "";
                }
            }
        }