mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-14 22:51:50 +03:00
Prefer /proc/<pid>/task/<pid>/maps over /proc/<pid>/maps on Linux.
This resolves #227.
This commit is contained in:
parent
f1f2b45429
commit
8e33c21d2d
1 changed files with 24 additions and 5 deletions
29
src/prof.c
29
src/prof.c
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue