Skip to content

Commit

Permalink
Use int64 as TypeID and use -1 as uninitialised value
Browse files Browse the repository at this point in the history
  • Loading branch information
sivachandran committed Sep 5, 2024
1 parent 365b303 commit 905b8eb
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 2 deletions.
29 changes: 28 additions & 1 deletion parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func (p *Parser) checkTypes() error {
if typeCPLogLevel != nil {
p.TypeMap.T_LOG_LEVEL = typeCPLogLevel.ID
} else {
p.TypeMap.T_LOG_LEVEL = 0
p.TypeMap.T_LOG_LEVEL = -1
}
p.TypeMap.T_STACK_TRACE = typeCPStackTrace.ID
p.TypeMap.T_CLASS_LOADER = typeCPClassLoader.ID
Expand Down Expand Up @@ -521,30 +521,57 @@ func (p *Parser) checkTypes() error {
if typeExecutionSample != nil {
p.TypeMap.T_EXECUTION_SAMPLE = typeExecutionSample.ID
p.bindExecutionSample = types2.NewBindExecutionSample(typeExecutionSample, &p.TypeMap)
} else {
p.TypeMap.T_EXECUTION_SAMPLE = -1
p.bindExecutionSample = nil
}

if typeAllocInNewTLAB != nil {
p.TypeMap.T_ALLOC_IN_NEW_TLAB = typeAllocInNewTLAB.ID
p.bindAllocInNewTLAB = types2.NewBindObjectAllocationInNewTLAB(typeAllocInNewTLAB, &p.TypeMap)
} else {
p.TypeMap.T_ALLOC_IN_NEW_TLAB = -1
p.bindAllocInNewTLAB = nil
}

if typeALlocOutsideTLAB != nil {
p.TypeMap.T_ALLOC_OUTSIDE_TLAB = typeALlocOutsideTLAB.ID
p.bindAllocOutsideTLAB = types2.NewBindObjectAllocationOutsideTLAB(typeALlocOutsideTLAB, &p.TypeMap)
} else {
p.TypeMap.T_ALLOC_OUTSIDE_TLAB = -1
p.bindAllocOutsideTLAB = nil
}

if typeMonitorEnter != nil {
p.TypeMap.T_MONITOR_ENTER = typeMonitorEnter.ID
p.bindMonitorEnter = types2.NewBindJavaMonitorEnter(typeMonitorEnter, &p.TypeMap)
} else {
p.TypeMap.T_MONITOR_ENTER = -1
p.bindMonitorEnter = nil
}

if typeThreadPark != nil {
p.TypeMap.T_THREAD_PARK = typeThreadPark.ID
p.bindThreadPark = types2.NewBindThreadPark(typeThreadPark, &p.TypeMap)
} else {
p.TypeMap.T_THREAD_PARK = -1
p.bindThreadPark = nil
}

if typeLiveObject != nil {
p.TypeMap.T_LIVE_OBJECT = typeLiveObject.ID
p.bindLiveObject = types2.NewBindLiveObject(typeLiveObject, &p.TypeMap)
} else {
p.TypeMap.T_LIVE_OBJECT = -1
p.bindLiveObject = nil
}

if typeActiveSetting != nil {
p.TypeMap.T_ACTIVE_SETTING = typeActiveSetting.ID
p.bindActiveSetting = types2.NewBindActiveSetting(typeActiveSetting, &p.TypeMap)
} else {
p.TypeMap.T_ACTIVE_SETTING = -1
p.bindActiveSetting = nil
}

p.FrameTypes.IDMap = nil
Expand Down
Binary file added parser/testdata/event-with-type-zero.jfr.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion parser/types/def/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package def

type TypeID uint64
type TypeID int64

type TypeMap struct {
IDMap map[TypeID]*Class
Expand Down
1 change: 1 addition & 0 deletions pprof/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var testfiles = []testdata{
{"dump2", "dump2.labels.pb.gz", 4},
{"dd-trace-java", "", 4},
{"cpool-uint64-constant-index", "", 4},
{"event-with-type-zero", "", 4},
}

type gprofile struct {
Expand Down

0 comments on commit 905b8eb

Please sign in to comment.