RFR: 8354920: SA core file support on Linux only prints error messages when debug logging is enabled [v2]
Daniel Jeliński
djelinski at openjdk.org
Tue Apr 22 16:36:43 UTC 2025
On Tue, 22 Apr 2025 09:47:02 GMT, Kevin Walls <kevinw at openjdk.org> wrote:
>> src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c line 450:
>>
>>> 448: if ( (ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle))) == NULL) {
>>> 449: snprintf(err_buf, err_buf_len, "can't allocate memory for ps_prochandle");
>>> 450: print_error("%s\n", err_buf);
>>
>> This might be one that would print it twice - the caller in LinuxDebuggerLocal.cpp will print what's in err_buf.
>
> Looks like here in Pgrab the intent is to snprintf an error message in err_buf, and the caller prints it. So Pgrab should not need the print_error calls.
>
> Some functions which are called, like read_lib_info, may print their own specific error message, then Pgrab stores an error that "failed to read lib info".. These are reporting the same thing but I don't see that as a problem or duplication, it could be really useful to track where things fail.
>
> Yes it's a little annoying that Pgrab_core is different, it doesn't take an error_buf so needs to print_error about any problems.
ah, interesting. The native caller doesn't print the error message, it throws a Java exception with the message in the exception string, and the Java code then deals with the exception.
This is different on MacOS, where the error message is printed, and then an exception with a generic message is thrown. I haven't checked what the Windows implementation does here.
The Linux implementation with dynamic exception messages was introduced in 57d8a71115b8fc9a2eb2be876a396c474c207cf3.
I'll modify the Linux Pgrab to report all errors through the exception message, and remove print_error from Pgrab.
Should I additionally modify the MacOS's Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__I to report all errors through the exception message and remove print_error, or is it OK if the implementations behave differently?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24722#discussion_r2054467779
More information about the serviceability-dev
mailing list