Skip to content

Commit

Permalink
usdt.py: improve error messags for enable_probe()
Browse files Browse the repository at this point in the history
  • Loading branch information
gfx authored and yonghong-song committed Mar 2, 2020
1 parent 440016f commit c46c7b3
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/python/bcc/usdt.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,18 @@ def enable_probe(self, probe, fn_name):
if lib.bcc_usdt_enable_probe(self.context, probe.encode('ascii'),
fn_name.encode('ascii')) != 0:
raise USDTException(
("failed to enable probe '%s'; a possible cause " +
"can be that the probe requires a pid to enable") %
probe
)
"""Failed to enable USDT probe '%s':
the specified pid might not contain the given language's runtime,
or the runtime was not built with the required USDT probes. Look
for a configure flag similar to --with-dtrace or --enable-dtrace.
To check which probes are present in the process, use the tplist tool.
""" % probe)

def enable_probe_or_bail(self, probe, fn_name):
if lib.bcc_usdt_enable_probe(self.context, probe.encode('ascii'),
fn_name.encode('ascii')) != 0:
print(
"""Error attaching USDT probes: the specified pid might not contain the
given language's runtime, or the runtime was not built with the required
USDT probes. Look for a configure flag similar to --with-dtrace or
--enable-dtrace. To check which probes are present in the process, use the
tplist tool.""")
try:
self.enable_probe(probe, fn_name)
except USDTException as e:
print(e)
sys.exit(1)

def get_context(self):
Expand Down

0 comments on commit c46c7b3

Please sign in to comment.