remix-debug readme

pull/713/head
aniket-engg 4 years ago committed by Aniket
parent c787dbd2b0
commit 9b749992a0
  1. 2
      libs/remix-analyzer/README.md
  2. 193
      libs/remix-debug/README.md

@ -5,7 +5,7 @@
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/ethereum/remix-project/tree/master/libs/remix-analyzer) [![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/ethereum/remix-project/tree/master/libs/remix-analyzer)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/ethereum/remix-project/issues) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/ethereum/remix-project/issues)
`@remix-project/remix-analyzer` is a tool to perform static analysis on Solidity smart contracts to check security vulnerabilities and bad development practices. It works underneath Remix IDE plugin "SOLIDITY STATIC ANALYSIS" which is used to run analysis for a compiled contract according to selected modules. `@remix-project/remix-analyzer` is a tool to perform static analysis on Solidity smart contracts to check security vulnerabilities and bad development practices. It works underneath Remix IDE "SOLIDITY STATIC ANALYSIS" plugin which is used to run analysis for a compiled contract according to selected modules.
### Installation ### Installation
`@remix-project/remix-analyzer` is an NPM package and can be installed using NPM as: `@remix-project/remix-analyzer` is an NPM package and can be installed using NPM as:

@ -1,20 +1,23 @@
# `remix-debug` ## Remix Debug`
[![npm version](https://badge.fury.io/js/%40remix-project%2Fremix-debug.svg)](https://www.npmjs.com/package/@remix-project/remix-debug)
[![npm](https://img.shields.io/npm/dt/@remix-project/remix-debug.svg?label=Total%20Downloads)](https://www.npmjs.com/package/@remix-project/remix-debug)
[![npm](https://img.shields.io/npm/dw/@remix-project/remix-debug.svg)](https://www.npmjs.com/package/@remix-project/remix-debug)
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/ethereum/remix-project/tree/master/libs/remix-debug)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/ethereum/remix-project/issues)
remix-debug wrap other remix-* libraries and can be used to debug Ethereum transactions. `@remix-project/remix-debug` is a tool to to debug Ethereum transactions on different Remix environments (VM, testnet etc.). It works underneath Remix IDE "DEBUGGER" plugin which is used to analyse step-to-step executioon of a transaction to debug it.
+ [Installation](#installation) ### Installation
+ [Development](#development) `@remix-project/remix-debug` is an NPM package and can be installed using NPM as:
## Installation `npm install @remix-project/remix-debug`
### How to use
```bash `@remix-project/remix-debug` can be used as:
npm install remix-debug
```
## Development ```ts
```javascript
var Debugger = require('remix-debug').EthDebugger var Debugger = require('remix-debug').EthDebugger
var BreakpointManager = require('remix-debug').BreakpointManager var BreakpointManager = require('remix-debug').BreakpointManager
@ -64,169 +67,85 @@ debugger.callTree.register('callTreeReady', () => {
}) })
``` ```
## Library It exports:
Provides:
```javascript ```javascript
{ {
code: { init,
CodeManager: CodeManager, traceHelper,
BreakpointManager: BreakpointManager sourceMappingDecoder,
}, EthDebugger,
storage: { TransactionDebugger,
StorageViewer: StorageViewer, BreakpointManager,
StorageResolver: StorageResolver SolidityDecoder,
}, storage: {
trace: { StorageViewer: StorageViewer,
TraceManager: TraceManager StorageResolver: StorageResolver
} },
CmdLine
} }
``` ```
TraceManager is a convenient way to access a VM Trace and resolve some value from it.
`TraceManager()` :
`function resolveTrace(stepIndex, tx)`
`function init(stepIndex, tx)`
`function inRange(stepIndex, tx)`
`function isLoaded(stepIndex, tx)`
`function getLength(stepIndex, tx)`
`function accumulateStorageChanges(stepIndex, tx)`
`function getAddresses(stepIndex, tx)`
`function getCallDataAt(stepIndex, tx)`
`function getCallStackAt(stepIndex, tx)`
`function getStackAt(stepIndex, tx)`
`function getLastCallChangeSince(stepIndex, tx)`
`function getCurrentCalledAddressAt(stepIndex, tx)`
`function getContractCreationCode(stepIndex, tx)`
`function getMemoryAt(stepIndex, tx)`
`function getCurrentPC(stepIndex, tx)` Some of the class details are as:
`function getReturnValue(stepIndex, tx)` - - - -
`function getCurrentStep(stepIndex, tx)`
`function getMemExpand(stepIndex, tx)`
`function getStepCost(stepIndex, tx)`
`function getRemainingGas(stepIndex, tx)`
`function getStepCost(stepIndex, tx)`
`function isCreationStep(stepIndex, tx)`
`function findStepOverBack(stepIndex, tx)`
`function findStepOverForward(stepIndex, tx)`
`function findStepOverBack(stepIndex, tx)`
`function findNextCall(stepIndex, tx)`
`function findStepOut(stepIndex, tx)`
`function checkRequestedStep(stepIndex, tx)`
`function waterfall(stepIndex, tx)` **BreakpointManager**
`constructor({ traceManager, callTree, solidityProxy, locationToRowConverter })` : create new instance
- - - - `jumpNextBreakpoint(defaultToLimit)` : start looking for the next breakpoint
`CodeManager(_traceManager)` : `jumpPreviousBreakpoint(defaultToLimit)` : start looking for the previous breakpoint
`function getCode(stepIndex, tx)` : `jump(direction, defaultToLimit)` : start looking for the previous or next breakpoint
Resolve the code of the given @arg stepIndex and trigger appropriate event
`function resolveStep(address, cb)` : `hasBreakpointAtLine((fileIndex, line)` : check the given pair fileIndex/line against registered breakpoints
Retrieve the code located at the given @arg address
`function getFunctionFromStep(stepIndex, sourceMap, ast)` : `hasBreakpoint()` : return true if current manager has breakpoint
Retrieve the called function for the current vm step
`function getInstructionIndex(address, step, callback)` : `add(sourceLocation)` : add a new breakpoint to the manager
Retrieve the instruction index of the given @arg step
`function getFunctionFromPC(address, pc, sourceMap, ast)` : `remove(sourceLocation)` : remove a breakpoint from the manager
Retrieve the called function for the given @arg pc and @arg address
- - - - - - - -
`BreakpointManager(_ethdebugger, _locationToRowConverter)` : **StorageViewer**
`function jumpNextBreakpoint(defaultToLimit)` : `constructor (_context, _storageResolver, _traceManager)` : create new instance
start looking for the next breakpoint
`function jumpPreviousBreakpoint(defaultToLimit)` : `storageRange(defaultToLimit)` : return the storage for the current context (address and vm trace index)
start looking for the previous breakpoint
`function jump(direction, defaultToLimit)` : `storageSlot(defaultToLimit)` : return a slot value for the current context (address and vm trace index)
start looking for the previous or next breakpoint
`function hasBreakpointAtLine((fileIndex, line)` : `isComplete(direction, defaultToLimit)` : return True if the storage at @arg address is complete
check the given pair fileIndex/line against registered breakpoints
`function hasBreakpoint()` : `initialMappingsLocation((fileIndex, line)` : return all the possible mappings locations for the current context (cached) do not return state changes during the current transaction
return true if current manager has breakpoint
`function add(sourceLocation)` : `mappingsLocation()` : return all the possible mappings locations for the current context (cached) and current mapping slot. returns state changes during the current transaction
add a new breakpoint to the manager
`function remove(sourceLocation)` : `extractMappingsLocationChanges(sourceLocation)` : retrieve mapping location changes from the storage changes.
remove a breakpoint from the manager
- - - - - - - -
`StorageViewer(_context, _storageResolver, _traceManager)` : **StorageResolver**
`function storageRange(defaultToLimit)` : `constructor (options)` : create new instance
return the storage for the current context (address and vm trace index)
`function storageSlot(defaultToLimit)` : `storageRange(tx, stepIndex, address, callback)` : return the storage for the current context (address and vm trace index)
return a slot value for the current context (address and vm trace index)
`function isComplete(direction, defaultToLimit)` : `initialPreimagesMappings(tx, stepIndex, address, callback)` : return a slot value for the current context (address and vm trace index)
return True if the storage at @arg address is complete
`function initialMappingsLocation((fileIndex, line)` : `storageSlot(slot, tx, stepIndex, address, callback)` : return True if the storage at @arg address is complete
return all the possible mappings locations for the current context (cached) do not return state changes during the current transaction
`function mappingsLocation()` :
return all the possible mappings locations for the current context (cached) and current mapping slot. returns state changes during the current transaction
`function extractMappingsLocationChanges(sourceLocation)` :
retrieve mapping location changes from the storage changes.
- - - -
`StorageResolver()` : `isComplete(address)` : return all the possible mappings locations for the current context (cached) do not return state changes during the current transaction
`function storageRange(tx, stepIndex, address, callback)` : ### Contribute
return the storage for the current context (address and vm trace index)
`function initialPreimagesMappings(tx, stepIndex, address, callback)` : Please feel free to open an issue or a pull request.
return a slot value for the current context (address and vm trace index)
`function storageSlot(slot, tx, stepIndex, address, callback)` : In case you want to add some code, do have a look to our contribution guidelnes [here](https://github.com/ethereum/remix-project/blob/master/CONTRIBUTING.md). Reach us on [Gitter](https://gitter.im/ethereum/remix) in case of any queries.
return True if the storage at @arg address is complete
`function isComplete(address)` : ### License
return all the possible mappings locations for the current context (cached) do not return state changes during the current transaction MIT © 2018-21 Remix Team

Loading…
Cancel
Save