[DTrace-devel] [oracle/dtrace-utils] 2f6407: Unify the handling of stack traces in the consumer
Kris Van Hees
noreply at github.com
Wed Oct 8 19:37:24 UTC 2025
Branch: refs/heads/dev-queue
Home: https://github.com/oracle/dtrace-utils
Commit: 2f6407bb70907c37f5e99dfc04db8ef17e8996dc
https://github.com/oracle/dtrace-utils/commit/2f6407bb70907c37f5e99dfc04db8ef17e8996dc
Author: Kris Van Hees <kris.van.hees at oracle.com>
Date: 2025-10-03 (Fri, 03 Oct 2025)
Changed paths:
M include/dtrace/actions_defines.h
M libdtrace/dt_cg.c
M libdtrace/dt_consume.c
M libdtrace/dt_impl.h
M libdtrace/dt_printf.c
M libdtrace/dt_printf.h
Log Message:
-----------
Unify the handling of stack traces in the consumer
Distinguishing between kernel stacks and userspace stacks was done
based on the action id, even when used outside of action context
(i.e. in aggregation keys). That is far from ideal.
Encode the stack type along with the nframes and strsize values in
the data record description argument for stack() and ustack()
records.
The macros for managing that argument are moved to dt_impl.h since
they are internal to the DTrace implementation.
All printing of stack traces is now consolidated in dt_printf.c as
well.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
Commit: d32e526203677acfd29ac447bf85a17f4141787d
https://github.com/oracle/dtrace-utils/commit/d32e526203677acfd29ac447bf85a17f4141787d
Author: Kris Van Hees <kris.van.hees at oracle.com>
Date: 2025-10-03 (Fri, 03 Oct 2025)
Changed paths:
M include/dtrace/dif_defines.h
M libdtrace/dt_cg.c
M libdtrace/dt_dctx.h
M libdtrace/dt_open.c
M libdtrace/dt_options.c
M libdtrace/dt_printf.c
M test/unittest/funcs/tst.subr.d
M test/unittest/printa/err.D_PRINTF_ARG_TYPE.stack.r
M test/unittest/printa/err.D_PRINTF_ARG_TYPE.ustack.r
Log Message:
-----------
cg: transition [u]stack() from action to subroutine
In order to allow [u]stack() to be used in expressions, they must be
subroutines. An exception is added to allow them to retain their
original behaviour as data recording actions as well.
The implementation change requires a new internal type to be defined
(dt_stack) to hold stack trace data.
This patch does not allow [u]stack() to be used in assignments to
variables just yet, but it supports all previous uses of [u]stack().
Additional functionality will be added on top of this.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
Commit: 280162e4205472cff19778468ca81c83b3a55b24
https://github.com/oracle/dtrace-utils/commit/280162e4205472cff19778468ca81c83b3a55b24
Author: Kris Van Hees <kris.van.hees at oracle.com>
Date: 2025-10-03 (Fri, 03 Oct 2025)
Changed paths:
M libdtrace/dt_impl.h
M libdtrace/dt_open.c
M libdtrace/dt_options.c
A test/unittest/options/err.jstackframes-negative.d
A test/unittest/options/err.jstackframes-too-high.sh
A test/unittest/options/err.maxframes-negative.d
A test/unittest/options/err.maxframes-too-high.sh
A test/unittest/options/err.stackframes-negative.d
A test/unittest/options/err.stackframes-too-high.sh
A test/unittest/options/err.ustackframes-negative.d
A test/unittest/options/err.ustackframes-too-high.sh
Log Message:
-----------
options: check *frames option values against system limit
Commit 81e99397d ("Add support for the stack() action") added code to
retrieve the system limit for stack traces and used that value to set
the 'maxframes' option.
However, a user can set the 'maxframes' option from the command line,
which would allow setting the option to value beyond the system limit.
We now record the system limit in dtrace_hdl_t as well as setting the
'maxframes' option to this value as a default. Options processing now
ensures that *frames options cannot be set beyond the system limit.
Note: If 'stackframes', 'ustackframes', or 'jstackframes' are set
before 'maxframes' they could be given a value that exceeds 'maxframes'.
The existing immplementation in the code generator already lowers their
value to 'maxframes' as needed.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
Commit: 17efd07d1344688551289b11fe83ea5600aa5cc1
https://github.com/oracle/dtrace-utils/commit/17efd07d1344688551289b11fe83ea5600aa5cc1
Author: Kris Van Hees <kris.van.hees at oracle.com>
Date: 2025-10-08 (Wed, 08 Oct 2025)
Changed paths:
M libdtrace/dt_cg.c
M libdtrace/dt_dctx.h
M libdtrace/dt_impl.h
M libdtrace/dt_open.c
M libdtrace/dt_parser.c
M libdtrace/dt_printf.c
A test/unittest/funcs/stack/err.corrupted-data.d
A test/unittest/funcs/stack/err.corrupted-data.r
A test/unittest/funcs/stack/err.store-to-stack.d
A test/unittest/funcs/stack/err.store-to-stack.r
A test/unittest/funcs/stack/tst.asgn_dvar.d
A test/unittest/funcs/stack/tst.asgn_dvar.r
A test/unittest/funcs/stack/tst.asgn_dvar.r.p
A test/unittest/funcs/stack/tst.asgn_gvar.d
A test/unittest/funcs/stack/tst.asgn_gvar.r
A test/unittest/funcs/stack/tst.asgn_gvar.r.p
A test/unittest/funcs/stack/tst.asgn_lvar.d
A test/unittest/funcs/stack/tst.asgn_lvar.r
A test/unittest/funcs/stack/tst.asgn_lvar.r.p
A test/unittest/funcs/stack/tst.asgn_tvar.d
A test/unittest/funcs/stack/tst.asgn_tvar.r
A test/unittest/funcs/stack/tst.asgn_tvar.r.p
A test/unittest/funcs/stack/tst.ref_addrs.d
A test/unittest/funcs/stack/tst.ref_addrs.r
A test/unittest/funcs/stack/tst.ref_depth.d
A test/unittest/funcs/stack/tst.ref_depth.r
A test/unittest/funcs/stack/tst.ref_is_user.d
A test/unittest/funcs/stack/tst.ref_is_user.r
A test/unittest/funcs/stack/tst.ref_pid.d
A test/unittest/funcs/stack/tst.ref_pid.r
A test/unittest/funcs/stack/tst.ref_strsz.d
A test/unittest/funcs/stack/tst.ref_strsz.r
A test/unittest/funcs/stack/tst.store.d
A test/unittest/funcs/stack/tst.store.r
A test/unittest/funcs/stack/tst.store.r.p
A test/unittest/funcs/ustack/err.corrupted-data.d
A test/unittest/funcs/ustack/err.corrupted-data.r
A test/unittest/funcs/ustack/err.store-to-stack.d
A test/unittest/funcs/ustack/err.store-to-stack.r
A test/unittest/funcs/ustack/tst.asgn_dvar.d
A test/unittest/funcs/ustack/tst.asgn_dvar.r
A test/unittest/funcs/ustack/tst.asgn_dvar.r.p
A test/unittest/funcs/ustack/tst.asgn_gvar.d
A test/unittest/funcs/ustack/tst.asgn_gvar.r
A test/unittest/funcs/ustack/tst.asgn_gvar.r.p
A test/unittest/funcs/ustack/tst.asgn_lvar.d
A test/unittest/funcs/ustack/tst.asgn_lvar.r
A test/unittest/funcs/ustack/tst.asgn_lvar.r.p
A test/unittest/funcs/ustack/tst.asgn_tvar.d
A test/unittest/funcs/ustack/tst.asgn_tvar.r
A test/unittest/funcs/ustack/tst.asgn_tvar.r.p
A test/unittest/funcs/ustack/tst.ref_addrs.d
A test/unittest/funcs/ustack/tst.ref_addrs.r
A test/unittest/funcs/ustack/tst.ref_depth.d
A test/unittest/funcs/ustack/tst.ref_depth.r
A test/unittest/funcs/ustack/tst.ref_is_user.d
A test/unittest/funcs/ustack/tst.ref_is_user.r
A test/unittest/funcs/ustack/tst.ref_pid.d
A test/unittest/funcs/ustack/tst.ref_strsz.d
A test/unittest/funcs/ustack/tst.ref_strsz.r
A test/unittest/funcs/ustack/tst.store.d
A test/unittest/funcs/ustack/tst.store.r
A test/unittest/funcs/ustack/tst.store.r.p
M test/unittest/printa/err.D_PRINTF_ARG_TYPE.stack.r
M test/unittest/printa/err.D_PRINTF_ARG_TYPE.ustack.r
A test/unittest/printf/tst.stack.d
A test/unittest/printf/tst.stack.r
A test/unittest/printf/tst.stack.r.p
A test/unittest/printf/tst.ustack25_pid.d
A test/unittest/printf/tst.ustack25_pid.r
A test/unittest/printf/tst.ustack25_pid.r.p
Log Message:
-----------
cg, printf: allow storing [u]stack() into vars and printf using %k
To support storing [u]stack() values in variables and as arguments for
printf(), a type definition is introduced:
typedef struct dt_stack {
uint32_t frames;
uint32_t strsz; // optional string blob size
uint32_t is_user // > 0 if userspace stack trace
uint32_t pid; // process id (or 0 for kernel)
uint64_t addrs[n]; // stack trace addresses
} dt_stack_t;
where 'n' is the maximum number of frames that can be retrieved (set
with the 'maxframes' option).
Since dt_stack_t needs to be known early enough to define stack(),
jstack(), and ustack(), it is defined in two stages. First dt_stack_t
is defined as a typedef for struct dt_stack, and once options have been
processed, struct dt_stack is finalized.
Once the value of a stack has been assigned to a variable, it can be
accessed as a regular struct (*not* a pointer to a struct).
Modification is also possible, and safety checks are performed to ensure
that such modifications do not cause crashes in the consumer.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
Compare: https://github.com/oracle/dtrace-utils/compare/877fcdeb25b3...17efd07d1344
To unsubscribe from these emails, change your notification settings at https://github.com/oracle/dtrace-utils/settings/notifications
More information about the DTrace-devel
mailing list