On Thu, 22 Feb 2024 14:05:28 GMT, Kevin Walls <kev...@openjdk.org> wrote:
>> Ok, I see now that there is indeed a slight difference. The debug.cpp >> symbols are present as local symbols in the .symtab, both before and after >> this patch. However, before this patch they had visibility DEFAULT and now >> they have visibility HIDDEN. I don't think this matters for anything except >> the linker, but I should probably verify that they are still correctly >> usable from gcc. >> >> I would appreciate it if someone could provide a step-by-step instruction on >> how to verify these functions on gdb (I haven't used it for 10-15 years so I >> apologize if I'm a bit rusty), or provide a pointer to where I can find such >> instructions. Is this supposed to work on core dumps, live attached >> processes or both? > > On a latest JDK build today, in Linux I can attach to a live process (not a > core dump): > gdb --pid PID > ..and type: > call universe() > (I think you need to switch to a JavaThread first) and see on the JVM's > output: > > "Executing universe" > Heap > garbage-first heap total reserved 30932992K, ...etc... > > > Removing JNIEXPORT here on Linux and rebuilding: still works. > > readelf shows: > existing build (using JNIEXPORT): > 32252: 0000000000698160 249 FUNC LOCAL DEFAULT 11 universe > > without JNIEXPORT: > 32252: 0000000000698160 249 FUNC LOCAL HIDDEN 11 universe > > So gdb on Linux can call a HIDDEN function, i.e. without the JNIEXPORT. It > seems happy either way, not affected by visibility. Windows: Attach Visual Studio, in the Immediate Window, type (funny VS syntax I do not claim to understand): {,,JVM}universe() ...and on the JVM's console window I see: "Executing universe" Heap garbage-first heap total reserved 8343552K,...etc... (It actually did nothing on the first invocation for me, I have typed it 5 times, only got 4 sets of output. But the symbol is working...) In that working (JNIEXPORT) case, the map file jdk/bin/server/jvm.dll.map shows: 0001:0027ff50 universe 0000000180280f50 f debug.obj (I do like that we call it jvm.dll.map now, not just "jvm.map"!) Test removing JNIEXPORT: Without JNIEXPORT, on Windows, the symbol universe is just not there. Nothing in the map file. In Visual Studio: {,,JVM}universe() identifier "universe" is undefined That confirms the expected Windows behaviour: we still need JNIEXPORT to make debug.cpp utils callable by a debugger. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/17955#discussion_r1499341256