Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading from arguments doesn't work with bpftrace #2

Open
vchuravy opened this issue Apr 7, 2019 · 6 comments
Open

Reading from arguments doesn't work with bpftrace #2

vchuravy opened this issue Apr 7, 2019 · 6 comments

Comments

@vchuravy
Copy link
Member

vchuravy commented Apr 7, 2019

julia> using UProbes

julia> function f(arg)
           if @query(:julia, :test, typeof(arg))
               @probe(:julia, :test, arg)
           end
       end
f (generic function with 1 method)

julia> while true
           i = rand(Int64)
           f(i)
       end
➜  ~ sudo bpftrace -p 31417 -e "usdt:julia:test { @[comm] = hist(arg0); }"
Attaching 1 probe...
Code not generated for probe: usdt:/tmp/jl_bnvl90:test
➜  ~ readelf -n /tmp/jl_bnvl90 

Displaying notes found in: .note.stapsdt
  Owner                 Data size       Description
  stapsdt              0x0000002f       NT_STAPSDT (SystemTap probe descriptors)
    Provider: julia
    Name: test
    Location: 0x0000000000001005, Base: 0x0000000000002000, Semaphore: 0x0000000000004000
    Arguments: -8@-8(%rsp)
@vchuravy
Copy link
Member Author

vchuravy commented Apr 7, 2019

