diff options
| author | Joey Jiao <joeyjiaojg@gmail.com> | 2021-03-18 12:25:10 +0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-03-18 09:17:51 +0100 |
| commit | c753ca8ef9b9cae42f9f8ebed5a73b47511b2698 (patch) | |
| tree | ba287c5c40c4b65f07d6d329e6d82df2784633d3 /pkg | |
| parent | 4ca2935d663453b098b895ae56a309f3efb6a4b9 (diff) | |
pkg/cover: objDir is not necessary for cleanPath
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/cover/backend/elf.go | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/pkg/cover/backend/elf.go b/pkg/cover/backend/elf.go index 3e8693fae..9ed0c79ba 100644 --- a/pkg/cover/backend/elf.go +++ b/pkg/cover/backend/elf.go @@ -99,7 +99,7 @@ func makeELF(target *targets.Target, objDir, srcDir, buildDir string, continue // drop the unit } // TODO: objDir won't work for out-of-tree modules. - unit.Name, unit.Path = cleanPath(unit.Name, objDir, srcDir, buildDir) + unit.Name, unit.Path = cleanPath(unit.Name, srcDir, buildDir) allUnits[nunit] = unit nunit++ } @@ -370,7 +370,6 @@ func symbolizeModule(target *targets.Target, srcDir, buildDir string, mod *Modul i = end } close(pcchan) - objDir := filepath.Dir(mod.Path) var err0 error var frames []Frame for p := 0; p < procs; p++ { @@ -379,7 +378,7 @@ func symbolizeModule(target *targets.Target, srcDir, buildDir string, mod *Modul err0 = res.err } for _, frame := range res.frames { - name, path := cleanPath(frame.File, objDir, srcDir, buildDir) + name, path := cleanPath(frame.File, srcDir, buildDir) frames = append(frames, Frame{ Module: mod, PC: frame.PC + mod.Addr, @@ -536,13 +535,9 @@ func parseLine(callInsns, traceFuncs [][]byte, ln []byte) uint64 { return pc } -func cleanPath(path, objDir, srcDir, buildDir string) (string, string) { +func cleanPath(path, srcDir, buildDir string) (string, string) { filename := "" switch { - case strings.HasPrefix(path, objDir): - // Assume the file was built there. - path = strings.TrimPrefix(path, objDir) - filename = filepath.Join(objDir, path) case strings.HasPrefix(path, buildDir): // Assume the file was moved from buildDir to srcDir. path = strings.TrimPrefix(path, buildDir) |
