Skip to content

Commit 3abc886

Browse files
authored
Merge pull request #174 from sipma/summaries
Summaries
2 parents 34c7332 + 66ed2e2 commit 3abc886

File tree

110 files changed

+10168
-5345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+10168
-5345
lines changed

.github/workflows/dune.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Prepare tar file for upload
3232
run: tar -hcvf artifacts.tar CodeHawk/_build/install/default/bin/*
3333
- name: Upload artifacts tar file
34-
uses: actions/upload-artifact@v3
34+
uses: actions/upload-artifact@v4
3535
with:
3636
name: artifacts-${{ matrix.ocaml-compiler }}
3737
path: artifacts.tar
@@ -54,7 +54,7 @@ jobs:
5454
- name: Delete submitted prebuilts
5555
run: rm -f chb/bin/binaries/linux/chx86_analyze
5656
- name: Download artifacts tar
57-
uses: actions/download-artifact@v3
57+
uses: actions/download-artifact@v4
5858
with:
5959
name: artifacts-${{ matrix.ocaml-compiler }}
6060
- name: Extract artifacts
@@ -84,7 +84,7 @@ jobs:
8484
rm -f chc/bin/linux/parseFile
8585
rm -f chc/bin/linux/canalyzer
8686
- name: Download artifacts tar
87-
uses: actions/download-artifact@v3
87+
uses: actions/download-artifact@v4
8888
with:
8989
name: artifacts-${{ matrix.ocaml-compiler }}
9090
- name: Extract artifacts

.github/workflows/makefiles.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Prepare tar file for upload
2525
run: tar -cvf artifacts.tar CodeHawk/CHB/bchcmdline/chx86_analyze CodeHawk/CHC/cchcil/parseFile CodeHawk/CHC/cchcmdline/canalyzer
2626
- name: Upload artifacts tar file
27-
uses: actions/upload-artifact@v3
27+
uses: actions/upload-artifact@v4
2828
with:
2929
name: artifacts-${{ matrix.ocaml-compiler }}
3030
path: artifacts.tar
@@ -45,7 +45,7 @@ jobs:
4545
- name: Delete submitted prebuilts
4646
run: rm -f chb/bin/binaries/linux/chx86_analyze
4747
- name: Download artifacts tar
48-
uses: actions/download-artifact@v3
48+
uses: actions/download-artifact@v4
4949
with:
5050
name: artifacts-${{ matrix.ocaml-compiler }}
5151
- name: Extract artifacts
@@ -73,7 +73,7 @@ jobs:
7373
rm -f chc/bin/linux/parseFile
7474
rm -f chc/bin/linux/canalyzer
7575
- name: Download artifacts tar
76-
uses: actions/download-artifact@v3
76+
uses: actions/download-artifact@v4
7777
with:
7878
name: artifacts-${{ matrix.ocaml-compiler }}
7979
- name: Extract artifacts

CodeHawk/CH/chutil/cHLogger.ml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Copyright (c) 2005-2019 Kestrel Technology LLC
88
Copyright (c) 2020 Henny B. Sipma
9-
Copyright (c) 2021-2024 Aarno Labs LLC
9+
Copyright (c) 2021-2025 Aarno Labs LLC
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal
@@ -226,3 +226,29 @@ let log_tfold_default
226226
log_tracelog_error logspec e;
227227
d
228228
end
229+
230+
231+
let log_error_result
232+
?(msg="")
233+
?(tag="")
234+
(filename: string)
235+
(linenumber: int)
236+
(error: string list) =
237+
let tag = if tag = "" then tag else tag ^ ":" in
238+
let msg = if msg = "" then msg else msg ^ ": " in
239+
ch_error_log#add
240+
(tag ^ filename ^ ":" ^ (string_of_int linenumber))
241+
(LBLOCK [STR msg; STR (String.concat "; " error)])
242+
243+
244+
let log_result
245+
?(msg="")
246+
?(tag="")
247+
(filename: string)
248+
(linenumber: int)
249+
(error: string list) =
250+
let tag = if tag = "" then tag else tag ^ ":" in
251+
let msg = if msg = "" then msg else msg ^ ":" in
252+
chlog#add
253+
(tag ^ filename ^ ":" ^ (string_of_int linenumber))
254+
(LBLOCK [STR msg; STR (String.concat "; " error)])

CodeHawk/CH/chutil/cHLogger.mli

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Copyright (c) 2005-2019 Kestrel Technology LLC
88
Copyright (c) 2020-2021 Henny B. Sipma
9-
Copyright (c) 2022-2024 Aarno Labs LLC
9+
Copyright (c) 2022-2025 Aarno Labs LLC
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal
@@ -112,3 +112,19 @@ val log_tfold:
112112
[e] is logged according [tls].*)
113113
val log_tfold_default:
114114
tracelogspec_t -> ('a -> 'c) -> 'c -> 'a traceresult -> 'c
115+
116+
117+
(** [log_error_result msg tag filename linenumber error] writes an entry to
118+
[ch_error_log] with a tag that combines [tag], [filename], and [linenumber].
119+
The entry is the concatenation of [msg] and the list of error messages
120+
making up [error].*)
121+
val log_error_result:
122+
?msg:string -> ?tag:string -> string -> int -> string list -> unit
123+
124+
125+
(** [log_result msg tag filename linenumber error] writes an entry to
126+
[chlog] with a tag that combines [tag], [filename], and [linenumber].
127+
The entry is the concatenation of [msg] and the list of error messages
128+
making up [error].*)
129+
val log_result:
130+
?msg:string -> ?tag:string -> string -> int -> string list -> unit

CodeHawk/CH/chutil/cHTraceResult.ml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
------------------------------------------------------------------------------
55
The MIT License (MIT)
66
7-
Copyright (c) 2023-2024 Aarno Labs LLC
7+
Copyright (c) 2023-2025 Aarno Labs LLC
88
99
Permission is hereby granted, free of charge, to any person obtaining a copy
1010
of this software and associated documentation files (the "Software"), to deal
@@ -61,6 +61,25 @@ let tmap2
6161
| Error e1, Error e2 -> Error (msg1 :: msg2 :: (e1 @ e2))
6262

6363

64+
let tmap3
65+
?(msg1="")
66+
?(msg2="")
67+
?(msg3="")
68+
(f: 'a -> 'b -> 'c -> 'd)
69+
(r1: 'a traceresult)
70+
(r2: 'b traceresult)
71+
(r3: 'c traceresult): 'd traceresult =
72+
match r1, r2, r3 with
73+
| Ok v1, Ok v2, Ok v3 -> Ok (f v1 v2 v3)
74+
| Error e1, Ok _, Ok _ -> Error (msg1 :: e1)
75+
| Ok _, Error e2, Ok _ -> Error (msg2 :: e2)
76+
| Ok _, Ok _, Error e3 -> Error (msg3 :: e3)
77+
| Error e1, Error e2, Ok _ -> Error (msg1 :: msg2 :: (e1 @ e2))
78+
| Error e1, Ok _, Error e3 -> Error (msg1 :: msg3 :: (e1 @ e3))
79+
| Ok _, Error e2, Error e3 -> Error (msg2 :: msg3 :: (e2 @ e3))
80+
| Error e1, Error e2, Error e3 -> Error (msg1 :: msg2 :: msg3 :: (e1 @ e2 @ e3))
81+
82+
6483
let tbind ?(msg="") (f: 'a -> 'c traceresult) (r: 'a traceresult) =
6584
match r with
6685
| Ok v -> f v
@@ -86,7 +105,13 @@ let tprop (r: 'a traceresult) (msg: string): 'a traceresult =
86105
| Error e -> Error (msg :: e)
87106

88107

89-
let titer (f: 'a -> unit) (r: 'a traceresult) =
108+
let titer ~(ok:'a -> unit) ~(error: string list -> unit) (r: 'a traceresult) =
109+
match r with
110+
| Ok v -> ok v
111+
| Error e -> error e
112+
113+
114+
let titer_default (f: 'a -> unit) (r: 'a traceresult) =
90115
match r with
91116
| Ok v -> f v
92117
| Error _ -> ()

CodeHawk/CH/chutil/cHTraceResult.mli

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ val tmap2:
6565
-> 'c traceresult
6666

6767

68+
(** [tmap3 f r1 r2 r3] is [Ok (f v1 v2 v3)] if [r1] is [Ok v1] and [r2] is
69+
[Ok v2] and [r3] is [Ok v3]; otherwise it returns an [Error] appending
70+
the messages corresponding to the error value as appropriate.*)
71+
val tmap3:
72+
?msg1:string
73+
-> ?msg2:string
74+
-> ?msg3:string
75+
-> ('a -> 'b -> 'c -> 'd)
76+
-> 'a traceresult
77+
-> 'b traceresult
78+
-> 'c traceresult
79+
-> 'd traceresult
80+
81+
6882
(** [tfold ~ok ~error r] is [ok v] if [r] is [Ok v] and [error e] if [r] is
6983
[Error e].*)
7084
val tfold: ok:('a -> 'c) -> error:(string list -> 'c) -> 'a traceresult -> 'c
@@ -86,8 +100,13 @@ val tbind:
86100
?msg:string -> ('a -> 'c traceresult) -> ('a traceresult) -> 'c traceresult
87101

88102

89-
(** [titer f r] is [f v] if [r] is [Ok v] and [()] otherwise.*)
90-
val titer: ('a -> unit) -> ('a traceresult) -> unit
103+
(** [titer ~ok ~error r] is [ok v] if [r] is [Ok v] and [error e] if [r] is
104+
[Error e].*)
105+
val titer: ok:('a -> unit) -> error:(string list -> unit) -> ('a traceresult) -> unit
106+
107+
108+
(** [titer_default f r] is [f v] if [r] is [Ok v] and [()] otherwise.*)
109+
val titer_default: ('a -> unit) -> 'a traceresult -> unit
91110

92111

93112
(** [tfold_list ~ok init rl] folds [Ok] values left to right, starting from

CodeHawk/CHB/bchanalyze/bCHFileIO.ml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,19 @@ let save_global_state () =
200200
file_output#saveFile filename doc#toPretty
201201
end
202202

203+
204+
let save_global_memory_map () =
205+
let filename = get_global_memory_map_filename () in
206+
let doc = xmlDocument () in
207+
let root = get_bch_root "global-locations" in
208+
let gNode = xmlElement "global-locations" in
209+
begin
210+
BCHGlobalMemoryMap.global_memory_map#write_xml gNode;
211+
doc#setNode root;
212+
root#appendChildren [gNode];
213+
file_output#saveFile filename doc#toPretty
214+
end
215+
203216
let save_system_info () =
204217
let filename = get_system_info_filename () in
205218
let doc = xmlDocument () in

CodeHawk/CHB/bchanalyze/bCHFileIO.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ val save_functions_list: unit -> unit
4343
val save_arm_functions_list: unit -> unit
4444

4545
val save_global_state: unit -> unit
46+
val save_global_memory_map: unit -> unit
4647
val save_system_info: unit -> unit
4748
val save_resultmetrics: xml_element_int -> unit
4849
val save_disassembly_status: unit -> unit

CodeHawk/CHB/bchanalyze/bCHTrace.ml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Copyright (c) 2005-2020 Kestrel Technology LLC
88
Copyright (c) 2020 Henny Sipma
9-
Copyright (c) 2021-2024 Aarno Labs LLC
9+
Copyright (c) 2021-2025 Aarno Labs LLC
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal
@@ -76,10 +76,13 @@ let se_address_is_referenced
7676
if floc#is_address x then
7777
let (memref,memoffset) = floc#decompose_address x in
7878
if is_constant_offset memoffset then
79-
let memv =
80-
finfo#env#mk_memory_variable memref (get_total_constant_offset memoffset) in
81-
let memx = floc#rewrite_variable_to_external memv in
82-
var_is_referenced finfo memx v
79+
TR.tfold_default
80+
(fun offset ->
81+
let memv = finfo#env#mk_memory_variable memref offset in
82+
let memx = floc#rewrite_variable_to_external memv in
83+
var_is_referenced finfo memx v)
84+
false
85+
(get_total_constant_offset memoffset)
8386
else
8487
false
8588
else

CodeHawk/CHB/bchcil/bCHParseCilFile.ml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,25 @@ open CHLogger
3838
(* bchlib *)
3939
open BCHBCFiles
4040
open BCHBCTypes
41-
open BCHBCTypePretty
4241
open BCHBCTypeUtil
4342
open BCHCilToCBasic
44-
open BCHConstantDefinitions
4543

4644

4745
let update_symbolic_address_types () =
48-
let globalvarnames = get_untyped_symbolic_address_names () in
49-
begin
50-
List.iter (fun name ->
51-
if bcfiles#has_varinfo name then
52-
let vinfo = bcfiles#get_varinfo name in
53-
begin
54-
update_symbolic_address_btype name vinfo.bvtype;
55-
chlog#add
56-
"symbolic address: update with vinfo"
57-
(LBLOCK [STR name; STR ": "; STR (btype_to_string vinfo.bvtype)])
58-
end
59-
else
60-
chlog#add "symbolic address: no update" (STR name)) globalvarnames;
61-
chlog#add
62-
"symbolic address updates"
63-
(LBLOCK [STR "Names: "; STR (String.concat ", " globalvarnames)])
64-
end
46+
let gfunnames = bcfiles#get_gfun_names in
47+
let varinfos = bcfiles#get_varinfos in
48+
List.iter
49+
(fun vinfo ->
50+
if List.mem vinfo.bvname gfunnames then
51+
()
52+
else
53+
match BCHGlobalMemoryMap.update_global_location_type vinfo with
54+
| Error e ->
55+
ch_error_log#add
56+
"update-global-location-type"
57+
(LBLOCK [
58+
STR "varinfo: "; STR vinfo.bvname; STR (String.concat "; " e)])
59+
| _ -> ()) varinfos
6560

6661

6762
let parse_cil_file ?(computeCFG=true) ?(removeUnused=true) (filename: string) =

0 commit comments

Comments
 (0)