changeset 54:870312703ba1

Fix issuge of crossing dexfile.ref when updating offset
author Thinker K.F. Li <thinker@codemud.net>
date Thu, 23 Jun 2011 09:32:51 +0800
parents 705356005362
children 6e4cf6905729
files paraspace/dex_deptracker.py paraspace/dexfile.py
diffstat 2 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/paraspace/dex_deptracker.py	Wed Jun 22 20:22:03 2011 +0800
+++ b/paraspace/dex_deptracker.py	Thu Jun 23 09:32:51 2011 +0800
@@ -34,7 +34,11 @@
             obj = obj.child_type
             continue
 
-        obj = getattr(parent, name)
+        try:
+            obj = getattr(parent, name)
+        except:
+            print obj, parent, name_path
+            raise
         pass
     return obj, parent
 
@@ -760,13 +764,25 @@
         obj, path_parts = queue.pop()
         name_path = '.'.join(path_parts)
         
+        obj_clazz = _resolve_name_path(name_path)
+        if isinstance(obj_clazz, dexfile.depend):
+            continue
+        
         if name_path in depon_dep_map:
             marker, dummy = _resolve_name_path(name_path)
+            while isinstance(marker, dexfile.ref):
+                marker, dummy = _resolve_name_path(marker.target_path)
+                try:
+                    obj = obj[0]
+                except:
+                    print name_path
+                    raise
+                pass
             marker.set_marker(obj, moff())
             pass
 
         if isinstance(obj, (tuple, list)):
-            attrs = [(elt, path_parts + [str(idx)])
+            attrs = [(elt, make_path(elt, path_parts, str(idx)))
                      for idx, elt in enumerate(obj)]
             attrs.reverse()
             queue = queue + attrs
--- a/paraspace/dexfile.py	Wed Jun 22 20:22:03 2011 +0800
+++ b/paraspace/dexfile.py	Thu Jun 23 09:32:51 2011 +0800
@@ -991,11 +991,11 @@
 class _DEX_Try(composite):
     startAddr = uint32
     insnCount = uint16
+    catch_ref = ref('_DEX_Catch')
     handlerOff = depend_off_rel('_DEX_Code.handlers_size',
                                 '_DEX_Try.catch_ref')(uint16)
-    catch_ref = ref('_DEX_Catch')
 
-    child_names = 'startAddr insnCount handlerOff catch_ref'.split()
+    child_names = 'startAddr insnCount catch_ref handlerOff'.split()
     pass