RFR: 8293422: DWARF emitted by Clang cannot be parsed [v2]

Christian Hagedorn chagedorn at openjdk.org
Wed Sep 21 13:20:56 UTC 2022


On Wed, 21 Sep 2022 10:34:07 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> Christian Hagedorn has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Change old bailout fix to only apply to Clang versions older than 5.0 and add new fix with -gdwarf-aranges + -gdwarf-4 for Clang 5.0+
>
> src/hotspot/share/utilities/elfFile.cpp line 1632:
> 
>> 1630: // example, for Clang debug builds which emit a relative path while GCC only emits the filename.
>> 1631: void DwarfFile::LineNumberProgram::strip_path_prefix(char* filename, const size_t filename_len) {
>> 1632:   char* last_slash = strrchr(filename, '/');
> 
> Maybe use `os::file_separator()` instead of `/` here.

Also corrected a second usage of `/` in the DWARF parser code.

> src/hotspot/share/utilities/elfFile.cpp line 1639:
> 
>> 1637:     assert(bytes_written > 0, "could not strip path prefix");
>> 1638:     // Add null terminator.
>> 1639:     jio_snprintf(filename + bytes_written, 1, "%s", '\0');
> 
> I think the correct format string is `%c` here. I also looked into other code that appends the `\0`, that one just pokes it in via direct assignment, but `snprintf` does not seem wrong.

Right, directly setting it is more straight forward.

> test/hotspot/gtest/runtime/test_os_linux.cpp line 462:
> 
>> 460:   // This gives us either "jni.cp" or "src/ho". In the latter case, we strip the path prefix to get to the actual
>> 461:   // filename which, however, is useless in this case - we get "ho".
>> 462:   ASSERT_TRUE(strcmp(buf, "jni.cp") == 0 || strcmp(buf, "ho") == 0);
> 
> I did not try it out, but since we already stripped the prefix before printing the file name, why can we get "ho" here?

I updated the comment to make it more clear. Due to the small buffer, we only read "src/ho" instead of "src/hotspot/share...". And since we are also calling `strip_path_prefix`, we strip "src/" and we get "ho" as filename which is not actually a filename.

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

PR: https://git.openjdk.org/jdk/pull/10287


More information about the hotspot-dev mailing list