MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / prof_dump_maps

Function prof_dump_maps

deps/memkind/src/jemalloc/src/prof.c:1427–1480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1425}
1426
1427static bool
1428prof_dump_maps(bool propagate_err) {
1429 bool ret;
1430 int mfd;
1431
1432 cassert(config_prof);
1433#ifdef __FreeBSD__
1434 mfd = prof_open_maps("/proc/curproc/map");
1435#elif defined(_WIN32)
1436 mfd = -1; // Not implemented
1437#else
1438 {
1439 int pid = prof_getpid();
1440
1441 mfd = prof_open_maps("/proc/%d/task/%d/maps", pid, pid);
1442 if (mfd == -1) {
1443 mfd = prof_open_maps("/proc/%d/maps", pid);
1444 }
1445 }
1446#endif
1447 if (mfd != -1) {
1448 ssize_t nread;
1449
1450 if (prof_dump_write(propagate_err, "\nMAPPED_LIBRARIES:\n") &&
1451 propagate_err) {
1452 ret = true;
1453 goto label_return;
1454 }
1455 nread = 0;
1456 do {
1457 prof_dump_buf_end += nread;
1458 if (prof_dump_buf_end == PROF_DUMP_BUFSIZE) {
1459 /* Make space in prof_dump_buf before read(). */
1460 if (prof_dump_flush(propagate_err) &&
1461 propagate_err) {
1462 ret = true;
1463 goto label_return;
1464 }
1465 }
1466 nread = read(mfd, &prof_dump_buf[prof_dump_buf_end],
1467 PROF_DUMP_BUFSIZE - prof_dump_buf_end);
1468 } while (nread > 0);
1469 } else {
1470 ret = true;
1471 goto label_return;
1472 }
1473
1474 ret = false;
1475label_return:
1476 if (mfd != -1) {
1477 close(mfd);
1478 }
1479 return ret;
1480}
1481
1482/*
1483 * See prof_sample_threshold_update() comment for why the body of this function

Callers 1

prof_dump_fileFunction · 0.70

Calls 4

prof_open_mapsFunction · 0.70
prof_getpidFunction · 0.70
prof_dump_writeFunction · 0.70
prof_dump_flushFunction · 0.70

Tested by

no test coverage detected