Skip to content

Commit

Permalink
Fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Hagy committed Oct 28, 2015
1 parent d386f98 commit 2bfeab4
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions pyhprof/heap_blocks.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@

class BaseHeapDumpBlock(object):

def __init__(self, id):
self.id = id

class BaseOnlyIdHeapDumpBlock(BaseHeapDumpBlock):

class BaseOnlyIdHeapDumpBlock(BaseHeapDumpBlock):
@classmethod
def parse(cls, p):
return cls(p.read_id())

class BaseThreadHeapDumpBlock(BaseHeapDumpBlock):

class BaseThreadHeapDumpBlock(BaseHeapDumpBlock):
def __init__(self, id, thread_serial_number):
super(BaseThreadFrameHeadDumpBlock, self).__init__(id)
super(BaseThreadHeapDumpBlock, self).__init__(id)
self.thread_serial_number = thread_serial_number

@classmethod
def parse(cls, p):
return cls(p.read_id(), p.i4())

class BaseThreadFrameHeadDumpBlock(BaseThreadHeapDumpBlock):

class BaseThreadFrameHeadDumpBlock(BaseThreadHeapDumpBlock):
def __init__(self, id, thread_serial_number, frame_number):
super(BaseThreadFrameHeadDumpBlock, self).__init__(id, thread_serial_number)
self.frame_number = frame_number
Expand All @@ -30,12 +28,12 @@ def __init__(self, id, thread_serial_number, frame_number):
def parse(cls, p):
return cls(p.read_id(), p.i4(), p.i4())

class RootUnkown(BaseOnlyIdHeapDumpBlock):

class RootUnknown(BaseOnlyIdHeapDumpBlock):
pass

class RootJniGlobal(BaseHeapDumpBlock):

class RootJniGlobal(BaseHeapDumpBlock):
def __init__(self, id, jni_global_ref):
super(RootJniGlobal, self).__init__(id)
self.jni_global_ref = jni_global_ref
Expand All @@ -44,42 +42,42 @@ def __init__(self, id, jni_global_ref):
def prase(cls, p):
return cls(p.read_id(), p.read_id())

class RootJniLocal(BaseThreadFrameHeadDumpBlock):

class RootJniLocal(BaseThreadFrameHeadDumpBlock):
pass

class RootJavaFrame(BaseThreadFrameHeadDumpBlock):

class RootJavaFrame(BaseThreadFrameHeadDumpBlock):
pass

class RootNativeStack(BaseThreadHeapDumpBlock):

class RootNativeStack(BaseThreadHeapDumpBlock):
pass

class RootStickyClass(BaseOnlyIdHeapDumpBlock):

class RootStickyClass(BaseOnlyIdHeapDumpBlock):
pass

class RootThreadBlock(BaseThreadHeapDumpBlock):

class RootThreadBlock(BaseThreadHeapDumpBlock):
pass

class RootMonitorUsed(BaseOnlyIdHeapDumpBlock):

class RootMonitorUsed(BaseOnlyIdHeapDumpBlock):
pass

class RootThreadObject(BaseThreadHeapDumpBlock):

class RootThreadObject(BaseThreadHeapDumpBlock):
def __init__(self, id, thread_serial_number, stack_trace_serial_number):
super(BaseThreadFrameHeadDumpBlock, self).__init__(id, thread_serial_number)
super(RootThreadObject, self).__init__(id, thread_serial_number)
self.stack_trace_serial_number = stack_trace_serial_number

@classmethod
def parse(cls, p):
return cls(p.read_id(), p.i4(), p.i4())

class ClassDump(BaseHeapDumpBlock):

