uobjnew: Attach uprobe only to the requested process
authorSasha Goldshtein <goldshtn@gmail.com>
Mon, 19 Dec 2016 09:52:34 +0000 (09:52 +0000)
committerSasha Goldshtein <goldshtn@gmail.com>
Mon, 19 Dec 2016 09:52:34 +0000 (09:52 +0000)
When C allocations are traced, attach the `malloc`
uprobe only to the requested process -- otherwise, we
get allocation information from the entire system.

tools/uobjnew.py

index 7f14686..98bc01d 100755 (executable)
@@ -133,7 +133,8 @@ if args.verbose:
 
 bpf = BPF(text=program, usdt_contexts=[usdt])
 if args.language == "c":
-    bpf.attach_uprobe(name="c", sym="malloc", fn_name="alloc_entry")
+    bpf.attach_uprobe(name="c", sym="malloc", fn_name="alloc_entry",
+                      pid=args.pid)
 
 exit_signaled = False
 print("Tracing allocations in process %d (language: %s)... Ctrl-C to quit." %