Skip to content

Commit

Permalink
db*: Print the BPF program prior to loading it (in -v mode)
Browse files Browse the repository at this point in the history
Printing the BPF program after loading it means that if there is a
load error, the program isn't printed, which sort of defeats the
purpose of the whole thing.
  • Loading branch information
goldshtn committed Apr 20, 2017
1 parent aa124dd commit da1c607
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tools/dbslower.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@
usdt.enable_probe("query__start", "probe_start")
usdt.enable_probe("query__done", "probe_end")

bpf = BPF(text=program, usdt_contexts=usdts)
if args.verbose:
print('\n'.join(map(lambda u: u.get_text(), usdts)))
print(program)

bpf = BPF(text=program, usdt_contexts=usdts)

class Data(ct.Structure):
_fields_ = [
("pid", ct.c_ulonglong),
Expand Down
3 changes: 2 additions & 1 deletion tools/dbstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@
usdt.enable_probe("query__start", "probe_start")
usdt.enable_probe("query__done", "probe_end")

bpf = BPF(text=program, usdt_contexts=usdts)
if args.verbose:
print('\n'.join(map(lambda u: u.get_text(), usdts)))
print(program)

bpf = BPF(text=program, usdt_contexts=usdts)

print("Tracing database queries for pids %s slower than %d ms..." %
(', '.join(map(str, args.pids)), args.threshold))

Expand Down

0 comments on commit da1c607

Please sign in to comment.