MCPcopy Index your code
hub / github.com/java-native-access/jna / dump

Method dump

src/com/sun/jna/Pointer.java:1159–1181  ·  view source on GitHub ↗

Dump memory for debugging purposes.

(long offset, int size)

Source from the content-addressed store, hash-verified

1157
1158 /** Dump memory for debugging purposes. */
1159 public String dump(long offset, int size) {
1160 final int BYTES_PER_ROW = 4;
1161 final String TITLE = "memory dump";
1162 // estimate initial size assuming a 2 char line separator
1163 StringWriter sw = new StringWriter(TITLE.length() + 2 + size * 2 + (size / BYTES_PER_ROW * 4));
1164 PrintWriter out = new PrintWriter(sw);
1165 out.println(TITLE);
1166// byte[] buf = getByteArray(offset, size);
1167 for (int i=0;i < size;i++) {
1168// byte b = buf[i];
1169 byte b = getByte(offset + i);
1170 if ((i % BYTES_PER_ROW) == 0) out.print("[");
1171 if (b >=0 && b < 16)
1172 out.print("0");
1173 out.print(Integer.toHexString(b & 0xFF));
1174 if ((i % BYTES_PER_ROW) == BYTES_PER_ROW-1 && i < size-1)
1175 out.println("]");
1176 }
1177 if (sw.getBuffer().charAt(sw.getBuffer().length() - 2) != ']') {
1178 out.println("]");
1179 }
1180 return sw.toString();
1181 }
1182
1183 @Override
1184 public String toString() {

Callers

nothing calls this directly

Calls 5

getByteMethod · 0.95
getBufferMethod · 0.80
lengthMethod · 0.45
charAtMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected