[gdb/testsuite] Add pseudo line number program instruction: line
authorTom de Vries <tdevries@suse.de>
Thu, 16 Jul 2020 13:34:00 +0000 (15:34 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 16 Jul 2020 13:34:00 +0000 (15:34 +0200)
There's an idiom in dwarf assembly test-cases:
...
set line1 [gdb_get_line_number "line 1"]
set line2 [gdb_get_line_number "line 2"]
set line3 [gdb_get_line_number "line 3"]
  ...
            {DW_LNS_advance_line [expr $line1 - 1]}
  ...
            {DW_LNS_advance_line [expr $line2 - $line1]}
  ...
            {DW_LNS_advance_line [expr $line3 - $line2]}
...

Add a pseudo line number program instruction "line", such that we can simply
write:
...
            {line $line1}
  ...
            {line $line2}
  ...
            {line $line3}
...

Build and reg-tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp
gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp
gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp
gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp
gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp
gdb/testsuite/lib/dwarf.exp

index 9559355905d19cbbe338753dd06955ec0dd2984e..78344179649a28343950b44078aa78ee357d111f 100644 (file)
@@ -1,3 +1,16 @@
+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
index 0c2c66122657e771c8e9cd5ec99f2ea6814497f8..e826825eb4b2705960d45a03117db46f17ef2fb5 100644 (file)
@@ -188,91 +188,91 @@ Dwarf::assemble $asm_file {
 
        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}
index 4fcc3cfeac9a3168d328c56abd3df820095e8d4c..12a60a01edd5bed9db5e91100c4ad243ae430536 100644 (file)
@@ -95,14 +95,14 @@ Dwarf::assemble $asm_file {
 
        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}
@@ -110,7 +110,7 @@ Dwarf::assemble $asm_file {
 
            {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}
index 81a678243d9966258789f219289abd07b83a1eaa..1632d5e898985bea54c9e908c743de9aac39f4ca 100644 (file)
@@ -95,25 +95,25 @@ Dwarf::assemble $asm_file {
 
        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}
index 2fcad93e957f6c3e60f2c6569b4ac65122ba51c7..745af0409fab1346e5f1f21f6b2cb7adb5aeb55d 100644 (file)
@@ -69,20 +69,15 @@ Dwarf::assemble $asm_file {
 
        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}
 
@@ -91,28 +86,20 @@ Dwarf::assemble $asm_file {
            {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}
@@ -120,9 +107,7 @@ Dwarf::assemble $asm_file {
            {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}
@@ -130,15 +115,11 @@ Dwarf::assemble $asm_file {
            {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}
@@ -146,28 +127,20 @@ Dwarf::assemble $asm_file {
            {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}
 
index e200e91fd77a6827e25188447551fe439e651e9a..62e655a0ee8f9967a7994b22e59025afdc6322a0 100644 (file)
@@ -69,21 +69,16 @@ Dwarf::assemble $asm_file {
 
        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}
 
@@ -96,9 +91,7 @@ Dwarf::assemble $asm_file {
            {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}
 
index 0a95adc5bcc753069c8a4ca4668ac65fafa715c2..ac37b24285a138a8442a90ad5b461b42e92b483b 100644 (file)
@@ -134,30 +134,30 @@ proc do_test {suffix} {
            # 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}
@@ -165,7 +165,7 @@ proc do_test {suffix} {
                {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}
@@ -173,7 +173,7 @@ proc do_test {suffix} {
                {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}
@@ -181,13 +181,13 @@ proc do_test {suffix} {
                {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}
index 5febc75e6c0e678a8e928e1aa75e7f7e43367801..21dc0f62d4da0302b091fc9ac50801ff295738e3 100644 (file)
@@ -1423,6 +1423,9 @@ namespace eval Dwarf {
        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.
@@ -1447,9 +1450,11 @@ namespace eval Dwarf {
            }
 
            proc DW_LNE_end_sequence {} {
+               variable _line
                _op .byte 0
                _op .uleb128 1
                _op .byte 1
+               set _line 1
            }
 
            proc DW_LNS_copy {} {
@@ -1466,8 +1471,25 @@ namespace eval Dwarf {
            }
 
            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} {