consistent tree node shape

This commit is contained in:
Steven Hugg 2020-07-11 20:29:55 -05:00
parent 7393d8276f
commit 4480e217f6
1 changed files with 14 additions and 9 deletions

View File

@ -1500,11 +1500,11 @@ export class DebugBrowserView extends TreeViewBase implements ProjectView {
} }
interface CallGraphNode { interface CallGraphNode {
count : number;
$$SP : number; $$SP : number;
$$PC? : number; $$PC : number;
startLine? : number; count : number;
endLine? : number; startLine : number;
endLine : number;
calls : {[id:string] : CallGraphNode}; calls : {[id:string] : CallGraphNode};
} }
@ -1547,14 +1547,17 @@ export class CallStackView extends ProbeViewBaseBase implements ProjectView {
this.rts = false; this.rts = false;
} }
newNode(pc : number, sp : number) {
return {$$SP:sp, $$PC:pc, count:0, startLine:null, endLine:null, calls:{}};
}
newRoot(pc : number, sp : number) { newRoot(pc : number, sp : number) {
if (this.stack.length == 0) { if (this.stack.length == 0) {
this.graph = {count:0, $$SP:sp, calls:{}}; this.graph = this.newNode(null, sp);
this.stack.unshift(this.graph); this.stack.unshift(this.graph);
} else if (sp > this.stack[0].$$SP) { } else if (sp > this.stack[0].$$SP) {
let calls = {}; this.graph = this.newNode(null, sp);
calls[this.addr2str(pc)] = this.stack[0]; this.graph.calls[this.addr2str(pc)] = this.stack[0];
this.graph = {count:0, $$SP:sp, calls:calls};
this.stack.unshift(this.graph); this.stack.unshift(this.graph);
} }
} }
@ -1585,7 +1588,9 @@ export class CallStackView extends ProbeViewBaseBase implements ProjectView {
let top = this.stack[this.stack.length-1]; let top = this.stack[this.stack.length-1];
let sym = this.addr2str(addr); let sym = this.addr2str(addr);
let child = top.calls[sym]; let child = top.calls[sym];
if (child == null) { child = top.calls[sym] = {count:0, $$PC:addr, $$SP:this.lastsp, calls:{}}; } if (child == null) {
child = top.calls[sym] = this.newNode(addr, this.lastsp);
}
else if (child.$$PC == null) child.$$PC = addr; else if (child.$$PC == null) child.$$PC = addr;
//this.stack.forEach((node) => node.count++); //this.stack.forEach((node) => node.count++);
this.stack.push(child); this.stack.push(child);