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

create copyright #8

Closed
wants to merge 145 commits into from
Closed

Conversation

sravyamks
Copy link
Contributor

Add copyright file to repo to add it to the package when installing.

Checklist
  • Language changes are updated in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md

@sravyamks sravyamks mentioned this pull request May 21, 2020
13 tasks
pzakha pushed a commit to pzakha/bpftrace that referenced this pull request Jul 10, 2020
This fixes the following error.

```
% sudo ./src/bpftrace -e 'w::0x10000000:8:: {}'
AddressSanitizer:DEADLYSIGNAL
=================================================================
==26761==ERROR: AddressSanitizer: SEGV on unknown address 0x614000010000 (pc 0x0000008dc6b6 bp 0x7ffe172080c0 sp 0x7ffe17207540 T0)
==26761==The signal is caused by a READ memory access.
    #0 0x8dc6b6 in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::AttachPoint&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/semantic_analyser.cpp:1684:25
    delphix#1 0x87c3e3 in bpftrace::ast::AttachPoint::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/ast.cpp:323:5
    delphix#2 0x8dd1bc in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::Probe&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/semantic_analyser.cpp:1737:9
    delphix#3 0x87c603 in bpftrace::ast::Probe::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/ast.cpp:355:5
    delphix#4 0x8dd2eb in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::Program&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/semantic_analyser.cpp:1751:12
    delphix#5 0x87c6b3 in bpftrace::ast::Program::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/ast.cpp:364:5
    delphix#6 0x8dd35a in bpftrace::ast::SemanticAnalyser::analyse() /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/semantic_analyser.cpp:1760:12
    delphix#7 0x80f63f in main /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/main.cpp:577:19
    delphix#8 0x7fec4efa5b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    delphix#9 0x5c1e39 in _start (/home/ubuntu/work/bpftrace/bpftrace/build_asan/src/bpftrace+0x5c1e39)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/semantic_analyser.cpp:1684:25 in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::AttachPoint&)
==26761==ABORTING
```

This is because `ap.mode.size()` is zero (`ap.mode` is a empty string)
and `ap.mode.size() - 1` causes underflow (`size_t` is unsigned).

https://github.com/iovisor/bpftrace/blob/96b6eb83c93668fd1e54147c8e1929fedd571dac/src/ast/semantic_analyser.cpp#L1683-L1684

With this patch,

```
% sudo ./src/bpftrace -e 'w::0x10000000:8:: {}'
stdin:1:1-18: ERROR: watchpoint mode must be combination of (r,w,x)
w::0x10000000:8:: {}
~~~~~~~~~~~~~~~~
```
pzakha pushed a commit to pzakha/bpftrace that referenced this pull request Jul 10, 2020
This prevents the error like the follwing:

```
% sudo ASAN_OPTIONS=detect_leaks=0 ./src/bpftrace -e 'BEGIN { @ = max(exit()); }'
AddressSanitizer:DEADLYSIGNAL
=================================================================
==25253==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000089e3dc bp 0x7fff0bf07270 sp 0x7fff0bf07270 T0)
==25253==The signal is caused by a READ memory access.
==25253==Hint: address points to the zero page.
    #0 0x89e3dc in llvm::Value::getType() const /usr/lib/llvm-10/include/llvm/IR/Value.h:246:34
    delphix#1 0x89cd6e in llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateIntCast(llvm::Value*, llvm::Type*, bool, llvm::Twine const&) /usr/lib/llvm-10/include/llvm/IR/IRBuilder.h:2172:12
    delphix#2 0x889ad5 in bpftrace::ast::CodegenLLVM::visit(bpftrace::ast::Call&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:328:16
    delphix#3 0x880160 in bpftrace::ast::Call::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/ast.cpp:129:5
    delphix#4 0x8966c0 in bpftrace::ast::CodegenLLVM::visit(bpftrace::ast::AssignMapStatement&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:1315:20
    delphix#5 0x880fa3 in bpftrace::ast::AssignMapStatement::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/ast.cpp:284:5
    delphix#6 0x897a70 in bpftrace::ast::CodegenLLVM::visit(bpftrace::ast::Probe&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:1510:13
    delphix#7 0x8815f3 in bpftrace::ast::Probe::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/ast.cpp:355:5
    delphix#8 0x89895b in bpftrace::ast::CodegenLLVM::visit(bpftrace::ast::Program&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:1601:12
    delphix#9 0x8816a3 in bpftrace::ast::Program::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/ast.cpp:364:5
    delphix#10 0x89b397 in bpftrace::ast::CodegenLLVM::compile(bpftrace::DebugLevel, std::ostream&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:2019:10
    delphix#11 0x813f3c in main /home/ubuntu/work/bpftrace/bpftrace/src/main.cpp:589:22
    delphix#12 0x7f2794c4db96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    delphix#13 0x5c64c9 in _start (/home/ubuntu/work/bpftrace/bpftrace/build_llvm10/src/bpftrace+0x5c64c9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /usr/lib/llvm-10/include/llvm/IR/Value.h:246:34 in llvm::Value::getType() const
==25253==ABORTING
```
danobi and others added 25 commits August 7, 2020 19:47
Non functional change.

