blazesym

package module
v0.0.0-...-ebb5b50 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: BSD-3-Clause Imports: 4 Imported by: 3

README

blazsym-go

Go wrapper for C bindings of blazesym.

Building

First of all, you need to have blazesym-c available on your system. If it is installed in the expected places, everything should build out of the box.

If you don't have installed, you can build it yourself from capi dir in the repo:

cargo build --release

You can then pass flags to tell Go where to find things:

CGO_CFLAGS="-I/path/to/blazesym/capi/include" CGO_LDFLAGS="-L/path/to/blazesym/target/release"

At runtime you need to set LD_LIBRARY_PATH=/path/to/blazesym/target/release.

Static linking

You might want to link against blazesym statically by adding the following to CGO_LDFLAGS:

-Wl,-Bstatic -lblazesym_c -Wl,-Bdynamic

This way blazesym_c.so doesn't need to be installed on the system where the binary will run.

Fully static builds are possible if you pass the following to go build or go install:

-ldflags='-extldflags "-static"'
Example usage

See example_source_elf_test.go for a basic example.

Documentation

Overview

Package blazesym provides Go bindings for blazesym library.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeInfo

type CodeInfo struct {
	// The directory in which the source file resides.
	Dir string
	// The file that defines the symbol.
	File string
	// The line number of the symbolized instruction in the source code.
	Line uint32
	// The column number of the symbolized instruction in the source code.
	Column uint16
}

CodeInfo describes source code location information for a symbol or inlined function. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_code_info.html

type ElfSource

type ElfSource struct {
	// contains filtered or unexported fields
}

ElfSource describes the parameters to load symbols and debug information from an ELF. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_src_elf.html

Example
package main

import (
	"fmt"
	"log"

	blazesym "github.com/libbpf/blazesym/go"
)

func main() {
	symbolizer, err := blazesym.NewSymbolizer()
	if err != nil {
		log.Fatalf("error creating symbolizer: %v", err)
	}

	symbols, err := symbolizer.SymbolizeElfVirtOffsets([]uint64{0x2000200}, "../data/test-stable-addrs-compressed-debug-zlib.bin", blazesym.ElfSourceWithDebugSyms(true))
	if err != nil {
		log.Fatalf("error symbolizing: %v", err)
	}

	fmt.Printf("%s @ 0x%x %s\n", symbols[0].Name, symbols[0].Addr, symbols[0].CodeInfo.File)
}
Output:
factorial @ 0x2000200 test-stable-addrs.c

type ElfSourceOption

type ElfSourceOption func(*ElfSource)

ElfSourceOption configures ElfSource objects.

func ElfSourceWithDebugSyms

func ElfSourceWithDebugSyms(enabled bool) ElfSourceOption

ElfSourceWithDebugSyms configures whether or not to consult debug symbols to satisfy the request (if present). See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_src_elf.html#structfield.debug_syms

type GsymDataSource

type GsymDataSource struct {
	// contains filtered or unexported fields
}

GsymDataSource describes the parameters to load symbols and debug information from “raw” Gsym data. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_src_gsym_data.html

type GsymFileSource

type GsymFileSource struct {
	// contains filtered or unexported fields
}

GsymFileSource describes the parameters to load symbols and debug information from a Gsym file. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_src_gsym_file.html

type InlinedFn

type InlinedFn struct {
	// The symbol name of the inlined function.
	Name string
	// Source code location information for the call to the function.
	CodeInfo *CodeInfo
}

InlinedFn represents an inlined function. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_inlined_fn.html

type ProcessSource

type ProcessSource struct {
	// contains filtered or unexported fields
}

ProcessSource describes the parameters to load symbols and debug information from a process. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_src_process.html

type ProcessSourceOption

type ProcessSourceOption func(*ProcessSource)

ProcessSourceOption configures ProcessSource objects.

func ProcessSourceWithDebugSyms

func ProcessSourceWithDebugSyms(enabled bool) ProcessSourceOption

ProcessSourceWithDebugSyms configures whether or not to consult debug symbols to satisfy the request (if present). See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_src_process.html#structfield.debug_syms

func ProcessSourceWithPerfMap

func ProcessSourceWithPerfMap(enabled bool) ProcessSourceOption

ProcessSourceWithPerfMap configures whether to incorporate a process' perf map file into the symbolization procedure. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_src_process.html#structfield.perf_map

func ProcessSourceWithoutMapFiles

func ProcessSourceWithoutMapFiles(enabled bool) ProcessSourceOption

ProcessSourceWithoutMapFiles configures whether to work with /proc/<pid>/map_files/ entries or with symbolic paths mentioned in /proc/<pid>/maps instead. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_src_process.html#structfield.no_map_files

func ProcessSourceWithoutVDSO

func ProcessSourceWithoutVDSO(enabled bool) ProcessSourceOption

ProcessSourceWithoutVDSO configures whether or not to symbolize addresses in a vDSO (virtual dynamic shared object). See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_src_process.html#structfield.no_vdso

type Sym

type Sym struct {
	// The symbol name that an address belongs to.
	Name string
	// The path to or name of the module containing the symbol.
	Module string
	// The address at which the symbol is located (i.e., its “start”).
	Addr uint64
	// The byte offset of the address that got symbolized from the start of the symbol (i.e., from addr).
	Offset uint64
	// The symbol's size, if available.
	Size int64
	// Source code location information for the symbol.
	CodeInfo *CodeInfo
	// Inlined function information, if requested and available.
	Inlined []InlinedFn
	// On error (i.e., if name is NULL), a reason trying to explain why symbolization failed.
	Reason SymbolizeReason
}

