RFR: 8311542: Consolidate the native stack printing code
David Holmes
dholmes at openjdk.org
Fri Dec 6 13:15:39 UTC 2024
On Fri, 6 Dec 2024 10:52:48 GMT, Fredrik Bredberg <fbredberg at openjdk.org> wrote:
>> We now print native stacks in a number of contexts, not just VMError reporting, and we have to try `os::platform_print_native_stack` else fall back to `VMError::print_native stack`.
>>
>> The refactoring adds a new `NativeStackPrinter` (NSP) helper class which can be constructed with some of the context information for the printing that will follow. This avoids the need for the print functions to have a large number of parameters. We have to expose both the top-level printing functionality and the "lower-level" frame-based stack walk as the error reporter needs access to that directly. To maintain the exact same format of output the NSP has to be aware of some error reporter usage requirements.
>>
>> I also had to expose a direct `frame` taking print function for the Debug.cpp `pns` case.
>>
>> Testing:
>> - tiers 1 - 4
>>
>> Some frame management code was also moved from `VMError` to the `frame` class.
>
> src/hotspot/share/runtime/frame.cpp line 1566:
>
>> 1564: * @returns an invalid frame (i.e. fr.pc() === 0) if the caller cannot be obtained
>> 1565: */
>> 1566: frame frame::next_frame(frame fr, Thread* t) {
>
> I think `next_frame` is a bit ambiguous, like are we talking next up, or next down the stack?
> I'm no fan of the Smalltalkish sender notation, so I don't want that. But since the comment says "gets the caller frame", why not call it `get_caller_frame`?
@fbredber thanks for looking at this. I'm not trying to change anything here, all I did was move the code from VMError into frame. Terminology gets complex with frames and we already have the notion of "sender" rather than caller in this code.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22472#discussion_r1873313979
More information about the hotspot-dev
mailing list