This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: adding CFLAGS or EXTRA_CFLAGS
- From: David Smith <dsmith at redhat dot com>
- To: Daniel Doron <danielmeirdoron at gmail dot com>
- Cc: systemtap at sourceware dot org
- Date: Wed, 16 Aug 2017 10:58:50 -0500
- Subject: Re: adding CFLAGS or EXTRA_CFLAGS
- Authentication-results: sourceware.org; auth=none
- References: <CAFwN=+x4ERxhzn9PKv3HYKCcvq2FEau2y_5-UP_uuUjNiEm-fw@mail.gmail.com> <CAKFOr-Z_J2BKS8fXTnsOqy_p5caOB48_znLTHn5ryefv9qCQDw@mail.gmail.com> <CAFwN=+xHPVWx9MpcC4=8LXa7D1Ywk0D8-vGyzNwXua5esfmPQg@mail.gmail.com>
On Tue, Aug 15, 2017 at 11:51 PM, Daniel Doron
<danielmeirdoron@gmail.com> wrote:
> I wanted to include a header in the module of another module i am
> communicating with. So just to avoid duplicate code maintenance and
> hard coding the path, I wanted to add a search path.
OK, if I am understanding you correctly, you are probing an external
kernel module whose source isn't in the kernel tree. Assuming you
aren't using embedded C constructs and your external kernel module is
being compiled with debuginfo, you shouldn't need the headers. The
debuginfo should include all the type information you need. You can
use the @cast() operator to force things if you'd like, especially if
you are passing a structure pointer down to a systemtap function. It
would look something like this (the following is untested of course):
====
# In module FOO, we've got:
# struct custom_struct {
# int a;
# char b;
# long c;
# };
# bar(struct custom_struct *ptr)
probe module("FOO").function("bar")
{
print($ptr$$)
handle_custom_struct($ptr)
}
function handle_custom_struct(ptr:long)
{
if (@cast(ptr, "custom_struct", "FOO")->a == 0) {
# do something with ptr->b
}
else {
# do something with ptr->c
}
}
====
In the above you might need to list the header file in the @cast,
which would look like:
@cast(ptr, "custom_struct", "FOO<foo.h>").
If you are trying to do something with embedded C constructs and you
want to include your external kernel module's header file, you could
try something tricky like a relative path from /tmp/XXXX to your
kernel source. like:
%{
#include "../../home/daniel/src/FOO/foo.h"
%}
I haven't tried something like that, but it just might work.
I hope this helps.