Bug fix around USDT argument handling for constants
authorSasha Goldshtein <goldshtn@gmail.com>
Thu, 31 Mar 2016 13:32:14 +0000 (06:32 -0700)
committerSasha Goldshtein <goldshtn@gmail.com>
Thu, 31 Mar 2016 14:19:11 +0000 (07:19 -0700)
For USDT arguments of the form "-4@$-1", the parsing logic would fail
because it didn't expect the second number (the actual value of the
USDT argument as a constant) to be negative. This is now fixed.

src/python/bcc/usdt.py

index 5b72815..b4e3151 100644 (file)
@@ -204,13 +204,14 @@ class USDTProbeLocation(object):
                 any_reg = "(" + "|".join(qregs + dregs + wregs + bregs) + ")"
 
                 # -4@$0, 8@$1234
-                m = re.match(r'(\-?)(\d+)@\$(\d+)', arg)
+                m = re.match(r'(\-?)(\d+)@\$(\-?)(\d+)', arg)
                 if m is not None:
+                        sign = -1 if len(m.group(3)) > 0 else 1
                         self.args.append(USDTArgument(
                                 int(m.group(2)),
                                 m.group(1) == '-',
                                 self,
-                                constant=int(m.group(3))
+                                constant=sign*int(m.group(4))
                                 ))
                         return