New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix demangle #672

Merged
merged 4 commits into from Jul 5, 2017
Jump to file or symbol
Failed to load files and symbols.
+34 −17
Diff settings

Always

Just for now

Copy path View file
@@ -30,6 +30,7 @@ _oasis
/man/bap.1
/lib/bap_config/bap_config.ml
/lib/bap_llvm/bap_llvm_config.ml
/plugins/cxxfilt/cxxfilt_config.ml
/plugins/ida/bap_ida_config.ml
/plugins/objdump/objdump_config.ml
/plugins/api/api_config.ml
@@ -1,5 +1,11 @@
open Core_kernel.Std
let maybe_mangled name =
String.length name > 2 &&
name.[0] = '_' &&
Char.is_uppercase name.[1] &&
Char.is_alpha name.[1]
let demangle_internal str =
let open String in
let open Option.Monad_infix in
@@ -28,6 +34,14 @@ let demangle_internal str =
| "" -> str
| s -> s
let demangle_internal name =
let open Option in
some_if (maybe_mangled name) name >>= fun name ->

This comment has been minimized.

@ivg

ivg Jun 30, 2017

Member

👎

try_with (fun () -> demangle_internal name)
let run_internal name =
Option.value_map ~default:name ~f:ident (demangle_internal name)
module Std = struct
type demangler = {
name : string;
@@ -49,7 +63,7 @@ module Std = struct
let internal = {
name = "internal";
run = demangle_internal;
run = run_internal;
}
let () = Demanglers.register internal
Copy path View file
@@ -6,5 +6,5 @@ let () =
| Some xs -> xs);
add_variable ~doc:"A path to cxxfilt binary" "cxxfilt_path"
~define:(function
| None -> "cxxfilt"
| None -> "c++filt"
| Some x -> x)

This file was deleted.

Oops, something went wrong.
@@ -12,11 +12,9 @@ let apply demangler proj =
Sub.with_name sub (Demangler.run demangler (Sub.name sub))) |>
Project.with_program proj
let main = function
| None -> ()
| Some demangler ->
Project.register_pass ~autorun:true (apply demangler)
let find_demangler name =
Demanglers.available () |>
List.find ~f:(fun d -> Demangler.name d = name)
let () =
let () = Config.manpage [
@@ -25,12 +23,18 @@ let () =
`S "SEE ALSO";
`P "$(b,bap-plugin-cxxfilt)(1)"
] in
let demangler : demangler option Config.param =
let demanglers =
Demanglers.available () |>
List.map ~f:(fun d -> Demangler.name d, d) in
let doc = sprintf "Demangle all function names using $(docv),
that should be %s" @@ Config.doc_enum demanglers in
Config.(param (some (enum demanglers)) "with" ~docv:"DEMANGLER" ~doc) in
let demangler : string Config.param =
let doc = sprintf "Demangle all function names using $(docv)" in
Config.(param string) "with" ~docv:"DEMANGLER" ~doc in
Config.when_ready (fun {Config.get=(!)} ->
Future.upon Plugins.loaded (fun () -> main !demangler))
Future.upon Plugins.loaded (fun () ->
match find_demangler !demangler with
| Some d -> Project.register_pass ~autorun:true (apply d)
| None ->
let names =
Demanglers.available () |>
List.map ~f:Demangler.name |>
String.concat ~sep:", " in
eprintf "Didn't find demangler %s, should be one of: %s\n"

This comment has been minimized.

@ivg

ivg Jun 30, 2017

Member

use invalid_argf

!demangler names;
exit 1))
ProTip! Use n and p to navigate between commits in a pull request.