summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <tbaeder@redhat.com>2021-02-02 11:23:24 +0100
committerMark Wielaard <mark@klomp.org>2021-02-05 16:42:58 +0100
commitf36ac0f291356912106d06bb851b36baf0351e0f (patch)
treedef16df04b7688ac61066ef1ef672ce2b67b7096
parent8db222e36ae777e6aec8c61c616838a86258e99f (diff)
downloadelfutils-f36ac0f291356912106d06bb851b36baf0351e0f.tar.gz
readelf: Remove show_op_index variable
advance_pc() uses show_op_index to save whether the current op_index is > 0 OR the new op_index is > 0. The new op index is calculated via new_op_index = (op_index + op_advance) % max_ops_per_instr; since all of the variables involved are unsigned, new_op_index >= op_index is always true. So... if op_index > 0, then new_op_index > 0 if op_index == 0, then new_op_index >= 0 and if the new_op_index is > 0, then the old one was as well. In any case, we only need to check the new_op_index, since show_op_index used to OR the two comparisons. In other words: op_index > 0 | new_op_index > 0 || show_op_index ------------------------------------------------ true true true false true true true false true xx false false false ... but since the third line (marked with xx) is not possible, the table becomes: op_index > 0 | new_op_index > 0 || show_op_index ------------------------------------------------ true true true false true true false false false ... and show_op_index is equal to (new_op_index > 0). So, remove the show_op_index variable and simply replace it by comparing the new op_index > 0.
-rw-r--r--src/ChangeLog5
-rw-r--r--src/readelf.c9
2 files changed, 8 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1f53ca7b..9e30df31 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2021-02-02 Timm Bäder <tbaeder@redhat.com>
+
+ * readelf.c (print_debug_line_section): Remove unnecessary
+ show_op_index variable, replace with (op_index > 0).
+
2021-01-08 Timm Bäder <tbaeder@redhat.com>
* readelf.c (print_cfa_program): Lift regname function to...
diff --git a/src/readelf.c b/src/readelf.c
index 9943c211..11692bb5 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -8752,14 +8752,11 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
/* Apply the "operation advance" from a special opcode
or DW_LNS_advance_pc (as per DWARF4 6.2.5.1). */
unsigned int op_addr_advance;
- bool show_op_index;
inline void advance_pc (unsigned int op_advance)
{
op_addr_advance = minimum_instr_len * ((op_index + op_advance)
/ max_ops_per_instr);
address += op_addr_advance;
- show_op_index = (op_index > 0 ||
- (op_index + op_advance) % max_ops_per_instr > 0);
op_index = (op_index + op_advance) % max_ops_per_instr;
}
@@ -8803,7 +8800,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
printf (_(" special opcode %u: address+%u = "),
opcode, op_addr_advance);
print_dwarf_addr (dwflmod, 0, address, address);
- if (show_op_index)
+ if (op_index > 0)
printf (_(", op_index = %u, line%+d = %zu\n"),
op_index, line_increment, line);
else
@@ -8921,7 +8918,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
printf (_(" advance address by %u to "),
op_addr_advance);
print_dwarf_addr (dwflmod, 0, address, address);
- if (show_op_index)
+ if (op_index > 0)
printf (_(", op_index to %u"), op_index);
printf ("\n");
}
@@ -8982,7 +8979,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
printf (_(" advance address by constant %u to "),
op_addr_advance);
print_dwarf_addr (dwflmod, 0, address, address);
- if (show_op_index)
+ if (op_index > 0)
printf (_(", op_index to %u"), op_index);
printf ("\n");
}