RFR: 8268425: Show decimal nid of OSThread instead of hex format one [v2]
David Holmes
david.holmes at oracle.com
Mon Jun 28 12:37:57 UTC 2021
On 28/06/2021 6:49 pm, Thomas Stuefe wrote:
> On Mon, 28 Jun 2021 07:37:10 GMT, Yi Yang <yyang at openjdk.org> wrote:
>
>>> src/hotspot/share/runtime/osThread.cpp line 41:
>>>
>>>> 39: // Printing
>>>> 40: void OSThread::print_on(outputStream *st) const {
>>>> 41: st->print("nid=%d ", thread_id());
>>>
>>> thread_id is of an opaque type (eg pthread_t). I think we can reasonably assume its numeric, but I would print it as an unsigned 64bit int just in case.
>>
>> Hi Thomas, we can not use other format specifiers (`%ld`,`%llu`) after my practice, because it can not compile on my mac:
>
> You'd do:
>
> print("nid: " UINT64_FORMAT, (uint64_t) id):;
>
> thread_t is, among other things, pthread_t, which is opaque. Any current code treating that as signed int is incorrect too.
If it is opaque then I don't see how signed or unsigned makes any
difference. You are assuming it can just be treated as a 64-bit value;
whether you interpret that as a signed or unsigned value just changes
how you print it. I agree printing only positive values is nicer visually.
David
> -------------
>
> PR: https://git.openjdk.java.net/jdk/pull/4449
>
More information about the serviceability-dev
mailing list