elf_arrows/src/test_objdump.ml

35 lines
1,023 B
OCaml

let uncaught_exn exc backtrace =
let descr = (match exc with
| Failure msg -> Format.sprintf " (%s)" msg
| _ -> ""
) in
Format.eprintf "Uncaught exception %s%s. Backtrace:@.%s@."
(Printexc.exn_slot_name exc)
descr
(Printexc.raw_backtrace_to_string backtrace) ;
exit 1
let read_all handle =
let len = in_channel_length handle in
let buffer = Bytes.create len in
let bytes_read = input handle buffer 0 len in
if bytes_read <> len then
raise (Failure "Could not read whole file")
else
Bytes.to_string buffer
let _ =
Printexc.record_backtrace true ;
Printexc.set_uncaught_exception_handler uncaught_exn ;
let in_path = "/tmp/objdump_dump" in
let in_handle = open_in in_path in
let objdump_out = read_all in_handle in
close_in in_handle ;
let parsed = Asm_acquire.interpret_objdump objdump_out in
Format.eprintf "%a" Asm_acquire.pp_asm_info parsed
(*
List.iter (fun asm_sub ->
Format.eprintf "%a" Asm_acquire.pp_asm_sub asm_sub)
parsed
*)