db/smdb: add info command with type filtering
PATCH 1/1 db/smdb: add info command with type filtering
Add a new command to smdb that shows caller info filtered by a user specified type. This allows us to remove the abandoned, broken and undocumented user_data and param_value commands.
It's also possible to remove the unamed command (i.e. calling smdb with just a function), as this new 'info' command provides the same functionality when a user does not specify a type. However let's keep it for now to avoid confusing users.
--- smatch_data/db/smdb.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
smatch_data/db/smdb.py +7 -7
@@ -17,6 +17,7 @@ except sqlite3.Error, e: def usage(): print "%s" %(sys.argv[0]) print "<function> - how a function is called" + print "info <type> - how a function is called, filtered by type" print "return_states <function> - what a function returns" print "call_tree <function> - show the call tree" print "where <struct_type> <member> - where a struct member is set"
@@ -605,6 +606,12 @@ if len(sys.argv) < 2: if len(sys.argv) == 2: func = sys.argv[1] print_caller_info("", func) +elif sys.argv[1] == "info": + my_type = "" + if len(sys.argv) == 4: + my_type = sys.argv[3] + func = sys.argv[2] + print_caller_info("", func, my_type) elif sys.argv[1] == "call_info": if len(sys.argv) != 4: usage()
@@ -612,13 +619,6 @@ elif sys.argv[1] == "call_info": func = sys.argv[3] caller_info_values(filename, func) print_caller_info(filename, func) -elif sys.argv[1] == "user_data": - func = sys.argv[2] - filename = sys.argv[3] - print_caller_info(filename, func, "USER_DATA") -elif sys.argv[1] == "param_value": - func = sys.argv[2] - print_caller_info(filename, func, "PARAM_VALUE") elif sys.argv[1] == "function_ptr" or sys.argv[1] == "fn_ptr": func = sys.argv[2] print_fn_ptrs(func)
Signature · 1 line
2.21.0
Dan Carpenter
AppliedQuoted 4 lines · Andrew Murray
smatch_data/db/smdb.py +0
-0@@ -612,13 +619,6 @@ elif sys.argv[1] == "call_info": func = sys.argv[3] caller_info_values(filename, func) print_caller_info(filename, func)
smatch_data/db/smdb.py elif sys.argv[1] == "call_info": · line 624
Quoted 10 lines
smatch_data/db/smdb.py +0
-7-elif sys.argv[1] == "user_data": - func = sys.argv[2] - filename = sys.argv[3] - print_caller_info(filename, func, "USER_DATA") -elif sys.argv[1] == "param_value": - func = sys.argv[2] - print_caller_info(filename, func, "PARAM_VALUE") elif sys.argv[1] == "function_ptr" or sys.argv[1] == "fn_ptr": func = sys.argv[2] print_fn_ptrs(func)
Somehow this chunk didn't apply at all but I did it manually.
Applied.
regards,
dan carpenter
Quoted 8 lines · Dan Carpenter
smatch_data/db/smdb.py elif sys.argv[1] == "call_info": · line 617
Quoted 7 lines · Andrew Murray
smatch_data/db/smdb.py +0
-3@@ -612,13 +619,6 @@ elif sys.argv[1] == "call_info": func = sys.argv[3] caller_info_values(filename, func) print_caller_info(filename, func) -elif sys.argv[1] == "user_data": - func = sys.argv[2] - filename = sys.argv[3]
The patch didn't apply because my local tree had this line ^^ in.
Quoted 9 lines
smatch_data/db/smdb.py elif sys.argv[1] == "call_info": · line 624
Quoted 7 lines
smatch_data/db/smdb.py +0
-4- print_caller_info(filename, func, "USER_DATA") -elif sys.argv[1] == "param_value": - func = sys.argv[2] - print_caller_info(filename, func, "PARAM_VALUE") elif sys.argv[1] == "function_ptr" or sys.argv[1] == "fn_ptr": func = sys.argv[2] print_fn_ptrs(func)Somehow this chunk didn't apply at all but I did it manually.
I messed up when making the patch.
Thanks,
Andrew Murray
Quoted 5 lines
Applied.
regards,
dan carpenter