Linux DTrace development list
 help / color / mirror / Atom feed
* [PATCH v2 0/4] ELF note-based USDT support
@ 2025-01-29 14:55 Alan Maguire
  2025-01-29 14:55 ` [PATCH v2 1/4] USDT: support ELF-note-defined probes Alan Maguire
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Alan Maguire @ 2025-01-29 14:55 UTC (permalink / raw)
  To: dtrace; +Cc: dtrace-devel, Alan Maguire

This series adds support (patch 1) for ELF-note defined USDT
probes in binaries and libraries; patches 2-4 add tests.

Basic pid-specific USDT support is added; i.e. it is necessary
to specify the target pid in the provider name such as
"example1234" ; future work could add pid wildcarding.

ELF note defined probes are defined by including sys/sdt.h
from the systemtap-sdt-devel package, and are defined in
C programs via

DTRACE_PROBEn(provider, probe, [args...])

See the tests for concrete examples.

For python, go, etc, USDT probes can be added via libstapsdt [1]
and associated language-specific bindings.  This allows users
of those languages to add USDT probes too.  For example, the
following example program adds a "pythonapp" probe "firstProbe"
using the python-specific libstapsdt binding:

#!/usr/bin/python3
from time import sleep
import stapsdt
provider = stapsdt.Provider("pythonapp")
probe = provider.add_probe(
"firstProbe", stapsdt.ArgTypes.uint64, stapsdt.ArgTypes.int32)
provider.load()
while True:
    print("Firing probe...")
    if probe.fire("My little probe", 42):
        print("Probe fired!")
    sleep(1)

We can then trace this via dtrace:

# dtrace -n 'pythonapp503211:::* { printf("args %s, %d\n", copyinstr(arg0), arg1); }'

dtrace: description 'pythonapp503211:::* ' matched 1 probe
CPU     ID                    FUNCTION:NAME
  6 286628                      :firstProbe args My little probe, 42

[1] https://github.com/linux-usdt/libstapsdt

Alan Maguire (4):
  USDT: support ELF-note-defined probes
  selftests/usdt: add test for USDT note-defined probe firing, args
  selftests/usdt: add test for USDT notes in shared library
  selftests/usdt: add test covering different forms of USDT note args

 include/dtrace/pid.h                      |  29 ++
 libdtrace/dt_cg.c                         |  47 ++
 libdtrace/dt_cg.h                         |   1 +
 libdtrace/dt_pid.c                        | 466 ++++++++++++++++++++
 libdtrace/dt_prov_uprobe.c                |  19 +-
 test/unittest/usdt/sdt_notes.h            | 504 ++++++++++++++++++++++
 test/unittest/usdt/tst.usdt-notes-args.r  |   2 +
 test/unittest/usdt/tst.usdt-notes-args.sh |  51 +++
 test/unittest/usdt/tst.usdt-notes-lib.r   |  14 +
 test/unittest/usdt/tst.usdt-notes-lib.sh  | 145 +++++++
 test/unittest/usdt/tst.usdt-notes.r       |  14 +
 test/unittest/usdt/tst.usdt-notes.sh      | 121 ++++++
 12 files changed, 1406 insertions(+), 7 deletions(-)
 create mode 100644 test/unittest/usdt/sdt_notes.h
 create mode 100644 test/unittest/usdt/tst.usdt-notes-args.r
 create mode 100755 test/unittest/usdt/tst.usdt-notes-args.sh
 create mode 100644 test/unittest/usdt/tst.usdt-notes-lib.r
 create mode 100755 test/unittest/usdt/tst.usdt-notes-lib.sh
 create mode 100644 test/unittest/usdt/tst.usdt-notes.r
 create mode 100755 test/unittest/usdt/tst.usdt-notes.sh

-- 
2.43.5


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-06-08  3:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-29 14:55 [PATCH v2 0/4] ELF note-based USDT support Alan Maguire
2025-01-29 14:55 ` [PATCH v2 1/4] USDT: support ELF-note-defined probes Alan Maguire
2025-01-29 14:55 ` [PATCH v2 2/4] selftests/usdt: add test for USDT note-defined probe firing, args Alan Maguire
2025-01-29 14:55 ` [PATCH v2 3/4] selftests/usdt: add test for USDT notes in shared library Alan Maguire
2025-01-29 14:55 ` [PATCH v2 4/4] selftests/usdt: add test covering different forms of USDT note args Alan Maguire
2025-01-29 15:33 ` [PATCH v2 0/4] ELF note-based USDT support Kris Van Hees
2025-01-30 11:12   ` Alan Maguire
2025-06-08  1:42     ` [DTrace-devel] " Sam James
2025-06-08  3:08       ` Kris Van Hees

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox