On Tue, 20 Aug 2024 07:14:18 GMT, Thomas Stuefe <[email protected]> wrote:
>> src/hotspot/os/windows/memMapPrinter_windows.cpp line 98:
>>
>>> 96: buffer[idx++] = 'n';
>>> 97: } else if (prot != 0) {
>>> 98: snprintf(buffer, bufsiz, "(0x%x)", prot);
>>
>> This could truncate for the longest possible value (16+4 chars).
>
> But (here and in other places) raw-printing the unknown constant may not be
> the best way. Chances are this code is executed rarely and most people will
> just be perplexed at the weird printouts.
>
> We could assert here: After all, we expect to handle all possible values; if
> we see an unknown constant, then we either have a bug in the code and what we
> read here is no protection value, or Microsoft added new constants. In both
> cases, a code fix is needed. Asserts would fire up in automatic regression
> tests.
>
> The alternative is to print an '?'. And possibly scan for that in regression
> tests too.
>
> I leave this decision up to you.
I now handle less cases but will assert() if unimplemented bits are
encountered. I have currently only implemented this for protection bits, but
I'm still thinking what's best and intent to handle unknown cases identically
for the other two functions.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20597#discussion_r1727467806