Tuples become hard to read after you get enough entries.
We had two codepaths with almost duplicate code. This commit factors out
the common code.
Non functional change.

Just some small code cleanup.
This commit adds support for duplicated USDT markers. Duplication in
this context means identical provider and name. See the later runtime
test for an example of how this can occur.

With this commit, bpftrace will generate separate programs for each
duplicated marker. We need to generate separate programs because the
location of the usdt arguments may not be the same in each call site.
The later runtime test does not reproduce this behavior but I've
observed this happening in production before.
This commit sets up all the scaffolding for actual implementation.
This helper is used to determine if a memcpy is necessary or if a simple
load will work.
Before:
```
stdin:1:9-16: ERROR: Can not access field '' on expression of type 'int64'
BEGIN { (1+2).2 }
        ~~~~~~~
```

After:
```
stdin:1:9-16: ERROR: Can not access index 2 on expression of type 'int64'
BEGIN { (1+2).2 }
        ~~~~~~~
```
This commit implements codegen for tuple creation and tuple indexing.

Note that tuples are allocated on the stack because we can't really
contain aggregate types in registers.
Have `map_value_to_str` take a SizedType instead of an `IMap` reference
so we can later reuse this method to print tuple elements.
Support for both text and json output
Forgot to add checks for <sys/sdt.h> headers.
Arrays used the `size`, `elem_type` and `pointee_size` fields to store
array type information. This is confusing as `pointee_size` indicates a
pointer and also incomplete as an array of pointers cannot be stored
without losing pointee size information.

This fixes that by storing the complete type (`SizedType *`) instead of
just a few fields.
danobi and others added 24 commits August 7, 2020 19:47
bpftrace executable needs to lookup `BEGIN_trigger` and `END_trigger`
symbols. Since the bump of the minimal versin of CMake in
1a1a4a9, these symbols are stripped
from bpftrace: the executable is built without the `-rdynamic` option
and the symbol is not present anymore (tested with GCC 10). To restore
this compile option, we can instruct CMake to export symbols for
bpftrace executable.

Also, see #954.
Use `err_` instead of `out_` so that we can check whether errors
occur later by checking the length of `err_`.
Also fix tests to prevent an error message from being printed to stderr.
Currently, using `print` with a large `top` arg (any number larger than number
of map keys) on `hist` maps would result in a negative overflow bug, which will
make `print` fail to produce any output. This patch resolves this issue.
Before, if a tracepoint argument was accessed, bpftrace would prefer
using headers instead of BTF. This causes some friction for users/hosts
that don't have headers installed. They would have to pass in --btf to
override the default headers behavior.

This commit makes BTF the default if it's available. Now, users don't
need to pass in --btf.
The merged PR which enables `top` and `div` args of `print` for `avg` maps has
two issues that need addressing:

1. It came with subtractions of unsigned integers which can easily cause
negative overflows.
2. The runtime tests it came with are somehow unstable and fails randomly. This
patch brings more straightforward tests.
This reverts commit 38f1c69.

It was breaking the embedded builds.
The embedded build / test takes a while to run but it's probably better
than having master randomly break. Every time that breaks it takes at
least a couple days to get a fix up.
This introduces a stream-style logging infrastructure. It supports the basic
functionalities for now and can be extended with future PRs.

