Date: Sat, 23 Feb 2008 00:06:47 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 135997 for review Message-ID: <200802230006.m1N06lQ0076313@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=135997 Change 135997 by jb@jb_freebsd1 on 2008/02/23 00:06:24 Flesh out the printt() action. Affected files ... .. //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/dtrace/dtrace.c#40 edit Differences ... ==== //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/dtrace/dtrace.c#40 (text) ==== @@ -4509,14 +4509,15 @@ } case DIF_SUBR_TYPEREF: { - uintptr_t size = 3 * sizeof(uintptr_t); + uintptr_t size = 4 * sizeof(uintptr_t); uintptr_t *typeref = (uintptr_t *) P2ROUNDUP(mstate->dtms_scratch_ptr, sizeof(uintptr_t)); size_t scratch_size = ((uintptr_t) typeref - mstate->dtms_scratch_ptr) + size; - /* address, length, type */ + /* address, num_elements, type_str, type_len */ typeref[0] = tupregs[0].dttk_value; typeref[1] = tupregs[1].dttk_value; typeref[2] = tupregs[2].dttk_value; + typeref[3] = tupregs[3].dttk_value; regs[rd] = (uintptr_t) typeref; mstate->dtms_scratch_ptr += scratch_size; @@ -6067,30 +6068,53 @@ case DTRACEACT_PRINTT: { /* The DIF returns a 'typeref'. */ uintptr_t *typeref = (uintptr_t *)(uintptr_t) val; + char c = '\0' + 1; + size_t s; + + /* + * Get the type string length and round it + * up so that the data that follows is + * aligned for easy access. + */ + size_t typs = strlen((char *) typeref[2]) + 1; + typs = roundup(typs, sizeof(uintptr_t)); - /* Get the size from the typeref. */ - size = typeref[1]; + /* + *Get the size from the typeref using the + * number of elements and the type size. + */ + size = typeref[1] * typeref[3]; /* * Check if the size exceeds the allocated * buffer size. */ - if (size + sizeof(uintptr_t) > dp->dtdo_rtype.dtdt_size) { + if (size + typs + 2 * sizeof(uintptr_t) > dp->dtdo_rtype.dtdt_size) { /* Flag a drop! */ *flags |= CPU_DTRACE_DROP; - continue; + } /* Store the size in the buffer first. */ DTRACE_STORE(uintptr_t, tomax, valoffs, size); + valoffs += sizeof(uintptr_t); - /* - * Offset the buffer address to the start - * of the data. - */ + /* Store the type size in the buffer. */ + DTRACE_STORE(uintptr_t, tomax, + valoffs, typeref[3]); valoffs += sizeof(uintptr_t); + val = typeref[2]; + + for (s = 0; s < typs; s++) { + if (c != '\0') + c = dtrace_load8(val++); + + DTRACE_STORE(uint8_t, tomax, + valoffs++, c); + } + /* * Reset to the memory address rather than * the typeref array, then let the BYREF
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802230006.m1N06lQ0076313>