copy / gdbprofiler Goto Github PK
View Code? Open in Web Editor NEW(deprecated) Rich man's profiler, a profiler for native OCaml and other executables
(deprecated) Rich man's profiler, a profiler for native OCaml and other executables
lldb also supports the mi interface, so it should be possible to use it as a debugger backend too. The implementation seems to be slightly different though, so it doesn't work out of the box.
The following stacktrace is present now:
Fatal error: exception End_of_file
Raised at file "src/gdb.ml", line 58, characters 4-576
Re-raised at file "src/gdb.ml", line 97, characters 2-122
Re-raised at file "cli/gdbprofiler.ml", line 100, characters 2-1023
Re-raised at file "src/core/lwt.ml", line 3008, characters 20-29
Called from file "src/unix/lwt_main.ml", line 42, characters 8-18
Called from file "cli/gdbprofiler.ml", line 207, characters 6-84
Anyone familiar with Arg
got an idea why this is happening?
% ./rmp.native -p
./rmp.native: option '-p' needs an argument.
Usage: rmp -p <pid> [--use-lldb] [--debugger path] [--cpuprofile path] [--callgrind path]
-p : process id (pid)
--cpuprofile : Write out cpuprofile file to the given path (can be opened with Chromium)
--callgrind : Write out callgrind file to the given path (can be opened with kcachegrind)
--use-lldb : pass this to use lldb instead of gdb
--debugger : the debugger to invoke. Defaults to 'lldb-mi' if --use-lldb is passed and 'gdb' otherwise
-help Display this list of options
--help Display this list of options
./rmp.native: ./rmp.native: option '-p' needs an argument.
Usage: rmp -p <pid> [--use-lldb] [--debugger path] [--cpuprofile path] [--callgrind path]
-p : process id (pid)
--cpuprofile : Write out cpuprofile file to the given path (can be opened with Chromium)
--callgrind : Write out callgrind file to the given path (can be opened with kcachegrind)
--use-lldb : pass this to use lldb instead of gdb
--debugger : the debugger to invoke. Defaults to 'lldb-mi' if --use-lldb is passed and 'gdb' otherwise
-help Display this list of options
--help Display this list of options
.
Usage: rmp -p <pid> [--use-lldb] [--debugger path] [--cpuprofile path] [--callgrind path]
-p : process id (pid)
--cpuprofile : Write out cpuprofile file to the given path (can be opened with Chromium)
--callgrind : Write out callgrind file to the given path (can be opened with kcachegrind)
--use-lldb : pass this to use lldb instead of gdb
--debugger : the debugger to invoke. Defaults to 'lldb-mi' if --use-lldb is passed and 'gdb' otherwise
-help Display this list of options
--help Display this list of options
I'm running gdbprofiler with OCaml 5.1.1 on Ubuntu 24.04.
gdbprofiler does not seem to produce a .cpuprofile file that is compatible with current tools. For example, I used it to profile the attached file hello.ml. It produced the attached file out.cpuprofile. I'm not able to open this file in the Visual Studio Code cpuprofile view, or in Chromium's developer tools, or in an online cpuprofile viewer (https://lahmatiy.github.io/cpupro/).
The readme mentions that OCaml is supported up to 4.06. Is there a reason why this project can't be made to work on later versions?
I get this result when running measure.ml
to completion:
ocamlfind opt -g -linkpkg -package unix -package markup measure.ml && ./a.out React-1774 & sleep 1 && rmp -p `pidof a.out` --cpuprofile react.cpuprofile
[1] 20180
Press enter to stop
cpu: 126.0 ms
wall: 128.1 ms
[1] + 20180 done ./a.out React-1774
Fatal error: exception Failure("stack-list-frames error result: (Gdbmi_types.OpError (\"No registers.\", None))")
Raised at file "src/core/lwt.ml", line 805, characters 16-23
Called from file "src/unix/lwt_main.ml", line 34, characters 8-18
Called from file "cli/rmp.ml", line 158, characters 4-61
This is on an OS X system using GNU gdb 7.9.1 from MacPorts. I am sure that this is using MacPorts gdb because I had to patch Gdb.launch
to start ggdb
instead of trying gdb
, which could be its own issue.
If I "press enter," I get this instead:
Fatal error: exception Failure("Empty records")
May look into this in a few days. Would be nice to get rmp
running :)
Cool!
I wonder, might it be possible to support https://kcachegrind.github.io/ at some point?
It is not really an issue but I want to share if people are wondering whether this tool works on other platforms other than real linux.
I test it under OCaml 4.14.0.
For ubuntu 20.04 on windows wsl2, just follow the instructions in Readme.md
.
For macOS 12, I build lldb-mi
from the source. I follow the instructions in section Building against custom LLDB with llvm installed from homebrew:
cmake . -DLLVM_DIR=/usr/local/opt/llvm/lib/cmake/llvm
cmake --build .
Then I change the command a bit:
gdbprofiler -p `pgrep my_example_program.native` --cpuprofile example.cpuprofile --callgrind callgrind.out --use-lldb
I don't figure out how to use gdb
mode on mac.
I installed gdb
from homebrew and followed the certificate signing suggested in the brew installation log. After doing the manual steps, I can enter the normal gdb
.
However, when running gdbprofiler
, my program always exits immediately. I guess there may be some interrupt.
(since mac+llvm works, I don't delve into it)
F12 - Performance - Load profile : loads the file but nothing shown.
https://stackoverflow.com/a/41291519 hints that json format might have changed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.