mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-13 11:36:37 +00:00
core/tracing: add CodeSection and functionDepth to traces
This commit is contained in:
parent
1bb727ba75
commit
a03d1cdc1c
3 changed files with 19 additions and 1 deletions
|
|
@ -43,6 +43,8 @@ type OpContext interface {
|
||||||
CallValue() *uint256.Int
|
CallValue() *uint256.Int
|
||||||
CallInput() []byte
|
CallInput() []byte
|
||||||
ContractCode() []byte
|
ContractCode() []byte
|
||||||
|
CurrentCodeSection() uint64
|
||||||
|
ReturnStackDepth() uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// StateDB gives tracers access to the whole state.
|
// StateDB gives tracers access to the whole state.
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,20 @@ func (ctx *ScopeContext) ContractCode() []byte {
|
||||||
return ctx.Contract.Code
|
return ctx.Contract.Code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CodeSection returns the current code section of the contract being executed.
|
||||||
|
func (ctx *ScopeContext) CurrentCodeSection() uint64 {
|
||||||
|
return ctx.CodeSection
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReturnStackDepth returns the depth of the return stack.
|
||||||
|
func (ctx *ScopeContext) ReturnStackDepth() uint64 {
|
||||||
|
if ctx.Contract.IsEOF() {
|
||||||
|
return uint64(ctx.ReturnStack.Len() + 1)
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type ReturnStack []*ReturnContext
|
type ReturnStack []*ReturnContext
|
||||||
|
|
||||||
// Pop removes an element from the return stack
|
// Pop removes an element from the return stack
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ type Config struct {
|
||||||
// current internal state prior to the execution of the statement.
|
// current internal state prior to the execution of the statement.
|
||||||
type StructLog struct {
|
type StructLog struct {
|
||||||
Pc uint64 `json:"pc"`
|
Pc uint64 `json:"pc"`
|
||||||
|
Section uint64 `json:"section,omitempty"`
|
||||||
Op vm.OpCode `json:"op"`
|
Op vm.OpCode `json:"op"`
|
||||||
Gas uint64 `json:"gas"`
|
Gas uint64 `json:"gas"`
|
||||||
GasCost uint64 `json:"gasCost"`
|
GasCost uint64 `json:"gasCost"`
|
||||||
|
|
@ -66,6 +67,7 @@ type StructLog struct {
|
||||||
ReturnData []byte `json:"returnData,omitempty"`
|
ReturnData []byte `json:"returnData,omitempty"`
|
||||||
Storage map[common.Hash]common.Hash `json:"-"`
|
Storage map[common.Hash]common.Hash `json:"-"`
|
||||||
Depth int `json:"depth"`
|
Depth int `json:"depth"`
|
||||||
|
FunctionDepth uint64 `json:"functionDepth,omitempty"`
|
||||||
RefundCounter uint64 `json:"refund"`
|
RefundCounter uint64 `json:"refund"`
|
||||||
Err error `json:"-"`
|
Err error `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
@ -274,7 +276,7 @@ func (l *StructLogger) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scope
|
||||||
stack = scope.StackData()
|
stack = scope.StackData()
|
||||||
stackLen = len(stack)
|
stackLen = len(stack)
|
||||||
)
|
)
|
||||||
log := StructLog{pc, op, gas, cost, nil, len(memory), nil, nil, nil, depth, l.env.StateDB.GetRefund(), err}
|
log := StructLog{pc, scope.CurrentCodeSection(), op, gas, cost, nil, len(memory), nil, nil, nil, depth, scope.ReturnStackDepth(), l.env.StateDB.GetRefund(), err}
|
||||||
if l.cfg.EnableMemory {
|
if l.cfg.EnableMemory {
|
||||||
log.Memory = memory
|
log.Memory = memory
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue