• Matheus Marchini's avatar
    attach to multiple identical probes · 3a184594
    Matheus Marchini authored
    There were two problems keeping bpftrace from attaching to multiple
    identical probes in the same script: the first one was in our IR code
    generation, where we were creating multiple sections with the same name
    (since the secion name is determined by the probe's name). Since
    sections must have unique names, LLVM was not able to translate our IR
    to BPF. This was resolved by appending a `_#` to the section's name.
    
    The second problem was attaching to that probe: we can't use the same
    event name multiple times in "kprobe_events". bcc already handles
    multiple probes coming from *different* processes, since it also
    includes the PID on the event name. The solution was similar, we append
    `_#` to the event name before sending it to bcc. This required some
    strucutral changes, like keeping the `#` (index) in the AST Probe nodes
    and calling `BPFTrace::add_probe` during codegen instead of during
    semantic analysis (otherwise we wouldn't have the index for our Probes).
    
    Fixes: https://github.com/iovisor/bpftrace/issues/97
    3a184594
types.h 1.63 KB