Skip to content

Commit a2c629a

Browse files
image base
1 parent 17970c0 commit a2c629a

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/symbols_macos.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class MachOParser {
7474
const char* name = str_table + sym->n_un.n_strx;
7575
if (name[0] == '_') name++;
7676
_cc->add(addr, 0, name);
77+
if (strstr(_cc->name(), "libsystem_m.dylib") || strstr(_cc->name(), "libjninativestacks.dylib")) {
78+
fprintf(stderr, "%s ==> %s => %p\n", _cc->name(), name, (void*)sym->n_value);
79+
}
7780
debug_symbols = true;
7881
}
7982
sym++;
@@ -99,6 +102,10 @@ class MachOParser {
99102
char stub_name[256];
100103
snprintf(stub_name, sizeof(stub_name), "stub:%s", name);
101104
_cc->add(stubs_start + i * stubs_section->reserved2, stubs_section->reserved2, stub_name);
105+
106+
if (strstr(_cc->name(), "libsystem_m.dylib") || strstr(_cc->name(), "libjninativestacks.dylib")) {
107+
fprintf(stderr, "%s(stubs) ==> %s => %p\n", _cc->name(), name, (void*)(stubs_section->addr + i * stubs_section->reserved2));
108+
}
102109
}
103110
}
104111

@@ -159,9 +166,16 @@ class MachOParser {
159166
memcpy(&unwind_table[i + base_index], &FrameDesc::default_frame, sizeof(FrameDesc));
160167
unwind_table[i + base_index].loc = *pages;
161168

169+
if (strstr(_cc->name(), "libsystem_m.dylib") || strstr(_cc->name(), "libjninativestacks.dylib")) {
170+
fprintf(stderr, "%s ==> PAGE = %d, location = 0x%x\n", _cc->name(), i, *pages);
171+
}
172+
162173
pages++; // address
163174
pages++; // second_level_page_offset
164175
pages++; // lsda_index_offset
176+
} // 0x18e62df80
177+
if (strstr(_cc->name(), "libsystem_m.dylib") || strstr(_cc->name(), "libjninativestacks.dylib")) {
178+
fprintf(stderr, "%s ==> PAGE = %d, location = 0x%x\n", _cc->name(), pages_len - 1, *pages);
165179
}
166180
unwind_table[pages_len + base_index - 1].loc = *pages; // set information of last unwinding
167181

@@ -194,7 +208,6 @@ class MachOParser {
194208
_cc->updateBounds(_image_base, add(_image_base, sc->vmsize));
195209
stubs_section = findSection(sc, "__stubs");
196210
unwind_info_section = findSection(sc, "__unwind_info");
197-
_cc->setTextBase(sc->vmaddr + _vmaddr_slide);
198211
} else if (strcmp(sc->segname, "__LINKEDIT") == 0) {
199212
link_base = _vmaddr_slide + sc->vmaddr - sc->fileoff;
200213
} else if (strcmp(sc->segname, "__DATA") == 0 || strcmp(sc->segname, "__DATA_CONST") == 0) {
@@ -258,6 +271,11 @@ void Symbols::parseLibraries(CodeCacheArray* array, bool kernel_symbols) {
258271
const char* vmaddr_slide = (const char*)_dyld_get_image_vmaddr_slide(i);
259272

260273
CodeCache* cc = new CodeCache(path, count);
274+
cc->setTextBase((const char*)image_base);
275+
276+
if (strstr(path, "libsystem_m.dylib") || strstr(path, "libjninativestacks.dylib")){
277+
fprintf(stderr, "SLIDE (%s) = %p, BASE = %p\n", path, (void*)vmaddr_slide, (void*)image_base);
278+
}
261279

262280
UnloadProtection handle(cc);
263281
if (handle.isValid()) {

test/test/stackwalker/StackwalkerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void normalStackVMX(TestProcess p) throws Exception {
7272
}
7373

7474
@Test(mainClass = StackGenerator.class, jvmArgs = "-Xss5m", args = "leafFrame",
75-
agentArgs = "start,event=cpu,cstack=vm,file=%f.jfr")
75+
agentArgs = "start,event=cpu,cstack=vm,file=%f.jfr,features=pcaddr")
7676
public void normalStackVM(TestProcess p) throws Exception {
7777
p.waitForExit();
7878
assert p.exitCode() == 0;

0 commit comments

Comments
 (0)