On Mon, 27 Nov 2023 15:44:58 GMT, suchismith1993 <d...@openjdk.org> wrote:
> > > > i would have to repeat the line 1132 and 1139 in os_aix.cpp again , if > > > > the condition fails for .so files, because i have to reload it again > > > > and check if the .a exists. In the shared code i had repeat less number > > > > of lines i believe. Do you suggest moving lines 1132 to 1139 to another > > > > function then ? > > > > > > > > > @tstuefe Any suggestion on this ? > > > > > > ``` > > --- a/src/hotspot/os/aix/os_aix.cpp > > +++ b/src/hotspot/os/aix/os_aix.cpp > > @@ -1108,7 +1108,7 @@ bool os::dll_address_to_library_name(address addr, > > char* buf, > > return true; > > } > > > > -void *os::dll_load(const char *filename, char *ebuf, int ebuflen) { > > +static void* dll_load_inner(const char *filename, char *ebuf, int ebuflen) > > { > > > > log_info(os)("attempting shared library load of %s", filename); > > > > @@ -1158,6 +1158,35 @@ void *os::dll_load(const char *filename, char *ebuf, > > int ebuflen) { > > return nullptr; > > } > > > > +void* os::dll_load(const char *filename, char *ebuf, int ebuflen) { > > + > > + void* result = nullptr; > > + > > + // First try using *.so suffix; failing that, retry with *.a suffix. > > + const size_t len = strlen(filename); > > + constexpr size_t safety = 3 + 1; > > + constexpr size_t bufsize = len + safety; > > + char* buf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal); > > + strcpy(buf, filename); > > + char* const dot = strrchr(buf, '.'); > > + > > + assert(dot != nullptr, "Attempting to load a shared object without > > extension? %s", filename); > > + assert(strcmp(dot, ".a") == 0 || strcmp(dot, ".so") == 0, > > + "Attempting to load a shared object that is neither *.so nor *.a", > > filename); > > + > > + sprintf(dot, ".so"); > > + result = dll_load_inner(buf, ebuf, ebuflen); > > + > > + if (result == nullptr) { > > + sprintf(dot, ".a"); > > + result = dll_load_inner(buf, ebuf, ebuflen); > > + } > > + > > + FREE_C_HEAP_ARRAY(char, buf); > > + > > + return result; > > +} > > + > > ``` > > @tstuefe as discussed with @TheRealMDoerr do you think using default argument > will help ? Either we pass agent object as 3rd parameter or an empty > character buffer(and not const chat*) which would be spcifically used to copy > the alternate filename to it using strcpy so that it is reflected in the > jvmagent code ? A third parameter for what? ------------- PR Comment: https://git.openjdk.org/jdk/pull/16604#issuecomment-1829602040