Permalink
Browse files

work around a bug in dtrace - it strips const from function parameters

With usedtrace this caused:

- build failures under g++ (OS X)

- const qualification warnings with gcc (OS X)

The workaround simply adds const to char * parameters if not already
present.

The bug in dtrace was apparently reported to Sun in 2006:
  http://opensolaris.org/jive/thread.jspa?threadID=53810

Mozilla ran into the same problem:
  https://bugzilla.mozilla.org/show_bug.cgi?id=593483
  • Loading branch information...
1 parent 2186be1 commit 12b81ca50a3ad3c06c786138add2f964cf24acb6 @tonycoz tonycoz committed Jul 20, 2011
Showing with 6 additions and 3 deletions.
  1. +4 −1 Makefile.SH
  2. +2 −2 perldtrace.d
View
@@ -749,8 +749,11 @@ else
case "$dtrace_h" in
?*)
$spitshell >>$Makefile <<'!NO!SUBS!'
+# dtrace dicards const qualifiers from arguments, put them back
$(DTRACE_H): perldtrace.d
- $(DTRACE) -h -s perldtrace.d -o $(DTRACE_H)
+ $(DTRACE) -h -s perldtrace.d -o $(DTRACE_H).in
+ sed -e '/const/!s/char \*/const char */g' $(DTRACE_H).in >$(DTRACE_H)
+ $(RMS) $(DTRACE_H).in
mydtrace.h: $(DTRACE_H)
View
@@ -4,8 +4,8 @@
*/
provider perl {
- probe sub__entry(char *, char *, int, char *);
- probe sub__return(char *, char *, int, char *);
+ probe sub__entry(const char *, const char *, int, const char *);
+ probe sub__return(const char *, const char *, int, const char *);
probe phase__change(const char *, const char *);
};

0 comments on commit 12b81ca

Please sign in to comment.