This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
RE: Issue related to systemtap output in guru mode
Jim Keniston wrote:
> On Tue, 2007-09-18 at 19:50 +0530, ramya rao wrote:
>> [...]
>> I would like to illustrate with a simple example as shown below:
>>
>> Code snippet for hello world program
>>
>> #!/usr/bin/stap -g
>>
>> //hello_world.stp - prints hello world
>>
>> function print_hello() %{
>>
>> printf ("Hello World\n");
>>
>> %}
>
> Change "%{" to "{" and change "%}" to "}", and this will work. (You
> don't even need guru mode.)
>
> Code between %{ ... %} is interpreted as embedded C code, to be
> included as-is in the stap-generated kernel module. Since the kernel
> has no printf function, this yields an error.
>
> printf, as used in SystemTap scripts, is basically built into the
> SystemTap language.
Generally, yes, you should avoid embedded-C where possible. If you can
collect your special data from embedded-C and then return it to a normal
function for printing, then that's preferable.
Sometimes it's inconvenient to pass data around though, so if you really
want to print from an embedded-C function, you can use _stp_printf().
Josh