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

Use debug info for func args #1183

Merged
merged 3 commits into from
Aug 3, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -1067,9 +1067,37 @@ FuzzerFunctionWrapper FuzzIntrospector::wrapFunction(Function *F) {
FuncWrap.ReturnType = resolveTypeName(F->getReturnType());

// Arguments
// errs() << "Function:\n";
// errs() << FuncWrap.FunctionName << "\n";
for (auto &A : F->args()) {
FuncWrap.ArgTypes.push_back(resolveTypeName(A.getType()));
FuncWrap.ArgNames.push_back(A.getName().str());
//FuncWrap.ArgNames.push_back(A.getName().str());
if (A.getName().str().empty()) {
const DILocalVariable* Var = NULL;
bool FoundArg = false;
for (auto &BB : *F) {
for (auto &I : BB) {
if (const DbgDeclareInst* DbgDeclare = dyn_cast<DbgDeclareInst>(&I)) {
if (auto DLV = dyn_cast<DILocalVariable>(DbgDeclare->getVariable())) {
if ( DLV->getArg() == A.getArgNo() + 1 &&
!DLV->getName().empty() &&
DLV->getScope()->getSubprogram() == F->getSubprogram()) {
//errs() << "--" << DLV->getName().str() << "\n";
FuncWrap.ArgNames.push_back(DLV->getName().str());
FoundArg = true;
}
}
}
}
}
if (FoundArg == false) {
FuncWrap.ArgNames.push_back("");
}
}
else {
// It's non empty, we just push that.
FuncWrap.ArgNames.push_back(A.getName().str());
}
}

// Log the amount of basic blocks, instruction count and cyclomatic
Expand Down
1 change: 1 addition & 0 deletions src/fuzz_introspector/html_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def create_all_function_table(
json_copy = row_element.copy()
json_copy['Func name'] = demangled_func_name
json_copy['Args'] = str(fd.arg_types)
json_copy['ArgNames'] = fd.arg_names
json_copy['Reached by Fuzzers'] = fd.reached_by_fuzzers
json_copy['return_type'] = fd.return_type
json_copy['raw-function-name'] = fd.raw_function_name
Expand Down
Loading