From owner-p4-projects@FreeBSD.ORG Fri Jul 14 13:33:07 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0A78416A4DE; Fri, 14 Jul 2006 13:33:07 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C245816A4DA for ; Fri, 14 Jul 2006 13:33:06 +0000 (UTC) (envelope-from howardsu@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id EA1EF43D5F for ; Fri, 14 Jul 2006 13:33:05 +0000 (GMT) (envelope-from howardsu@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6EDX5E5089945 for ; Fri, 14 Jul 2006 13:33:05 GMT (envelope-from howardsu@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6EDX5on089942 for perforce@freebsd.org; Fri, 14 Jul 2006 13:33:05 GMT (envelope-from howardsu@FreeBSD.org) Date: Fri, 14 Jul 2006 13:33:05 GMT Message-Id: <200607141333.k6EDX5on089942@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to howardsu@FreeBSD.org using -f From: Howard Su To: Perforce Change Reviews Cc: Subject: PERFORCE change 101546 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jul 2006 13:33:07 -0000 http://perforce.freebsd.org/chv.cgi?CH=101546 Change 101546 by howardsu@su_laptop on 2006/07/14 13:32:18 Fix SDT bugs. kldload/unload SDT provider works now. Affected files ... .. //depot/projects/dtrace/src/sys/cddl/dev/sdt/sdt.c#6 edit .. //depot/projects/dtrace/src/sys/i386/i386/elf_machdep.c#5 edit .. //depot/projects/dtrace/src/sys/sys/kernel.h#7 edit Differences ... ==== //depot/projects/dtrace/src/sys/cddl/dev/sdt/sdt.c#6 (text+ko) ==== @@ -1,4 +1,3 @@ - /* * CDDL HEADER START * @@ -94,7 +93,7 @@ sdt_disable, sdt_suspend, sdt_resume, - NULL, + sdt_getargdesc, NULL, NULL, sdt_destroy @@ -141,9 +140,8 @@ } static int -sdt_provide_module_function(linker_file_t lf, linker_symval_t *symval, void *opaque) +sdt_create_module_probes(linker_file_t lf, char *modname) { - char *modname = opaque; sdt_probedesc_t *sdpd; sdt_probe_t *sdp, *old; sdt_provider_t *prov; @@ -162,77 +160,74 @@ return (0); for (; sdpd != NULL; sdpd = sdpd->sdpd_next) { - char *name = sdpd->sdpd_name, *func, *nname; + char *name = sdpd->sdpd_name, *nname; int i, j; sdt_provider_t *prov; dtrace_id_t id; for (prov = sdt_providers; prov->sdtp_prefix != NULL; prov++) { - char *prefix = prov->sdtp_prefix; + char *prefix = prov->sdtp_prefix; - if (strncmp(name, prefix, strlen(prefix)) == 0) { - name += strlen(prefix); - break; + if (strncmp(name, prefix, strlen(prefix)) == 0) { + name += strlen(prefix); + break; + } } - } + + while (*name != '\0') { + if (*name <= '9' && *name>='0') + name++; + else + break; + } + + nname = malloc(len = strlen(name) + 1, M_SDT, M_WAITOK); - nname = malloc(len = strlen(name) + 1, M_SDT, M_WAITOK); + for (i = 0, j = 0; name[j] != '\0'; i++) { + if (name[j] == '_' && name[j + 1] == '_') { + nname[i] = '-'; + j += 2; + } else { + nname[i] = name[j++]; + } + } - for (i = 0, j = 0; name[j] != '\0'; i++) { - if (name[j] == '_' && name[j + 1] == '_') { - nname[i] = '-'; - j += 2; - } else { - nname[i] = name[j++]; - } - } + nname[i] = '\0'; - nname[i] = '\0'; + sdp = malloc(sizeof (sdt_probe_t), M_SDT, M_WAITOK | M_ZERO); + sdp->sdp_loadcnt = lf->loadcnt; + sdp->sdp_ctl = lf; + sdp->sdp_name = nname; + sdp->sdp_namelen = len; + sdp->sdp_provider = prov; - sdp = malloc(sizeof (sdt_probe_t), M_SDT, M_WAITOK | M_ZERO); - sdp->sdp_loadcnt = lf->loadcnt; - sdp->sdp_ctl = lf; - sdp->sdp_name = nname; - sdp->sdp_namelen = len; - sdp->sdp_provider = prov; - - if (symval->name == NULL) - func = ""; - else { - /* HACK: we need change prototype of _probe_lookup */ - func = malloc(strlen(symval->name) + 1, M_SDT, M_WAITOK); - strcpy(func, symval->name); - } - - /* - * We have our provider. Now create the probe. - */ - if ((id = dtrace_probe_lookup(prov->sdtp_id, modname, - func, nname)) != DTRACE_IDNONE) { - old = dtrace_probe_arg(prov->sdtp_id, id); - ASSERT(old != NULL); + /* + * We have our provider. Now create the probe. + */ + if ((id = dtrace_probe_lookup(prov->sdtp_id, modname, + NULL, nname)) != DTRACE_IDNONE) { + old = dtrace_probe_arg(prov->sdtp_id, id); + ASSERT(old != NULL); - sdp->sdp_next = old->sdp_next; - sdp->sdp_id = id; - old->sdp_next = sdp; - } else { - sdp->sdp_id = dtrace_probe_create(prov->sdtp_id, - modname, func, nname, 3, sdp); + sdp->sdp_next = old->sdp_next; + sdp->sdp_id = id; + old->sdp_next = sdp; + } else { + sdp->sdp_id = dtrace_probe_create(prov->sdtp_id, + modname, NULL, nname, 3, sdp); - lf->sdt_nprobes++; - } + lf->sdt_nprobes++; + } - sdp->sdp_hashnext = - sdt_probetab[SDT_ADDR2NDX(sdpd->sdpd_offset)]; - sdt_probetab[SDT_ADDR2NDX(sdpd->sdpd_offset)] = sdp; + sdp->sdp_hashnext = + sdt_probetab[SDT_ADDR2NDX(sdpd->sdpd_offset)]; + sdt_probetab[SDT_ADDR2NDX(sdpd->sdpd_offset)] = sdp; - sdp->sdp_patchval = SDT_PATCHVAL; - sdp->sdp_patchpoint = (uint8_t *)sdpd->sdpd_offset; - sdp->sdp_savedval = *sdp->sdp_patchpoint; - if (symval->name != NULL) - free(func, M_SDT); + sdp->sdp_patchval = SDT_PATCHVAL; + sdp->sdp_patchpoint = (uint8_t *)sdpd->sdpd_offset; + sdp->sdp_savedval = *sdp->sdp_patchpoint; } - return (0); + return (0); } /*ARGSUSED*/ @@ -246,11 +241,8 @@ len = strlen(modname); if (len > 3 && strcmp(modname + len - 3, ".ko") == 0) modname[len - 3] = '\0'; - - /* - * List the functions in the module and the symbol values. - */ - linker_file_function_listall(lf, sdt_provide_module_function, modname); + + sdt_create_module_probes(lf, modname); } /* ARGSUSED */ @@ -258,14 +250,13 @@ sdt_destroy(void *arg, dtrace_id_t id, void *parg) { sdt_probe_t *sdt = parg, *next, *hash, *last; - modctl_t *ctl; + modctl_t *ctl = sdt->sdp_ctl; int ndx; + if (ctl->loadcnt == sdt->sdp_loadcnt) + ctl->sdt_nprobes--; + do { - ctl = sdt->sdp_ctl; - - ctl->sdt_nentries--; - /* * Now we need to remove this probe from the sdt_probetab. */ ==== //depot/projects/dtrace/src/sys/i386/i386/elf_machdep.c#5 (text+ko) ==== @@ -241,11 +241,11 @@ sdt_reloc_resolve(uint8_t *instr, sdt_probedesc_t *sdp) { int i; - instr -= SDT_SIZEOF_CALL; + instr -= SDT_SIZEOF_CALL - 1; sdp->sdpd_offset = (uintptr_t)instr; for(i = 0; i < SDT_NOPS; i++) { - instr[i] = SDT_NOP; + instr[i - 1] = SDT_NOP; } return (1); ==== //depot/projects/dtrace/src/sys/sys/kernel.h#7 (text+ko) ==== @@ -112,7 +112,6 @@ SI_SUB_WITNESS = 0x1A80000, /* witness initialization */ SI_SUB_MTX_POOL_DYNAMIC = 0x1AC0000, /* dynamic mutex pool */ SI_SUB_LOCK = 0x1B00000, /* various locks */ - SI_SUB_SDT = 0x1B80000, /* statically defined tracing */ SI_SUB_EVENTHANDLER = 0x1C00000, /* eventhandler init */ SI_SUB_KLD = 0x2000000, /* KLD and module setup */ SI_SUB_CPU = 0x2100000, /* CPU resource(s)*/