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

Migrate from objdump and grep to library calls #410

Merged
merged 2 commits into from
Apr 18, 2019

Conversation

acj
Copy link
Contributor

@acj acj commented Feb 10, 2019

Fixes #128.

@brendangregg
Copy link
Contributor

Thanks!

I'd merge it but we need to figure out how to handle this:

[ 18%] Building CXX object src/CMakeFiles/bpftrace.dir/bpftrace.cpp.o
/home/bgregg/Build/bpftrace/src/bpftrace.cpp:19:10: fatal error: bcc_elf.h: No such file or directory
 #include "bcc_elf.h"
          ^~~~~~~~~~~

I guess I have an older bcc version installed.

@acj
Copy link
Contributor Author

acj commented Feb 14, 2019

It looks like bcc_elf.h was separated from bcc_helpers.h around bcc 0.2 or so. I haven't been able to build that version locally, but hopefully the cmake workaround that I just pushed will work. I'm no cmake expert, though, so suggestions are welcome.

@brendangregg
Copy link
Contributor

Now get:

/home/bgregg/Build/bpftrace/src/bpftrace.cpp:22:10: fatal error: bcc_helpers.h: No such file or directory
 #include "bcc_helpers.h"
          ^~~~~~~~~~~~~~~

@acj
Copy link
Contributor Author

acj commented Feb 16, 2019

Hmm, okay. I'll investigate this more. What version of bcc do you have installed?

@acj
Copy link
Contributor Author

acj commented Mar 2, 2019

This seems similar to the issue reported in this comment from #335, but I don't think it's a bcc version problem. The libbpfcc-dev package on Ubuntu 18.04 doesn't include bcc_elf.h despite its being present in bcc 0.5.0. The upstream Debian package has it, and the libbcc package from the iovisor apt repo also has it.

I can see the symbols in the library:

$ objdump -tT /usr/lib/x86_64-linux-gnu/libbcc.so.0.5.0 | grep bcc_elf
00000000004418f0 g    DF .text  0000000000000017  Base        bcc_elf_is_shared_obj
0000000000441700 g    DF .text  0000000000000131  Base        bcc_elf_foreach_load_section
00000000004418c0 g    DF .text  0000000000000028  Base        bcc_elf_is_exe
0000000000441440 g    DF .text  00000000000002ad  Base        bcc_elf_foreach_usdt
000000000232eea0 g    DF .text  000000000000013a  Base        _ZN4USDT7Context9add_probeEPKcPK12bcc_elf_usdt
0000000000441ae0 g    DF .text  00000000000000ac  Base        bcc_elf_foreach_vdso_sym
00000000004416f0 g    DF .text  0000000000000008  Base        bcc_elf_foreach_sym
0000000000441910 g    DF .text  0000000000000018  Base        bcc_elf_is_vdso
000000000232efe0 g    DF .text  0000000000000011  Base        _ZN4USDT7Context11_each_probeEPKcPK12bcc_elf_usdtPv
0000000000441840 g    DF .text  000000000000007c  Base        bcc_elf_get_type

How can we fix this? Should I open an issue on the bcc repo?

@acj
Copy link
Contributor Author

acj commented Mar 11, 2019

@brendangregg ping. Any recommendations here?

@acj acj force-pushed the acj/resolve-symbols-with-bcc branch from 6b91c04 to 8664160 Compare March 13, 2019 00:45
@brendangregg
Copy link
Contributor

I need to setup a fresh environment and retest to see if it was just a problem with my dev environment (my dev environments get messy since I'm always building and testing things).

@acj
Copy link
Contributor Author

acj commented Mar 15, 2019

I ended up doing the same. It was working for me on Ubuntu 16.04, but I ran into the missing header issue on 18.04. Seems like a bug with the libbpfcc-dev package.

@mmarchini
Copy link
Contributor

@acj it should be working now with bcc master. I'm just not sure we want to land this before bcc makes a new release.

Also, should we try to keep it backwards compatible (keep using objdump for older bcc versions)?

@mmarchini
Copy link
Contributor

I would like to merge this since it will bring a big improvement on startup time once #557 is merged as well.

@acj
Copy link
Contributor Author

acj commented Apr 18, 2019

Sorry for the delay. Great to hear about the startup time improvements!

I'll test this against bcc master tomorrow morning.

If we want to merge soon, then I agree that backwards compatibility is a good move. Do we have a reliable way to get the installed bcc version? If not, I can probably branch based on the presence of bcc_elf.h.

@mmarchini
Copy link
Contributor

We tend to use feature detection for compatibility with multiple bcc versions. Here's one example: c03c39f

@acj acj force-pushed the acj/resolve-symbols-with-bcc branch from 8664160 to fdd02ec Compare April 18, 2019 10:36
Copy link
Contributor

@mmarchini mmarchini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brendangregg
Copy link
Contributor

Looks good, thanks!

@brendangregg brendangregg merged commit 48619f4 into bpftrace:master Apr 18, 2019
@acj acj deleted the acj/resolve-symbols-with-bcc branch April 18, 2019 23:28
palexster pushed a commit to palexster/bcc that referenced this pull request Jul 7, 2019
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

Successfully merging this pull request may close these issues.

Remove dependencies on objdump and grep
3 participants