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

Unified Diff: src/platform-macos.cc

Issue 155437: Implement shared libraries logging on Mac OS X, added required support in Tick Processor. (Closed)
Patch Set: Created 11 years, 5 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 | « no previous file | tools/mac-nm » ('j') | tools/mac-nm » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-macos.cc
diff --git a/src/platform-macos.cc b/src/platform-macos.cc
index 880931e048b3a9a8a417b6441fbadea6995d75cc..5e444b6ce465f526a080366faf64ef257fe02fde 100644
--- a/src/platform-macos.cc
+++ b/src/platform-macos.cc
@@ -32,6 +32,8 @@
#include <unistd.h>
#include <sys/mman.h>
#include <mach/mach_init.h>
+#include <mach-o/dyld.h>
+#include <mach-o/getsect.h>
#include <AvailabilityMacros.h>
@@ -205,7 +207,18 @@ PosixMemoryMappedFile::~PosixMemoryMappedFile() {
void OS::LogSharedLibraryAddresses() {
- // TODO(1233579): Implement.
+ unsigned int images_count = _dyld_image_count();
+ for (unsigned int i = 0; i < images_count; ++i) {
+ const mach_header *header = _dyld_get_image_header(i);
iposva 2009/07/13 20:18:21 The correct style is "mach_header* header".
Mikhail Naganov 2009/07/14 05:00:42 Done.
+ if (header == NULL) continue;
+ unsigned int size;
+ char *code_ptr;
iposva 2009/07/13 20:18:21 The correct style is "char* code_ptr". I also ass
Mikhail Naganov 2009/07/14 05:00:42 No, it's just a lack of attention. Fixed, thanks!
+ code_ptr = getsectdatafromheader(header, SEG_TEXT, SECT_TEXT, &size);
+ if (code_ptr == NULL) continue;
+ const uintptr_t slide = _dyld_get_image_vmaddr_slide(i);
+ const uintptr_t start = reinterpret_cast<uintptr_t>(code_ptr) + slide;
+ LOG(SharedLibraryEvent(_dyld_get_image_name(i), start, start + size));
+ }
}
« no previous file with comments | « no previous file | tools/mac-nm » ('j') | tools/mac-nm » ('J')

Powered by Google App Engine
This is Rietveld 408576698