On Fri, 6 Nov 2026 13:13:40 GMT, Yasumasa Suenaga <[email protected]> wrote:

>> Currently SA would find Build ID from `SHT_NOTE` to load debuginfo file. 
>> However it does not work in some case for example, ELF binaries which does 
>> not have `.note.gnu.build-id`section. I see this case in vDSO (vdso64.so) in 
>> Linux Kernel 7.2.15-300.fc45.x86_64. This file can be handled in 
>> `debuginfod-find` - it can identify Build ID, and can download appropriate 
>> debuginfo file, but SA cannot identify it.
>> 
>> It might not be a common case, but we can create such ELF binaries with 
>> `strip -R .note.gnu.build-id`, and it works. So it is better to support such 
>> binaries in SA. In this case, the Build ID note is accessible through a 
>> `PT_NOTE` program header, even though there is no corresponding 
>> `.note.gnu.build-id` section. This change makes SA scan the notes in 
>> `PT_NOTE` segments instead of relying on `SHT_NOTE` section headers to 
>> obtain the Build ID.
>> 
>> SA already supports debuginfo, but test code is not available. So this PR 
>> adds it.
>> We need to separate debuginfo from native library and strip it, so I 
>> modified related makefiles to do it in force. It works regardless of 
>> `--with-native-debug-symbols` configure option.
>> However we cannot test Build ID because the debuginfo depends on Build ID 
>> should be located at debug directory on host e.g. `/usr/lib/debug`. So the 
>> test introduced by this PR tests to load debug symbols from separated 
>> debuginfo file.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Yasumasa Suenaga has updated the pull request incrementally with four 
> additional commits since the last revision:
> 
>  - Remove blank line
>  - improvement
>  - Fix
>  - Exclude libDebuginfoTest.c from non-Linux platforms

src/jdk.hotspot.agent/linux/native/libsaproc/salibelf.c line 253:

> 251:       if (read(fd, buf, php->p_filesz) != php->p_filesz) {
> 252:         print_error("failed to read PT_NOTE data in %s\n", filename);
> 253:         break;

You should free buf first.

src/jdk.hotspot.agent/linux/native/libsaproc/salibelf.c line 275:

> 273:             print_error("failed to allocate memory for Build ID of 
> %s\n", filename);
> 274:           }
> 275:           loop_exit = true;

Setting loop_exit here does not break out of the inner loop. If another match 
is found on line 267, you will leak the previously malloc'd *buildid.

test/hotspot/jtreg/serviceability/sa/TestELFDebuginfo.java line 44:

> 42:  * @run driver TestELFDebuginfo
> 43:  */
> 44: public class TestELFDebuginfo {

This test needs comments describing its purpose,  and describing how it relies 
on the build changes you made to create a .debuginfo that is stripped of the 
.note.gnu.build-id section.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33764#discussion_r4520639505
PR Review Comment: https://git.openjdk.org/jdk/pull/33764#discussion_r4520631594
PR Review Comment: https://git.openjdk.org/jdk/pull/33764#discussion_r4520656716

Reply via email to