@@ -628,7 +628,7 @@ def do_classdesc(self, parent=None, ident=0):
628628 clazz .serialVersionUID = serialVersionUID
629629 clazz .flags = classDescFlags
630630
631- self ._add_reference (clazz )
631+ self ._add_reference (clazz , ident )
632632
633633 log_debug ("Serial: 0x{0:X} / {0:d} - classDescFlags: 0x{1:X} {2}"
634634 .format (serialVersionUID , classDescFlags ,
@@ -643,23 +643,27 @@ def do_classdesc(self, parent=None, ident=0):
643643 field_name = self ._readString ()
644644 field_type = self ._convert_char_to_type (typecode )
645645
646+ log_debug ("> Reading field {0}" .format (field_name ), ident )
647+
646648 if field_type == self .TYPE_ARRAY :
647649 _ , field_type = self ._read_and_exec_opcode (
648650 ident = ident + 1 ,
649651 expect = (self .TC_STRING , self .TC_REFERENCE ))
650- assert type (field_type ) is JavaString
651- # if field_type is not None:
652- # field_type = "array of " + field_type
653- # else:
654- # field_type = "array of None"
652+
653+ if type (field_type ) is not JavaString :
654+ raise AssertionError ("Field type must be a JavaString, "
655+ "not {0}" .format (type (field_type )))
655656
656657 elif field_type == self .TYPE_OBJECT :
657658 _ , field_type = self ._read_and_exec_opcode (
658659 ident = ident + 1 ,
659660 expect = (self .TC_STRING , self .TC_REFERENCE ))
660- assert type (field_type ) is JavaString
661661
662- log_debug ("FieldName: 0x{0:X} Name:{1} Type:{2} ID:{3}"
662+ if type (field_type ) is not JavaString :
663+ raise AssertionError ("Field type must be a JavaString, "
664+ "not {0}" .format (type (field_type )))
665+
666+ log_debug ("< FieldName: 0x{0:X} Name:{1} Type:{2} ID:{3}"
663667 .format (typecode , field_name , field_type , fieldId ),
664668 ident )
665669 assert field_name is not None
@@ -674,15 +678,18 @@ def do_classdesc(self, parent=None, ident=0):
674678
675679 # classAnnotation
676680 (opid ,) = self ._readStruct (">B" )
677- log_debug ("OpCode: 0x{0:X}" .format (opid ), ident )
681+ log_debug ("OpCode: 0x{0:X} -- {1} (classAnnotation)"
682+ .format (opid , OpCodeDebug .op_id (opid )), ident )
678683 if opid != self .TC_ENDBLOCKDATA :
679684 raise NotImplementedError ("classAnnotation isn't implemented yet" )
680685
681686 # superClassDesc
687+ log_debug ("Reading Super Class of {0}" .format (clazz .name ), ident )
682688 _ , superclassdesc = self ._read_and_exec_opcode (
683689 ident = ident + 1 ,
684690 expect = (self .TC_CLASSDESC , self .TC_NULL , self .TC_REFERENCE ))
685- log_debug (str (superclassdesc ), ident )
691+ log_debug ("Super Class for {0}: {1}"
692+ .format (clazz .name , str (superclassdesc )), ident )
686693 clazz .superclass = superclassdesc
687694 return clazz
688695
@@ -782,10 +789,15 @@ def do_object(self, parent=None, ident=0):
782789 tempclass = classdesc
783790 megalist = []
784791 megatypes = []
792+ log_debug ("Constructing class..." , ident )
785793 while tempclass :
786- log_debug (">>> {0} {1}"
787- .format (tempclass .fields_names , tempclass ), ident )
788- log_debug (">>> {0}" .format (tempclass .fields_types ), ident )
794+ log_debug ("Class: {0}" .format (tempclass .name ), ident + 1 )
795+ class_fields_str = ' - ' .join (
796+ ' ' .join ((field_type , field_name ))
797+ for field_type , field_name
798+ in zip (tempclass .fields_types , tempclass .fields_names ))
799+ if class_fields_str :
800+ log_debug (class_fields_str , ident + 2 )
789801
790802 fieldscopy = tempclass .fields_names [:]
791803 fieldscopy .extend (megalist )
@@ -802,6 +814,8 @@ def do_object(self, parent=None, ident=0):
802814 log_debug ("Prepared list of types: {0}" .format (megatypes ), ident )
803815
804816 for field_name , field_type in zip (megalist , megatypes ):
817+ log_debug ("Reading field: {0} - {1}"
818+ .format (field_type , field_name ))
805819 res = self ._read_value (field_type , ident , name = field_name )
806820 java_object .__setattr__ (field_name , res )
807821
@@ -909,12 +923,12 @@ def do_reference(self, parent=None, ident=0):
909923
910924 :param parent:
911925 :param ident: Log indentation level
912- :return:
926+ :return: The referenced object
913927 """
914928 (handle ,) = self ._readStruct (">L" )
915929 log_debug ("## Reference handle: 0x{0:X}" .format (handle ), ident )
916930 ref = self .references [handle - self .BASE_REFERENCE_IDX ]
917- log_debug ("Reference: %s" % ref )
931+ log_debug ("###-> Type: {0} - Value: {1}" . format ( type ( ref ), ref ), ident )
918932 return ref
919933
920934 @staticmethod
@@ -1037,9 +1051,9 @@ def _add_reference(self, obj, ident=0):
10371051 :param obj: Reference to add
10381052 :param ident: Log indentation level
10391053 """
1040- log_debug ("## New reference handle 0x{0:X}"
1041- .format (len (self .references ) + self .BASE_REFERENCE_IDX ) ,
1042- ident )
1054+ log_debug ("## New reference handle 0x{0:X}: {1} -> {2} "
1055+ .format (len (self .references ) + self .BASE_REFERENCE_IDX ,
1056+ type ( obj ). __name__ , obj ), ident )
10431057 self .references .append (obj )
10441058
10451059 def _oops_dump_state (self , ignore_remaining_data = False ):
0 commit comments