RFR (S) 8217994: os::print_hex_dump should be more resilient against unreadable memory
Thomas Stüfe
thomas.stuefe at gmail.com
Wed Jan 30 12:10:08 UTC 2019
Or, since this thing keeps coming up, add a helper to outputStream:
+void outputStream::put(char ch, int repeat_count) {
+ for (int i = 0; i < repeat_count; i ++) {
+ put(ch);
+ }
+}
+
st->put('?', 2*unitsize);
..Thomas
On Wed, Jan 30, 2019 at 12:35 PM Schmidt, Lutz <lutz.schmidt at sap.com> wrote:
> 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