@NHDaly would be grand if you could try and reproduce this on Mac.
(I currently don't even know if these are what dtrace on mac expects)

@NHDaly
Copy link
Member

NHDaly commented Apr 8, 2019

Unfortunately the asm didn't parse on my mac:

julia> function f(arg)
           if @query(:julia, :test, typeof(arg))
               @probe(:julia, :test, arg)
           end
       end
f (generic function with 1 method)

julia> while true
           i = rand(Int64)
           f(i)
       end
<inline asm>:2:22: error: mach-o section specifier uses an unknown section type
        .pushsection .note.stapsdt,"?","note"
                     ^
<inline asm>:14:20: error: .popsection without corresponding .pushsection
        .popsection
                   ^
<inline asm>:16:22: error: mach-o section specifier uses an unknown section type
        .pushsection .stapsdt.base,"aG","progbits",.stapsdt.base,comdat
                     ^
<inline asm>:17:9: error: unknown directive
        .weak _.stapsdt.base
        ^
<inline asm>:18:9: error: unknown directive
        .hidden _.stapsdt.base
        ^
<inline asm>:20:9: error: unknown directive
        .size _.stapsdt.base, 1
        ^
<inline asm>:21:20: error: .popsection without corresponding .pushsection
        .popsection
                   ^
<inline asm>:2:22: error: mach-o section specifier uses an unknown section type
        .pushsection .note.stapsdt,"?","note"
                     ^
<inline asm>:14:20: error: .popsection without corresponding .pushsection
        .popsection
                   ^
<inline asm>:16:22: error: mach-o section specifier uses an unknown section type
        .pushsection .stapsdt.base,"aG","progbits",.stapsdt.base,comdat
                     ^
<inline asm>:17:9: error: unknown directive
        .weak _.stapsdt.base
        ^
<inline asm>:18:9: error: unknown directive
        .hidden _.stapsdt.base
        ^
<inline asm>:20:9: error: unknown directive
        .size _.stapsdt.base, 1
        ^
<inline asm>:21:20: error: .popsection without corresponding .pushsection
        .popsection
                   ^
<inline asm>:2:22: error: mach-o section specifier uses an unknown section type
        .pushsection .note.stapsdt,"?","note"
                     ^
<inline asm>:14:20: error: .popsection without corresponding .pushsection
        .popsection
                   ^
<inline asm>:16:22: error: mach-o section specifier uses an unknown section type
        .pushsection .stapsdt.base,"aG","progbits",.stapsdt.base,comdat
                     ^
<inline asm>:17:9: error: unknown directive
        .weak _.stapsdt.base
        ^
<inline asm>:18:9: error: unknown directive
        .hidden _.stapsdt.base
        ^
<inline asm>:20:9: error: unknown directive
        .size _.stapsdt.base, 1
        ^
<inline asm>:21:20: error: .popsection without corresponding .pushsection
        .popsection
                   ^
<inline asm>:2:22: error: mach-o section specifier uses an unknown section type
        .pushsection .note.stapsdt,"?","note"
                     ^
<inline asm>:14:20: error: .popsection without corresponding .pushsection
        .popsection
                   ^
<inline asm>:16:22: error: mach-o section specifier uses an unknown section type
        .pushsection .stapsdt.base,"aG","progbits",.stapsdt.base,comdat
                     ^
<inline asm>:17:9: error: unknown directive
        .weak _.stapsdt.base
        ^
<inline asm>:18:9: error: unknown directive
        .hidden _.stapsdt.base
        ^
<inline asm>:20:9: error: unknown directive
        .size _.stapsdt.base, 1
        ^
<inline asm>:21:20: error: .popsection without corresponding .pushsection
        .popsection
                   ^
ERROR: LLVM error: Error parsing inline asm

Stacktrace:
 [1] handle_error(::Cstring) at /Users/nathan.daly/.julia/packages/LLVM/tg8MX/src/core/context.jl:103
 [2] macro expansion at /Users/nathan.daly/.julia/packages/LLVM/tg8MX/src/base.jl:18 [inlined]
 [3] LLVMTargetMachineEmitToFile(::Ptr{LLVM.API.LLVMOpaqueTargetMachine}, ::Ptr{LLVM.API.LLVMOpaqueModule}, ::String, ::UInt32, ::Base.RefValue{Cstring}) at /Users/nathan.daly/.julia/packages/LLVM/tg8MX/lib/6.0/libLLVM_h.jl:297
 [4] emit at /Users/nathan.daly/.julia/packages/LLVM/tg8MX/src/targetmachine.jl:57 [inlined]
 [5] (::getfield(UProbes, Symbol("##9#13")){LLVM.Module,String})(::LLVM.TargetMachine) at /Users/nathan.daly/.julia/packages/UProbes/199dD/src/UProbes.jl:164
 [6] LLVM.TargetMachine(::getfield(UProbes, Symbol("##9#13")){LLVM.Module,String}, ::LLVM.Target, ::Vararg{Any,N} where N) at /Users/nathan.daly/.julia/packages/LLVM/tg8MX/src/targetmachine.jl:24
 [7] #emit_probe#5(::String, ::typeof(UProbes.emit_probe), ::Symbol, ::Symbol, ::Tuple{DataType}) at /Users/nathan.daly/.julia/packages/UProbes/199dD/src/UProbes.jl:163
 [8] emit_probe at /Users/nathan.daly/.julia/packages/UProbes/199dD/src/UProbes.jl:93 [inlined]
 [9] cache_dl(::Symbol, ::Symbol, ::Tuple{DataType}) at /Users/nathan.daly/.julia/packages/UProbes/199dD/src/UProbes.jl:75
 [10] #s13#4(::Any, ::Any, ::Any, ::Any, ::Type, ::Type, ::Any) at /Users/nathan.daly/.julia/packages/UProbes/199dD/src/UProbes.jl:64
 [11] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any,N} where N) at ./boot.jl:524
 [12] f at ./REPL[10]:2 [inlined]
 [13] top-level scope at ./REPL[11]:3

i'll putz with this now.

@NHDaly
Copy link
Member

NHDaly commented Apr 8, 2019

Based on this random comment from the internet, it looks like the ASM is different for x86 gnu linux and x86 macos :(
TeamShadow/shadow#10 (comment)

@vchuravy
Copy link
Member Author

vchuravy commented Apr 8, 2019

Ah that makes sense and I will need to figure out what the correct asm is for Mac/how dtrace probes look on Mac.

@jpsamaroo
Copy link
Member

Arguments are working now via bpftrace, at least on the LLVM 4 branch with Julia ~master.

@jpsamaroo
Copy link
Member

(Specifically on Linux)

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

No branches or pull requests

3 participants