Comments (4)
Honestly, I am surprised that it generated any output at all. Usually, one would only feed in a few methods at a time, not disassemble the entire program graphically. Also, there are many dot file engines with different parametrizations and getting such big inputs to be even somewhat readable is always an exercise in tuning.
Anyway, you tried it, so I guess there is a use-case beyond curiosity for you. Maybe you can go a bit deeper into what you want to achieve? Then we might be able to find a workable solution or plan future features accordingly.
from rbpf.
how I did it
the graph above was generated using following command
rbpf-cli --use cfg target/deploy/as_simple_as_it_gets.so
how would you do it?
based on the bpfi-cli usage how would you feed in only a few methods?
Maybe you could generate an asm file and manually modify it to extract a subset of the solana program.
But based on the documentation that isn't clear.
USAGE:
rbpf-cli [OPTIONS] <PROGRAM>
ARGS:
<PROGRAM> Program file to use. This is either an ELF shared-object file to be executed,
or an assembly file to be assembled and executed.
OPTIONS:
-h, --help Print help information
-i, --input <FILE / BYTES> Input for the program to run on, where FILE is a name of a JSON
file with input data, or BYTES is the number of 0-valued bytes to
allocate for program parameters [default: 0]
-l, --limit <COUNT> Limit the number of instructions to execute [default:
9223372036854775807]
-m, --memory <BYTES> Heap memory for the program to run on [default: 0]
-p, --profile Output profile to 'profile.dot' file using tracing instrumentation
-t, --trace Output trace to 'trace.out' file using tracing instrumentation
-u, --use <VALUE> Method of execution to use, where 'cfg' generates Control Flow
Graph of the program, 'disassembler' dumps disassembled code of
the program, 'interpreter' runs the program in the virtual
machine's interpreter, and 'jit' precompiles the program to native
machine code before execting it in the virtual machine. [default:
jit] [possible values: cfg, disassembler, interpreter, jit]
-v, --verify Run the verifier before execution or disassembly
-V, --version Print version information
use-case
Have a look at https://go.dev/blog/pprof.
While that example can't be translated 1:1 to solana programs, the goal is usually to visualise control flow and
identify issues in your program that you wouldn't find by just thinking about it or adding fprintf() statements to the code.
I am not sure to what extend rbpf emulates the operation that occurs within the runtime in a solana cluster, but since the solana runtime has a uniq set of rules, optimisation and debugging of solana programs will benefit from a good profiler.
from rbpf.
I am not sure to what extend rbpf emulates the operation that occurs within the runtime in a solana cluster
This crate (RBPF) does not emulate the solana program runtime, it is what the solana program runtime depends on.
However, the rbpf-cli here is a standalone tool for development purposes. There is another one here which is similar but a bit better integrated into the program runtime and e.g. allows for account inputs to be specified.
optimization and debugging of solana programs will benefit from a good profiler.
Yes, we are definitely lacking good tooling on this end. Currently there is no way to restrict the DOT output to specific functions or to only show the profiling at function level (not at instruction level). What you can do right now is manually either cut parts from the input binary file, or the output dot file.
Do you just need any kind of profile (would a textual trace suffice?) or do you specifically want to see the heat / color coded CFG visually?
from rbpf.
I am using https://github.com/solana-labs/solana/tree/master/rbpf-cli but if you look at https://github.com/solana-labs/solana/blob/3c5f505d3e3ded8b3110b44bc458d01701b93e4d/rbpf-cli/Cargo.toml#L19 you see it pulls this repo as a dependency, therefor I opened the issue here.
I think what I am really looking for would be:
- something that starts in entrypoint and traces functions called from there, seeing every unwrap and match is just overkill.
- lamports used during bpf execution
- rent fee for data in lamports per byte-epoch
from rbpf.
Related Issues (20)
- The new ELF parser should use checked instead of saturating arithmetic
- elf: retrieve all dynamic metadata from the `.dynamic` table instead of requiring section headers
- JitCompiler::new() uses unwrap()
- Read only sections can overlap with the stack
- eBPF Standardization HOT 2
- Call target labels are not resolved in v0.2.38 HOT 4
- 32bit target support HOT 2
- ExceededMaxInstructions error message is confusing HOT 1
- Only require winapi on Windows
- git clone and cargo build gives error HOT 3
- elf_parser fails loading a valid ELF file HOT 8
- Call instruction transfers control to incorrect address HOT 4
- RBPF is killed by the OS while running a program HOT 2
- make btf instruction class an enum
- Attempt to negate with overflow in disassembler
- Warnings when compiling on macOS Arm
- Removing check SHIFT immediate number from verifier HOT 2
- assembler: register inconsistency HOT 3
- Interpreter LD_DW_IMM: add `!sbpf_version.disable_lddw()` checking
- type casting of rbpf HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rbpf.