summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2010-12-09 23:18:58 +0000
committerDevang Patel <dpatel@apple.com>2010-12-09 23:18:58 +0000
commit7dddad562fff1542e0c29f4bb748d0a2c7a7c449 (patch)
tree2283872900b47998a91fc7a71d4ab764924dd9a0 /utils
parent5fad7a99c00980fc30ce16fb51ce09dc435c40ad (diff)
downloadllvm-7dddad562fff1542e0c29f4bb748d0a2c7a7c449.tar.gz
llvm-7dddad562fff1542e0c29f4bb748d0a2c7a7c449.tar.bz2
llvm-7dddad562fff1542e0c29f4bb748d0a2c7a7c449.tar.xz
Add initial support to measure local variables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121428 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rwxr-xr-xutils/CollectDebugInfoUsingLLDB.py12
-rwxr-xr-xutils/CompareDebugInfo.py31
2 files changed, 33 insertions, 10 deletions
diff --git a/utils/CollectDebugInfoUsingLLDB.py b/utils/CollectDebugInfoUsingLLDB.py
index b82a7c172e..9dba66a22c 100755
--- a/utils/CollectDebugInfoUsingLLDB.py
+++ b/utils/CollectDebugInfoUsingLLDB.py
@@ -66,7 +66,7 @@ def print_var_value (v, file, frame):
file.write(v.GetValue(frame))
# print_vars - Print variable values in output file.
-def print_vars (vars, fname, line, file, frame, target, thread):
+def print_vars (tag, vars, fname, line, file, frame, target, thread):
# disable this thread.
count = thread.GetStopReasonDataCount()
bid = 0
@@ -87,7 +87,7 @@ def print_vars (vars, fname, line, file, frame, target, thread):
bp_loc.SetEnabled(False);
for i in range(vars.GetSize()):
- file.write("#Argument ")
+ file.write(tag)
file.write(fname)
file.write(':')
file.write(str(line))
@@ -163,10 +163,12 @@ if target.IsValid():
if fname is None:
fname = function.GetName()
#print "function : ",fname
- vars = frame.GetVariables(1,0,0,0)
line = frame.GetLineEntry().GetLine()
- print_vars (vars, fname, line, file, frame, target, thread)
- #print vars
+ vars = frame.GetVariables(1,0,0,0)
+ print_vars ("#Argument ", vars, fname, line, file, frame, target, thread)
+ vars = frame.GetVariables(0,1,0,0)
+ print_vars ("#Variables ", vars, fname, line, file, frame, target, thread)
+
process.Continue()
file.close()
diff --git a/utils/CompareDebugInfo.py b/utils/CompareDebugInfo.py
index 12a086b518..1d9b8df625 100755
--- a/utils/CompareDebugInfo.py
+++ b/utils/CompareDebugInfo.py
@@ -7,10 +7,14 @@ class BreakPoint:
def __init__(self, bp_name):
self.name = bp_name
self.values = {}
+ self.var_values = {}
def recordArgument(self, arg_name, value):
self.values[arg_name] = value
+ def recordVariable(self, var_name, var_value):
+ self.var_values[var_name] = var_value
+
def __repr__(self):
print self.name
items = self.values.items()
@@ -18,9 +22,15 @@ class BreakPoint:
print items[i][0]," = ",items[i][1]
return ''
- def __cmp__(self, other):
+ def compare_args(self, other):
return cmp(self.values, other.values)
+ def compare_vars(self, other):
+ return cmp(self.var_values, other.var_values)
+
+ def __cmp__(self, other):
+ return cmp(self.values, other.values)
+
def read_input(filename, dict):
f = open(filename, "r")
lines = f.readlines()
@@ -33,6 +43,13 @@ def read_input(filename, dict):
dict[c[2]] = bp
bp.recordArgument(c[3], c[4])
+ if c[0] == "#Variables":
+ bp = dict.get(c[2])
+ if bp is None:
+ bp = BreakPoint(c[1])
+ dict[c[2]] = bp
+ bp.recordVariable(c[3], c[4])
+
f.close()
return
@@ -44,7 +61,8 @@ f2_breakpoints = {}
read_input(sys.argv[2], f2_breakpoints)
f2_items = f2_breakpoints.items()
-mismatch = 0
+arg_mismatch = 0
+var_mismatch = 0
for f2bp in range(len(f2_items)):
id = f2_items[f2bp][0]
bp = f2_items[f2bp][1]
@@ -52,13 +70,16 @@ for f2bp in range(len(f2_items)):
if bp1 is None:
print "bp is missing"
else:
- if bp1 != bp:
- mismatch = mismatch + 1
+ if bp1.compare_args(bp):
+ arg_mismatch = arg_mismatch + 1
+ if bp1.compare_vars(bp):
+ var_mismatch = var_mismatch + 1
l2 = len(f2_items)
print "=========="
if l2 != 0:
- print sys.argv[3]," success rate is", (l2-mismatch)*100/l2,"%"
+ print sys.argv[3]," Argument success rate is", (l2-arg_mismatch)*100/l2,"%"
+ print sys.argv[3]," Variable success rate is", (l2-var_mismatch)*100/l2,"%"
else:
print sys.argv[3]," success rate is 100%"
print "=========="