Repository navigation
Description
What version of pprof are you using?
Built from source at 4d45320 (current main). Also present in the copy the Go
toolchain vendors, at src/cmd/vendor/github.com/google/pprof/internal/binutils/binutils.go:139,
so go tool pprof behaves the same way.
go version go1.26.5 windows/amd64
What operating system and processor architecture are you using?
Windows 10 Pro 19045, amd64. Object tools are GNU binutils from MinGW-w64 in
C:\mingw64\bin.
What did you do?
Passed a directory to -tools the way the flag documents it, so that the
directory is searched for every object tool:
$ pprof -tools 'C:\mingw64\bin' -disasm 'main' profgen.exe cpu.prof
C:\mingw64\bin was removed from PATH first, so the flag is the only way
pprof can find objdump, nm and addr2line.
What did you expect to see?
The disassembly, the same output produced when the tools are reachable through
PATH:
$ pprof -disasm 'main' profgen.exe cpu.prof
Total: 1.24s
ROUTINE ======================== main.main
1.23s 1.24s (flat, cum) 100% of Total
. . 1400cafa0: cmp 0x10(%r14),%rsp ;<main.main>
What did you see instead?
$ pprof -tools 'C:\mingw64\bin' -disasm 'main' profgen.exe cpu.prof
pprof: no matches found for regexp main
No warning that the directory was discarded. Spelling the tools out one by one
works, which is what pointed at the cause:
$ pprof -tools 'objdump:C:\mingw64\bin,nm:C:\mingw64\bin,addr2line:C:\mingw64\bin' -disasm 'main' profgen.exe cpu.prof
Total: 1.24s
ROUTINE ======================== main.main
1.23s 1.24s (flat, cum) 100% of Total
. . 1400cafa0: cmp 0x10(%r14),%rsp ;<main.main>
initTools in internal/binutils/binutils.go:137-143 reads each comma
separated entry as name:path:
for _, t := range strings.Split(config, ",") {
name, path := "", t
if ct := strings.SplitN(t, ":", 2); len(ct) == 2 {
name, path = ct[0], ct[1]
}
paths[name] = append(paths[name], path)
}Every absolute Windows path carries a colon after the drive letter, so
C:\mingw64\bin splits into name C and path \mingw64\bin. The directory is
filed under a tool named C, which nothing ever looks up, and paths[""] stays
empty. pprof then behaves as though -tools had not been passed at all. The
name:path form survives because SplitN with a limit of 2 leaves the drive
letter inside the path.
PPROF_TOOLS reads through the same function, so setting
PPROF_TOOLS=C:\mingw64\bin is discarded in the same way.
A relative path such as -tools mingw64\bin works, since there is no colon to
split on. Absolute paths on Linux and macOS carry no colon either, so they land
in the default list, which is likely why this has not come up before. I have
only run this on Windows.
One fix that stays platform neutral: treat the prefix as a tool name only when
it is one of the names initTools actually looks up (llvm-symbolizer,
addr2line, nm, objdump), and otherwise take the whole entry as a path.
Today a prefix like foo: is accepted and then silently ignored, so tightening
it costs nothing. Checking for a single letter before the colon on Windows would
also work, though it only covers drive letters.
Happy to send a PR with tests if you want it fixed this way, or a different way
if you prefer.
Activity
aalexand commentedon Aug 30, 2026
I think this is cleaner. We can check
nameagainst the three strings and concat the string back if it doesn't match the known tool name. Happy to review a PR (please add a test and add a sentence or two about the motivation.One caveat is that if someone makes a typo in the tool name, the whole
<name>:<path>string will become a path to search now while previously it would effectively be ignored. But this is kind of a pre-existing problem and things don't get much worse.Alternatively, we could only do the concat-back hack if
nameis a single character, as you say. I don't have a strong preference.