-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flambda-backend: Correctly stack debuginfo for inlined body in classi…
…c mode (#1152)
- Loading branch information
Showing
7 changed files
with
140 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
let[@inline never] print s = (print_endline[@inlined never]) s | ||
|
||
let[@inline] print_stack () = | ||
let st = Printexc.get_callstack 100 in | ||
(Printexc.print_raw_backtrace[@inlined never]) stdout st | ||
|
||
let[@inline] f s = | ||
print_stack (); | ||
print s | ||
|
||
let[@inline] g s = | ||
let s = (String.cat[@inlined never]) s " !" in | ||
f s; | ||
print_stack (); | ||
print "end of g" | ||
|
||
let[@inline] h s = | ||
g s; | ||
print_stack (); | ||
print "end of h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
(* TEST_BELOW *) | ||
|
||
let[@inline never] test s = | ||
let s' = (String.cat[@inlined never]) "! " s in | ||
(Foo.h[@inlined]) s'; (* CR gbury: remove [@inlined], cf #1199 *) | ||
(Foo.print_stack[@inlined]) (); (* CR gbury: remove [@inlined], cf #1199 *) | ||
(print_endline[@inlined never]) "end of test" | ||
|
||
let () = | ||
Printexc.record_backtrace true; | ||
test "foobar" | ||
|
||
(* This test aims at checking that backtraces are correct after inlining, | ||
particularly after inlining of functions from other files, and | ||
furthermore from other files compiled with different optimization options. | ||
We therefore define quite a few functions (in `foo.ml`) that use one | ||
another (with a lot of inlining). Additionally, we also print | ||
stack/backtraces after an inlined function (in the `test` function above), | ||
to ensure that we do not wrongly propagate debuginfos past the function | ||
call. *) | ||
|
||
(* TEST | ||
readonly_files ="foo.ml" | ||
* setup-ocamlopt.opt-build-env | ||
compiler_directory_suffix = ".O3" | ||
** ocamlopt.opt | ||
module = "foo.ml" | ||
flags = "-g -O3" | ||
*** ocamlopt.opt | ||
module = "main.ml" | ||
flags = "-g -O3" | ||
**** ocamlopt.opt | ||
module = "" | ||
all_modules = "foo.cmx main.cmx" | ||
***** run | ||
****** check-program-output | ||
* setup-ocamlopt.opt-build-env | ||
compiler_directory_suffix = ".Oclassic" | ||
** ocamlopt.opt | ||
module = "foo.ml" | ||
flags = "-g -Oclassic" | ||
*** ocamlopt.opt | ||
module = "main.ml" | ||
flags = "-g -Oclassic" | ||
**** ocamlopt.opt | ||
module = "" | ||
all_modules = "foo.cmx main.cmx" | ||
***** run | ||
****** check-program-output | ||
* setup-ocamlopt.opt-build-env | ||
compiler_directory_suffix = ".O3-Oclassic" | ||
** ocamlopt.opt | ||
module = "foo.ml" | ||
flags = "-g -O3" | ||
*** ocamlopt.opt | ||
module = "main.ml" | ||
flags = "-g -Oclassic" | ||
**** ocamlopt.opt | ||
module = "" | ||
all_modules = "foo.cmx main.cmx" | ||
***** run | ||
****** check-program-output | ||
* setup-ocamlopt.opt-build-env | ||
compiler_directory_suffix = ".Oclassic-O3" | ||
** ocamlopt.opt | ||
module = "foo.ml" | ||
flags = "-g -Oclassic" | ||
*** ocamlopt.opt | ||
module = "main.ml" | ||
flags = "-g -O3" | ||
**** ocamlopt.opt | ||
module = "" | ||
all_modules = "foo.cmx main.cmx" | ||
***** run | ||
****** check-program-output | ||
*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Raised by primitive operation at Foo.print_stack in file "foo.ml" (inlined), line 5, characters 11-37 | ||
Called from Foo.f in file "foo.ml" (inlined), line 9, characters 2-16 | ||
Called from Foo.g in file "foo.ml" (inlined), line 14, characters 2-5 | ||
Called from Foo.h in file "foo.ml" (inlined), line 19, characters 2-5 | ||
Called from Main.test in file "main.ml", line 5, characters 2-22 | ||
Called from Main in file "main.ml", line 11, characters 2-15 | ||
! foobar ! | ||
Raised by primitive operation at Foo.print_stack in file "foo.ml" (inlined), line 5, characters 11-37 | ||
Called from Foo.g in file "foo.ml" (inlined), line 15, characters 2-16 | ||
Called from Foo.h in file "foo.ml" (inlined), line 19, characters 2-5 | ||
Called from Main.test in file "main.ml", line 5, characters 2-22 | ||
Called from Main in file "main.ml", line 11, characters 2-15 | ||
end of g | ||
Raised by primitive operation at Foo.print_stack in file "foo.ml" (inlined), line 5, characters 11-37 | ||
Called from Foo.h in file "foo.ml" (inlined), line 20, characters 2-16 | ||
Called from Main.test in file "main.ml", line 5, characters 2-22 | ||
Called from Main in file "main.ml", line 11, characters 2-15 | ||
end of h | ||
Raised by primitive operation at Foo.print_stack in file "foo.ml" (inlined), line 5, characters 11-37 | ||
Called from Main.test in file "main.ml", line 6, characters 2-32 | ||
Called from Main in file "main.ml", line 11, characters 2-15 | ||
end of test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
File "inline_test.ml", line 14, characters 2-24 | ||
File "inline_test.ml", line 17, characters 2-5 | ||
File "inline_test.ml", line 20, characters 12-17 | ||
File "inline_test.ml", line 23, characters 5-8 | ||
File "inline_test.ml", line 26, characters 2-6 | ||
File "inline_test.ml", line 17, characters 2-24 | ||
File "inline_test.ml", line 20, characters 2-5 | ||
File "inline_test.ml", line 23, characters 12-17 | ||
File "inline_test.ml", line 26, characters 5-8 | ||
File "inline_test.ml", line 29, characters 2-6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
File inline_traversal_test.ml:14, raise | ||
File inline_traversal_test.ml:17 | ||
File inline_traversal_test.ml:17, raise | ||
File inline_traversal_test.ml:20 | ||
File inline_traversal_test.ml:23 | ||
File inline_traversal_test.ml:27 | ||
File inline_traversal_test.ml:26 | ||
File inline_traversal_test.ml:30 |