Due to a mistake in how we compensate for the potential ULONG_MAX
sentinel value being added to kernel stacks on x86_64 (by the
save_stack_trace() function), the caller was always reported as 0.
This in turn was hiding a problem with the aframes values that are
used to ensure we skip the right amount of frames when reporting a
stack, caller, and calculating the stackdepth. Effectively, it tells
the stack walker how many frames were added to the stack due to DTrace
processing.
Orabug:
25727046
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
return 0;
if (!(mstate->dtms_present & DTRACE_MSTATE_CALLER)) {
- int aframes = mstate->dtms_probe->dtpr_aframes + 2;
+ int aframes = mstate->dtms_probe->dtpr_aframes + 3;
if (!DTRACE_ANCHORED(mstate->dtms_probe)) {
/*
dtrace_copyinstr_arch(uaddr, kaddr, size, flags);
}
+/*
+ * FIXME: aframes + 3 should really be aframes + 1, dtrace_stacktrace() in the
+ * kernel should do its own aframes + 2
+ */
void dtrace_getpcstack(uint64_t *pcstack, int pcstack_limit, int aframes,
uint32_t *intrpc)
{
pcstack,
NULL,
pcstack_limit,
- aframes,
+ aframes + 3,
STACKTRACE_KERNEL
};
dtrace_getufpstack(pcstack, NULL, pcstack_limit);
}
+/*
+ * FIXME: aframes + 3 should really be aframes + 1, dtrace_stacktrace() in the
+ * kernel should do its own aframes + 2
+ */
int dtrace_getstackdepth(dtrace_mstate_t *mstate, int aframes)
{
uintptr_t old = mstate->dtms_scratch_ptr;
NULL,
NULL,
0,
- aframes,
+ aframes + 3,
STACKTRACE_KERNEL
};
st.limit = (mstate->dtms_scratch_base + mstate->dtms_scratch_size -
(uintptr_t)st.pcs) >> 3;
+ DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
dtrace_stacktrace(&st);
+ DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
mstate->dtms_scratch_ptr = old;
dtrace_getpcstack(
(uint64_t *)(tomax + valoffs),
size / sizeof(pc_t),
- probe->dtpr_aframes,
+ probe->dtpr_aframes + 1,
DTRACE_ANCHORED(probe)
? NULL
: (uint32_t *)arg0);
fbp = kzalloc(sizeof(fbt_probe_t), GFP_KERNEL);
fbp->fbp_name = kstrdup(func, GFP_KERNEL);
fbp->fbp_id = dtrace_probe_create(fbt_id, mp->name, func,
- "entry", 3, fbp);
+ "entry", FBT_AFRAMES, fbp);
fbp->fbp_module = mp;
fbp->fbp_loadcnt = 1; /* FIXME */
fbp->fbp_primary = 1; /* FIXME */
fbp->fbp_id = prev->fbp_id;
} else {
fbp->fbp_id = dtrace_probe_create(fbt_id, mp->name,
- func, "return", 3,
- fbp);
+ func, "return",
+ FBT_AFRAMES, fbp);
}
fbp->fbp_module = mp;
#define _FBT_H_
#include <asm/dtrace_arch.h>
+#include <dtrace/fbt_arch.h>
typedef struct fbt_probe {
char *fbp_name; /* name of probe */
--- /dev/null
+#ifndef _SPARC64_FBT_ARCH_H
+#define _SPARC64_FBT_ARCH_H
+
+/*
+ * Function Boundary Tracing Implementation defines
+ *
+ * Note: The contents of this file are private to the implementation of the
+ * DTrace subsystem and are subject to change at any time without notice.
+ */
+
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright 2009-2014 Oracle, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#define FBT_AFRAMES 1
+
+#endif /* _SPARC64_FBT_ARCH_H */
--- /dev/null
+#ifndef _X86_64_FBT_ARCH_H
+#define _X86_64_FBT_ARCH_H
+
+/*
+ * Function Boundary Tracing Implementation defines
+ *
+ * Note: The contents of this file are private to the implementation of the
+ * DTrace subsystem and are subject to change at any time without notice.
+ */
+
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright 2017 Oracle, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#define FBT_AFRAMES 9
+
+#endif /* _X86_64_FBT_ARCH_H */