Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ install:
mkdir -p $(DESTDIR)$(PREFIX)/include
cp out/$(SONAME) $(DESTDIR)$(PREFIX)/lib/$(SONAME)
cp src/libstapsdt.h $(DESTDIR)$(PREFIX)/include/
rm -f $(DESTDIR)$(PREFIX)/lib/$(SOLINK)
ln -s $(DESTDIR)$(PREFIX)/lib/$(SONAME) $(DESTDIR)$(PREFIX)/lib/$(SOLINK)

uninstall:
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ Here's an example using [eBPF/bcc](https://github.com/iovisor/bcc) trace tool
sudo /usr/share/bcc/tools/trace -p $(pgrep demo) 'u::PROBE_NAME'
```

Other tracing tools that do not support tracing of the libstapsdt-created
libraries can trace the USDT stapsdt/probe. It will fire when a
libstapsdt probe fires. It is passed the provider and probe names
along with arguments. For example, the following BPF C program could
be used to show probe firing:

```
SEC("usdt//usr/lib/libstapsdt.so:stapsdt:probe")
int BPF_USDT(args, const char *provider, const char *probename)
{
__bpf_printk("%s/%s fired\n", provider, probename);
return 0;
}
```

One benefit of this form of tracing is that by tracing libstapsdt.so
itself, we can trace libstapsdt probe firings system-wide.

## Run tests

To run tests, just run the command below. Please be aware that there are only
Expand Down
12 changes: 12 additions & 0 deletions src/libstapsdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "shared-lib.h"
#include "util.h"
#include "libstapsdt.h"
#include "stapsdt-probe.h"
#include "errors.h"

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
Expand Down Expand Up @@ -227,6 +228,12 @@ void probeFire(SDTProbe_t *probe, ...) {
arg[i] = va_arg(vl, uint64_t);
}

/* fire static probe for libstapsdt signifying a dynamic probe has
* fired; tracers can attach to libstapsdt to see all dynamic probe
* firings system-wide.
*/
stapsdtProbeFire(probe, arg);

switch(probe->argCount) {
case 0:
((void (*)())probe->_fire) ();
Expand Down Expand Up @@ -259,6 +266,11 @@ int probeIsEnabled(SDTProbe_t *probe) {
if(probe->_fire == NULL) {
return 0;
}
/* tracers can attach to stapsdt/probe to see probe firings across
* libstapsdt.
*/
if (stapsdtProbeIsEnabled(probe))
return 1;
if(((*(char *)probe->_fire) & 0x90) == 0x90) {
return 0;
}
Expand Down
6 changes: 6 additions & 0 deletions src/sdt-config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* includes/sys/sdt-config.h. Generated from sdt-config.h.in by configure.

This file just defines _SDT_ASM_SECTION_AUTOGROUP_SUPPORT to 0 or 1 to
indicate whether the assembler supports "?" in .pushsection directives. */

#define _SDT_ASM_SECTION_AUTOGROUP_SUPPORT 1
Loading