Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for LLVM objdump #534

Merged
merged 8 commits into from
Jun 15, 2020
Merged

Add support for LLVM objdump #534

merged 8 commits into from
Jun 15, 2020

Conversation

kalyanac
Copy link
Contributor

@kalyanac kalyanac commented May 6, 2020

Adds support for LLVM objdump

kalyanac and others added 5 commits February 4, 2019 21:12
When a binary provided to pprof has no symbols, it is not recognized as a binary. This happens because the err value is only checked against 'nil'.

This PR fixes this issue by checking the err value against elf.ErrNoSymbols in addition to nil.
Recognize an executable without symbols
pull from remote master
@googlebot
Copy link
Collaborator

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@kalyanac kalyanac force-pushed the mac_disasm branch 2 times, most recently from c470b1e to e072f4a Compare May 6, 2020 18:20
@googlebot
Copy link
Collaborator

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot removed the cla: no label May 6, 2020
@googlebot
Copy link
Collaborator

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@kalyanac
Copy link
Contributor Author

kalyanac commented May 6, 2020

Failures unrelated. Restarted the jobs

@kalyanac
Copy link
Contributor Author

gentle ping.

@aalexand
Copy link
Collaborator

It feels that the PR description doesn't tell the full story. There is no binutils version 9.0, that seems LLVM objdump. It seems that what we are trying to dispatch on here is binutils vs. LLVM objdump, so the PR description and the code change should be centered around that IMO.

@@ -120,6 +121,29 @@ func (bu *Binutils) SetTools(config string) {
bu.update(func(r *binrep) { initTools(r, config) })
}

func ensureObjdumpVersion(objdump string, objdumpFound bool) (string, bool) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer top-down function order in Go - place this function after its use, i.e. after initTools.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -189,14 +191,39 @@ func skipUnlessDarwinAmd64(t *testing.T) {
}

func testDisasm(t *testing.T, intelSyntax bool) {
if runtime.GOOS == "darwin" {
// get objdump version and skip test if < 9.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: get -> Get (proper sentences for comments).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@MaskRay
Copy link
Contributor

MaskRay commented May 17, 2020

Thanks for the patch! As Alexey noted, this patch with a few tweaks can work with llvm-objdump on other (non-Mac) platforms. Both rupprecht and I have made some UI improvements to llvm-objdump 10. llvm-objdump 10 may be closer to GNU objdump. (The function:line pattern just looks like GNU objdump's output)

Consider using --version (instead of Sun-style -version). GNU objdump doesn't accept -version. Latest llvm-objdump does not accept -version, either.

@kalyanac kalyanac force-pushed the mac_disasm branch 2 times, most recently from cda73ae to 853e9d0 Compare May 19, 2020 06:09
@kalyanac
Copy link
Contributor Author

It feels that the PR description doesn't tell the full story. There is no binutils version 9.0, that seems LLVM objdump. It seems that what we are trying to dispatch on here is binutils vs. LLVM objdump, so the PR description and the code change should be centered around that IMO.

The PR description states objdump version should be at least 9.0, not binutils. This is from OS X core (pkgid: com.apple.pkg.Core) and not the homebrew binutils, which packages GNU tools.

Yes, this is (Apple) LLVM objdump. This PR is only to add support for the objdump installed with XCode.

objdump -version
Apple LLVM version 10.0.0 (clang-1000.11.45.5)

LLVM objdump support for Linux should be a separate, probably small, PR.

@kalyanac
Copy link
Contributor Author

Thanks for the patch! As Alexey noted, this patch with a few tweaks can work with llvm-objdump on other (non-Mac) platforms. Both rupprecht and I have made some UI improvements to llvm-objdump 10. llvm-objdump 10 may be closer to GNU objdump. (The function:line pattern just looks like GNU objdump's output)

A separate PR will add support for LLVM objdump for non-Mac platforms.

Consider using --version (instead of Sun-style -version). GNU objdump doesn't accept -version. Latest llvm-objdump does not accept -version, either.

objdump on Mac seems to support the --version format but does not document it. --help only uses the single dash format.

I am not too familiar with how Apple changes their code from LLVM, so I figured it is safe to stay with documented flags.

@codecov-commenter
Copy link

codecov-commenter commented May 19, 2020

Codecov Report

Merging #534 into master will increase coverage by 0.00%.
The diff coverage is 72.72%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #534   +/-   ##
=======================================
  Coverage   68.33%   68.33%           
=======================================
  Files          39       39           
  Lines        8005     8044   +39     
=======================================
+ Hits         5470     5497   +27     
- Misses       2114     2120    +6     
- Partials      421      427    +6     
Impacted Files Coverage Δ
internal/binutils/binutils.go 58.89% <70.00%> (+1.09%) ⬆️
internal/binutils/disasm.go 89.61% <100.00%> (+0.56%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 163a225...8119593. Read the comment docs.

@aalexand
Copy link
Collaborator

The PR description states objdump version should be at least 9.0, not binutils. This is from OS X core (pkgid: com.apple.pkg.Core) and not the homebrew binutils, which packages GNU tools.

objdump is part of binutils package on Linux. On a Mac machine objdump can come either from LLVM or from binutils. We should check for whether objdump being used is from LLVM or from binutils, not for the version.

@kalyanac
Copy link
Contributor Author

Some Mac combinations which were not tested in CI

$ ./objdump --version
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  Optimized build.
  Default target: x86_64-apple-darwin19.4.0
  Host CPU: skylake
....

$> PATH=./ /usr/local/go/bin/go test -v
...
=== RUN   TestDisasm
--- PASS: TestDisasm (0.03s)
=== RUN   TestObjFile
    TestObjFile: binutils_test.go:181: This test only works on x86-64 Linux
--- SKIP: TestObjFile (0.00s)
$ objdump --version
Apple LLVM version 11.0.3 (clang-1103.0.32.62)
  Optimized build.
  Default target: x86_64-apple-darwin19.4.0
  Host CPU: skylake
...

$ /usr/local/go/bin/go test -v
...
=== RUN   TestDisasm
--- PASS: TestDisasm (0.08s)
=== RUN   TestObjFile
    TestObjFile: binutils_test.go:181: This test only works on x86-64 Linux
--- SKIP: TestObjFile (0.00s)
....

@kalyanac
Copy link
Contributor Author

Failures are due to timeouts. PR can be reviewed

internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/disasm.go Show resolved Hide resolved
internal/binutils/binutils_test.go Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
@kalyanac kalyanac force-pushed the mac_disasm branch 2 times, most recently from cb2b584 to 478ecfd Compare May 28, 2020 23:09
@kalyanac
Copy link
Contributor Author

Failures due to timeout, restarted. Code ok to review.

@kalyanac
Copy link
Contributor Author

kalyanac commented Jun 1, 2020

gentle ping.

internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
@kalyanac kalyanac force-pushed the mac_disasm branch 2 times, most recently from b0bc32b to ed96624 Compare June 3, 2020 02:52
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils_test.go Outdated Show resolved Hide resolved
internal/binutils/binutils_test.go Outdated Show resolved Hide resolved
internal/binutils/binutils_test.go Outdated Show resolved Hide resolved
@kalyanac kalyanac force-pushed the mac_disasm branch 2 times, most recently from 1edfed9 to ee01eb1 Compare June 8, 2020 17:30
@kalyanac
Copy link
Contributor Author

kalyanac commented Jun 8, 2020

PTAL. All test passed before the latest merge. The latest merge is only a comment change, no functional changes. Code can be reviewed.

@kalyanac
Copy link
Contributor Author

kalyanac commented Jun 8, 2020

Restarted timedout tests.

Copy link
Collaborator

@aalexand aalexand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, probably last round of minor style nits. Thanks for bearing with the comments.

internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils.go Outdated Show resolved Hide resolved
internal/binutils/binutils_test.go Outdated Show resolved Hide resolved
internal/binutils/binutils_test.go Outdated Show resolved Hide resolved
internal/binutils/binutils_test.go Outdated Show resolved Hide resolved
internal/binutils/binutils_test.go Outdated Show resolved Hide resolved
internal/binutils/disasm_test.go Outdated Show resolved Hide resolved
@kalyanac
Copy link
Contributor Author

Restarted timed out tests.

Code is ready for review, PTAL.

Thanks for bearing with the comments.

Thank you for patiently providing the thoughtful reviews.

@kalyanac
Copy link
Contributor Author

Gentle ping

@aalexand aalexand merged commit 03e1cf3 into master Jun 15, 2020
@kalyanac kalyanac deleted the mac_disasm branch June 16, 2020 00:16
giordano added a commit to JuliaPackaging/Yggdrasil that referenced this pull request Nov 13, 2020
* Update pprof to latest revision

Bump from 20191205061153 => 20201109224723

My personal interest is to pull in google/pprof#564, which adds support for displaying names with `"` in them, which julia functions sometimes have (e.g. `var"#foo#23"`)

Includes:
- google/pprof#564
- google/pprof#575
- google/pprof#574
- google/pprof#571
- google/pprof#572
- google/pprof#570
- google/pprof#562
- google/pprof#561
- google/pprof#565
- google/pprof#560
- google/pprof#563
- google/pprof#557
- google/pprof#554
- google/pprof#552
- google/pprof#545
- google/pprof#549
- google/pprof#547
- google/pprof#541
- google/pprof#534
- google/pprof#542
- google/pprof#535
- google/pprof#531
- google/pprof#530
- google/pprof#528
- google/pprof#522
- google/pprof#525
- google/pprof#527
- google/pprof#519
- google/pprof#520
- google/pprof#517
- google/pprof#518
- google/pprof#514
- google/pprof#513
- google/pprof#510
- google/pprof#508
- google/pprof#506
- google/pprof#509
- google/pprof#504

* Update P/pprof/build_tarballs.jl - use a real version number

Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>

* Remove now unused `timestamp`

* [pprof] Use `GitSource`

Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
gmarin13 pushed a commit to gmarin13/pprof that referenced this pull request Dec 17, 2020
Add support for LLVM objdump.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants