Closed
Description
DWARF generation is completely disabled on darwin/arm and darwin/arm64. There's a
*ld.FlagW = true // disable DWARF generation
in cmd/link/internal/arm*/obj.go for objabi.Hdarwin. Blindly deleting those lines doesn't result in errors, but doesn't improve Xcode backtrace in my informal crash test.
This issue is about enabling (and testing) DWARF generation on darwin/arm and darwin/arm64 to enjoy the same debugging benefits on iOS as other DWARF-enabled platforms. For example, DWARF probably helps #22716.
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
steeve commentedon Apr 16, 2018
Can you output a
dwarfdump -a --arch=arm64
of the generated file?eliasnaur commentedon Apr 16, 2018
Sure.
dwarfdump-arm64.txt
steeve commentedon Apr 16, 2018
Looking at it, the data is there, but the values seem... weird:
steeve commentedon Apr 16, 2018
Another instance:
steeve commentedon Apr 16, 2018
I'm guessing it was disabled because the generation part is skipped (the
0
s indicate default struct values)cherrymui commentedon Apr 16, 2018
cmd/go also disables dwarf generation in the compiler:
https://go.googlesource.com/go/+/04a27bef6f2c96251161d63761617542ddc762bc/src/cmd/go/internal/work/gc.go#93
If DWARF works on these platforms, we should also enable the compiler part.
steeve commentedon Apr 16, 2018
I've tried applying the following diff to Go tip, doing what @cherrymui suggested:
However, the information, while there, is incomplete, addresses are wrong (they look uninitialized):
gopherbot commentedon Apr 19, 2018
Change https://golang.org/cl/108295 mentions this issue:
cmd/link, cmd/go: enable DWARF on darwin/arm and darwin/arm64
cherrymui commentedon Apr 19, 2018
Does iOS debugging tools use DWARF? (I'm asking as I don't know why DWARF was disabled on those platforms -- is it because we didn't support it, or because there was no tool use it so no need to do it?)
I tried to enable DWARF on darwin/arm and arm64. I put up a CL https://golang.org/cl/108295. With that CL, it generates DWARF and the DWARF looks reasonable on ARM (32-bit).
But for ARM64, there is some problem. The low PCs for functions look correct (I checked with objdump), but the high PCs don't (e.g. they are even smaller than low PC). There might be other problems, I don't know yet.
Before I look into the detail, I would want to make sure the DWARF are useful for those platforms.
steeve commentedon Apr 19, 2018
steeve commentedon Apr 19, 2018
eliasnaur commentedon Apr 19, 2018
With 108295 applied, darwin/arm backtraces looks good now:
Very promising. On darwin/arm64, it is not quite as well:

Both traces are without the arm64 framepointer CL applied.
5 remaining items
eliasnaur commentedon Apr 20, 2018
Perhaps we're talking about different kinds of traces? I'm referring to the traces seen in Xcode, not the traces from the Go runtime.
eliasnaur commentedon Apr 20, 2018
Compiling to c-archives, it seems both AT_low_pc and AT_high_pc are wrong on arm64.
For arm:
For arm64:
Not sure where to go next, though.
gopherbot commentedon Apr 21, 2018
Change https://golang.org/cl/108655 mentions this issue:
cmd/link: remove R_ADDR relocation workaround for macho arm64
eliasnaur commentedon Apr 21, 2018
WIth CL 108655, the addresses from dwarfdump seem correct and stack traces look good in Xcode on darwin/arm64.
cmd/link: remove R_ADDR relocation workaround for macho arm64
steeve commentedon Apr 27, 2018
I'm happy to report that breakpoints work (note the local var

i
):eliasnaur commentedon Apr 27, 2018
Is the problem with wrong traces in the panic() case iOS specific? It seems to me that it could occur on the desktop platforms as well. If so, feel free to open another issue about that. If the problem covers all platforms it might be fixed quicker.
steeve commentedon Apr 27, 2018
@eliasnaur indeed I do think this is the same on all platform, will do!
biscottigelato commentedon Jun 1, 2018
Is all this applicable to gomobile bind? I tried to grab master as of today, which should include both commits mentioned above. I also set *ld.FlagW to false. But a dwarfdump on my .framework gave me nothing. And of course the framework did not get symbolicated upon a crash or a breakpoint. Please advise. Thanks!
eliasnaur commentedon Jun 1, 2018
It should work, as seen from the discussion. This issue is closed, please open a new one with detailed steps to reproduce the problem. Thanks. If you like, CC me on the issue.