From: fche@redhat.com (Frank Ch. Eigler)
To: Yeshpal Jain <jainyeshpal@gmail.com>
Cc: systemtap@sourceware.org
Subject: Re: Run system tap with a user defined function
Date: Tue, 16 Aug 2022 13:53:20 -0400 [thread overview]
Message-ID: <87mtc4hy7j.fsf@redhat.com> (raw)
In-Reply-To: <CAH67PmMAQjodRctsCo+V1t83oyNnmJ+AgqpeWsoRVS8DCszSwA@mail.gmail.com> (Yeshpal Jain via Systemtap's message of "Sun, 7 Aug 2022 21:39:23 +0530")
Yeshpal Jain via Systemtap <systemtap@sourceware.org> 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 <stdio.h>,
which is a userspace header.
You might find it simpler to code this up as pure script code:
{ ...
print ("%s", @cast($fom, "phase", "<mylibrary/phase.h>")->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
prev parent reply other threads:[~2022-08-16 17:53 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
2022-08-12 7:16 ` Yeshpal Jain
2022-08-16 17:53 ` Frank Ch. Eigler [this message]
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=87mtc4hy7j.fsf@redhat.com \
--to=fche@redhat.com \
--cc=jainyeshpal@gmail.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).