binutils-gdb/gdb/testsuite/gdb.dwarf2
Tom de Vries d8cc8af6a1 [gdb/symtab] Fix line-table end-of-sequence sorting
Consider test-case gdb.dwarf2/dw2-ranges-base.exp.  It has (ignoring
non-sensical entries that are filtered out by buildsym_compunit::record_line)
a line-table for dw2-ranges-base.c like this:
...
 Line Number Statements:
  [0x0000014e]  Extended opcode 2: set Address to 0x4004ba
  [0x00000159]  Advance Line by 10 to 11
  [0x0000015b]  Copy
  [0x0000015c]  Advance PC by 12 to 0x4004c6
  [0x0000015e]  Extended opcode 1: End of Sequence

  [0x00000161]  Extended opcode 2: set Address to 0x4004ae
  [0x0000016c]  Advance Line by 20 to 21
  [0x0000016e]  Copy
  [0x0000016f]  Advance PC by 12 to 0x4004ba
  [0x00000171]  Extended opcode 1: End of Sequence

  [0x00000174]  Extended opcode 2: set Address to 0x4004a7
  [0x0000017f]  Advance Line by 30 to 31
  [0x00000181]  Copy
  [0x00000182]  Advance PC by 7 to 0x4004ae
  [0x00000184]  Extended opcode 1: End of Sequence
...

If we disable the sorting in buildsym_compunit::end_symtab_with_blockvector,
we have the unsorted line table:
...
INDEX  LINE   ADDRESS            IS-STMT
0      11     0x00000000004004ba Y
1      END    0x00000000004004c6 Y
2      21     0x00000000004004ae Y
3      END    0x00000000004004ba Y
4      31     0x00000000004004a7 Y
5      END    0x00000000004004ae Y
...
It contains 3 sequences, 11/END, 21/END and 31/END.

We want to sort the 3 sequences relative to each other, while sorting on
address, to get:
...
INDEX  LINE   ADDRESS            IS-STMT
0      31     0x00000000004004a7 Y
1      END    0x00000000004004ae Y
2      21     0x00000000004004ae Y
3      END    0x00000000004004ba Y
4      11     0x00000000004004ba Y
5      END    0x00000000004004c6 Y
...

However, if we re-enable the sorting, we have instead:
...
INDEX  LINE   ADDRESS            IS-STMT
0      31     0x00000000004004a7 Y
1      21     0x00000000004004ae Y
2      END    0x00000000004004ae Y
3      11     0x00000000004004ba Y
4      END    0x00000000004004ba Y
5      END    0x00000000004004c6 Y
...

This is a regression since commit 3d92a3e313 "gdb: Don't reorder line table
entries too much when sorting", that introduced sorting on address while
keeping entries with the same address in pre-sort order.

Indeed the entries 1 and 2 are in pre-sort order (they map to entries 2 and 5
in the unsorted line table), but entry 1 does not belong in the sequence
terminated by 2.

Fix this by handling End-Of-Sequence entries in the sorting function, such
that they are sorted before other entries with the same address.

Also, revert the find_pc_sect_line workaround introduced in commit 3d92a3e313,
since that's no longer necessary.

Tested on x86_64-linux.

gdb/ChangeLog:

2020-07-06  Tom de Vries  <tdevries@suse.de>

	* buildsym.c (buildsym_compunit::end_symtab_with_blockvector): Handle
	End-Of-Sequence in lte_is_less_than.
	* symtab.c (find_pc_sect_line): Revert change from commit 3d92a3e313
	"gdb: Don't reorder line table entries too much when sorting".

gdb/testsuite/ChangeLog:

2020-07-06  Tom de Vries  <tdevries@suse.de>

	* gdb.dwarf2/dw2-ranges-base.exp: Test line-table order.
2020-07-06 14:28:58 +02:00
..
ada-linkage-name.c
ada-linkage-name.exp
ada-valprint-error.c
ada-valprint-error.exp
arr-stride.c
arr-stride.exp
arr-subrange.c
arr-subrange.exp
atomic-type.exp
atomic.c
bad-regnum.c
bad-regnum.exp
bitfield-parent-optimized-out.exp
break-inline-psymtab-2.c [gdb/testsuite] Don't use O2 for inlining in break-inline-psymtab.exp 2020-04-02 17:12:49 +02:00
break-inline-psymtab.c [gdb/testsuite] Add test-case gdb.dwarf2/break-inline-psymtab.exp 2020-03-18 14:40:49 +01:00
break-inline-psymtab.exp [gdb/testsuite] Don't use O2 for inlining in break-inline-psymtab.exp 2020-04-02 17:12:49 +02:00
callframecfa.exp
callframecfa.S
clang-debug-names-2-foo.c [gdb/symtab] Fix incomplete CU list assert in .debug_names 2020-05-11 15:03:54 +02:00
clang-debug-names-2.c [gdb/symtab] Fix incomplete CU list assert in .debug_names 2020-05-11 15:03:54 +02:00
clang-debug-names-2.exp [gdb/testsuite] Rename *.exp.in to *.exp.tcl 2020-05-15 14:49:48 +02:00
clang-debug-names.c [gdb/testsuite] Add gdb.dwarf2/clang-debug-names.c 2020-05-08 16:24:09 +02:00
clang-debug-names.exp [gdb/testsuite] Rename *.exp.in to *.exp.tcl 2020-05-15 14:49:48 +02:00
clang-debug-names.exp.tcl [gdb/testsuite] Rename *.exp.in to *.exp.tcl 2020-05-15 14:49:48 +02:00
clztest.c
clztest.exp
clztest.S
comp-unit-lang.c
comp-unit-lang.exp [gdb/testsuite] Fix duplicate test-names in gdb.dwarf2 2020-05-12 09:47:15 +02:00
corrupt.c
corrupt.exp
count.exp
cpp-linkage-name.c
cpp-linkage-name.exp
data-loc.c
data-loc.exp [gdb/testsuite] Fix duplicate test-names in gdb.dwarf2 2020-05-12 09:47:15 +02:00
dup-psym.exp
dup-psym.S
dw2-abs-hi-pc-hello-dbg.S
dw2-abs-hi-pc-hello.c
dw2-abs-hi-pc-world-dbg.S
dw2-abs-hi-pc-world.c
dw2-abs-hi-pc.c
dw2-abs-hi-pc.exp
dw2-ada-ffffffff.exp
dw2-ada-ffffffff.S
dw2-align.exp
dw2-anon-mptr.exp
dw2-anon-mptr.S
dw2-anonymous-func.exp
dw2-anonymous-func.S
dw2-bad-elf-other.S
dw2-bad-elf.c
dw2-bad-elf.exp
dw2-bad-mips-linkage-name.c
dw2-bad-mips-linkage-name.exp [gdb/testsuite] Fix language in dw2-bad-mips-linkage-name.exp 2020-04-24 23:25:44 +02:00
dw2-bad-parameter-type.exp [gdb/testsuite] Fix duplicate test-names in gdb.dwarf2 2020-05-12 09:47:15 +02:00
dw2-bad-parameter-type.S
dw2-bad-unresolved.c
dw2-bad-unresolved.exp
dw2-basic.exp
dw2-basic.S
dw2-canonicalize-type.exp
dw2-canonicalize-type.S
dw2-case-insensitive-debug.S
dw2-case-insensitive.c
dw2-case-insensitive.exp
dw2-common-block.exp
dw2-common-block.S
dw2-compdir-oldgcc.exp
dw2-compdir-oldgcc.S
dw2-compressed.exp
dw2-compressed.S
dw2-const.exp
dw2-const.S
dw2-cp-infcall-ref-static-main.c
dw2-cp-infcall-ref-static.exp
dw2-cp-infcall-ref-static.S
dw2-cu-size.exp
dw2-cu-size.S
dw2-dir-file-name.c
dw2-dir-file-name.exp
dw2-dos-drive.exp
dw2-dos-drive.S
dw2-double-set-die-type.exp
dw2-double-set-die-type.S
dw2-dummy-cu.exp
dw2-dummy-cu.S
dw2-dup-frame.c
dw2-dup-frame.exp
dw2-dup-frame.S
dw2-empty-namespace.exp
dw2-empty-namespace.S
dw2-empty-pc-range.exp
dw2-empty-pc-range.S
dw2-entry-value-main.c
dw2-entry-value.exp
dw2-entry-value.S
dw2-error.c
dw2-error.exp [gdb/testsuite] Compile gdb.dwarf2/dw2-error.exp quietly 2020-04-24 13:21:49 +02:00
dw2-error.S
dw2-filename.exp
dw2-filename.S
dw2-icc-opaque.exp
dw2-icc-opaque.S
dw2-icycle.c
dw2-icycle.exp
dw2-icycle.S
dw2-ifort-parameter.c
dw2-ifort-parameter.exp
dw2-inheritance.exp
dw2-inheritance.S
dw2-inline-break.exp
dw2-inline-break.S
dw2-inline-header-1.exp gdb: Preserve is-stmt lines when switch between files 2020-06-01 10:02:44 +01:00
dw2-inline-header-2.exp gdb: Preserve is-stmt lines when switch between files 2020-06-01 10:02:44 +01:00
dw2-inline-header-3.exp gdb: Preserve is-stmt lines when switch between files 2020-06-01 10:02:44 +01:00
dw2-inline-header-lbls.c gdb: Preserve is-stmt lines when switch between files 2020-06-01 10:02:44 +01:00
dw2-inline-header.c gdb: Preserve is-stmt lines when switch between files 2020-06-01 10:02:44 +01:00
dw2-inline-header.h gdb: Preserve is-stmt lines when switch between files 2020-06-01 10:02:44 +01:00
dw2-inline-many-frames.c
dw2-inline-many-frames.exp gdb/testsuite: Move helper function into lib/dwarf.exp 2020-04-14 12:13:06 +01:00
dw2-inline-param-main.c
dw2-inline-param.exp
dw2-inline-param.S
dw2-inline-small-func-lbls.c gdb: Don't remove duplicate entries from the line table 2020-04-02 17:44:03 +01:00
dw2-inline-small-func.c gdb: Don't remove duplicate entries from the line table 2020-04-02 17:44:03 +01:00
dw2-inline-small-func.exp gdb/testsuite: Move helper function into lib/dwarf.exp 2020-04-14 12:13:06 +01:00
dw2-inline-small-func.h gdb: Don't remove duplicate entries from the line table 2020-04-02 17:44:03 +01:00
dw2-inline-stepping.c
dw2-inline-stepping.exp
dw2-intercu.exp
dw2-intercu.S
dw2-intermix.exp
dw2-intermix.S
dw2-is-stmt-2.c
dw2-is-stmt-2.exp gdb/testsuite: Move helper function into lib/dwarf.exp 2020-04-14 12:13:06 +01:00
dw2-is-stmt.c
dw2-is-stmt.exp gdb/testsuite: Move helper function into lib/dwarf.exp 2020-04-14 12:13:06 +01:00
dw2-lexical-block-bare.exp
dw2-linkage-name-trust-main.cc
dw2-linkage-name-trust.exp
dw2-linkage-name-trust.S
dw2-minsym-in-cu.exp
dw2-minsym-in-cu.S
dw2-modula2-self-type.exp
dw2-modula2-self-type.S
dw2-namespaceless-anonymous.c Don't call compute_and_set_names for partial symbols 2020-04-24 15:35:03 -06:00
dw2-namespaceless-anonymous.exp Don't call compute_and_set_names for partial symbols 2020-04-24 15:35:03 -06:00
dw2-noloc-main.c
dw2-noloc.exp
dw2-noloc.S
dw2-objfile-overlap-inner.S
dw2-objfile-overlap-outer.S
dw2-objfile-overlap.exp
dw2-op-call.exp
dw2-op-call.S
dw2-op-out-param.exp
dw2-op-out-param.S
dw2-op-stack-value.exp
dw2-op-stack-value.S
dw2-opt-structptr.c
dw2-opt-structptr.exp
dw2-param-error-main.c
dw2-param-error.exp
dw2-param-error.S
dw2-producer.exp
dw2-producer.S
dw2-ranges2.c
dw2-ranges3.c
dw2-ranges-base.c
dw2-ranges-base.exp [gdb/symtab] Fix line-table end-of-sequence sorting 2020-07-06 14:28:58 +02:00
dw2-ranges-func-hi-cold.c
dw2-ranges-func-lo-cold.c
dw2-ranges-func.exp
dw2-ranges-main.c
dw2-ranges-psym.c
dw2-ranges-psym.exp
dw2-ranges.c
dw2-ranges.exp
dw2-ref-missing-frame-func.c
dw2-ref-missing-frame-main.c
dw2-ref-missing-frame.exp
dw2-ref-missing-frame.S
dw2-reg-undefined.c
dw2-reg-undefined.exp
dw2-reg-undefined.S
dw2-regno-invalid.exp
dw2-restore.exp
dw2-restore.S
dw2-restrict.c
dw2-restrict.exp
dw2-restrict.S
dw2-simple-locdesc.exp
dw2-simple-locdesc.S
dw2-single-line-discriminators.c
dw2-single-line-discriminators.exp
dw2-single-line-discriminators.S
dw2-skip-prologue.c
dw2-skip-prologue.exp
dw2-skip-prologue.S
dw2-stack-boundary.exp
dw2-stack-boundary.S
dw2-strp.exp
dw2-strp.S
dw2-symtab-includes.exp [gdb] Fix missing symtab includes 2020-04-14 15:30:50 +02:00
dw2-undefined-ret-addr.c
dw2-undefined-ret-addr.exp
dw2-undefined-ret-addr.S
dw2-unresolved-main.c
dw2-unresolved.exp
dw2-unresolved.S
dw2-unusual-field-names.c
dw2-unusual-field-names.exp
dw2-var-zero-addr.exp
dw2-var-zero-addr.S
dw4-sig-type-unused.exp
dw4-sig-type-unused.S
dw4-sig-types-b.cc
dw4-sig-types.cc
dw4-sig-types.exp
dw4-sig-types.h
dw4-toplevel-types.cc gdb: Fix toplevel types with -fdebug-types-section 2020-04-28 16:12:45 +02:00
dw4-toplevel-types.exp gdb: Fix toplevel types with -fdebug-types-section 2020-04-28 16:12:45 +02:00
dwp-sepdebug.c
dwp-sepdebug.exp
dwp-symlink.c
dwp-symlink.exp
dwz.exp
dwzbuildid.exp [gdb/testsuite] Compile dwzbuildid-mismatch more quietly 2020-04-24 13:59:42 +02:00
dynarr-ptr.c
dynarr-ptr.exp
enum-type.exp
file1.txt
fission-base.c
fission-base.exp
fission-base.S
fission-loclists-pie.exp
fission-loclists-pie.S
fission-loclists.exp
fission-loclists.S
fission-mix2.c
fission-mix.c
fission-mix.exp
fission-mix.h
fission-multi-cu1.c
fission-multi-cu2.c
fission-multi-cu.exp
fission-multi-cu.S
fission-reread.exp
fission-reread.S
formdata16.c
formdata16.exp
gdb-add-index.exp [gdb/symtab] Handle PU without import in "save gdb-index" 2020-04-16 14:56:32 +02:00
gdb-index.exp
implptr-64bit.exp
implptr-optimized-out.exp
implptr.c
implptr.exp
implptr.S
implptrconst.c
implptrconst.exp
implptrpiece.exp
implref-array.c
implref-array.exp
implref-const.exp
implref-global.c
implref-global.exp
implref-struct.c
implref-struct.exp [gdb/testsuite] Fix duplicate test-names in gdb.dwarf2 2020-05-12 09:47:15 +02:00
imported-unit-abstract-const-value.exp [gdb/symtab] Add symbol with inherited DW_AT_const_value to psymtabs 2020-04-07 17:33:05 +02:00
imported-unit-runto-main.exp [gdb/symtab] Handle PU without import in "save gdb-index" 2020-04-16 14:56:32 +02:00
imported-unit.c
imported-unit.exp [gdb/symtab] Find filename in shared psymtab 2020-04-22 08:24:11 +02:00
info-locals-optimized-out.c
info-locals-optimized-out.exp
inlined_subroutine-inheritance.exp
mac-fileno.exp
mac-fileno.S
main-foo.c [gdb/symtab] Handle struct decl with DW_AT_signature 2020-04-28 06:12:35 +02:00
main-subprogram.c
main-subprogram.exp
main.c
member-ptr-forwardref.exp
member-ptr-forwardref.S
method-ptr.cc
method-ptr.exp
missing-sig-type.exp
missing-type-name.exp
multidictionary.exp [gdb/testsuite] Fix scrolling in gdb.dwarf2/multidictionary.exp 2020-06-02 14:20:25 +02:00
nonvar-access.exp
nostaticblock.exp
opaque-type-lookup-2.c
opaque-type-lookup.c
opaque-type-lookup.exp
pieces-optimized-out.c
pieces-optimized-out.exp
pieces-optimized-out.S
pieces.c
pieces.exp
pieces.S
pr10770.c
pr10770.exp
pr11465.exp
pr11465.S
pr13961.exp
pr13961.S
shortpiece.exp
staticvirtual.exp
struct-with-sig.exp [gdb/symtab] Handle struct decl with DW_AT_signature 2020-04-28 06:12:35 +02:00
subrange.exp
symtab-producer.exp
trace-crash.exp
trace-crash.S
typeddwarf-amd64.S
typeddwarf.c
typeddwarf.exp
typeddwarf.S
typedef-void-finish.exp
valop.exp
valop.S
var-access.c
var-access.exp
variant.c
variant.exp
varval.c
varval.exp [gdb/testsuite] Fix duplicate test-names in gdb.dwarf2 2020-05-12 09:47:15 +02:00
void-type.c
void-type.exp
watch-notconst2.c
watch-notconst2.S
watch-notconst.c
watch-notconst.exp