[PATCH v2 4/4] options: discontinue -xversion=V as a valid option
Kris Van Hees <[email protected]>
| Newsgroups | dev.linux.lists.dtrace |
|---|---|
| Message-ID | <DS0PR10MB75225B4E633FF1F79FABFFFEC2A8A@DS0PR10MB7522.namprd10.prod.outlook.com> |
DTrace allowed setting a previous version to operate in compatibility mode. Unfortunately, it was not fully implemented. Translators are not really versioned, and if a translator uses an identifier that does not exist in the version specified in -xversion=V, data structures end up corrupted. Since the usefulness of -xversion=V seems to be less than the effort needed to rectify the implementation, we are no longer supporting this option. Tests added to ensure that the error is reported for -xversion=V and when set using a pragma. The former version tests have been removed as they have become obsolete. Signed-off-by: Kris Van Hees <[email protected]> --- libdtrace/dt_options.c | 14 ++--------- test/unittest/options/err.version-pragma.d | 18 ++++++++++++++ test/unittest/options/err.version-pragma.r | 2 ++ test/unittest/options/err.version.d | 4 ++-- test/unittest/options/err.version.r | 2 +- test/unittest/options/tst.version.r | 1 - test/unittest/options/tst.version.sh | 14 ----------- test/unittest/version/err.1.1.d | 27 --------------------- test/unittest/version/tst.1.0.d | 28 ---------------------- 9 files changed, 25 insertions(+), 85 deletions(-) create mode 100644 test/unittest/options/err.version-pragma.d create mode 100644 test/unittest/options/err.version-pragma.r delete mode 100644 test/unittest/options/tst.version.r delete mode 100755 test/unittest/options/tst.version.sh delete mode 100644 test/unittest/version/err.1.1.d delete mode 100644 test/unittest/version/tst.1.0.d diff --git a/libdtrace/dt_options.c b/libdtrace/dt_options.c index 97516517..0a35e852 100644 --- a/libdtrace/dt_options.c +++ b/libdtrace/dt_options.c @@ -24,6 +24,7 @@ #include <dt_pcap.h> #include <dt_string.h> #include <libproc.h> +#include <port.h> static int dt_opt_agg(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) @@ -676,18 +677,7 @@ dt_opt_invcflags(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) static int dt_opt_version(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) { - dt_version_t v; - - if (arg == NULL) - return dt_set_errno(dtp, EDT_BADOPTVAL); - - if (dt_version_str2num(arg, &v) == -1) - return dt_set_errno(dtp, EDT_VERSINVAL); - - if (!dt_version_defined(v)) - return dt_set_errno(dtp, EDT_VERSUNDEF); - - return dt_reduce(dtp, v); + return dt_set_errno(dtp, ENOTSUPP); } static int diff --git a/test/unittest/options/err.version-pragma.d b/test/unittest/options/err.version-pragma.d new file mode 100644 index 00000000..88825ef6 --- /dev/null +++ b/test/unittest/options/err.version-pragma.d @@ -0,0 +1,18 @@ +/* + * Oracle Linux DTrace. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Licensed under the Universal Permissive License v 1.0 as shown at + * http://oss.oracle.com/licenses/upl. + */ + +/* + * ASSERTION: The -xversion option is deprecated. + * + * SECTION: Options and Tunables/Consumer Options + */ + +#pragma D option version=99.1 + +BEGIN { + exit(0); +} diff --git a/test/unittest/options/err.version-pragma.r b/test/unittest/options/err.version-pragma.r new file mode 100644 index 00000000..279186d3 --- /dev/null +++ b/test/unittest/options/err.version-pragma.r @@ -0,0 +1,2 @@ +-- @@stderr -- +dtrace: failed to compile script test/unittest/options/err.version-pragma.d: line 14: failed to set option 'version' to '99.1': Operation not supported diff --git a/test/unittest/options/err.version.d b/test/unittest/options/err.version.d index bd86e13f..093b29aa 100644 --- a/test/unittest/options/err.version.d +++ b/test/unittest/options/err.version.d @@ -1,12 +1,12 @@ /* * Oracle Linux DTrace. - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ /* - * ASSERTION: The -xversion option works. + * ASSERTION: The -xversion option is deprecated. * * SECTION: Options and Tunables/Consumer Options */ diff --git a/test/unittest/options/err.version.r b/test/unittest/options/err.version.r index 6cdd1f7f..7c659859 100644 --- a/test/unittest/options/err.version.r +++ b/test/unittest/options/err.version.r @@ -1,2 +1,2 @@ -- @@stderr -- -dtrace: failed to set -x version: Requested version is not supported by compiler +dtrace: failed to set -x version: Operation not supported diff --git a/test/unittest/options/tst.version.r b/test/unittest/options/tst.version.r deleted file mode 100644 index 8b137891..00000000 --- a/test/unittest/options/tst.version.r +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/unittest/options/tst.version.sh b/test/unittest/options/tst.version.sh deleted file mode 100755 index 37fb6f75..00000000 --- a/test/unittest/options/tst.version.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# -# Oracle Linux DTrace. -# Copyright (c) 2023, 2025,Oracle and/or its affiliates. All rights reserved. -# Licensed under the Universal Permissive License v 1.0 as shown at -# http://oss.oracle.com/licenses/upl. -# - -dtrace=$1 - -myversion=`$dtrace $dt_flags -V | gawk '{ print $NF }'` - -$dtrace $dt_flags -xversion=$myversion -qn 'BEGIN { exit(0) }' -exit $? diff --git a/test/unittest/version/err.1.1.d b/test/unittest/version/err.1.1.d deleted file mode 100644 index 0b63421f..00000000 --- a/test/unittest/version/err.1.1.d +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Oracle Linux DTrace. - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ -/* @@runtest-opts: -Ze */ - -#pragma D option version=1.1 - -/* - * The following identifiers were added as D built-ins as of version 1.1. - * Using these identifiers as user-specified variables should be illegal in - * that and any later versions, but legal in earlier versions. - */ -int strstr; -int strchr; -int strrchr; -int strtok; -int substr; -int index; -int freopen; - -write:entry -{ - exit(0); -} diff --git a/test/unittest/version/tst.1.0.d b/test/unittest/version/tst.1.0.d deleted file mode 100644 index 79f23b0d..00000000 --- a/test/unittest/version/tst.1.0.d +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Oracle Linux DTrace. - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ -/* @@runtest-opts: -Ze */ - -#pragma D option version=1.0 - -/* - * The following identifiers were added as D built-ins as of version 1.1. - * Using these identifiers as user-specified variables should be illegal in - * that and any later versions, but legal in earlier versions. - */ -int strstr; -int strchr; -int strrchr; -int strtok; -int substr; -int index; -int freopen; - -write:entry -{ - exit(0); -} - -- 2.51.0