Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created June 29, 2011 18:12
Show Gist options
  • Save tenderlove/1054471 to your computer and use it in GitHub Desktop.
Save tenderlove/1054471 to your computer and use it in GitHub Desktop.
dtrace problems

I can't seem to get this dtrace probe to work

I'm trying to implement a dtrace probe that takes a char * argument. Everything compiles fine, but when I run the dtrace script, I get this error:

dtrace: failed to compile script timing.d: line 3: printf( ) argument #2 is incompatible with conversion #1 prototype:
	conversion: %s
	 prototype: char [] or string (or use stringof)
	  argument: int64_t
make: *** [test] Error 1

To reproduce:

$ make clean
$ make test
#include <stdio.h>
#include "probes.h"
long primes[1000000] = { 3 };
long primecount = 1;
int main(int argc, char **argv)
{
long divisor = 0;
long currentprime = 5;
long isprime = 1;
while (currentprime < 1000000)
{
isprime = 1;
PRIMES_PRIMECALC_START(currentprime);
for(divisor=0;divisor<primecount;divisor++)
{
if (currentprime % primes[divisor] == 0)
{
isprime = 0;
}
}
PRIMES_PRIMECALC_DONE(currentprime,isprime);
if (isprime)
{
primes[primecount++] = currentprime;
PRIMES_PRIMECALC_TABLESIZE(primecount);
PRIMES_PRIMECALC_NAME("this is a test");
}
currentprime = currentprime + 2;
}
return 0;
}
all:
dtrace -h -s probes.d
gcc -Wall -O0 -I. -o aaron aaron.c
clean:
rm probes.h
rm aaron
test: all
sudo dtrace -s timing.d -c './aaron'
provider primes {
probe primecalc__name(char* name);
/* Start of the prime calculation */
probe primecalc__start(long prime);
/* End of the prime calculation */
probe primecalc__done(long prime, int isprime);
/* Exposes the size of the table of existing primes */
probe primecalc__tablesize(long tablesize);
};
primes*:::primecalc-name
{
printf("%s\n", arg0);
}
@kristopherjohnson
Copy link

I have this problem now. Did you ever find a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment