File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -497,9 +497,44 @@ func newProgramInfoFromFd(fd *sys.FD) (*ProgramInfo, error) {
497497 }
498498 }
499499
500+ if len (pi .Name ) == len (info .Name )- 1 { // Possibly truncated, check BTF info for full name
501+ name , err := readNameFromFunc (& pi )
502+ if err == nil {
503+ pi .Name = name
504+ } // If an error occurs, keep the truncated name, which is better than none
505+ }
506+
500507 return & pi , nil
501508}
502509
510+ func readNameFromFunc (pi * ProgramInfo ) (string , error ) {
511+ if pi .numFuncInfos == 0 {
512+ return "" , errors .New ("no function info" )
513+ }
514+
515+ spec , err := pi .btfSpec ()
516+ if err != nil {
517+ return "" , err
518+ }
519+
520+ funcInfos , err := btf .LoadFuncInfos (
521+ bytes .NewReader (pi .funcInfos ),
522+ internal .NativeEndian ,
523+ pi .numFuncInfos ,
524+ spec ,
525+ )
526+ if err != nil {
527+ return "" , err
528+ }
529+
530+ for _ , funcInfo := range funcInfos {
531+ if funcInfo .Offset == 0 { // Information about the whole program
532+ return funcInfo .Func .Name , nil
533+ }
534+ }
535+ return "" , errors .New ("no function info about program" )
536+ }
537+
503538func readProgramInfoFromProc (fd * sys.FD , pi * ProgramInfo ) error {
504539 var progType uint32
505540 err := scanFdInfo (fd , map [string ]interface {}{
You can’t perform that action at this time.
0 commit comments