7373// fileIDMapper and symbolReporter. Specify nil for fileIDMapper to use the default
7474// implementation.
7575func New (ctx context.Context , includeTracers types.IncludedTracers , monitorInterval time.Duration ,
76- ebpf pmebpf.EbpfHandler , fileIDMapper FileIDMapper , traceReporter reporter.TraceReporter ,
76+ ebpf pmebpf.EbpfHandler , traceReporter reporter.TraceReporter ,
7777 exeReporter reporter.ExecutableReporter , sdp nativeunwind.StackDeltaProvider ,
7878 filterErrorFrames bool , includeEnvVars libpf.Set [string ]) (* ProcessManager , error ) {
79- if fileIDMapper == nil {
80- var err error
81- fileIDMapper , err = newFileIDMapper (lruFileIDCacheSize )
82- if err != nil {
83- return nil , fmt .Errorf ("failed to initialize file ID mapping: %v" , err )
84- }
85- }
8679 if exeReporter == nil {
8780 exeReporter = executableReporterStub {}
8881 }
@@ -114,7 +107,6 @@ func New(ctx context.Context, includeTracers types.IncludedTracers, monitorInter
114107 exitEvents : make (map [libpf.PID ]times.KTime ),
115108 pidToProcessInfo : make (map [libpf.PID ]* processInfo ),
116109 ebpf : ebpf ,
117- FileIDMapper : fileIDMapper ,
118110 elfInfoCache : elfInfoCache ,
119111 frameCache : frameCache ,
120112 traceReporter : traceReporter ,
@@ -240,10 +232,16 @@ func (pm *ProcessManager) symbolizeFrame(pid libpf.PID, bpfFrame *host.Frame, fr
240232// if non-trivial cacheable conversion was done.
241233func (pm * ProcessManager ) convertFrame (pid libpf.PID , frame * host.Frame , dst * libpf.Frames ) bool {
242234 switch frame .Type .Interpreter () {
243- case libpf .UnknownInterp :
244- log .Errorf ("Unexpected frame type 0x%02X (neither error nor interpreter frame)" ,
235+ case libpf .UnknownInterp , libpf . Kernel :
236+ log .Errorf ("Unexpected frame type 0x%02X (neither error nor usermode frame)" ,
245237 uint8 (frame .Type ))
246- case libpf .Native , libpf .Kernel :
238+ case libpf .Native :
239+ // Attempt symbolization of native frames. It is best effort and
240+ // provides non-symbolized frames if no native symbolizer is active.
241+ if err := pm .symbolizeFrame (pid , frame , dst ); err == nil {
242+ return true
243+ }
244+
247245 // The BPF code classifies whether an address is a return address or not.
248246 // Return addresses are where execution resumes when returning to the stack
249247 // frame and point to the **next instruction** after the call instruction
@@ -264,43 +262,13 @@ func (pm *ProcessManager) convertFrame(pid libpf.PID, frame *host.Frame, dst *li
264262 }
265263
266264 // Locate mapping info for the frame.
267- var mappingStart , mappingEnd libpf.Address
268- var fileOffset uint64
269- if frame .Type .Interpreter () == libpf .Native {
270- if mapping , ok := pm .findMappingForTrace (pid , frame .File , frame .Lineno ); ok {
271- mappingStart = mapping .Vaddr - libpf .Address (mapping .Bias )
272- mappingEnd = mappingStart + libpf .Address (mapping .Length )
273- fileOffset = mapping .FileOffset
274- }
275- }
276-
277- // Attempt symbolization of native frames. It is best effort and
278- // provides non-symbolized frames if no native symbolizer is active.
279- if err := pm .symbolizeFrame (pid , frame , dst ); err == nil {
280- return true
281- }
282-
283- if mappingFile , ok := pm .FileIDMapper .Get (frame .File ); ok {
284- dst .Append (& libpf.Frame {
285- Type : frame .Type ,
286- AddressOrLineno : relativeRIP ,
287- MappingStart : mappingStart ,
288- MappingEnd : mappingEnd ,
289- MappingFileOffset : fileOffset ,
290- MappingFile : mappingFile ,
265+ mapping := pm .findMappingForTrace (pid , frame .File ,
266+ libpf .Address (frame .Lineno ))
267+ dst .Append (& libpf.Frame {
268+ Type : frame .Type ,
269+ AddressOrLineno : relativeRIP ,
270+ Mapping : mapping ,
291271 })
292- } else {
293- log .Debugf (
294- "file ID lookup failed for PID %d, frame type %d" ,
295- pid , frame .Type )
296-
297- dst .Append (& libpf.Frame {
298- Type : frame .Type ,
299- MappingStart : mappingStart ,
300- MappingEnd : mappingEnd ,
301- MappingFileOffset : fileOffset ,
302- })
303- }
304272 default :
305273 err := pm .symbolizeFrame (pid , frame , dst )
306274 if err == nil {
0 commit comments