Hi. I am trying to use the -C option to include a file so I can use #define''s in the file. This is part of a larger script: ------------------------------------------------------- #!/usr/sbin/dtrace -Cs #include <sys/stream.h> strrput:entry / args[0]->q_stream->sd_vnode == (struct vnode *)$1 && args[1]->b_datap->db_type == M_DATA / { printf("strrput mp = %p\n", args[1]); printf("mp->b_rptr = %*.*s\n", args[1]->b_wptr-args[1]->b_rptr, args[1]->b_wptr-args[1]->b_rptr, stringof(args[1]->b_rptr)); } ----------------------------------------------------- At any rate, without the -C, I can''t use #include <sys/stream.h>. Without the #include <sys/stream.h>, I can''t use the M_DATA. As it is, I get the following: # ./strrput.d 0xd595a6c0 <-- this is a vnode for a socket ftp is using (not important here) dtrace: failed to compile script ./strrput.d: line 7: sd_vnode is not a member of struct stdata # sd_vnode is definitely a member, so I tried using #define _KERNEL in the script, and then I get an error: dtrace: failed to compile script ./strrput.d: "/usr/include/sys/kstat.h", line 439: invalid type combination Anyone have any luck with using the preprocessor? thanks, max _______________________________________________ DTrace mailing list DTrace@opensolaris.org https://www.opensolaris.org/mailman/listinfo/dtrace
Thanks Philip. The easy fix (use #define M_DATA 0x00) I had done before I sent the original email. I don''t mind work-arounds, I just wanted to make sure I wasn''t missing anything. max On Sat, 2005-01-01 at 13:12, Philip Beevers wrote:> Hi Max/DTrace list, > > > At any rate, without the -C, I can''t use #include <sys/stream.h>. > > Without the #include <sys/stream.h>, I can''t use the M_DATA. > > As it is, I get the following: > > > > # ./strrput.d 0xd595a6c0 <-- this is a vnode for a socket > > ftp is using (not important here) > > dtrace: failed to compile script ./strrput.d: line 7: > > sd_vnode is not a member of struct stdata > > # > > > > sd_vnode is definitely a member, so I tried using #define > > _KERNEL in the script, and then I get an error: > > dtrace: failed to compile script ./strrput.d: > > "/usr/include/sys/kstat.h", line 439: invalid type combination > > Checking line 439 of that file... > > 423 typedef struct kstat_named { > > 424 char name[KSTAT_STRLEN]; /* name of counter */ > > 425 uchar_t data_type; /* data type */ > > 426 union { > > 427 char c[16]; /* enough for 128-bit ints */ > > 428 int32_t i32; > > 429 uint32_t ui32; > > 430 struct { > > 431 union { > > 432 char *ptr; /* NULL-term string */ > > 433 #if defined(_KERNEL) && defined(_MULTI_DATAMODEL) > > 434 caddr32_t ptr32; > > 435 #endif > > 436 char __pad[8]; /* 64-bit padding */ > > 437 } addr; > > 438 uint32_t len; /* # bytes for strlen + ''\0'' */ > > 439 } string; > > > What seems to be happening is that DTrace is getting confused with this > definition of a type called "string", and the internal D type "string". > > I can''t take the credit for finding this though - a friend within Sun > pointed out he''s raised this already (thanks Jon!) as CR 6207207 (Synopsis: > string definition in kstat.h conflicts with built in string type), and you > can work around it with something like: > > #define string __C_string > > to change the typedef so it defines a different type. > > As you say, -D_KERNEL is necessary to pull in the definition of struct > stdata - it isn''t there otherwise, which I think is why you''re seeing this: > > > dtrace: failed to compile script ./strrput.d: line 7: > > sd_vnode is not a member of struct stdata > > Alternatively you can just include sys/strsubr.h before sys/stream.h, which > has the same effect as -D_KERNEL in terms of ensuring struct stdata is > defined; you then get the same problem with the duplicate string definition, > though. But going back to the original problem: > > > At any rate, without the -C, I can''t use #include <sys/stream.h>. > > Without the #include <sys/stream.h>, I can''t use the M_DATA. > > As the typing works magically without the include, maybe it''s better just to > hard-code the value of M_DATA, or if you want to continue to use the name, > simply copy the definition, e.g. > > #!/usr/sbin/dtrace -Cs > > /* Copied from /usr/include/sys/stream.h */ > #define M_DATA 0x00 > > strrput:entry > ... etc etc ... > > -- > > Philip Beevers > Fidessa Infrastructure Development > > mailto:philip.beevers@fidessa.com > phone: +44 1483 206571 > > > > -----Original Message----- > > From: Max Bruning [mailto:max@bruningsystems.com] > > Sent: 29 December 2004 01:42 > > To: dtrace@opensolaris.org > > Subject: [DTrace] using C preprocessor in dtrace scripts > > > > > > Hi. > > I am trying to use the -C option to include a file so > > I can use #define''s in the file. > > > > This is part of a larger script: > > ------------------------------------------------------- > > > > #!/usr/sbin/dtrace -Cs > > > > #include <sys/stream.h> > > > > strrput:entry > > / > > args[0]->q_stream->sd_vnode == (struct vnode *)$1 > > && args[1]->b_datap->db_type == M_DATA > > / > > { > > printf("strrput mp = %p\n", args[1]); > > printf("mp->b_rptr = %*.*s\n", > > args[1]->b_wptr-args[1]->b_rptr, > > args[1]->b_wptr-args[1]->b_rptr, stringof(args[1]->b_rptr)); > > } > > > > ----------------------------------------------------- > > > > At any rate, without the -C, I can''t use #include <sys/stream.h>. > > Without the #include <sys/stream.h>, I can''t use the M_DATA. > > As it is, I get the following: > > > > # ./strrput.d 0xd595a6c0 <-- this is a vnode for a socket > > ftp is using (not important here) > > dtrace: failed to compile script ./strrput.d: line 7: > > sd_vnode is not a member of struct stdata > > # > > > > sd_vnode is definitely a member, so I tried using #define > > _KERNEL in the script, and then I get an error: > > dtrace: failed to compile script ./strrput.d: > > "/usr/include/sys/kstat.h", line 439: invalid type combination > > > > Anyone have any luck with using the preprocessor? > > > > thanks, > > max > > > > > > > > > > _______________________________________________ > > DTrace mailing list > > DTrace@opensolaris.org > > https://www.opensolaris.org/mailman/listinfo/dtrace > > > _______________________________________________ > DTrace mailing list > DTrace@opensolaris.org > https://www.opensolaris.org/mailman/listinfo/dtrace >_______________________________________________ DTrace mailing list DTrace@opensolaris.org https://www.opensolaris.org/mailman/listinfo/dtrace
Hi Max/DTrace list,> At any rate, without the -C, I can''t use #include <sys/stream.h>. > Without the #include <sys/stream.h>, I can''t use the M_DATA. > As it is, I get the following: > > # ./strrput.d 0xd595a6c0 <-- this is a vnode for a socket > ftp is using (not important here) > dtrace: failed to compile script ./strrput.d: line 7: > sd_vnode is not a member of struct stdata > # > > sd_vnode is definitely a member, so I tried using #define > _KERNEL in the script, and then I get an error: > dtrace: failed to compile script ./strrput.d: > "/usr/include/sys/kstat.h", line 439: invalid type combinationChecking line 439 of that file... 423 typedef struct kstat_named { 424 char name[KSTAT_STRLEN]; /* name of counter */ 425 uchar_t data_type; /* data type */ 426 union { 427 char c[16]; /* enough for 128-bit ints */ 428 int32_t i32; 429 uint32_t ui32; 430 struct { 431 union { 432 char *ptr; /* NULL-term string */ 433 #if defined(_KERNEL) && defined(_MULTI_DATAMODEL) 434 caddr32_t ptr32; 435 #endif 436 char __pad[8]; /* 64-bit padding */ 437 } addr; 438 uint32_t len; /* # bytes for strlen + ''\0'' */ 439 } string; What seems to be happening is that DTrace is getting confused with this definition of a type called "string", and the internal D type "string". I can''t take the credit for finding this though - a friend within Sun pointed out he''s raised this already (thanks Jon!) as CR 6207207 (Synopsis: string definition in kstat.h conflicts with built in string type), and you can work around it with something like: #define string __C_string to change the typedef so it defines a different type. As you say, -D_KERNEL is necessary to pull in the definition of struct stdata - it isn''t there otherwise, which I think is why you''re seeing this:> dtrace: failed to compile script ./strrput.d: line 7: > sd_vnode is not a member of struct stdataAlternatively you can just include sys/strsubr.h before sys/stream.h, which has the same effect as -D_KERNEL in terms of ensuring struct stdata is defined; you then get the same problem with the duplicate string definition, though. But going back to the original problem:> At any rate, without the -C, I can''t use #include <sys/stream.h>. > Without the #include <sys/stream.h>, I can''t use the M_DATA.As the typing works magically without the include, maybe it''s better just to hard-code the value of M_DATA, or if you want to continue to use the name, simply copy the definition, e.g. #!/usr/sbin/dtrace -Cs /* Copied from /usr/include/sys/stream.h */ #define M_DATA 0x00 strrput:entry ... etc etc ... -- Philip Beevers Fidessa Infrastructure Development mailto:philip.beevers@fidessa.com phone: +44 1483 206571> -----Original Message----- > From: Max Bruning [mailto:max@bruningsystems.com] > Sent: 29 December 2004 01:42 > To: dtrace@opensolaris.org > Subject: [DTrace] using C preprocessor in dtrace scripts > > > Hi. > I am trying to use the -C option to include a file so > I can use #define''s in the file. > > This is part of a larger script: > ------------------------------------------------------- > > #!/usr/sbin/dtrace -Cs > > #include <sys/stream.h> > > strrput:entry > / > args[0]->q_stream->sd_vnode == (struct vnode *)$1 > && args[1]->b_datap->db_type == M_DATA > / > { > printf("strrput mp = %p\n", args[1]); > printf("mp->b_rptr = %*.*s\n", > args[1]->b_wptr-args[1]->b_rptr, > args[1]->b_wptr-args[1]->b_rptr, stringof(args[1]->b_rptr)); > } > > ----------------------------------------------------- > > At any rate, without the -C, I can''t use #include <sys/stream.h>. > Without the #include <sys/stream.h>, I can''t use the M_DATA. > As it is, I get the following: > > # ./strrput.d 0xd595a6c0 <-- this is a vnode for a socket > ftp is using (not important here) > dtrace: failed to compile script ./strrput.d: line 7: > sd_vnode is not a member of struct stdata > # > > sd_vnode is definitely a member, so I tried using #define > _KERNEL in the script, and then I get an error: > dtrace: failed to compile script ./strrput.d: > "/usr/include/sys/kstat.h", line 439: invalid type combination > > Anyone have any luck with using the preprocessor? > > thanks, > max > > > > > _______________________________________________ > DTrace mailing list > DTrace@opensolaris.org > https://www.opensolaris.org/mailman/listinfo/dtrace >_______________________________________________ DTrace mailing list DTrace@opensolaris.org https://www.opensolaris.org/mailman/listinfo/dtrace