Enable profiling / leak detection in FreeBSD
* Assumes procfs is mounted at /proc, cf. <http://www.freebsd.org/doc/en/articles/linux-users/procfs.html>
This commit is contained in:
parent
9e20df163c
commit
bf543df20c
20
bin/pprof
20
bin/pprof
@ -4197,8 +4197,12 @@ sub FindLibrary {
|
|||||||
# For libc libraries, the copy in /usr/lib/debug contains debugging symbols
|
# For libc libraries, the copy in /usr/lib/debug contains debugging symbols
|
||||||
sub DebuggingLibrary {
|
sub DebuggingLibrary {
|
||||||
my $file = shift;
|
my $file = shift;
|
||||||
if ($file =~ m|^/| && -f "/usr/lib/debug$file") {
|
if ($file =~ m|^/|) {
|
||||||
|
if (-f "/usr/lib/debug$file") {
|
||||||
return "/usr/lib/debug$file";
|
return "/usr/lib/debug$file";
|
||||||
|
} elsif (-f "/usr/lib/debug$file.debug") {
|
||||||
|
return "/usr/lib/debug$file.debug";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -4360,6 +4364,19 @@ sub ParseLibraries {
|
|||||||
$finish = HexExtend($2);
|
$finish = HexExtend($2);
|
||||||
$offset = $zero_offset;
|
$offset = $zero_offset;
|
||||||
$lib = $3;
|
$lib = $3;
|
||||||
|
}
|
||||||
|
# FreeBSD 10.0 virtual memory map /proc/curproc/map as defined in
|
||||||
|
# function procfs_doprocmap (sys/fs/procfs/procfs_map.c)
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# 0x800600000 0x80061a000 26 0 0xfffff800035a0000 r-x 75 33 0x1004 COW NC vnode /libexec/ld-elf.s
|
||||||
|
# o.1 NCH -1
|
||||||
|
elsif ($l =~ /^(0x$h)\s(0x$h)\s\d+\s\d+\s0x$h\sr-x\s\d+\s\d+\s0x\d+\s(COW|NCO)\s(NC|NNC)\svnode\s(\S+\.so(\.\d+)*)/) {
|
||||||
|
$start = HexExtend($1);
|
||||||
|
$finish = HexExtend($2);
|
||||||
|
$offset = $zero_offset;
|
||||||
|
$lib = FindLibrary($5);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
@ -4382,6 +4399,7 @@ sub ParseLibraries {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($main::opt_debug) { printf STDERR "$start:$finish ($offset) $lib\n"; }
|
||||||
push(@{$result}, [$lib, $start, $finish, $offset]);
|
push(@{$result}, [$lib, $start, $finish, $offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,12 @@
|
|||||||
#include <unwind.h>
|
#include <unwind.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#define PROCESS_VMEM_MAP "/proc/curproc/map"
|
||||||
|
#else
|
||||||
|
#define PROCESS_VMEM_MAP "/proc/%d/maps"
|
||||||
|
#endif
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* Data. */
|
/* Data. */
|
||||||
|
|
||||||
@ -936,7 +942,7 @@ prof_dump_maps(bool propagate_err)
|
|||||||
|
|
||||||
cassert(config_prof);
|
cassert(config_prof);
|
||||||
|
|
||||||
malloc_snprintf(filename, sizeof(filename), "/proc/%d/maps",
|
malloc_snprintf(filename, sizeof(filename), PROCESS_VMEM_MAP,
|
||||||
(int)getpid());
|
(int)getpid());
|
||||||
mfd = open(filename, O_RDONLY);
|
mfd = open(filename, O_RDONLY);
|
||||||
if (mfd != -1) {
|
if (mfd != -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user