From 0db62311980cd045e5a9e2c030b653aacf104825 Mon Sep 17 00:00:00 2001 From: Fredrik Bredberg Date: Wed, 13 Mar 2024 15:15:03 +0000 Subject: [PATCH] 8314508: Improve how relativized pointers are printed by frame::describe Reviewed-by: coleenp, pchilanomate --- src/hotspot/share/runtime/frame.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/runtime/frame.cpp b/src/hotspot/share/runtime/frame.cpp index c68180e105b..33abbd61694 100644 --- a/src/hotspot/share/runtime/frame.cpp +++ b/src/hotspot/share/runtime/frame.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1620,6 +1620,7 @@ void FrameValues::print_on(outputStream* st, int min_index, int max_index, intpt intptr_t* max = MAX2(v0, v1); intptr_t* cur = max; intptr_t* last = nullptr; + intptr_t* fp = nullptr; for (int i = max_index; i >= min_index; i--) { FrameValue fv = _values.at(i); while (cur > fv.location) { @@ -1630,7 +1631,20 @@ void FrameValues::print_on(outputStream* st, int min_index, int max_index, intpt const char* spacer = " " LP64_ONLY(" "); st->print_cr(" %s %s %s", spacer, spacer, fv.description); } else { + if (*fv.description == '#' && isdigit(fv.description[1])) { + // The fv.description string starting with a '#' is the line for the + // saved frame pointer eg. "#10 method java.lang.invoke.LambdaForm..." + // basicaly means frame 10. + fp = fv.location; + } + // To print a fp-relative value: + // 1. The content of *fv.location must be such that we think it's a + // fp-relative number, i.e [-100..100]. + // 2. We must have found the frame pointer. + // 3. The line can not be the line for the saved frame pointer. + // 4. Recognize it as being part of the "fixed frame". if (*fv.location != 0 && *fv.location > -100 && *fv.location < 100 + && fp != nullptr && *fv.description != '#' #if !defined(PPC64) && (strncmp(fv.description, "interpreter_frame_", 18) == 0 || strstr(fv.description, " method ")) #else // !defined(PPC64) @@ -1639,7 +1653,8 @@ void FrameValues::print_on(outputStream* st, int min_index, int max_index, intpt strcmp(fv.description, "locals") == 0 || strstr(fv.description, " method ")) #endif //!defined(PPC64) ) { - st->print_cr(" " INTPTR_FORMAT ": %18d %s", p2i(fv.location), (int)*fv.location, fv.description); + st->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %-32s (relativized: fp%+d)", + p2i(fv.location), p2i(&fp[*fv.location]), fv.description, (int)*fv.location); } else { st->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", p2i(fv.location), *fv.location, fv.description); }