Skip to content

Commit b6f43e4

Browse files
committed
CHB: force functiondata add with function annotation
1 parent fa6dc35 commit b6f43e4

File tree

1 file changed

+79
-81
lines changed

1 file changed

+79
-81
lines changed

CodeHawk/CHB/bchlib/bCHFunctionData.ml

Lines changed: 79 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -738,87 +738,85 @@ let read_xml_function_annotation (node: xml_element_int) =
738738
let faddr = get "faddr" in
739739
TR.titer
740740
~ok:(fun dw ->
741-
if functions_data#has_function dw then
742-
let fndata = functions_data#get_function dw in
743-
let stackvintros =
744-
if hasc "stackvar-intros" then
745-
let svintros = getc "stackvar-intros" in
746-
List.fold_left
747-
(fun acc n ->
748-
TR.tfold
749-
~ok:(fun svi -> svi :: acc)
750-
~error:(fun e ->
751-
begin
752-
log_error_result __FILE__ __LINE__ e;
753-
acc
754-
end)
755-
(read_xml_stackvar_intro n))
756-
[]
757-
(svintros#getTaggedChildren "vintro")
758-
else
759-
[] in
760-
let regvintros =
761-
if hasc "regvar-intros" then
762-
let rvintros = getc "regvar-intros" in
763-
List.fold_left
764-
(fun acc n ->
765-
TR.tfold
766-
~ok:(fun rvi -> rvi :: acc)
767-
~error:(fun e ->
768-
begin
769-
log_error_result __FILE__ __LINE__ e;
770-
acc
771-
end)
772-
(read_xml_regvar_intro n))
773-
[]
774-
(rvintros#getTaggedChildren "vintro")
775-
else
776-
[] in
777-
let typingrules =
778-
if hasc "typing-rules" then
779-
let trules = getc "typing-rules" in
780-
List.fold_left
781-
(fun acc n ->
782-
TR.tfold
783-
~ok:(fun tr -> tr :: acc)
784-
~error:(fun e ->
785-
begin
786-
log_error_result __FILE__ __LINE__ e;
787-
acc
788-
end)
789-
(read_xml_typing_rule n))
790-
[]
791-
(trules#getTaggedChildren "typingrule")
792-
else
793-
[] in
794-
let rdefspecs =
795-
if hasc "remove-rdefs" then
796-
let rrds = getc "remove-rdefs" in
797-
List.fold_left
798-
(fun acc n ->
799-
TR.tfold
800-
~ok:(fun rds -> rds :: acc)
801-
~error:(fun e ->
802-
begin
803-
log_error_result __FILE__ __LINE__ e;
804-
acc
805-
end)
806-
(read_xml_reachingdef_spec n))
807-
[]
808-
(rrds#getTaggedChildren "remove-var-rdefs")
809-
else
810-
[] in
811-
fndata#set_function_annotation
812-
{regvarintros = regvintros;
813-
stackvarintros = stackvintros;
814-
typingrules = typingrules;
815-
reachingdefspecs = rdefspecs
816-
}
817-
else
818-
log_error_result
819-
~tag:"function annotation faddr not found"
820-
__FILE__ __LINE__
821-
["Function annotation address: " ^ faddr ^ " not known"])
741+
let fndata =
742+
if functions_data#has_function dw then
743+
functions_data#get_function dw
744+
else
745+
functions_data#add_function dw in
746+
let stackvintros =
747+
if hasc "stackvar-intros" then
748+
let svintros = getc "stackvar-intros" in
749+
List.fold_left
750+
(fun acc n ->
751+
TR.tfold
752+
~ok:(fun svi -> svi :: acc)
753+
~error:(fun e ->
754+
begin
755+
log_error_result __FILE__ __LINE__ e;
756+
acc
757+
end)
758+
(read_xml_stackvar_intro n))
759+
[]
760+
(svintros#getTaggedChildren "vintro")
761+
else
762+
[] in
763+
let regvintros =
764+
if hasc "regvar-intros" then
765+
let rvintros = getc "regvar-intros" in
766+
List.fold_left
767+
(fun acc n ->
768+
TR.tfold
769+
~ok:(fun rvi -> rvi :: acc)
770+
~error:(fun e ->
771+
begin
772+
log_error_result __FILE__ __LINE__ e;
773+
acc
774+
end)
775+
(read_xml_regvar_intro n))
776+
[]
777+
(rvintros#getTaggedChildren "vintro")
778+
else
779+
[] in
780+
let typingrules =
781+
if hasc "typing-rules" then
782+
let trules = getc "typing-rules" in
783+
List.fold_left
784+
(fun acc n ->
785+
TR.tfold
786+
~ok:(fun tr -> tr :: acc)
787+
~error:(fun e ->
788+
begin
789+
log_error_result __FILE__ __LINE__ e;
790+
acc
791+
end)
792+
(read_xml_typing_rule n))
793+
[]
794+
(trules#getTaggedChildren "typingrule")
795+
else
796+
[] in
797+
let rdefspecs =
798+
if hasc "remove-rdefs" then
799+
let rrds = getc "remove-rdefs" in
800+
List.fold_left
801+
(fun acc n ->
802+
TR.tfold
803+
~ok:(fun rds -> rds :: acc)
804+
~error:(fun e ->
805+
begin
806+
log_error_result __FILE__ __LINE__ e;
807+
acc
808+
end)
809+
(read_xml_reachingdef_spec n))
810+
[]
811+
(rrds#getTaggedChildren "remove-var-rdefs")
812+
else
813+
[] in
814+
fndata#set_function_annotation
815+
{regvarintros = regvintros;
816+
stackvarintros = stackvintros;
817+
typingrules = typingrules;
818+
reachingdefspecs = rdefspecs
819+
})
822820
~error:(fun e -> log_error_result __FILE__ __LINE__ e)
823821
(string_to_doubleword faddr)
824822

0 commit comments

Comments
 (0)