hintonda added a comment. In https://reviews.llvm.org/D36347#908186, @zturner wrote:
> Do I understand correctly that this will insert breakpoints on *all* clang > diagnostics? That's not necessarily bad, but I was under the impression > originally that it would let you pick the diagnostics you wanted to insert > breakpoints on. `clangdiag enable` sets a breakpoint in `DiagnosticsEngine::Report` and adds a callback. The callback passed the value of DiagID to diagtool to get the enum spelling of the DiagID, e.g., `err_undeclared_var_use`, then calls `BreakpointCreateBySourceRegex` with that string and and empty `FileSpec` to set breakpoints in every location that string is seen -- specifically, we use "diag::err_undeclared_var_use` for this case. Now, that might add a few more breakpoints than actually needed, but not many, and only rarely in places that were actually covered by this particular run. Also, since we add the breakpoint after it was seen -- `DiagnosticsEngine::Report` is called later, and sometimes much later, you'll need to run the debugger again to actually hit all the breakpoints. > Also, What is the workflow for using the "clangdiag diagtool" subcommand? > Would you have to do two steps, `clangdiag enable` and then `clangdiag > diagtool`? If so, maybe it could just be `clangdiag enable --diagtool=<path>` I put `command script import /Users/dhinton/projects/llvm_project/llvm/tools/clang/utils/clangdiag.py` in my `~/.lldbinit` file, so here's an example of how I use it: $ lldb bin/clang-6.0 The "clangdiag" command has been installed, type "help clangdiag" or "clangdiag --help" for detailed help. (lldb) target create "bin/clang-6.0" Current executable set to 'bin/clang-6.0' (x86_64). (lldb) clangdiag diagtool diagtool = /Users/dhinton/projects/llvm_project/build/Debug/bin/diagtool (lldb) clangdiag diagtool /bad/path/xx clangdiag: /bad/path/xx not found. diagtool = /Users/dhinton/projects/llvm_project/build/Debug/bin/diagtool (lldb) clangdiag diagtool /Users/dhinton/projects/monorepo/build/Debug/bin/diagtool diagtool = /Users/dhinton/projects/monorepo/build/Debug/bin/diagtool (lldb) clangdiag diagtool reset diagtool = /Users/dhinton/projects/llvm_project/build/Debug/bin/diagtool (lldb) clangdiag enable (lldb) br l Current breakpoints: 1: name = 'DiagnosticsEngine::Report', locations = 33 Breakpoint commands (Python): return clangdiag.setDiagBreakpoint(frame, bp_loc, internal_dict) Names: clang::Diagnostic 1.1: where = clang-6.0`clang::DiagnosticsEngine::Report(unsigned int) + 38 at Diagnostic.h:1215, address = clang-6.0[0x0000000100022cd6], unresolved, hit count = 0 1.2: where = clang-6.0`clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned int) + 46 at Diagnostic.h:1207, address = clang-6.0[0x000000010002c6ce], unresolved, hit count = 0 <...snip...> (lldb) clangdiag disable (lldb) br l No breakpoints currently set. (lldb) clangdiag enable (lldb) br l Current breakpoints: 2: name = 'DiagnosticsEngine::Report', locations = 33 Breakpoint commands (Python): return clangdiag.setDiagBreakpoint(frame, bp_loc, internal_dict) Names: clang::Diagnostic 2.1: where = clang-6.0`clang::DiagnosticsEngine::Report(unsigned int) + 38 at Diagnostic.h:1215, address = clang-6.0[0x0000000100022cd6], unresolved, hit count = 0 2.2: where = clang-6.0`clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned int) + 46 at Diagnostic.h:1207, address = clang-6.0[0x000000010002c6ce], unresolved, hit count = 0 <...snip...> (lldb) run <...> #### might hit one of the new breakpoints if they are seen more than once (lldb) run #### should hit all the breakpoints for which diagnostics were produced (lldb) br l Current breakpoints: 2: name = 'DiagnosticsEngine::Report', locations = 33, resolved = 33, hit count = 5 Breakpoint commands (Python): return clangdiag.setDiagBreakpoint(frame, bp_loc, internal_dict) Names: clang::Diagnostic 2.1: where = clang-6.0`clang::DiagnosticsEngine::Report(unsigned int) + 38 at Diagnostic.h:1215, address = 0x0000000100022cd6, resolved, hit count = 0 2.2: where = clang-6.0`clang::DiagnosticsEngine::Report(clang::SourceLocation, unsigned int) + 46 at Diagnostic.h:1207, address = 0x000000010002c6ce, resolved, hit count = 0 <...snip...> 3: source regex = "err_unknown_typename", exact_match = 0, locations = 6, resolved = 6, hit count = 2 Names: clang::Diagnostic 3.1: where = libclangSema.dylib`clang::Sema::DiagnoseUnknownTypeName(clang::IdentifierInfo*&, clang::SourceLocation, clang::Scope*, clang::CXXScopeSpec*, clang::OpaquePtr<clang::QualType>&, bool) + 1721 at SemaDecl.cpp:677, address = 0x0000000111553ee9, resolved, hit count = 0 <...snip...> 4: source regex = "warn_return_missing_expr", exact_match = 0, locations = 1, resolved = 1, hit count = 0 Names: clang::Diagnostic 4.1: where = libclangSema.dylib`clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*) + 3149 at SemaStmt.cpp:3489, address = 0x0000000111db1c6d, resolved, hit count = 0 <...snip...> 5: source regex = "err_expected_lparen_after", exact_match = 0, locations = 39, resolved = 39, hit count = 0 Names: clang::Diagnostic 5.1: where = libclangParse.dylib`clang::Parser::ConsumeAndStoreFunctionPrologue(llvm::SmallVector<clang::Token, 4u>&) + 527 at ParseCXXInlineMethods.cpp:786, address = 0x0000000110fd74df, resolved, hit count = 0 <...snip...> 6: source regex = "err_undeclared_var_use", exact_match = 0, locations = 11, resolved = 11, hit count = 0 Names: clang::Diagnostic 6.1: where = libclangSema.dylib`clang::Sema::BuildCXXNestedNameSpecifier(clang::Scope*, clang::Sema::NestedNameSpecInfo&, bool, clang::CXXScopeSpec&, clang::NamedDecl*, bool, bool*, bool) + 5820 at SemaCXXScopeSpec.cpp:630, address = 0x0000000111440ddc, resolved, hit count = 0 <...snip...> 7: source regex = "err_unknown_typename", exact_match = 0, locations = 6, resolved = 6, hit count = 1 Names: clang::Diagnostic 7.1: where = libclangSema.dylib`clang::Sema::DiagnoseUnknownTypeName(clang::IdentifierInfo*&, clang::SourceLocation, clang::Scope*, clang::CXXScopeSpec*, clang::OpaquePtr<clang::QualType>&, bool) + 1721 at SemaDecl.cpp:677, address = 0x0000000111553ee9, resolved, hit count = 0 <...snip...> (lldb) clangdiag enable #### removes all existing breakpoints, then adds back one for DiagnosticsEngine::Report (lldb) clangdiag disable #### removes all clangdiag breakpoints https://reviews.llvm.org/D36347 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits