From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id 304A73858C20 for ; Tue, 9 Aug 2022 05:18:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 304A73858C20 Received: by mail-pj1-x1034.google.com with SMTP id t2-20020a17090a4e4200b001f21572f3a4so11212934pjl.0 for ; Mon, 08 Aug 2022 22:18:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=r5/jmOdnAjtYN//k+pJpmr3/Sxs4YvPW+NGnjqAF2vg=; b=BmsednCW6nIAG0B7glclTaPcJ+wsoBa3cS+uX3/wxRvKbCXJUeZxhzsjOzj+S8OH01 dU6t4R4InWvRh3TQnDFhNKPEm2cUgRyQ/lPNmTnmINjl/KB71Zhfs8/HMmsDWaGVch0o XZR6T+2d55Gv/quuDBO/OmnO/5TQEhZQII5IZP5W74iBnysJEnVreYphjKTXUnOYuD65 oNnlGnvCeZwJW3Sso/bO95pT7kRmpQT1+E+K5kuBUtil1TaSkBwibpsyNIUjX/M3VoQp bQxShSg3uXC26bJVUML3i+ZZ0fnu1sLeEnbgwa05nYrvLlSYzEXIWirBuwiuvGtjf16F wLJQ== X-Gm-Message-State: ACgBeo1K4XWO0iVOxXaosTGz3sqWJ/YcKNqLUcXbDPhb7ssUkp1uj8at 8baRdmrqR+I3L1ADOaBfhWiwVUQr+sGNSNFf2ySYCeA/zAjYqQ== X-Google-Smtp-Source: AA6agR4YsDGINRBLzKvuerBdE9VZotcrJt5LSfXThW0wPYH6INAqn0jHKnExUMBIuHDxCWxRvQrh0pvqqXeCP/OK3B4= X-Received: by 2002:a17:902:f70d:b0:16c:50a2:78d1 with SMTP id h13-20020a170902f70d00b0016c50a278d1mr21338906plo.34.1660022280184; Mon, 08 Aug 2022 22:18:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yeshpal Jain Date: Tue, 9 Aug 2022 10:47:49 +0530 Message-ID: Subject: Re: Run system tap with a user defined function To: "Bryn M. Reeves" Cc: systemtap@sourceware.org X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: systemtap@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Systemtap mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Aug 2022 05:18:03 -0000 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=3Dgnu89 -fno-PIE -DCC_HAVE_ASM_GOTO -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=3D1 -falign-loops=3D1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3D3 -mskip-rax-setup -mtune=3Dgeneric -mno-red-z= one -mcmodel=3Dkernel -funit-at-a-time -DCONFIG_AS_CFI=3D1 -DCONFIG_AS_CFI_SIGNAL_FRAME=3D1 -DCONFIG_AS_CFI_SECTIONS=3D1 -DCONFIG_AS_FXSAVEQ=3D1 -DCONFIG_AS_SSSE3=3D1 -DCONFIG_AS_CRC32=3D1 -DCONFIG_AS_AVX=3D1 -DCONFIG_AS_AVX2=3D1 -DCONFIG_AS_AVX512=3D1 -DCONFIG_AS_SHA1_NI=3D1 -DCONFIG_AS_SHA256_NI=3D1 -DCONFIG_TPAUSE=3D1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=3Dthunk-extern -mindirect-branch-register -fno-jump-table= s -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -O2 --param=3Dallow-store-data-races=3D0 -Wframe-larger-than=3D2048 -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=3Dimplicit-int -Werror=3Dstrict-prototypes -Werror=3Ddate-time -Werror=3Dincompatible-pointer-types -Werror=3Ddesignated-init -fmacro-prefix-map=3D./=3D -Wno-packed-not-aligned -Iinclude2/asm/mach-defa= ult -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=3D'"stap_symbols"' -DKBUILD_MODNAME=3D'"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 wrote: > On Sun, Aug 07, 2022 at 09:39:23PM +0530, Yeshpal Jain via Systemtap wrot= e: > > 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 =3D (struct phase *)((long)STAP_ARG_phase= ); > > int phase_st =3D 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 =3D %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 =E2=80=98struct phase= =E2=80=99 > > 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 > %} > > ... rest of script > > Regards, > Bryn. > > --=20 Thanks and Regards, Yeshpal Jain.