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

Method loadPdbFunctions

src/debugformat/pdb.cpp:66–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void DebugFormat::loadPdbFunctions()
67{
68 auto* pdbFunctions = _pdbFile->get_functions();
69 if (pdbFunctions == nullptr)
70 return;
71
72 for (auto& f : *pdbFunctions)
73 {
74 if (f.second == nullptr)
75 continue;
76
77 retdec::pdbparser::PDBFunction *pfnc = f.second;
78
79 retdec::common::Function fnc(pfnc->getNameWithOverloadIndex());
80
81 fnc.setStartEnd(pfnc->address, pfnc->address + pfnc->length);
82 fnc.setSourceFileName(_pdbFile->get_module_name(pfnc->module_index));
83
84 auto* sym = _inFile->getFileFormat()->getSymbol(pfnc->address + 1);
85 fnc.setIsThumb(sym && sym->isThumbSymbol());
86
87 fnc.setIsVariadic(pfnc->type_def->func_is_variadic);
88
89 if (!pfnc->lines.empty())
90 {
91 fnc.setStartLine(pfnc->lines.front().line);
92 fnc.setEndLine(pfnc->lines.back().line);
93 }
94
95 if (pfnc->type_def != nullptr)
96 {
97 fnc.returnType = loadPdbType(pfnc->type_def->func_rettype_def);
98 }
99
100 unsigned argCntr = 0;
101 for (auto& a : pfnc->arguments)
102 {
103 retdec::common::Storage storage;
104 if (a.location == retdec::pdbparser::PDBLVLOC_REGISTER) // in register
105 {
106 storage = retdec::common::Storage::inRegister(a.register_num);
107 }
108 else // in register-relative stack
109 {
110 auto num = a.location == retdec::pdbparser::PDBLVLOC_BPREL32 ? 22 /*CV_REG_EBP*/ : a.register_num;
111 storage = retdec::common::Storage::onStack(a.offset, num);
112 }
113
114 std::string n = a.name;
115 std::string name = n.empty() ? std::string("arg") + std::to_string(argCntr) : n;
116 retdec::common::Object newArg(name, storage);
117 newArg.type = loadPdbType(a.type_def);
118 fnc.parameters.push_back(newArg);
119 ++argCntr;
120 }
121
122 for (auto& lv : pfnc->loc_variables)
123 {

Callers

nothing calls this directly

Calls 15

get_functionsMethod · 0.80
setStartEndMethod · 0.80
setSourceFileNameMethod · 0.80
get_module_nameMethod · 0.80
isThumbSymbolMethod · 0.80
setIsVariadicMethod · 0.80
setStartLineMethod · 0.80
setEndLineMethod · 0.80
getSymbolMethod · 0.45
getFileFormatMethod · 0.45
setIsThumbMethod · 0.45

Tested by

no test coverage detected