Vladimir Kotal
2011-04-14 10:19:03 UTC
Hi again,
I am trying to construct set of scripts with common translator
definitions stored in separate header file (so that all the scripts can
use it):
$ cat xlate.h
#include <sys/types.h>
inline string state_string[int32_t state] =
state == 0 ? "initial" :
state == 1 ? "other" :
state == 2 ? "next" :
"<unknown>";
$ cat state.d
#!/usr/sbin/dtrace -I. -Cs
#include "xlate.h"
BEGIN
{
printf("%s", state_string[1]);
}
However, it fails with:
$ chmod +x ./state.d
$ ./state.d
dtrace: no probes specified
$ dtrace -I. -Cs state.d
dtrace: failed to compile script state.d: "./xlate.h", line 8: failed to
resolve type string: Unknown type name
If I concatenate the 2 files together it works fine:
$ cat concat.d
inline string state_string[int32_t state] =
state == 0 ? "initial" :
state == 1 ? "other" :
state == 2 ? "next" :
"<unknown>";
BEGIN
{
printf("%s", state_string[1]);
}
$ dtrace -s concat.d
dtrace: script 'concat.d' matched 1 probe
CPU ID FUNCTION:NAME
1 1 :BEGIN other
^C
Any clues what I am doing wrong ?
v.
I am trying to construct set of scripts with common translator
definitions stored in separate header file (so that all the scripts can
use it):
$ cat xlate.h
#include <sys/types.h>
inline string state_string[int32_t state] =
state == 0 ? "initial" :
state == 1 ? "other" :
state == 2 ? "next" :
"<unknown>";
$ cat state.d
#!/usr/sbin/dtrace -I. -Cs
#include "xlate.h"
BEGIN
{
printf("%s", state_string[1]);
}
However, it fails with:
$ chmod +x ./state.d
$ ./state.d
dtrace: no probes specified
$ dtrace -I. -Cs state.d
dtrace: failed to compile script state.d: "./xlate.h", line 8: failed to
resolve type string: Unknown type name
If I concatenate the 2 files together it works fine:
$ cat concat.d
inline string state_string[int32_t state] =
state == 0 ? "initial" :
state == 1 ? "other" :
state == 2 ? "next" :
"<unknown>";
BEGIN
{
printf("%s", state_string[1]);
}
$ dtrace -s concat.d
dtrace: script 'concat.d' matched 1 probe
CPU ID FUNCTION:NAME
1 1 :BEGIN other
^C
Any clues what I am doing wrong ?
v.