Topics

bpftrace and include search paths?

Richard Elling
 

I have a need to have a bpftrace script #include headers from a project
directory. In cc, this is like adding -I<path>. Am I blind from reading manuals
or is there a clever way to pass that info down through bpftrace into bpf or
is this a new RFE?
-- richard

Brendan Gregg
 

C_INCLUDE_PATH=... environment variable should work.

But you can file an RFE or PR anyway to add this to the docs. Thanks!

Brendan


On Thu, Apr 4, 2019 at 12:41 PM Richard Elling <richard.elling@...> wrote:
I have a need to have a bpftrace script #include headers from a project
directory. In cc, this is like adding -I<path>. Am I blind from reading manuals
or is there a clever way to pass that info down through bpftrace into bpf or
is this a new RFE?
 -- richard




Richard Elling
 



On Apr 4, 2019, at 1:38 PM, Brendan Gregg <brendan.d.gregg@...> wrote:

C_INCLUDE_PATH=... environment variable should work.

Yes, thanks. Though CPATH seems to be more universal. I'll work up some docs and
submit a PR.

Now, if I can find an equivalent to dtrace's print(arg[0])...
 -- richard



But you can file an RFE or PR anyway to add this to the docs. Thanks!

Brendan

On Thu, Apr 4, 2019 at 12:41 PM Richard Elling <richard.elling@...> wrote:
I have a need to have a bpftrace script #include headers from a project
directory. In cc, this is like adding -I<path>. Am I blind from reading manuals
or is there a clever way to pass that info down through bpftrace into bpf or
is this a new RFE?
 -- richard




Matheus Marchini
 

We use the clang library to process includes, so any environment
variable that clang accepts should work. I haven't tested it, but
CPATH is listed in clang's documentation, so it should work as well.
C_INCLUDE_PATH will force the includes to only be used if clang is
parsing a .c file (which it always is in bpftrace context).

On Fri, Apr 12, 2019 at 1:55 PM Richard Elling
<richard.elling@...> wrote:



On Apr 4, 2019, at 1:38 PM, Brendan Gregg <brendan.d.gregg@...> wrote:

C_INCLUDE_PATH=... environment variable should work.


Yes, thanks. Though CPATH seems to be more universal. I'll work up some docs and
submit a PR.

Now, if I can find an equivalent to dtrace's print(arg[0])...
-- richard



But you can file an RFE or PR anyway to add this to the docs. Thanks!

Brendan

On Thu, Apr 4, 2019 at 12:41 PM Richard Elling <richard.elling@...> wrote:

I have a need to have a bpftrace script #include headers from a project
directory. In cc, this is like adding -I<path>. Am I blind from reading manuals
or is there a clever way to pass that info down through bpftrace into bpf or
is this a new RFE?
-- richard



Richard Elling
 



On Apr 23, 2019, at 12:36 PM, Matheus Marchini <mat@...> wrote:

We use the clang library to process includes, so any environment
variable that clang accepts should work. I haven't tested it, but
CPATH is listed in clang's documentation, so it should work as well.
C_INCLUDE_PATH will force the includes to only be used if clang is
parsing a .c file (which it always is in bpftrace context).

Thanks Matheus, CPATH works for sure, C_INCLUDE_PATH I'll need to verify. 
I'll send a docs PR when I get a chance.
 -- richard




On Fri, Apr 12, 2019 at 1:55 PM Richard Elling
<richard.elling@...> wrote:



On Apr 4, 2019, at 1:38 PM, Brendan Gregg <brendan.d.gregg@...> wrote:

C_INCLUDE_PATH=... environment variable should work.


Yes, thanks. Though CPATH seems to be more universal. I'll work up some docs and
submit a PR.

Now, if I can find an equivalent to dtrace's print(arg[0])...
-- richard



But you can file an RFE or PR anyway to add this to the docs. Thanks!

Brendan

On Thu, Apr 4, 2019 at 12:41 PM Richard Elling <richard.elling@...> wrote:

I have a need to have a bpftrace script #include headers from a project
directory. In cc, this is like adding -I<path>. Am I blind from reading manuals
or is there a clever way to pass that info down through bpftrace into bpf or
is this a new RFE?
-- richard