There are several benefits for including it in bpftrace:

- It would be more convinient for developers to keep track of inner status of
bpftrace and debug.
- It can help to print consistent error/warning messages.
- Future work will offer users the option to toggle on/off certain messages.

Related to #1411
TIMEOUT field is necessary
Currently, the runtime tests will continue even if there is a parser error.
Fix this by calling exit(1) if the parser error occurs.
The list of available kfunc symbols is taken from the BTF data, however,
it should not include non-traceable functions (those that are not listed
in /sys/kernel/debug/tracing/available_filter_functions) as tracing of
these may fail or be unstable. These are usually inlined functions or
functions marked as "notrace".

Resolves iovisor#1366.
Currently, when creating a BPF trampoline (in function
arch_prepare_bpf_trampoline), kernel only supports saving arguments of
the probed function that are passed in registers (at least for x86,
which is now the only architecture that has BPF trampolines). If the
function has more arguments, it is not attached, causing bpftrace to
fail.

This patch disables tracing of functions that have more arguments than
the number passed in registers for the current architecture.
Most of the errors for kfunc (non-existing or non-traceable function
etc.) occur when resolving kfunc arguments. Instead of printing a
generic "resolving kfunc arguments failed", print a better message that
could help the user to identify the problem.
We regressed on array indexing because the CreateArray() helper forgot
to set pointee_size. This caused all array indexes to silently index to
index 0.
@sravyamks sravyamks closed this Aug 7, 2020
@sravyamks
Copy link
Contributor Author

will rebase and open new PR

delphix-devops-bot pushed a commit that referenced this pull request Oct 22, 2020
The expr_ of a PositionalParameter is a pointer to a buffer, and an
offset can be added to it (e.g., `str($1 + 1)`). Cast expr_ to int so
that llvm does not complain about type mismatches when operating addition.

This fixes the following error reported by AddressSanitizer.

```
% sudo ./src/bpftrace -e 'BEGIN { printf("%s", str($1 + 1)); exit(); }' hello
AddressSanitizer:DEADLYSIGNAL
=================================================================
==3979==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000f8b (pc 0x7f1947a755ba bp 0x60700000def0 sp 0x7ffc07b486b0 T0)
==3979==The signal is caused by a READ memory access.
==3979==Hint: address points to the zero page.
    #0 0x7f1947a755ba in llvm::Constant::isNullValue() const (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xa735ba)
    #1 0x7f1948826177 in llvm::LazyValueInfo::getPredicateAt(unsigned int, llvm::Value*, llvm::Constant*, llvm::Instruction*) (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x1824177)
    #2 0x7f194841e4a8  (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x141c4a8)
    #3 0x7f1948420049  (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x141e049)
    #4 0x7f1947b13ed5 in llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xb11ed5)
    #5 0x7f194879ca90  (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x179aa90)
    #6 0x7f1947b145ff in llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xb125ff)
    #7 0x851bbe in bpftrace::ast::CodegenLLVM::optimize() /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:2720:6
    #8 0x791416 in main /home/ubuntu/work/bpftrace/bpftrace/src/main.cpp:745:10
    #9 0x7f1945cc8b96 in __libc_start_main /build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:310
    #10 0x4d1c79 in _start (/home/ubuntu/work/bpftrace/bpftrace/build_dev/src/bpftrace+0x4d1c79)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xa735ba) in llvm::Constant::isNullValue() const
==3979==ABORTING
```
delphix-devops-bot pushed a commit that referenced this pull request Jan 14, 2021
I though #1572 fixes the issue of invalid tuple creation, but there is
another issue. libfuzzer found the following:

