Hye everybody, I''m trying to use the tcpsnoop.d script which comes from the Dtrace Toolkit, with the Dtrace java api. But it doesn''t work, I''ve got a invalid control directive exception on the #include directive. What have I got to do to make the java api accept scripts which contain a #include ? I''m using the java api which is bundled with Solaris Express Developper Edition Thanks in advance Cydrike -- This message posted from opensolaris.org
Make sure your dtrace invocation includes -C to run the C preprocessor. (either the first #! line of the script, or the dtrace command you type.) C?dric wrote:> Hye everybody, > > I''m trying to use the tcpsnoop.d script which comes from the Dtrace Toolkit, with the Dtrace java api. > But it doesn''t work, I''ve got a invalid control directive exception on the #include directive. > What have I got to do to make the java api accept scripts which contain a #include ? > > I''m using the java api which is bundled with Solaris Express Developper Edition > > Thanks in advance > > Cydrike > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
The call to set the cpp option using the Java DTrace API looks like this: consumer.setOption(Option.cpp); and it needs to be called before consumer.compile(). If you''ve already done that, and it still isn''t working, you''re probably compiling a program string instead of a file. The DTrace library will not run the precompiler on program strings, so you need to use compile(File program, String ... macroArgs) instead of compile(String program, String ... macroArgs) Chime works around this problem, allowing program strings with #include, by creating a temporary file: http://www.opensolaris.org/os/project/dtrace-chime/changelog/issues/#Preprocessor_statements_fail_to_compile See also this thread: http://www.opensolaris.org/jive/thread.jspa?messageID=56009 Tom -- This message posted from opensolaris.org
Hey, thanks for helping me. You were right. I didn''t know about the consumer.setOption(Option.cpp); I''ve just added this line and now it works very well. Thanks a lot Cydrike -- This message posted from opensolaris.org