llvm-symbolizer will consult one of the .dSYM paths passed via -dsym-hint if it fails to find the .dSYM bundle at the default location.
Details
Diff Detail
Event Timeline
Sorry, wasn't able to carefully review it today. Some early feedback.
Note that you will need tests in test/DebugInfo/ (add actual .dSYM bundles and macho files you're trying to symbolize under test/DebugInfo/, preferrably with sources and comments describing how to build them).
LLVMSymbolize.cpp | ||
---|---|---|
215 ↗ | (On Diff #14660) | Why all this complexity? Can you just change this function to take .dSYM bundle, and call it either on file from .dSYM hints argument, or from PathToExe + ".dSYM"? |
329 ↗ | (On Diff #14660) | This can be a static helper, pass Opts.DynamicHints here. |
llvm-symbolizer.cpp | ||
34 ↗ | (On Diff #14660) | Please update docs/CommandGuide/llvm-symbolizer.rst |
130 ↗ | (On Diff #14660) | Additional method looks like an overkill. Opts is a struct, you can just call Opts.DsymHints.assign(ClDsymHint.begin(), ClDsymHint.end()); |
Don't you think the tests for commandline args should go into tets/tools/llvm-symbolizer instead?
LLVMSymbolize.cpp | ||
---|---|---|
215 ↗ | (On Diff #14660) | We probably don't want to try those paths from -dsym-hints that don't end with ".dSYM" |
329 ↗ | (On Diff #14660) | Agreed. |
llvm-symbolizer.cpp | ||
34 ↗ | (On Diff #14660) | Done |
130 ↗ | (On Diff #14660) | Done |
LLVMSymbolize.cpp | ||
---|---|---|
215 ↗ | (On Diff #14660) | Hmm, the following workflow still doesn't work: $ clang foo.c -g -c && clang foo.o -g -o foo $ dsymutil foo -o bar.dSYM Turns out the DWARF binary for foo is at bar.dSYM/Contents/Resources/DWARF/foo. |
329 ↗ | (On Diff #14660) | Actually, no. This function needs Opts.DsymHints. |
Sorry the last comment has been lost in time. The updated diff fixes the problem mentioned in http://reviews.llvm.org/D5705?id=14660#inline-47195
I'm not sure if adding user-facing Verbosity option is a good idea, in this patch it looks merely like a debugging aid.
If we decide to introduce it, I'd prefer a separate patch, with a careful audit of all existing code and reasonable decisions of what and when to print (for instance, it makes sense to print our steps in attempt to resolve .gnu_debuglink).
docs/CommandGuide/llvm-symbolizer.rst | ||
---|---|---|
18 | Existing options are already listed below (after EXAMPLE) | |
31 | Please specify that this flag may be provided multiple times and that it's relevant only for Mac OS. | |
tools/llvm-symbolizer/LLVMSymbolize.cpp | ||
218 | Looks like unfinished sentence. | |
304–375 | Looks like this routine is generally usable and should reside somewhere in libLLVMObject. At the very least, add a FIXME about it. | |
305 | dyn_cast may return null. Either handle this, or take MachOObjectFile as an input argument. | |
320 | static | |
329 | I still think this should be a static helper, which should take Opts.DsymHints as an argument. Also, consider checking --dsym_hint values in the main binary (probably, even reporting an error is incorrect value is passed there), so that "Opts.DsymHints" are always reasonable. | |
331 | Variable names should start with capital letter. | |
335 | const auto &path | |
346 | DsymPaths | |
362 | just use "else if" here. | |
368 | You can use EC.message() - this can be a different kind of error. | |
376–377 | Please get rid of Bin/DbgBin here, use local variables with small scope where appropriate instead. | |
380–381 | So, you have this sequence scattered throughout the code (at least three times): OwningBinary<Binary> B = std::move(BinaryOrErr.get()); Bin = B.getBinary().get(); Obj = getObjectFileFromBinary(Bin, ArchName); Can it be simplified or moved to a function? | |
391 | if (!DbgObj) ? | |
tools/llvm-symbolizer/LLVMSymbolize.h | ||
66 | BinaryPair is unused now. | |
93 | typedef is not really needed now in C++11 world. ObjectPairForPathArchTy::iterator can be replaced with auto. |
Addressed the comments.
WDYT is better: a) commit the binaries and .dSYM files for testing to the repository, or b) generate them on the fly?
docs/CommandGuide/llvm-symbolizer.rst | ||
---|---|---|
18 | Indeed. Sorry, I've missed those. | |
31 | Done. | |
tools/llvm-symbolizer/LLVMSymbolize.cpp | ||
218 | Good catch, fixed. | |
304–375 | Sent http://reviews.llvm.org/D5752 for review | |
305 | Done | |
320 | Done | |
329 | I've moved the check for ".dSYM" extension to the main binary, so this function has become really small now. | |
331 | Done (hope I've fixed them all) | |
335 | done | |
346 | done | |
362 | Removed Opts.Verbose instead. | |
368 | Ok, but I've removed Opts.Verbose. | |
376–377 | Moved them 1-2 scopes down. | |
380–381 | I've tried to compactify these a bit. | |
391 | Fixed | |
tools/llvm-symbolizer/LLVMSymbolize.h | ||
66 | Removed. | |
93 | Removed typedefs except for ObjectPair which is used in several class members' declarations. |
I think we should check in .dSYM binaries - IIUC we can't generate these files unless we have dsymutil installed in the system (and we certainly don't have it on Linux).
test/tools/llvm-symbolizer/Inputs/dsym-test.c | ||
---|---|---|
1 | Please provide a comment with sequence of compiler / dsymutil invocations yielding the all the binaries you check in to Inputs/ |
test/tools/llvm-symbolizer/Inputs/dsym-test.c | ||
---|---|---|
2 | Do you need to add lit.local.cfg to this directory to exclude .c files from testsuite? | |
tools/llvm-symbolizer/LLVMSymbolize.cpp | ||
101 | SymbolIterator | |
327 | Is it OK for a binary to not have UUID command? I think that if the object is well-formed, but doesn't have UUID command, you shouldn't use error() wrapper, as it prints error messages to stderr. | |
334 | Probably it's ok to even sink this function down to lookUpDsymFile (I don't see how it can be generally useful). | |
337 | ResourcePath (or just get rid of local variable). | |
347 | This variable is not used. | |
383 | Please check that the code works if Obj is nullptr | |
386 | if (auto MachObj = dyn_cast<const MachOObjectFile>(Obj)) DbgObj = ...; | |
tools/llvm-symbolizer/LLVMSymbolize.h | ||
95 | Thanks for the typedef cleanup. You may want to commit it separately as a cleanup change before the main patch. | |
130 | Please define each member on a separate line. | |
tools/llvm-symbolizer/llvm-symbolizer.cpp | ||
132 | You may want to print the invalid flag value here. |
test/tools/llvm-symbolizer/Inputs/dsym-test.c | ||
---|---|---|
1 | Done | |
2 | I think no, lit doesn't attempt to run this file. | |
tools/llvm-symbolizer/LLVMSymbolize.cpp | ||
101 | Fixed in r219682. | |
327 | No, it's not ok. However this code has changed in the latest version of the patch. | |
334 | Done | |
337 | Done | |
347 | Removed. | |
383 | It should. I've inserted a return statement just for the case. | |
386 | Done | |
tools/llvm-symbolizer/LLVMSymbolize.h | ||
95 | Done in r219682. | |
130 | Fixed in r219682. | |
tools/llvm-symbolizer/llvm-symbolizer.cpp | ||
132 | Done. |
LGTM, once the following minor comments are addressed.
Please run the patch through clang-format-diff before submitting. Thanks for working on this!
tools/llvm-symbolizer/LLVMSymbolize.cpp | ||
---|---|---|
321 | s/path/Path | |
385 | We still need to cache (nullptr, nullptr) pair in ObjectPairForPathArch. For example, if the path is invalid and provided 50 times, we don't want to print diagnostics 50 times in error() function. So, at least in the way the code is structured now, we'll have to increase the indentation. | |
385–386 | Do you need this check now? Looks like it's enough to check that Obj is a MachOObjectFile (and you won't need "Bin" variable in this case). |
Existing options are already listed below (after EXAMPLE)