addr2line: rework check_range conditions

Simplify logic and reduce indentation for DW_AT_low_pc case.

Reviewed by:	Tiger Gao, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27426
This commit is contained in:
Ed Maste 2020-12-02 17:22:29 +00:00
parent 8f9d5a8dbf
commit f4d6ed9a5c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=368280

View file

@ -580,8 +580,8 @@ check_range(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Unsigned addr,
ranges_cnt = 0;
in_cu = false;
ret = dwarf_attrval_unsigned(die, DW_AT_ranges, &ranges_off, &de);
if (ret == DW_DLV_OK) {
if (dwarf_attrval_unsigned(die, DW_AT_ranges, &ranges_off, &de) ==
DW_DLV_OK) {
ret = dwarf_get_ranges(dbg, ranges_off, &ranges,
&ranges_cnt, NULL, &de);
if (ret != DW_DLV_OK)
@ -612,19 +612,17 @@ check_range(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Unsigned addr,
break;
}
}
} else {
if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) ==
} else if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) ==
DW_DLV_OK) {
if (lopc == curlopc)
return (DW_DLV_ERROR);
if (dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc,
&de) == DW_DLV_OK) {
if (dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc, &de) ==
DW_DLV_OK) {
/*
* Check if the address falls into the PC
* range of this CU.
*/
if (handle_high_pc(die, lopc, &hipc) !=
DW_DLV_OK)
if (handle_high_pc(die, lopc, &hipc) != DW_DLV_OK)
return (DW_DLV_ERROR);
} else {
/* Assume ~0ULL if DW_AT_high_pc not present. */
@ -635,11 +633,10 @@ check_range(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Unsigned addr,
in_cu = true;
}
} else {
/* Addr not in range die, try labels. */
/* Addr not found above, try labels. */
ret = check_labels(dbg, die, addr, range);
return ret;
}
}
if (in_cu) {
if ((*range = calloc(1, sizeof(struct range))) == NULL)