You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 7790 Reporter: alexSanchezStern Status: resolved (set by @xavierleroy on 2018-05-06T08:18:31Z) Resolution: fixed Priority: normal Severity: minor Platform: Linux OS: Gentoo Linux OS Version: 4.12.12-gentoo Version: 4.04.2 Fixed in version: 4.05.0 Category: back end (clambda to assembly)
Bug description
When calls are made to Printf.printf, the generated debug info in native code assembly marks the call instruction as coming from the callee, printf, not the caller as it should be.
Steps to reproduce
Compile the following program as hello-world.ml with ocamlopt -g
let say_hello _ =
let rand = Random.float(1.0) in
let x = sqrt(rand) in
Printf.printf "Hello world %e!\n" x;;
say_hello () ;;
Run objdump -d on the binary and search for the say_hello function
Get the address of its call to camlPrintf__fprintf
Run gdb on the binary
Ask for the debug info of the printf call line (in my case info line *0x41c482)
This will return "Line 29 of printf.ml" when the call actually happens at Line 4 of hello_world.ml
The text was updated successfully, but these errors were encountered:
Isn't this just inlining? printf is defined as a one-line wrapper around fprintf (in printf.ml), so fprintf, if it ends up in the function body by inlining, has debug information located in printf.ml.
Printf.printf is inlined at point of call, into some small computations and a call to Printf.fprintf. The call to fprintf (notice the "f" !) is marked as coming from the printf.ml file of the standard library because this is where it occurs initially. So, nothing is wrong here.
In private e-mail to me the reporter also noticed that the addsd and subsd instructions corresponding to the occurrences of "+." and "-." in the source code are marked as belonging to random.ml from the standard library.
Here we have a partial inlining (of Random.float) like in the Printf.printf case, but it is true that ocamlopt 4.04.2 does not insert the required ".loc" directive at the end of the inlined code for Random.float, hence a couple of subsequent instructions end up covered by a ".loc" pointing into random.ml
However this bug is seen in 4.04.2 but not in 4.05.0. I'm too lazy to chase the commit that improved the situation. Instead I'll just mark this PR as resolved.
Original bug ID: 7790
Reporter: alexSanchezStern
Status: resolved (set by @xavierleroy on 2018-05-06T08:18:31Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: Linux
OS: Gentoo Linux
OS Version: 4.12.12-gentoo
Version: 4.04.2
Fixed in version: 4.05.0
Category: back end (clambda to assembly)
Bug description
When calls are made to Printf.printf, the generated debug info in native code assembly marks the call instruction as coming from the callee, printf, not the caller as it should be.
Steps to reproduce
hello-world.ml
withocamlopt -g
objdump -d
on the binary and search for thesay_hello
functiongdb
on the binaryinfo line *0x41c482
)The text was updated successfully, but these errors were encountered: