aboutsummaryrefslogtreecommitdiffstats
path: root/debug/DwarfUtil.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-09-29 18:35:36 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2015-09-29 18:35:36 +0200
commit05acff8bcb4f127a6f0ff6c587ba38d1c8cbe2fc (patch)
treeef79a4e4e812a0dc988462d9c22670cddfa29a13 /debug/DwarfUtil.ml
parent4e0ffb627524e3a251ee9e82ed88e1ed45e26b16 (diff)
downloadcompcert-kvx-05acff8bcb4f127a6f0ff6c587ba38d1c8cbe2fc.tar.gz
compcert-kvx-05acff8bcb4f127a6f0ff6c587ba38d1c8cbe2fc.zip
More fixes for the DebugInformation.
Changed the sizeof function to take into account the bytes needed for the sleb128/uleb128 encoding of the DW_OP_* arguments and changed the end_live_range function to only close functions where the live range is currently open.
Diffstat (limited to 'debug/DwarfUtil.ml')
-rw-r--r--debug/DwarfUtil.ml27
1 files changed, 27 insertions, 0 deletions
diff --git a/debug/DwarfUtil.ml b/debug/DwarfUtil.ml
index e1869281..16e446ee 100644
--- a/debug/DwarfUtil.ml
+++ b/debug/DwarfUtil.ml
@@ -113,3 +113,30 @@ let data_location_block_type_abbr = dw_form_block
let data_location_ref_type_abbr = dw_form_ref4
let bound_const_type_abbr = dw_form_udata
let bound_ref_type_abbr=dw_form_ref4
+
+(* Sizeof functions for the encoding of uleb128 and sleb128 *)
+let sizeof_uleb128 value =
+ let size = ref 1 in
+ let value = ref (value lsr 7) in
+ while !value <> 0 do
+ value := !value lsr 7;
+ incr size;
+ done;
+ !size
+
+let sizeof_sleb128 value =
+ let size = ref 1 in
+ let byte = ref (value land 0x7f) in
+ let value = ref (value lsr 7) in
+ while not ((!value = 0 && (!byte land 0x40) = 0) || (!value = -1 && ((!byte land 0x40) <> 0))) do
+ byte := !value land 0x7f;
+ value := !value lsr 7;
+ incr size;
+ done;
+ !size
+
+let size_of_loc_expr = function
+ | DW_OP_bregx (a,b) -> 1 + (sizeof_uleb128 a) + (sizeof_sleb128 (Int32.to_int b))
+ | DW_OP_plus_uconst a
+ | DW_OP_piece a -> 1 + (sizeof_uleb128 a)
+ | DW_OP_reg i -> if i < 32 then 1 else 2