Index: llvm/docs/CommandGuide/llvm-debuginfo-analyzer.rst =================================================================== --- llvm/docs/CommandGuide/llvm-debuginfo-analyzer.rst +++ llvm/docs/CommandGuide/llvm-debuginfo-analyzer.rst @@ -576,6 +576,72 @@ =Unspecified: Unspecified type. =Volatile: Volatile specifier. +COMBINED +^^^^^^^^ +If the output generated by any of the options (:option:`--select`), +(:option:`--select-elements`), (:option:`--select-lines`), +(:option:`--select-scopes`), (:option:`--select-symbols`), +(:option:`--select-types`) is too general, a combined selection can be +used to add extra filtering. + +:program:`llvm-debuginfo-analyzer` supports a combined selection feature, +that includes the and as a criteria, to allow the +selection of a specific of logical element, line, scope, symbol +or type that matches the given . + +The most basic combined criteria will include one of the following +options: + +.. code-block:: none + + --select= --select-elements= + +which select logical elements that satisfy the given +**and** whose name or line number matches the given . + +.. code-block:: none + + --select= --select-lines= + +which select logical lines that match the given **and** whose +line number matches . + +.. code-block:: none + + --select= --select-scopes= + +which select logical scopes that match the given **and** whose +name matches the given . + +.. code-block:: none + + --select= --select-symbols= + +which select logical symbols that match the given **and** whose +name matches the given . + +.. code-block:: none + + --select= --select-types= + +which select logical types that match the given **and** whose +name matches the given . + +For more specific combined criterias, a mix of the following options + +.. code-block:: none + + --select= --select-elements= + --select= --select-lines= + --select= --select-scopes= + --select= --select-symbols= + --select= --select-types= + +can be specified. A logical element, line, scope, symbol or type will +be selected if their name or line number matches any of the given +s **and** their or matches any of the given +s or s. + .. _compare_: COMPARE @@ -847,6 +913,51 @@ ----------------------------- Total 26 8 +COMBINED SELECT LOGICAL ELEMENTS +"""""""""""""""""""""""""""""""" +The following prints all *scopes* that are **Function**, all *lines* +that are **LineDebug** or **LineAssembler**, all *symbols* that are +**Parameter** and all *types* that are **Typedef** and that contain +**'foo'** or **'ParamBool'** or **'retq'** or **'INTEGER'** or **'6'** +in their names, types, assembler instructions or line numbers, using +a tab layout and given the number of matches. + +.. code-block:: none + + llvm-debuginfo-analyzer --attribute=level + --select=foo + --select=ParamBool + --select=retq + --select=INTEGER + --select=6 + --select-lines=LineAssembler,LineDebug + --select-scopes=Function + --select-symbols=Parameter + --select-types=Typedef + --report=list + --print=elements,summary + test-dwarf-clang.o + + Logical View: + [000] {File} 'test-dwarf-clang.o' + + [001] {CompileUnit} 'test.cpp' + [003] {Code} 'retq' + [003] 2 {Parameter} 'ParamBool' -> 'bool' + [002] 2 {Function} extern not_inlined 'foo' -> 'int' + [003] 4 {TypeAlias} 'INTEGER' -> 'int' + [004] 6 {Line} + + ----------------------------- + Element Total Found + ----------------------------- + Scopes 3 1 + Symbols 4 1 + Types 2 1 + Lines 25 2 + ----------------------------- + Total 34 5 + COMPARISON MODE ^^^^^^^^^^^^^^^ In this mode :program:`llvm-debuginfo-analyzer` compares logical views Index: llvm/include/llvm/DebugInfo/LogicalView/Core/LVOptions.h =================================================================== --- llvm/include/llvm/DebugInfo/LogicalView/Core/LVOptions.h +++ llvm/include/llvm/DebugInfo/LogicalView/Core/LVOptions.h @@ -232,19 +232,20 @@ class LVSelect { public: - bool IgnoreCase = false; // --select-ignore-case - bool UseRegex = false; // --select-use-regex - bool Execute = false; // Select requested. - bool GenericKind = false; // We have collected generic kinds. - bool GenericPattern = false; // We have collected generic patterns. - bool OffsetPattern = false; // We have collected offset patterns. - StringSet<> Generic; // --select= - LVOffsetSet Offsets; // --select-offset= - LVElementKindSet Elements; // --select-elements= - LVLineKindSet Lines; // --select-lines= - LVScopeKindSet Scopes; // --select-scopes= - LVSymbolKindSet Symbols; // --select-symbols= - LVTypeKindSelection Types; // --select-types= + bool IgnoreCase = false; // --select-ignore-case + bool UseRegex = false; // --select-use-regex + bool Execute = false; // Select requested. + bool GenericKind = false; // We have collected generic kinds. + bool GenericPattern = false; // We have collected generic patterns. + bool OffsetPattern = false; // We have collected offset patterns. + bool CombinedPattern = false; // We have combined selection. + StringSet<> Generic; // --select= + LVOffsetSet Offsets; // --select-offset= + LVElementKindSet Elements; // --select-elements= + LVLineKindSet Lines; // --select-lines= + LVScopeKindSet Scopes; // --select-scopes= + LVSymbolKindSet Symbols; // --select-symbols= + LVTypeKindSelection Types; // --select-types= }; class LVOutput { @@ -416,6 +417,7 @@ BOOL_FUNCTION(Select, GenericKind); BOOL_FUNCTION(Select, GenericPattern); BOOL_FUNCTION(Select, OffsetPattern); + BOOL_FUNCTION(Select, CombinedPattern); // --warning. WARNING_OPTION(All); @@ -518,11 +520,17 @@ auto CheckOffset = [=]() -> bool { return matchOffsetPattern(Element->getOffset()); }; - if ((options().getSelectGenericPattern() && CheckPattern()) || - (options().getSelectOffsetPattern() && CheckOffset()) || - ((Requests.size() || ElementRequest.size()) && - checkElementRequest(Element, Requests))) - addElement(Element); + if (options().getSelectCombinedPattern()) { + if (CheckPattern() && (Requests.size() || ElementRequest.size()) && + checkElementRequest(Element, Requests)) + addElement(Element); + } else { + if ((options().getSelectGenericPattern() && CheckPattern()) || + (options().getSelectOffsetPattern() && CheckOffset()) || + ((Requests.size() || ElementRequest.size()) && + checkElementRequest(Element, Requests))) + addElement(Element); + } } template @@ -536,10 +544,16 @@ auto CheckOffset = [=]() -> bool { return matchOffsetPattern(Line->getAddress()); }; - if ((options().getSelectGenericPattern() && CheckPattern()) || - (options().getSelectOffsetPattern() && CheckOffset()) || - (Requests.size() && checkElementRequest(Line, Requests))) - addElement(Line); + if (options().getSelectCombinedPattern()) { + if (CheckPattern() && + (Requests.size() && checkElementRequest(Line, Requests))) + addElement(Line); + } else { + if ((options().getSelectGenericPattern() && CheckPattern()) || + (options().getSelectOffsetPattern() && CheckOffset()) || + (Requests.size() && checkElementRequest(Line, Requests))) + addElement(Line); + } } Error createMatchEntry(LVMatchInfo &Filters, StringRef Pattern, Index: llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp =================================================================== --- llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp +++ llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp @@ -369,12 +369,13 @@ // --select OS << "** Select **\n" - << "IgnoreCase: " << getSelectIgnoreCase() << ", " - << "UseRegex: " << getSelectUseRegex() << ", " - << "Execute: " << getSelectExecute() << ", " - << "GenericKind: " << getSelectGenericKind() << "\n" - << "GenericPattern: " << getSelectGenericPattern() << ", " - << "OffsetPattern: " << getSelectOffsetPattern() << "\n" + << "IgnoreCase: " << getSelectIgnoreCase() << ", " + << "UseRegex: " << getSelectUseRegex() << ", " + << "Execute: " << getSelectExecute() << ", " + << "GenericKind: " << getSelectGenericKind() << "\n" + << "GenericPattern: " << getSelectGenericPattern() << ", " + << "OffsetPattern: " << getSelectOffsetPattern() << "," + << "CombinedPattern: " << getSelectCombinedPattern() << "\n" << "\n"; // --warning @@ -490,6 +491,9 @@ void LVPatterns::updateReportOptions() { if (ElementRequest.size() || LineRequest.size() || ScopeRequest.size() || SymbolRequest.size() || TypeRequest.size()) { + // Compound selection. + if (options().getSelectGenericPattern()) + options().setSelectCombinedPattern(); options().setSelectGenericKind(); options().setSelectExecute(); } Index: llvm/test/tools/llvm-debuginfo-analyzer/COFF/01-coff-select-logical-elements.test =================================================================== --- llvm/test/tools/llvm-debuginfo-analyzer/COFF/01-coff-select-logical-elements.test +++ llvm/test/tools/llvm-debuginfo-analyzer/COFF/01-coff-select-logical-elements.test @@ -68,3 +68,38 @@ ; TWO-EMPTY: ; TWO-NEXT: [001] {CompileUnit} 'test.cpp' ; TWO-NEXT: [004] {TypeAlias} 'INTEGER' -> 'int' + +; RUN: llvm-debuginfo-analyzer --attribute=level \ +; RUN: --select=foo \ +; RUN: --select=ParamBool \ +; RUN: --select=retq \ +; RUN: --select=INTEGER \ +; RUN: --select=6 \ +; RUN: --select-lines=LineAssembler,LineDebug \ +; RUN: --select-scopes=Function \ +; RUN: --select-symbols=Parameter \ +; RUN: --select-types=Typedef \ +; RUN: --report=list \ +; RUN: --print=elements \ +; RUN: %p/Inputs/test-codeview-clang.o \ +; RUN: %p/Inputs/test-codeview-msvc.o 2>&1 | \ +; RUN: FileCheck --strict-whitespace -check-prefix=THR %s + +; THR: Logical View: +; THR-NEXT: [000] {File} 'test-codeview-clang.o' +; THR-EMPTY: +; THR-NEXT: [001] {CompileUnit} 'test.cpp' +; THR-NEXT: [003] {TypeAlias} 'INTEGER' -> 'int' +; THR-NEXT: [003] {Parameter} 'ParamBool' -> 'bool' +; THR-NEXT: [002] {Function} extern not_inlined 'foo' -> 'int' +; THR-NEXT: [003] {Code} 'retq' +; THR-NEXT: [004] 6 {Line} +; THR-EMPTY: +; THR-NEXT: Logical View: +; THR-NEXT: [000] {File} 'test-codeview-msvc.o' +; THR-EMPTY: +; THR-NEXT: [001] {CompileUnit} 'test.cpp' +; THR-NEXT: [004] {TypeAlias} 'INTEGER' -> 'int' +; THR-NEXT: [002] {Function} extern not_inlined 'foo' -> 'int' +; THR-NEXT: [003] {Code} 'retq' +; THR-NEXT: [004] 6 {Line} Index: llvm/test/tools/llvm-debuginfo-analyzer/DWARF/01-dwarf-select-logical-elements.test =================================================================== --- llvm/test/tools/llvm-debuginfo-analyzer/DWARF/01-dwarf-select-logical-elements.test +++ llvm/test/tools/llvm-debuginfo-analyzer/DWARF/01-dwarf-select-logical-elements.test @@ -71,3 +71,39 @@ ; TWO-NEXT: [001] {CompileUnit} 'test.cpp' ; TWO-NEXT: [004] 4 {TypeAlias} 'INTEGER' -> 'int' ; TWO-NEXT: [004] 5 {Variable} 'CONSTANT' -> 'const INTEGER' + +; RUN: llvm-debuginfo-analyzer --attribute=level \ +; RUN: --select=foo \ +; RUN: --select=ParamBool \ +; RUN: --select=retq \ +; RUN: --select=INTEGER \ +; RUN: --select=6 \ +; RUN: --select-lines=LineAssembler,LineDebug \ +; RUN: --select-scopes=Function \ +; RUN: --select-symbols=Parameter \ +; RUN: --select-types=Typedef \ +; RUN: --report=list \ +; RUN: --print=elements \ +; RUN: %p/Inputs/test-dwarf-clang.o \ +; RUN: %p/Inputs/test-dwarf-gcc.o 2>&1 | \ +; RUN: FileCheck --strict-whitespace -check-prefix=THR %s + +; THR: Logical View: +; THR-NEXT: [000] {File} 'test-dwarf-clang.o' +; THR-EMPTY: +; THR-NEXT: [001] {CompileUnit} 'test.cpp' +; THR-NEXT: [003] {Code} 'retq' +; THR-NEXT: [003] 2 {Parameter} 'ParamBool' -> 'bool' +; THR-NEXT: [002] 2 {Function} extern not_inlined 'foo' -> 'int' +; THR-NEXT: [003] 4 {TypeAlias} 'INTEGER' -> 'int' +; THR-NEXT: [004] 6 {Line} +; THR-EMPTY: +; THR-NEXT: Logical View: +; THR-NEXT: [000] {File} 'test-dwarf-gcc.o' +; THR-EMPTY: +; THR-NEXT: [001] {CompileUnit} 'test.cpp' +; THR-NEXT: [003] {Code} 'retq' +; THR-NEXT: [003] 2 {Parameter} 'ParamBool' -> 'bool' +; THR-NEXT: [002] 2 {Function} extern not_inlined 'foo' -> 'int' +; THR-NEXT: [004] 4 {TypeAlias} 'INTEGER' -> 'int' +; THR-NEXT: [004] 6 {Line}