* [PATCH 2/4] Eliminate DT_VERS_LATEST
2025-02-08 19:06 [PATCH 1/4] Rename _DTRACE_VERSION eugene.loh
@ 2025-02-08 19:06 ` eugene.loh
2025-02-27 16:40 ` Kris Van Hees
2025-02-08 19:06 ` [PATCH 3/4] Sync up the version numbers eugene.loh
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: eugene.loh @ 2025-02-08 19:06 UTC (permalink / raw)
To: dtrace, dtrace-devel
From: Eugene Loh <eugene.loh@oracle.com>
Updating the DTrace version number requires too many distinct
changes. Eliminate DT_VERS_LATEST, since it can be determined
on the fly.
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
libdtrace/dt_open.c | 3 ++-
libdtrace/dt_version.h | 14 +++++---------
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/libdtrace/dt_open.c b/libdtrace/dt_open.c
index a02058871..b4d160359 100644
--- a/libdtrace/dt_open.c
+++ b/libdtrace/dt_open.c
@@ -721,7 +721,8 @@ dt_vopen(int version, int flags, int *errp,
dtp->dt_proc_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
if (dt_aggregate_init(dtp) == -1)
return set_open_errno(dtp, errp, dtrace_errno(dtp));
- dtp->dt_vmax = DT_VERS_LATEST;
+ for (i = 0; _dtrace_versions[i] != 0; i++)
+ dtp->dt_vmax = _dtrace_versions[i];
dtp->dt_cpp_path = strdup(_dtrace_defcpp);
dtp->dt_cpp_argv = malloc(sizeof(char *));
dtp->dt_cpp_argc = 1;
diff --git a/libdtrace/dt_version.h b/libdtrace/dt_version.h
index 3fd1b3d1e..bef3243e9 100644
--- a/libdtrace/dt_version.h
+++ b/libdtrace/dt_version.h
@@ -38,18 +38,15 @@ extern "C" {
*
* These #defines are used in identifier tables to fill in the version fields
* associated with each identifier. The DT_VERS_* macros declare the encoded
- * integer values of all versions used so far. DT_VERS_LATEST must correspond
- * to the latest version value among all versions exported by the D compiler.
- * DT_VERS_STRING must be an ASCII string that contains DT_VERS_LATEST within
- * it along with any suffixes (e.g. Beta).
+ * integer values of all versions used so far. DT_VERS_STRING must be an ASCII
+ * string that contains the latest version within it along with any suffixes
+ * (e.g. Beta). You must update DT_VERS_STRING when adding a new version,
+ * and then add the new version to the _dtrace_versions[] array declared in
+ * dt_open.c.
*
* Refer to the Solaris Dynamic Tracing Guide Versioning chapter for an
* explanation of these DTrace features and their values.
*
- * You must update DT_VERS_LATEST and DT_VERS_STRING when adding a new version,
- * and then add the new version to the _dtrace_versions[] array declared in
- * dt_open.c..
- *
* NOTE: Although the DTrace versioning scheme supports the labeling and
* introduction of incompatible changes (e.g. dropping an interface in a
* major release), the libdtrace code does not currently support this.
@@ -85,7 +82,6 @@ extern "C" {
#define DT_VERS_2_0 DT_VERSION_NUMBER(2, 0, 0)
#define DT_VERS_2_0_1 DT_VERSION_NUMBER(2, 0, 1)
-#define DT_VERS_LATEST DT_VERS_2_0_1
#define DT_VERS_STRING "Oracle D 2.0"
#ifdef __cplusplus
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH 2/4] Eliminate DT_VERS_LATEST
2025-02-08 19:06 ` [PATCH 2/4] Eliminate DT_VERS_LATEST eugene.loh
@ 2025-02-27 16:40 ` Kris Van Hees
2025-02-27 16:57 ` [DTrace-devel] " Kris Van Hees
0 siblings, 1 reply; 11+ messages in thread
From: Kris Van Hees @ 2025-02-27 16:40 UTC (permalink / raw)
To: eugene.loh; +Cc: dtrace, dtrace-devel
On Sat, Feb 08, 2025 at 02:06:20PM -0500, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
>
> Updating the DTrace version number requires too many distinct
> changes. Eliminate DT_VERS_LATEST, since it can be determined
> on the fly.
>
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
> ---
> libdtrace/dt_open.c | 3 ++-
> libdtrace/dt_version.h | 14 +++++---------
> 2 files changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/libdtrace/dt_open.c b/libdtrace/dt_open.c
> index a02058871..b4d160359 100644
> --- a/libdtrace/dt_open.c
> +++ b/libdtrace/dt_open.c
> @@ -721,7 +721,8 @@ dt_vopen(int version, int flags, int *errp,
> dtp->dt_proc_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
> if (dt_aggregate_init(dtp) == -1)
> return set_open_errno(dtp, errp, dtrace_errno(dtp));
> - dtp->dt_vmax = DT_VERS_LATEST;
> + for (i = 0; _dtrace_versions[i] != 0; i++)
> + dtp->dt_vmax = _dtrace_versions[i];
dtp->dt_vmax = _dtrace_versions[ARRAY_SIZE(_dtrace_versions) - 2];
(-2 to account for the 0 sentinel value)
But this will only be accurate if you also add 2.0.1 to the _dtrace_versions
array, and then you should probably add 2.0.2 to it also for accuracy.
> dtp->dt_cpp_path = strdup(_dtrace_defcpp);
> dtp->dt_cpp_argv = malloc(sizeof(char *));
> dtp->dt_cpp_argc = 1;
> diff --git a/libdtrace/dt_version.h b/libdtrace/dt_version.h
> index 3fd1b3d1e..bef3243e9 100644
> --- a/libdtrace/dt_version.h
> +++ b/libdtrace/dt_version.h
> @@ -38,18 +38,15 @@ extern "C" {
> *
> * These #defines are used in identifier tables to fill in the version fields
> * associated with each identifier. The DT_VERS_* macros declare the encoded
> - * integer values of all versions used so far. DT_VERS_LATEST must correspond
> - * to the latest version value among all versions exported by the D compiler.
> - * DT_VERS_STRING must be an ASCII string that contains DT_VERS_LATEST within
> - * it along with any suffixes (e.g. Beta).
> + * integer values of all versions used so far. DT_VERS_STRING must be an ASCII
> + * string that contains the latest version within it along with any suffixes
> + * (e.g. Beta). You must update DT_VERS_STRING when adding a new version,
> + * and then add the new version to the _dtrace_versions[] array declared in
> + * dt_open.c.
> *
> * Refer to the Solaris Dynamic Tracing Guide Versioning chapter for an
> * explanation of these DTrace features and their values.
> *
> - * You must update DT_VERS_LATEST and DT_VERS_STRING when adding a new version,
> - * and then add the new version to the _dtrace_versions[] array declared in
> - * dt_open.c..
> - *
> * NOTE: Although the DTrace versioning scheme supports the labeling and
> * introduction of incompatible changes (e.g. dropping an interface in a
> * major release), the libdtrace code does not currently support this.
> @@ -85,7 +82,6 @@ extern "C" {
> #define DT_VERS_2_0 DT_VERSION_NUMBER(2, 0, 0)
> #define DT_VERS_2_0_1 DT_VERSION_NUMBER(2, 0, 1)
>
> -#define DT_VERS_LATEST DT_VERS_2_0_1
> #define DT_VERS_STRING "Oracle D 2.0"
You should add 2.0.2 and update the DT_VERS_STRING also.
>
> #ifdef __cplusplus
> --
> 2.43.5
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [DTrace-devel] [PATCH 2/4] Eliminate DT_VERS_LATEST
2025-02-27 16:40 ` Kris Van Hees
@ 2025-02-27 16:57 ` Kris Van Hees
2025-02-28 3:19 ` Kris Van Hees
0 siblings, 1 reply; 11+ messages in thread
From: Kris Van Hees @ 2025-02-27 16:57 UTC (permalink / raw)
To: Kris Van Hees; +Cc: eugene.loh, dtrace, dtrace-devel
There is some overlap with the patch that follows this one, and that got me
thinking a bit more...
I think that we should rework all this a little bit, and have dt_version.h be
the sole source of version number data. We can put macros in there that
provide all the version information (strings and codes), and use that to
populate everything else, I think. That way we reduce the places where changes
need to be made (somewhat).
Let me muse on that a little and I'll follow-up with another email soon with
a example of what I am envisioing.
On Thu, Feb 27, 2025 at 11:40:45AM -0500, Kris Van Hees via DTrace-devel wrote:
> On Sat, Feb 08, 2025 at 02:06:20PM -0500, eugene.loh@oracle.com wrote:
> > From: Eugene Loh <eugene.loh@oracle.com>
> >
> > Updating the DTrace version number requires too many distinct
> > changes. Eliminate DT_VERS_LATEST, since it can be determined
> > on the fly.
> >
> > Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
> > ---
> > libdtrace/dt_open.c | 3 ++-
> > libdtrace/dt_version.h | 14 +++++---------
> > 2 files changed, 7 insertions(+), 10 deletions(-)
> >
> > diff --git a/libdtrace/dt_open.c b/libdtrace/dt_open.c
> > index a02058871..b4d160359 100644
> > --- a/libdtrace/dt_open.c
> > +++ b/libdtrace/dt_open.c
> > @@ -721,7 +721,8 @@ dt_vopen(int version, int flags, int *errp,
> > dtp->dt_proc_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
> > if (dt_aggregate_init(dtp) == -1)
> > return set_open_errno(dtp, errp, dtrace_errno(dtp));
> > - dtp->dt_vmax = DT_VERS_LATEST;
> > + for (i = 0; _dtrace_versions[i] != 0; i++)
> > + dtp->dt_vmax = _dtrace_versions[i];
>
> dtp->dt_vmax = _dtrace_versions[ARRAY_SIZE(_dtrace_versions) - 2];
>
> (-2 to account for the 0 sentinel value)
>
> But this will only be accurate if you also add 2.0.1 to the _dtrace_versions
> array, and then you should probably add 2.0.2 to it also for accuracy.
>
> > dtp->dt_cpp_path = strdup(_dtrace_defcpp);
> > dtp->dt_cpp_argv = malloc(sizeof(char *));
> > dtp->dt_cpp_argc = 1;
> > diff --git a/libdtrace/dt_version.h b/libdtrace/dt_version.h
> > index 3fd1b3d1e..bef3243e9 100644
> > --- a/libdtrace/dt_version.h
> > +++ b/libdtrace/dt_version.h
> > @@ -38,18 +38,15 @@ extern "C" {
> > *
> > * These #defines are used in identifier tables to fill in the version fields
> > * associated with each identifier. The DT_VERS_* macros declare the encoded
> > - * integer values of all versions used so far. DT_VERS_LATEST must correspond
> > - * to the latest version value among all versions exported by the D compiler.
> > - * DT_VERS_STRING must be an ASCII string that contains DT_VERS_LATEST within
> > - * it along with any suffixes (e.g. Beta).
> > + * integer values of all versions used so far. DT_VERS_STRING must be an ASCII
> > + * string that contains the latest version within it along with any suffixes
> > + * (e.g. Beta). You must update DT_VERS_STRING when adding a new version,
> > + * and then add the new version to the _dtrace_versions[] array declared in
> > + * dt_open.c.
> > *
> > * Refer to the Solaris Dynamic Tracing Guide Versioning chapter for an
> > * explanation of these DTrace features and their values.
> > *
> > - * You must update DT_VERS_LATEST and DT_VERS_STRING when adding a new version,
> > - * and then add the new version to the _dtrace_versions[] array declared in
> > - * dt_open.c..
> > - *
> > * NOTE: Although the DTrace versioning scheme supports the labeling and
> > * introduction of incompatible changes (e.g. dropping an interface in a
> > * major release), the libdtrace code does not currently support this.
> > @@ -85,7 +82,6 @@ extern "C" {
> > #define DT_VERS_2_0 DT_VERSION_NUMBER(2, 0, 0)
> > #define DT_VERS_2_0_1 DT_VERSION_NUMBER(2, 0, 1)
> >
> > -#define DT_VERS_LATEST DT_VERS_2_0_1
> > #define DT_VERS_STRING "Oracle D 2.0"
>
> You should add 2.0.2 and update the DT_VERS_STRING also.
>
> >
> > #ifdef __cplusplus
> > --
> > 2.43.5
> >
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel@oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [DTrace-devel] [PATCH 2/4] Eliminate DT_VERS_LATEST
2025-02-27 16:57 ` [DTrace-devel] " Kris Van Hees
@ 2025-02-28 3:19 ` Kris Van Hees
0 siblings, 0 replies; 11+ messages in thread
From: Kris Van Hees @ 2025-02-28 3:19 UTC (permalink / raw)
To: Kris Van Hees; +Cc: eugene.loh, dtrace, dtrace-devel
On Thu, Feb 27, 2025 at 11:57:29AM -0500, Kris Van Hees wrote:
> There is some overlap with the patch that follows this one, and that got me
> thinking a bit more...
>
> I think that we should rework all this a little bit, and have dt_version.h be
> the sole source of version number data. We can put macros in there that
> provide all the version information (strings and codes), and use that to
> populate everything else, I think. That way we reduce the places where changes
> need to be made (somewhat).
>
> Let me muse on that a little and I'll follow-up with another email soon with
> a example of what I am envisioing.
See the patch I just posted:
[PATCH] Refactor the versioning handling system
I think it might accomplish the same thing, i.e. consolidating the places where
changes are needed for new versions? I was going to just do some prototype of
a possible solution but that one didn't work out (it needed to expose too much
of the version handling to other code), and then I came up with this idea.
Open to suggestions/feedback/...
> On Thu, Feb 27, 2025 at 11:40:45AM -0500, Kris Van Hees via DTrace-devel wrote:
> > On Sat, Feb 08, 2025 at 02:06:20PM -0500, eugene.loh@oracle.com wrote:
> > > From: Eugene Loh <eugene.loh@oracle.com>
> > >
> > > Updating the DTrace version number requires too many distinct
> > > changes. Eliminate DT_VERS_LATEST, since it can be determined
> > > on the fly.
> > >
> > > Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
> > > ---
> > > libdtrace/dt_open.c | 3 ++-
> > > libdtrace/dt_version.h | 14 +++++---------
> > > 2 files changed, 7 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/libdtrace/dt_open.c b/libdtrace/dt_open.c
> > > index a02058871..b4d160359 100644
> > > --- a/libdtrace/dt_open.c
> > > +++ b/libdtrace/dt_open.c
> > > @@ -721,7 +721,8 @@ dt_vopen(int version, int flags, int *errp,
> > > dtp->dt_proc_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
> > > if (dt_aggregate_init(dtp) == -1)
> > > return set_open_errno(dtp, errp, dtrace_errno(dtp));
> > > - dtp->dt_vmax = DT_VERS_LATEST;
> > > + for (i = 0; _dtrace_versions[i] != 0; i++)
> > > + dtp->dt_vmax = _dtrace_versions[i];
> >
> > dtp->dt_vmax = _dtrace_versions[ARRAY_SIZE(_dtrace_versions) - 2];
> >
> > (-2 to account for the 0 sentinel value)
> >
> > But this will only be accurate if you also add 2.0.1 to the _dtrace_versions
> > array, and then you should probably add 2.0.2 to it also for accuracy.
> >
> > > dtp->dt_cpp_path = strdup(_dtrace_defcpp);
> > > dtp->dt_cpp_argv = malloc(sizeof(char *));
> > > dtp->dt_cpp_argc = 1;
> > > diff --git a/libdtrace/dt_version.h b/libdtrace/dt_version.h
> > > index 3fd1b3d1e..bef3243e9 100644
> > > --- a/libdtrace/dt_version.h
> > > +++ b/libdtrace/dt_version.h
> > > @@ -38,18 +38,15 @@ extern "C" {
> > > *
> > > * These #defines are used in identifier tables to fill in the version fields
> > > * associated with each identifier. The DT_VERS_* macros declare the encoded
> > > - * integer values of all versions used so far. DT_VERS_LATEST must correspond
> > > - * to the latest version value among all versions exported by the D compiler.
> > > - * DT_VERS_STRING must be an ASCII string that contains DT_VERS_LATEST within
> > > - * it along with any suffixes (e.g. Beta).
> > > + * integer values of all versions used so far. DT_VERS_STRING must be an ASCII
> > > + * string that contains the latest version within it along with any suffixes
> > > + * (e.g. Beta). You must update DT_VERS_STRING when adding a new version,
> > > + * and then add the new version to the _dtrace_versions[] array declared in
> > > + * dt_open.c.
> > > *
> > > * Refer to the Solaris Dynamic Tracing Guide Versioning chapter for an
> > > * explanation of these DTrace features and their values.
> > > *
> > > - * You must update DT_VERS_LATEST and DT_VERS_STRING when adding a new version,
> > > - * and then add the new version to the _dtrace_versions[] array declared in
> > > - * dt_open.c..
> > > - *
> > > * NOTE: Although the DTrace versioning scheme supports the labeling and
> > > * introduction of incompatible changes (e.g. dropping an interface in a
> > > * major release), the libdtrace code does not currently support this.
> > > @@ -85,7 +82,6 @@ extern "C" {
> > > #define DT_VERS_2_0 DT_VERSION_NUMBER(2, 0, 0)
> > > #define DT_VERS_2_0_1 DT_VERSION_NUMBER(2, 0, 1)
> > >
> > > -#define DT_VERS_LATEST DT_VERS_2_0_1
> > > #define DT_VERS_STRING "Oracle D 2.0"
> >
> > You should add 2.0.2 and update the DT_VERS_STRING also.
> >
> > >
> > > #ifdef __cplusplus
> > > --
> > > 2.43.5
> > >
> >
> > _______________________________________________
> > DTrace-devel mailing list
> > DTrace-devel@oss.oracle.com
> > https://oss.oracle.com/mailman/listinfo/dtrace-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/4] Sync up the version numbers
2025-02-08 19:06 [PATCH 1/4] Rename _DTRACE_VERSION eugene.loh
2025-02-08 19:06 ` [PATCH 2/4] Eliminate DT_VERS_LATEST eugene.loh
@ 2025-02-08 19:06 ` eugene.loh
2025-02-08 19:06 ` [PATCH 4/4] test: Add test for predefined preprocessor definitions eugene.loh
2025-02-27 16:27 ` [PATCH 1/4] Rename _DTRACE_VERSION Kris Van Hees
3 siblings, 0 replies; 11+ messages in thread
From: eugene.loh @ 2025-02-08 19:06 UTC (permalink / raw)
To: dtrace, dtrace-devel
From: Eugene Loh <eugene.loh@oracle.com>
DTrace has many version numbers -- e.g., for the release, packaging,
and API.
In reality, the variations in numbering have become nearly meaningless:
- Packaging numbers -- like the Version in the dtrace*spec RPM spec
file and the VERSION in GNUmakefile -- have basically been tracking
the DTrace release since 2.0 anyway.
- Stability attributes for idents are haphazard. Generally, they
are 1.0 (or sometimes other 1.x), and all the BPFs are 2.0. While
this is generally accurate, it is not exactly robust, and idents
are sometimes introduced or modified without careful regard to
the version number. Further, the stability of user D scripts is
likely to depend more on kernel variations -- e.g., the contents of
available_filter_functions -- than on D changes.
- Version number updates are susceptible to mistakes, and so there
have been version mismatches.
Bring the version numbers into sync for 2.0.2. Clean up the descriptions
in dt_version.h.
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
GNUmakefile | 5 +-
dtrace.spec | 1 +
libdtrace/dt_open.c | 3 ++
libdtrace/dt_version.h | 53 ++++++++++++--------
test/unittest/dtrace-util/tst.APIVersion.r | 2 +-
test/unittest/dtrace-util/tst.APIVersion.r.p | 6 +++
test/unittest/options/tst.version.r | 2 +-
test/unittest/options/tst.version.sh | 4 +-
8 files changed, 50 insertions(+), 26 deletions(-)
create mode 100755 test/unittest/dtrace-util/tst.APIVersion.r.p
diff --git a/GNUmakefile b/GNUmakefile
index d1e18bb1b..ddf997878 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -3,7 +3,7 @@
# Build files in subdirectories are included by this file.
#
# Oracle Linux DTrace.
-# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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.
@@ -14,7 +14,8 @@
SHELL = /bin/bash
PROJECT := dtrace
-VERSION := 2.0.1
+# When updating version, see comments in dt_version.h.
+VERSION := 2.0.2
# Verify supported hardware.
diff --git a/dtrace.spec b/dtrace.spec
index 902ad7d8b..46950bf5a 100644
--- a/dtrace.spec
+++ b/dtrace.spec
@@ -87,6 +87,7 @@ Requires: libdtrace-ctf >= 1.1.0
BuildRequires: libdtrace-ctf-devel >= 1.1.0
%endif
Summary: DTrace user interface.
+# When updating version, see comments in dt_version.h.
Version: 2.0.2
Release: 1%{?dist}
Source: dtrace-%{version}.tar.bz2
diff --git a/libdtrace/dt_open.c b/libdtrace/dt_open.c
index b4d160359..b843228b3 100644
--- a/libdtrace/dt_open.c
+++ b/libdtrace/dt_open.c
@@ -58,6 +58,9 @@ const dt_version_t _dtrace_versions[] = {
DT_VERS_1_6_3, /* D API 1.6.3 */
DT_VERS_1_6_4, /* D API 1.6.4 */
DT_VERS_2_0, /* D API 2.0 */
+ DT_VERS_2_0_1, /* D API 2.0.1 */
+ DT_VERS_2_0_2, /* D API 2.0.2 */
+ /* When updating version, see comments in dt_version.h. */
0
};
diff --git a/libdtrace/dt_version.h b/libdtrace/dt_version.h
index bef3243e9..4e230ceae 100644
--- a/libdtrace/dt_version.h
+++ b/libdtrace/dt_version.h
@@ -38,32 +38,28 @@ extern "C" {
*
* These #defines are used in identifier tables to fill in the version fields
* associated with each identifier. The DT_VERS_* macros declare the encoded
- * integer values of all versions used so far. DT_VERS_STRING must be an ASCII
- * string that contains the latest version within it along with any suffixes
- * (e.g. Beta). You must update DT_VERS_STRING when adding a new version,
- * and then add the new version to the _dtrace_versions[] array declared in
- * dt_open.c.
+ * integer values of all versions used so far.
*
- * Refer to the Solaris Dynamic Tracing Guide Versioning chapter for an
- * explanation of these DTrace features and their values.
+ * The major number should be incremented when a fundamental change has been
+ * made that would affect all consumers, and would reflect sweeping changes
+ * to DTrace or the D language.
+ *
+ * The minor number should be incremented when a change is introduced that
+ * could break scripts that had previously worked; for example, adding a
+ * new built-in variable could break a script which was already using that
+ * identifier.
+ *
+ * The micro number should be changed when introducing functionality changes
+ * or major bug fixes that do not affect backward compatibility -- this is
+ * merely to make capabilities easily determined from the version number.
+ *
+ * Minor bugs do not require any modification to the version number.
*
* NOTE: Although the DTrace versioning scheme supports the labeling and
* introduction of incompatible changes (e.g. dropping an interface in a
* major release), the libdtrace code does not currently support this.
* All versions are assumed to strictly inherit from one another. If
* we ever need to provide divergent interfaces, this will need work.
- *
- * The version number should be increased for every customer visible release
- * of Solaris. The major number should be incremented when a fundamental
- * change has been made that would affect all consumers, and would reflect
- * sweeping changes to DTrace or the D language. The minor number should be
- * incremented when a change is introduced that could break scripts that had
- * previously worked; for example, adding a new built-in variable could break
- * a script which was already using that identifier. The micro number should
- * be changed when introducing functionality changes or major bug fixes that
- * do not affect backward compatibility -- this is merely to make capabilities
- * easily determined from the version number. Minor bugs do not require any
- * modification to the version number.
*/
#define DT_VERS_1_0 DT_VERSION_NUMBER(1, 0, 0)
#define DT_VERS_1_1 DT_VERSION_NUMBER(1, 1, 0)
@@ -81,8 +77,25 @@ extern "C" {
#define DT_VERS_1_6_4 DT_VERSION_NUMBER(1, 6, 4)
#define DT_VERS_2_0 DT_VERSION_NUMBER(2, 0, 0)
#define DT_VERS_2_0_1 DT_VERSION_NUMBER(2, 0, 1)
+#define DT_VERS_2_0_2 DT_VERSION_NUMBER(2, 0, 2)
+
+/*
+ * When the version number is updated, the following must be kept in sync:
+ *
+ * libdtrace/dt_version.h DT_VERS_STRING, an ASCII string that contains
+ * the latest version within it along with any
+ * suffixes (e.g. Beta)
+ *
+ * libdtrace/dt_open.c _dtrace_versions[]
+ *
+ * dtrace.spec Version
+ *
+ * libdtrace/Build libdtrace_VERSION
+ *
+ * GNUmakefile VERSION
+ */
-#define DT_VERS_STRING "Oracle D 2.0"
+#define DT_VERS_STRING "Oracle D 2.0.2"
#ifdef __cplusplus
}
diff --git a/test/unittest/dtrace-util/tst.APIVersion.r b/test/unittest/dtrace-util/tst.APIVersion.r
index 6bc7b9d72..02bf03150 100644
--- a/test/unittest/dtrace-util/tst.APIVersion.r
+++ b/test/unittest/dtrace-util/tst.APIVersion.r
@@ -1 +1 @@
-dtrace: Oracle D 2.0
+dtrace: Oracle D 2.0.x
diff --git a/test/unittest/dtrace-util/tst.APIVersion.r.p b/test/unittest/dtrace-util/tst.APIVersion.r.p
new file mode 100755
index 000000000..32ec94df4
--- /dev/null
+++ b/test/unittest/dtrace-util/tst.APIVersion.r.p
@@ -0,0 +1,6 @@
+#!/usr/bin/gawk -f
+
+# The test allows the version string to vary in micro number as well as
+# other suffixes (like "Beta"). The .r.p and .r files still need to be
+# updated for each minor number change.
+{ sub("^dtrace: Oracle D 2\\.0\\..*$", "dtrace: Oracle D 2.0.x"); print }
diff --git a/test/unittest/options/tst.version.r b/test/unittest/options/tst.version.r
index 15010b3db..882e208ed 100644
--- a/test/unittest/options/tst.version.r
+++ b/test/unittest/options/tst.version.r
@@ -1,2 +1,2 @@
-version is 2.0
+version is 2.0.x
diff --git a/test/unittest/options/tst.version.sh b/test/unittest/options/tst.version.sh
index ffffcdd8b..684120af8 100755
--- a/test/unittest/options/tst.version.sh
+++ b/test/unittest/options/tst.version.sh
@@ -1,7 +1,7 @@
#!/bin/bash
#
# 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.
#
@@ -9,7 +9,7 @@
dtrace=$1
myversion=`$dtrace $dt_flags -V | gawk '{ print $NF }'`
-echo version is $myversion
+echo version is $myversion | sed 's:2.0.[0-9]:2.0.x:'
$dtrace $dt_flags -xversion=$myversion -qn 'BEGIN { exit(0) }'
exit $?
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 4/4] test: Add test for predefined preprocessor definitions
2025-02-08 19:06 [PATCH 1/4] Rename _DTRACE_VERSION eugene.loh
2025-02-08 19:06 ` [PATCH 2/4] Eliminate DT_VERS_LATEST eugene.loh
2025-02-08 19:06 ` [PATCH 3/4] Sync up the version numbers eugene.loh
@ 2025-02-08 19:06 ` eugene.loh
2025-03-18 19:18 ` Kris Van Hees
2025-02-27 16:27 ` [PATCH 1/4] Rename _DTRACE_VERSION Kris Van Hees
3 siblings, 1 reply; 11+ messages in thread
From: eugene.loh @ 2025-02-08 19:06 UTC (permalink / raw)
To: dtrace, dtrace-devel
From: Eugene Loh <eugene.loh@oracle.com>
Orabug: 28763074
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
COMMANDLINE-OPTIONS | 10 +-
test/unittest/preprocessor/tst.predefined.r | 1 +
test/unittest/preprocessor/tst.predefined.sh | 119 +++++++++++++++++++
3 files changed, 125 insertions(+), 5 deletions(-)
create mode 100644 test/unittest/preprocessor/tst.predefined.r
create mode 100755 test/unittest/preprocessor/tst.predefined.sh
diff --git a/COMMANDLINE-OPTIONS b/COMMANDLINE-OPTIONS
index 40561af91..73be89b1f 100644
--- a/COMMANDLINE-OPTIONS
+++ b/COMMANDLINE-OPTIONS
@@ -321,12 +321,12 @@ definitions are always specified and valid in all modes:
* __sparcv9 (on SPARC® systems only when 64–bit programs are compiled)
* __i386 (on x86 systems only when 32–bit programs are compiled)
* __amd64 (on x86 systems only when 64–bit programs are compiled)
- * _`uname -s` (for example, __Linux)
+ * __`uname -s` (for example, __Linux)
* __SUNW_D=1
- * _SUNW_D_VERSION=0x_MMmmmuuu (where MM is the Major release value
- in hexadecimal, mmm is the Minor release value in hexadecimal,
- and uuu is the Micro release value in hexadecimal; see Chapter
- 41, Versioning for more information about DTrace versioning)
+ * _SUNW_D_VERSION=(MM << 24 | mmm << 12 | uuu), where
+ MM is the Major release value
+ mmm is the Minor release value
+ uuu is the Micro release value
-Z
Permit probe descriptions that match zero probes. If the -Z option is
diff --git a/test/unittest/preprocessor/tst.predefined.r b/test/unittest/preprocessor/tst.predefined.r
new file mode 100644
index 000000000..2e9ba477f
--- /dev/null
+++ b/test/unittest/preprocessor/tst.predefined.r
@@ -0,0 +1 @@
+success
diff --git a/test/unittest/preprocessor/tst.predefined.sh b/test/unittest/preprocessor/tst.predefined.sh
new file mode 100755
index 000000000..79caf17ac
--- /dev/null
+++ b/test/unittest/preprocessor/tst.predefined.sh
@@ -0,0 +1,119 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 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.
+#
+# Confirm preprocessor pre-definitions.
+
+dtrace=$1
+
+DIRNAME=$tmpdir/predefined.$$.$RANDOM
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+# Arg 1 is macro that we check is defined.
+
+function check_defined() {
+ # Add to script: #ifdef is okay, else is ERROR.
+ echo '#ifdef' $1 >> D.d
+ echo 'printf("'$1' okay\n");' >> D.d
+ echo '#else' >> D.d
+ echo 'printf("ERROR! missing '$1'\n");' >> D.d
+ echo '#endif' >> D.d
+
+ # Add to check file: expect "okay" message.
+ echo $1 okay >> chk.txt
+}
+
+# Arg 1 is macro whose value we check to be arg 2.
+
+function check_value() {
+ # Add to script: print value.
+ echo 'printf("'$1'=%x\n", '$1');' >> D.d
+
+ # Add to check file: expected value.
+ echo $1=$2 >> chk.txt
+}
+
+# Arg 1 is macro that we check is not defined.
+
+function check_undef() {
+ # Add to script: #ifdef is ERROR, else is okay.
+ echo '#ifdef' $1 >> D.d
+ echo 'printf("ERROR! found '$1'\n");' >> D.d
+ echo '#else' >> D.d
+ echo 'printf("missing '$1' is okay\n");' >> D.d
+ echo '#endif' >> D.d
+
+ # Add to check file: expect "okay" message.
+ echo missing $1 is okay >> chk.txt
+}
+
+# Construct version string (major, minor, micro).
+
+read MM mmm uuu <<< `dtrace -vV | awk '/^This is DTrace / { gsub("\\\.", " "); print $(NF-2), $(NF-1), $NF }'`
+vers=`printf "%x" $(($MM << 24 | $mmm << 12 | $uuu))`
+
+# Start setting up the D script.
+
+echo 'BEGIN {' > D.d
+
+# Check for the preprocessor definitions of COMMANDLINE-OPTIONS.
+
+check_defined __linux
+check_defined __unix
+check_defined __SVR4
+if [ `uname -m` == x86_64 ]; then
+check_defined __amd64
+else
+check_undef __amd64
+fi
+check_defined __`uname -s`
+check_value __SUNW_D 1
+check_value __SUNW_D_VERSION $vers
+
+# Confirm other preprocessor definitions.
+
+check_defined __SUNW_D_64
+
+# Confirm that __GNUC__ is not present.
+
+check_undef __GNUC__
+
+# Finish setting up the D script.
+
+echo 'exit(0); }' >> D.d
+echo >> chk.txt
+
+# Run the D script.
+
+$dtrace $dt_flags -qCs D.d -o out.txt
+if [ $? -ne 0 ]; then
+ echo ERROR: DTrace failed
+ echo "==== D.d"
+ cat D.d
+ echo "==== out.txt"
+ cat out.txt
+ exit 1
+fi
+
+# Check.
+
+if ! diff -q chk.txt out.txt; then
+ echo ERROR output disagrees
+ echo === expect ===
+ cat chk.txt
+ echo === actual ===
+ cat out.txt
+ echo === diff ===
+ diff chk.txt out.txt
+ exit 1
+fi
+
+# Indicate success.
+
+echo success
+
+exit 0
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH 4/4] test: Add test for predefined preprocessor definitions
2025-02-08 19:06 ` [PATCH 4/4] test: Add test for predefined preprocessor definitions eugene.loh
@ 2025-03-18 19:18 ` Kris Van Hees
2025-03-18 20:35 ` Eugene Loh
0 siblings, 1 reply; 11+ messages in thread
From: Kris Van Hees @ 2025-03-18 19:18 UTC (permalink / raw)
To: eugene.loh; +Cc: dtrace, dtrace-devel
On Sat, Feb 08, 2025 at 02:06:22PM -0500, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
>
> Orabug: 28763074
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
... and incidentally, should we add defines with ORCL instead of SUNW
(but keep SUNW variants for backwards compatibility)? Or some other
forms that do not include SUNW. Things like __DTRACE?
> ---
> COMMANDLINE-OPTIONS | 10 +-
> test/unittest/preprocessor/tst.predefined.r | 1 +
> test/unittest/preprocessor/tst.predefined.sh | 119 +++++++++++++++++++
> 3 files changed, 125 insertions(+), 5 deletions(-)
> create mode 100644 test/unittest/preprocessor/tst.predefined.r
> create mode 100755 test/unittest/preprocessor/tst.predefined.sh
>
> diff --git a/COMMANDLINE-OPTIONS b/COMMANDLINE-OPTIONS
> index 40561af91..73be89b1f 100644
> --- a/COMMANDLINE-OPTIONS
> +++ b/COMMANDLINE-OPTIONS
> @@ -321,12 +321,12 @@ definitions are always specified and valid in all modes:
> * __sparcv9 (on SPARC® systems only when 64–bit programs are compiled)
> * __i386 (on x86 systems only when 32–bit programs are compiled)
> * __amd64 (on x86 systems only when 64–bit programs are compiled)
> - * _`uname -s` (for example, __Linux)
> + * __`uname -s` (for example, __Linux)
> * __SUNW_D=1
> - * _SUNW_D_VERSION=0x_MMmmmuuu (where MM is the Major release value
> - in hexadecimal, mmm is the Minor release value in hexadecimal,
> - and uuu is the Micro release value in hexadecimal; see Chapter
> - 41, Versioning for more information about DTrace versioning)
> + * _SUNW_D_VERSION=(MM << 24 | mmm << 12 | uuu), where
> + MM is the Major release value
> + mmm is the Minor release value
> + uuu is the Micro release value
>
> -Z
> Permit probe descriptions that match zero probes. If the -Z option is
> diff --git a/test/unittest/preprocessor/tst.predefined.r b/test/unittest/preprocessor/tst.predefined.r
> new file mode 100644
> index 000000000..2e9ba477f
> --- /dev/null
> +++ b/test/unittest/preprocessor/tst.predefined.r
> @@ -0,0 +1 @@
> +success
> diff --git a/test/unittest/preprocessor/tst.predefined.sh b/test/unittest/preprocessor/tst.predefined.sh
> new file mode 100755
> index 000000000..79caf17ac
> --- /dev/null
> +++ b/test/unittest/preprocessor/tst.predefined.sh
> @@ -0,0 +1,119 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 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.
> +#
> +# Confirm preprocessor pre-definitions.
> +
> +dtrace=$1
> +
> +DIRNAME=$tmpdir/predefined.$$.$RANDOM
> +mkdir -p $DIRNAME
> +cd $DIRNAME
> +
> +# Arg 1 is macro that we check is defined.
> +
> +function check_defined() {
> + # Add to script: #ifdef is okay, else is ERROR.
> + echo '#ifdef' $1 >> D.d
> + echo 'printf("'$1' okay\n");' >> D.d
> + echo '#else' >> D.d
> + echo 'printf("ERROR! missing '$1'\n");' >> D.d
> + echo '#endif' >> D.d
> +
> + # Add to check file: expect "okay" message.
> + echo $1 okay >> chk.txt
> +}
> +
> +# Arg 1 is macro whose value we check to be arg 2.
> +
> +function check_value() {
> + # Add to script: print value.
> + echo 'printf("'$1'=%x\n", '$1');' >> D.d
> +
> + # Add to check file: expected value.
> + echo $1=$2 >> chk.txt
> +}
> +
> +# Arg 1 is macro that we check is not defined.
> +
> +function check_undef() {
> + # Add to script: #ifdef is ERROR, else is okay.
> + echo '#ifdef' $1 >> D.d
> + echo 'printf("ERROR! found '$1'\n");' >> D.d
> + echo '#else' >> D.d
> + echo 'printf("missing '$1' is okay\n");' >> D.d
> + echo '#endif' >> D.d
> +
> + # Add to check file: expect "okay" message.
> + echo missing $1 is okay >> chk.txt
> +}
> +
> +# Construct version string (major, minor, micro).
> +
> +read MM mmm uuu <<< `dtrace -vV | awk '/^This is DTrace / { gsub("\\\.", " "); print $(NF-2), $(NF-1), $NF }'`
> +vers=`printf "%x" $(($MM << 24 | $mmm << 12 | $uuu))`
> +
> +# Start setting up the D script.
> +
> +echo 'BEGIN {' > D.d
> +
> +# Check for the preprocessor definitions of COMMANDLINE-OPTIONS.
> +
> +check_defined __linux
> +check_defined __unix
> +check_defined __SVR4
> +if [ `uname -m` == x86_64 ]; then
> +check_defined __amd64
> +else
> +check_undef __amd64
> +fi
> +check_defined __`uname -s`
> +check_value __SUNW_D 1
> +check_value __SUNW_D_VERSION $vers
> +
> +# Confirm other preprocessor definitions.
> +
> +check_defined __SUNW_D_64
> +
> +# Confirm that __GNUC__ is not present.
> +
> +check_undef __GNUC__
> +
> +# Finish setting up the D script.
> +
> +echo 'exit(0); }' >> D.d
> +echo >> chk.txt
> +
> +# Run the D script.
> +
> +$dtrace $dt_flags -qCs D.d -o out.txt
> +if [ $? -ne 0 ]; then
> + echo ERROR: DTrace failed
> + echo "==== D.d"
> + cat D.d
> + echo "==== out.txt"
> + cat out.txt
> + exit 1
> +fi
> +
> +# Check.
> +
> +if ! diff -q chk.txt out.txt; then
> + echo ERROR output disagrees
> + echo === expect ===
> + cat chk.txt
> + echo === actual ===
> + cat out.txt
> + echo === diff ===
> + diff chk.txt out.txt
> + exit 1
> +fi
> +
> +# Indicate success.
> +
> +echo success
> +
> +exit 0
> --
> 2.43.5
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 4/4] test: Add test for predefined preprocessor definitions
2025-03-18 19:18 ` Kris Van Hees
@ 2025-03-18 20:35 ` Eugene Loh
2025-03-18 20:42 ` Kris Van Hees
0 siblings, 1 reply; 11+ messages in thread
From: Eugene Loh @ 2025-03-18 20:35 UTC (permalink / raw)
To: Kris Van Hees; +Cc: dtrace, dtrace-devel
On 3/18/25 15:18, Kris Van Hees wrote:
> On Sat, Feb 08, 2025 at 02:06:22PM -0500, eugene.loh@oracle.com wrote:
>> From: Eugene Loh <eugene.loh@oracle.com>
>>
>> Orabug: 28763074
>> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
>
> ... and incidentally, should we add defines with ORCL instead of SUNW
> (but keep SUNW variants for backwards compatibility)? Or some other
> forms that do not include SUNW. Things like __DTRACE?
Separate patch, right? And, we need to coordinate documentation.
>> ---
>> COMMANDLINE-OPTIONS | 10 +-
>> test/unittest/preprocessor/tst.predefined.r | 1 +
>> test/unittest/preprocessor/tst.predefined.sh | 119 +++++++++++++++++++
>> 3 files changed, 125 insertions(+), 5 deletions(-)
>> create mode 100644 test/unittest/preprocessor/tst.predefined.r
>> create mode 100755 test/unittest/preprocessor/tst.predefined.sh
>>
>> diff --git a/COMMANDLINE-OPTIONS b/COMMANDLINE-OPTIONS
>> index 40561af91..73be89b1f 100644
>> --- a/COMMANDLINE-OPTIONS
>> +++ b/COMMANDLINE-OPTIONS
>> @@ -321,12 +321,12 @@ definitions are always specified and valid in all modes:
>> * __sparcv9 (on SPARC® systems only when 64–bit programs are compiled)
>> * __i386 (on x86 systems only when 32–bit programs are compiled)
>> * __amd64 (on x86 systems only when 64–bit programs are compiled)
>> - * _`uname -s` (for example, __Linux)
>> + * __`uname -s` (for example, __Linux)
>> * __SUNW_D=1
>> - * _SUNW_D_VERSION=0x_MMmmmuuu (where MM is the Major release value
>> - in hexadecimal, mmm is the Minor release value in hexadecimal,
>> - and uuu is the Micro release value in hexadecimal; see Chapter
>> - 41, Versioning for more information about DTrace versioning)
>> + * _SUNW_D_VERSION=(MM << 24 | mmm << 12 | uuu), where
>> + MM is the Major release value
>> + mmm is the Minor release value
>> + uuu is the Micro release value
>>
>> -Z
>> Permit probe descriptions that match zero probes. If the -Z option is
>> diff --git a/test/unittest/preprocessor/tst.predefined.r b/test/unittest/preprocessor/tst.predefined.r
>> new file mode 100644
>> index 000000000..2e9ba477f
>> --- /dev/null
>> +++ b/test/unittest/preprocessor/tst.predefined.r
>> @@ -0,0 +1 @@
>> +success
>> diff --git a/test/unittest/preprocessor/tst.predefined.sh b/test/unittest/preprocessor/tst.predefined.sh
>> new file mode 100755
>> index 000000000..79caf17ac
>> --- /dev/null
>> +++ b/test/unittest/preprocessor/tst.predefined.sh
>> @@ -0,0 +1,119 @@
>> +#!/bin/bash
>> +#
>> +# Oracle Linux DTrace.
>> +# Copyright (c) 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.
>> +#
>> +# Confirm preprocessor pre-definitions.
>> +
>> +dtrace=$1
>> +
>> +DIRNAME=$tmpdir/predefined.$$.$RANDOM
>> +mkdir -p $DIRNAME
>> +cd $DIRNAME
>> +
>> +# Arg 1 is macro that we check is defined.
>> +
>> +function check_defined() {
>> + # Add to script: #ifdef is okay, else is ERROR.
>> + echo '#ifdef' $1 >> D.d
>> + echo 'printf("'$1' okay\n");' >> D.d
>> + echo '#else' >> D.d
>> + echo 'printf("ERROR! missing '$1'\n");' >> D.d
>> + echo '#endif' >> D.d
>> +
>> + # Add to check file: expect "okay" message.
>> + echo $1 okay >> chk.txt
>> +}
>> +
>> +# Arg 1 is macro whose value we check to be arg 2.
>> +
>> +function check_value() {
>> + # Add to script: print value.
>> + echo 'printf("'$1'=%x\n", '$1');' >> D.d
>> +
>> + # Add to check file: expected value.
>> + echo $1=$2 >> chk.txt
>> +}
>> +
>> +# Arg 1 is macro that we check is not defined.
>> +
>> +function check_undef() {
>> + # Add to script: #ifdef is ERROR, else is okay.
>> + echo '#ifdef' $1 >> D.d
>> + echo 'printf("ERROR! found '$1'\n");' >> D.d
>> + echo '#else' >> D.d
>> + echo 'printf("missing '$1' is okay\n");' >> D.d
>> + echo '#endif' >> D.d
>> +
>> + # Add to check file: expect "okay" message.
>> + echo missing $1 is okay >> chk.txt
>> +}
>> +
>> +# Construct version string (major, minor, micro).
>> +
>> +read MM mmm uuu <<< `dtrace -vV | awk '/^This is DTrace / { gsub("\\\.", " "); print $(NF-2), $(NF-1), $NF }'`
>> +vers=`printf "%x" $(($MM << 24 | $mmm << 12 | $uuu))`
>> +
>> +# Start setting up the D script.
>> +
>> +echo 'BEGIN {' > D.d
>> +
>> +# Check for the preprocessor definitions of COMMANDLINE-OPTIONS.
>> +
>> +check_defined __linux
>> +check_defined __unix
>> +check_defined __SVR4
>> +if [ `uname -m` == x86_64 ]; then
>> +check_defined __amd64
>> +else
>> +check_undef __amd64
>> +fi
>> +check_defined __`uname -s`
>> +check_value __SUNW_D 1
>> +check_value __SUNW_D_VERSION $vers
>> +
>> +# Confirm other preprocessor definitions.
>> +
>> +check_defined __SUNW_D_64
>> +
>> +# Confirm that __GNUC__ is not present.
>> +
>> +check_undef __GNUC__
>> +
>> +# Finish setting up the D script.
>> +
>> +echo 'exit(0); }' >> D.d
>> +echo >> chk.txt
>> +
>> +# Run the D script.
>> +
>> +$dtrace $dt_flags -qCs D.d -o out.txt
>> +if [ $? -ne 0 ]; then
>> + echo ERROR: DTrace failed
>> + echo "==== D.d"
>> + cat D.d
>> + echo "==== out.txt"
>> + cat out.txt
>> + exit 1
>> +fi
>> +
>> +# Check.
>> +
>> +if ! diff -q chk.txt out.txt; then
>> + echo ERROR output disagrees
>> + echo === expect ===
>> + cat chk.txt
>> + echo === actual ===
>> + cat out.txt
>> + echo === diff ===
>> + diff chk.txt out.txt
>> + exit 1
>> +fi
>> +
>> +# Indicate success.
>> +
>> +echo success
>> +
>> +exit 0
>> --
>> 2.43.5
>>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 4/4] test: Add test for predefined preprocessor definitions
2025-03-18 20:35 ` Eugene Loh
@ 2025-03-18 20:42 ` Kris Van Hees
0 siblings, 0 replies; 11+ messages in thread
From: Kris Van Hees @ 2025-03-18 20:42 UTC (permalink / raw)
To: Eugene Loh; +Cc: Kris Van Hees, dtrace, dtrace-devel
On Tue, Mar 18, 2025 at 04:35:08PM -0400, Eugene Loh wrote:
> On 3/18/25 15:18, Kris Van Hees wrote:
>
> > On Sat, Feb 08, 2025 at 02:06:22PM -0500, eugene.loh@oracle.com wrote:
> > > From: Eugene Loh <eugene.loh@oracle.com>
> > >
> > > Orabug: 28763074
> > > Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
> > Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
> >
> > ... and incidentally, should we add defines with ORCL instead of SUNW
> > (but keep SUNW variants for backwards compatibility)? Or some other
> > forms that do not include SUNW. Things like __DTRACE?
>
> Separate patch, right? And, we need to coordinate documentation.
Yes, definitely separate patch.
> > > ---
> > > COMMANDLINE-OPTIONS | 10 +-
> > > test/unittest/preprocessor/tst.predefined.r | 1 +
> > > test/unittest/preprocessor/tst.predefined.sh | 119 +++++++++++++++++++
> > > 3 files changed, 125 insertions(+), 5 deletions(-)
> > > create mode 100644 test/unittest/preprocessor/tst.predefined.r
> > > create mode 100755 test/unittest/preprocessor/tst.predefined.sh
> > >
> > > diff --git a/COMMANDLINE-OPTIONS b/COMMANDLINE-OPTIONS
> > > index 40561af91..73be89b1f 100644
> > > --- a/COMMANDLINE-OPTIONS
> > > +++ b/COMMANDLINE-OPTIONS
> > > @@ -321,12 +321,12 @@ definitions are always specified and valid in all modes:
> > > * __sparcv9 (on SPARC® systems only when 64???bit programs are compiled)
> > > * __i386 (on x86 systems only when 32???bit programs are compiled)
> > > * __amd64 (on x86 systems only when 64???bit programs are compiled)
> > > - * _`uname -s` (for example, __Linux)
> > > + * __`uname -s` (for example, __Linux)
> > > * __SUNW_D=1
> > > - * _SUNW_D_VERSION=0x_MMmmmuuu (where MM is the Major release value
> > > - in hexadecimal, mmm is the Minor release value in hexadecimal,
> > > - and uuu is the Micro release value in hexadecimal; see Chapter
> > > - 41, Versioning for more information about DTrace versioning)
> > > + * _SUNW_D_VERSION=(MM << 24 | mmm << 12 | uuu), where
> > > + MM is the Major release value
> > > + mmm is the Minor release value
> > > + uuu is the Micro release value
> > > -Z
> > > Permit probe descriptions that match zero probes. If the -Z option is
> > > diff --git a/test/unittest/preprocessor/tst.predefined.r b/test/unittest/preprocessor/tst.predefined.r
> > > new file mode 100644
> > > index 000000000..2e9ba477f
> > > --- /dev/null
> > > +++ b/test/unittest/preprocessor/tst.predefined.r
> > > @@ -0,0 +1 @@
> > > +success
> > > diff --git a/test/unittest/preprocessor/tst.predefined.sh b/test/unittest/preprocessor/tst.predefined.sh
> > > new file mode 100755
> > > index 000000000..79caf17ac
> > > --- /dev/null
> > > +++ b/test/unittest/preprocessor/tst.predefined.sh
> > > @@ -0,0 +1,119 @@
> > > +#!/bin/bash
> > > +#
> > > +# Oracle Linux DTrace.
> > > +# Copyright (c) 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.
> > > +#
> > > +# Confirm preprocessor pre-definitions.
> > > +
> > > +dtrace=$1
> > > +
> > > +DIRNAME=$tmpdir/predefined.$$.$RANDOM
> > > +mkdir -p $DIRNAME
> > > +cd $DIRNAME
> > > +
> > > +# Arg 1 is macro that we check is defined.
> > > +
> > > +function check_defined() {
> > > + # Add to script: #ifdef is okay, else is ERROR.
> > > + echo '#ifdef' $1 >> D.d
> > > + echo 'printf("'$1' okay\n");' >> D.d
> > > + echo '#else' >> D.d
> > > + echo 'printf("ERROR! missing '$1'\n");' >> D.d
> > > + echo '#endif' >> D.d
> > > +
> > > + # Add to check file: expect "okay" message.
> > > + echo $1 okay >> chk.txt
> > > +}
> > > +
> > > +# Arg 1 is macro whose value we check to be arg 2.
> > > +
> > > +function check_value() {
> > > + # Add to script: print value.
> > > + echo 'printf("'$1'=%x\n", '$1');' >> D.d
> > > +
> > > + # Add to check file: expected value.
> > > + echo $1=$2 >> chk.txt
> > > +}
> > > +
> > > +# Arg 1 is macro that we check is not defined.
> > > +
> > > +function check_undef() {
> > > + # Add to script: #ifdef is ERROR, else is okay.
> > > + echo '#ifdef' $1 >> D.d
> > > + echo 'printf("ERROR! found '$1'\n");' >> D.d
> > > + echo '#else' >> D.d
> > > + echo 'printf("missing '$1' is okay\n");' >> D.d
> > > + echo '#endif' >> D.d
> > > +
> > > + # Add to check file: expect "okay" message.
> > > + echo missing $1 is okay >> chk.txt
> > > +}
> > > +
> > > +# Construct version string (major, minor, micro).
> > > +
> > > +read MM mmm uuu <<< `dtrace -vV | awk '/^This is DTrace / { gsub("\\\.", " "); print $(NF-2), $(NF-1), $NF }'`
> > > +vers=`printf "%x" $(($MM << 24 | $mmm << 12 | $uuu))`
> > > +
> > > +# Start setting up the D script.
> > > +
> > > +echo 'BEGIN {' > D.d
> > > +
> > > +# Check for the preprocessor definitions of COMMANDLINE-OPTIONS.
> > > +
> > > +check_defined __linux
> > > +check_defined __unix
> > > +check_defined __SVR4
> > > +if [ `uname -m` == x86_64 ]; then
> > > +check_defined __amd64
> > > +else
> > > +check_undef __amd64
> > > +fi
> > > +check_defined __`uname -s`
> > > +check_value __SUNW_D 1
> > > +check_value __SUNW_D_VERSION $vers
> > > +
> > > +# Confirm other preprocessor definitions.
> > > +
> > > +check_defined __SUNW_D_64
> > > +
> > > +# Confirm that __GNUC__ is not present.
> > > +
> > > +check_undef __GNUC__
> > > +
> > > +# Finish setting up the D script.
> > > +
> > > +echo 'exit(0); }' >> D.d
> > > +echo >> chk.txt
> > > +
> > > +# Run the D script.
> > > +
> > > +$dtrace $dt_flags -qCs D.d -o out.txt
> > > +if [ $? -ne 0 ]; then
> > > + echo ERROR: DTrace failed
> > > + echo "==== D.d"
> > > + cat D.d
> > > + echo "==== out.txt"
> > > + cat out.txt
> > > + exit 1
> > > +fi
> > > +
> > > +# Check.
> > > +
> > > +if ! diff -q chk.txt out.txt; then
> > > + echo ERROR output disagrees
> > > + echo === expect ===
> > > + cat chk.txt
> > > + echo === actual ===
> > > + cat out.txt
> > > + echo === diff ===
> > > + diff chk.txt out.txt
> > > + exit 1
> > > +fi
> > > +
> > > +# Indicate success.
> > > +
> > > +echo success
> > > +
> > > +exit 0
> > > --
> > > 2.43.5
> > >
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] Rename _DTRACE_VERSION
2025-02-08 19:06 [PATCH 1/4] Rename _DTRACE_VERSION eugene.loh
` (2 preceding siblings ...)
2025-02-08 19:06 ` [PATCH 4/4] test: Add test for predefined preprocessor definitions eugene.loh
@ 2025-02-27 16:27 ` Kris Van Hees
3 siblings, 0 replies; 11+ messages in thread
From: Kris Van Hees @ 2025-02-27 16:27 UTC (permalink / raw)
To: eugene.loh; +Cc: dtrace, dtrace-devel
On Sat, Feb 08, 2025 at 02:06:19PM -0500, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
>
> There are many DTrace version numbers (for version, API version,
> package version, etc.). Meanwhile, _DTRACE_VERSION is not a
> version number at all. It's a preprocessor macro in USDT .h header
> files. Prior to commit e2fb0ecd9
> ("Ensure multiple passes through dtrace -G work."), it was perhaps
> not even set. With that commit, it was always set to 1, with
> the rationale:
>
> Also add an explicit define for _DTRACE__VERSION in the generated
> header file from 'dtrace -h' invocations. This seems silly, but
> it is there to give people a skeleton to work with if they want to
> pre-generate header files and select whether to actually compile
> on the probes at a later time.
>
> Rename to _DTRACE_HEADER for better clarity. Define it only once
> per file.
Based on the rationale, I would think that something like _DTRACE_USE_USDT
or somethng similar would be better? Since the purpose seems to be to allow
(after the header file is generated) for someone to change that 1 to 0 to
disable the USDT probes to be compiled in.
In fact, if we want to support this in a more developer-friendly way, we
might as well change the generted line to be more like:
#ifndef _DTRACE_USE_USDT
# define _DTARCE_USE_USDT 1
#endif
so that a package could e.g. allow a configure option or something to set it
to 1 or 0, dypassing the need to manually change the file.
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
> ---
> libdtrace/dt_program.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/libdtrace/dt_program.c b/libdtrace/dt_program.c
> index 23b91fb2e..c6fdafb47 100644
> --- a/libdtrace/dt_program.c
> +++ b/libdtrace/dt_program.c
> @@ -505,13 +505,12 @@ dt_header_provider(dtrace_hdl_t *dtp, dt_provider_t *pvp, FILE *out)
> info.dthi_pfname = alloca(strlen(pvp->desc.dtvd_name) + 1 + i);
> dt_header_fmt_func(info.dthi_pfname, pvp->desc.dtvd_name);
>
> - if (fprintf(out, "#define _DTRACE_VERSION 1\n\n"
> - "#if _DTRACE_VERSION\n\n") < 0)
> + if (fprintf(out, "#if _DTRACE_HEADER\n\n") < 0)
> return dt_set_errno(dtp, errno);
>
> if (dt_idhash_iter(pvp->pv_probes, dt_header_probe, &info) != 0)
> return -1; /* dt_errno is set for us */
> - if (fprintf(out, "\n\n") < 0)
> + if (fprintf(out, "\n") < 0)
> return dt_set_errno(dtp, errno);
> if (dt_idhash_iter(pvp->pv_probes, dt_header_decl, &info) != 0)
> return -1; /* dt_errno is set for us */
> @@ -560,6 +559,9 @@ dtrace_program_header(dtrace_hdl_t *dtp, FILE *out, const char *fname)
> "#endif\n\n") < 0)
> return -1;
>
> + if (fprintf(out, "#define _DTRACE_HEADER 1\n\n") < 0)
> + return -1;
> +
> while ((pvp = dt_htab_next(dtp->dt_provs, &it)) != NULL) {
> if (dt_header_provider(dtp, pvp, out) != 0) {
> dt_htab_next_destroy(it);
> --
> 2.43.5
>
^ permalink raw reply [flat|nested] 11+ messages in thread