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

Function prof_dump_maps

deps/jemalloc/src/prof.c:1706–1760  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1704}
1705
1706static bool
1707prof_dump_maps(bool propagate_err) {
1708 bool ret;
1709 int mfd;
1710
1711 cassert(config_prof);
1712#ifdef __FreeBSD__
1713 mfd = prof_open_maps("/proc/curproc/map");
1714#elif defined(_WIN32)
1715 mfd = -1; // Not implemented
1716#else
1717 {
1718 int pid = prof_getpid();
1719
1720 mfd = prof_open_maps("/proc/%d/task/%d/maps", pid, pid);
1721 if (mfd == -1) {
1722 mfd = prof_open_maps("/proc/%d/maps", pid);
1723 }
1724 }
1725#endif
1726 if (mfd != -1) {
1727 ssize_t nread;
1728
1729 if (prof_dump_write(propagate_err, "\nMAPPED_LIBRARIES:\n") &&
1730 propagate_err) {
1731 ret = true;
1732 goto label_return;
1733 }
1734 nread = 0;
1735 do {
1736 prof_dump_buf_end += nread;
1737 if (prof_dump_buf_end == PROF_DUMP_BUFSIZE) {
1738 /* Make space in prof_dump_buf before read(). */
1739 if (prof_dump_flush(propagate_err) &&
1740 propagate_err) {
1741 ret = true;
1742 goto label_return;
1743 }
1744 }
1745 nread = malloc_read_fd(mfd,
1746 &prof_dump_buf[prof_dump_buf_end], PROF_DUMP_BUFSIZE
1747 - prof_dump_buf_end);
1748 } while (nread > 0);
1749 } else {
1750 ret = true;
1751 goto label_return;
1752 }
1753
1754 ret = false;
1755label_return:
1756 if (mfd != -1) {
1757 close(mfd);
1758 }
1759 return ret;
1760}
1761
1762/*
1763 * See prof_sample_threshold_update() comment for why the body of this function

Callers 1

prof_dump_fileFunction · 0.70

Calls 5

malloc_read_fdFunction · 0.85
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