[DTrace-devel] [PATCH 4/4] Do not register handlers when not executing probe clauses

Kris Van Hees kris.van.hees at oracle.com
Wed Jun 10 08:23:35 PDT 2020


The various handlers that are used by consumers only apply to the
execution of probe clauses.  For operating modes that do not execute
clauses there is no need to register handlers.  Even worse, if e.g.
the error handler is being registered with the default error clause
and -xnolibs is used (which is common with the -h option to generate
a header file), an error will occur because bpf_get_bvar() cannot be
found.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 cmd/dtrace.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cmd/dtrace.c b/cmd/dtrace.c
index cef86ef2..17d5692a 100644
--- a/cmd/dtrace.c
+++ b/cmd/dtrace.c
@@ -1337,7 +1337,11 @@ main(int argc, char *argv[])
 	for (i = 0; i < g_cmdc; i++)
 		g_cmdv[i].dc_func(&g_cmdv[i]);
 
-	if (g_mode != DMODE_LIST) {
+	/*
+	 * We only need to register handler if we are going to execute probe
+	 * clauses.
+	 */
+	if (g_mode == DMODE_EXEC) {
 		if (dtrace_handle_err(g_dtp, &errhandler, NULL) == -1)
 			dfatal("failed to establish error handler");
 
-- 
2.26.0




More information about the DTrace-devel mailing list