Howdy, While attempting to access the rnode_t type and the VTOR() macro in /usr/include/nfs/rnode.h, I bumped into another preprocessor issue: $ uname -a SunOS winnie 5.11 opensol-b37 sun4u sparc SUNW,Ultra-5_10 $ dtrace -C -s ick.d "/dev/fd/4", line 2: #include of /usr/include/... may be non-portable dtrace: failed to compile script ick.d: "/usr/include/nfs/rnode.h", line 164: syntax error near "kthread_t" $ cat ick.d #include "/usr/include/nfs/rnode.h" fbt:nfs:nfs3_access:entry { } Anyone happen to know what is causing this? Since rnode.h is a Sun supplied header file, I would think it should just work. Thanks, - Ryan -- UNIX Administrator http://daemons.net/~matty
Nicolas Williams
2006-Apr-17 05:08 UTC
[dtrace-discuss] Problems including Sun supplied header files
On Sun, Apr 16, 2006 at 11:45:50PM -0400, Matty wrote:> While attempting to access the rnode_t type and the VTOR() macro in > /usr/include/nfs/rnode.h, I bumped into another preprocessor issue: > > $ uname -a > SunOS winnie 5.11 opensol-b37 sun4u sparc SUNW,Ultra-5_10 > > $ dtrace -C -s ick.d > "/dev/fd/4", line 2: #include of /usr/include/... may be non-portable > dtrace: failed to compile script ick.d: "/usr/include/nfs/rnode.h", line > 164: syntax error near "kthread_t"Try including <sys/thread.h>... # cat /tmp/ick.d #include <sys/thread.h> #include <nfs/rnode.h> fbt:nfs:nfs3_access:entry { } # dtrace -C -s /tmp/ick.d dtrace: script ''/tmp/ick.d'' matched 1 probe ^C #> Anyone happen to know what is causing this? Since rnode.h is a Sun > supplied header file, I would think it should just work.Perhaps <nfs/rnode.h> or <nfs/nfs.h> ought to include <sys/thread.h>... Five headers in /usr/include/nfs/ reference kthread_t. Nico --
Eric Schrock
2006-Apr-17 05:12 UTC
[dtrace-discuss] Problems including Sun supplied header files
This doesn''t seem to be a DTrace issue, and is easily reproduced if you try to compile a .c file that only includes this header file. Looks like it uses ''kthread_t'' but doesn''t bring in sys/thread.h, presumably because all the current consumers include it manually beforehand. Feel free to file a bug. In the meantime you can just include <sys/thread.h> before <nfs/rnode.h>. Hope that helps, - Eric On Sun, Apr 16, 2006 at 11:45:50PM -0400, Matty wrote:> > Howdy, > > While attempting to access the rnode_t type and the VTOR() macro in > /usr/include/nfs/rnode.h, I bumped into another preprocessor issue: > > $ uname -a > SunOS winnie 5.11 opensol-b37 sun4u sparc SUNW,Ultra-5_10 > > $ dtrace -C -s ick.d > "/dev/fd/4", line 2: #include of /usr/include/... may be non-portable > dtrace: failed to compile script ick.d: "/usr/include/nfs/rnode.h", line > 164: syntax error near "kthread_t" > > $ cat ick.d > #include "/usr/include/nfs/rnode.h" > > fbt:nfs:nfs3_access:entry > { > } > > Anyone happen to know what is causing this? Since rnode.h is a Sun > supplied header file, I would think it should just work. > > Thanks, > - Ryan > -- > UNIX Administrator > http://daemons.net/~matty > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Eric Schrock, Solaris Kernel Development http://blogs.sun.com/eschrock
Casper.Dik at Sun.COM
2006-Apr-17 07:53 UTC
[dtrace-discuss] Problems including Sun supplied header files
>While attempting to access the rnode_t type and the VTOR() macro in >/usr/include/nfs/rnode.h, I bumped into another preprocessor issue:Dtrace doesn''t allow including random C .h files. The rnode_t is known to dtrace because it''s compiled into the kernel (CTF is used to store compiled type information in the kernel)>Anyone happen to know what is causing this? Since rnode.h is a Sun >supplied header file, I would think it should just work.If included in a kernel module, yes. Not in D. Casper
On Mon, 17 Apr 2006, Casper.Dik at Sun.COM wrote:> >> While attempting to access the rnode_t type and the VTOR() macro in >> /usr/include/nfs/rnode.h, I bumped into another preprocessor issue: > > Dtrace doesn''t allow including random C .h files.I was under the impression that you could use #include to add header files with types and macros? A quick search through the "Bin" directory in the DTraceToolkit seems to indicate that this is possible: $ grep include tcpsnoop #include <sys/file.h> #include <inet/common.h> #include <sys/byteorder.h> #include <sys/socket.h> #include <sys/socketvar.h> Can someone from the DTrace team shed some light on this for me? I am getting conflicting information.> The rnode_t is known to dtrace because it''s compiled into the kernel > (CTF is used to store compiled type information in the kernel) > >> Anyone happen to know what is causing this? Since rnode.h is a Sun >> supplied header file, I would think it should just work. > > If included in a kernel module, yes. Not in D.Type information is available, but macro definitions are not. I want to use macros from /usr/include/* in my scripts to simplify the implementation. Thanks, - Ryan -- UNIX Administrator http://daemons.net/~matty
Bryan Cantrill
2006-Apr-17 16:04 UTC
[dtrace-discuss] Problems including Sun supplied header files
On Mon, Apr 17, 2006 at 10:28:28AM -0400, Matty wrote:> On Mon, 17 Apr 2006, Casper.Dik at Sun.COM wrote: > > > > >>While attempting to access the rnode_t type and the VTOR() macro in > >>/usr/include/nfs/rnode.h, I bumped into another preprocessor issue: > > > >Dtrace doesn''t allow including random C .h files.That''s incorrect -- DTrace _does_ allow including C header files, with the caveat that there are some constructs that a C compiler can absorb in a C header file that the D compiler will choke on. The most obvious of these is the use of D keywords -- if you have a type named "string" D won''t be able to compile it. Slightly more subtle is the declaration of complete functions and/or static globals in C header files. This is an absolutely terrible practice (absent optimization, the text for the function and/or the data for the global will exist in every object that includes the file), and solving it is very hard for D. (It''s one thing to be able to deal with C structure and type definitions, but quite another to be able to parse arbitrary C.) So if you run into this issue, you will need to either (1) find a way to not include the header file or (2) wrap the definition with "#ifndef __SUNW_D". Finally, you might run into preprocessor directives that are not supported by the (ancient) version of cpp that we run. (An example of such a directive is ''##'', used (ironically) in /usr/include/sys/dtrace.h.) If you get nailed by this, try GCC''s cpp, as outlined on slide 46 of the "Advanced DTrace" presentation: http://blogs.sun.com/roller/page/bmc?entry=dtrace_tips_tricks_and_gotchas> I was under the impression that you could use #include to add header files > with types and macros?Yes, that''s correct. And we actually test that we can include every file in /usr/include/sys that can be successfully compiled by including it alone. (As of this writing, there are four exceptions on 64-bit, five on 32-bit.) Of course, we wouldn''t have picked up your rnode.h problem because (1) it''s in /usr/include/nfs (we should add that to the list) and (2) it can''t be compiled by including it alone (and as Eric mentioned, this is just a bug in rnode.h). - Bryan -------------------------------------------------------------------------- Bryan Cantrill, Solaris Kernel Development. http://blogs.sun.com/bmc
Casper.Dik at Sun.COM
2006-Apr-17 17:02 UTC
[dtrace-discuss] Problems including Sun supplied header files
>>> While attempting to access the rnode_t type and the VTOR() macro in >>> /usr/include/nfs/rnode.h, I bumped into another preprocessor issue: >> >> Dtrace doesn''t allow including random C .h files. > >I was under the impression that you could use #include to add header files >with types and macros? A quick search through the "Bin" directory in the >DTraceToolkit seems to indicate that this is possible:Hm, I was not quite expecting that. And generally for types this is not required. And since D isn''t C I expect that: - there''s not testing that it''s still valid D syntax - it may fail at any time.>$ grep include tcpsnoop >#include <sys/file.h> >#include <inet/common.h> >#include <sys/byteorder.h> >#include <sys/socket.h> >#include <sys/socketvar.h>Interesting.>Type information is available, but macro definitions are not. I want to >use macros from /usr/include/* in my scripts to simplify the >implementation.Ah, Casper
On Mon, 17 Apr 2006, Bryan Cantrill wrote:>> I was under the impression that you could use #include to add header files >> with types and macros? > > Yes, that''s correct. And we actually test that we can include every > file in /usr/include/sys that can be successfully compiled by including > it alone. (As of this writing, there are four exceptions on 64-bit, > five on 32-bit.) Of course, we wouldn''t have picked up your rnode.h problem > because (1) it''s in /usr/include/nfs (we should add that to the list) and > (2) it can''t be compiled by including it alone (and as Eric mentioned, this > is just a bug in rnode.h).Thanks for the clarification. I filed CR #6413818 to address the bug I bumped into. Thanks, - Ryan -- UNIX Administrator http://daemons.net/~matty