D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
usr
/
share
/
doc
/
python3-pycparser
/
examples
/
Filename :
func_calls.py
back
Copy
#----------------------------------------------------------------- # pycparser: func_defs.py # # Using pycparser for printing out all the calls of some function # in a C file. # # Copyright (C) 2008-2015, Eli Bendersky # License: BSD #----------------------------------------------------------------- from __future__ import print_function import sys from pycparser import c_parser, c_ast, parse_file # A visitor with some state information (the funcname it's # looking for) # class FuncCallVisitor(c_ast.NodeVisitor): def __init__(self, funcname): self.funcname = funcname def visit_FuncCall(self, node): if node.name.name == self.funcname: print('%s called at %s' % (self.funcname, node.name.coord)) def show_func_calls(filename, funcname): ast = parse_file(filename, use_cpp=True) v = FuncCallVisitor(funcname) v.visit(ast) if __name__ == "__main__": if len(sys.argv) > 2: filename = sys.argv[1] func = sys.argv[2] else: filename = 'examples/c_files/hash.c' func = 'malloc' show_func_calls(filename, func)
Name
Size
Last Modified
Owner
Permissions
Actions
c_files
Dir
July 28 2023 2:56:41
root
0755
c-to-c.py
1.419
KB
November 13 2019 2:57:05
root
0644
cdecl.py
3.048
KB
November 13 2019 2:57:05
root
0644
explore_ast.py
5.27
KB
November 13 2019 2:57:05
root
0644
func_calls.py
1.084
KB
November 13 2019 2:57:05
root
0644
func_defs.py
1.081
KB
November 13 2019 2:57:05
root
0644
rewrite_ast.py
0.585
KB
June 10 2015 3:00:55
root
0644
using_cpp_libc.py
0.727
KB
November 13 2019 2:57:05
root
0644
using_gcc_E_libc.py
0.778
KB
November 13 2019 2:57:05
root
0644
2017 © D7net | D704T team