- unsigned int j;
-
- /* Check that the symbol is a global and that it has a name. */
- if (((N_SECT | N_EXT) != n_type && (N_ABS | N_EXT) != n_type))
- continue;
-
- if (0 == sym[i].n_un.n_strx) /* iff a null, "", name. */
- continue;
-
- /* Lop off omnipresent leading underscore. */
- if (*name == '_')
- name += 1;
-
- if (strncmp(name, DTRACE_PROBE_PREFIX, sizeof(DTRACE_PROBE_PREFIX) - 1) == 0) {
- sdt_probedesc_t *sdpd = kmem_alloc(sizeof(sdt_probedesc_t), KM_SLEEP);
- int len = strlen(name) + 1;
-
- sdpd->sdpd_name = kmem_alloc(len, KM_SLEEP);
- strncpy(sdpd->sdpd_name, name, len); /* NUL termination is ensured. */
-
- prev_name = "<unknown>";
- best = 0;
-
- /*
- * Find the symbol immediately preceding the sdt probe site just discovered,
- * that symbol names the function containing the sdt probe.
- */
- for (j = 0; j < orig_st->nsyms; j++) {
- uint8_t jn_type = sym[j].n_type & N_TYPE;
- char *jname = strings + sym[j].n_un.n_strx;
-
- if ((N_SECT != jn_type && N_ABS != jn_type))
- continue;
-
- if (0 == sym[j].n_un.n_strx) /* iff a null, "", name. */
- continue;
-
- if (*jname == '_')
- jname += 1;
-
- if (*(unsigned long *)sym[i].n_value <= (unsigned long)sym[j].n_value)
- continue;
-
- if ((unsigned long)sym[j].n_value > best) {
- best = (unsigned long)sym[j].n_value;
- prev_name = jname;
- }
+
+ sdt_probedesc_t *sdpd = kmem_alloc(sizeof(sdt_probedesc_t), KM_SLEEP);
+
+ /* Unescape probe name and keep a note of the size of original memory allocation. */
+ sdpd->sdpd_name = sdt_strdup_name(sdtdef->dsd_name);
+ sdpd->sdpd_namelen = strlen(sdtdef->dsd_name) + 1;
+
+ /* Used only for provider structure lookup so there is no need to make dynamic copy. */
+ sdpd->sdpd_prov = sdtdef->dsd_prov;
+
+ /*
+ * Find the symbol immediately preceding the sdt probe site just discovered,
+ * that symbol names the function containing the sdt probe.
+ */
+ funcname = "<unknown>";
+ for (i = 0; i < orig_st->nsyms; i++) {
+ uint8_t jn_type = sym[i].n_type & N_TYPE;
+ char *jname = strings + sym[i].n_un.n_strx;
+
+ if ((N_SECT != jn_type && N_ABS != jn_type)) {
+ continue;
+ }
+
+ if (0 == sym[i].n_un.n_strx) { /* iff a null, "", name. */
+ continue;