From: Sasha Goldshtein Date: Thu, 27 Oct 2016 22:58:14 +0000 (-0700) Subject: ustat: Graceful error handling X-Git-Tag: v0.3.0~97^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb3c471fe40a33dffb509f84825f9bd53a22dd36;p=platform%2Fupstream%2Fbcc.git ustat: Graceful error handling If the process in question doesn't have the USDT probes we expect, handle the failure gracefully. After all, it could be a binary compiled without USDT support, the pid could be recycled to some other application, or -- the process name could match, but by accident, and really belong to some other runtime. --- diff --git a/tools/ustat.py b/tools/ustat.py index 55e8493..cc410df 100755 --- a/tools/ustat.py +++ b/tools/ustat.py @@ -64,7 +64,15 @@ class Probe(object): for pid in self.targets: usdt = USDT(pid=pid) for event in self.events: - usdt.enable_probe(event, "%s_%s" % (self.language, event)) + try: + usdt.enable_probe(event, "%s_%s" % (self.language, event)) + except Exception: + # This process might not have a recent version of the USDT + # probes enabled, or might have been compiled without USDT + # probes at all. The process could even have been shut down + # and the pid been recycled. We have to gracefully handle + # the possibility that we can't attach probes to it at all. + pass self.usdts.append(usdt) def _generate_tables(self): @@ -175,7 +183,7 @@ class Tool(object): } if self.args.language: - self.probes = [probes_by_lang[args.language]] + self.probes = [probes_by_lang[self.args.language]] else: self.probes = probes_by_lang.values()