Print this page
11506 smatch resync
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/smatch/src/smatch_data/db/smdb.py
+++ new/usr/src/tools/smatch/src/smatch_data/db/smdb.py
1 1 #!/usr/bin/python
2 2
3 3 # Copyright (C) 2013 Oracle.
4 4 #
5 5 # Licensed under the Open Software License version 1.1
6 6
7 7 import sqlite3
8 8 import sys
9 9 import re
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
10 10
11 11 try:
12 12 con = sqlite3.connect('smatch_db.sqlite')
13 13 except sqlite3.Error, e:
14 14 print "Error %s:" % e.args[0]
15 15 sys.exit(1)
16 16
17 17 def usage():
18 18 print "%s" %(sys.argv[0])
19 19 print "<function> - how a function is called"
20 + print "info <type> - how a function is called, filtered by type"
20 21 print "return_states <function> - what a function returns"
21 22 print "call_tree <function> - show the call tree"
22 23 print "where <struct_type> <member> - where a struct member is set"
23 24 print "type_size <struct_type> <member> - how a struct member is allocated"
24 25 print "data_info <struct_type> <member> - information about a given data type"
25 26 print "function_ptr <function> - which function pointers point to this"
26 27 print "trace_param <function> <param> - trace where a parameter came from"
27 28 print "locals <file> - print the local values in a file."
28 29 sys.exit(1)
29 30
30 31 function_ptrs = []
31 32 searched_ptrs = []
32 33 def get_function_pointers_helper(func):
33 34 cur = con.cursor()
34 35 cur.execute("select distinct ptr from function_ptr where function = '%s';" %(func))
35 36 for row in cur:
36 37 ptr = row[0]
37 38 if ptr in function_ptrs:
38 39 continue
39 40 function_ptrs.append(ptr)
40 41 if not ptr in searched_ptrs:
41 42 searched_ptrs.append(ptr)
42 43 get_function_pointers_helper(ptr)
43 44
44 45 def get_function_pointers(func):
45 46 global function_ptrs
46 47 global searched_ptrs
47 48 function_ptrs = [func]
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
48 49 searched_ptrs = [func]
49 50 get_function_pointers_helper(func)
50 51 return function_ptrs
51 52
52 53 db_types = { 0: "INTERNAL",
53 54 101: "PARAM_CLEARED",
54 55 103: "PARAM_LIMIT",
55 56 104: "PARAM_FILTER",
56 57 1001: "PARAM_VALUE",
57 58 1002: "BUF_SIZE",
58 - 1003: "USER_DATA",
59 59 1004: "CAPPED_DATA",
60 60 1005: "RETURN_VALUE",
61 61 1006: "DEREFERENCE",
62 62 1007: "RANGE_CAP",
63 63 1008: "LOCK_HELD",
64 64 1009: "LOCK_RELEASED",
65 65 1010: "ABSOLUTE_LIMITS",
66 66 1012: "PARAM_ADD",
67 67 1013: "PARAM_FREED",
68 68 1014: "DATA_SOURCE",
69 69 1015: "FUZZY_MAX",
70 70 1016: "STR_LEN",
71 71 1017: "ARRAY_LEN",
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
72 72 1018: "CAPABLE",
73 73 1019: "NS_CAPABLE",
74 74 1022: "TYPE_LINK",
75 75 1023: "UNTRACKED_PARAM",
76 76 1024: "CULL_PATH",
77 77 1025: "PARAM_SET",
78 78 1026: "PARAM_USED",
79 79 1027: "BYTE_UNITS",
80 80 1028: "COMPARE_LIMIT",
81 81 1029: "PARAM_COMPARE",
82 - 8017: "USER_DATA2",
82 + 1030: "EXPECTS_TYPE",
83 + 1031: "CONSTRAINT",
84 + 1032: "PASSES_TYPE",
85 + 1033: "CONSTRAINT_REQUIRED",
86 + 1034: "BIT_INFO",
87 + 1035: "NOSPEC",
88 + 1036: "NOSPEC_WB",
89 + 1037: "STMT_CNT",
90 + 1038: "TERMINATED",
91 + 1039: "SLEEP",
92 + 1040: "NO_SLEEP_CNT",
93 + 1041: "SMALLISH",
94 + 1042: "FRESH_MTAG",
95 +
96 + 8017: "USER_DATA",
97 + 9017: "USER_DATA_SET",
83 98 8018: "NO_OVERFLOW",
84 99 8019: "NO_OVERFLOW_SIMPLE",
85 100 8020: "LOCKED",
86 101 8021: "UNLOCKED",
87 102 8023: "ATOMIC_INC",
88 103 8024: "ATOMIC_DEC",
89 104 };
90 105
91 106 def add_range(rl, min_val, max_val):
92 107 check_next = 0
93 108 done = 0
94 109 ret = []
95 110 idx = 0
96 111
97 112 if len(rl) == 0:
98 113 return [[min_val, max_val]]
99 114
100 115 for idx in range(len(rl)):
101 116 cur_min = rl[idx][0]
102 117 cur_max = rl[idx][1]
103 118
104 119 # we already merged the new range but we might need to change later
105 120 # ranges if they over lap with more than one
106 121 if check_next:
107 122 # join with added range
108 123 if max_val + 1 == cur_min:
109 124 ret[len(ret) - 1][1] = cur_max
110 125 done = 1
111 126 break
112 127 # don't overlap
113 128 if max_val < cur_min:
114 129 ret.append([cur_min, cur_max])
115 130 done = 1
116 131 break
117 132 # partially overlap
118 133 if max_val < cur_max:
119 134 ret[len(ret) - 1][1] = cur_max
120 135 done = 1
121 136 break
122 137 # completely overlap
123 138 continue
124 139
125 140 # join 2 ranges into one
126 141 if max_val + 1 == cur_min:
127 142 ret.append([min_val, cur_max])
128 143 done = 1
129 144 break
130 145 # range is entirely below
131 146 if max_val < cur_min:
132 147 ret.append([min_val, max_val])
133 148 ret.append([cur_min, cur_max])
134 149 done = 1
135 150 break
136 151 # range is partially below
137 152 if min_val < cur_min:
138 153 if max_val <= cur_max:
139 154 ret.append([min_val, cur_max])
140 155 done = 1
141 156 break
142 157 else:
143 158 ret.append([min_val, max_val])
144 159 check_next = 1
145 160 continue
146 161 # range already included
147 162 if max_val <= cur_max:
148 163 ret.append([cur_min, cur_max])
149 164 done = 1
150 165 break;
151 166 # range partially above
152 167 if min_val <= cur_max:
153 168 ret.append([cur_min, max_val])
154 169 check_next = 1
155 170 continue
156 171 # join 2 ranges on the other side
157 172 if min_val - 1 == cur_max:
158 173 ret.append([cur_min, max_val])
159 174 check_next = 1
160 175 continue
161 176 # range is above
162 177 ret.append([cur_min, cur_max])
163 178
164 179 if idx + 1 < len(rl): # we hit a break statement
165 180 ret = ret + rl[idx + 1:]
166 181 elif done: # we hit a break on the last iteration
167 182 pass
168 183 elif not check_next: # it's past the end of the rl
169 184 ret.append([min_val, max_val])
170 185
171 186 return ret;
172 187
173 188 def rl_union(rl1, rl2):
174 189 ret = []
175 190 for r in rl1:
176 191 ret = add_range(ret, r[0], r[1])
177 192 for r in rl2:
178 193 ret = add_range(ret, r[0], r[1])
179 194
180 195 if (rl1 or rl2) and not ret:
181 196 print "bug: merging %s + %s gives empty" %(rl1, rl2)
182 197
183 198 return ret
184 199
185 200 def txt_to_val(txt):
186 201 if txt == "s64min":
187 202 return -(2**63)
188 203 elif txt == "s32min":
189 204 return -(2**31)
↓ open down ↓ |
97 lines elided |
↑ open up ↑ |
190 205 elif txt == "s16min":
191 206 return -(2**15)
192 207 elif txt == "s64max":
193 208 return 2**63 - 1
194 209 elif txt == "s32max":
195 210 return 2**31 - 1
196 211 elif txt == "s16max":
197 212 return 2**15 - 1
198 213 elif txt == "u64max":
199 214 return 2**64 - 1
215 + elif txt == "ptr_max":
216 + return 2**64 - 1
200 217 elif txt == "u32max":
201 218 return 2**32 - 1
202 219 elif txt == "u16max":
203 220 return 2**16 - 1
204 221 else:
205 222 try:
206 223 return int(txt)
207 224 except ValueError:
208 225 return 0
209 226
210 227 def val_to_txt(val):
211 228 if val == -(2**63):
212 229 return "s64min"
213 230 elif val == -(2**31):
214 231 return "s32min"
215 232 elif val == -(2**15):
216 233 return "s16min"
217 234 elif val == 2**63 - 1:
218 235 return "s64max"
219 236 elif val == 2**31 - 1:
220 237 return "s32max"
221 238 elif val == 2**15 - 1:
222 239 return "s16max"
223 240 elif val == 2**64 - 1:
224 241 return "u64max"
225 242 elif val == 2**32 - 1:
226 243 return "u32max"
227 244 elif val == 2**16 - 1:
228 245 return "u16max"
229 246 elif val < 0:
230 247 return "(%d)" %(val)
231 248 else:
232 249 return "%d" %(val)
233 250
234 251 def get_next_str(txt):
235 252 val = ""
236 253 parsed = 0
237 254
238 255 if txt[0] == '(':
239 256 parsed += 1
240 257 for char in txt[1:]:
241 258 if char == ')':
242 259 break
243 260 parsed += 1
244 261 val = txt[1:parsed]
245 262 parsed += 1
246 263 elif txt[0] == 's' or txt[0] == 'u':
247 264 parsed += 6
248 265 val = txt[:parsed]
249 266 else:
250 267 if txt[0] == '-':
251 268 parsed += 1
252 269 for char in txt[parsed:]:
253 270 if char == '-':
254 271 break
255 272 parsed += 1
256 273 val = txt[:parsed]
257 274 return [parsed, val]
258 275
259 276 def txt_to_rl(txt):
260 277 if len(txt) == 0:
261 278 return []
262 279
263 280 ret = []
264 281 pairs = txt.split(",")
265 282 for pair in pairs:
266 283 cnt, min_str = get_next_str(pair)
267 284 if cnt == len(pair):
268 285 max_str = min_str
269 286 else:
270 287 cnt, max_str = get_next_str(pair[cnt + 1:])
271 288 min_val = txt_to_val(min_str)
272 289 max_val = txt_to_val(max_str)
273 290 ret.append([min_val, max_val])
274 291
275 292 # Hm... Smatch won't call INT_MAX s32max if the variable is unsigned.
276 293 # if txt != rl_to_txt(ret):
277 294 # print "bug: converting: text = %s rl = %s internal = %s" %(txt, rl_to_txt(ret), ret)
278 295
279 296 return ret
280 297
281 298 def rl_to_txt(rl):
282 299 ret = ""
283 300 for idx in range(len(rl)):
284 301 cur_min = rl[idx][0]
285 302 cur_max = rl[idx][1]
286 303
287 304 if idx != 0:
288 305 ret += ","
289 306
290 307 if cur_min == cur_max:
291 308 ret += val_to_txt(cur_min)
292 309 else:
293 310 ret += val_to_txt(cur_min)
294 311 ret += "-"
295 312 ret += val_to_txt(cur_max)
296 313 return ret
297 314
298 315 def type_to_str(type_int):
299 316
300 317 t = int(type_int)
301 318 if db_types.has_key(t):
302 319 return db_types[t]
303 320 return type_int
304 321
305 322 def type_to_int(type_string):
306 323 for k in db_types.keys():
307 324 if db_types[k] == type_string:
308 325 return k
309 326 return -1
310 327
311 328 def display_caller_info(printed, cur, param_names):
312 329 for txt in cur:
313 330 if not printed:
314 331 print "file | caller | function | type | parameter | key | value |"
315 332 printed = 1
316 333
317 334 parameter = int(txt[6])
318 335 key = txt[7]
319 336 if len(param_names) and parameter in param_names:
320 337 key = key.replace("$", param_names[parameter])
321 338
322 339 print "%20s | %20s | %20s |" %(txt[0], txt[1], txt[2]),
323 340 print " %10s |" %(type_to_str(txt[5])),
324 341 print " %d | %s | %s" %(parameter, key, txt[8])
325 342 return printed
326 343
327 344 def get_caller_info(filename, ptrs, my_type):
328 345 cur = con.cursor()
329 346 param_names = get_param_names(filename, func)
330 347 printed = 0
331 348 type_filter = ""
332 349 if my_type != "":
333 350 type_filter = "and type = %d" %(type_to_int(my_type))
334 351 for ptr in ptrs:
335 352 cur.execute("select * from caller_info where function = '%s' %s;" %(ptr, type_filter))
336 353 printed = display_caller_info(printed, cur, param_names)
337 354
338 355 def print_caller_info(filename, func, my_type = ""):
339 356 ptrs = get_function_pointers(func)
340 357 get_caller_info(filename, ptrs, my_type)
341 358
342 359 def merge_values(param_names, vals, cur):
343 360 for txt in cur:
344 361 parameter = int(txt[0])
345 362 name = txt[1]
346 363 rl = txt_to_rl(txt[2])
347 364 if parameter in param_names:
348 365 name = name.replace("$", param_names[parameter])
349 366
350 367 if not parameter in vals:
351 368 vals[parameter] = {}
352 369
353 370 # the first item on the list is the number of rows. it's incremented
354 371 # every time we call merge_values().
355 372 if name in vals[parameter]:
356 373 vals[parameter][name] = [vals[parameter][name][0] + 1, rl_union(vals[parameter][name][1], rl)]
357 374 else:
358 375 vals[parameter][name] = [1, rl]
359 376
360 377 def get_param_names(filename, func):
361 378 cur = con.cursor()
362 379 param_names = {}
363 380 cur.execute("select parameter, value from parameter_name where file = '%s' and function = '%s';" %(filename, func))
364 381 for txt in cur:
365 382 parameter = int(txt[0])
366 383 name = txt[1]
367 384 param_names[parameter] = name
368 385 if len(param_names):
369 386 return param_names
370 387
371 388 cur.execute("select parameter, value from parameter_name where function = '%s';" %(func))
372 389 for txt in cur:
373 390 parameter = int(txt[0])
374 391 name = txt[1]
375 392 param_names[parameter] = name
376 393 return param_names
377 394
378 395 def get_caller_count(ptrs):
379 396 cur = con.cursor()
380 397 count = 0
381 398 for ptr in ptrs:
382 399 cur.execute("select count(distinct(call_id)) from caller_info where function = '%s';" %(ptr))
383 400 for txt in cur:
384 401 count += int(txt[0])
385 402 return count
386 403
387 404 def print_merged_caller_values(filename, func, ptrs, param_names, call_cnt):
388 405 cur = con.cursor()
389 406 vals = {}
390 407 for ptr in ptrs:
391 408 cur.execute("select parameter, key, value from caller_info where function = '%s' and type = %d;" %(ptr, type_to_int("PARAM_VALUE")))
392 409 merge_values(param_names, vals, cur);
393 410
394 411 for param in sorted(vals):
395 412 for name in sorted(vals[param]):
396 413 if vals[param][name][0] != call_cnt:
397 414 continue
398 415 print "%d %s -> %s" %(param, name, rl_to_txt(vals[param][name][1]))
399 416
400 417
401 418 def print_unmerged_caller_values(filename, func, ptrs, param_names):
402 419 cur = con.cursor()
403 420 for ptr in ptrs:
404 421 prev = -1
405 422 cur.execute("select file, caller, call_id, parameter, key, value from caller_info where function = '%s' and type = %d;" %(ptr, type_to_int("PARAM_VALUE")))
406 423 for filename, caller, call_id, parameter, name, value in cur:
407 424 if prev != int(call_id):
408 425 prev = int(call_id)
409 426
410 427 parameter = int(parameter)
411 428 if parameter < len(param_names):
412 429 name = name.replace("$", param_names[parameter])
413 430 else:
414 431 name = name.replace("$", "$%d" %(parameter))
415 432
416 433 print "%s | %s | %s | %s" %(filename, caller, name, value)
417 434 print "=========================="
418 435
419 436 def print_caller_values(filename, func, ptrs):
420 437 param_names = get_param_names(filename, func)
421 438 call_cnt = get_caller_count(ptrs)
422 439
423 440 print_merged_caller_values(filename, func, ptrs, param_names, call_cnt)
424 441 print "=========================="
425 442 print_unmerged_caller_values(filename, func, ptrs, param_names)
426 443
427 444 def caller_info_values(filename, func):
428 445 ptrs = get_function_pointers(func)
429 446 print_caller_values(filename, func, ptrs)
430 447
431 448 def print_return_states(func):
432 449 cur = con.cursor()
433 450 cur.execute("select * from return_states where function = '%s';" %(func))
434 451 count = 0
435 452 for txt in cur:
436 453 printed = 1
437 454 if count == 0:
438 455 print "file | function | return_id | return_value | type | param | key | value |"
439 456 count += 1
440 457 print "%s | %s | %2s | %13s" %(txt[0], txt[1], txt[3], txt[4]),
441 458 print "| %13s |" %(type_to_str(txt[6])),
442 459 print " %2d | %20s | %20s |" %(txt[7], txt[8], txt[9])
443 460
444 461 def print_return_implies(func):
445 462 cur = con.cursor()
446 463 cur.execute("select * from return_implies where function = '%s';" %(func))
447 464 count = 0
448 465 for txt in cur:
449 466 if not count:
450 467 print "file | function | type | param | key | value |"
451 468 count += 1
452 469 print "%15s | %15s" %(txt[0], txt[1]),
453 470 print "| %15s" %(type_to_str(txt[4])),
454 471 print "| %3d | %s | %15s |" %(txt[5], txt[6], txt[7])
455 472
456 473 def print_type_size(struct_type, member):
457 474 cur = con.cursor()
458 475 cur.execute("select * from type_size where type like '(struct %s)->%s';" %(struct_type, member))
459 476 print "type | size"
460 477 for txt in cur:
461 478 print "%-15s | %s" %(txt[0], txt[1])
462 479
463 480 cur.execute("select * from function_type_size where type like '(struct %s)->%s';" %(struct_type, member))
464 481 print "file | function | type | size"
465 482 for txt in cur:
466 483 print "%-15s | %-15s | %-15s | %s" %(txt[0], txt[1], txt[2], txt[3])
467 484
468 485 def print_data_info(struct_type, member):
469 486 cur = con.cursor()
470 487 cur.execute("select * from data_info where data like '(struct %s)->%s';" %(struct_type, member))
471 488 print "file | data | type | value"
472 489 for txt in cur:
473 490 print "%-15s | %-15s | %-15s | %s" %(txt[0], txt[1], type_to_str(txt[2]), txt[3])
474 491
475 492 def print_fn_ptrs(func):
476 493 ptrs = get_function_pointers(func)
477 494 if not ptrs:
478 495 return
479 496 print "%s = " %(func),
480 497 print(ptrs)
481 498
482 499 def print_functions(member):
483 500 cur = con.cursor()
484 501 cur.execute("select * from function_ptr where ptr like '%%->%s';" %(member))
485 502 print "File | Pointer | Function | Static"
486 503 for txt in cur:
487 504 print "%-15s | %-15s | %-15s | %s" %(txt[0], txt[2], txt[1], txt[3])
488 505
489 506 def get_callers(func):
490 507 ret = []
491 508 cur = con.cursor()
492 509 ptrs = get_function_pointers(func)
493 510 for ptr in ptrs:
494 511 cur.execute("select distinct caller from caller_info where function = '%s';" %(ptr))
495 512 for row in cur:
496 513 ret.append(row[0])
497 514 return ret
498 515
499 516 printed_funcs = []
500 517 def call_tree_helper(func, indent = 0):
501 518 global printed_funcs
502 519 if func in printed_funcs:
503 520 return
504 521 print "%s%s()" %(" " * indent, func)
505 522 if func == "too common":
506 523 return
507 524 if indent > 6:
508 525 return
509 526 printed_funcs.append(func)
510 527 callers = get_callers(func)
511 528 if len(callers) >= 20:
512 529 print "Over 20 callers for %s()" %(func)
513 530 return
514 531 for caller in callers:
515 532 call_tree_helper(caller, indent + 2)
516 533
517 534 def print_call_tree(func):
518 535 global printed_funcs
519 536 printed_funcs = []
520 537 call_tree_helper(func)
521 538
522 539 def function_type_value(struct_type, member):
523 540 cur = con.cursor()
524 541 cur.execute("select * from function_type_value where type like '(struct %s)->%s';" %(struct_type, member))
525 542 for txt in cur:
526 543 print "%-30s | %-30s | %s | %s" %(txt[0], txt[1], txt[2], txt[3])
527 544
528 545 def trace_callers(func, param):
529 546 sources = []
530 547 prev_type = 0
531 548
532 549 cur = con.cursor()
533 550 ptrs = get_function_pointers(func)
534 551 for ptr in ptrs:
535 552 cur.execute("select type, caller, value from caller_info where function = '%s' and (type = 0 or type = 1014 or type = 1028) and (parameter = -1 or parameter = %d);" %(ptr, param))
536 553 for row in cur:
537 554 data_type = int(row[0])
538 555 if data_type == 1014:
539 556 sources.append((row[1], row[2]))
540 557 elif data_type == 1028:
541 558 sources.append(("%", row[2])) # hack...
542 559 elif data_type == 0 and prev_type == 0:
543 560 sources.append((row[1], ""))
544 561 prev_type = data_type
545 562 return sources
546 563
547 564 def trace_param_helper(func, param, indent = 0):
548 565 global printed_funcs
549 566 if func in printed_funcs:
550 567 return
551 568 print "%s%s(param %d)" %(" " * indent, func, param)
552 569 if func == "too common":
553 570 return
554 571 if indent > 20:
555 572 return
556 573 printed_funcs.append(func)
557 574 sources = trace_callers(func, param)
558 575 for path in sources:
559 576
560 577 if len(path[1]) and path[1][0] == 'p' and path[1][1] == ' ':
561 578 p = int(path[1][2:])
562 579 trace_param_helper(path[0], p, indent + 2)
563 580 elif len(path[0]) and path[0][0] == '%':
564 581 print " %s%s" %(" " * indent, path[1])
565 582 else:
566 583 print "* %s%s %s" %(" " * (indent - 1), path[0], path[1])
567 584
568 585 def trace_param(func, param):
569 586 global printed_funcs
570 587 printed_funcs = []
571 588 print "tracing %s %d" %(func, param)
572 589 trace_param_helper(func, param)
573 590
574 591 def print_locals(filename):
575 592 cur = con.cursor()
576 593 cur.execute("select file,data,value from data_info where file = '%s' and type = 8029 and value != 0;" %(filename))
577 594 for txt in cur:
578 595 print "%s | %s | %s" %(txt[0], txt[1], txt[2])
579 596
580 597 def constraint(struct_type, member):
581 598 cur = con.cursor()
↓ open down ↓ |
372 lines elided |
↑ open up ↑ |
582 599 cur.execute("select * from constraints_required where data like '(struct %s)->%s' or bound like '(struct %s)->%s';" %(struct_type, member, struct_type, member))
583 600 for txt in cur:
584 601 print "%-30s | %-30s | %s | %s" %(txt[0], txt[1], txt[2], txt[3])
585 602
586 603 if len(sys.argv) < 2:
587 604 usage()
588 605
589 606 if len(sys.argv) == 2:
590 607 func = sys.argv[1]
591 608 print_caller_info("", func)
609 +elif sys.argv[1] == "info":
610 + my_type = ""
611 + if len(sys.argv) == 4:
612 + my_type = sys.argv[3]
613 + func = sys.argv[2]
614 + print_caller_info("", func, my_type)
592 615 elif sys.argv[1] == "call_info":
593 616 if len(sys.argv) != 4:
594 617 usage()
595 618 filename = sys.argv[2]
596 619 func = sys.argv[3]
597 620 caller_info_values(filename, func)
598 621 print_caller_info(filename, func)
599 -elif sys.argv[1] == "user_data":
600 - func = sys.argv[2]
601 - print_caller_info(filename, func, "USER_DATA")
602 -elif sys.argv[1] == "param_value":
603 - func = sys.argv[2]
604 - print_caller_info(filename, func, "PARAM_VALUE")
605 622 elif sys.argv[1] == "function_ptr" or sys.argv[1] == "fn_ptr":
606 623 func = sys.argv[2]
607 624 print_fn_ptrs(func)
608 625 elif sys.argv[1] == "return_states":
609 626 func = sys.argv[2]
610 627 print_return_states(func)
611 628 print "================================================"
612 629 print_return_implies(func)
613 630 elif sys.argv[1] == "return_implies":
614 631 func = sys.argv[2]
615 632 print_return_implies(func)
616 633 elif sys.argv[1] == "type_size" or sys.argv[1] == "buf_size":
617 634 struct_type = sys.argv[2]
618 635 member = sys.argv[3]
619 636 print_type_size(struct_type, member)
620 637 elif sys.argv[1] == "data_info":
621 638 struct_type = sys.argv[2]
622 639 member = sys.argv[3]
623 640 print_data_info(struct_type, member)
624 641 elif sys.argv[1] == "call_tree":
625 642 func = sys.argv[2]
626 643 print_call_tree(func)
627 644 elif sys.argv[1] == "where":
628 645 if len(sys.argv) == 3:
629 646 struct_type = "%"
630 647 member = sys.argv[2]
631 648 elif len(sys.argv) == 4:
632 649 struct_type = sys.argv[2]
633 650 member = sys.argv[3]
634 651 function_type_value(struct_type, member)
635 652 elif sys.argv[1] == "local":
636 653 filename = sys.argv[2]
637 654 variable = ""
638 655 if len(sys.argv) == 4:
639 656 variable = sys.argv[3]
640 657 local_values(filename, variable)
641 658 elif sys.argv[1] == "functions":
642 659 member = sys.argv[2]
643 660 print_functions(member)
644 661 elif sys.argv[1] == "trace_param":
645 662 if len(sys.argv) != 4:
646 663 usage()
647 664 func = sys.argv[2]
648 665 param = int(sys.argv[3])
649 666 trace_param(func, param)
650 667 elif sys.argv[1] == "locals":
651 668 if len(sys.argv) != 3:
652 669 usage()
653 670 filename = sys.argv[2]
654 671 print_locals(filename);
655 672 elif sys.argv[1] == "constraint":
656 673 if len(sys.argv) == 3:
657 674 struct_type = "%"
658 675 member = sys.argv[2]
659 676 elif len(sys.argv) == 4:
660 677 struct_type = sys.argv[2]
661 678 member = sys.argv[3]
662 679 constraint(struct_type, member)
663 680 elif sys.argv[1] == "test":
664 681 filename = sys.argv[2]
665 682 func = sys.argv[3]
666 683 caller_info_values(filename, func)
667 684 else:
668 685 usage()
↓ open down ↓ |
54 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX