Skip to content

Commit

Permalink
address reviews and linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylfrena committed Feb 7, 2024
1 parent 279c297 commit ecf0036
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/eh-frame/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func main() {
}

ptb := unwind.NewUnwindTableBuilder(logger)
err := ptb.PrintTable(os.Stdout, logger, executablePath, flags.Compact, pc)
err := ptb.PrintTable(logger, os.Stdout, executablePath, flags.Compact, pc)
if err != nil {
// nolint:forbidigo
fmt.Println("failed with:", err)
Expand Down
5 changes: 2 additions & 3 deletions internal/dwarf/frame/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func NewContext(logger log.Logger, fullExecutablePath string) *Context {
buf: &bytes.Reader{},
rememberedState: newStateStack(),
fullExecutablePath: fullExecutablePath,
logger: logger,
logger: log.With(logger, "component", "dwarf unwind table context"),
}
}

Expand Down Expand Up @@ -413,8 +413,7 @@ func lookupFunc(instruction byte, ctx *Context) instruction {
case DW_CFA_GNU_window_save:
fn = gnuwindowsave
default:
//panic(fmt.Sprintf("Encountered an unexpected DWARF CFA opcode: %#v", instruction))
level.Error(ctx.logger).Log("msg", "Encountered an unexpected DWARF CFA opcode", "opcode instruction", instruction, "PID", getPid(ctx.fullExecutablePath), "comm", ctx.fullExecutablePath)
level.Error(ctx.logger).Log("msg", "encountered an unexpected DWARF CFA opcode", "opcode instruction", instruction, "PID", getPid(ctx.fullExecutablePath), "comm", ctx.fullExecutablePath)
}
return fn
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/stack/unwind/compact_unwind_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"bytes"
"debug/elf"
"fmt"

"sort"

"github.com/go-kit/log"

"github.com/parca-dev/parca-agent/internal/dwarf/frame"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/stack/unwind/unwind_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func registerToString(reg uint64, arch elf.Machine) string {
}

// PrintTable is a debugging helper that prints the unwinding table to the given io.Writer.
func (ptb *UnwindTableBuilder) PrintTable(writer io.Writer, logger log.Logger, path string, compact bool, pc *uint64) error {
func (ptb *UnwindTableBuilder) PrintTable(logger log.Logger, writer io.Writer, path string, compact bool, pc *uint64) error {
fdes, arch, err := ReadFDEs(path)
if err != nil {
return err
Expand Down
12 changes: 8 additions & 4 deletions pkg/stack/unwind/unwind_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@
package unwind

import (
"os"
"testing"

"github.com/go-kit/log"
"github.com/stretchr/testify/require"

"github.com/parca-dev/parca-agent/internal/dwarf/frame"
"github.com/parca-dev/parca-agent/pkg/logger"
)

// TODO(Sylfrena): Add equivalent test for arm64
func TestBuildUnwindTable(t *testing.T) {
fdes, _, err := ReadFDEs("../../../testdata/out/x86/basic-cpp")
require.NoError(t, err)

logger := logger.NewLogger("error", logger.LogFormatLogfmt, "unwind-table-tests")
logger := log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr))
logger = log.With(logger, "component", "unwind table test")
unwindContext := frame.NewContext(logger, "../../../testdata/out/x86/basic-cpp")

unwindTable := BuildUnwindTable(unwindContext, fdes)
Expand All @@ -53,7 +55,8 @@ func TestSpecialOpcodes(t *testing.T) {
},
}

logger := logger.NewLogger("error", logger.LogFormatLogfmt, "unwind-table-tests")
logger := log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr))
logger = log.With(logger, "component", "unwind table test")

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -75,7 +78,8 @@ func benchmarkParsingDWARFUnwindInformation(b *testing.B, executable string) {

var rbpOffset int64

logger := logger.NewLogger("error", logger.LogFormatLogfmt, "unwind-table-tests")
logger := log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr))
logger = log.With(logger, "component", "unwind table test")

for n := 0; n < b.N; n++ {
fdes, _, err := ReadFDEs(executable)
Expand Down

0 comments on commit ecf0036

Please sign in to comment.