On Fri, Oct 24, 2008 at 01:04:41PM -0700, Adam Mitchell wrote: > I am using the "-C" option to invoke the C preprocessor and include > Apache's httpd.h in a dtrace script. This lets me dereference > Apache's request_rec struct and pull some great per-request details. > > But it won't work "out of the box." Dtrace (or the D compiler in > libdtrace) fails to parse the cpp output. I have to run cpp manually > on httpd.h, saving the output to a monolithic dot-h file and then > iteratively remove lines from that file when Dtrace complains about > them until I have a "working" file. After that, it's just awesome. > > I guess my question is, is there any Dtrace debug flag that will give > me more information on the parse error? Where are the "-x" (compiler > and tracing) options defined? If I understood the parse error (found > ABC but expecting XYZ), maybe I could contribute something back.
The D compiler defaults to the pre-ansi-C precompiler /usr/ccs/lib/cpp, since that is the only one guaranteed to be on the system. Since it is pre-ANSI C, constructs like "#" and "##" will confuse it. You can specify a different preprocessor using the -xcpppath=/path/to/cpp Cheers, - jonathan > > Here's all I see now: > > $ sudo dtrace -32 -C -I /export/home/amitchel/include -s > watchApacheRequestsTestingCPP.d -p 16770 > dtrace: failed to compile script watchApacheRequestsTestingCPP.d: > "/export/home/amitchel/include/apr_thread_mutex.h", line 100: syntax error > near "#" > > > Line 100 is: > APR_POOL_DECLARE_ACCESSOR(thread_mutex); > > > My script is: > > $ cat watchApacheRequestsTestingCPP.d > #!/usr/sbin/dtrace > > #include <httpd.h> > > pid$target:a.out:ap_process_request:entry > { > > self->ts = timestamp; > self->r = (request_rec*) copyin(arg0, sizeof(request_rec)); > self->uri = copyinstr((uintptr_t) self->r->uri); > > } > > > pid$target:a.out:ap_process_request:return > /self->ts/ > { > @request_uris[self->uri] = quantize((timestamp - self->ts) / 1000000); > self->ts = 0; > self->uri = "err"; > } > > tick-5s > { > printa(@request_uris); > } > -- > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss@opensolaris.org _______________________________________________ dtrace-discuss mailing list dtrace-discuss@opensolaris.org