prof_spacetime
prof_spacetime copied to clipboard
Owee_buf.Invalid_format("No ELF magic number") on macOS
This may be a known issue, but I am unable to use prof_spacetime on macOS.
touch foo.ml # empty file
ocamlfind opt -linkpkg foo.ml
OCAML_SPACETIME_INTERVAL=100 ./a.out
prof_spacetime process -e a.out spacetime-*
results in
Processing series...prof-spacetime: internal error, uncaught exception:
Owee_buf.Invalid_format("No ELF magic number")
Raised at file "owee_buf.ml", line 12, characters 25-51
Called from file "owee_elf.ml", line 15, characters 4-40
Called from file "owee_elf.ml", line 136, characters 2-16
Called from file "elf_locations.ml", line 19, characters 26-47
Called from file "spacetime_lib.ml", line 727, characters 13-62
Called from file "bin/main.ml", line 45, characters 9-56
Called from file "src/cmdliner.ml", line 1350, characters 17-26
Called from file "src/cmdliner.ml", line 1390, characters 6-34
Presumably since a.out is not an ELF file. Not sure if this properly belongs to prof_spacetime, spacetime_lib, or owee.
I haven't looked at this issue properly yet, but it is worth noting that you can run prof_spacetime without the -e a.out. You won't get the symbol names or the locations of c function calls (which will just show as raw addresses) but you will still have the locations of the OCaml function calls.
Thanks, this is sufficient for my purposes for the time being :)
Ok, so apparently macOS uses Mach-o format rather than ELF, which is not supported by owee yet. However, rumour has it that @let-def has been working on adding this support recently.
Even with that support, some object formats are never going to get support, so we also need to give a proper error message rather than an exception.
I think Owee_macho is in a good enough state that we can try using it :). This is just a reader, it extracts the basic commands of Mach-O files. More work is needed to make sense of the values.