MCPcopy Create free account
hub / github.com/F-Stack/f-stack / prof_dump_maps

Function prof_dump_maps

app/redis-6.2.6/deps/jemalloc/src/prof.c:1435–1489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

prof_dump_fileFunction · 0.85

Calls 6

prof_open_mapsFunction · 0.85
prof_getpidFunction · 0.85
prof_dump_writeFunction · 0.85
prof_dump_flushFunction · 0.85
malloc_read_fdFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected