This is an archive of the discontinued LLVM Phabricator instance.

[Debug-Info] implement -gstrict-dwarf
ClosedPublic

Authored by shchenz on Apr 19 2021, 8:19 PM.

Details

Summary

This patch implements -gstrict-dwarf option in clang FE.

We had this option in clang code base just not used it.

We plan to verify the DWARF info based on DWARF 3.

Diff Detail

Event Timeline

shchenz created this revision.Apr 19 2021, 8:19 PM
shchenz requested review of this revision.Apr 19 2021, 8:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2021, 8:19 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
dblaikie added inline comments.Apr 19 2021, 9:30 PM
clang/docs/ClangCommandLineReference.rst
3549–3550

This description is probably backwards/doesn't explicitly clarify which version of the flag does which behavior.

I guess the only nearby example is the -gembed-source, which describes the effect of -gembed-source, not the effect of -gno-embed-source.

clang/lib/Driver/ToolChains/Clang.cpp
3973–3974

@aprantl or anyone else - is this the right use of checkDebugInfoOption? I forget what it's for/how it should be used.

clang/test/Driver/debug-options.c
329–330

"STRICT" v "G_STRICT" seems confusing to me - how do other flags differentiate their positive/negative tests? (looks like GNO_X/GX or GX/NOX, etc - something like that'd be good)

shchenz updated this revision to Diff 338752.Apr 20 2021, 1:25 AM
shchenz marked 2 inline comments as done.

address @dblaikie comments.

clang/lib/Driver/ToolChains/Clang.cpp
3973–3974

See the nearby example for -gcolumn-info:

if (const Arg *A = Args.getLastArg(options::OPT_gcolumn_info))
  (void)checkDebugInfoOption(A, Args, D, TC)
clang/test/Driver/debug-options.c
329–330

use the similar way like GPUB & NOPUB

Nit on the description, this patch supports -gstrict-dwarf in the frontend.

clang/docs/ClangCommandLineReference.rst
3549–3550

Maybe something like, "Restrict DWARF features to those defined in the specified version, avoiding features from later versions."

clang/lib/Driver/ToolChains/Clang.cpp
3973–3974

It's a wrapper for ToolChain::supportsDebugInfoOption() and the only implementation I see is for Cuda, which has severely limited support for the g options. I think this is correct.

dblaikie accepted this revision.Apr 20 2021, 10:10 AM

Sounds good

This revision is now accepted and ready to land.Apr 20 2021, 10:10 AM
aprantl accepted this revision.Apr 21 2021, 9:53 AM
shchenz edited the summary of this revision. (Show Details)Apr 21 2021, 8:22 PM

Thanks for your review! @probinson @dblaikie @aprantl

clang/docs/ClangCommandLineReference.rst
3549–3550

Thanks, will update in the commit

This revision was automatically updated to reflect the committed changes.