File tree Expand file tree Collapse file tree 4 files changed +18
-11
lines changed Expand file tree Collapse file tree 4 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ export interface Operation {
66 argument : any
77 begin ?: number
88 end ?: number
9+ repeated ?: number
910}
Original file line number Diff line number Diff line change @@ -7,13 +7,16 @@ import { DebugTrace } from '../symbolic/evm/DebugTrace'
77@injectable ( )
88export class GraphVizService {
99 createDotFromBlocks ( blocks : CFGBlocks , trace : DebugTrace ) : string {
10- return `digraph " " {
10+ let graph = `digraph " " {
1111 graph [splines=ortho ranksep="2" nodesep="2"]
1212 rankdir=LR
13- node [shape=plain fillcolor="#2A2A2A" style=filled fontname="Courier"]
14- ${ this . createLegend ( ) }
15- ${ this . buildBody ( blocks , trace ) }
16- }`
13+ node [shape=plain fillcolor="#2A2A2A" style=filled fontname="Courier"]`
14+ if ( trace ) {
15+ graph += `${ this . createLegend ( ) } `
16+ }
17+ graph += `${ this . buildBody ( blocks , trace ) }
18+ }`
19+ return graph
1720 }
1821
1922 private createLegend ( ) {
@@ -46,6 +49,9 @@ export class GraphVizService {
4649 if ( trace && this . isOperationInTrace ( op , trace ) ) {
4750 fontColor = '#ff1020'
4851 }
52+ if ( op . repeated > 1 ) {
53+ fontColor = '#CD950C'
54+ }
4955 ops += `<TR>`
5056 ops += `<TD ID="${ op . offset . toString ( 16 ) } " HREF=" "><font color="${ fontColor } ">0x${ op . offset . toString (
5157 16
Original file line number Diff line number Diff line change @@ -4,6 +4,5 @@ export interface OperationBlock {
44 offset : number
55 operations : Operation [ ]
66 childA ?: number
7- childB ?: number ,
8- repeated ?: number
7+ childB ?: number
98}
Original file line number Diff line number Diff line change @@ -51,13 +51,14 @@ export class CFGService {
5151 checkTraceLoops ( blocks : CFGBlocks , trace : DebugTrace ) {
5252 const logs = trace . result . structLogs
5353 const count = this . count ( logs . map ( l => l . pc ) )
54- const repeated : any = Object . keys ( count ) . filter ( key => count [ key ] > 1 ) . map ( key => { return { offset : key , repeated : count [ key ] } } )
54+ const repeated : any = Object . keys ( count ) . filter ( key => count [ key ] > 1 ) . map ( key => { return { offset : parseInt ( key ) , repeated : parseInt ( count [ key ] ) } } )
5555 for ( const repeatedOffset of repeated ) {
56- console . log ( `trying to find block ${ repeatedOffset . offset } ` )
5756 const block = blocks . get ( repeatedOffset . offset )
5857 if ( block ) {
59- console . log ( 'block found' )
60- block . repeated = repeatedOffset . repeated
58+ const operation = block . operations . find ( op => op . offset === parseInt ( repeatedOffset . offset ) )
59+ if ( operation ) {
60+ operation . repeated = repeatedOffset . repeated
61+ }
6162 }
6263 }
6364 }
You can’t perform that action at this time.
0 commit comments