public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Yeshpal Jain <jainyeshpal@gmail.com>
To: "Bryn M. Reeves" <breeves@redhat.com>
Cc: systemtap@sourceware.org
Subject: Re: Run system tap with a user defined function
Date: Tue, 9 Aug 2022 10:47:49 +0530	[thread overview]
Message-ID: <CAH67PmN20MWXykjDdxH42uyGWXkD+fMpV7RHndkK+ps+NHH5QA@mail.gmail.com> (raw)
In-Reply-To: <YvDXs3yywR8jkZkC@redhat.com>

Thanks for your reply,
Is there a way i can add my header path in stap common so that it looks in
my header path, when i try to add a header it is erroring out because other
files in myheader.h are not accessible, if somehow i can include the header
path in compilation command then that should resolve this problem.
Below is the command which stap will execute.

 gcc -Wp,-MD,/tmp/stap0qTelA/.stap_symbols.o.d  -nostdinc -isystem
/usr/lib/gcc/x86_64-redhat-linux/8/include -I./arch/x86/include
-I./arch/x86/include/generated   -I./include/drm-backport -I./include
-I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi
-I./include/uapi -I./include/generated/uapi -include
./include/linux/kconfig.h -include ./include/linux/compiler_types.h
-D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -fshort-wchar
-Werror-implicit-function-declaration -Wno-format-security -std=gnu89
-fno-PIE -DCC_HAVE_ASM_GOTO -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
-m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387
-mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone
-mcmodel=kernel -funit-at-a-time -DCONFIG_AS_CFI=1
-DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1
-DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1
-DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1
-DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -DCONFIG_TPAUSE=1 -pipe
-Wno-sign-compare -fno-asynchronous-unwind-tables
-mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables
-fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation
-Wno-format-overflow -Wno-int-in-bool-context -O2
--param=allow-store-data-races=0 -Wframe-larger-than=2048
-fstack-protector-strong -Wno-unused-but-set-variable
-Wno-unused-const-variable -gdwarf-4 -pg -mrecord-mcount -mfentry
-DCC_USING_FENTRY -fno-inline-functions-called-once
-Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation
-fno-strict-overflow -fno-merge-all-constants -fmerge-constants
-fno-stack-check -fconserve-stack -Werror=implicit-int
-Werror=strict-prototypes -Werror=date-time
-Werror=incompatible-pointer-types -Werror=designated-init
-fmacro-prefix-map=./= -Wno-packed-not-aligned -Iinclude2/asm/mach-default
-I/lib/modules/4.18.0-305.3.1.el8_4.x86_64/build -include
/tmp/stap0qTelA/stapconf_ee8a8c12ef5d50607466e03c8831c981_784.h
-freorder-blocks -fasynchronous-unwind-tables -fno-ipa-icf -Wno-unused
-Werror -Wno-pragmas -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
-I/usr/share/systemtap/runtime  -DMODULE
 -DKBUILD_BASENAME='"stap_symbols"' -DKBUILD_MODNAME='"stap_3268232"' -c -o
/tmp/stap0qTelA/stap_symbols.o /tmp/stap0qTelA/stap_symbols.c

Regards,
Yeshpal.

On Mon, Aug 8, 2022 at 3:00 PM Bryn M. Reeves <breeves@redhat.com> wrote:

> On Sun, Aug 07, 2022 at 09:39:23PM +0530, Yeshpal Jain via Systemtap wrote:
> > I want to run a user defined function inside one of the function probes.
> > for ex :
> > #! /usr/bin/env stap
> >
> >
> > function __read_phase:long(phase:long) %{ /* pure */
> >         struct phase *phase_s = (struct phase *)((long)STAP_ARG_phase);
> >         int phase_st = phase->p_state;
> >         STAP_RETURN(phase_st);
> > %} /* <-- function body */
> >
> > function trace_phase(entry_p, extra) {
> >   %( $# > 1 %? if (tid() in trace) %)
> >                   printf("%s%s%s %s phase = %d\n",
> >                                   thread_indent (entry_p),
> >                                   (entry_p>0?"->":"<-"),
> >                                   ppfunc (),
> >                                   extra, __read_phase($fom))
> >
> > }
> >
> > probe process("/root/test/.libs/mylib.so").function("*_test_func").call
>  {
> > trace_phase(1, $$parms) }
> >
> > i am running stap with -g option,
> > when i compile i am getting error,
> > error: dereferencing pointer to incomplete type ‘struct phase’
> > struct phase is a structure defined in mylibrary,
> > Is there a way to include custom directory/headers while generating
> system
> > tap.
>
> Just put the include directives inside %{..%} at file level, e.g.:
>
>   %{
>   #include <myheader.h>
>   %}
>
>   ... rest of script
>
> Regards,
> Bryn.
>
>

-- 
Thanks and Regards,
Yeshpal Jain.

  reply	other threads:[~2022-08-09  5:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-07 16:09 Yeshpal Jain
2022-08-08  9:30 ` Bryn M. Reeves
2022-08-09  5:17   ` Yeshpal Jain [this message]
2022-08-12  7:16     ` Yeshpal Jain
2022-08-16 17:53 ` Frank Ch. Eigler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH67PmN20MWXykjDdxH42uyGWXkD+fMpV7RHndkK+ps+NHH5QA@mail.gmail.com \
    --to=jainyeshpal@gmail.com \
    --cc=breeves@redhat.com \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).