RFR: 8349003: NativeCallStack::print_on() output is unreadable

Thomas Stuefe stuefe at openjdk.org
Thu Jan 30 14:15:33 UTC 2025


On Wed, 29 Jan 2025 22:00:08 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:

> Please review this trivial change that improves output readability.

Ah, now I remember.

I introduced the `NativeCallStackPrinter` for when you need to print many stacks (e.g. in NMT reporting) and want to have source output. Since reading ELF files is costly and can significantly slow down printing, I now cache retrieved source information by PC. That cache needs a lifetime, hence the `NativeCallStackPrinter`. The CR was removed from `NativeCallStack::print_frame`, since in case of the `NativeCallStackPrinter`, the text may be succeeded by source file info that has to appear on the same line.

So we have two call chains: 
1 `NativeCallStackPrinter::print_stack()` -> `NativeCallStack::print_frame()`, after which source file info is printed, after which CR is added
2 `NativeCallStack::print_stack()` -> `NativeCallStack::print_frame()` which now misses the CR

I think the patch is okay. But I wonder whether we should use, up in the NMT reporter code, an instance of `NativeCallStackPrinter` instead. Since we do this many times and it may also benefit from sped-up source lookup.

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

PR Comment: https://git.openjdk.org/jdk/pull/23359#issuecomment-2624625670


More information about the hotspot-dev mailing list