```
% sudo ./src/bpftrace -e 'BEGIN { (1, !(int1)1); }'
/disk/work/bpftrace2/src/struct.cpp:29:37: runtime error: division by zero
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /disk/work/bpftrace2/src/struct.cpp:29:37 in
AddressSanitizer:DEADLYSIGNAL
=================================================================
==46777==ERROR: AddressSanitizer: FPE on unknown address 0x00000000b6b9 (pc 0x0000009aa53c bp 0x7fffffff68d0 sp 0x7fffffff64a0 T0)
    #0 0x9aa53c in bpftrace::Tuple::Create(std::vector<bpftrace::SizedType, std::allocator<bpftrace::SizedType> >) /disk/work/bpftrace2/src/struct.cpp:29:37
    #1 0x9cb00a in bpftrace::CreateTuple(std::vector<bpftrace::SizedType, std::allocator<bpftrace::SizedType> > const&) /disk/work/bpftrace2/src/types.cpp:443:20
    #2 0xc9dd2c in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::Tuple&) /disk/work/bpftrace2/src/ast/semantic_analyser.cpp:1994:16
    #3 0xa8048b in bpftrace::ast::Tuple::accept(bpftrace::ast::Visitor&) /disk/work/bpftrace2/src/ast/ast.cpp:31:1
    #4 0xc9e116 in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::ExprStatement&) /disk/work/bpftrace2/src/ast/semantic_analyser.cpp:1999:14
    #5 0xa805eb in bpftrace::ast::ExprStatement::accept(bpftrace::ast::Visitor&) /disk/work/bpftrace2/src/ast/ast.cpp:32:1
    #6 0xcbb643 in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::Probe&) /disk/work/bpftrace2/src/ast/semantic_analyser.cpp:2473:11
    #7 0xa8124b in bpftrace::ast::Probe::accept(bpftrace::ast::Visitor&) /disk/work/bpftrace2/src/ast/ast.cpp:41:1
    #8 0xcbb97d in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::Program&) /disk/work/bpftrace2/src/ast/semantic_analyser.cpp:2481:12
    #9 0xa813ab in bpftrace::ast::Program::accept(bpftrace::ast::Visitor&) /disk/work/bpftrace2/src/ast/ast.cpp:42:1
    #10 0xcbbda0 in bpftrace::ast::SemanticAnalyser::analyse() /disk/work/bpftrace2/src/ast/semantic_analyser.cpp:2490:12
    #11 0xa474fa in main /disk/work/bpftrace2/src/main.cpp:738:19
    #12 0x7fffed57e0b2 in __libc_start_main /build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:308:16
    #13 0x4fe68d in _start (/disk/work/bpftrace2/build/src/bpftrace+0x4fe68d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: FPE /disk/work/bpftrace2/src/struct.cpp:29:37 in bpftrace::Tuple::Create(std::vector<bpftrace::SizedType, std::allocator<bpftrace::SizedType> >)
==46777==ABORTING
```

In this case, `elem->type` is `int` because of `!`, but its size is zero
and that causes the problem. To fix issue, don't create tuple if an
elemenet size is zero.
delphix-devops-bot pushed a commit that referenced this pull request Aug 10, 2023
Integer arguments to printf-style functions are represented as 64-bit ints,
both in generated BPF code [1] and in bpftrace-side printing logic [2].
Therefore, a common pattern such as `printf("%d", pid)` is buggy -- it uses
the conversion specifier for ints to print an int64_t value.

