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

Kernel callstacks not show correct #7

Closed
woodpenker opened this issue Sep 2, 2022 · 4 comments
Closed

Kernel callstacks not show correct #7

woodpenker opened this issue Sep 2, 2022 · 4 comments

Comments

@woodpenker
Copy link

hi, I am using version 885b4d5297c1633444317d439b312626920b5486 from libbpf-bootstrap with C API , when I set cfg like this:

src.src_type = SRC_T_KERNEL;
src.params.kernel.kallsyms = NULL;
src.params.kernel.kernel_image = NULL;

It shows like this:

fail to load the kernel image /usr/lib/debug/boot/vmlinux-4.18.0-22-generic
  0 [<ffffffff9dabc7a1>]
  1 [<ffffffff9e3f46ac>]
  2 [<ffffffff9e3f8989>]
  3 [<ffffffff9e3f8a73>]
  4 [<ffffffff9dcb6836>]
  5 [<ffffffff9dcb77d6>]
  6 [<ffffffff9dcb8473>]
  7 [<ffffffff9da042aa>]
  8 [<ffffffff9e400088>]

The /proc/kallsyms exists, but /usr/lib/debug/boot/vmlinux-4.18.0-22-generic don't. Also I know on some machine, there is no kernel_image, such as Xavier. When I try to not give src.params.kernel.kernel_image and run, it crashed.

Seems kernel sym trans failed and can it run with only provide kallsyms path?

@woodpenker
Copy link
Author

BTW, it seems not correct to link C program with this -lrt -ldl -lpthread -lm libblazesym.a according to https://github.com/libbpf/blazesym#link-c-programs, such as gcc CMakeFiles/xx.dir/xx.c.o -o xx -lrt -ldl -lpthread -lm ./libblazesym.a libbpf/libbpf.a -lelf -lz, the ld program complains a lot like this:

/home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.24.2/src/sys/timer.rs:162: undefined reference to `timer_getoverrun'
./libblazesym.a(nix-1d96e29aba325ff2.nix.dba0ec83-cgu.8.rcgu.o): In function `<nix::sys::timer::Timer as core::ops::drop::Drop>::drop':
/home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.24.2/src/sys/timer.rs:169: undefined reference to `timer_delete'
collect2: error: ld returned 1 exit status

The sequence of the args matters. If I change it to libblazesym.a -lrt -ldl -lpthread -lm, such as gcc CMakeFiles/xx.dir/xx.c.o -o xx ./libblazesym.a -lrt -ldl -lpthread -lm libbpf/libbpf.a -lelf -lz, the ld succeed.

Maybe the doc needs to change the order?

My GCC version is 7.4.0.

@ThinkerYzu1
Copy link
Collaborator

I am looking into this issue.

ThinkerYzu1 pushed a commit to ThinkerYzu1/blazesym-priv that referenced this issue Sep 23, 2022
Issue libbpf#7 mentioned that the BlazeSym doesn't resolve any address in
the kernel space if a kernel image is not given or installed in the
system. KernelResolver required both kallsyms and a kernel image to
create itself successfully. However, the resolver should at least
partially work even with only kallsyms.

Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
@ThinkerYzu1
Copy link
Collaborator

@woodpenker pull #11 should fix your issue. It should work with only kallsyms or a kernel image. Please check if it fixes your problem. Thank you!

ThinkerYzu1 pushed a commit to ThinkerYzu1/blazesym-priv that referenced this issue Sep 23, 2022
Issue libbpf#7 mentioned about link errors about the order of parameters
sugguested in the README. libblazesym.a should go first before its
dependencies.

Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
@woodpenker
Copy link
Author

@woodpenker pull #11 should fix your issue. It should work with only kallsyms or a kernel image. Please check if it fixes your problem. Thank you!

👍 It works! I had tested it with the setting src.params.kernel.kallsyms = NULL and src.params.kernel.kallsyms = "/proc/kallsyms";, both work well. Thanks!

ThinkerYzu1 pushed a commit that referenced this issue Sep 26, 2022
Issue #7 mentioned about link errors about the order of parameters
sugguested in the README. libblazesym.a should go first before its
dependencies.

Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
ThinkerYzu1 pushed a commit that referenced this issue Sep 26, 2022
Issue #7 mentioned that the BlazeSym doesn't resolve any address in
the kernel space if a kernel image is not given or installed in the
system. KernelResolver required both kallsyms and a kernel image to
create itself successfully. However, the resolver should at least
partially work even with only kallsyms.

Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
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

2 participants