[DTrace-devel] [PATCH v4 13/25] usdt: common infrastructure

Kris Van Hees kris.van.hees at oracle.com
Sat Oct 8 03:21:06 UTC 2022


On Fri, Oct 07, 2022 at 11:25:12AM +0100, Nick Alcock via DTrace-devel wrote:
> USDT will include a daemon that implements a CUSE device that programs
> containing USDT probes issue ioctl()s to.  This daemon needs to create
> uprobes, and this needs to use libproc to extract information about the
> processes (like mapping addresses, etc).  This is something the rest of
> DTrace can already do: so split out infrastructure needed by libproc and
> infrastructure needed to create uprobes into a new libcommon (static)
> library that the daemon can use.  Make tiny adjustments to libproc and
> triggers that use it so that libproc can stand independent of libdtrace
> (it was very nearly there already: only one debugging statement change
> and a move of dt_list into the common library is needed).
> 
> A future commit will adjust DTrace to use this library to create uprobes
> too.
> 
> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>

> ---
>  libcommon/Build                    | 13 +++++++++++++
>  libcommon/GNUmakefile              |  5 +++++
>  {libdtrace => libcommon}/dt_list.c |  0
>  {libdtrace => libcommon}/dt_list.h |  0
>  libdtrace/Build                    |  5 ++---
>  libproc/Build                      |  5 ++++-
>  libproc/Pcontrol.c                 |  4 ++--
>  test/triggers/Build                | 16 ++++++++--------
>  test/utils/Build                   |  4 ++--
>  9 files changed, 36 insertions(+), 16 deletions(-)
>  create mode 100644 libcommon/Build
>  create mode 100644 libcommon/GNUmakefile
>  rename {libdtrace => libcommon}/dt_list.c (100%)
>  rename {libdtrace => libcommon}/dt_list.h (100%)
> 
> diff --git a/libcommon/Build b/libcommon/Build
> new file mode 100644
> index 000000000000..f4cf3ba5cb88
> --- /dev/null
> +++ b/libcommon/Build
> @@ -0,0 +1,13 @@
> +# Oracle Linux DTrace.
> +# Copyright (c) 2022, 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.
> +
> +BUILDLIBS += libcommon
> +LIBS += libcommon
> +
> +libcommon_TARGET = libcommon
> +libcommon_DIR := $(current-dir)
> +libcommon_CPPFLAGS := -Ilibcommon -Ilibproc
> +libcommon_SOURCES = dt_list.c
> +libcommon_LIBSOURCES = libcommon
> diff --git a/libcommon/GNUmakefile b/libcommon/GNUmakefile
> new file mode 100644
> index 000000000000..4a27e08b8a8a
> --- /dev/null
> +++ b/libcommon/GNUmakefile
> @@ -0,0 +1,5 @@
> +%:
> +	$(MAKE) -C .. $@
> +
> +all::
> +	$(MAKE) -C .. all
> diff --git a/libdtrace/dt_list.c b/libcommon/dt_list.c
> similarity index 100%
> rename from libdtrace/dt_list.c
> rename to libcommon/dt_list.c
> diff --git a/libdtrace/dt_list.h b/libcommon/dt_list.h
> similarity index 100%
> rename from libdtrace/dt_list.h
> rename to libcommon/dt_list.h
> diff --git a/libdtrace/Build b/libdtrace/Build
> index ff8c6180e073..2e553c67b634 100644
> --- a/libdtrace/Build
> +++ b/libdtrace/Build
> @@ -4,7 +4,7 @@
>  # http://oss.oracle.com/licenses/upl.
>  
>  BUILDLIBS += libdtrace-build
> -libdtrace-build_CPPFLAGS = -Ilibdtrace -Ilibproc -Iuts/intel -Ilibdtrace/$(ARCHINC) \
> +libdtrace-build_CPPFLAGS = -Ilibdtrace -Ilibproc -Ilibcommon -Iuts/intel -Ilibdtrace/$(ARCHINC) \
>                             -DDTRACE_LIBDIR="\"$(LIBDIR)/dtrace\"" -DDTRACE_USER_UID=$(USER_UID) \
>                             -DUNPRIV_UID=$(UNPRIV_UID) -DDUMPCAP_GROUP=\"$(DUMPCAP_GROUP)\" \
>                             -DUNPRIV_HOME=\"$(UNPRIV_HOME)\"
> @@ -32,7 +32,6 @@ libdtrace-build_SOURCES = dt_aggregate.c \
>  			  dt_lex.c \
>  			  dt_link.c \
>  			  dt_kernel_module.c \
> -			  dt_list.c \
>  			  dt_map.c \
>  			  dt_module.c \
>  			  dt_open.c \
> @@ -77,7 +76,7 @@ endif
>  libdtrace_VERSION := 2.0.0
>  libdtrace_SONAME := libdtrace.so.2
>  libdtrace_VERSCRIPT := libdtrace.ver
> -libdtrace_LIBSOURCES := libdtrace-build libproc libport
> +libdtrace_LIBSOURCES := libdtrace-build libproc libport libcommon
>  libdtrace_SECONDARY := libproc libport
>  
>  # Disable certain warnings for these files
> diff --git a/libproc/Build b/libproc/Build
> index af268f2832b9..983ff92eefcc 100644
> --- a/libproc/Build
> +++ b/libproc/Build
> @@ -4,10 +4,13 @@
>  # http://oss.oracle.com/licenses/upl.
>  
>  BUILDLIBS += libproc
> -libproc_CPPFLAGS = -Ilibproc -Ilibdtrace -I$(objdir) -Iuts/intel -Ilibproc/$(ARCHINC)
> +LIBS += libproc
> +libproc_CPPFLAGS = -Ilibproc -Ilibdtrace -Ilibcommon -I$(objdir) -Iuts/intel -Ilibproc/$(ARCHINC)
>  libproc_TARGET = libproc
>  libproc_DIR := $(current-dir)
>  libproc_SOURCES = Pcontrol.c elfish.c elfish_64.c elfish_32.c Psymtab.c rtld_db.c rtld_offsets.c wrap.c isadep_dispatch.c $(ARCHINC)/isadep.c
> +libproc_LIBSOURCES := libproc libcommon
> +libproc_SECONDARY := libcommon
>  libproc_SRCDEPS := $(objdir)/rtld_offsets.stamp
>  
>  rtld_offsets.c_CFLAGS := -Wno-prio-ctor-dtor
> diff --git a/libproc/Pcontrol.c b/libproc/Pcontrol.c
> index 8c129a7f8c1e..9bdf2068478c 100644
> --- a/libproc/Pcontrol.c
> +++ b/libproc/Pcontrol.c
> @@ -1,6 +1,6 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2010, 2022, 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.
>   */
> @@ -352,7 +352,7 @@ Pgrab(pid_t pid, int noninvasiveness, int already_ptraced, void *wrap_arg,
>  	 * it to definite noninvasiveness.
>  	 */
>  	if (*perr || noninvasiveness > 1) {
> -		dt_dprintf("%i: grabbing noninvasively.\n", P->pid);
> +		_dprintf("%i: grabbing noninvasively.\n", P->pid);
>  		P->noninvasive = TRUE;
>  	}
>  
> diff --git a/test/triggers/Build b/test/triggers/Build
> index 76a23f9f6a3f..6321b8468892 100644
> --- a/test/triggers/Build
> +++ b/test/triggers/Build
> @@ -133,8 +133,8 @@ visible-constructor-32_LDFLAGS := -s
>  libproc-pldd_CFLAGS := -Ilibproc -Ilibdtrace
>  libproc-pldd_NOCFLAGS :=
>  libproc-pldd_NOLDFLAGS :=
> -libproc-pldd_DEPS := build-libproc.a build-libdtrace.a libport.a
> -libproc-pldd_LIBS := $(objdir)/build-libproc.a $(objdir)/build-libdtrace.a $(objdir)/build-libport.a $(libdtrace_LIBS)
> +libproc-pldd_DEPS := build-libproc.a build-libdtrace.a libcommon.a libport.a
> +libproc-pldd_LIBS := $(objdir)/build-libproc.a $(objdir)/build-libdtrace.a $(objdir)/build-libcommon.a $(objdir)/build-libport.a $(libdtrace_LIBS)
>  
>  # Technically libproc-dlmlib is not a dependency of libproc-consistency, but in
>  # practice the tests never call it with anything else, so it's needed whenever
> @@ -142,8 +142,8 @@ libproc-pldd_LIBS := $(objdir)/build-libproc.a $(objdir)/build-libdtrace.a $(obj
>  libproc-consistency_CFLAGS := -Ilibproc -Ilibdtrace
>  libproc-consistency_NOCFLAGS :=
>  libproc-consistency_NOLDFLAGS :=
> -libproc-consistency_DEPS := build-libproc.a build-libdtrace.a libport.a libproc-dlmlib.so
> -libproc-consistency_LIBS := $(objdir)/build-libproc.a $(objdir)/build-libdtrace.a $(objdir)/build-libport.a $(libdtrace_LIBS)
> +libproc-consistency_DEPS := build-libproc.a build-libdtrace.a libcommon.a libport.a libproc-dlmlib.so
> +libproc-consistency_LIBS := $(objdir)/build-libproc.a $(objdir)/build-libdtrace.a $(objdir)/libcommon.a $(objdir)/build-libport.a $(libdtrace_LIBS)
>  
>  # The lookup victim also needs to have an rpath baked into it, since when
>  # testing in --use-installed mode, there is no LD_LIBRARY_PATH pointing into
> @@ -157,15 +157,15 @@ libproc-lookup-by-name_CFLAGS := -Ilibproc -Ilibdtrace
>  libproc-lookup-by-name_LDFLAGS := -Bdynamic
>  libproc-lookup-by-name_NOCFLAGS :=
>  libproc-lookup-by-name_NOLDFLAGS :=
> -libproc-lookup-by-name_DEPS := build-libproc.a build-libdtrace.a libport.a
> -libproc-lookup-by-name_LIBS := $(objdir)/build-libproc.a $(objdir)/build-libdtrace.a $(objdir)/build-libport.a $(libdtrace_LIBS)
> +libproc-lookup-by-name_DEPS := build-libproc.a build-libdtrace.a libcommon.a libport.a
> +libproc-lookup-by-name_LIBS := $(objdir)/build-libproc.a $(objdir)/build-libdtrace.a $(objdir)/libcommon.a $(objdir)/build-libport.a $(libdtrace_LIBS)
>  
>  libproc-execing-bkpts_CFLAGS := -Ilibproc -Ilibdtrace
>  libproc-execing-bkpts_LDFLAGS :=
>  libproc-execing-bkpts_NOCFLAGS :=
>  libproc-execing-bkpts_NOLDFLAGS :=
> -libproc-execing-bkpts_DEPS := build-libproc.a build-libdtrace.a libport.a
> -libproc-execing-bkpts_LIBS := $(objdir)/build-libproc.a $(objdir)/build-libdtrace.a $(objdir)/build-libport.a $(libdtrace_LIBS)
> +libproc-execing-bkpts_DEPS := build-libproc.a build-libdtrace.a libcommon.a libport.a
> +libproc-execing-bkpts_LIBS := $(objdir)/build-libproc.a $(objdir)/build-libdtrace.a $(objdir)/libcommon.a $(objdir)/build-libport.a $(libdtrace_LIBS)
>  
>  # We need multiple versions of libproc-sleeper with different combinations
>  # of flags.
> diff --git a/test/utils/Build b/test/utils/Build
> index 202048e8ba22..992fca19ae78 100644
> --- a/test/utils/Build
> +++ b/test/utils/Build
> @@ -1,5 +1,5 @@
>  # Oracle Linux DTrace.
> -# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
> +# Copyright (c) 2011, 2022, 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.
>  
> @@ -11,7 +11,7 @@ $(1)_DIR := $(current-dir)
>  $(1)_TARGET = $(1)
>  $(1)_SOURCES = $(1).c
>  $(1)_POST := link-test-util
> -$(1)_CFLAGS := -Ilibdtrace -Ilibproc
> +$(1)_CFLAGS := -Ilibdtrace -Ilibproc -Ilibcommon
>  $(1)_NOCFLAGS := --coverage
>  $(1)_NOLDFLAGS := --coverage
>  $(1)_DEPS = libdtrace.so
> -- 
> 2.35.1
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list