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

Zhengyu Gu zgu at openjdk.org
Thu Jan 30 14:30:48 UTC 2025


On Thu, 30 Jan 2025 14:27:44 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:

> 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.

I use `NativeCallStack` for debugging purpose a lot,  `print_on()` method is very handy.

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

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


More information about the hotspot-dev mailing list