From owner-p4-projects@FreeBSD.ORG Sat Feb 23 00:06:47 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7D05D16A404; Sat, 23 Feb 2008 00:06:47 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4289016A400 for ; Sat, 23 Feb 2008 00:06:47 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 3B5C213C4D5 for ; Sat, 23 Feb 2008 00:06:47 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m1N06lnO076316 for ; Sat, 23 Feb 2008 00:06:47 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m1N06lQ0076313 for perforce@freebsd.org; Sat, 23 Feb 2008 00:06:47 GMT (envelope-from jb@freebsd.org) Date: Sat, 23 Feb 2008 00:06:47 GMT Message-Id: <200802230006.m1N06lQ0076313@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 135997 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: Sat, 23 Feb 2008 00:06:48 -0000 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