# DTrace in 7.1-p2



## alp (Jan 28, 2009)

Hello.
I've updated to FreeBSD-7.1-p2 and I'm going to look at DTrace. But I have the following error after compiling new kernel according the instructions in Handbook:

```
# ./hotkernel
Sampling... Hit Ctrl-C to end.
dtrace: invalid probe specifier 
	#pragma D option quiet
	profile:::profile-1001hz
	/arg0/
	{
		@pc[arg0] = count();
	}
	dtrace:::END
	{
		printa("%a %@d\n", @pc);
	}
: "/usr/lib/dtrace/psinfo.d", line 37: syntax error near "uid_t"
```

I have compiled kernel with the following options:


```
options         KDTRACE_FRAME   # Ensure frames are compiled in - need it on amd64
options         KDTRACE_HOOKS           # Kernel DTrace hooks
options         DDB_CTF # DTrace CTF.
```

and made [cmd=]make WITH_CTF=1 kernel KERNCONF=MyConf[/cmd]

ctfdump on /boot/kernel/kernel gives a long listing, begining with:


```
- CTF Header -----------------------------------------------------------------

  cth_magic    = 0xcff1
  cth_version  = 2
  cth_flags    = 0x01
  cth_parlabel = (anon)
  cth_parname  = (anon)
  cth_lbloff   = 0
  cth_objtoff  = 8
  cth_funcoff  = 19910
  cth_typeoff  = 41348
  cth_stroff   = 41348
  cth_strlen   = 37

- Label Table ----------------------------------------------------------------

      0 FreeBSD 7.1-RELEASE-p2 amd64 701000

- Data Objects ---------------------------------------------------------------

  [0] 0        __set_sysctl_set_sym_sysctl___kern_cam (3)
```


----------



## Maledictus (Jan 28, 2009)

Hmm, I had the same error but I forgot WITH_CTF=1 at that time. The first thing I tried was renaming psinfo.d which kinda helped too. Maybe just try that too?


----------



## alp (Jan 29, 2009)

It shouldn't help, cause as I understand this will make the psinfo struct unknown to DTrace. It seems, DTrace doesn't understand uid_t type...


----------



## nox@ (Jan 31, 2009)

alp said:
			
		

> Hello.
> I've updated to FreeBSD-7.1-p2 and I'm going to look at DTrace. But I have the following error after compiling new kernel according the instructions in Handbook:
> # ./hotkernel
> Sampling... Hit Ctrl-C to end.
> ...



I don't see a problem with your kernel options, the same script 'works' here (works in quotes because using too many fbt probes like this does can cause panics which is a known problem mentioned in an early DTrace for FreeBSD - sources available via cvsup announcement) - maybe you forgot to `# kldload dtraceall` or something went wrong with the way you did the installkernel?


----------



## f-andrey (Jan 31, 2009)

My sistem dtrace not working to 

```
test# uname -a
FreeBSD test.local 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sat Jan 31 18:35:34 MSK 2009     andrey@test.local:/usr/obj/usr/src/sys/MY_USB2  amd64
test# kldstat 
Id Refs Address            Size     Name
...
 8    1 0xffffffff80cff000 1588     dtraceall.ko
 9    4 0xffffffff80d01000 51e8     cyclic.ko
10    9 0xffffffff80d07000 3678     opensolaris.ko
11    7 0xffffffff80d0b000 14fab0   dtrace.ko
12    2 0xffffffff80e5b000 1e40     dtmalloc.ko
13    2 0xffffffff80e5d000 4b30     fbt.ko
...
test# dtrace -l
   ID   PROVIDER  MODULE         FUNCTION NAME
    1     dtrace                 BEGIN
    2     dtrace                 END
    3     dtrace                 ERROR
    4    syscall                 syscall entry
...
test# dtrace -l | wc -l
   30546
test# dtrace -n "syscall::::"
dtrace: invalid probe specifier syscall::::: "/usr/lib/dtrace/psinfo.d", line 37: syntax error near "uid_t"

test# grep KDTRACE /usr/src/sys/amd64/conf/MY_USB2
options         KDTRACE_FRAME           # Ensure frames are compiled in
options         KDTRACE_HOOKS           # Kernel DTrace hooks
test# grep CTF /usr/src/sys/amd64/conf/MY_USB2 /etc/make.conf
/usr/src/sys/amd64/conf/MY_USB2:options         DDB_CTF
/etc/make.conf:WITH_CTF=1
```
Mayby this is because of  amd64?


----------



## trasz@ (Jul 20, 2010)

The '/usr/lib/dtrace/psinfo.d", line 37: syntax error near "uid_t"' error means you have to recompile your kernel and world with "WITH_CTF=1" in /etc/src.conf.


----------



## mjb (Dec 7, 2010)

I know it's an old thread, but this is one of the top google results for psinfo.d so may help someone else with the same problem



			
				trasz@ said:
			
		

> The '/usr/lib/dtrace/psinfo.d", line 37: syntax error near "uid_t"' error means you have to recompile your kernel and world with "WITH_CTF=1" in /etc/src.conf.



This may have been the case previously or for 7.x, but the wiki page says:



> Note: WITH_CTF=1 in the kernel config file works only on 9-CURRENT (or later) but not for stable/8. For stable/8 specify WITH_CTF on the make command line. *In either case WITH_CTF=1 will not be picked up from make.conf or src.conf for the kernel build*.



After failing to RTFM properly the first time around, I can confirm you do need it on the 'make kernel' command line (at least on 8.2-PRERELEASE), not just in src.conf


----------

