From: Francis Deslauriers Date: Tue, 28 May 2019 00:45:06 +0000 (-0400) Subject: Fix: flt.lttng-utils.debug-info: cannot find addr past the first CU X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=1ed6d0cc62643f0a6acfa13623339e18ae4daa79 Fix: flt.lttng-utils.debug-info: cannot find addr past the first CU Issue ===== The `bin_info_lookup_source_location()` function doesn't look past the first Compile Unit(CU) in the Dwarf information to find the filename and line number of an address. This function iterates over all CUs of the binary (or shared object) and tries to translate the address with each of them. It ends up calling two other functions: `bin_info_lookup_cu_src_loc_no_inl()`and `bin_info_lookup_cu_src_loc_inl()` in a loop to cover all the CUs. The `bin_info_lookup_cu_src_loc_no_inl()` function returns an error (returning -1) if it can't find the line of the give address making the calling function exit the loop, and thus abort the resolving. The information that the resolving was unsuccessful is transmit back to the caller by omitting to set the `src_loc` output parameter. The return value of this function is used to notify the caller of an error. Not resolving the source line should not make the function return -1. This has the effect that if an address is contained in a CU after the first one this function will not be able to resolve it. Solution ======== Return 0 if the line is not found so that the search continues with other CUs. Drawbacks ========= None. Signed-off-by: Francis Deslauriers Change-Id: I4d85bc75d32a9a25a7044f3686c6d5940311fa68 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1337 Reviewed-by: Philippe Proulx --- diff --git a/plugins/lttng-utils/debug-info/bin-info.c b/plugins/lttng-utils/debug-info/bin-info.c index 28046290..c0546c86 100644 --- a/plugins/lttng-utils/debug-info/bin-info.c +++ b/plugins/lttng-utils/debug-info/bin-info.c @@ -1435,7 +1435,9 @@ error: * @param cu bt_dwarf_cu instance in which to look for the address * @param addr The address for which to look for * @param src_loc Out parameter, the source location (filename and - * line number) for the address + * line number) for the address. Set only if the address + * is found and resolved successfully + * * @returns 0 on success, -1 on failure */ static @@ -1460,7 +1462,8 @@ int bin_info_lookup_cu_src_loc_no_inl(struct bt_dwarf_cu *cu, uint64_t addr, line = dwarf_getsrc_die(die->dwarf_die, addr); if (!line) { - goto error; + /* This is not an error. The caller needs to keep looking. */ + goto end; } ret = dwarf_lineaddr(line, &line_addr); @@ -1494,6 +1497,7 @@ int bin_info_lookup_cu_src_loc_no_inl(struct bt_dwarf_cu *cu, uint64_t addr, *src_loc = _src_loc; } +end: return 0; error: