|
|
|
# `remix-debug`
|
|
|
|
|
|
|
|
remix-debug wrap other remix-* libraries and can be used to debug Ethereum transactions.
|
|
|
|
|
|
|
|
+ [Installation](#installation)
|
|
|
|
+ [Development](#development)
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
npm install remix-debug
|
|
|
|
```
|
|
|
|
|
|
|
|
## Development
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
var Debugger = require('remix-debug').EthDebugger
|
|
|
|
var BreakpointManager = require('remix-debug').EthDebugger
|
|
|
|
|
|
|
|
var debugger = new Debugger({
|
|
|
|
compilationResult: () => {
|
|
|
|
return compilationResult // that helps resolving source location
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
debugger.addProvider(web3, 'web3')
|
|
|
|
debugger.switchProvider('web3')
|
|
|
|
|
|
|
|
var breakPointManager = new remixCore.code.BreakpointManager(this.debugger, (sourceLocation) => {
|
|
|
|
// return offsetToLineColumn
|
|
|
|
})
|
|
|
|
debugger.setBreakpointManager(breakPointManager)
|
|
|
|
breakPointManager.add({fileName, row})
|
|
|
|
breakPointManager.add({fileName, row})
|
|
|
|
|
|
|
|
debugger.debug(<tx_hash>)
|
|
|
|
|
|
|
|
// this.traceManager.getCurrentCalledAddressAt
|
|
|
|
|
|
|
|
debugger.event.register('newTraceLoaded', () => {
|
|
|
|
// start doing basic stuff like retrieving step details
|
|
|
|
debugger.traceManager.getCallStackAt(34, (error, callstack) => {})
|
|
|
|
})
|
|
|
|
|
|
|
|
debugger.callTree.register('callTreeReady', () => {
|
|
|
|
// start doing more complex stuff like resolvng local variables
|
|
|
|
breakPointManager.jumpNextBreakpoint(true)
|
|
|
|
|
|
|
|
var storageView = debugger.storageViewAt(38, <contract address>,
|
|
|
|
storageView.storageSlot(0, (error, storage) => {})
|
|
|
|
storageView.storageRange(error, storage) => {}) // retrieve 0 => 1000 slots
|
|
|
|
|
|
|
|
debugger.extractStateAt(23, (error, state) => {
|
|
|
|
debugger.decodeStateAt(23, state, (error, decodedState) => {})
|
|
|
|
})
|
|
|
|
|
|
|
|
debugger.sourceLocationFromVMTraceIndex(<contract address>, 23, (error, location) => {
|
|
|
|
debugger.decodeLocalsAt(23, location, (error, decodedlocals) => {})
|
|
|
|
})
|
|
|
|
|
|
|
|
debugger.extractLocalsAt(23, (null, locals) => {})
|
|
|
|
|
|
|
|
})
|
|
|
|
```
|