summaryrefslogtreecommitdiff
path: root/peek
diff options
context:
space:
mode:
Diffstat (limited to 'peek')
-rwxr-xr-xpeek31
1 files changed, 31 insertions, 0 deletions
diff --git a/peek b/peek
new file mode 100755
index 0000000000..057c897e6e
--- /dev/null
+++ b/peek
@@ -0,0 +1,31 @@
+#!./perl
+
+sub peekstr {
+ local ($addr, $len) = @_;
+ local ($mem) = unpack("P$len", pack("L",$addr+0));
+ $mem;
+}
+
+sub unpackmem {
+ local ($addr, $len, $template) = @_;
+ local $mem = peekstr($addr, $len);
+ unpack($template, $mem);
+}
+
+$foo = "stuff";
+
+($any, $refcnt, $type, $flags, $storage, $private) =
+ unpackmem(\$foo, 12, "L2 C4");
+
+printf "SV = any %lx refcnt %d type %d flags %x storage '%c' private %x\n",
+ $any, $refcnt, $type, $flags, $storage, $private;
+
+if ($type >= 4) {
+ ($pv, $cur, $len) = unpackmem($any, 12, "L3");
+
+ printf "XPV = pv %lx cur %d len %d\n", $pv,$cur,$len;
+
+ $string = peekstr($pv, $cur);
+
+ print "String = $string\n"
+}