Skip to content

Commit 6c4b977

Browse files
committed
Merge pull request #2 from feseal/bap-trace-plugin-compilation-fix
Trace plugin compilation errors fix
2 parents ce586ba + 8419002 commit 6c4b977

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

plugin/frame_events.ml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ end = struct
5656
| `r64 -> Bitvector.of_int64 ~width:64 address
5757

5858
let move arch tag cell width value =
59-
let endian =
60-
Option.value_map arch ~default:Bitvector.LittleEndian ~f:Arch.endian in
61-
Value.create tag Trace.Move.{
62-
cell;
63-
data = let width = match width with 0 -> None | w -> Some w in
64-
Bitvector.(of_binary ?width endian value)}
59+
let data =
60+
let endian =
61+
Option.value_map arch ~default:Bitvector.LittleEndian ~f:Arch.endian in
62+
let width = match width with 0 -> None | w -> Some w in
63+
Bitvector.of_binary ?width endian value in
64+
Trace.Move.Fields.create ~cell ~data |>
65+
Value.create tag
6566

6667
let memory_operation arch tag mo width value =
6768
move arch tag (addr_of_address arch mo.Frame.Mem_operand.address)
@@ -87,33 +88,31 @@ end = struct
8788
Value.create pc_update (addr_of_address arch address)
8889

8990
let code_exec arch address data =
90-
Value.create code_exec Trace.Chunk.{
91-
addr = addr_of_address arch address;
92-
data
93-
}
91+
Trace.Chunk.Fields.create ~addr:(addr_of_address arch address) ~data |>
92+
Value.create code_exec
9493

9594
let context_switch id =
9695
Value.create context_switch @@ Int64.to_int_exn id
9796

9897
let syscall ~number args =
99-
Value.create syscall Trace.Syscall.{
100-
number = Int64.to_int_exn number;
101-
args = Array.of_list @@ List.map ~f:Bitvector.of_int64 args
102-
}
98+
Trace.Syscall.Fields.create
99+
~number:(Int64.to_int_exn number)
100+
~args:(Array.of_list @@ List.map ~f:Bitvector.of_int64 args) |>
101+
Value.create syscall
103102

104103
let exn arch number ~from_addr ~to_addr =
105-
Value.create exn Trace.Exn.{
106-
number = Int64.to_int_exn number;
107-
src = Option.map from_addr ~f:(addr_of_address arch);
108-
dst = Option.map to_addr ~f:(addr_of_address arch)
109-
}
104+
Trace.Exn.Fields.create
105+
~number:(Int64.to_int_exn number)
106+
~src:(Option.map from_addr ~f:(addr_of_address arch))
107+
~dst:(Option.map to_addr ~f:(addr_of_address arch)) |>
108+
Value.create exn
110109

111110
let modload arch name low high =
112-
Value.create modload Trace.Modload.{
113-
name;
114-
low = addr_of_address arch low;
115-
high = addr_of_address arch high;
116-
}
111+
Trace.Modload.Fields.create
112+
~name
113+
~low:(addr_of_address arch low)
114+
~high:(addr_of_address arch high) |>
115+
Value.create modload
117116
end
118117

119118
let of_new_frame context arch address thread_id =

test/fetchlibs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ cd libs
5858

5959
LIBS="libc-bin libstdc++6 libcap2"
6060
fetcharch armel ubuntu precise
61+
fetcharch i386 precise
6162
# mini debootstrap
6263

test/tracedump.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ let print_error = function
2121
| `System_error err -> prerr_string @@ Unix.error_message err
2222
| `No_provider -> prerr_string "No provider for a given URI"
2323
| `Ambiguous_uri -> prerr_string "More than one provider for a given URI"
24+
2425

2526
let main uri =
2627
Trace.load uri >>|
28+
(fun trace ->
29+
Trace.meta trace |>
30+
Dict.data |>
31+
Sequence.iter ~f:(Format.printf "meta: @[%a@]@." Value.pp);
32+
trace) >>|
2733
Trace.events >>|
2834
Sequence.iter ~f:(Format.printf "@[%a@]@." Value.pp)
2935

0 commit comments

Comments
 (0)