Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Why are the function's arguments optimized out in the case of breakpoint_on_error() ? #100

Open
josefsachsconning opened this issue May 13, 2016 · 1 comment

Comments

@josefsachsconning
Copy link
Collaborator

They are not optimized out if I set a breakpoint.

Using master branch of Gallium and its dependencies.

AWS-Sachs-Ubuntu$ usr/bin/julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-dev+4083 (2016-05-13 15:09 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 906e06b (0 days old master)
|__/                   |  x86_64-linux-gnu

julia> using Gallium

julia> function myfunction1(x, y)
           return x + y
       end
myfunction1 (generic function with 1 method)

julia> bp = Gallium.breakpoint(myfunction1)
Locations (+: active, -: inactive, *: source):
 * Any matching method added to #myfunction1
 * Any matching specialization of myfunction1(x, y) at REPL[2]:2


julia> myfunction1(2,3)
In REPL[2]:2
1 function myfunction1(x, y)
2     return x + y
3 end

About to run: Main.+
1|debug > bt
[1] myfunction1(x, y) at REPL[2]:2
  | #self# = <undefined>
  | x::Int64 = 2
  | y::Int64 = 3
[2] eval(m, e) at boot.jl:226
  | #self# = <optimized out>
  | m = <optimized out>
  | e = <optimized out>
[3] eval_user_input(ast, backend) at REPL.jl:50
  | #self# = <optimized out>
  | ast::Expr = myfunction1(2,3)
  | backend = <optimized out>
  | iserr = <optimized out>
  | bt::Void = nothing
  | lasterr::Tuple{} = ()
  | err = <optimized out>
  | ans = <optimized out>
  | value = <optimized out>
[4] #1() at event.jl:46
  | #self# = <optimized out>
  | tls = <optimized out>
  | ast = <optimized out>
  | show_value = <optimized out>

1|debug >
5

julia> Gallium.remove(bp)

julia> Gallium.breakpoint_on_error()
Gallium.Hooking.Hook(Ptr{Void} @0x00007faba703d160,UInt8[0x55,0x48,0x89,0xe5,0x53,0x48,0x89,0xfb,0x48,0x83,0xec,0x08,0xe8,0x6f,0x23,0x02,0x00],Gallium.breakpoint_on_error_hit)

julia> myfunction1(2,"three")
ERROR: MethodError: no method matching +(::Int64, ::String)
Closest candidates are:
  +(::Any, ::Any, ::Any, ::Any...)
  +{T<:Union{Int128,Int16,Int32,Int64,Int8,UInt128,UInt16,UInt32,UInt64,UInt8}}(::T<:Union{Int128,Int16,Int32,Int64,Int8,UInt128,UInt16,UInt32,UInt64,UInt8}, ::T<:Union{Int128,Int16,Int32,Int64,Int8,UInt128,UInt16,UInt32,UInt64,UInt8})
  +(::Integer, ::Ptr{T})
  ...

In REPL[2]:2
1 function myfunction1(x, y)
2     return x + y
3 end

1|debug > bt
[1] myfunction1(x, y) at REPL[2]:2
  | #self# = <optimized out>
  | x = <optimized out>
  | y = <optimized out>
[2] eval(m, e) at boot.jl:226
  | #self# = <optimized out>
  | m = <optimized out>
  | e = <optimized out>
[3] eval_user_input(ast, backend) at REPL.jl:50
  | #self# = <optimized out>
  | ast::Expr = myfunction1(2,"three")
  | backend = <optimized out>
  | iserr = <optimized out>
  | bt::Void = nothing
  | lasterr::Tuple{} = ()
  | err = <optimized out>
  | ans = <optimized out>
  | value = <optimized out>
[4] #1() at event.jl:46
  | #self# = <optimized out>
  | tls = <optimized out>
  | ast = <optimized out>
  | show_value = <optimized out>

1|debug >
@Keno
Copy link
Member

Keno commented May 13, 2016

Try julia -O0 when using Gallium in order to avoid things being optimized out. The reason that they're not optimized out with regular breakpoints is that argument registers get clobbered by the call to the error function (since the compiler realizes the arguments are no longer needed). I have some plans to improve debug information in non-O0 mode, but that's a long path.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants