On Thu, 22 Feb 2024 13:28:43 GMT, Magnus Ihse Bursie <i...@openjdk.org> wrote:

>> Your comment had me go and elfdump the entire libjvm.so and compare the 
>> entire output... :-) Now at least I understand why there were so many 
>> spurious changes in the linux binary -- the old symbols were named e.g. 
>> `JVM_MonitorWait@@SUNWprivate_1.1` while the new one are just named 
>> `JVM_MonitorWait`. This caused the segment to be shorter, and this in turned 
>> offsetted all following position, so the change cascaded down.
>
> 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.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17955#discussion_r1499294627

Reply via email to