tracing: use bitcoind pid in bcc tracing examples

BCC needs the PID of a bitcoind process to attach to the tracepoints
(instead of the binary path used before) when the tracepoints have a
semaphore.

For reference, we already use the PID in our tracepoint interface
tests. See 220a5a2841.
This commit is contained in:
0xb10c
2022-12-20 12:51:13 +01:00
parent 411c6cfc6c
commit 0de3e96e33
5 changed files with 38 additions and 29 deletions

View File

@ -132,8 +132,9 @@ def print_message(event, inbound):
)
def main(bitcoind_path):
bitcoind_with_usdts = USDT(path=str(bitcoind_path))
def main(pid):
print(f"Hooking into bitcoind with pid {pid}")
bitcoind_with_usdts = USDT(pid=int(pid))
# attaching the trace functions defined in the BPF program to the tracepoints
bitcoind_with_usdts.enable_probe(
@ -176,8 +177,8 @@ def main(bitcoind_path):
if __name__ == "__main__":
if len(sys.argv) < 2:
print("USAGE:", sys.argv[0], "path/to/bitcoind")
if len(sys.argv) != 2:
print("USAGE:", sys.argv[0], "<pid of bitcoind>")
exit()
path = sys.argv[1]
main(path)
pid = sys.argv[1]
main(pid)