MCPcopy Create free account
hub / github.com/MJx0/KittyMemoryEx / getMaps

Function getMaps

KittyMemoryEx/KittyMemoryEx.cpp:243–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241 }
242
243 std::vector<ProcMap> getMaps(pid_t pid,
244 EProcMapFilter filter,
245 const std::string &name,
246 const std::vector<ProcMap> &maps)
247 {
248 std::vector<ProcMap> retMaps;
249 regex_t re{};
250 bool isRegex = (filter == EProcMapFilter::Regex);
251
252 if (isRegex)
253 {
254 if (regcomp(&re, name.c_str(), REG_EXTENDED | REG_NOSUB) != 0)
255 return retMaps;
256 }
257
258 for (auto &it : (maps.empty() ? getAllMaps(pid) : maps))
259 {
260 if (!it.isValid())
261 continue;
262
263 bool match = false;
264 switch (filter)
265 {
266 case EProcMapFilter::Equal:
267 match = (it.pathname == name);
268 break;
269 case EProcMapFilter::StartWith:
270 match = KittyUtils::String::startsWith(it.pathname, name);
271 break;
272 case EProcMapFilter::EndWith:
273 match = KittyUtils::String::endsWith(it.pathname, name);
274 break;
275 case EProcMapFilter::Regex:
276 match = (regexec(&re, it.pathname.c_str(), 0, NULL, 0) == 0);
277 break;
278 case EProcMapFilter::Contains:
279 default:
280 match = KittyUtils::String::contains(it.pathname, name);
281 break;
282 }
283
284 if (match)
285 {
286 retMaps.push_back(it);
287 }
288 }
289
290 if (isRegex)
291 regfree(&re);
292
293 return retMaps;
294 }
295
296 std::vector<ProcMap> getMaps(EProcMapFilter filter, const std::string &name, const std::vector<ProcMap> &maps)
297 {

Callers 2

dumpMemFileMethod · 0.85
KittyScanner.cppFile · 0.85

Calls 2

getAllMapsFunction · 0.85
isValidMethod · 0.45

Tested by

no test coverage detected