# New Ticket Created by Bob Rogers # Please include the string: [perl #58660] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=58660 >
The attached tarball illustrates the problem (which has been around for a while): 1. Unpack in your Parrot working copy. 2. "cd pbc-merge-lnum-bug" 3. Running "make" generates the following output, with the expected error: [EMAIL PROTECTED]> make ../parrot -o main.pbc main.pir ../parrot -o foo.pbc foo.pir ../parrot -o bar.pbc bar.pir ../pbc_merge -o all.pbc main.pbc foo.pbc bar.pbc ../parrot all.pbc in foo in bar Could not find non-existent sub baz current instr.: 'bar' pc 36 (bar.pir:3) called from Sub 'foo' pc 21 (foo.pir:3) called from Sub 'main' pc 7 (main.pir:2) make: *** [test] Error 1 [EMAIL PROTECTED]> The problem is that the backtrace reports that the current instruction is "bar.pir" line 3, when it's really line 6. Line numbers for "foo" and "main" are correct. 4. Running "make test2" uses a different "main" that loads the other two PBC files explicitly; the correct line number is reported in this case. I notice that pbc_merge_debugs (src/pbc_merge.c:546) adds the cumulative sum of the previous debug segment sizes to the mapping offsets. These sizes are 7, 9, and 10 for main.pbc, foo.pbc, and bar.pbc respectively, but each of these values seems high by one. The attached patch is based on the theory that in_seg->base.size is really the count of words in the bytecode file and therefore includes the initial size word as well as the data. It does make the attached test case work, but this is too much voodoo for my taste, so I'll wait to hear from someone who knows what's going on. -- Bob Rogers http://rgrjr.dyndns.org/
pbc-merge-lnum-bug.tgz
Description: Binary data
* src/pbc_merge.c: + (pbc_merge_debugs): Fix line number offset bug in bytecode merging. Index: src/pbc_merge.c =================================================================== --- src/pbc_merge.c (revision 30656) +++ src/pbc_merge.c (working copy) @@ -584,8 +584,9 @@ mappings[num_mappings + j] = mapping; } - /* Update counts. */ - num_lines += in_seg->base.size; + /* Update counts. The "- 1" allows for the fact that the size value + itself is included in in_seg->base.size. */ + num_lines += in_seg->base.size - 1; num_mappings += in_seg->num_mappings; }