diff -r f5480f924571 -r 556122252316 test/hotspot/gtest/runtime/test_os.cpp --- a/test/hotspot/gtest/runtime/test_os.cpp Wed Jan 30 18:21:06 2019 +0000 +++ b/test/hotspot/gtest/runtime/test_os.cpp Wed Jan 30 19:45:10 2019 +0100 @@ -153,6 +153,30 @@ } #endif +TEST(os, test_print_hex_dump) { + ResourceMark rm; + stringStream ss; + outputStream* out = &ss; +// outputStream* out = tty; // enable for printout + + // Test dumping unreadable memory does not fail + os::print_hex_dump(out, (address)0, (address)100, 1); + os::print_hex_dump(out, (address)0, (address)100, 2); + os::print_hex_dump(out, (address)0, (address)100, 4); + os::print_hex_dump(out, (address)0, (address)100, 8); + + // Test dumping readable memory does not fail + char arr[100]; + for (int c = 0; c < 100; c++) { + arr[c] = c; + } + address addr = (address)&arr; + os::print_hex_dump(out, addr, addr + 100, 1); + os::print_hex_dump(out, addr, addr + 100, 2); + os::print_hex_dump(out, addr, addr + 100, 4); + os::print_hex_dump(out, addr, addr + 100, 8); +} + ////////////////////////////////////////////////////////////////////////////// // Test os::vsnprintf and friends.