Documentation
¶
Overview ¶
Package procmap resolves addresses into per-binary mapping identity (path, start/limit, file offset, build-id) by parsing /proc/<pid>/maps and ELF .note.gnu.build-id sections. Results feed pprof.Mapping so downstream tools can round-trip samples back to ELF file offsets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadBuildID ¶
ReadBuildID returns the GNU build-id of the ELF at path as a lowercase hex string. Returns an empty string (with nil error) when the ELF is valid but has no .note.gnu.build-id note, and an error when the file can't be opened or isn't ELF.
Types ¶
type Mapping ¶
type Mapping struct {
Path string
Start uint64
Limit uint64 // exclusive
Offset uint64 // p_offset of the backing PT_LOAD segment
BuildID string // hex; empty if no .note.gnu.build-id
IsExec bool
}
Mapping describes one executable range in a process's address space. Non-executable and anonymous ranges are dropped during parsing.
type Option ¶
type Option func(*resolverConfig)
Option configures a Resolver.
func WithProcRoot ¶
WithProcRoot overrides the filesystem root used to resolve /proc paths. Defaults to "/proc". Intended for unit tests with fake per-PID fixtures.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver caches per-PID /proc/<pid>/maps snapshots and per-path build-ids. Safe for concurrent use. Populates lazily on first Lookup for a PID.
func NewResolver ¶
NewResolver returns a Resolver ready for concurrent use.
func (*Resolver) BuildID ¶
BuildID returns a cached hex build-id for path, reading the ELF on first call. Read failures produce an empty string (cached) — a missing build-id is not a Lookup failure. Safe for concurrent use.
func (*Resolver) Close ¶
func (r *Resolver) Close()
Close releases cached state. After Close, the Resolver remains usable but behaves as freshly constructed; in-flight Lookups that captured a *pidEntry before the call complete normally against their captured snapshot.
func (*Resolver) Invalidate ¶
Invalidate drops any cached state for pid. The next Lookup re-parses /proc/<pid>/maps. Call on process exit or when the agent learns of whole-process churn (e.g., exec).
func (*Resolver) InvalidateAddr ¶
InvalidateAddr invalidates pid's cache only if addr falls outside every currently cached mapping — i.e., a new mmap extended the process's address space. Cheap no-op otherwise.