lttng: list-triggers: implement listing of SDT userspace-probe
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 14 Apr 2021 21:25:27 +0000 (17:25 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 22 Apr 2021 01:28:51 +0000 (21:28 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id57c265dcdb3b324ffbb274ca97ead9364275cf0

src/bin/lttng/commands/list_triggers.c
tests/regression/tools/trigger/test_list_triggers_cli

index 70ab4c4e540d95c79aae6967207ce20b3f137861..1590bbc79619693843edc9c9c80418c64027b2bf 100644 (file)
@@ -266,7 +266,7 @@ void print_event_rule_userspace_probe(const struct lttng_event_rule *event_rule)
                goto end;
        }
 
-       _MSG("    rule: %s (type: userspace probe, location: ", name);
+       _MSG("    rule: %s (type: userspace probe, ", name);
 
        userspace_probe_location_type =
                        lttng_userspace_probe_location_get_type(location);
@@ -281,12 +281,22 @@ void print_event_rule_userspace_probe(const struct lttng_event_rule *event_rule)
                function_name = lttng_userspace_probe_location_function_get_function_name(
                                location);
 
-               _MSG("%s:%s", binary_path, function_name);
+               _MSG("location type: ELF, location: %s:%s", binary_path, function_name);
                break;
        }
        case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
-               _MSG("SDT not implemented yet");
+       {
+               const char *binary_path, *provider_name, *probe_name;
+
+               binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(
+                               location);
+               provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(
+                               location);
+               probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(
+                               location);
+               _MSG("location type: SDT, location: %s:%s:%s", binary_path, provider_name, probe_name);
                break;
+       }
        default:
                abort();
        }
index 60221a2b57fbab0d3bb6f09f3c625df27502923c..9c85838b399554492b982ba82318301b1b593cb3 100755 (executable)
@@ -24,7 +24,7 @@ TESTDIR="$CURDIR/../../.."
 source "$TESTDIR/utils/utils.sh"
 
 
-NUM_TESTS=67
+NUM_TESTS=72
 
 FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}"
 
@@ -32,14 +32,22 @@ tmp_stdout=$(mktemp -t test_list_triggers_cli_stdout.XXXXXX)
 tmp_stderr=$(mktemp -t test_list_triggers_cli_stderr.XXXXXX)
 tmp_expected_stdout=$(mktemp -t test_list_triggers_cli_expected_stdout.XXXXXX)
 uprobe_elf_binary=$(realpath "${TESTDIR}/utils/testapp/userspace-probe-elf-binary/.libs/userspace-probe-elf-binary")
+uprobe_sdt_binary=$(realpath "${TESTDIR}/utils/testapp/userspace-probe-sdt-binary/.libs/userspace-probe-sdt-binary")
 
 uid=$(id --user)
 gid=$(id --group)
 
 if [ "$uid" == "0" ]; then
        ist_root=1
+       ls "$uprobe_sdt_binary" >/dev/null 2>&1
+       if test $? == 0; then
+               hast_sdt_binary=1
+       else
+               hast_sdt_binary=0
+       fi
 else
        ist_root=0
+       hast_sdt_binary=0
 fi
 
 
@@ -253,7 +261,7 @@ test_on_event_probe ()
        lttng_remove_trigger_ok "T2"
 }
 
-test_on_event_userspace_probe ()
+test_on_event_userspace_probe_elf ()
 {
        local elf_function_name="test_function"
 
@@ -265,7 +273,7 @@ test_on_event_userspace_probe ()
        - id: T0
          user id: ${uid}
          condition: event rule hit
-           rule: ma-probe-elf (type: userspace probe, location: ${uprobe_elf_binary}:${elf_function_name})
+           rule: ma-probe-elf (type: userspace probe, location type: ELF, location: ${uprobe_elf_binary}:${elf_function_name})
          actions:
            notify
              errors: none
@@ -277,6 +285,32 @@ test_on_event_userspace_probe ()
        lttng_remove_trigger_ok "T0"
 }
 
+test_on_event_userspace_probe_sdt ()
+{
+
+       local sdt_provider_name="foobar"
+       local sdt_probe_name="tp1"
+
+       diag "on-event userspace-probe sdt"
+
+       lttng_add_trigger_ok "T0" --condition on-event -k --userspace-probe=sdt:${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name} ma-probe-sdt --action notify
+
+       cat > "${tmp_expected_stdout}" <<- EOF
+       - id: T0
+         user id: 0
+         condition: event rule hit
+           rule: ma-probe-sdt (type: userspace probe, location type: SDT, location: ${uprobe_sdt_binary}:${sdt_provider_name}:${sdt_probe_name})
+         actions:
+           notify
+             errors: none
+         errors: none
+       EOF
+
+       list_triggers_matches_ok "on-event, userspace-probe event rule SDT" "${tmp_expected_stdout}"
+
+       lttng_remove_trigger_ok "T0"
+}
+
 test_on_event_syscall ()
 {
        diag "Listing on-event syscall"
@@ -454,7 +488,8 @@ start_lttng_sessiond_notap
 test_top_level_options
 test_on_event_tracepoint
 skip $ist_root "non-root user: skipping kprobe tests" 9 || test_on_event_probe
-skip $ist_root "non-root user: skipping userspace probe elf tests" 5 || test_on_event_userspace_probe
+skip $ist_root "non-root user: skipping userspace probe elf tests" 5 || test_on_event_userspace_probe_elf
+skip $(($ist_root && $hast_sdt_binary)) "skipping userspace probe SDT tests" 5 || test_on_event_userspace_probe_sdt
 skip $ist_root "non-root user: skipping syscall tests" 7 || test_on_event_syscall
 test_snapshot_action
 test_notify_action
This page took 0.029313 seconds and 4 git commands to generate.