comparison paraspace/dex_deptracker.py @ 124:8e42b2816893

Fixing compute_size() and sizeof() for DEX types. - Prevent compute_size() and sizeof() of depend_* to include size of depend-on.
author Thinker K.F. Li <thinker@codemud.net>
date Sun, 07 Aug 2011 22:07:08 +0800
parents 78357afb4a9d
children b9688a3badaa
comparison
equal deleted inserted replaced
123:78357afb4a9d 124:8e42b2816893
296 pass 296 pass
297 297
298 return all_dep_decls 298 return all_dep_decls
299 299
300 300
301 ## Mark where we need offset information for link dependencies.
302 #
301 class _marker(dexfile.null_relocatable): 303 class _marker(dexfile.null_relocatable):
302 back_type = None 304 back_type = None
303 305
304 def set_marker(self, obj, off): 306 def set_marker(self, obj, off):
305 raise NotImplementedError, \ 307 raise NotImplementedError, \
306 'The marker does not implement set_marker()' 308 'The marker does not implement set_marker()'
309
310 ## \brief Prepare data_offset for linking.
311 def link_prepare(self, obj, name_path, parents, markers_info):
312 raise NotImplementedError, \
313 '_marker should be used to instantiate an instance directly'
307 pass 314 pass
308 315
309 class _uid_marker(_marker): 316 class _uid_marker(_marker):
310 uid_seq = 0 317 uid_seq = 0
311 318
728 dep_type = dep[0] 735 dep_type = dep[0]
729 if dep_type == dexfile.depend_off_rel: 736 if dep_type == dexfile.depend_off_rel:
730 depon2 = _rel_offset_marker.find_depon(dep[2], parents) 737 depon2 = _rel_offset_marker.find_depon(dep[2], parents)
731 offset = depon2.data_offset + obj 738 offset = depon2.data_offset + obj
732 depon1 = markers_info[dep[1]][offset] 739 depon1 = markers_info[dep[1]][offset]
740 dep_type._depon2_log[depon1] = depon2
733 741
734 name = name_path.split('.')[-1] 742 name = name_path.split('.')[-1]
735 _dex_tree_set_child(imm_parent, name, depon1) 743 _dex_tree_set_child(imm_parent, name, depon1)
736 elif dep_type == dexfile.depend_off: 744 elif dep_type == dexfile.depend_off:
737 depon_name_path = dep[1] 745 depon_name_path = dep[1]
783 # 791 #
784 # \param dexroot is a linked (called build_dependencies()) \ref DEXFile. 792 # \param dexroot is a linked (called build_dependencies()) \ref DEXFile.
785 # \param all_dep_decls is a dictionary returned by prepare_dep_decls(). 793 # \param all_dep_decls is a dictionary returned by prepare_dep_decls().
786 # 794 #
787 def update_offset(dexroot, all_dep_decls): 795 def update_offset(dexroot, all_dep_decls):
788 from dexfile import man_off 796 from paraspace.dexfile import man_off
789 797
790 depon_dep_map = _build_depon_dep_map(all_dep_decls) 798 depon_dep_map = _build_depon_dep_map(all_dep_decls)
791 dex_type_names = _all_dex_type_to_names() 799 dex_type_names = _all_dex_type_to_names()
792 800
793 def make_path(obj, parent_path, obj_name): 801 def make_path(obj, parent_path, obj_name):
833 841
834 if isinstance(obj, dexfile.ref): 842 if isinstance(obj, dexfile.ref):
835 continue 843 continue
836 844
837 if not isinstance(obj, dexfile.relocatable): 845 if not isinstance(obj, dexfile.relocatable):
838 #if isinstance(obj_clazz, dexfile.auto_align): 846 if isinstance(obj_clazz, dexfile.auto_align):
839 # obj = obj_clazz.recompute_align(moff()) 847 obj = obj_clazz.recompute_align(moff())
840 # print '%s %x %d' % (name_path, moff(), obj) 848 name = name_path.split('.')[-1]
841 # name = name_path.split('.')[-1] 849 _dex_tree_set_child(parent, name, obj)
842 # _dex_tree_set_child(parent, name, obj) 850 pass
843 # pass
844 moff(obj_clazz.sizeof(obj)) 851 moff(obj_clazz.sizeof(obj))
845 continue 852 continue
846 853
847 children = obj.children() 854 children = obj.children()
848 attr_n_names = [(_dex_tree_get_child(obj, child_name), child_name) 855 attr_n_names = [(_dex_tree_get_child(obj, child_name), child_name)