prof_spacetime icon indicating copy to clipboard operation
prof_spacetime copied to clipboard

Owee_buf.Invalid_format("No ELF magic number") on macOS

Open aantron opened this issue 8 years ago • 4 comments

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.

aantron avatar Dec 10 '16 17:12 aantron

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.

lpw25 avatar Dec 11 '16 08:12 lpw25

Thanks, this is sufficient for my purposes for the time being :)

aantron avatar Dec 11 '16 17:12 aantron

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.

lpw25 avatar Dec 12 '16 10:12 lpw25

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.

let-def avatar Dec 12 '16 16:12 let-def