Skip to content

Commit

Permalink
usdt: common infrastructure
Browse files Browse the repository at this point in the history
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@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
nickalcock authored and kvanhees committed Oct 27, 2022
1 parent 164fe6f commit ec5254b
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 16 deletions.
13 changes: 13 additions & 0 deletions libcommon/Build
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions libcommon/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%:
$(MAKE) -C .. $@

all::
$(MAKE) -C .. all
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions libdtrace/Build
Original file line number Diff line number Diff line change
Expand Up @@ -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)\"
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion libproc/Build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libproc/Pcontrol.c
Original file line number Diff line number Diff line change
@@ -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.
*/
Expand Down Expand Up @@ -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;
}

Expand Down
16 changes: 8 additions & 8 deletions test/triggers/Build
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,17 @@ 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
# libproc-consistency is.
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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions test/utils/Build
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand Down

0 comments on commit ec5254b

Please sign in to comment.