While in practice this works as expected on most platforms (the value is
truncated to 4 bytes), it's by accident -- it depends on the architecture,
toolchain, calling convention, etc. For example, the above breaks on arm
with gcc where the compiler emits the following code for PrintableInt:

   0x000d6240 <+8>:     vldr    d7, [r12, #8]    # this->value_
   [...]
   0x000d6250 <+24>:    vstr    d7, [sp]
   0x000d6254 <+28>:    mov     r2, r3           # fmt
   0x000d6258 <+32>:    bl      0x1e000 <snprintf@plt>

(Note that the first 3 arguments to snprintf are passed via r0-r2, but
value_ is pushed onto the stack; snprintf expects the "%d" argument to
be in r3, so it ends up printing the value of fmt instead)

This patch adds an explicit cast to make sure that the argument provided
to snprintf is consistent with the conversion specifier.

[1] https://github.com/iovisor/bpftrace/blob/34cf5c2b53b82cddc9111055cd499d6e35763f3c/src/ast/passes/codegen_llvm.cpp#L3167
[2] https://github.com/iovisor/bpftrace/blob/34cf5c2b53b82cddc9111055cd499d6e35763f3c/src/printf.h#L82
delphix-devops-bot pushed a commit that referenced this pull request Jul 3, 2024
If it is dummy, then the visit() operation should not be executed. For
example, on aarch64, there is no syscalls:sys_{enter,exit}_open
tracepoint, however, opensnoop.bt tool will try to attch them and visit
args's field. We expect to get a warning, but instead we get a segmentation
fault. As follows:

    $ sudo gdb bpftrace
    ...
    (gdb) set args opensnoop.bt
    (gdb) r
    opensnoop.bt:22-24: WARNING: tracepoint not found: syscalls:sys_enter_open
    opensnoop.bt:28-30: WARNING: tracepoint not found: syscalls:sys_exit_open

    Thread 1 "bpftrace" received signal SIGSEGV, Segmentation fault.
    0x000000000052bbd8 in __gnu_cxx::__normal_iterator<bpftrace::Field const*, std::vector<bpftrace::Field, std::allocator<bpftrace::Field> > >::__normal_iterator (this=0xffffffffb0b8, __i=<error reading variable: Cannot access memory at address 0x10>)
        at /usr/include/c++/14/bits/stl_iterator.h:1068
    1068              : _M_current(__i) { }
    (gdb) bt
    #0  0x000000000052bbd8 in __gnu_cxx::__normal_iterator<bpftrace::Field const*, std::vector<bpftrace::Field, std::allocator<bpftrace::Field> > >::__normal_iterator (this=0xffffffffb0b8,
        __i=<error reading variable: Cannot access memory at address 0x10>) at /usr/include/c++/14/bits/stl_iterator.h:1068
    #1  0x0000000000525bdc in std::vector<bpftrace::Field, std::allocator<bpftrace::Field> >::begin (this=0x10)
        at /usr/include/c++/14/bits/stl_vector.h:884
    #2  0x000000000059ce8c in bpftrace::Struct::GetField (this=0x0, name="filename")
        at /home/rongtao/Git/bpftrace/bpftrace/src/struct.cpp:131
    #3  0x00000000005a70a0 in bpftrace::SizedType::GetField (this=0xe9b998, name="filename")
        at /home/rongtao/Git/bpftrace/bpftrace/src/types.cpp:538
    #4  0x00000000007c7178 in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, acc=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:1973
    #5  0x0000000000847db0 in bpftrace::ast::FieldAccess::accept (this=0xe9be30, v=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:31
    #6  0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xe9be30)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778
    #7  0x00000000007c8bec in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, assignment=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2218
    #8  0x0000000000847eb4 in bpftrace::ast::AssignMapStatement::accept (this=0xffffe4429250, v=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:36
    #9  0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xffffe4429250)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778
    #10 0x00000000007ca4c4 in bpftrace::ast::CodegenLLVM::generateProbe (this=0xffffffffc650, probe=..., full_func_id="dummy",
        name="dummy", func_type=0xff2b50, usdt_location_index=std::optional [no contained value], dummy=true)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2539
    #11 0x00000000007cb4e4 in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, probe=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2734
    #12 0x00000000008480f0 in bpftrace::ast::Probe::accept (this=0xffffe4427650, v=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:47
    #13 0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xffffe4427650)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778
    #14 0x00000000007cb7a4 in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, program=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2752
    #15 0x000000000084818c in bpftrace::ast::Program::accept (this=0xe90f50, v=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:50
    #16 0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xe90f50)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778
    #17 0x00000000007d03fc in bpftrace::ast::CodegenLLVM::generate_ir (this=0xffffffffc650)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3450
    #18 0x0000000000478138 in main (argc=2, argv=0xfffffffff4c8) at /home/rongtao/Git/bpftrace/bpftrace/src/main.cpp:898

We can simplify opensnoop.bt to:

    tracepoint:syscalls:sys_enter_open_not_exist,
    tracepoint:syscalls:sys_enter_openat
    {
        @ = args.filename;
    }

This will produce the following error:

    stdin:1:1-45: WARNING: tracepoint not found: syscalls:sys_enter_open_not_exist
    tracepoint:syscalls:sys_enter_open_not_exist,tracepoint:syscalls:sys_enter_openat {@ = args.filename;}
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Segmentation fault

We need to generate the dummy probe only for cases when none of the probe
attach points exists.

Link: bpftrace/bpftrace#3274
Signed-off-by: Viktor Malik <viktor.malik@gmail.com>
Signed-off-by: Rong Tao <rongtao@cestc.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet