Changeset 53641 in vbox for trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace
- Timestamp:
- Jan 2, 2015 12:14:42 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dtrace.c
r53640 r53641 96 96 # include <sys/dtrace_impl.h> 97 97 # include <iprt/assert.h> 98 # include <iprt/cpuset.h> 98 99 # include <iprt/mp.h> 100 # include <iprt/string.h> 99 101 # include <iprt/process.h> 100 102 # include <iprt/thread.h> 103 # include <limits.h> 101 104 102 105 # undef NULL … … 176 179 static taskq_t *dtrace_taskq; /* task queue */ 177 180 static dtrace_probe_t **dtrace_probes; /* array of all probes */ 178 static intdtrace_nprobes; /* number of probes */181 static VBDTTYPE(uint32_t,int) dtrace_nprobes; /* number of probes */ 179 182 static dtrace_provider_t *dtrace_provider; /* provider list */ 180 183 static dtrace_meta_t *dtrace_meta_pid; /* user-land meta provider */ … … 5703 5706 hrtime_t now; 5704 5707 5708 #ifndef VBOX 5705 5709 /* 5706 5710 * Kick out immediately if this CPU is still being born (in which case … … 5710 5714 if (((uintptr_t)curthread & 1) || (curthread->t_flag & T_DONTDTRACE)) 5711 5715 return; 5716 #endif 5712 5717 5713 5718 cookie = dtrace_interrupt_disable(); … … 5726 5731 } 5727 5732 5733 #ifndef VBOX 5728 5734 if (panic_quiesce) { 5729 5735 /* … … 5733 5739 return; 5734 5740 } 5741 #endif 5735 5742 5736 5743 now = dtrace_gethrtime(); … … 5856 5863 s_cr->cr_gid != cr->cr_rgid || 5857 5864 s_cr->cr_gid != cr->cr_sgid || 5858 (proc = ttoproc(curthread)) == NULL ||5865 (proc = VBDT_GET_PROC()) == NULL || 5859 5866 (proc->p_flag & SNOCD)) 5860 5867 continue; 5861 5868 } 5862 5869 5870 #ifndef VBOX 5863 5871 if (ecb->dte_cond & DTRACE_COND_ZONEOWNER) { 5864 5872 cred_t *cr; … … 5873 5881 continue; 5874 5882 } 5883 #endif 5875 5884 } 5876 5885 … … 6004 6013 6005 6014 dtrace_getpcstack((pc_t *)(tomax + valoffs), 6006 size / sizeof (pc_t), probe->dtpr_aframes,6015 VBDTCAST(int)(size / sizeof (pc_t)), probe->dtpr_aframes, 6007 6016 DTRACE_ANCHORED(probe) ? NULL : 6008 6017 (uint32_t *)arg0); … … 6144 6153 case DTRACEACT_UMOD: 6145 6154 case DTRACEACT_UADDR: { 6155 #ifndef VBOX 6146 6156 struct pid *pid = curthread->t_procp->p_pidp; 6147 6157 … … 6153 6163 DTRACE_STORE(uint64_t, tomax, 6154 6164 valoffs + sizeof (uint64_t), val); 6155 6165 #else 6166 DTRACE_CPUFLAG_SET(CPU_DTRACE_UPRIV); 6167 #endif 6156 6168 continue; 6157 6169 } … … 6925 6937 */ 6926 6938 if (hash == NULL) { 6927 for (i = 0; i < dtrace_nprobes; i++) {6939 for (i = 0; i < VBDTCAST(dtrace_id_t)dtrace_nprobes; i++) { 6928 6940 if ((probe = dtrace_probes[i]) == NULL || 6929 6941 dtrace_match_probe(probe, pkp, priv, uid, … … 7177 7189 dtrace_provider_t *old = (dtrace_provider_t *)id; 7178 7190 dtrace_provider_t *prev = NULL; 7179 inti, self = 0;7191 VBDTTYPE(uint32_t,int) i, self = 0; 7180 7192 dtrace_probe_t *probe, *first = NULL; 7181 7193 … … 7361 7373 { 7362 7374 dtrace_provider_t *prov = (dtrace_provider_t *)id; 7363 inti;7375 VBDTTYPE(uint32_t,int) i; 7364 7376 dtrace_probe_t *probe; 7365 7377 … … 7601 7613 dtrace_probe_provide(dtrace_probedesc_t *desc, dtrace_provider_t *prv) 7602 7614 { 7615 #ifndef VBOX 7603 7616 struct modctl *ctl; 7617 #endif 7604 7618 int all = 0; 7605 7619 … … 7617 7631 prv->dtpv_pops.dtps_provide(prv->dtpv_arg, desc); 7618 7632 7633 #ifndef VBOX 7619 7634 /* 7620 7635 * Now call the per-module provide operation. We will grab … … 7635 7650 7636 7651 mutex_exit(&mod_lock); 7652 #endif 7637 7653 } while (all && (prv = prv->dtpv_next) != NULL); 7638 7654 } … … 7649 7665 dtrace_probe_t *probe; 7650 7666 dtrace_icookie_t cookie; 7651 inti;7667 VBDTTYPE(uint32_t,int) i; 7652 7668 7653 7669 /* … … 7825 7841 uintptr_t daddr = (uintptr_t)dhp->dofhp_dof; 7826 7842 dof_hdr_t *dof = (dof_hdr_t *)daddr; 7827 inti;7843 VBDTTYPE(uint32_t,int) i; 7828 7844 7829 7845 ASSERT(MUTEX_HELD(&dtrace_meta_lock)); … … 7882 7898 uintptr_t daddr = (uintptr_t)dhp->dofhp_dof; 7883 7899 dof_hdr_t *dof = (dof_hdr_t *)daddr; 7884 inti;7900 VBDTTYPE(uint32_t,int) i; 7885 7901 7886 7902 ASSERT(MUTEX_HELD(&dtrace_meta_lock)); … … 7909 7925 dtrace_meta_t *meta; 7910 7926 dtrace_helpers_t *help, *next; 7911 inti;7927 VBDTTYPE(uint32_t,int) i; 7912 7928 7913 7929 *idp = DTRACE_METAPROVNONE; … … 8051 8067 cred_t *cr) 8052 8068 { 8069 #ifndef VBOX 8053 8070 int err = 0, i; 8071 #else 8072 int err = 0; 8073 uint_t i; 8074 #endif 8054 8075 int (*efunc)(uint_t pc, const char *, ...) = dtrace_difo_err; 8055 8076 int kcheckload; … … 8370 8391 switch (v->dtdv_scope) { 8371 8392 case DIFV_SCOPE_GLOBAL: 8372 if ( ndx < vstate->dtvs_nglobals) {8393 if (VBDTCAST(int64_t)ndx < vstate->dtvs_nglobals) { 8373 8394 dtrace_statvar_t *svar; 8374 8395 … … 8380 8401 8381 8402 case DIFV_SCOPE_THREAD: 8382 if ( ndx < vstate->dtvs_ntlocals)8403 if (VBDTCAST(int64_t)ndx < vstate->dtvs_ntlocals) 8383 8404 existing = &vstate->dtvs_tlocals[ndx]; 8384 8405 break; 8385 8406 8386 8407 case DIFV_SCOPE_LOCAL: 8387 if ( ndx < vstate->dtvs_nlocals) {8408 if (VBDTCAST(int64_t)ndx < vstate->dtvs_nlocals) { 8388 8409 dtrace_statvar_t *svar; 8389 8410 … … 8597 8618 dtrace_difo_cacheable(dtrace_difo_t *dp) 8598 8619 { 8599 inti;8620 VBDTTYPE(uint_t,int) i; 8600 8621 8601 8622 if (dp == NULL) … … 8642 8663 dtrace_difo_hold(dtrace_difo_t *dp) 8643 8664 { 8644 inti;8665 VBDTTYPE(uint_t,int) i; 8645 8666 8646 8667 ASSERT(MUTEX_HELD(&dtrace_lock)); … … 8809 8830 dtrace_difo_init(dtrace_difo_t *dp, dtrace_vstate_t *vstate) 8810 8831 { 8832 #ifndef VBOX 8811 8833 int i, oldsvars, osz, nsz, otlocals, ntlocals; 8834 #else 8835 int oldsvars, osz, nsz, otlocals, ntlocals; 8836 uint_t i; 8837 #endif 8812 8838 uint_t id; 8813 8839 … … 8829 8855 switch (scope) { 8830 8856 case DIFV_SCOPE_THREAD: 8831 while ( id >= (otlocals = vstate->dtvs_ntlocals)) {8857 while (VBDTCAST(int64_t)id >= (otlocals = vstate->dtvs_ntlocals)) { 8832 8858 dtrace_difv_t *tlocals; 8833 8859 … … 8879 8905 } 8880 8906 8881 while ( id >= (oldsvars = *np)) {8907 while (VBDTCAST(int64_t)id >= (oldsvars = *np)) { 8882 8908 dtrace_statvar_t **statics; 8883 8909 int newsvars, oldsize, newsize; … … 8966 8992 dtrace_difo_destroy(dtrace_difo_t *dp, dtrace_vstate_t *vstate) 8967 8993 { 8968 inti;8994 VBDTTYPE(uint_t,int) i; 8969 8995 8970 8996 ASSERT(dp->dtdo_refcnt == 0); … … 8999 9025 9000 9026 id -= DIF_VAR_OTHER_UBASE; 9001 ASSERT( id < *np);9027 ASSERT(VBDTCAST(int64_t)id < *np); 9002 9028 9003 9029 svar = svarp[id]; … … 9029 9055 dtrace_difo_release(dtrace_difo_t *dp, dtrace_vstate_t *vstate) 9030 9056 { 9031 inti;9057 VBDTTYPE(uint_t,int) i; 9032 9058 9033 9059 ASSERT(MUTEX_HELD(&dtrace_lock)); … … 9056 9082 { 9057 9083 char *fmt, **new; 9058 uint16_t ndx, len = strlen(str) + 1;9084 uint16_t ndx, len = VBDTCAST(uint16_t)strlen(str) + 1; 9059 9085 9060 9086 fmt = kmem_zalloc(len, KM_SLEEP); … … 9276 9302 epid = state->dts_epid++; 9277 9303 9278 if ( epid - 1 >= state->dts_necbs) {9304 if (VBDTCAST(int64_t)epid - 1 >= state->dts_necbs) { 9279 9305 dtrace_ecb_t **oecbs = state->dts_ecbs, **ecbs; 9280 9306 int necbs = state->dts_necbs << 1; … … 9557 9583 } 9558 9584 9559 agg->dtag_action.dta_rec.dtrd_size = size;9585 agg->dtag_action.dta_rec.dtrd_size = VBDTCAST(uint32_t)size; 9560 9586 9561 9587 if (ntuple == 0) … … 9607 9633 VM_BESTFIT | VM_SLEEP); 9608 9634 9609 if ( aggid - 1 >= state->dts_naggregations) {9635 if (VBDTCAST(int64_t)aggid - 1 >= state->dts_naggregations) { 9610 9636 dtrace_aggregation_t **oaggs = state->dts_aggregations; 9611 9637 dtrace_aggregation_t **aggs; … … 9747 9773 } 9748 9774 9749 size = nframes * sizeof (pc_t);9775 size = VBDTCAST(uint32_t)(nframes * sizeof (pc_t)); 9750 9776 break; 9751 9777 … … 9772 9798 * Save a slot for the pid. 9773 9799 */ 9774 size = (nframes + 1) * sizeof (uint64_t);9800 size = VBDTCAST(uint32_t)((nframes + 1) * sizeof (uint64_t)); 9775 9801 size += DTRACE_USTACK_STRSIZE(arg); 9776 9802 size = P2ROUNDUP(size, (uint32_t)(sizeof (uintptr_t))); … … 10160 10186 ASSERT(MUTEX_HELD(&dtrace_lock)); 10161 10187 10162 if (id == 0 || id > state->dts_necbs)10188 if (id == 0 || VBDTCAST(int64_t)id > state->dts_necbs) 10163 10189 return (NULL); 10164 10190 … … 10176 10202 ASSERT(MUTEX_HELD(&dtrace_lock)); 10177 10203 10178 if (id == 0 || id > state->dts_naggregations)10204 if (id == 0 || VBDTCAST(int64_t)id > state->dts_naggregations) 10179 10205 return (NULL); 10180 10206 … … 10256 10282 processorid_t cpu) 10257 10283 { 10284 #ifndef VBOX 10258 10285 cpu_t *cp; 10286 #else 10287 RTCPUSET CpuSet; 10288 unsigned iCpu; 10289 #endif 10259 10290 dtrace_buffer_t *buf; 10260 10291 … … 10262 10293 ASSERT(MUTEX_HELD(&dtrace_lock)); 10263 10294 10264 if (size > dtrace_nonroot_maxsize && 10265 !PRIV_POLICY_CHOICE(CRED(), PRIV_ALL, B_FALSE)) 10295 if (VBDTCAST(int64_t)size > dtrace_nonroot_maxsize 10296 #ifndef VBOX 10297 && !PRIV_POLICY_CHOICE(CRED(), PRIV_ALL, B_FALSE) 10298 #endif 10299 ) 10266 10300 return (EFBIG); 10267 10301 10302 #ifndef VBOX 10268 10303 cp = cpu_list; 10269 10304 #else 10305 RTMpGetSet(&CpuSet); 10306 #endif 10307 10308 #ifndef VBOX 10270 10309 do { 10271 10310 if (cpu != DTRACE_CPUALL && cpu != cp->cpu_id) … … 10273 10312 10274 10313 buf = &bufs[cp->cpu_id]; 10314 #else 10315 for (iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++) { 10316 if ( !RTCpuSetIsMember(&CpuSet, iCpu) 10317 || (cpu != DTRACE_CPUALL && cpu != iCpu)) 10318 continue; 10319 10320 buf = &bufs[iCpu]; 10321 #endif 10275 10322 10276 10323 /* … … 10299 10346 if ((buf->dtb_xamot = kmem_zalloc(size, KM_NOSLEEP)) == NULL) 10300 10347 goto err; 10348 #ifndef VBOX 10301 10349 } while ((cp = cp->cpu_next) != cpu_list); 10350 #else 10351 } 10352 #endif 10302 10353 10303 10354 return (0); 10304 10355 10305 10356 err: 10357 #ifndef VBOX 10306 10358 cp = cpu_list; 10307 10359 … … 10311 10363 10312 10364 buf = &bufs[cp->cpu_id]; 10365 #else 10366 for (iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++) { 10367 if ( !RTCpuSetIsMember(&CpuSet, iCpu) 10368 || (cpu != DTRACE_CPUALL && cpu != iCpu)) 10369 continue; 10370 10371 buf = &bufs[iCpu]; 10372 #endif 10313 10373 10314 10374 if (buf->dtb_xamot != NULL) { … … 10326 10386 buf->dtb_xamot = NULL; 10327 10387 buf->dtb_size = 0; 10388 #ifndef VBOX 10328 10389 } while ((cp = cp->cpu_next) != cpu_list); 10390 #else 10391 } 10392 #endif 10329 10393 10330 10394 return (ENOMEM); … … 10379 10443 } 10380 10444 10381 if ( (soffs = offs + needed) > buf->dtb_size) {10445 if (VBDTCAST(uintptr_t)(soffs = offs + needed) > buf->dtb_size) { 10382 10446 dtrace_buffer_drop(buf); 10383 10447 return (-1); … … 10450 10514 * offset to the end (there may be old gunk there). 10451 10515 */ 10452 while ( offs < buf->dtb_size)10516 while (VBDTCAST(uintptr_t)offs < buf->dtb_size) 10453 10517 tomax[offs++] = 0; 10454 10518 … … 10487 10551 } 10488 10552 10489 while ( offs + total >woffs) {10553 while (VBDTCAST(uintptr_t)offs + total > VBDTCAST(uintptr_t)woffs) { 10490 10554 dtrace_epid_t epid = *(uint32_t *)(tomax + woffs); 10491 10555 size_t size; … … 10494 10558 size = sizeof (uint32_t); 10495 10559 } else { 10496 ASSERT( epid <= state->dts_necbs);10560 ASSERT(VBDTCAST(int64_t)epid <= state->dts_necbs); 10497 10561 ASSERT(state->dts_ecbs[epid - 1] != NULL); 10498 10562 … … 10529 10593 woffs = total; 10530 10594 10531 while ( woffs < buf->dtb_size)10595 while (VBDTCAST(uintptr_t)woffs < buf->dtb_size) 10532 10596 tomax[woffs++] = 0; 10533 10597 } … … 11016 11080 cred_t *cr = enab->dten_vstate->dtvs_state->dts_cred.dcr_cred; 11017 11081 11082 #ifndef VBOX 11018 11083 if (INGLOBALZONE(curproc) || 11019 11084 cr != NULL && getzoneid() == crgetzoneid(cr)) 11085 #endif 11020 11086 (void) dtrace_enabling_match(enab, NULL); 11021 11087 }
Note:
See TracChangeset
for help on using the changeset viewer.