This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: adding CFLAGS or EXTRA_CFLAGS


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]