@@ -31,10 +31,6 @@ import (
3131 "go.opentelemetry.io/ebpf-profiler/util"
3232)
3333
34- // #include "../../support/ebpf/types.h"
35- // #include "../../support/ebpf/frametypes.h"
36- import "C"
37-
3834// heapRange contains info for an individual heap.
3935type heapRange struct {
4036 codeStart , codeEnd libpf.Address
@@ -237,9 +233,9 @@ func (d *hotspotInstance) getPoolSymbol(addr libpf.Address, ndx uint16) libpf.St
237233
238234// getStubNameID read the stub name from the code blob at given address and generates a ID.
239235func (d * hotspotInstance ) getStubNameID (symbolReporter reporter.SymbolReporter , ripOrBci uint32 ,
240- addr libpf.Address , _ uint32 ) ( libpf.AddressOrLineno , error ) {
236+ addr libpf.Address , _ uint32 ) libpf.AddressOrLineno {
241237 if value , ok := d .addrToStubNameID .Get (addr ); ok {
242- return value , nil
238+ return value
243239 }
244240 vms := & d .d .Get ().vmStructs
245241 constStubNameAddr := d .rm .Ptr (addr + libpf .Address (vms .CodeBlob .Name ))
@@ -263,7 +259,7 @@ func (d *hotspotInstance) getStubNameID(symbolReporter reporter.SymbolReporter,
263259 })
264260 d .addrToStubNameID .Add (addr , stubID )
265261
266- return stubID , nil
262+ return stubID
267263}
268264
269265// getMethod reads and returns the interesting data from "class Method" at given address
@@ -745,31 +741,31 @@ func (d *hotspotInstance) populateMainMappings(vmd *hotspotVMData,
745741
746742 // Set up the main eBPF info structure.
747743 vms := & vmd .vmStructs
748- procInfo := C .HotspotProcInfo {
749- nmethod_deopt_offset : C . u16 (vms .Nmethod .DeoptimizeOffset ),
750- nmethod_compileid : C . u16 (vms .Nmethod .CompileID ),
751- nmethod_orig_pc_offset : C . u16 (vms .Nmethod .OrigPcOffset ),
752- codeblob_name : C . u8 (vms .CodeBlob .Name ),
753- codeblob_codestart : C . u8 (vms .CodeBlob .CodeBegin ),
754- codeblob_codeend : C . u8 (vms .CodeBlob .CodeEnd ),
755- codeblob_framecomplete : C . u8 (vms .CodeBlob .FrameCompleteOffset ),
756- codeblob_framesize : C . u8 (vms .CodeBlob .FrameSize ),
757- cmethod_size : C . u8 (vms .ConstMethod .Sizeof ),
758- heapblock_size : C . u8 (vms .HeapBlock .Sizeof ),
759- method_constmethod : C . u8 (vms .Method .ConstMethod ),
760- jvm_version : C . u8 (vmd .version >> 24 ),
761- segment_shift : C . u8 (heap .segmentShift ),
762- nmethod_uses_offsets : C . u8 ( vmd .nmethodUsesOffsets ) ,
744+ procInfo := support .HotspotProcInfo {
745+ Nmethod_deopt_offset : uint16 (vms .Nmethod .DeoptimizeOffset ),
746+ Nmethod_compileid : uint16 (vms .Nmethod .CompileID ),
747+ Nmethod_orig_pc_offset : uint16 (vms .Nmethod .OrigPcOffset ),
748+ Codeblob_name : uint8 (vms .CodeBlob .Name ),
749+ Codeblob_codestart : uint8 (vms .CodeBlob .CodeBegin ),
750+ Codeblob_codeend : uint8 (vms .CodeBlob .CodeEnd ),
751+ Codeblob_framecomplete : uint8 (vms .CodeBlob .FrameCompleteOffset ),
752+ Codeblob_framesize : uint8 (vms .CodeBlob .FrameSize ),
753+ Cmethod_size : uint8 (vms .ConstMethod .Sizeof ),
754+ Heapblock_size : uint8 (vms .HeapBlock .Sizeof ),
755+ Method_constmethod : uint8 (vms .Method .ConstMethod ),
756+ Jvm_version : uint8 (vmd .version >> 24 ),
757+ Segment_shift : uint8 (heap .segmentShift ),
758+ Nmethod_uses_offsets : vmd .nmethodUsesOffsets ,
763759 }
764760
765761 if vms .CodeCache .LowBound == 0 {
766762 // JDK-8 has only one heap, use its bounds
767- procInfo .codecache_start = C . u64 (heap .ranges [0 ].codeStart )
768- procInfo .codecache_end = C . u64 (heap .ranges [0 ].codeEnd )
763+ procInfo .Codecache_start = uint64 (heap .ranges [0 ].codeStart )
764+ procInfo .Codecache_end = uint64 (heap .ranges [0 ].codeEnd )
769765 } else {
770766 // JDK9+ the VM tracks it separately
771- procInfo .codecache_start = C . u64 (d .rm .Ptr (vms .CodeCache .LowBound + d .bias ))
772- procInfo .codecache_end = C . u64 (d .rm .Ptr (vms .CodeCache .HighBound + d .bias ))
767+ procInfo .Codecache_start = uint64 (d .rm .Ptr (vms .CodeCache .LowBound + d .bias ))
768+ procInfo .Codecache_end = uint64 (d .rm .Ptr (vms .CodeCache .HighBound + d .bias ))
773769 }
774770
775771 if err = ebpf .UpdateProcData (libpf .HotSpot , pid , unsafe .Pointer (& procInfo )); err != nil {
@@ -875,22 +871,19 @@ func (d *hotspotInstance) Symbolize(symbolReporter reporter.SymbolReporter,
875871 sfCounter := successfailurecounter .New (& d .successCount , & d .failCount )
876872 defer sfCounter .DefaultToFailure ()
877873
878- switch subtype {
879- case C . FRAME_HOTSPOT_STUB , C . FRAME_HOTSPOT_VTABLE :
874+ switch uint8 ( subtype ) {
875+ case support . FrameHotspotStub , support . FrameHotspotVtable :
880876 // These are stub frames that may or may not be interesting
881877 // to be seen in the trace.
882- stubID , err1 := d .getStubNameID (symbolReporter , ripOrBci , ptr , ptrCheck )
883- if err1 != nil {
884- return err
885- }
878+ stubID := d .getStubNameID (symbolReporter , ripOrBci , ptr , ptrCheck )
886879 trace .AppendFrame (libpf .HotSpotFrame , hotspotStubsFileID , stubID )
887- case C . FRAME_HOTSPOT_INTERPRETER :
880+ case support . FrameHotspotInterpreter :
888881 method , err1 := d .getMethod (ptr , ptrCheck )
889882 if err1 != nil {
890883 return err1
891884 }
892885 method .symbolize (symbolReporter , ripOrBci , d , trace )
893- case C . FRAME_HOTSPOT_NATIVE :
886+ case support . FrameHotspotNative :
894887 jitinfo , err1 := d .getJITInfo (ptr , ptrCheck )
895888 if err1 != nil {
896889 return err1
0 commit comments