Conversation
nojb
left a comment
There was a problem hiding this comment.
This looks like a potentially useful change, and the patch is very small and simple. Not really familiar with Matching, but I am approving on the basis that the patch just replaces a Location.none by an actual location, and the supplied test.
@lpw25 could you rebase the PR please, and add Changes entry? Thanks! In the meantime maybe @gasche or @trefis (which are working on cleaning up Matching) can give a second approval for good measure.
|
The same location improvement in |
|
There are conflicts with #9520 (already merged). Could you please rebase, solve the conflicts, and add a Changes entry? |
8f5a44b to
022ca03
Compare
|
Rebased and Changes entry added. |
|
The test is failing: https://travis-ci.org/github/ocaml/ocaml/jobs/694263670#L5446-L5463 |
|
It is due to a bug in |
022ca03 to
6029221
Compare
|
I've pushed the change to avoid the ocamltest bug. |
Thank you! Will merge once CI passes. |
|
There is another error (only in some Travis configs): |
|
The tests are failing because the executables produced by ocamlopt.opt and ocamlopt.byte differ. I don't know why or how we test that, but I can't tell which differences matter for that check. The disassembled code is identical. |
6029221 to
faa56c1
Compare
|
I've added |
I think this should be fine. Thanks. (As this is done in other tests in that directory, I think this can be merged once CI passes.) Out of curiosity, I looked a bit into the problem. It appears there is a tiny difference (1 byte offset?) between the (C compiler's) debug info generated for the two versions: nojebar@walras$ readelf -a lazy.opt.opt > lazy.opt.opt.elf
nojebar@walras$ readelf -a lazy.byte.opt > lazy.byte.opt.elf
nojebar@walras$ git diff --no-index lazy.byte.opt.elf lazy.opt.opt.elf
diff --git a/lazy.byte.opt.elf b/lazy.opt.opt.elf
index ae60d72..848217b 100644
--- a/lazy.byte.opt.elf
+++ b/lazy.opt.opt.elf
@@ -79,14 +79,14 @@ Section Headers:
[27] .debug_aranges PROGBITS 0000000000000000 00093c30
0000000000006900 0000000000000000 0 0 16
[28] .debug_info PROGBITS 0000000000000000 0009a530
- 000000000004698b 0000000000000000 0 0 1
- [29] .debug_abbrev PROGBITS 0000000000000000 000e0ebb
+ 000000000004698a 0000000000000000 0 0 1
+ [29] .debug_abbrev PROGBITS 0000000000000000 000e0eba
000000000000a3fd 0000000000000000 0 0 1
- [30] .debug_line PROGBITS 0000000000000000 000eb2b8
+ [30] .debug_line PROGBITS 0000000000000000 000eb2b7
0000000000017f14 0000000000000000 0 0 1
- [31] .debug_str PROGBITS 0000000000000000 001031cc
+ [31] .debug_str PROGBITS 0000000000000000 001031cb
00000000000089ff 0000000000000001 MS 0 0 1
- [32] .debug_loc PROGBITS 0000000000000000 0010bbcb
+ [32] .debug_loc PROGBITS 0000000000000000 0010bbca
00000000000450fc 0000000000000000 0 0 1
[33] .debug_ranges PROGBITS 0000000000000000 00150cd0
000000000000d330 0000000000000000 0 0 16
@@ -6243,4 +6243,4 @@ Displaying notes found at file offset 0x00000254 with length 0x00000020:
Displaying notes found at file offset 0x00000274 with length 0x00000024:
Owner Data size Description
GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring)
- Build ID: d4c417d02ecbf81e33029a65a3ec786bc0394b02
+ Build ID: 4d222207f8523892ac9439b2c2ffca8137e89e13Maybe something to consider is to just drop the idea of comparing native binaries and restrict comparison to pure bytecode executables, where the output should be deterministic. |
|
OK, it turns out the difference is that the (C compiler's) debug information stores the path to the compilation directory which is different for both versions: diff --git a/lazy.byte.elf.debug b/lazy.opt.elf.debug
index 491613e..04673d2 100644
--- a/lazy.byte.elf.debug
+++ b/lazy.opt.elf.debug
@@ -14,7 +14,7 @@ Contents of the .debug_info section:
<47> DW_AT_producer : GNU AS 2.24
<53> DW_AT_language : 32769 (MIPS assembler)
Compilation Unit @ offset 0x55:
- Length: 0x7e (32-bit)
+ Length: 0x7d (32-bit)
Version: 2
Abbrev Offset: 0x14
Pointer Size: 8
@@ -23,120334 +23,120334 @@ Contents of the .debug_info section:
<65> DW_AT_low_pc : 0x4201c0
<6d> DW_AT_high_pc : 0x4203c6
<75> DW_AT_name : lazy.ml
- <7d> DW_AT_comp_dir : /home/nojebar/ocaml/testsuite/tests/backtrace/_ocamltest/lazy/ocamlopt.byte
- <c9> DW_AT_producer : GNU AS 2.24
- <d5> DW_AT_language : 32769 (MIPS assembler)
- Compilation Unit @ offset 0xd7:
+ <7d> DW_AT_comp_dir : /home/nojebar/ocaml/testsuite/tests/backtrace/_ocamltest/lazy/ocamlopt.opt
+ <c8> DW_AT_producer : GNU AS 2.24
+ <d4> DW_AT_language : 32769 (MIPS assembler)
+ Compilation Unit @ offset 0xd6:
Length: 0x55 (32-bit)
Version: 2
Abbrev Offset: 0x28
Pointer Size: 8This means that comparing native programs is broken when passing |
|
CI green, merged. Thank you for your efforts! |
|
Thanks for the detective work. I would suggest to remove the comparison between ocamlopt.byte- and ocamlopt.opt-generated executables in all cases. We don't control the C linker and there are various reasons why it can generate different but functionally-equivalent executables. |
|
According to my testing, native programs now have better backtrace, but bytecode programs don't. In fact looking at the PR again, I see that the backtrace test is restricted to native compilation only. I looked at the code and I don't understand why the backtrace would not be improved on bytecode (the compilation path is different, but both paths generate a function call that should now have the correct location). Can someone explain the difference? test.ml 4.12+dev native backtrace: 4.12+dev bytecode backtrace: |
Currently code like:
produces a backtrace that does not include any location in the
test1function. Similarly,produces a backtrace that does not include any location in the
test2function.This PR fixes that by making sure that the code generated for forcing lazy values is given the location of the call or pattern that produced it.