summaryrefslogtreecommitdiffstats
path: root/sys/cddl
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2013-06-02 01:05:36 +0000
committermarkj <markj@FreeBSD.org>2013-06-02 01:05:36 +0000
commit4396d998dbeff2e96f52262af37828127c312d19 (patch)
tree9339ce8d71c97a41a31b623fa3aa05b49ac79947 /sys/cddl
parentf492c31639eaf495f9f716a99298e803ce0bf00a (diff)
downloadFreeBSD-src-4396d998dbeff2e96f52262af37828127c312d19.zip
FreeBSD-src-4396d998dbeff2e96f52262af37828127c312d19.tar.gz
SDT probes can directly pass up to five arguments as arguments to
dtrace_probe(). Arguments beyond these five must be obtained in an architecture-specific way; this can be done through the getargval provider method, and through dtrace_getarg() if getargval isn't overridden. This change fixes two off-by-one bugs in the way these arguments are fetched in FreeBSD's DTrace implementation. First, the SDT provider must set the aframes parameter to 1 when creating a probe. The aframes parameter controls the number of frames that dtrace_getarg() will step over in order to find the frame containing the extra arguments. On FreeBSD, dtrace_getarg() is called in SDT probe context via dtrace_probe()->dtrace_dif_emulate()->dtrace_dif_variable->dtrace_getarg() so aframes must be 3 since the arguments are in dtrace_probe()'s frame; it was previously being called with a value of 2 instead. illumos uses a different aframes value for SDT probes, but this is because illumos SDT probes fire by triggering the #UD fault handler rather than calling dtrace_probe() directly. The second bug has to do with the way arguments are grabbed out dtrace_probe()'s frame on amd64. The code currently jumps over the first stack argument and retrieves the rest of them using a pointer into the stack. This works on i386 because all of dtrace_probe()'s arguments will be on the stack and the first argument is the probe ID, which should be ignored. However, it is incorrect to ignore the first stack argument on amd64, so we correct the pointer used to access the arguments. MFC after: 2 weeks
Diffstat (limited to 'sys/cddl')
-rw-r--r--sys/cddl/dev/dtrace/amd64/dtrace_isa.c2
-rw-r--r--sys/cddl/dev/sdt/sdt.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/sys/cddl/dev/dtrace/amd64/dtrace_isa.c b/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
index d9ed080..34d6f33 100644
--- a/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
+++ b/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
@@ -398,7 +398,7 @@ dtrace_getarg(int arg, int aframes)
}
arg -= (inreg + 1);
- stack = (uintptr_t *)&fp[1];
+ stack = (uintptr_t *)fp + 2;
load:
DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
diff --git a/sys/cddl/dev/sdt/sdt.c b/sys/cddl/dev/sdt/sdt.c
index 395daf7..96ab550 100644
--- a/sys/cddl/dev/sdt/sdt.c
+++ b/sys/cddl/dev/sdt/sdt.c
@@ -134,7 +134,7 @@ sdt_probe_callback(struct sdt_probe *probe, void *arg __unused)
return (0);
(void) dtrace_probe_create(prov->id, probe->mod, probe->func,
- probe->name, 0, probe);
+ probe->name, 1, probe);
return (0);
}
OpenPOWER on IntegriCloud