Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: use structured debug info handling v2 #1449

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/fuzz_introspector/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,17 +851,20 @@ def correlate_introspection_functions_to_debug_info(all_functions_json_report,
func_sig, correlated_debug_function = correlate_introspector_func_to_debug_information(
if_func, all_debug_functions)
if func_sig is not None:
if_func['function_signature'] = func_sig
if_func['debug_function_info'] = correlated_debug_function
if_func['function_signature_v1'] = func_sig
if_func['debug_function_info_v1'] = correlated_debug_function
else:
if_func['function_signature'] = 'N/A'
if_func['debug_function_info'] = dict()
if_func['function_signature_v1'] = 'N/A'
if_func['debug_function_info_v1'] = dict()


def convert_debug_info_to_signature_v2(function, introspector_func):
function['return_type'] = 'N/A'
function['args'] = []
try:
return_type = convert_param_list_to_str_v2(
function['func_signature_elems']['return_type'])
function['return_type'] = return_type
func_signature = return_type + " "
except KeyError:
return 'N/A'
Expand Down Expand Up @@ -924,6 +927,7 @@ def convert_debug_info_to_signature_v2(function, introspector_func):
len(function['func_signature_elems']['params'])):
param_string = convert_param_list_to_str_v2(
function['func_signature_elems']['params'][idx])
function['args'].append(param_string)
func_signature += param_string
if idx < len(function['func_signature_elems']['params']) - 1:
func_signature += ', '
Expand Down Expand Up @@ -972,14 +976,12 @@ def correlate_introspector_func_to_debug_information_v2(
most_likely_func = None
for dfunction in all_debug_functions:
try:
dline = int(
dfunction['func_signature_elems']['source_location'].get(
'line', '-1'))
dline = int(dfunction['source'].get('source_line', '-1'))
except ValueError:
continue

if dfunction['func_signature_elems']['source_location'].get(
'file', '') == if_func['Functions filename']:
if dfunction['source'].get('source_file',
'') == if_func['Functions filename']:

# Match based on containment, as there can be discrepancies between function
# signatur start (as from frunc_to_match) and the lines of code of the first
Expand Down Expand Up @@ -1012,8 +1014,8 @@ def correlate_introspection_functions_to_debug_info_v2(
if_func, debug_all_functions)

if func_sig is not None:
if_func['function_signature_v2'] = func_sig
if_func['debug_function_info_v2'] = correlated_debug_function
if_func['function_signature'] = func_sig
if_func['debug_function_info'] = correlated_debug_function
else:
if_func['function_signature_v2'] = 'N/A'
if_func['debug_function_info_v2'] = dict()
if_func['function_signature'] = 'N/A'
if_func['debug_function_info'] = dict()
10 changes: 4 additions & 6 deletions src/fuzz_introspector/debug_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,23 +407,21 @@ def extract_debugged_function_signature(dfunc, all_debug_types):
function_signature_elements = {
'return_type': return_type,
'params': params,
'source_location': {
'file': source_file,
'line': source_line
}
}
source_location = {'source_file': source_file, 'source_line': source_line}

return function_signature_elements
return function_signature_elements, source_location


def clean_extract_raw_all_debugged_function_signatures(all_debug_types,
all_debug_functions):
print("Correlating")
for dfunc in all_debug_functions:

func_signature_elems = extract_debugged_function_signature(
func_signature_elems, source_location = extract_debugged_function_signature(
dfunc, all_debug_types)
dfunc['func_signature_elems'] = func_signature_elems
dfunc['source'] = source_location


if __name__ in "__main__":
Expand Down
Loading