diff options
author | Bryan Cantrill <bryan@joyent.com> | 2011-07-12 21:51:55 -0700 |
---|---|---|
committer | Bryan Cantrill <bryan@joyent.com> | 2011-07-12 21:51:55 -0700 |
commit | 14c0b03165f67fc77b52e53701ea2a4a41976948 (patch) | |
tree | 03fb88201eebb3a25d7456f7b96ea056aaaa416f /usr/src | |
parent | 1ea5f93d6265bec480d4d5f9640ddffbfcd03df1 (diff) | |
download | illumos-gate-14c0b03165f67fc77b52e53701ea2a4a41976948.tar.gz |
1451 DTrace needs toupper()/tolower() subroutines
Reviewed by: Gordon Ross <gwr@nexenta.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Approved by: Garrett D'Amore <garrett@nexenta.com>
Diffstat (limited to 'usr/src')
13 files changed, 383 insertions, 6 deletions
diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d index 5ca1f1ef93..bb0739f0d3 100644 --- a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d +++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/dtrace.h> #define INTFUNC(x) \ @@ -98,6 +96,8 @@ INTFUNC(ntohll(0x1234567890abcdefL)) STRFUNC(inet_ntoa((ipaddr_t *)alloca(sizeof (ipaddr_t)))) STRFUNC(inet_ntoa6((in6_addr_t *)alloca(sizeof (in6_addr_t)))) STRFUNC(inet_ntop(AF_INET, (void *)alloca(sizeof (ipaddr_t)))) +STRFUNC(toupper("foo")) +STRFUNC(tolower("BAR")) BEGIN /subr == DIF_SUBR_MAX + 1/ diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.tolower.d b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.tolower.d new file mode 100644 index 0000000000..9d4e40b4db --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.tolower.d @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(tolower(2152006)); + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.toupper.d b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.toupper.d new file mode 100644 index 0000000000..2c1389bdeb --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_ARG.toupper.d @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(toupper(timestamp)); + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolower.d b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolower.d new file mode 100644 index 0000000000..7d9c27f902 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolower.d @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(tolower()); + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolowertoomany.d b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolowertoomany.d new file mode 100644 index 0000000000..afaa7f976e --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.tolowertoomany.d @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(tolower("dory", "eel", "roughy")); + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.toupper.d b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.toupper.d new file mode 100644 index 0000000000..9658f6a754 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.toupper.d @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(toupper()); + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.touppertoomany.d b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.touppertoomany.d new file mode 100644 index 0000000000..bee8697fb2 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.touppertoomany.d @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +BEGIN +{ + trace(tolower("haino", "tylo")); + exit(1); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/tst.tolower.d b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.tolower.d new file mode 100644 index 0000000000..2539630e9d --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.tolower.d @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; + + input[i] = "ahi"; + expected[i++] = "ahi"; + + input[i] = "MaHi!"; + expected[i++] = "mahi!"; + + input[i] = " Nase-5"; + expected[i++] = " nase-5"; + + input[i] = "!@#$%"; + expected[i++] = "!@#$%"; + + i = 0; +} + +tick-1ms +/input[i] != NULL && (this->out = tolower(input[i])) != expected[i]/ +{ + printf("expected tolower(\"%s\") to be \"%s\"; found \"%s\"\n", + input[i], expected[i], this->out); + exit(1); +} + +tick-1ms +/input[i] != NULL/ +{ + printf("tolower(\"%s\") is \"%s\", as expected\n", + input[i], expected[i]); +} + +tick-1ms +/input[i++] == NULL/ +{ + exit(0); +} diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/tst.toupper.d b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.toupper.d new file mode 100644 index 0000000000..fd803f2ef0 --- /dev/null +++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.toupper.d @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2011, Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +BEGIN +{ + i = 0; + + input[i] = "ahi"; + expected[i++] = "AHI"; + + input[i] = "MaHi!"; + expected[i++] = "MAHI!"; + + input[i] = " dace-9"; + expected[i++] = " DACE-9"; + + input[i] = "!@#$%"; + expected[i++] = "!@#$%"; + + i = 0; +} + +tick-1ms +/input[i] != NULL && (this->out = toupper(input[i])) != expected[i]/ +{ + printf("expected toupper(\"%s\") to be \"%s\"; found \"%s\"\n", + input[i], expected[i], this->out); + exit(1); +} + +tick-1ms +/input[i] != NULL/ +{ + printf("toupper(\"%s\") is \"%s\", as expected\n", + input[i], expected[i]); +} + +tick-1ms +/input[i++] == NULL/ +{ + exit(0); +} diff --git a/usr/src/lib/libdtrace/common/dt_open.c b/usr/src/lib/libdtrace/common/dt_open.c index 4f366f2b22..84adcfd88c 100644 --- a/usr/src/lib/libdtrace/common/dt_open.c +++ b/usr/src/lib/libdtrace/common/dt_open.c @@ -106,8 +106,9 @@ #define DT_VERS_1_6_3 DT_VERSION_NUMBER(1, 6, 3) #define DT_VERS_1_7 DT_VERSION_NUMBER(1, 7, 0) #define DT_VERS_1_7_1 DT_VERSION_NUMBER(1, 7, 1) -#define DT_VERS_LATEST DT_VERS_1_7_1 -#define DT_VERS_STRING "Sun D 1.7.1" +#define DT_VERS_1_8 DT_VERSION_NUMBER(1, 8, 0) +#define DT_VERS_LATEST DT_VERS_1_8 +#define DT_VERS_STRING "Sun D 1.8" const dt_version_t _dtrace_versions[] = { DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */ @@ -125,6 +126,7 @@ const dt_version_t _dtrace_versions[] = { DT_VERS_1_6_3, /* D API 1.6.3 */ DT_VERS_1_7, /* D API 1.7 */ DT_VERS_1_7_1, /* D API 1.7.1 */ + DT_VERS_1_8, /* D API 1.8 */ 0 }; @@ -379,6 +381,10 @@ static const dt_ident_t _dtrace_globals[] = { { "timestamp", DT_IDENT_SCALAR, 0, DIF_VAR_TIMESTAMP, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "uint64_t" }, +{ "tolower", DT_IDENT_FUNC, 0, DIF_SUBR_TOLOWER, DT_ATTR_STABCMN, DT_VERS_1_8, + &dt_idops_func, "string(const char *)" }, +{ "toupper", DT_IDENT_FUNC, 0, DIF_SUBR_TOUPPER, DT_ATTR_STABCMN, DT_VERS_1_8, + &dt_idops_func, "string(const char *)" }, { "trace", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACE, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "void(@)" }, { "tracemem", DT_IDENT_ACTFUNC, 0, DT_ACT_TRACEMEM, diff --git a/usr/src/pkg/manifests/system-dtrace-tests.mf b/usr/src/pkg/manifests/system-dtrace-tests.mf index 4949d8272a..d9d2ec541d 100644 --- a/usr/src/pkg/manifests/system-dtrace-tests.mf +++ b/usr/src/pkg/manifests/system-dtrace-tests.mf @@ -748,6 +748,8 @@ file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_ARG.copyoutbadarg.d \ file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_ARG.mobadarg.d mode=0444 file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_ARG.raisebadarg.d \ mode=0444 +file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_ARG.tolower.d mode=0444 +file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_ARG.toupper.d mode=0444 file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_LEN.allocanoarg.d \ mode=0444 file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_LEN.badbreakpoint.d \ @@ -774,6 +776,12 @@ file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_LEN.panicbadarg.d \ file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_LEN.progenyofbad2.d \ mode=0444 file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_LEN.stopbadarg.d mode=0444 +file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_LEN.tolower.d mode=0444 +file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_LEN.tolowertoomany.d \ + mode=0444 +file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_LEN.toupper.d mode=0444 +file path=opt/SUNWdtrt/tst/common/funcs/err.D_PROTO_LEN.touppertoomany.d \ + mode=0444 file path=opt/SUNWdtrt/tst/common/funcs/err.D_STRINGOF_TYPE.badstringof.d \ mode=0444 file path=opt/SUNWdtrt/tst/common/funcs/err.D_VAR_UNDEF.badvar.d mode=0444 @@ -840,6 +848,8 @@ file path=opt/SUNWdtrt/tst/common/funcs/tst.substrminate.d mode=0444 file path=opt/SUNWdtrt/tst/common/funcs/tst.substrminate.d.out mode=0444 file path=opt/SUNWdtrt/tst/common/funcs/tst.system.d mode=0444 file path=opt/SUNWdtrt/tst/common/funcs/tst.system.d.out mode=0444 +file path=opt/SUNWdtrt/tst/common/funcs/tst.tolower.d mode=0444 +file path=opt/SUNWdtrt/tst/common/funcs/tst.toupper.d mode=0444 file path=opt/SUNWdtrt/tst/common/grammar/err.D_ADDROF_LVAL.d mode=0444 file path=opt/SUNWdtrt/tst/common/grammar/err.D_EMPTY.empty.d mode=0444 file path=opt/SUNWdtrt/tst/common/grammar/tst.clauses.d mode=0444 diff --git a/usr/src/uts/common/dtrace/dtrace.c b/usr/src/uts/common/dtrace/dtrace.c index 26d3be2a9e..159a4cb14a 100644 --- a/usr/src/uts/common/dtrace/dtrace.c +++ b/usr/src/uts/common/dtrace/dtrace.c @@ -3904,7 +3904,54 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs, break; } - case DIF_SUBR_GETMAJOR: + case DIF_SUBR_TOUPPER: + case DIF_SUBR_TOLOWER: { + uintptr_t s = tupregs[0].dttk_value; + uint64_t size = state->dts_options[DTRACEOPT_STRSIZE]; + char *dest = (char *)mstate->dtms_scratch_ptr, c; + size_t len = dtrace_strlen((char *)s, size); + char lower, upper, convert; + int64_t i; + + if (subr == DIF_SUBR_TOUPPER) { + lower = 'a'; + upper = 'z'; + convert = 'A'; + } else { + lower = 'A'; + upper = 'Z'; + convert = 'a'; + } + + if (!dtrace_canload(s, len + 1, mstate, vstate)) { + regs[rd] = NULL; + break; + } + + if (!DTRACE_INSCRATCH(mstate, size)) { + DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH); + regs[rd] = NULL; + break; + } + + for (i = 0; i < size - 1; i++) { + if ((c = dtrace_load8(s + i)) == '\0') + break; + + if (c >= lower && c <= upper) + c = convert + (c - lower); + + dest[i] = c; + } + + ASSERT(i < size); + dest[i] = '\0'; + regs[rd] = (uintptr_t)dest; + mstate->dtms_scratch_ptr += size; + break; + } + +case DIF_SUBR_GETMAJOR: #ifdef _LP64 regs[rd] = (tupregs[0].dttk_value >> NBITSMINOR64) & MAXMAJ64; #else diff --git a/usr/src/uts/common/sys/dtrace.h b/usr/src/uts/common/sys/dtrace.h index 7e6b8c2766..c15799a4e4 100644 --- a/usr/src/uts/common/sys/dtrace.h +++ b/usr/src/uts/common/sys/dtrace.h @@ -285,8 +285,10 @@ typedef enum dtrace_probespec { #define DIF_SUBR_INET_NTOP 41 #define DIF_SUBR_INET_NTOA 42 #define DIF_SUBR_INET_NTOA6 43 +#define DIF_SUBR_TOUPPER 44 +#define DIF_SUBR_TOLOWER 45 -#define DIF_SUBR_MAX 43 /* max subroutine value */ +#define DIF_SUBR_MAX 45 /* max subroutine value */ typedef uint32_t dif_instr_t; |