diff options
author | Jason Evans <jasone@canonware.com> | 2015-05-01 16:03:20 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2015-05-01 16:03:20 (GMT) |
commit | 8e33c21d2d03ee7f540e32c3d75b10c128eaea57 (patch) | |
tree | e3b6394f9e6c753fd6e84ca29909d2f8be7d3e4d /src/prof.c | |
parent | f1f2b4542902c5bc14788f6c2d4190b422e5901f (diff) | |
download | jemalloc-8e33c21d2d03ee7f540e32c3d75b10c128eaea57.zip jemalloc-8e33c21d2d03ee7f540e32c3d75b10c128eaea57.tar.gz jemalloc-8e33c21d2d03ee7f540e32c3d75b10c128eaea57.tar.bz2 |
Prefer /proc/<pid>/task/<pid>/maps over /proc/<pid>/maps on Linux.
This resolves #227.
Diffstat (limited to 'src/prof.c')
-rw-r--r-- | src/prof.c | 29 |
1 files changed, 24 insertions, 5 deletions
@@ -1338,21 +1338,40 @@ label_return: return (ret); } +JEMALLOC_ATTR(format(printf, 1, 2)) +static int +prof_open_maps(const char *format, ...) +{ + int mfd; + va_list ap; + char filename[PATH_MAX + 1]; + + va_start(ap, format); + malloc_vsnprintf(filename, sizeof(filename), format, ap); + va_end(ap); + mfd = open(filename, O_RDONLY); + + return (mfd); +} + static bool prof_dump_maps(bool propagate_err) { bool ret; int mfd; - char filename[PATH_MAX + 1]; cassert(config_prof); #ifdef __FreeBSD__ - malloc_snprintf(filename, sizeof(filename), "/proc/curproc/map"); + mfd = prof_open_maps("/proc/curproc/map"); #else - malloc_snprintf(filename, sizeof(filename), "/proc/%d/maps", - (int)getpid()); + { + int pid = getpid(); + + mfd = prof_open_maps("/proc/%d/task/%d/maps", pid, pid); + if (mfd == -1) + mfd = prof_open_maps("/proc/%d/maps", pid); + } #endif - mfd = open(filename, O_RDONLY); if (mfd != -1) { ssize_t nread; |