From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BDE063858C2D for ; Tue, 16 Aug 2022 17:53:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BDE063858C2D Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-577-A8bbN4KlPb6UxieylEXWcQ-1; Tue, 16 Aug 2022 13:53:22 -0400 X-MC-Unique: A8bbN4KlPb6UxieylEXWcQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EB2403C11982; Tue, 16 Aug 2022 17:53:21 +0000 (UTC) Received: from redhat.com (unknown [10.2.17.198]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC7B2C15BA6; Tue, 16 Aug 2022 17:53:21 +0000 (UTC) Received: from [127.0.0.1] (helo=vm-rhel7) by redhat.com with esmtp (Exim 4.94.2) (envelope-from ) id 1oO0ki-0002c0-II; Tue, 16 Aug 2022 13:53:21 -0400 From: fche@redhat.com (Frank Ch. Eigler) To: Yeshpal Jain Cc: systemtap@sourceware.org Subject: Re: Run system tap with a user defined function References: Date: Tue, 16 Aug 2022 13:53:20 -0400 In-Reply-To: (Yeshpal Jain via Systemtap's message of "Sun, 7 Aug 2022 21:39:23 +0530") Message-ID: <87mtc4hy7j.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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 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, 16 Aug 2022 17:53:24 -0000 Yeshpal Jain via Systemtap writes: > 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 */ Keeping in mind that, by default, you're using the linux kernel runtime, this means that any declarations your embedded-C code needs need to be included manually (like Bryn said), but in such a way that a kernel-oriented module build can use it. So no #include , which is a userspace header. You might find it simpler to code this up as pure script code: { ... print ("%s", @cast($fom, "phase", "")->p_state; ... } In this case, @cast() takes a -userpace- header file name, and should generate enough debuginfo out of it to let the ->p_state part resolve naturally. As a bonus, no -g guru mode required. - FChE