DTrace fixes for node.js

Mark Johnston markj at freebsd.org
Thu Feb 27 05:01:40 UTC 2014


On Tue, Feb 25, 2014 at 06:16:15PM +0400, Fedor Indutny wrote:
> Hello devs!
> 
> I have made some fixes to fix DTrace support for node.js in FreeBSD:
> 
> * http://www.freebsd.org/cgi/query-pr.cgi?pr=186821
> * http://www.freebsd.org/cgi/query-pr.cgi?pr=187027
> 
> Here is a blog post with a bit of explanation of why this is needed
> and what is fixed: https://blog.indutny.com/7.freebsd-dtrace
> 
> Please let me know if I could be any help in reviewing it.

Hi Fedor,

The DOF limit change looks fine to me. I note that the illumos guys have
just pushed a change to illumos-gate which bumps dtrace_dof_maxsize, but
it's good to have the sysctl as well.

The drti change looks mostly good to me. The real problem there is that
our linker doesn't know how to merge DOF, so it just concatenates the
tables into one SUNW_dof section. So we should really fix our linker,
but it doesn't hurt to also handle the problem in drti.o.

There are a couple of bugs in the patch. First, the "break" added after
finding the DOF section causes problems if we haven't yet seen the
symbol table. Second, fixedprobes needs to be reset at the beginning of
each iteration of the while loop that you added, else we may not try
searching the dynamic symbol table when fixing the probe addresses. I've
pasted a patch below; could you test it and make sure things still work
properly with node?

Thanks for the detailed blog post and problem description, they were
very helpful. :)

-Mark

diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
index e47cfb4d..bb02d8c 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
@@ -162,7 +162,7 @@ dtrace_dof_init(void)
 	char *dofstrtabraw;
 	size_t shstridx, symtabidx = 0, dynsymidx = 0;
 	unsigned char *buf;
-	int fixedprobes = 0;
+	int fixedprobes;
 #endif
 
 	if (getenv("DTRACE_DOF_INIT_DISABLE") != NULL)
@@ -214,7 +214,6 @@ dtrace_dof_init(void)
 			if  (s && strcmp(s, ".SUNW_dof") == 0) {
 				dofdata = elf_getdata(scn, NULL);
 				dof = dofdata->d_buf;
-				break;
 			}
 		}
 	}
@@ -226,6 +225,7 @@ dtrace_dof_init(void)
 	}
 
 	while ((char *) dof < (char *) dofdata->d_buf + dofdata->d_size) {
+		fixedprobes = 0;
 		dof_next = (void *) ((char *) dof + dof->dofh_filesz);
 #endif
 


More information about the freebsd-dtrace mailing list