44 ------------------------------------------------------------------------------
55 The MIT License (MIT)
66
7- Copyright (c) 2024 Aarno Labs LLC
7+ Copyright (c) 2024-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
@@ -47,6 +47,8 @@ let bcd = BCHBCDictionary.bcdictionary
4747let bd = BCHDictionary. bdictionary
4848let tcd = BCHTypeConstraintDictionary. type_constraint_dictionary
4949
50+ let p2s = CHPrettyUtil. pretty_to_string
51+
5052
5153class type_constraint_store_t : type_constraint_store_int =
5254object (self )
@@ -250,14 +252,12 @@ object (self)
250252 result := ! result @ (List. map tcd#get_type_constraint tcs))
251253 iaddrentry in
252254 let _ =
253- chlog#add
254- " stack lhs constraints"
255- (LBLOCK [
256- INT offset;
257- STR " : " ;
258- pretty_print_list ! result
259- (fun tc -> STR (type_constraint_to_string tc))
260- " [" " ; " " ]" ]) in
255+ log_diagnostics_result
256+ ~tag: (" stack lhs constraints for " ^ faddr)
257+ __FILE__ __LINE__
258+ [(string_of_int offset) ^ " : ["
259+ ^ (String. concat " ; " (List. map type_constraint_to_string ! result))
260+ ^ " ]" ] in
261261 ! result
262262 else
263263 []
@@ -439,28 +439,25 @@ object (self)
439439 let evaluation = self#evaluate_reglhs_type reg faddr iaddr in
440440 let logresults = iaddr = " 0xffffffff" in
441441 let log_evaluation () =
442- chlog#add
443- (" reglhs resolution was not successfull:" ^ faddr)
444- (LBLOCK [
445- STR iaddr;
446- STR " - " ;
447- STR (register_to_string reg);
448- STR " : " ;
449- pretty_print_list
450- evaluation
451- (fun (vars , consts ) ->
452- LBLOCK [
453- STR " vars: " ;
454- pretty_print_list
455- vars
456- (fun v -> STR (type_variable_to_string v))
457- " [" " ; " " ]" ;
458- STR " ; consts: " ;
459- pretty_print_list
460- consts
461- (fun c -> STR (type_constant_to_string c))
462- " [" " ; " " ]" ;
463- NL ]) " [[" " -- " " ]]" ]) in
442+ log_diagnostics_result
443+ ~tag: (" reglhs resolution not successfull for " ^ faddr)
444+ __FILE__ __LINE__
445+ [iaddr ^ " - " ^ (register_to_string reg) ^ " : "
446+ ^ (p2s (pretty_print_list
447+ evaluation
448+ (fun (vars , consts ) ->
449+ LBLOCK [
450+ STR " vars: " ;
451+ pretty_print_list
452+ vars
453+ (fun v -> STR (type_variable_to_string v))
454+ " [" " ; " " ]" ;
455+ STR " ; consts: " ;
456+ pretty_print_list
457+ consts
458+ (fun c -> STR (type_constant_to_string c))
459+ " [" " ; " " ]" ;
460+ NL ]) " [[" " -- " " ]]" ))] in
464461 let result = new IntCollections. set_t in
465462 begin
466463 List. iter (fun (vars , consts ) ->
@@ -499,16 +496,13 @@ object (self)
499496 | _ ->
500497 begin
501498 log_evaluation () ;
502- chlog#add
503- " top type constant in join"
504- (LBLOCK [
505- STR iaddr;
506- STR " --- " ;
507- STR (register_to_string reg);
508- STR " : " ;
509- pretty_print_list
510- (List. map bcd#get_typ result#toList)
511- (fun ty -> STR (btype_to_string ty)) " [" " ; " " ]" ]);
499+ log_diagnostics_result
500+ ~tag: (" top type constant in join for " ^ faddr)
501+ __FILE__ __LINE__
502+ [iaddr ^ " -- " ^ (register_to_string reg) ^ " : "
503+ ^ (p2s (pretty_print_list
504+ (List. map bcd#get_typ result#toList)
505+ (fun ty -> STR (btype_to_string ty)) " [" " ; " " ]" ))];
512506 None
513507 end
514508 end
@@ -517,26 +511,25 @@ object (self)
517511 (offset: int ) (faddr: string ): btype_t option =
518512 let evaluation = self#evaluate_stack_lhs_type offset faddr in
519513 let log_evaluation () =
520- chlog#add
521- (" stacklhs resolution was not successfull:" ^ faddr)
522- (LBLOCK [
523- INT offset;
524- STR " : " ;
525- pretty_print_list
526- evaluation
527- (fun (vars , consts ) ->
528- LBLOCK [
529- STR " vars: " ;
530- pretty_print_list
531- vars
532- (fun v -> STR (type_variable_to_string v))
533- " [" " ; " " ]" ;
534- STR " ; consts: " ;
535- pretty_print_list
536- consts
537- (fun c -> STR (type_constant_to_string c))
538- " [" " ; " " ]" ;
539- NL ]) " [[" " -- " " ]]" ]) in
514+ log_diagnostics_result
515+ ~tag: (" stacklhs resolution was not successful for " ^ faddr)
516+ __FILE__ __LINE__
517+ [(string_of_int offset) ^ " : "
518+ ^ (p2s (pretty_print_list
519+ evaluation
520+ (fun (vars , consts ) ->
521+ LBLOCK [
522+ STR " vars: " ;
523+ pretty_print_list
524+ vars
525+ (fun v -> STR (type_variable_to_string v))
526+ " [" " ; " " ]" ;
527+ STR " ; consts: " ;
528+ pretty_print_list
529+ consts
530+ (fun c -> STR (type_constant_to_string c))
531+ " [" " ; " " ]" ;
532+ NL ]) " [[" " -- " " ]]" ))] in
540533 let first_field_struct (s : IntCollections.set_t ): btype_t option =
541534 (* The type of a data item at a particular stack offset can legally
542535 be both a struct and the type of the first field of the struct.
@@ -566,19 +559,16 @@ object (self)
566559 let _ixftype = bcd#index_typ ftype in
567560 let _ixctype = bcd#index_typ ty in
568561 let _ =
569- chlog#add
570- " first field struct check"
571- (LBLOCK [
572- INT offset;
573- STR " : " ;
574- pretty_print_list
575- s#toList
576- (fun i -> STR (btype_to_string (bcd#get_typ i)))
577- " {" " ; " " }" ;
578- STR " : compinfo: " ;
579- STR cinfo.bcname;
580- STR " : first field type: " ;
581- STR (btype_to_string ftype)]) in
562+ log_diagnostics_result
563+ ~tag: " first field struct check"
564+ __FILE__ __LINE__
565+ [(string_of_int offset) ^ " : "
566+ ^ (p2s (pretty_print_list
567+ s#toList
568+ (fun i -> STR (btype_to_string (bcd#get_typ i)))
569+ " {" " ; " " }" ))
570+ ^ " : compinfo: " ^ cinfo.bcname
571+ ^ " : first field type: " ^ (btype_to_string ftype)] in
582572 (* TBD: restore this check in a better way
583573 if s#fold (fun acc i -> acc && (i = ixftype || i = ixctype)) true then
584574 Some tstructarray
@@ -597,20 +587,18 @@ object (self)
597587 let ixftype = bcd#index_typ ftype in
598588 let ixctype = bcd#index_typ ty in
599589 let _ =
600- chlog#add
601- " first field struct check (TComp case)"
602- (LBLOCK [
603- INT offset;
604- STR " : " ;
605- pretty_print_list
606- s#toList
607- (fun i -> STR (btype_to_string (bcd#get_typ i)))
608- " {" " ; " " }" ;
609- STR " : compinfo: " ;
610- STR cinfo.bcname;
611- STR " : first field type: " ;
612- STR (btype_to_string ftype)]) in
613- if s#fold (fun acc i -> acc && (i = ixftype || i = ixctype)) true then
590+ log_diagnostics_result
591+ ~tag: " first field struct check (TComp case)"
592+ __FILE__ __LINE__
593+ [(string_of_int offset) ^ " : "
594+ ^ (p2s (pretty_print_list
595+ s#toList
596+ (fun i -> STR (btype_to_string (bcd#get_typ i)))
597+ " {" " ; " " }" ))
598+ ^ " : compinfo: " ^ cinfo.bcname
599+ ^ " : first field type: " ^ (btype_to_string ftype)] in
600+ if s#fold
601+ (fun acc i -> acc && (i = ixftype || i = ixctype)) true then
614602 Some ftype
615603 else
616604 None ))
@@ -644,14 +632,13 @@ object (self)
644632 | _ ->
645633 begin
646634 log_evaluation () ;
647- chlog#add
648- " multiple distinct types"
649- (LBLOCK [
650- INT offset;
651- STR " ; " ;
652- pretty_print_list
653- (List. map bcd#get_typ result#toList)
654- (fun ty -> STR (btype_to_string ty)) " [" " ; " " ]" ]);
635+ log_diagnostics_result
636+ ~tag: (" multiple distinct types for " ^ faddr)
637+ __FILE__ __LINE__
638+ [(string_of_int offset) ^ " : "
639+ ^ (p2s (pretty_print_list
640+ (List. map bcd#get_typ result#toList)
641+ (fun ty -> STR (btype_to_string ty)) " [" " ; " " ]" ))];
655642 None
656643 end
657644 end
0 commit comments