Skip to content

Commit

Permalink
tools: support -I abspath in trace, argdist
Browse files Browse the repository at this point in the history
  • Loading branch information
ShelbyFrances authored and ShelbyFrances committed Feb 13, 2017
1 parent 86cd535 commit f5dbbdb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 8 additions & 2 deletions tools/argdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ def __init__(self):
"(see examples below)")
parser.add_argument("-I", "--include", action="append",
metavar="header",
help="additional header files to include in the BPF program")
help="additional header files to include in the BPF program "
"as either full path, or relative to '/usr/include'")
self.args = parser.parse_args()
self.usdt_ctx = None

Expand All @@ -640,7 +641,12 @@ def _generate_program(self):
#include <uapi/linux/ptrace.h>
""" % self.args.string_size
for include in (self.args.include or []):
bpf_source += "#include <%s>\n" % include
if include.startswith((".", "/")):
include = os.path.abspath(include)
bpf_source += "#include \"%s\"\n" % include
else:
bpf_source += "#include <%s>\n" % include

bpf_source += BPF.generate_auto_includes(
map(lambda p: p.raw_spec, self.probes))
for probe in self.probes:
Expand Down
9 changes: 7 additions & 2 deletions tools/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,8 @@ def __init__(self):
help="probe specifier (see examples)")
parser.add_argument("-I", "--include", action="append",
metavar="header",
help="additional header files to include in the BPF program")
help="additional header files to include in the BPF program "
"as either full path, or relative to '/usr/include'")
self.args = parser.parse_args()
if self.args.tgid and self.args.pid:
parser.error("only one of -p and -t may be specified")
Expand All @@ -644,7 +645,11 @@ def _generate_program(self):
"""
for include in (self.args.include or []):
self.program += "#include <%s>\n" % include
if include.startswith((".", "/")):
include = os.path.abspath(include)
self.program += "#include \"%s\"\n" % include
else:
self.program += "#include <%s>\n" % include
self.program += BPF.generate_auto_includes(
map(lambda p: p.raw_probe, self.probes))
for probe in self.probes:
Expand Down

0 comments on commit f5dbbdb

Please sign in to comment.