nopieprofile

package module
v0.0.0-...-75e0c49 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 6 Imported by: 0

README

nopieprofile

nopieprofile is a Go package that provides utilities for converting CPU profiles generated by Go's pprof tool from runtime addresses to static addresses.

Motivation

When Go binaries are built with Position-Independent Executables (PIE) enabled, the addresses of the functions and variables in the binary are determined at runtime. This can make it difficult to analyze CPU profiles generated by the pprof tool, because the profile samples will contain runtime addresses that are different each time the program runs.

nopieprofile provides a way to convert such profiles to use static addresses instead of runtime addresses, making them more amenable to analysis and easier to compare across multiple runs.

Example

package nopieprofile_test

import (
	"log"
	"os"
	"testing"

	"github.com/orisano/nopieprofile"
)

func TestMain(m *testing.M) {
	code := m.Run()
	if err := nopieprofile.RewriteTestProfile(); err != nil {
		log.Printf("warn: failed to rewrite test profile: %v", err)
	}
	os.Exit(code)
}

shorthand

package nopieprofile_test

import (
	"testing"

	"github.com/orisano/nopieprofile/nopieprofiletest"
)

func TestMain(m *testing.M) { nopieprofiletest.Main(m) }

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rewrite

func Rewrite(profilePath string) error

Rewrite rewrites the sample held by the profilePath's profile from a runtime address to a static address.

func RewriteTestProfile

func RewriteTestProfile() error

RewriteTestProfile rewrites the CPU profile generated during testing, making sure the profile corresponds to static addresses. The profile is located in the directory specified by the "test.outputdir" test flag and has the file name specified by the "test.cpuprofile" flag.

This function returns an error if the profile was not successfully rewritten.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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