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

func-sig: handle namespaced non-class functions #1434

Merged
merged 2 commits into from
Feb 17, 2024
Merged
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
14 changes: 12 additions & 2 deletions src/fuzz_introspector/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,14 @@ def detect_branch_level_blockers(
return fuzz_blockers


def extract_namespace(mangled_function_name):
def extract_namespace(mangled_function_name, return_type=None):
logger.info("Demangling: %s" % (mangled_function_name))
demangled_func_name = utils.demangle_cpp_func(mangled_function_name)
logger.info("Demangled name: %s" % (demangled_func_name))
if return_type is not None and demangled_func_name.startswith(
f"{return_type} "):
demangled_func_name = demangled_func_name[len(return_type) + 1:]
logger.info("Removed function type: %s" % (demangled_func_name))
if "::" not in demangled_func_name:
return []

Expand Down Expand Up @@ -722,7 +726,8 @@ def convert_debug_info_to_signature(function, introspector_func):
# 2) identify namespace
# 3) identify if namespace last part matches first argument
# 4) assemble
namespace = extract_namespace(introspector_func['raw-function-name'])
namespace = extract_namespace(introspector_func['raw-function-name'],
function['return_type'])

func_name = ''
param_idx = 0
Expand Down Expand Up @@ -751,6 +756,11 @@ def convert_debug_info_to_signature(function, introspector_func):
logger.info("Option 3")
func_name = "::".join(namespace[0:-1]) + "::"
param_idx += 1
else:
# Simple function in namespace but not in a class
# No increasae in param_idx, since we don't eat the object
# instance pointer.
func_name = "::".join(namespace[0:-1]) + "::"

func_name += function['name']

Expand Down
Loading