summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/cli_pickle.cpp2
-rw-r--r--cli/pickle.hpp10
-rwxr-xr-xscripts/unpickle.py17
3 files changed, 27 insertions, 2 deletions
diff --git a/cli/cli_pickle.cpp b/cli/cli_pickle.cpp
index 761f3118..8ea507be 100644
--- a/cli/cli_pickle.cpp
+++ b/cli/cli_pickle.cpp
@@ -152,7 +152,7 @@ public:
}
void visit(Pointer *node) {
- writer.writeInt(node->value);
+ writer.writePointer(node->value);
}
void visit(Repr *r) {
diff --git a/cli/pickle.hpp b/cli/pickle.hpp
index aaecc188..35973ef5 100644
--- a/cli/pickle.hpp
+++ b/cli/pickle.hpp
@@ -296,6 +296,16 @@ public:
os.put(REDUCE);
}
+ inline void writePointer(unsigned long long addr) {
+ os.put(GLOBAL);
+ os << "unpickle\nPointer\n";
+ os.put(BINPUT);
+ os.put(1);
+ writeInt(addr);
+ os.put(TUPLE1);
+ os.put(REDUCE);
+ }
+
protected:
inline void putInt16(uint16_t i) {
os.put( i & 0xff);
diff --git a/scripts/unpickle.py b/scripts/unpickle.py
index 5fe40f59..1932497e 100755
--- a/scripts/unpickle.py
+++ b/scripts/unpickle.py
@@ -55,6 +55,17 @@ CALL_FLAG_MARKER_PUSH = (1 << 9)
CALL_FLAG_MARKER_POP = (1 << 10)
+class Pointer(int):
+
+ def __str__(self):
+ if self == 0:
+ return 'NULL'
+ else:
+ return hex(self)
+
+ __repr__ = __str__
+
+
class Visitor:
def __init__(self):
@@ -69,9 +80,10 @@ class Visitor:
self.dispatch[list] = self.visitList
self.dispatch[dict] = self.visitDict
self.dispatch[bytearray] = self.visitByteArray
+ self.dispatch[Pointer] = self.visitPointer
def visit(self, obj):
- method = self.dispatch.get(type(obj), self.visitObj)
+ method = self.dispatch.get(obj.__class__, self.visitObj)
return method(obj)
def visitObj(self, obj):
@@ -110,6 +122,9 @@ class Visitor:
def visitByteArray(self, obj):
raise NotImplementedError
+ def visitPointer(self, obj):
+ return self.visitAtom(obj)
+
class Dumper(Visitor):