RFR (S) 8217994: os::print_hex_dump should be more resilient against unreadable memory

Schmidt, Lutz lutz.schmidt at sap.com
Wed Jan 30 11:35:05 UTC 2019


OK, my fault. 
Didn't RTFM before typing. How about this version:

  st->print("%*.*s", 2*unitsize, 2*unitsize, "????????????????");

For strings, the .precision sub-specifier serves as "max. #characters to be printed". 
(see http://www.cplusplus.com/reference/cstdio/printf/) 

Regards, Lutz

On 30.01.19, 12:02, "Aleksey Shipilev" <shade at redhat.com> wrote:

    On 1/30/19 11:48 AM, Schmidt, Lutz wrote:
    > When looking at the newly introduced else branch, I had the idea of replacing the entire switch by
    > 
    >   st->print("%*s", 2*unitsize, "????????????????");
    > 
    > Like it? I do!
    
    That's a cute trick, but I don't think it works: the format width is the _minimal_ width, and the
    that 16-wide string argument would not be truncated to 2*unitsize.
    
    -Aleksey
    
    



More information about the hotspot-dev mailing list