Skip to content

Commit 0db6231

Browse files
fbredbercoleenp
authored andcommitted
8314508: Improve how relativized pointers are printed by frame::describe
Reviewed-by: coleenp, pchilanomate
1 parent 0353245 commit 0db6231

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/hotspot/share/runtime/frame.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* 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
16201620
intptr_t* max = MAX2(v0, v1);
16211621
intptr_t* cur = max;
16221622
intptr_t* last = nullptr;
1623+
intptr_t* fp = nullptr;
16231624
for (int i = max_index; i >= min_index; i--) {
16241625
FrameValue fv = _values.at(i);
16251626
while (cur > fv.location) {
@@ -1630,7 +1631,20 @@ void FrameValues::print_on(outputStream* st, int min_index, int max_index, intpt
16301631
const char* spacer = " " LP64_ONLY(" ");
16311632
st->print_cr(" %s %s %s", spacer, spacer, fv.description);
16321633
} else {
1634+
if (*fv.description == '#' && isdigit(fv.description[1])) {
1635+
// The fv.description string starting with a '#' is the line for the
1636+
// saved frame pointer eg. "#10 method java.lang.invoke.LambdaForm..."
1637+
// basicaly means frame 10.
1638+
fp = fv.location;
1639+
}
1640+
// To print a fp-relative value:
1641+
// 1. The content of *fv.location must be such that we think it's a
1642+
// fp-relative number, i.e [-100..100].
1643+
// 2. We must have found the frame pointer.
1644+
// 3. The line can not be the line for the saved frame pointer.
1645+
// 4. Recognize it as being part of the "fixed frame".
16331646
if (*fv.location != 0 && *fv.location > -100 && *fv.location < 100
1647+
&& fp != nullptr && *fv.description != '#'
16341648
#if !defined(PPC64)
16351649
&& (strncmp(fv.description, "interpreter_frame_", 18) == 0 || strstr(fv.description, " method "))
16361650
#else // !defined(PPC64)
@@ -1639,7 +1653,8 @@ void FrameValues::print_on(outputStream* st, int min_index, int max_index, intpt
16391653
strcmp(fv.description, "locals") == 0 || strstr(fv.description, " method "))
16401654
#endif //!defined(PPC64)
16411655
) {
1642-
st->print_cr(" " INTPTR_FORMAT ": %18d %s", p2i(fv.location), (int)*fv.location, fv.description);
1656+
st->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %-32s (relativized: fp%+d)",
1657+
p2i(fv.location), p2i(&fp[*fv.location]), fv.description, (int)*fv.location);
16431658
} else {
16441659
st->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", p2i(fv.location), *fv.location, fv.description);
16451660
}

0 commit comments

Comments
 (0)