Skip to content

Commit

Permalink
cleanup, add debug and analytic rels
Browse files Browse the repository at this point in the history
  • Loading branch information
sifislag committed Dec 21, 2023
1 parent 5338247 commit 340fe0f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
8 changes: 8 additions & 0 deletions logic/debug.dl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

.output global.BlockEdge, global.FallthroughEdge, global.BlockJumpValidTarget, global.BlockJumpTarget, MaybeInFunctionUnderContext
.output MaybeFunctionCallReturn // DEBUG
.output global.PrivateFunctionCall
.output PotentialCall // DEBUG
.output PossibleReturnAddressWithPos // DEBUG
.output IsFunctionCallReturn // DEBUG
Expand Down Expand Up @@ -56,6 +57,11 @@ BlockJumpValidTargetOrd(ord(context), block, var, target):-
MergeContextOrd(ord(ctx), caller, ord(newContext)):-
global.sens.MergeContext(ctx, caller, newContext).

.decl MergeContextResponseOrd(ctx: number, caller: Block, nextBlock: Block, newContext: number)
.output MergeContextResponseOrd
MergeContextResponseOrd(ord(ctx), caller, otherBlock, ord(newContext)):-
global.sens.MergeContextResponse(ctx, caller, otherBlock, newContext).

.decl ReachableContextOrd(ctx: number, block: Block)
.output ReachableContextOrd
ReachableContextOrd(ord(ctx), block):-
Expand All @@ -82,6 +88,8 @@ MaybeInFunctionUnderContextOrd(ord(ctx), block, func):-
MaybeInFunctionUnderContext(ctx, block, func).


.output global.sens.CutToCaller

// .decl CFGImprecisionPersists(srcCtx: global.sens.Context, srcBlk: Block, currCtx: global.sens.Context, currBlk: Block, targetVar1: Variable, targetVar2: Variable, pathLen: number)
// .output CFGImprecisionPersists

Expand Down
6 changes: 6 additions & 0 deletions logic/decompiler_analytics.dl
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ Analytics_Block_TimesInContexts(block, timesInContext):-
GloballyReachableBlocks(block),
timesInContext = count : { global.sens.ContextContainsBlock(_, block, _) }.

.decl Analytics_PublicFunction_Contexts(pubFun: symbol, contexts: number)
.output Analytics_PublicFunction_Contexts

Analytics_PublicFunction_Contexts(pubFun, contexts):-
global.sens.Context_PublicFunction(_, pubFun),
contexts = count: global.sens.Context_PublicFunction(_, pubFun).

.decl Verbatim_BlocksReachabilityMetric(blocks: number, totalReach: number, avg: float)
.output Verbatim_BlocksReachabilityMetric
Expand Down
3 changes: 2 additions & 1 deletion logic/global.dl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define MAX_NUM_PRIVATE_FUNCTION_RETS 50

#define LIMITSIZE_BLOCK_OUTPUT_CONTENTS 1000000
#define LIMITSIZE_BIG_BLOCK_OUTPUT_CONTENTS 5000000
#define CheckIsVariable(v) ((v) < 0)
#define CheckIsStackIndex(v) ((v) >= 0, (v) < MAX_STACK_HEIGHT)

Expand Down Expand Up @@ -322,7 +323,7 @@ PreMask_Length(cat(mask, "ff"), bytes+1) :-
*/
.comp CompleteOptimizedGlobalAnalysis <AbstractContextSensitivity, LocalAnalysis> : OptimizedGlobalAnalysis <AbstractContextSensitivity, LocalAnalysis> {
#ifdef ENABLE_LIMITSIZE
.limitsize BlockOutputContents(n=LIMITSIZE_BLOCK_OUTPUT_CONTENTS)
.limitsize BlockOutputContents(n=LIMITSIZE_BIG_BLOCK_OUTPUT_CONTENTS)
#endif
}

Expand Down
6 changes: 0 additions & 6 deletions logic/local.dl
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,6 @@ ByteCodeHex(substr(bytecode, 2, strlen(bytecode))):-
PrivateFunctionCall(block, _, _, _);
PrivateFunctionReturn(block).

.output MultiplePrivateFunctionCall
.output PrivateFunctionCall
// .output CallBlockEarliestContinuation

.decl CODECOPYStatement(stmt: Statement, offset: Value, size: Value)

CODECOPYStatement(codeCopy, codeOffsetNumHex, smallNumHex) :-
Expand Down Expand Up @@ -1155,8 +1151,6 @@ postTrans.PublicFunction(block , hash, selector):-
preTrans.PublicFunction(block, hash, selector),
ValidSelector(selector).

.output postTrans.PublicFunction, preTrans.PublicFunction, preTrans.BlockComparesSigFallthroughSolidity, preTrans.BlockComparesSigVyper, insertor.MetaData
.output postTrans.PublicFunctionJump
// Code chunking logic reserved for future EIP

#define CHUNK_SIZE 31
Expand Down

0 comments on commit 340fe0f

Please sign in to comment.