java

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

heap provides functions for extracting meaningfull data from heap dump. For example, it is able to parse class hierarchies from HPROF_GC_CLASS_DUMP records into the linked-list like data structure or parse values of heap objects like instances of instances fields.

Assembling the such data requires a lot of references traverse by the identifiers of heap objects. Package dump.ParsedAccessor is used for that purpose. For example, to get the class from class dump it's important to follow the links and collect superclass, superclass of superclass, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Class

type Class struct {
	Name           string
	Superclass     *Class
	StaticFields   []StaticField
	InstanceFields []InstanceField
}

Class is linked-list of information extracted from HPROF_GC_CLASS_DUMP as well as the Class data of all its superclasses.

type FieldValue

type FieldValue struct {
	Value  core.JavaValue
	Origin string
}

FieldValue is a wrapper returns from NormalObject.GetFieldValueByName. Origin field has the name of the class (or any superclass) that actually defines requested field.

type Heap

type Heap struct {
	// contains filtered or unexported fields
}

Heap contains methods for reading data from the heap dump.

func NewHeap

func NewHeap(parsedAccessor *dump.ParsedAccessor) *Heap

func (*Heap) ParseClass

func (h *Heap) ParseClass(classId core.Identifier) (Class, error)

ParseClass parses inforamsion from HPROF_DC_CLASS_DUMP record of a class and all its superclasses.

func (*Heap) ParseJavaString

func (h *Heap) ParseJavaString(str core.JavaValue) (string, error)

ParseJavaString takes the instance values known to be a reference to java.lang.String object and converts it to convenient Go string.

func (*Heap) ParseNormalObject

func (h *Heap) ParseNormalObject(objectId core.Identifier) (NormalObject, error)

ParseNormalObject is used to parse NormalObject by given objectId. It also triggers ObjectReader.ParseClass because NormalObject should contain information about class it represents.

func (*Heap) ParseObjectArrayFull

func (h *Heap) ParseObjectArrayFull(arrayObjectId core.Identifier) (ObjectArray, error)

ParseObjectArrayFull reads the whole object array and returns slice with ObjectArray structs

type InstanceField

type InstanceField struct {
	Name string
	Type core.JavaType
}

InstanceField is representation of class'es instance field name and type, obtained from HPROF_GC_CLASS_DUMP

type NormalObject

type NormalObject struct {
	Class Class
	Bytes []byte
	// contains filtered or unexported fields
}

NormalObject is representation of HPROF_GC_INSTANCE_DUMP. It has corresponding Class. The values of fields are raw bytes. NormalObject.GetFieldValueByName should be used to read particular field value.

func (*NormalObject) GetFieldValueByName

func (o *NormalObject) GetFieldValueByName(name string) (FieldValue, error)

GetFieldValueByName extracts instance field value by name of the field as well as name of the class that actually defines requested field.

type ObjectArray

type ObjectArray struct {
	ArrayClassId core.Identifier
	Elements     []core.Identifier
}

ObjectArray holds type and elements of object array

type PrimitiveArray

type PrimitiveArray struct {
	Type   core.JavaType
	Length uint32
}

PrimitiveArray represents HPROF_GC_PRIM_ARRAY_DUMP but only it's "header" part. To obtain the body, i.e. elements of the array, raw bytes should be read from underlying index.Reader.

type StaticField

type StaticField struct {
	Name  string
	Type  core.JavaType
	Value core.JavaValue
}

StaticField is representation of class'es static field name, type and value, obtained from HPROF_GC_CLASS_DUMP

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL