github.com/inspektor-gadget/inspektor-gadget@v0.28.1/pkg/gadgets/profile/cpu/tracer/profile_x86_bpfel.go (about)

     1  // Code generated by bpf2go; DO NOT EDIT.
     2  //go:build 386 || amd64
     3  
     4  package tracer
     5  
     6  import (
     7  	"bytes"
     8  	_ "embed"
     9  	"fmt"
    10  	"io"
    11  
    12  	"github.com/cilium/ebpf"
    13  )
    14  
    15  type profileKeyT struct {
    16  	KernelIp    uint64
    17  	MntnsId     uint64
    18  	Pid         uint32
    19  	UserStackId int32
    20  	KernStackId int32
    21  	Name        [16]uint8
    22  	_           [4]byte
    23  }
    24  
    25  // loadProfile returns the embedded CollectionSpec for profile.
    26  func loadProfile() (*ebpf.CollectionSpec, error) {
    27  	reader := bytes.NewReader(_ProfileBytes)
    28  	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
    29  	if err != nil {
    30  		return nil, fmt.Errorf("can't load profile: %w", err)
    31  	}
    32  
    33  	return spec, err
    34  }
    35  
    36  // loadProfileObjects loads profile and converts it into a struct.
    37  //
    38  // The following types are suitable as obj argument:
    39  //
    40  //	*profileObjects
    41  //	*profilePrograms
    42  //	*profileMaps
    43  //
    44  // See ebpf.CollectionSpec.LoadAndAssign documentation for details.
    45  func loadProfileObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
    46  	spec, err := loadProfile()
    47  	if err != nil {
    48  		return err
    49  	}
    50  
    51  	return spec.LoadAndAssign(obj, opts)
    52  }
    53  
    54  // profileSpecs contains maps and programs before they are loaded into the kernel.
    55  //
    56  // It can be passed ebpf.CollectionSpec.Assign.
    57  type profileSpecs struct {
    58  	profileProgramSpecs
    59  	profileMapSpecs
    60  }
    61  
    62  // profileSpecs contains programs before they are loaded into the kernel.
    63  //
    64  // It can be passed ebpf.CollectionSpec.Assign.
    65  type profileProgramSpecs struct {
    66  	IgProfCpu *ebpf.ProgramSpec `ebpf:"ig_prof_cpu"`
    67  }
    68  
    69  // profileMapSpecs contains maps before they are loaded into the kernel.
    70  //
    71  // It can be passed ebpf.CollectionSpec.Assign.
    72  type profileMapSpecs struct {
    73  	Counts               *ebpf.MapSpec `ebpf:"counts"`
    74  	GadgetMntnsFilterMap *ebpf.MapSpec `ebpf:"gadget_mntns_filter_map"`
    75  	Stackmap             *ebpf.MapSpec `ebpf:"stackmap"`
    76  }
    77  
    78  // profileObjects contains all objects after they have been loaded into the kernel.
    79  //
    80  // It can be passed to loadProfileObjects or ebpf.CollectionSpec.LoadAndAssign.
    81  type profileObjects struct {
    82  	profilePrograms
    83  	profileMaps
    84  }
    85  
    86  func (o *profileObjects) Close() error {
    87  	return _ProfileClose(
    88  		&o.profilePrograms,
    89  		&o.profileMaps,
    90  	)
    91  }
    92  
    93  // profileMaps contains all maps after they have been loaded into the kernel.
    94  //
    95  // It can be passed to loadProfileObjects or ebpf.CollectionSpec.LoadAndAssign.
    96  type profileMaps struct {
    97  	Counts               *ebpf.Map `ebpf:"counts"`
    98  	GadgetMntnsFilterMap *ebpf.Map `ebpf:"gadget_mntns_filter_map"`
    99  	Stackmap             *ebpf.Map `ebpf:"stackmap"`
   100  }
   101  
   102  func (m *profileMaps) Close() error {
   103  	return _ProfileClose(
   104  		m.Counts,
   105  		m.GadgetMntnsFilterMap,
   106  		m.Stackmap,
   107  	)
   108  }
   109  
   110  // profilePrograms contains all programs after they have been loaded into the kernel.
   111  //
   112  // It can be passed to loadProfileObjects or ebpf.CollectionSpec.LoadAndAssign.
   113  type profilePrograms struct {
   114  	IgProfCpu *ebpf.Program `ebpf:"ig_prof_cpu"`
   115  }
   116  
   117  func (p *profilePrograms) Close() error {
   118  	return _ProfileClose(
   119  		p.IgProfCpu,
   120  	)
   121  }
   122  
   123  func _ProfileClose(closers ...io.Closer) error {
   124  	for _, closer := range closers {
   125  		if err := closer.Close(); err != nil {
   126  			return err
   127  		}
   128  	}
   129  	return nil
   130  }
   131  
   132  // Do not access this directly.
   133  //
   134  //go:embed profile_x86_bpfel.o
   135  var _ProfileBytes []byte