MCPcopy Create free account
hub / github.com/HexHive/NASS / SetFocusFunction

Method SetFocusFunction

fuzz/libfuzzer/FuzzerTracePC.cpp:251–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251void TracePC::SetFocusFunction(const std::string &FuncName) {
252 // This function should be called once.
253 assert(!FocusFunctionCounterPtr);
254 // "auto" is not a valid function name. If this function is called with "auto"
255 // that means the auto focus functionality failed.
256 if (FuncName.empty() || FuncName == "auto")
257 return;
258 for (size_t M = 0; M < NumModules; M++) {
259 auto &PCTE = ModulePCTable[M];
260 size_t N = PCTE.Stop - PCTE.Start;
261 for (size_t I = 0; I < N; I++) {
262 if (!(PcIsFuncEntry(&PCTE.Start[I]))) continue; // not a function entry.
263 auto Name = DescribePC("%F", GetNextInstructionPc(PCTE.Start[I].PC));
264 if (Name[0] == 'i' && Name[1] == 'n' && Name[2] == ' ')
265 Name = Name.substr(3, std::string::npos);
266 if (FuncName != Name) continue;
267 Printf("INFO: Focus function is set to '%s'\n", Name.c_str());
268 FocusFunctionCounterPtr = Modules[M].Start() + I;
269 return;
270 }
271 }
272
273 Printf("ERROR: Failed to set focus function. Make sure the function name is "
274 "valid (%s) and symbolization is enabled.\n", FuncName.c_str());
275 exit(1);
276}
277
278bool TracePC::ObservedFocusFunction() {
279 return FocusFunctionCounterPtr && *FocusFunctionCounterPtr;

Callers 1

LoopMethod · 0.80

Calls 5

DescribePCFunction · 0.85
PrintfFunction · 0.70
emptyMethod · 0.45
c_strMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected