threadsnoop: look for pthread_create in libc too
authorJerome Marchand <jmarchan@redhat.com>
Thu, 16 Sep 2021 12:44:23 +0000 (14:44 +0200)
committeryonghong-song <ys114321@gmail.com>
Fri, 17 Sep 2021 04:08:10 +0000 (21:08 -0700)
Since glibc 2.34, pthread features are integrated in libc directly.
Look for pthread_create there too when it is not found in libpthread.

Fixes #3623

tools/threadsnoop.py

index 04c5e680d868af03f3d20463d77d30c81f2705c9..471b0c3c66d827b5a51152a78f5ab802808c7ef8 100755 (executable)
@@ -38,7 +38,12 @@ void do_entry(struct pt_regs *ctx) {
     events.perf_submit(ctx, &data, sizeof(data));
 };
 """)
-b.attach_uprobe(name="pthread", sym="pthread_create", fn_name="do_entry")
+
+# Since version 2.34, pthread features are integrated in libc
+try:
+    b.attach_uprobe(name="pthread", sym="pthread_create", fn_name="do_entry")
+except Exception:
+    b.attach_uprobe(name="c", sym="pthread_create", fn_name="do_entry")
 
 print("%-10s %-6s %-16s %s" % ("TIME(ms)", "PID", "COMM", "FUNC"))