Parse /proc/self/maps lines better to handle variations between Linux kernels.

It seems noone has had time to file a bug on this.
Review URL: http://codereview.chromium.org/4210

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@360 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
erik.corry@gmail.com 2008-09-23 08:56:12 +00:00
parent 9d30045d06
commit a9e4a68ef2

View File

@ -38,11 +38,12 @@
// executable. Otherwise, OS raises an exception when executing code
// in that page.
#include <sys/types.h> // mmap & munmap
#include <sys/mman.h> // mmap & munmap
#include <sys/stat.h> // open
#include <sys/mman.h> // mmap & munmap
#include <sys/stat.h> // open
#include <sys/fcntl.h> // open
#include <unistd.h> // getpagesize
#include <execinfo.h> // backtrace, backtrace_symbols
#include <unistd.h> // getpagesize
#include <execinfo.h> // backtrace, backtrace_symbols
#include <strings.h> // index
#include <errno.h>
#include <stdarg.h>
@ -335,12 +336,13 @@ void OS::LogSharedLibraryAddresses() {
if (result < 1) break;
} while (buffer[bytes_read] != '\n');
buffer[bytes_read] = 0;
// There are 56 chars to ignore at this point in the line.
if (bytes_read < 56) continue;
// Ignore mappings that are not executable.
if (buffer[3] != 'x') continue;
char* start_of_path = index(buffer, '/');
// There may be no filename in this line. Skip to next.
if (start_of_path == NULL) continue;
buffer[bytes_read] = 0;
LOG(SharedLibraryEvent(buffer + 56, start, end));
LOG(SharedLibraryEvent(start_of_path, start, end));
}
close(fd);
#endif