Read an RTL file and finds callees for each function and if there are calls via function pointer. :param tu: the translation unit :param call_graph: a object used to store information about each function, results go here
(tu, call_graph)
| 120 | |
| 121 | |
| 122 | def read_rtl(tu, call_graph): |
| 123 | """ |
| 124 | Read an RTL file and finds callees for each function and if there are calls via function pointer. |
| 125 | :param tu: the translation unit |
| 126 | :param call_graph: a object used to store information about each function, results go here |
| 127 | """ |
| 128 | |
| 129 | # Construct A Call Graph |
| 130 | function = re.compile(r'^;; Function (.*) \((\S+), funcdef_no=\d+(, [a-z_]+=\d+)*\)( \([a-z ]+\))?$') |
| 131 | static_call = re.compile(r'^.*\(call.*"(.*)".*$') |
| 132 | other_call = re.compile(r'^.*call .*$') |
| 133 | |
| 134 | for line_ in open(tu + rtl_ext).readlines(): |
| 135 | m = function.match(line_) |
| 136 | if m: |
| 137 | fxn_name = m.group(2) |
| 138 | fxn_dict2 = find_fxn(tu, fxn_name, call_graph) |
| 139 | if not fxn_dict2: |
| 140 | pprint.pprint(call_graph) |
| 141 | raise Exception("Error locating function {} in {}".format(fxn_name, tu)) |
| 142 | |
| 143 | fxn_dict2['demangledName'] = m.group(1) |
| 144 | fxn_dict2['calls'] = set() |
| 145 | fxn_dict2['has_ptr_call'] = False |
| 146 | continue |
| 147 | |
| 148 | m = static_call.match(line_) |
| 149 | if m: |
| 150 | fxn_dict2['calls'].add(m.group(1)) |
| 151 | # print("Call: {0} -> {1}".format(current_fxn, m.group(1))) |
| 152 | continue |
| 153 | |
| 154 | m = other_call.match(line_) |
| 155 | if m: |
| 156 | fxn_dict2['has_ptr_call'] = True |
| 157 | continue |
| 158 | |
| 159 | |
| 160 | def read_su(tu, call_graph): |