public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* adding CFLAGS or EXTRA_CFLAGS
@ 2017-08-15  8:02 Daniel Doron
  2017-08-15  8:36 ` Arkady
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Daniel Doron @ 2017-08-15  8:02 UTC (permalink / raw)
  To: systemtap

Hi,

Is it possible to send via stap extra cflags?

I tried with "-D EXTRA_CFLAGS=-I$PWD"

but I get:
ERROR: Safety pattern mismatch for -D parameter
('EXTRA_CFLAGS=-I/home/danield/workspace/myproject' vs.
'^[a-z_][a-z_0-9]*(=-?[a-z_0-9]+)?$') rc=1


Thanks
Daniel.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding CFLAGS or EXTRA_CFLAGS
  2017-08-15  8:02 adding CFLAGS or EXTRA_CFLAGS Daniel Doron
@ 2017-08-15  8:36 ` Arkady
  2017-08-15  9:35 ` Arkady
  2017-08-15 17:44 ` David Smith
  2 siblings, 0 replies; 8+ messages in thread
From: Arkady @ 2017-08-15  8:36 UTC (permalink / raw)
  To: Daniel Doron; +Cc: systemtap

I think that you can add simple define symbols, but you can not add
include paths. I maintain large chunks of C code in the kernel module.
I include all C and H files into a single STP file. I considered
patching the SystemTap source to be able to control include
directories. In my case this feature would be Ok. For the generic
framework which target non root uses this is probably not a great
idea.

On Tue, Aug 15, 2017 at 11:02 AM, Daniel Doron
<danielmeirdoron@gmail.com> wrote:
> Hi,
>
> Is it possible to send via stap extra cflags?
>
> I tried with "-D EXTRA_CFLAGS=-I$PWD"
>
> but I get:
> ERROR: Safety pattern mismatch for -D parameter
> ('EXTRA_CFLAGS=-I/home/danield/workspace/myproject' vs.
> '^[a-z_][a-z_0-9]*(=-?[a-z_0-9]+)?$') rc=1
>
>
> Thanks
> Daniel.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding CFLAGS or EXTRA_CFLAGS
  2017-08-15  8:02 adding CFLAGS or EXTRA_CFLAGS Daniel Doron
  2017-08-15  8:36 ` Arkady
@ 2017-08-15  9:35 ` Arkady
  2017-08-15  9:43   ` Arkady
  2017-08-15 17:44 ` David Smith
  2 siblings, 1 reply; 8+ messages in thread
From: Arkady @ 2017-08-15  9:35 UTC (permalink / raw)
  To: Daniel Doron; +Cc: systemtap

If you use -B you do not change include path either. The include path
is specified in the kernel module makefile.

On Tue, Aug 15, 2017 at 11:02 AM, Daniel Doron
<danielmeirdoron@gmail.com> wrote:
> Hi,
>
> Is it possible to send via stap extra cflags?
>
> I tried with "-D EXTRA_CFLAGS=-I$PWD"
>
> but I get:
> ERROR: Safety pattern mismatch for -D parameter
> ('EXTRA_CFLAGS=-I/home/danield/workspace/myproject' vs.
> '^[a-z_][a-z_0-9]*(=-?[a-z_0-9]+)?$') rc=1
>
>
> Thanks
> Daniel.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding CFLAGS or EXTRA_CFLAGS
  2017-08-15  9:35 ` Arkady
@ 2017-08-15  9:43   ` Arkady
  2017-08-15 10:10     ` Daniel Doron
  0 siblings, 1 reply; 8+ messages in thread
From: Arkady @ 2017-08-15  9:43 UTC (permalink / raw)
  To: Daniel Doron; +Cc: systemtap

A sweet word "patch"
Another way to solve the problem is what I am using: a python script
which concatenates STP, C, H files into a single STP file, and makes
sure that the resulting STP is not broken.

On Tue, Aug 15, 2017 at 12:34 PM, Arkady <arkady.miasnikov@gmail.com> wrote:
> If you use -B you do not change include path either. The include path
> is specified in the kernel module makefile.
>
> On Tue, Aug 15, 2017 at 11:02 AM, Daniel Doron
> <danielmeirdoron@gmail.com> wrote:
>> Hi,
>>
>> Is it possible to send via stap extra cflags?
>>
>> I tried with "-D EXTRA_CFLAGS=-I$PWD"
>>
>> but I get:
>> ERROR: Safety pattern mismatch for -D parameter
>> ('EXTRA_CFLAGS=-I/home/danield/workspace/myproject' vs.
>> '^[a-z_][a-z_0-9]*(=-?[a-z_0-9]+)?$') rc=1
>>
>>
>> Thanks
>> Daniel.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding CFLAGS or EXTRA_CFLAGS
  2017-08-15  9:43   ` Arkady
