Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Unified Diff: src/platform-linux.cc

Issue 125183: Fix profiling for shared libraries on Linux loaded at negative addresses... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/log.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-linux.cc
===================================================================
--- src/platform-linux.cc (revision 2185)
+++ src/platform-linux.cc (working copy)
@@ -224,8 +224,8 @@
#ifdef ENABLE_LOGGING_AND_PROFILING
-static unsigned StringToLong(char* buffer) {
- return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT
+static uintptr_t StringToULong(char* buffer) {
+ return strtoul(buffer, NULL, 16); // NOLINT
}
#endif
@@ -242,13 +242,13 @@
addr_buffer[10] = 0;
int result = read(fd, addr_buffer + 2, 8);
if (result < 8) break;
- unsigned start = StringToLong(addr_buffer);
+ uintptr_t start = StringToULong(addr_buffer);
result = read(fd, addr_buffer + 2, 1);
if (result < 1) break;
if (addr_buffer[2] != '-') break;
result = read(fd, addr_buffer + 2, 8);
if (result < 8) break;
- unsigned end = StringToLong(addr_buffer);
+ uintptr_t end = StringToULong(addr_buffer);
char buffer[MAP_LENGTH];
int bytes_read = -1;
do {
@@ -262,10 +262,21 @@
// 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(start_of_path, start, end));
+ // If there is no filename for this line then log it as an anonymous
+ // mapping and use the address as its name.
+ if (start_of_path == NULL) {
+ // 40 is enough to print a 64 bit address range.
+ ASSERT(sizeof(buffer) > 40);
+ snprintf(buffer,
+ sizeof(buffer),
+ "%08" V8PRIxPTR "-%08" V8PRIxPTR,
+ start,
+ end);
+ LOG(SharedLibraryEvent(buffer, start, end));
+ } else {
+ buffer[bytes_read] = 0;
+ LOG(SharedLibraryEvent(start_of_path, start, end));
+ }
}
close(fd);
#endif
« no previous file with comments | « src/log.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698