diff options
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 19 | ||||
-rw-r--r-- | binutils/dwarf.c | 166 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/dw2-1.W | 2 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/dw2-3.W | 2 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/dw2-3gabi.W | 2 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/dw5.W | 4 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/i386/compressed-1a.d | 2 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/libdw2-compressedgabi.out | 6 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objdump.W | 2 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objdump.WL | 3 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/x86-64/compressed-1a.d | 4 |
11 files changed, 157 insertions, 55 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 7e9d809..4b1b9e0 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,22 @@ +2017-07-21 Alexandre Oliva <aoliva@redhat.com> + + * dwarf.c (struct State_Machine_Registers): Add view field. + (reset_state_machine): Reset view. + (process_extended_line_op): Reset view when appropriate. + (display_debug_lines_raw): Increment or reset view when appropriate. + Print nonzero views. Support print view resets, disabled by default. + (display_debug_lines_decoded): Likewise. Disambiguate op_code tests, + enabling printing of end_sequence. + * testsuite/binutils-all/dw2-1.W: Add nonzero views. + * testsuite/binutils-all/dw2-3.W: Likewise. + * testsuite/binutils-all/dw2-3gabi.W: Likewise. + * testsuite/binutils-all/dw5.W: Add end sequence lines. + * testsuite/binutils-all/i386/compressed-1a.d: Add nonzero views. + * testsuite/binutils-all/libdw2-compressedgabi.out: Likewise. + * testsuite/binutils-all/objdump.W: Likewise. + * testsuite/binutils-all/objdump.WL: Add end sequence lines. + * testsuite/binutils-all/x86-64/compressed-1a.d: Add nonzero views. + 2017-07-19 Tristan Gingold <gingold@adacore.com> * nm.c (show_stats): Remove variable. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index f6fa157..ab6446d 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -426,6 +426,7 @@ read_uleb128 (unsigned char * data, typedef struct State_Machine_Registers { dwarf_vma address; + unsigned int view; unsigned int file; unsigned int line; unsigned int column; @@ -433,8 +434,8 @@ typedef struct State_Machine_Registers int basic_block; unsigned char op_index; unsigned char end_sequence; -/* This variable hold the number of the last entry seen - in the File Table. */ + /* This variable hold the number of the last entry seen + in the File Table. */ unsigned int last_file_entry; } SMR; @@ -444,6 +445,7 @@ static void reset_state_machine (int is_stmt) { state_machine_regs.address = 0; + state_machine_regs.view = 0; state_machine_regs.op_index = 0; state_machine_regs.file = 1; state_machine_regs.line = 1; @@ -502,6 +504,7 @@ process_extended_line_op (unsigned char * data, SAFE_BYTE_GET (adr, data, len - bytes_read - 1, end); printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr)); state_machine_regs.address = adr; + state_machine_regs.view = 0; state_machine_regs.op_index = 0; break; @@ -3190,6 +3193,7 @@ display_debug_lines_raw (struct dwarf_section *section, unsigned char *end, void *file) { unsigned char *start = section->start; + int verbose_view = 0; printf (_("Raw dump of debug contents of section %s:\n\n"), section->name); @@ -3381,30 +3385,45 @@ display_debug_lines_raw (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; printf (_(" Special opcode %d: " - "advance Address by %s to 0x%s"), + "advance Address by %s to 0x%s%s"), op_code, dwarf_vmatoa ("u", uladv), - dwarf_vmatoa ("x", state_machine_regs.address)); + dwarf_vmatoa ("x", state_machine_regs.address), + verbose_view && uladv + ? _(" (reset view)") : ""); } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + + state_machine_regs.address += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; printf (_(" Special opcode %d: " - "advance Address by %s to 0x%s[%d]"), + "advance Address by %s to 0x%s[%d]%s"), op_code, dwarf_vmatoa ("u", uladv), dwarf_vmatoa ("x", state_machine_regs.address), - state_machine_regs.op_index); + state_machine_regs.op_index, + verbose_view && addrdelta + ? _(" (reset view)") : ""); } adv = (op_code % linfo.li_line_range) + linfo.li_line_base; state_machine_regs.line += adv; - printf (_(" and Line by %s to %d\n"), + printf (_(" and Line by %s to %d"), dwarf_vmatoa ("d", adv), state_machine_regs.line); + if (verbose_view || state_machine_regs.view) + printf (_(" (view %u)\n"), state_machine_regs.view); + else + putchar ('\n'); + state_machine_regs.view++; } else switch (op_code) { @@ -3413,7 +3432,12 @@ display_debug_lines_raw (struct dwarf_section *section, break; case DW_LNS_copy: - printf (_(" Copy\n")); + printf (_(" Copy")); + if (verbose_view || state_machine_regs.view) + printf (_(" (view %u)\n"), state_machine_regs.view); + else + putchar ('\n'); + state_machine_regs.view++; break; case DW_LNS_advance_pc: @@ -3423,23 +3447,33 @@ display_debug_lines_raw (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; - printf (_(" Advance PC by %s to 0x%s\n"), + if (uladv) + state_machine_regs.view = 0; + printf (_(" Advance PC by %s to 0x%s%s\n"), dwarf_vmatoa ("u", uladv), - dwarf_vmatoa ("x", state_machine_regs.address)); + dwarf_vmatoa ("x", state_machine_regs.address), + verbose_view && uladv + ? _(" (reset view)") : ""); } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) - / linfo.li_max_ops_per_insn) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; - printf (_(" Advance PC by %s to 0x%s[%d]\n"), + if (addrdelta) + state_machine_regs.view = 0; + printf (_(" Advance PC by %s to 0x%s[%d]%s\n"), dwarf_vmatoa ("u", uladv), dwarf_vmatoa ("x", state_machine_regs.address), - state_machine_regs.op_index); + state_machine_regs.op_index, + verbose_view && addrdelta + ? _(" (reset view)") : ""); } break; @@ -3486,23 +3520,33 @@ display_debug_lines_raw (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; - printf (_(" Advance PC by constant %s to 0x%s\n"), + if (uladv) + state_machine_regs.view = 0; + printf (_(" Advance PC by constant %s to 0x%s%s\n"), dwarf_vmatoa ("u", uladv), - dwarf_vmatoa ("x", state_machine_regs.address)); + dwarf_vmatoa ("x", state_machine_regs.address), + verbose_view && uladv + ? _(" (reset view)") : ""); } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) - / linfo.li_max_ops_per_insn) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; - printf (_(" Advance PC by constant %s to 0x%s[%d]\n"), + if (addrdelta) + state_machine_regs.view = 0; + printf (_(" Advance PC by constant %s to 0x%s[%d]%s\n"), dwarf_vmatoa ("u", uladv), dwarf_vmatoa ("x", state_machine_regs.address), - state_machine_regs.op_index); + state_machine_regs.op_index, + verbose_view && addrdelta + ? _(" (reset view)") : ""); } break; @@ -3513,6 +3557,7 @@ display_debug_lines_raw (struct dwarf_section *section, printf (_(" Advance PC by fixed size amount %s to 0x%s\n"), dwarf_vmatoa ("u", uladv), dwarf_vmatoa ("x", state_machine_regs.address)); + /* Do NOT reset view. */ break; case DW_LNS_set_prologue_end: @@ -3925,7 +3970,7 @@ display_debug_lines_decoded (struct dwarf_section *section, printf ("%s:\n", file_table[0].name); } - printf (_("File name Line number Starting address\n")); + printf (_("File name Line number Starting address View\n")); saved_linfo = linfo; } @@ -3933,12 +3978,14 @@ display_debug_lines_decoded (struct dwarf_section *section, while (data < end_of_sequence) { unsigned char op_code; + int xop; int adv; unsigned long int uladv; unsigned int bytes_read; int is_special_opcode = 0; op_code = *data++; + xop = op_code; if (op_code >= linfo.li_opcode_base) { @@ -3948,21 +3995,28 @@ display_debug_lines_decoded (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) - / linfo.li_max_ops_per_insn) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; } adv = (op_code % linfo.li_line_range) + linfo.li_line_base; state_machine_regs.line += adv; is_special_opcode = 1; + /* Increment view after printing this row. */ } else switch (op_code) { @@ -3983,11 +4037,13 @@ display_debug_lines_decoded (struct dwarf_section *section, } ext_op_code_len += bytes_read; ext_op_code = *op_code_data++; + xop = ext_op_code; + xop = -xop; switch (ext_op_code) { case DW_LNE_end_sequence: - reset_state_machine (linfo.li_default_is_stmt); + /* Reset stuff after printing this row. */ break; case DW_LNE_set_address: SAFE_BYTE_GET_AND_INC (state_machine_regs.address, @@ -3995,6 +4051,7 @@ display_debug_lines_decoded (struct dwarf_section *section, ext_op_code_len - bytes_read - 1, end); state_machine_regs.op_index = 0; + state_machine_regs.view = 0; break; case DW_LNE_define_file: { @@ -4037,6 +4094,7 @@ display_debug_lines_decoded (struct dwarf_section *section, break; } case DW_LNS_copy: + /* Increment view after printing this row. */ break; case DW_LNS_advance_pc: @@ -4046,16 +4104,22 @@ display_debug_lines_decoded (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) - / linfo.li_max_ops_per_insn) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; } break; @@ -4124,16 +4188,22 @@ display_debug_lines_decoded (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) - / linfo.li_max_ops_per_insn) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; } break; @@ -4141,6 +4211,7 @@ display_debug_lines_decoded (struct dwarf_section *section, SAFE_BYTE_GET_AND_INC (uladv, data, 2, end); state_machine_regs.address += uladv; state_machine_regs.op_index = 0; + /* Do NOT reset view. */ break; case DW_LNS_set_prologue_end: @@ -4172,8 +4243,8 @@ display_debug_lines_decoded (struct dwarf_section *section, /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row to the DWARF address/line matrix. */ - if ((is_special_opcode) || (op_code == DW_LNE_end_sequence) - || (op_code == DW_LNS_copy)) + if ((is_special_opcode) || (xop == -DW_LNE_end_sequence) + || (xop == DW_LNS_copy)) { const unsigned int MAX_FILENAME_LENGTH = 35; char *fileName; @@ -4214,11 +4285,11 @@ display_debug_lines_decoded (struct dwarf_section *section, if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH)) { if (linfo.li_max_ops_per_insn == 1) - printf ("%-35s %11d %#18" DWARF_VMA_FMT "x\n", + printf ("%-35s %11d %#18" DWARF_VMA_FMT "x", newFileName, state_machine_regs.line, state_machine_regs.address); else - printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]\n", + printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]", newFileName, state_machine_regs.line, state_machine_regs.address, state_machine_regs.op_index); @@ -4226,18 +4297,27 @@ display_debug_lines_decoded (struct dwarf_section *section, else { if (linfo.li_max_ops_per_insn == 1) - printf ("%s %11d %#18" DWARF_VMA_FMT "x\n", + printf ("%s %11d %#18" DWARF_VMA_FMT "x", newFileName, state_machine_regs.line, state_machine_regs.address); else - printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]\n", + printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]", newFileName, state_machine_regs.line, state_machine_regs.address, state_machine_regs.op_index); } - if (op_code == DW_LNE_end_sequence) - printf ("\n"); + if (state_machine_regs.view) + printf (" %6u\n", state_machine_regs.view); + else + putchar ('\n'); + state_machine_regs.view++; + + if (xop == -DW_LNE_end_sequence) + { + reset_state_machine (linfo.li_default_is_stmt); + putchar ('\n'); + } free (newFileName); } diff --git a/binutils/testsuite/binutils-all/dw2-1.W b/binutils/testsuite/binutils-all/dw2-1.W index d70581b..fb9c798 100644 --- a/binutils/testsuite/binutils-all/dw2-1.W +++ b/binutils/testsuite/binutils-all/dw2-1.W @@ -69,7 +69,7 @@ Raw dump of debug contents of section .z?debug_line: \[0x.*\] Extended opcode 2: set Address to 0x4 \[0x.*\] Advance Line by 3 to 4 \[0x.*\] Copy - \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) \[0x.*\] Extended opcode 2: set Address to 0x8 \[0x.*\] Extended opcode 1: End of Sequence diff --git a/binutils/testsuite/binutils-all/dw2-3.W b/binutils/testsuite/binutils-all/dw2-3.W index 08a7f35..af77f87 100644 --- a/binutils/testsuite/binutils-all/dw2-3.W +++ b/binutils/testsuite/binutils-all/dw2-3.W @@ -149,7 +149,7 @@ Raw dump of debug contents of section .z?debug_line: \[0x0000002d\] Extended opcode 2: set Address to 0x0 \[0x00000034\] Advance Line by 3 to 4 \[0x00000036\] Copy - \[0x00000037\] Copy + \[0x00000037\] Copy \(view 1\) \[0x00000038\] Extended opcode 2: set Address to 0x4 \[0x0000003f\] Extended opcode 1: End of Sequence diff --git a/binutils/testsuite/binutils-all/dw2-3gabi.W b/binutils/testsuite/binutils-all/dw2-3gabi.W index 0d0fe6a..4a79260 100644 --- a/binutils/testsuite/binutils-all/dw2-3gabi.W +++ b/binutils/testsuite/binutils-all/dw2-3gabi.W @@ -149,7 +149,7 @@ Raw dump of debug contents of section .debug_line: \[0x0000002d\] Extended opcode 2: set Address to 0x0 \[0x00000034\] Advance Line by 3 to 4 \[0x00000036\] Copy - \[0x00000037\] Copy + \[0x00000037\] Copy \(view 1\) \[0x00000038\] Extended opcode 2: set Address to 0x4 \[0x0000003f\] Extended opcode 1: End of Sequence diff --git a/binutils/testsuite/binutils-all/dw5.W b/binutils/testsuite/binutils-all/dw5.W index 6f3f8ef..1fa0d5d 100644 --- a/binutils/testsuite/binutils-all/dw5.W +++ b/binutils/testsuite/binutils-all/dw5.W @@ -345,11 +345,13 @@ Raw dump of debug contents of section .debug_line: Decoded dump of debug contents of section .debug_line: CU: ./main.c: -File name Line number Starting address +File name Line number Starting address View main.c 6 0x1234 main.c 6 0x12346 +main.c 6 0x1234 main.c 5 0x1234 main.c 5 0x1234 +main.c 5 0x1234 diff --git a/binutils/testsuite/binutils-all/i386/compressed-1a.d b/binutils/testsuite/binutils-all/i386/compressed-1a.d index 5f02def..a45c6b8 100644 --- a/binutils/testsuite/binutils-all/i386/compressed-1a.d +++ b/binutils/testsuite/binutils-all/i386/compressed-1a.d @@ -96,7 +96,7 @@ Raw dump of debug contents of section .[z]?debug_line: \[0x.*\] Extended opcode 2: set Address to 0x0 \[0x.*\] Advance Line by 10 to 11 \[0x.*\] Copy - \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12 + \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12 \(view 1\) \[0x.*\] Advance Line by -7 to 5 \[0x.*\] Special opcode 229: advance Address by 16 to 0x10 and Line by 0 to 5 \[0x.*\] Special opcode 49: advance Address by 3 to 0x13 and Line by 2 to 7 diff --git a/binutils/testsuite/binutils-all/libdw2-compressedgabi.out b/binutils/testsuite/binutils-all/libdw2-compressedgabi.out index 3baa42a..ab456d5 100644 --- a/binutils/testsuite/binutils-all/libdw2-compressedgabi.out +++ b/binutils/testsuite/binutils-all/libdw2-compressedgabi.out @@ -70,7 +70,7 @@ Raw dump of debug contents of section .debug_line: \[0x.*\] Extended opcode 2: set Address to 0x4 \[0x.*\] Advance Line by 3 to 4 \[0x.*\] Copy - \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) \[0x.*\] Extended opcode 2: set Address to 0x8 \[0x.*\] Extended opcode 1: End of Sequence @@ -172,7 +172,7 @@ Raw dump of debug contents of section .debug_line: \[0x0000002d\] Extended opcode 2: set Address to 0x0 \[0x00000034\] Advance Line by 3 to 4 \[0x00000036\] Copy - \[0x00000037\] Copy + \[0x00000037\] Copy \(view 1\) \[0x00000038\] Extended opcode 2: set Address to 0x4 \[0x0000003f\] Extended opcode 1: End of Sequence @@ -355,7 +355,7 @@ Raw dump of debug contents of section .debug_line: \[0x0000002d\] Extended opcode 2: set Address to 0x0 \[0x00000034\] Advance Line by 3 to 4 \[0x00000036\] Copy - \[0x00000037\] Copy + \[0x00000037\] Copy \(view 1\) \[0x00000038\] Extended opcode 2: set Address to 0x4 \[0x0000003f\] Extended opcode 1: End of Sequence diff --git a/binutils/testsuite/binutils-all/objdump.W b/binutils/testsuite/binutils-all/objdump.W index a5379d0..5f977ee 100644 --- a/binutils/testsuite/binutils-all/objdump.W +++ b/binutils/testsuite/binutils-all/objdump.W @@ -69,7 +69,7 @@ Raw dump of debug contents of section .z?debug_line: \[0x.*\] Extended opcode 2: set Address to .* \[0x.*\] Advance Line by 3 to 4 \[0x.*\] Copy - \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) \[0x.*\] Extended opcode 2: set Address to .* \[0x.*\] Extended opcode 1: End of Sequence diff --git a/binutils/testsuite/binutils-all/objdump.WL b/binutils/testsuite/binutils-all/objdump.WL index 3846f4f..7c5a591 100644 --- a/binutils/testsuite/binutils-all/objdump.WL +++ b/binutils/testsuite/binutils-all/objdump.WL @@ -4,7 +4,7 @@ Decoded dump of debug contents of section \.debug_line: CU: \./dw2-decodedline\.c: -File name Line number Starting address +File name Line number Starting address View directory/file1\.c: file1\.c 1 .* @@ -12,4 +12,5 @@ file1\.c 1 .* \./dw2-decodedline\.c:\[\+\+\] dw2-decodedline\.c 2 .* +dw2-decodedline\.c 2 .* diff --git a/binutils/testsuite/binutils-all/x86-64/compressed-1a.d b/binutils/testsuite/binutils-all/x86-64/compressed-1a.d index 574b719..75b8ce5 100644 --- a/binutils/testsuite/binutils-all/x86-64/compressed-1a.d +++ b/binutils/testsuite/binutils-all/x86-64/compressed-1a.d @@ -96,10 +96,10 @@ Raw dump of debug contents of section .[z]?debug_line: \[0x.*\] Extended opcode 2: set Address to 0x0 \[0x.*\] Advance Line by 10 to 11 \[0x.*\] Copy - \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12 + \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12 \(view 1\) \[0x.*\] Advance Line by -7 to 5 \[0x.*\] Special opcode 229: advance Address by 16 to 0x10 and Line by 0 to 5 - \[0x.*\] Special opcode 6: advance Address by 0 to 0x10 and Line by 1 to 6 + \[0x.*\] Special opcode 6: advance Address by 0 to 0x10 and Line by 1 to 6 \(view 1\) \[0x.*\] Advance PC by 5 to 0x15 \[0x.*\] Extended opcode 1: End of Sequence |