Skip to content

Commit

Permalink
polymorphic variant & pipe operator fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Phosphorus15 committed Jun 25, 2020
1 parent d6da1b9 commit 495c7a6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions plugins/radare2/radare2_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ let provide_roots funcs =

let extract_name (json : Yojson.t) =
match json with
| Yojson.(`Assoc list) ->
| `Assoc list ->
(match List.find list ~f:(fun (key, _) -> String.equal key "name") with
| Some (_, v) -> (match v with
| Yojson.(`String str) -> Some str
| `String str -> Some str
| _ -> None)
| _ -> None)
| _ -> None

let extract_addr (json : Yojson.t) =
match json with
| Yojson.(`Assoc list) ->
| `Assoc list ->
(match List.find list ~f:(fun (key, _) -> String.equal key "vaddr") with
| Some (_, v) -> (match v with
| Yojson.(`Int i) -> Z.of_int i |> Some
| Yojson.(`Intlit s) -> Z.of_string s |> Some
| `Int i -> Some (Z.of_int i)
| `Intlit s -> Some (Z.of_string s)
| _ -> None)
| _ -> None)
| _ -> None
Expand All @@ -55,12 +55,13 @@ let provide_radare2 file =
end) in
let accept name addr = Hashtbl.set funcs addr name in
let symbol_list = match R2.with_command_j "isj" file with
| Yojson.(`List list) -> Some list
| `List list -> Some list
| s -> warning "unexpected radare2 output: %a" Yojson.pp s; None
| exception _ -> warning "failed to get symbols - radare2 command failed"; None in
Option.iter symbol_list ~f:(List.iter ~f:(fun s -> match extract_name s, extract_addr s with
| Some name, Some addr -> accept (strip name) addr
| _ -> debug "skipping json item %a" Yojson.pp s));
Option.iter symbol_list
~f:(List.iter ~f:(fun s -> match extract_name s, extract_addr s with
| Some name, Some addr -> accept (strip name) addr
| _ -> debug "skipping json item %a" Yojson.pp s));
if Hashtbl.length funcs = 0
then warning "failed to obtain symbols";
let symbolizer = Symbolizer.create @@ fun addr ->
Expand Down

0 comments on commit 495c7a6

Please sign in to comment.