Skip to content

Commit

Permalink
add way to debug generated BPF code (iovisor#1494)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendangregg authored and goldshtn committed Dec 19, 2017
1 parent c8177e9 commit 73b5401
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/tcpretrans.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python
# @lint-avoid-python-3-compatibility-imports
#
# tcpretrans Trace TCP retransmits and TLPs.
# tcpretrans Trace or count TCP retransmits and TLPs.
# For Linux, uses BCC, eBPF. Embedded C.
#
# USAGE: tcpretrans [-h] [-l]
# USAGE: tcpretrans [-c] [-h] [-l]
#
# This uses dynamic tracing of kernel functions, and will need to be updated
# to match kernel changes.
Expand Down Expand Up @@ -38,6 +38,7 @@
parser.add_argument("-c", "--count", action="store_true",
help="count occurred retransmits per flow")
args = parser.parse_args()
debug = 0

# define BPF program
bpf_text = """
Expand Down Expand Up @@ -188,6 +189,9 @@
bpf_text = bpf_text.replace("IPV4_CORE", "ipv4_events.perf_submit(ctx, &data4, sizeof(data4));")
bpf_text = bpf_text.replace("IPV6_CORE", "ipv6_events.perf_submit(ctx, &data6, sizeof(data6));")

if debug:
print(bpf_text)

# event data
class Data_ipv4(ct.Structure):
_fields_ = [
Expand Down

0 comments on commit 73b5401

Please sign in to comment.