Sym is the result of address symbolization by Symbolizer. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_sym.html

type SymbolizeReason

type SymbolizeReason int

SymbolizeReason describes the reason why symbolization failed. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolize_reason.html

const (
	// SymbolizeReasonSuccess means that symbolization was successful.
	SymbolizeReasonSuccess SymbolizeReason = 0
	// SymbolizeReasonUnmapped means that the absolute address was not found
	// in the corresponding process' virtual memory map.
	SymbolizeReasonUnmapped SymbolizeReason = 1
	// SymbolizeReasonInvalidFileOffset means that the file offset does not map
	// to a valid piece of code/data.
	SymbolizeReasonInvalidFileOffset SymbolizeReason = 2
	// SymbolizeReasonMissingComponent means that the `/proc/<pid>/maps` entry
	// corresponding to the address does not have a component (file system path,
	// object, ...) associated with it.
	SymbolizeReasonMissingComponent SymbolizeReason = 3
	// SymbolizeReasonMissingSyms means that the symbolization source has no
	// or no relevant symbols.
	SymbolizeReasonMissingSyms SymbolizeReason = 4
	// SymbolizeReasonUnknownAddr means that the address could not be found
	// in the symbolization source.
	SymbolizeReasonUnknownAddr SymbolizeReason = 5
	// SymbolizeReasonUnsupported means that the address belonged to an entity
	// that is currently unsupported.
	SymbolizeReasonUnsupported SymbolizeReason = 6
)

type Symbolizer

type Symbolizer struct {
	// contains filtered or unexported fields
}

Symbolizer represents a Blazesym symbolizer.

func NewSymbolizer

func NewSymbolizer(options ...SymbolizerOption) (*Symbolizer, error)

NewSymbolizer creates an instance of a symbolizer. See: https://docs.rs/blazesym-c/latest/blazesym_c/fn.blaze_symbolizer_new.html

func (*Symbolizer) Close

func (s *Symbolizer) Close()

Close closes the a symbolizer.

func (*Symbolizer) SymbolizeElfVirtOffsets

func (s *Symbolizer) SymbolizeElfVirtOffsets(addrs []uint64, path string, options ...ElfSourceOption) ([]Sym, error)

SymbolizeElfVirtOffsets symbolizes virtual offsets in an ELF file. See: https://docs.rs/blazesym-c/latest/blazesym_c/fn.blaze_symbolize_elf_virt_offsets.html

func (*Symbolizer) SymbolizeGsymDataVirtOffsets

func (s *Symbolizer) SymbolizeGsymDataVirtOffsets(addrs []uint64, data []byte) ([]Sym, error)

SymbolizeGsymDataVirtOffsets symbolizes virtual offsets using “raw” Gsym data. See: https://docs.rs/blazesym-c/latest/blazesym_c/fn.blaze_symbolize_gsym_data_virt_offsets.html

func (*Symbolizer) SymbolizeGsymFileVirtOffsets

func (s *Symbolizer) SymbolizeGsymFileVirtOffsets(addrs []uint64, path string) ([]Sym, error)

SymbolizeGsymFileVirtOffsets symbolizes virtual offsets in a Gsym file. See: https://docs.rs/blazesym-c/latest/blazesym_c/fn.blaze_symbolize_gsym_file_virt_offsets.html

func (*Symbolizer) SymbolizeProcessAbsAddrs

func (s *Symbolizer) SymbolizeProcessAbsAddrs(addrs []uint64, pid uint32, options ...ProcessSourceOption) ([]Sym, error)

SymbolizeProcessAbsAddrs symbolizes a list of process absolute addresses. See: https://docs.rs/blazesym-c/latest/blazesym_c/fn.blaze_symbolize_process_abs_addrs.html

type SymbolizerOption

type SymbolizerOption func(*SymbolizerOptions)

SymbolizerOption configures SymbolizerOptions objects.

func SymbolizerWithAutoReload

func SymbolizerWithAutoReload(enabled bool) SymbolizerOption

SymbolizerWithAutoReload sets whether or not to automatically reload file system based symbolization sources that were updated since the last symbolization operation. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolizer_opts.html#structfield.auto_reload

func SymbolizerWithCodeInfo

func SymbolizerWithCodeInfo(enabled bool) SymbolizerOption

SymbolizerWithCodeInfo sets whether to attempt to gather source code location information. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolizer_opts.html#structfield.code_info

func SymbolizerWithDebugDirs

func SymbolizerWithDebugDirs(dirs []string) SymbolizerOption

SymbolizerWithDebugDirs sets the array of debug directories to search for split debug information. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolizer_opts.html#structfield.debug_dirs

func SymbolizerWithDemangle

func SymbolizerWithDemangle(enabled bool) SymbolizerOption

SymbolizerWithDemangle sets whether or not to transparently demangle symbols. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolizer_opts.html#structfield.demangle

func SymbolizerWithInlinedFns

func SymbolizerWithInlinedFns(enabled bool) SymbolizerOption

SymbolizerWithInlinedFns sets whether to report inlined functions as part of symbolization. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolizer_opts.html#structfield.inlined_fns

type SymbolizerOptions

type SymbolizerOptions struct {
	// contains filtered or unexported fields
}

SymbolizerOptions is options for configuring Symbolizer objects. See: https://docs.rs/blazesym-c/latest/blazesym_c/struct.blaze_symbolizer_opts.html

func (*SymbolizerOptions) Close

func (so *SymbolizerOptions) Close()

Close frees resources associated with SymbolizerOptions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL