+2020-07-16 Tom de Vries <tdevries@suse.de>
+
+ * lib/dwarf.exp (program): Initialize _line.
+ (DW_LNE_end_sequence): Reinitialize _line.
+ (DW_LNS_advance_line): Update _line.
+ (line): New proc.
+ * gdb.dwarf2/dw2-inline-many-frames.exp: Use line.
+ * gdb.dwarf2/dw2-inline-small-func.exp: Same.
+ * gdb.dwarf2/dw2-inline-stepping.exp: Same.
+ * gdb.dwarf2/dw2-is-stmt-2.exp: Same.
+ * gdb.dwarf2/dw2-is-stmt.exp: Same.
+ * gdb.dwarf2/dw2-ranges-func.exp: Same.
+
2020-07-15 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.fortran/ptype-on-functions.exp: Make the result pattern more
program {
{DW_LNE_set_address $main_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "main prologue"] - 1]}
+ {line [gdb_get_line_number "main prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address main_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "main set global_var"] - [gdb_get_line_number "main prologue"]]}
+ {line [gdb_get_line_number "main set global_var"]}
{DW_LNS_copy}
{DW_LNE_set_address main_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "main call aaa"] - [gdb_get_line_number "main set global_var"]]}
+ {line [gdb_get_line_number "main call aaa"]}
{DW_LNS_copy}
{DW_LNE_set_address main_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "aaa return"] - [gdb_get_line_number "main call aaa"]]}
+ {line [gdb_get_line_number "aaa return"]}
{DW_LNS_copy}
{DW_LNE_set_address main_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "bbb return"] - [gdb_get_line_number "aaa return"]]}
+ {line [gdb_get_line_number "bbb return"]}
{DW_LNS_copy}
{DW_LNE_set_address main_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "ccc return"] - [gdb_get_line_number "bbb return"]]}
+ {line [gdb_get_line_number "ccc return"]}
{DW_LNS_copy}
{DW_LNE_set_address main_label3}
- {DW_LNS_advance_line [expr [gdb_get_line_number "main end"] - [gdb_get_line_number "ccc return"]]}
+ {line [gdb_get_line_number "main end"]}
{DW_LNS_copy}
{DW_LNE_set_address $main_end}
{DW_LNE_end_sequence}
{DW_LNE_set_address $ddd_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "ddd prologue"] - 1]}
+ {line [gdb_get_line_number "ddd prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address ddd_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "ddd return"] - [gdb_get_line_number "ddd prologue"]]}
+ {line [gdb_get_line_number "ddd return"]}
{DW_LNS_copy}
{DW_LNE_set_address ddd_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "ddd end"] - [gdb_get_line_number "ddd return"]]}
+ {line [gdb_get_line_number "ddd end"]}
{DW_LNS_copy}
{DW_LNE_set_address $ddd_end}
{DW_LNE_end_sequence}
{DW_LNE_set_address $eee_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "eee prologue"] - 1]}
+ {line [gdb_get_line_number "eee prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address eee_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "eee return"] - [gdb_get_line_number "eee prologue"]]}
+ {line [gdb_get_line_number "eee return"]}
{DW_LNS_copy}
{DW_LNE_set_address eee_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "eee end"] - [gdb_get_line_number "eee return"]]}
+ {line [gdb_get_line_number "eee end"]}
{DW_LNS_copy}
{DW_LNE_set_address $eee_end}
{DW_LNE_end_sequence}
{DW_LNE_set_address $fff_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "fff prologue"] - 1]}
+ {line [gdb_get_line_number "fff prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address fff_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "fff return"] - [gdb_get_line_number "fff prologue"]]}
+ {line [gdb_get_line_number "fff return"]}
{DW_LNS_copy}
{DW_LNE_set_address fff_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "ggg return"] - [gdb_get_line_number "fff return"]]}
+ {line [gdb_get_line_number "ggg return"]}
{DW_LNS_copy}
{DW_LNE_set_address fff_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "hhh return"] - [gdb_get_line_number "ggg return"]]}
+ {line [gdb_get_line_number "hhh return"]}
{DW_LNS_copy}
{DW_LNE_set_address fff_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "iii return"] - [gdb_get_line_number "hhh return"]]}
+ {line [gdb_get_line_number "iii return"]}
{DW_LNS_copy}
{DW_LNE_set_address fff_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "fff end"] - [gdb_get_line_number "fff return"]]}
+ {line [gdb_get_line_number "fff end"]}
{DW_LNS_copy}
{DW_LNE_set_address $fff_end}
{DW_LNE_end_sequence}
{DW_LNE_set_address $jjj_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "jjj prologue"] - 1]}
+ {line [gdb_get_line_number "jjj prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address jjj_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "jjj return"] - [gdb_get_line_number "jjj prologue"]]}
+ {line [gdb_get_line_number "jjj return"]}
{DW_LNS_copy}
{DW_LNE_set_address jjj_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "jjj end"] - [gdb_get_line_number "jjj return"]]}
+ {line [gdb_get_line_number "jjj end"]}
{DW_LNS_copy}
{DW_LNE_set_address $jjj_end}
{DW_LNE_end_sequence}
{DW_LNE_set_address $kkk_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "kkk prologue"] - 1]}
+ {line [gdb_get_line_number "kkk prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address kkk_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "kkk return"] - [gdb_get_line_number "kkk prologue"]]}
+ {line [gdb_get_line_number "kkk return"]}
{DW_LNS_copy}
{DW_LNE_set_address $kkk_end}
{DW_LNE_end_sequence}
program {
{DW_LNE_set_address line_label_1}
- {DW_LNS_advance_line [expr $f1_l1 - 1]}
+ {line $f1_l1}
{DW_LNS_copy}
- {DW_LNS_advance_line [expr ${f1_l2} - ${f1_l1}]}
+ {line ${f1_l2}}
{DW_LNS_copy}
{DW_LNS_set_file 2}
- {DW_LNS_advance_line [expr ${f2_l1} - ${f1_l2}]}
+ {line ${f2_l1}}
{DW_LNS_copy}
{DW_LNS_negate_stmt}
{DW_LNS_set_file 1}
{DW_LNE_set_address line_label_2}
- {DW_LNS_advance_line [expr ${f1_l3} - ${f2_l1}]}
+ {line ${f1_l3}}
{DW_LNS_copy}
{DW_LNE_set_address line_label_3}
program {
{DW_LNE_set_address $main_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "main prologue"] - 1]}
+ {line [gdb_get_line_number "main prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address main_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "main set global_var"] - [gdb_get_line_number "main prologue"]]}
+ {line [gdb_get_line_number "main set global_var"]}
{DW_LNS_copy}
{DW_LNE_set_address main_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "main call foo"] - [gdb_get_line_number "main set global_var"]]}
+ {line [gdb_get_line_number "main call foo"]}
{DW_LNS_copy}
{DW_LNE_set_address main_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "foo call bar"] - [gdb_get_line_number "main call foo"]]}
+ {line [gdb_get_line_number "foo call bar"]}
{DW_LNS_copy}
{DW_LNE_set_address $main_end}
{DW_LNE_end_sequence}
{DW_LNE_set_address $bar_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "bar prologue"] - 1]}
+ {line [gdb_get_line_number "bar prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address bar_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "bar return global_var"] - [gdb_get_line_number "bar prologue"]]}
+ {line [gdb_get_line_number "bar return global_var"]}
{DW_LNS_copy}
{DW_LNE_set_address $bar_end}
{DW_LNE_end_sequence}
program {
{DW_LNE_set_address main}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "main prologue"] - 1]}
+ {line [gdb_get_line_number "main prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address line_label_0}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "main start"] \
- - [gdb_get_line_number "main prologue"]]}
+ {line [gdb_get_line_number "main start"]}
{DW_LNS_copy}
{DW_LNE_set_address line_label_1}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "Line 1"] \
- - [gdb_get_line_number "main start"]]}
+ {line [gdb_get_line_number "Line 1"]}
{DW_LNS_negate_stmt}
{DW_LNS_copy}
{DW_LNS_copy}
{DW_LNE_set_address line_label_3}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "Line 2"] \
- - [gdb_get_line_number "Line 1"]]}
+ {line [gdb_get_line_number "Line 2"]}
{DW_LNS_negate_stmt}
{DW_LNS_copy}
{DW_LNE_set_address line_label_4}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "Line 1"] \
- - [gdb_get_line_number "Line 2"]]}
+ {line [gdb_get_line_number "Line 1"]}
{DW_LNS_copy}
{DW_LNE_set_address line_label_5}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "Line 3"] \
- - [gdb_get_line_number "Line 1"]]}
+ {line [gdb_get_line_number "Line 3"]}
{DW_LNS_copy}
{DW_LNE_set_address line_label_6}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "Line 4"] \
- - [gdb_get_line_number "Line 3"]]}
+ {line [gdb_get_line_number "Line 4"]}
{DW_LNS_copy}
{DW_LNE_set_address line_label_7}
{DW_LNS_copy}
{DW_LNE_set_address line_label_8}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "Line 2"] \
- - [gdb_get_line_number "Line 4"]]}
+ {line [gdb_get_line_number "Line 2"]}
{DW_LNS_copy}
{DW_LNE_set_address line_label_9}
{DW_LNS_copy}
{DW_LNE_set_address line_label_10}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "Line 3"] \
- - [gdb_get_line_number "Line 2"]]}
+ {line [gdb_get_line_number "Line 3"]}
{DW_LNS_copy}
{DW_LNE_set_address line_label_11}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "Line 5"] \
- - [gdb_get_line_number "Line 3"]]}
+ {line [gdb_get_line_number "Line 5"]}
{DW_LNS_copy}
{DW_LNE_set_address line_label_12}
{DW_LNS_copy}
{DW_LNE_set_address line_label_13}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "Line 3"] \
- - [gdb_get_line_number "Line 5"]]}
+ {line [gdb_get_line_number "Line 3"]}
{DW_LNS_copy}
{DW_LNE_set_address line_label_14}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "Line 4"] \
- - [gdb_get_line_number "Line 3"]]}
+ {line [gdb_get_line_number "Line 4"]}
{DW_LNS_negate_stmt}
{DW_LNS_copy}
{DW_LNE_set_address line_label_15}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "Line 5"] \
- - [gdb_get_line_number "Line 4"]]}
+ {line [gdb_get_line_number "Line 5"]}
{DW_LNS_copy}
{DW_LNE_set_address line_label_16}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "main end"] \
- - [gdb_get_line_number "Line 5"]]}
+ {line [gdb_get_line_number "main end"]}
{DW_LNS_negate_stmt}
{DW_LNS_copy}
program {
{DW_LNE_set_address main}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "main prologue"] - 1]}
+ {line [gdb_get_line_number "main prologue"]}
{DW_LNS_negate_stmt}
{DW_LNS_copy}
{DW_LNE_set_address line_label_1}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "main, set var to 99"] \
- - [gdb_get_line_number "main prologue"]]}
+ {line [gdb_get_line_number "main, set var to 99"]}
{DW_LNS_copy}
{DW_LNE_set_address line_label_2}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "main, set var to 0"] \
- - [gdb_get_line_number "main, set var to 99"]]}
+ {line [gdb_get_line_number "main, set var to 0"]}
{DW_LNS_negate_stmt}
{DW_LNS_copy}
{DW_LNS_copy}
{DW_LNE_set_address line_label_5}
- {DW_LNS_advance_line \
- [expr [gdb_get_line_number "main end"] \
- - [gdb_get_line_number "main, set var to 0"]]}
+ {line [gdb_get_line_number "main end"]}
{DW_LNS_negate_stmt}
{DW_LNS_copy}
# reasonably accurate as it made debugging the test case easier.
program {
{DW_LNE_set_address $main_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "main prologue"] - 1]}
+ {line [gdb_get_line_number "main prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address main_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "main foo call"] - [gdb_get_line_number "main prologue"]]}
+ {line [gdb_get_line_number "main foo call"]}
{DW_LNS_copy}
{DW_LNE_set_address main_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "main return"] - [gdb_get_line_number "main foo call"]]}
+ {line [gdb_get_line_number "main return"]}
{DW_LNS_copy}
{DW_LNE_set_address $main_end}
- {DW_LNS_advance_line [expr [gdb_get_line_number "main end"] - [gdb_get_line_number "main return"] + 1]}
+ {line [expr [gdb_get_line_number "main end"] + 1]}
{DW_LNS_copy}
{DW_LNE_end_sequence}
{DW_LNE_set_address $foo_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "foo prologue"] - 1] }
+ {line [gdb_get_line_number "foo prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address foo_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "foo bar call"] - [gdb_get_line_number "foo prologue"]]}
+ {line [gdb_get_line_number "foo bar call"]}
{DW_LNS_copy}
{DW_LNE_set_address foo_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "foo foo_cold call"] - [gdb_get_line_number "foo bar call"]]}
+ {line [gdb_get_line_number "foo foo_cold call"]}
{DW_LNS_copy}
{DW_LNE_set_address foo_label3}
- {DW_LNS_advance_line [expr [gdb_get_line_number "foo end"] - [gdb_get_line_number "foo foo_cold call"]]}
+ {line [gdb_get_line_number "foo end"]}
{DW_LNS_copy}
{DW_LNE_set_address $foo_end}
{DW_LNS_advance_line 1}
{DW_LNE_end_sequence}
{DW_LNE_set_address $bar_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "bar end"] - 1]}
+ {line [gdb_get_line_number "bar end"]}
{DW_LNS_copy}
{DW_LNS_advance_pc $bar_len}
{DW_LNS_advance_line 1}
{DW_LNE_end_sequence}
{DW_LNE_set_address $baz_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "baz end"] - 1]}
+ {line [gdb_get_line_number "baz end"]}
{DW_LNS_copy}
{DW_LNS_advance_pc $baz_len}
{DW_LNS_advance_line 1}
{DW_LNE_end_sequence}
{DW_LNE_set_address $foo_cold_start}
- {DW_LNS_advance_line [expr [gdb_get_line_number "foo_cold prologue"] - 1]}
+ {line [gdb_get_line_number "foo_cold prologue"]}
{DW_LNS_copy}
{DW_LNE_set_address foo_cold_label}
- {DW_LNS_advance_line [expr [gdb_get_line_number "foo_cold baz call"] - [gdb_get_line_number "foo_cold prologue"]]}
+ {line [gdb_get_line_number "foo_cold baz call"]}
{DW_LNS_copy}
{DW_LNE_set_address foo_cold_label2}
- {DW_LNS_advance_line [expr [gdb_get_line_number "foo_cold end"] - [gdb_get_line_number "foo_cold baz call"]]}
+ {line [gdb_get_line_number "foo_cold end"]}
{DW_LNS_copy}
{DW_LNE_set_address $foo_cold_end}
{DW_LNS_advance_line 1}
proc program {statements} {
variable _line_saw_program
variable _line_header_end_label
+ variable _line
+
+ set _line 1
if "! $_line_saw_program" {
# Terminate the file list.
}
proc DW_LNE_end_sequence {} {
+ variable _line
_op .byte 0
_op .uleb128 1
_op .byte 1
+ set _line 1
}
proc DW_LNS_copy {} {
}
proc DW_LNS_advance_line {offset} {
+ variable _line
_op .byte 3
_op .sleb128 ${offset}
+ set _line [expr $_line + $offset]
+ }
+
+ # A pseudo line number program instruction, that can be used instead
+ # of DW_LNS_advance_line. Rather than writing:
+ # {DW_LNS_advance_line [expr $line1 - 1]}
+ # {DW_LNS_advance_line [expr $line2 - $line1]}
+ # {DW_LNS_advance_line [expr $line3 - $line2]}
+ # we can just write:
+ # {line $line1}
+ # {line $line2}
+ # {line $line3}
+ proc line {line} {
+ variable _line
+ set offset [expr $line - $_line]
+ DW_LNS_advance_line $offset
}
proc DW_LNS_set_file {num} {