class ClassDump(BaseHeapDumpBlock):
def __init__(self,
id,
stack_trace_serial_number,
Expand Down Expand Up @@ -111,7 +109,8 @@ def parse(cls, p):
constants = [cls.read_constant(p) for _ in xrange(p.i2())]
static_fields = [cls.read_static_field(p) for _ in xrange(p.i2())]
instance_fields = [cls.read_instance_field(p) for _ in xrange(p.i2())]
return cls(id, stack_trace_serial_number, super_class_id, class_loader_id, signers_object_id, protection_domain_object_id,
return cls(id, stack_trace_serial_number, super_class_id, class_loader_id, signers_object_id,
protection_domain_object_id,
reserved1, reserved2, instance_size, constants, static_fields, instance_fields)

@classmethod
Expand All @@ -134,8 +133,8 @@ def read_instance_field(cls, p):
tp = p.read_value_type()
return [name_id, tp]

class InstanceDump(BaseHeapDumpBlock):

class InstanceDump(BaseHeapDumpBlock):
def __init__(self, id, stack_trace_serial_number, class_object_id, bytes):
self.id = id
self.stack_trace_serial_number = stack_trace_serial_number
Expand All @@ -151,8 +150,8 @@ def parse(cls, p):
bytes = p.read(n_bytes)
return cls(id, stack_trace_serial_number, class_object_id, bytes)

class ObjectArrayDump(BaseHeapDumpBlock):

class ObjectArrayDump(BaseHeapDumpBlock):
def __init__(self, id, stack_trace_serial_number, array_class_object_id, elements):
self.id = id
self.stack_trace_serial_number = stack_trace_serial_number
Expand All @@ -168,8 +167,8 @@ def parse(cls, p):
elements = [p.read_id() for _ in xrange(n_elements)]
return cls(id, stack_trace_serial_number, array_class_object_id, elements)

class PrimitiveArrayDump(BaseHeapDumpBlock):

class PrimitiveArrayDump(BaseHeapDumpBlock):
def __init__(self, id, stack_trace_serial_number, element_type, size):
self.id = id
self.stack_trace_serial_number = stack_trace_serial_number
Expand All @@ -185,18 +184,19 @@ def parse(cls, p):
p.seek(p.type_size(element_type) * size)
return cls(id, stack_trace_serial_number, element_type, size)


HEAP_BLOCK_CLASSES_BY_TAG = {
'ROOT_UNKNOWN' : RootUnkown,
'ROOT_JNI_GLOBAL' : RootJniGlobal,
'ROOT_JNI_LOCAL' : RootJniLocal,
'ROOT_JAVA_FRAME' : RootJavaFrame,
'ROOT_NATIVE_STACK' : RootNativeStack,
'ROOT_STICKY_CLASS' : RootStickyClass,
'ROOT_THREAD_BLOCK' : RootThreadBlock,
'ROOT_MONITOR_USED' : RootMonitorUsed,
'ROOT_THREAD_OBJECT' : RootThreadObject,
'CLASS_DUMP' : ClassDump,
'INSTANCE_DUMP' : InstanceDump,
'OBJECT_ARRAY_DUMP' : ObjectArrayDump,
'PRIMITIVE_ARRAY_DUMP' : PrimitiveArrayDump
}
'ROOT_UNKNOWN': RootUnknown,
'ROOT_JNI_GLOBAL': RootJniGlobal,
'ROOT_JNI_LOCAL': RootJniLocal,
'ROOT_JAVA_FRAME': RootJavaFrame,
'ROOT_NATIVE_STACK': RootNativeStack,
'ROOT_STICKY_CLASS': RootStickyClass,
'ROOT_THREAD_BLOCK': RootThreadBlock,
'ROOT_MONITOR_USED': RootMonitorUsed,
'ROOT_THREAD_OBJECT': RootThreadObject,
'CLASS_DUMP': ClassDump,
'INSTANCE_DUMP': InstanceDump,
'OBJECT_ARRAY_DUMP': ObjectArrayDump,
'PRIMITIVE_ARRAY_DUMP': PrimitiveArrayDump
}

0 comments on commit 2bfeab4

Please sign in to comment.