Reviewers: bak,

Description:
Parse /proc/self/maps lines better to handle variations between Linux
kernels.
It seems noone has had time to file a bug on this.

Please review this at http://codereview.chromium.org/4210

Affected files:
   M     src/platform-linux.cc


Index: src/platform-linux.cc
===================================================================
--- src/platform-linux.cc       (revision 323)
+++ src/platform-linux.cc       (working copy)
@@ -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 @@
        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



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to