summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2020-12-02 17:22:29 +0000
committerEd Maste <emaste@FreeBSD.org>2020-12-02 17:22:29 +0000
commitf4d6ed9a5c5f5e78b9e20ae0c4b3ab78922aaf20 (patch)
tree2f12731544158e30fad2827768aa0eb7d4929aef /contrib
parent8f9d5a8dbf4ea69c5f9a1e3a36e23732ffaa5c75 (diff)
downloadsrc-test2-f4d6ed9a5c5f5e78b9e20ae0c4b3ab78922aaf20.tar.gz
src-test2-f4d6ed9a5c5f5e78b9e20ae0c4b3ab78922aaf20.zip
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
Notes
Notes: svn path=/head/; revision=368280
Diffstat (limited to 'contrib')
-rw-r--r--contrib/elftoolchain/addr2line/addr2line.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/contrib/elftoolchain/addr2line/addr2line.c b/contrib/elftoolchain/addr2line/addr2line.c
index 39366b6a8f05..3c5f4989bdde 100644
--- a/contrib/elftoolchain/addr2line/addr2line.c
+++ b/contrib/elftoolchain/addr2line/addr2line.c
@@ -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,33 +612,30 @@ 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 (lopc == curlopc)
+ /*
+ * Check if the address falls into the PC
+ * range of this CU.
+ */
+ if (handle_high_pc(die, lopc, &hipc) != DW_DLV_OK)
return (DW_DLV_ERROR);
- 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)
- return (DW_DLV_ERROR);
- } else {
- /* Assume ~0ULL if DW_AT_high_pc not present. */
- hipc = ~0ULL;
- }
-
- if (addr >= lopc && addr < hipc) {
- in_cu = true;
- }
} else {
- /* Addr not in range die, try labels. */
- ret = check_labels(dbg, die, addr, range);
- return ret;
+ /* Assume ~0ULL if DW_AT_high_pc not present. */
+ hipc = ~0ULL;
}
+
+ if (addr >= lopc && addr < hipc) {
+ in_cu = true;
+ }
+ } else {
+ /* Addr not found above, try labels. */
+ ret = check_labels(dbg, die, addr, range);
+ return ret;
}
if (in_cu) {