From 89ac1b83681c5edea6eaf234e0120f157657aa18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Fri, 22 Nov 2019 12:44:46 +0100 Subject: [PATCH] add_box_excl: use greater address below bound It is possible, eg. for the end-of-data debug_line tag, that the address does not correspond to an instruction address but eg. the last address of .text. To avoid an error here, we use as a bound address the greater known address below the given bound instead. --- src/renderer.ml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/renderer.ml b/src/renderer.ml index 4059544..c9ecebd 100644 --- a/src/renderer.ml +++ b/src/renderer.ml @@ -97,11 +97,14 @@ let add_box render_data range opt_data : render_data_t * int = (** Same as [add_box], with an included start, excluded end for range. *) let add_box_excl render_data (addr_beg, addr_end) opt_data = - (match RawAsm.AddrMap.find_opt addr_end render_data.render_prev_address with - | None -> Format.eprintf "Box end address %x not found, ignoring box." - addr_end ; - raise Not_found - | Some end_bound -> add_box render_data (addr_beg, end_bound) opt_data + let lower_than_end addr = addr <= addr_end in + (match RawAsm.AddrMap.find_last_opt + lower_than_end render_data.render_prev_address with + | None -> + Format.eprintf "Box end address %x not found, ignoring box.@." + addr_end ; + raise Not_found + | Some (_, end_bound) -> add_box render_data (addr_beg, end_bound) opt_data ) (** [to_file renderer render_data path] renders the given [render_data] to a