From fcaee535e21b3911ea651e78413af7a72a89e464 Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Tue, 18 Oct 2022 22:18:59 +0100 Subject: [PATCH 1/2] Fix calltree links Fixes: https://github.com/ossf/fuzz-introspector/issues/506 Signed-off-by: David Korczynski --- src/fuzz_introspector/analysis.py | 62 ++++++++++++++++++------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/src/fuzz_introspector/analysis.py b/src/fuzz_introspector/analysis.py index 5cf1240d5..0735e1938 100644 --- a/src/fuzz_introspector/analysis.py +++ b/src/fuzz_introspector/analysis.py @@ -238,38 +238,48 @@ def get_hit_count_color(hit_count: int) -> str: def get_url_to_cov_report(profile, node, target_coverage_url): """ Get URL to coverage report for the node. """ - link = "#" - for fd_k, fd in profile.all_class_functions.items(): - if fd.function_name == node.dst_function_name: - logger.debug("Found %s -- %s -- %d" % ( - fd.function_name, - fd.function_source_file, - fd.function_linenumber - )) - link = profile.resolve_coverage_link( - target_coverage_url, - fd.function_source_file, - fd.function_linenumber, - fd.function_name - ) - break - return link + dst_options = [ + node.dst_function_name, + utils.demangle_cpp_func(node.dst_function_name) + ] + for dst in dst_options: + for fd_k, fd in profile.all_class_functions.items(): + if ( + fd.function_name == dst or + utils.normalise_str(fd.function_name) == utils.normalise_str(dst) + ): + return profile.resolve_coverage_link( + target_coverage_url, + fd.function_source_file, + fd.function_linenumber, + fd.function_name + ) + return "#" def get_parent_callsite_link(node, callstack, profile, target_coverage_url): """Gets the coverage callsite link of a given node.""" - callsite_link = "#" if callstack_has_parent(node, callstack): parent_fname = callstack_get_parent(node, callstack) - for fd_k, fd in profile.all_class_functions.items(): - if utils.demangle_cpp_func(fd.function_name) == parent_fname: - callsite_link = profile.resolve_coverage_link( - target_coverage_url, - fd.function_source_file, - node.src_linenumber, - fd.function_name - ) - return callsite_link + dst_options = [ + parent_fname, + utils.demangle_cpp_func(parent_fname) + ] + for dst in dst_options: + for fd_k, fd in profile.all_class_functions.items(): + if ( + fd.function_name == dst or + utils.normalise_str(fd.function_name) == utils.normalise_str(dst) + ): + callsite_link = profile.resolve_coverage_link( + target_coverage_url, + fd.function_source_file, + node.src_linenumber, + fd.function_name + ) + return callsite_link + + return "#" def overlay_calltree_with_coverage( From 8fbb335f29c42fe77c2bdf365bc8a026a091bc5c Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Tue, 18 Oct 2022 22:21:43 +0100 Subject: [PATCH 2/2] nit Signed-off-by: David Korczynski --- src/fuzz_introspector/analysis.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fuzz_introspector/analysis.py b/src/fuzz_introspector/analysis.py index 0735e1938..0f8a7341a 100644 --- a/src/fuzz_introspector/analysis.py +++ b/src/fuzz_introspector/analysis.py @@ -245,8 +245,8 @@ def get_url_to_cov_report(profile, node, target_coverage_url): for dst in dst_options: for fd_k, fd in profile.all_class_functions.items(): if ( - fd.function_name == dst or - utils.normalise_str(fd.function_name) == utils.normalise_str(dst) + fd.function_name == dst + or utils.normalise_str(fd.function_name) == utils.normalise_str(dst) ): return profile.resolve_coverage_link( target_coverage_url, @@ -268,8 +268,8 @@ def get_parent_callsite_link(node, callstack, profile, target_coverage_url): for dst in dst_options: for fd_k, fd in profile.all_class_functions.items(): if ( - fd.function_name == dst or - utils.normalise_str(fd.function_name) == utils.normalise_str(dst) + fd.function_name == dst + or utils.normalise_str(fd.function_name) == utils.normalise_str(dst) ): callsite_link = profile.resolve_coverage_link( target_coverage_url,