MCPcopy Create free account
hub / github.com/avast/retdec / getDebugStackVariable

Method getDebugStackVariable

src/bin2llvmir/optimizations/stack/stack.cpp:293–327  ·  view source on GitHub ↗

* Find a value that is being added to the stack pointer register in \p root. * Find a debug variable with offset equal to this value. */

Source from the content-addressed store, hash-verified

291 * Find a debug variable with offset equal to this value.
292 */
293const retdec::common::Object* StackAnalysis::getDebugStackVariable(
294 llvm::Function* fnc,
295 SymbolicTree& root)
296{
297 auto baseOffset = getBaseOffset(root);
298 if (!baseOffset.has_value())
299 {
300 return nullptr;
301 }
302
303 if (_dbgf == nullptr)
304 {
305 return nullptr;
306 }
307
308 auto* debugFnc = _dbgf->getFunction(_config->getFunctionAddress(fnc));
309 if (debugFnc == nullptr)
310 {
311 return nullptr;
312 }
313
314 for (auto& var : debugFnc->locals)
315 {
316 if (!var.getStorage().isStack())
317 {
318 continue;
319 }
320 if (var.getStorage().getStackOffset() == baseOffset)
321 {
322 return &var;
323 }
324 }
325
326 return nullptr;
327}
328
329const retdec::common::Object* StackAnalysis::getConfigStackVariable(
330 llvm::Function* fnc,

Callers

nothing calls this directly

Calls 4

isStackMethod · 0.80
getStackOffsetMethod · 0.80
getFunctionMethod · 0.45
getFunctionAddressMethod · 0.45

Tested by

no test coverage detected