@ 2017-08-15 10:10     ` Daniel Doron
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Doron @ 2017-08-15 10:10 UTC (permalink / raw)
  To: Arkady; +Cc: systemtap

ok. thanks.

On Tue, Aug 15, 2017 at 12:42 PM, Arkady <arkady.miasnikov@gmail.com> wrote:
> A sweet word "patch"
> Another way to solve the problem is what I am using: a python script
> which concatenates STP, C, H files into a single STP file, and makes
> sure that the resulting STP is not broken.
>
> On Tue, Aug 15, 2017 at 12:34 PM, Arkady <arkady.miasnikov@gmail.com> wrote:
>> If you use -B you do not change include path either. The include path
>> is specified in the kernel module makefile.
>>
>> On Tue, Aug 15, 2017 at 11:02 AM, Daniel Doron
>> <danielmeirdoron@gmail.com> wrote:
>>> Hi,
>>>
>>> Is it possible to send via stap extra cflags?
>>>
>>> I tried with "-D EXTRA_CFLAGS=-I$PWD"
>>>
>>> but I get:
>>> ERROR: Safety pattern mismatch for -D parameter
>>> ('EXTRA_CFLAGS=-I/home/danield/workspace/myproject' vs.
>>> '^[a-z_][a-z_0-9]*(=-?[a-z_0-9]+)?$') rc=1
>>>
>>>
>>> Thanks
>>> Daniel.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding CFLAGS or EXTRA_CFLAGS
  2017-08-15  8:02 adding CFLAGS or EXTRA_CFLAGS Daniel Doron
  2017-08-15  8:36 ` Arkady
  2017-08-15  9:35 ` Arkady
@ 2017-08-15 17:44 ` David Smith
  2017-08-16  4:51   ` Daniel Doron
  2 siblings, 1 reply; 8+ messages in thread
From: David Smith @ 2017-08-15 17:44 UTC (permalink / raw)
  To: Daniel Doron; +Cc: systemtap

On Tue, Aug 15, 2017 at 3:02 AM, Daniel Doron <danielmeirdoron@gmail.com> wrote:
> Hi,
>
> Is it possible to send via stap extra cflags?

Because of safety reasons, we don't really allow setting CFLAGS.

Perhaps we should back up a bit and ask why you are trying to add an
extra include path.

-- 
David Smith
Principal Software Engineer
Red Hat

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding CFLAGS or EXTRA_CFLAGS
  2017-08-15 17:44 ` David Smith
@ 2017-08-16  4:51   ` Daniel Doron
  2017-08-16 15:58     ` David Smith
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Doron @ 2017-08-16  4:51 UTC (permalink / raw)
  To: David Smith; +Cc: systemtap

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.

On Tue, Aug 15, 2017 at 8:44 PM, David Smith <dsmith@redhat.com> wrote:
> On Tue, Aug 15, 2017 at 3:02 AM, Daniel Doron <danielmeirdoron@gmail.com> wrote:
>> Hi,
>>
>> Is it possible to send via stap extra cflags?
>
> Because of safety reasons, we don't really allow setting CFLAGS.
>
> Perhaps we should back up a bit and ask why you are trying to add an
> extra include path.
>
> --
> David Smith
> Principal Software Engineer
> Red Hat

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: adding CFLAGS or EXTRA_CFLAGS
  2017-08-16  4:51   ` Daniel Doron
@ 2017-08-16 15:58     ` David Smith
  0 siblings, 0 replies; 8+ messages in thread
From: David Smith @ 2017-08-16 15:58 UTC (permalink / raw)
  To: Daniel Doron; +Cc: systemtap

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-08-16 15:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-15  8:02 adding CFLAGS or EXTRA_CFLAGS Daniel Doron
2017-08-15  8:36 ` Arkady
2017-08-15  9:35 ` Arkady
2017-08-15  9:43   ` Arkady
2017-08-15 10:10     ` Daniel Doron
2017-08-15 17:44 ` David Smith
2017-08-16  4:51   ` Daniel Doron
2017-08-16 15:58     ` David Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).