RFR: 8333994: NMT: call stacks should show source information [v5]
Johan Sjölen
jsjolen at openjdk.org
Sun Jun 23 09:03:11 UTC 2024
On Sat, 22 Jun 2024 10:37:27 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> Patch adds printing of source file and line number to NMT call stacks that are printed in detail mode. Useful for hunting down leaks.
>
> Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:
>
> cleanups
Good job, I found some minor improvements to be had.
src/hotspot/share/nmt/nativeCallStackPrinter.cpp line 40:
> 38: for (int i = 0; i < NMT_TrackingStackDepth; i++) {
> 39: const address pc = stack->get_frame(i);
> 40: if (pc != nullptr) {
Style suggestion: Invert condition and `continue` instead, to reduce indentation of remaining code.
src/hotspot/share/nmt/nativeCallStackPrinter.cpp line 46:
> 44: stringStream ss(4 * K);
> 45: stack->print_frame(&ss, pc);
> 46: const size_t len = strlen(ss.base());
Just use `ss.size()`.
src/hotspot/share/nmt/nativeCallStackPrinter.cpp line 48:
> 46: const size_t len = strlen(ss.base());
> 47: char* store = NEW_ARENA_ARRAY(&_text_storage, char, len + 1);
> 48: strcpy(store, ss.base());
We have the sizes, use `memcpy`.
src/hotspot/share/nmt/nativeCallStackPrinter.cpp line 49:
> 47: char* store = NEW_ARENA_ARRAY(&_text_storage, char, len + 1);
> 48: strcpy(store, ss.base());
> 49: (*cached_frame_text) = store;
Redundant parens
-------------
PR Review: https://git.openjdk.org/jdk/pull/19655#pullrequestreview-2134220333
PR Review Comment: https://git.openjdk.org/jdk/pull/19655#discussion_r1650022361
PR Review Comment: https://git.openjdk.org/jdk/pull/19655#discussion_r1650022628
PR Review Comment: https://git.openjdk.org/jdk/pull/19655#discussion_r1650022710
PR Review Comment: https://git.openjdk.org/jdk/pull/19655#discussion_r1650022744
More information about the hotspot-dev
mailing list