.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "LLVM-DEBUGINFO-ANALYZER" "1" "2024-02-04" "15" "LLVM" .SH NAME llvm-debuginfo-analyzer \- Print a logical representation of low-level debug information. .INDENT 0.0 .IP \(bu 2 \fI\%SYNOPSIS\fP .IP \(bu 2 \fI\%DESCRIPTION\fP .IP \(bu 2 \fI\%OPTIONS\fP .INDENT 2.0 .IP \(bu 2 \fI\%GENERAL\fP .IP \(bu 2 \fI\%ATTRIBUTES\fP .IP \(bu 2 \fI\%PRINT\fP .IP \(bu 2 \fI\%OUTPUT\fP .IP \(bu 2 \fI\%REPORT\fP .IP \(bu 2 \fI\%SELECTION\fP .INDENT 2.0 .IP \(bu 2 \fI\%ELEMENTS\fP .IP \(bu 2 \fI\%LINES\fP .IP \(bu 2 \fI\%SCOPES\fP .IP \(bu 2 \fI\%SYMBOLS\fP .IP \(bu 2 \fI\%TYPES\fP .UNINDENT .IP \(bu 2 \fI\%COMPARE\fP .IP \(bu 2 \fI\%WARNING\fP .IP \(bu 2 \fI\%INTERNAL\fP .UNINDENT .IP \(bu 2 \fI\%EXAMPLES\fP .INDENT 2.0 .IP \(bu 2 \fI\%TEST CASE 1 \- GENERAL OPTIONS\fP .INDENT 2.0 .IP \(bu 2 \fI\%PRINTING MODE\fP .INDENT 2.0 .IP \(bu 2 \fI\%BASIC DETAILS\fP .IP \(bu 2 \fI\%SELECT LOGICAL ELEMENTS\fP .UNINDENT .IP \(bu 2 \fI\%COMPARISON MODE\fP .INDENT 2.0 .IP \(bu 2 \fI\%LOGICAL VIEW\fP .IP \(bu 2 \fI\%LOGICAL ELEMENTS\fP .UNINDENT .UNINDENT .IP \(bu 2 \fI\%TEST CASE 2 \- ASSEMBLER INSTRUCTIONS\fP .INDENT 2.0 .IP \(bu 2 \fI\%CodeView \- Clang (Windows)\fP .IP \(bu 2 \fI\%CodeView \- MSVC (Windows)\fP .IP \(bu 2 \fI\%DWARF \- Clang (Linux)\fP .IP \(bu 2 \fI\%DWARF \- GCC (Linux)\fP .UNINDENT .IP \(bu 2 \fI\%TEST CASE 3 \- INCORRECT LEXICAL SCOPE FOR TYPEDEF\fP .INDENT 2.0 .IP \(bu 2 \fI\%CodeView \- Clang (Windows)\fP .IP \(bu 2 \fI\%CodeView \- MSVC (Windows)\fP .IP \(bu 2 \fI\%DWARF \- Clang (Linux)\fP .IP \(bu 2 \fI\%DWARF \- GCC (Linux)\fP .UNINDENT .IP \(bu 2 \fI\%TEST CASE 4 \- MISSING NESTED ENUMERATIONS\fP .INDENT 2.0 .IP \(bu 2 \fI\%CodeView \- Clang (Windows)\fP .IP \(bu 2 \fI\%CodeView \- MSVC (Windows)\fP .IP \(bu 2 \fI\%DWARF \- Clang (Linux)\fP .IP \(bu 2 \fI\%DWARF \- GCC (Linux)\fP .UNINDENT .IP \(bu 2 \fI\%TEST CASE 5 \- INCORRECT LEXICAL SCOPE FOR VARIABLE\fP .INDENT 2.0 .IP \(bu 2 \fI\%CODEVIEW \- Clang (Windows)\fP .IP \(bu 2 \fI\%CODEVIEW \- MSVC (Windows)\fP .IP \(bu 2 \fI\%DWARF \- Clang (Linux)\fP .IP \(bu 2 \fI\%DWARF \- GCC (Linux)\fP .UNINDENT .IP \(bu 2 \fI\%TEST CASE 6 \- FULL LOGICAL VIEW\fP .UNINDENT .IP \(bu 2 \fI\%EXIT STATUS\fP .IP \(bu 2 \fI\%SEE ALSO\fP .UNINDENT .SH SYNOPSIS .sp \fBllvm\-debuginfo\-analyzer\fP [\fIoptions\fP] [\fIfilename …\fP] .SH DESCRIPTION .sp \fBllvm\-debuginfo\-analyzer\fP parses debug and text sections in binary object files and prints their contents in a logical view, which is a human readable representation that closely matches the structure of the original user source code. Supported object file formats include ELF, Mach\-O, PDB and COFF. .sp The \fBlogical view\fP abstracts the complexity associated with the different low\-level representations of the debugging information that is embedded in the object file. \fBllvm\-debuginfo\-analyzer\fP produces a canonical view of the debug information regardless of how it is formatted. The same logical view will be seen regardless of object file format, assuming the debug information correctly represents the same original source code. .sp The logical view includes the following \fBlogical elements\fP: \fItype\fP, \fIscope\fP, \fIsymbol\fP and \fIline\fP, which are the basic software elements used in the C/C++ programming language. Each logical element has a set of \fBattributes\fP, such as \fItypes\fP, \fIclasses\fP, \fIfunctions\fP, \fIvariables\fP, \fIparameters\fP, etc. The \fI\%\-\-attribute\fP can be used to specify which attributes to include when printing a logical element. A logical element may have a \fBkind\fP that describes specific types of elements. For instance, a \fIscope\fP could have a kind value of \fIfunction\fP, \fIclass\fP, \fInamespace\fP\&. .sp \fBllvm\-debuginfo\-analyzer\fP defaults to print a pre\-defined layout of logical elements and attributes. The command line options can be used to control the printed elements (\fI\%\-\-print\fP), using a specific layout (\fI\%\-\-report\fP), matching a given pattern (\fI\%\-\-select\fP, \fI\%\-\-select\-offsets\fP). Also, the output can be limited to specified logical elements using (\fI\%\-\-select\-lines\fP, \fI\%\-\-select\-scopes\fP, \fI\%\-\-select\-symbols\fP, \fI\%\-\-select\-types\fP). .sp \fBllvm\-debuginfo\-analyzer\fP can also compare a set of logical views (\fI\%\-\-compare\fP), to find differences and identify possible debug information syntax issues (\fI\%\-\-warning\fP) in any object file. .SH OPTIONS .sp \fBllvm\-debuginfo\-analyzer\fP options are separated into several categories, each tailored to a different purpose: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%GENERAL\fP \- Standard LLVM options to display help, version, etc. .IP \(bu 2 \fI\%ATTRIBUTES\fP \- Describe how to include different details when printing an element. .IP \(bu 2 \fI\%PRINT\fP \- Specify which elements will be included when printing the view. .IP \(bu 2 \fI\%OUTPUT\fP \- Describe the supported formats when printing the view. .IP \(bu 2 \fI\%REPORT\fP \- Describe the format layouts for view printing. .IP \(bu 2 \fI\%SELECTION\fP \- Allows to use specific criteria or conditions to select which elements to print. .IP \(bu 2 \fI\%COMPARE\fP \- Compare logical views and print missing and/or added elements. .IP \(bu 2 \fI\%WARNING\fP \- Print the warnings detected during the creation of the view. .IP \(bu 2 \fI\%INTERNAL\fP \- Internal analysis of the logical view. .UNINDENT .UNINDENT .UNINDENT .SS GENERAL .sp This section describes the standard help options, used to display the usage, version, response files, etc. .INDENT 0.0 .TP .B \-h, \-\-help Show help and usage for this command. (–help\-hidden for more). .UNINDENT .INDENT 0.0 .TP .B \-\-help\-list Show help and usage for this command without grouping the options into categories (–help\-list\-hidden for more). .UNINDENT .INDENT 0.0 .TP .B \-\-help\-hidden Display all available options. .UNINDENT .INDENT 0.0 .TP .B \-\-print\-all\-options Print all option values after command line parsing. .UNINDENT .INDENT 0.0 .TP .B \-\-print\-options Print non\-default options after command line parsing .UNINDENT .INDENT 0.0 .TP .B \-\-version Display the version of the tool. .UNINDENT .INDENT 0.0 .TP .B @ Read command\-line options from \fI\fP\&. .UNINDENT .sp If no input file is specified, \fBllvm\-debuginfo\-analyzer\fP defaults to read \fIa.out\fP and return an error when no input file is found. .sp If \fI\-\fP is used as the input file, \fBllvm\-debuginfo\-analyzer\fP reads the input from its standard input stream. .SS ATTRIBUTES .sp The following options enable attributes given for the printed elements. The attributes are divided in categories based on the type of data being added, such as: internal offsets in the binary file, location descriptors, register names, user source filenames, additional element transformations, toolchain name, binary file format, etc. .INDENT 0.0 .TP .B \-\-attribute= With \fBvalue\fP being one of the options in the following lists. .INDENT 7.0 .INDENT 3.5 .sp .EX =all: Include all the below attributes. =extended: Add low\-level attributes. =standard: Add standard high\-level attributes. .EE .UNINDENT .UNINDENT .sp The following attributes describe the most common information for a logical element. They help to identify the lexical scope level; the element visibility across modules (global, local); the toolchain name that produced the binary file. .INDENT 7.0 .INDENT 3.5 .sp .EX =global: Element referenced across Compile Units. =format: Object file format name. =level: Lexical scope level (File=0, Compile Unit=1). =local: Element referenced only in the Compile Unit. =producer: Toolchain identification name. .EE .UNINDENT .UNINDENT .sp The following attributes describe files and directory names from the user source code, where the elements are declared or defined; functions with public visibility across modules. These options allow to map the elements to their user code location, for cross references purposes. .INDENT 7.0 .INDENT 3.5 .sp .EX =directories: Directories referenced in the debug information. =filename: Filename where the element is defined. =files: Files referenced in the debug information. =pathname: Pathname where the object is defined. =publics: Function names that are public. .EE .UNINDENT .UNINDENT .sp The following attributes describe additional logical element source transformations, in order to display built\-in types (int, bool, etc.); parameters and arguments used during template instantiation; parent name hierarchy; array dimensions information; compiler generated elements and the underlying types associated with the types aliases. .INDENT 7.0 .INDENT 3.5 .sp .EX =argument: Template parameters replaced by its arguments. =base: Base types (int, bool, etc.). =generated: Compiler generated elements. =encoded: Template arguments encoded in the template name. =qualified: The element type include parents in its name. =reference: Element declaration and definition references. =subrange: Subrange encoding information for arrays. =typename: Template parameters. =underlying: Underlying type for type definitions. .EE .UNINDENT .UNINDENT .sp The following attributes describe the debug location information for a symbol or scope. It includes the symbol percentage coverage and any gaps within the location layout; ranges determining the code sections attached to a function. When descriptors are used, the target processor registers are displayed. .INDENT 7.0 .INDENT 3.5 .sp .EX =coverage: Symbol location coverage. =gaps: Missing debug location (gaps). =location: Symbol debug location. =range: Debug location ranges. =register: Processor register names. .EE .UNINDENT .UNINDENT .sp The following attributes are associated with low level details, such as: offsets in the binary file; discriminators added to the lines of inlined functions in order to distinguish specific instances; debug lines state machine registers; elements discarded by the compiler (inlining) or by the linker optimizations (dead\-stripping); system compile units generated by the MS toolchain in PDBs. .INDENT 7.0 .INDENT 3.5 .sp .EX =discarded: Discarded elements by the linker. =discriminator: Discriminators for inlined function instances. =inserted: Generated inlined abstract references. =linkage: Object file linkage name. =offset: Debug information offset. =qualifier: Line qualifiers (Newstatement, BasicBlock, etc). =zero: Zero line numbers. .EE .UNINDENT .UNINDENT .sp The following attribute described specific information for the \fBPE/COFF\fP file format. It includes MS runtime types. .INDENT 7.0 .INDENT 3.5 .sp .EX =system: Display PDB\(aqs MS system elements. .EE .UNINDENT .UNINDENT .sp The above attributes are grouped into \fIstandard\fP and \fIextended\fP categories that can be enabled. .sp The \fIstandard\fP group, contains those attributes that add sufficient information to describe a logical element and that can cover the normal situations while dealing with debug information. .INDENT 7.0 .INDENT 3.5 .sp .EX =base =coverage =directories =discriminator =filename =files =format =level =producer =publics =range =reference =zero .EE .UNINDENT .UNINDENT .sp The \fIextended\fP group, contains those attributes that require a more extended knowledge about debug information. They are intended when a lower level of detail is required. .INDENT 7.0 .INDENT 3.5 .sp .EX =argument =discarded =encoded =gaps =generated =global =inserted =linkage =local =location =offset =operation =pathname =qualified =qualifier =register =subrange =system =typename .EE .UNINDENT .UNINDENT .UNINDENT .SS PRINT .sp The following options describe the elements to print. The layout used is determined by the \fI\%\-\-report\fP\&. In the tree layout, all the elements have their enclosing lexical scopes printed, even when not explicitly specified. .INDENT 0.0 .TP .B \-\-print= With \fBvalue\fP being one of the options in the following lists. .INDENT 7.0 .INDENT 3.5 .sp .EX =all: Include all the below attributes. .EE .UNINDENT .UNINDENT .sp The following options print the requested elements; in the case of any given select conditions (\fI\%\-\-select\fP), only those elements that match them, will be printed. The \fBelements\fP value is a convenient way to specify instructions, lines, scopes, symbols and types all at once. .INDENT 7.0 .INDENT 3.5 .sp .EX =elements: Instructions, lines, scopes, symbols and types. =instructions: Assembler instructions for code sections. =lines: Source lines referenced in the debug information. =scopes: Lexical blocks (function, class, namespace, etc). =symbols: Symbols (variable, member, parameter, etc). =types: Types (pointer, reference, type alias, etc). .EE .UNINDENT .UNINDENT .sp The following options print information, collected during the creation of the elements, such as: scope contributions to the debug information; summary of elements created, printed or matched (\fI\%\-\-select\fP); warnings produced during the view creation. .INDENT 7.0 .INDENT 3.5 .sp .EX =sizes: Debug Information scopes contributions. =summary: Summary of elements allocated, selected or printed. =warnings: Warnings detected. .EE .UNINDENT .UNINDENT .sp Note: The \fB–print=sizes\fP option is ELF specific. .UNINDENT .SS OUTPUT .sp The following options describe how to control the output generated when printing the logical elements. .INDENT 0.0 .TP .B \-\-output\-file= Redirect the output to a file specified by , where \- is the standard output stream. .UNINDENT .sp \fBllvm\-debuginfo\-analyzer\fP has the concept of \fBsplit view\fP\&. When redirecting the output from a complex binary format, it is \fBdivided\fP into individual files, each one containing the logical view output for a single compilation unit. .INDENT 0.0 .TP .B \-\-output\-folder= The folder to write a file per compilation unit when \fB–output=split\fP is specified. .UNINDENT .INDENT 0.0 .TP .B \-\-output\-level= Only print elements up to the given \fBlexical level\fP value. The input file is at lexical level zero and a compilation unit is at lexical level one. .UNINDENT .INDENT 0.0 .TP .B \-\-output= With \fBvalue\fP being one of the options in the following lists. .INDENT 7.0 .INDENT 3.5 .sp .EX =all: Include all the below outputs. .EE .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .sp .EX =json: Use JSON as the output format (Not implemented). =split: Split the output by Compile Units. =text: Use a free form text output. .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B \-\-output\-sort= Primary key when ordering the elements in the output (default: line). Sorting by logical element kind, requires be familiarity with the element kind selection options (\fI\%\-\-select\-lines\fP, \fI\%\-\-select\-scopes\fP, \fI\%\-\-select\-symbols\fP, \fI\%\-\-select\-types\fP), as those options describe the different logical element kinds. .INDENT 7.0 .INDENT 3.5 .sp .EX =kind: Sort by element kind. =line: Sort by element line number. =name: Sort by element name. =offset: Sort by element offset. .EE .UNINDENT .UNINDENT .UNINDENT .SS REPORT .sp Depending on the task being executed (print, compare, select), several layouts are supported to display the elements in a more suitable way, to make the output easier to understand. .INDENT 0.0 .TP .B \-\-report= With \fBvalue\fP being one of the options in the following list. .INDENT 7.0 .INDENT 3.5 .sp .EX =all: Include all the below reports. .EE .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .sp .EX =children: Elements and children are displayed in a tree format. =list: Elements are displayed in a tabular format. =parents: Elements and parents are displayed in a tree format. =view: Elements, parents and children are displayed in a tree format. .EE .UNINDENT .UNINDENT .UNINDENT .sp The \fBlist\fP layout presents the logical elements in a tabular form without any parent\-child relationship. This may be the preferred way to display elements that match specific conditions when comparing logical views, making it easier to find differences. .sp The \fBchildren\fP, \fBparents\fP and \fBview\fP layout displays the elements in a tree format, with the scopes representing their nodes, and types, symbols, lines and other scopes representing the children. The layout shows the lexical scoping relationship between elements, with the binary file being the tree root (level 0) and each compilation unit being a child (level 1). .sp The \fBchildren\fP layout includes the elements that match any given criteria (\fI\%\-\-select\fP) or (\fI\%\-\-compare\fP) and its children. .sp The \fBparents\fP layout includes the elements that match any given criteria (\fI\%\-\-select\fP) or (\fI\%\-\-compare\fP) and its parents. .sp The combined \fBview\fP layout includes the elements that match any given criteria (\fI\%\-\-select\fP) or (\fI\%\-\-compare\fP), its parents and children. .sp \fBNotes\fP: .INDENT 0.0 .IP 1. 3 When a selection criteria (\fI\%\-\-select\fP) is specified with no report option, the \fBlist\fP layout is selected. .IP 2. 3 The comparison mode always uses the \fBview\fP layout. .UNINDENT .SS SELECTION .sp When printing an element, different data can be included and it varies (\fI\%\-\-attribute\fP) from data directly associated with the binary file (offset) to high level details such as coverage, lexical scope level, location. As the printed output can reach a considerable size, several selection options, enable printing of specific elements. .sp The pattern matching can ignore the case (\fI\%\-\-select\-nocase\fP) and be extended to use regular expressions (\fI\%\-\-select\-regex\fP). .SS ELEMENTS .sp The following options allow printing of elements that match the given , offset or an element . .INDENT 0.0 .TP .B \-\-select= Print all elements whose name or line number matches the given . .UNINDENT .INDENT 0.0 .TP .B \-\-select\-offsets= Print all elements whose offset matches the given values. See \fI\%\-\-attribute\fP option. .UNINDENT .INDENT 0.0 .TP .B \-\-select\-elements= Print all elements that satisfy the given . With \fBcondition\fP being one of the options in the following list. .INDENT 7.0 .INDENT 3.5 .sp .EX =discarded: Discarded elements by the linker. =global: Element referenced across Compile Units. =optimized: Optimized inlined abstract references. .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B \-\-select\-nocase Pattern matching is case\-insensitive when using \fI\%\-\-select\fP\&. .UNINDENT .INDENT 0.0 .TP .B \-\-select\-regex Treat any strings as regular expressions when selecting with \fI\%\-\-select\fP option. If \fI\%\-\-select\-nocase\fP is specified, the regular expression becomes case\-insensitive. .UNINDENT .sp If the criteria is too general, a more selective option can be specified to target a particular category of elements: lines (\fI\%\-\-select\-lines\fP), scopes (\fI\%\-\-select\-scopes\fP), symbols (\fI\%\-\-select\-symbols\fP) and types (\fI\%\-\-select\-types\fP). These options require knowledge of the debug information format (DWARF, CodeView, COFF), as the given \fBkind\fP describes a very specific type of element. .SS LINES .sp The following options allow printing of lines that match the given . The given criteria describes the debug line state machine registers. .INDENT 0.0 .TP .B \-\-select\-lines= With \fBkind\fP being one of the options in the following list. .INDENT 7.0 .INDENT 3.5 .sp .EX =AlwaysStepInto: marks an always step into. =BasicBlock: Marks a new basic block. =Discriminator: Line that has a discriminator. =EndSequence: Marks the end in the sequence of lines. =EpilogueBegin: Marks the start of a function epilogue. =LineDebug: Lines that correspond to debug lines. =LineAssembler: Lines that correspond to disassembly text. =NeverStepInto: marks a never step into. =NewStatement: Marks a new statement. =PrologueEnd: Marks the end of a function prologue. .EE .UNINDENT .UNINDENT .UNINDENT .SS SCOPES .sp The following options allow printing of scopes that match the given . .INDENT 0.0 .TP .B \-\-select\-scopes= With \fBkind\fP being one of the options in the following list. .INDENT 7.0 .INDENT 3.5 .sp .EX =Aggregate: A class, structure or union. =Array: An array. =Block: A generic block (lexical block or exception block). =CallSite: A call site. =CatchBlock: An exception block. =Class: A class. =CompileUnit: A compile unit. =EntryPoint: A subroutine entry point. =Enumeration: An enumeration. =Function: A function. =FunctionType: A function pointer. =InlinedFunction: An inlined function. =Label: A label. =LexicalBlock: A lexical block. =Namespace: A namespace. =Root: The element representing the main scope. =Structure: A structure. =Subprogram: A subprogram. =Template: A template definition. =TemplateAlias: A template alias. =TemplatePack: A template pack. =TryBlock: An exception try block. =Union: A union. .EE .UNINDENT .UNINDENT .UNINDENT .SS SYMBOLS .sp The following options allow printing of symbols that match the given . .INDENT 0.0 .TP .B \-\-select\-symbols= With \fBkind\fP being one of the options in the following list. .INDENT 7.0 .INDENT 3.5 .sp .EX =CallSiteParameter: A call site parameter. =Constant: A constant symbol. =Inheritance: A base class. =Member: A member class. =Parameter: A parameter to function. =Unspecified: Unspecified parameters to function. =Variable: A variable. .EE .UNINDENT .UNINDENT .UNINDENT .SS TYPES .sp The following options allow printing of types that match the given . .INDENT 0.0 .TP .B \-\-select\-types= With \fBkind\fP being one of the options in the following list. .INDENT 7.0 .INDENT 3.5 .sp .EX =Base: Base type (integer, boolean, etc). =Const: Constant specifier. =Enumerator: Enumerator. =Import: Import declaration. =ImportDeclaration: Import declaration. =ImportModule: Import module. =Pointer: Pointer type. =PointerMember: Pointer to member function. =Reference: Reference type. =Restrict: Restrict specifier. =RvalueReference: R\-value reference. =Subrange: Array subrange. =TemplateParam: Template parameter. =TemplateTemplateParam: Template template parameter. =TemplateTypeParam: Template type parameter. =TemplateValueParam: Template value parameter. =Typedef: Type definition. =Unspecified: Unspecified type. =Volatile: Volatile specifier. .EE .UNINDENT .UNINDENT .UNINDENT .SS COMPARE .sp When dealing with debug information, there are situations when the printing of the elements is not the correct approach. That is the case, when we are interested in the effects caused by different versions of the same toolchain, or the impact of specific compiler optimizations. .sp For those cases, we are looking to see which elements have been added or removed. Due to the complicated debug information format, it is very difficult to use a regular diff tool to find those elements; even impossible when dealing with different debug formats. .sp \fBllvm\-debuginfo\-analyzer\fP supports a logical element comparison, allowing to find semantic differences between logical views, produced by different toolchain versions or even debug information formats. .sp When comparing logical views created from different debug formats, its accuracy depends on how close the debug information represents the user code. For instance, a logical view created from a binary file with DWARF debug information may include more detailed data than a logical view created from a binary file with CodeView/COFF debug information. .sp The following options describe the elements to compare. .INDENT 0.0 .TP .B \-\-compare= With \fBvalue\fP being one of the options in the following list. .INDENT 7.0 .INDENT 3.5 .sp .EX =all: Include all the below elements. .EE .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .sp .EX =lines: Include lines. =scopes: Include scopes. =symbols: Include symbols. =types: Include types. .EE .UNINDENT .UNINDENT .UNINDENT .sp \fBllvm\-debuginfo\-analyzer\fP takes the first binary file on the command line as the \fBreference\fP and the second one as the \fBtarget\fP\&. To get a more descriptive report, the comparison is done twice. The reference and target views are swapped, in order to produce those \fBmissing\fP elements from the target view and those \fBadded\fP elements to the reference view. .sp See \fI\%\-\-report\fP options on how to describe the comparison reports. .SS WARNING .sp When reading the input object files, \fBllvm\-debuginfo\-analyzer\fP can detect issues in the raw debug information. These may not be considered fatal to the purpose of printing a logical view but they can give an indication about the quality and potentially expose issues with the generated debug information. .sp The following options describe the warnings to be recorded for later printing, if they are requested by \fI\%\-\-print\fP\&. .INDENT 0.0 .TP .B \-\-warning= With \fBvalue\fP being one of the options in the following list. .INDENT 7.0 .INDENT 3.5 .sp .EX =all: Include all the below warnings. .EE .UNINDENT .UNINDENT .sp The following options collect additional information during the creation of the logical view, to include invalid coverage values and locations for symbols; invalid code ranges; lines that are zero. .INDENT 7.0 .INDENT 3.5 .sp .EX =coverages: Invalid symbol coverages values. =lines: Debug lines that are zero. =locations: Invalid symbol locations. =ranges: Invalid code ranges. .EE .UNINDENT .UNINDENT .UNINDENT .SS INTERNAL .INDENT 0.0 .INDENT 3.5 For a better understanding of the logical view, access to more detailed internal information could be needed. Such data would help to identify debug information processed or incorrect logical element management. Typically these kind of options are available only in \fIdebug\fP builds. .sp \fBllvm\-debuginfo\-analyzer\fP supports these advanced options in both \fIrelease\fP and \fIdebug\fP builds, with the exception of the unique ID that is generated only in \fIdebug\fP builds. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B \-\-internal= With \fBvalue\fP being one of the options in the following list. .INDENT 7.0 .INDENT 3.5 .sp .EX =all: Include all the below options. .EE .UNINDENT .UNINDENT .sp The following options allow to check the integrity of the logical view; collect the debug tags that are processed or not implemented; ignore the logical element line number, to facilitate the logical view comparison when using external comparison tools; print the command line options used to invoke \fBllvm\-debuginfo\-analyzer\fP\&. .INDENT 7.0 .INDENT 3.5 .sp .EX =id: Print unique element ID. =cmdline: Print command line. =integrity: Check elements integrity. =none: Ignore element line number. =tag: Debug information tags. .EE .UNINDENT .UNINDENT .sp \fBNote:\fP For ELF format, the collected tags represent the debug tags that are not processed. For PE/COFF format, they represent the tags that are processed. .UNINDENT .SH EXAMPLES .sp This section includes some real binary files to show how to use \fBllvm\-debuginfo\-analyzer\fP to print a logical view and to diagnose possible debug information issues. .SS TEST CASE 1 \- GENERAL OPTIONS .sp The below example is used to show different output generated by \fBllvm\-debuginfo\-analyzer\fP\&. We compiled the example for an X86 ELF target with Clang (\-O0 \-g): .INDENT 0.0 .INDENT 3.5 .sp .EX 1 using INTPTR = const int *; 2 int foo(INTPTR ParamPtr, unsigned ParamUnsigned, bool ParamBool) { 3 if (ParamBool) { 4 typedef int INTEGER; 5 const INTEGER CONSTANT = 7; 6 return CONSTANT; 7 } 8 return ParamUnsigned; 9 } .EE .UNINDENT .UNINDENT .SS PRINTING MODE .sp In this mode \fBllvm\-debuginfo\-analyzer\fP prints the \fIlogical view\fP or portions of it, based on criteria patterns (including regular expressions) to select the kind of \fIlogical elements\fP to be included in the output. .SS BASIC DETAILS .sp The following command prints basic details for all the logical elements sorted by the debug information internal offset; it includes its lexical level and debug info format. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level,format \-\-output\-sort=offset \-\-print=scopes,symbols,types,lines,instructions test\-dwarf\-clang.o .EE .UNINDENT .UNINDENT .sp or .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level,format \-\-output\-sort=offset \-\-print=elements test\-dwarf\-clang.o .EE .UNINDENT .UNINDENT .sp Each row represents an element that is present within the debug information. The first column represents the scope level, followed by the associated line number (if any), and finally the description of the element. .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqtest\-dwarf\-clang.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqtest.cpp\(aq [002] 2 {Function} extern not_inlined \(aqfoo\(aq \-> \(aqint\(aq [003] 2 {Parameter} \(aqParamPtr\(aq \-> \(aqINTPTR\(aq [003] 2 {Parameter} \(aqParamUnsigned\(aq \-> \(aqunsigned int\(aq [003] 2 {Parameter} \(aqParamBool\(aq \-> \(aqbool\(aq [003] {Block} [004] 5 {Variable} \(aqCONSTANT\(aq \-> \(aqconst INTEGER\(aq [004] 5 {Line} [004] {Code} \(aqmovl $0x7, \-0x1c(%rbp)\(aq [004] 6 {Line} [004] {Code} \(aqmovl $0x7, \-0x4(%rbp)\(aq [004] {Code} \(aqjmp 0x6\(aq [004] 8 {Line} [004] {Code} \(aqmovl \-0x14(%rbp), %eax\(aq [003] 4 {TypeAlias} \(aqINTEGER\(aq \-> \(aqint\(aq [003] 2 {Line} [003] {Code} \(aqpushq %rbp\(aq [003] {Code} \(aqmovq %rsp, %rbp\(aq [003] {Code} \(aqmovb %dl, %al\(aq [003] {Code} \(aqmovq %rdi, \-0x10(%rbp)\(aq [003] {Code} \(aqmovl %esi, \-0x14(%rbp)\(aq [003] {Code} \(aqandb $0x1, %al\(aq [003] {Code} \(aqmovb %al, \-0x15(%rbp)\(aq [003] 3 {Line} [003] {Code} \(aqtestb $0x1, \-0x15(%rbp)\(aq [003] {Code} \(aqje 0x13\(aq [003] 8 {Line} [003] {Code} \(aqmovl %eax, \-0x4(%rbp)\(aq [003] 9 {Line} [003] {Code} \(aqmovl \-0x4(%rbp), %eax\(aq [003] {Code} \(aqpopq %rbp\(aq [003] {Code} \(aqretq\(aq [003] 9 {Line} [002] 1 {TypeAlias} \(aqINTPTR\(aq \-> \(aq* const int\(aq .EE .UNINDENT .UNINDENT .sp On closer inspection, we can see what could be a potential debug issue: .INDENT 0.0 .INDENT 3.5 .sp .EX [003] {Block} [003] 4 {TypeAlias} \(aqINTEGER\(aq \-> \(aqint\(aq .EE .UNINDENT .UNINDENT .sp The \fB‘INTEGER’\fP definition is at level \fB[003]\fP, the same lexical scope as the anonymous \fB{Block}\fP (‘true’ branch for the ‘if’ statement) whereas in the original source code the typedef statement is clearly inside that block, so the \fB‘INTEGER’\fP definition should also be at level \fB[004]\fP inside the block. .SS SELECT LOGICAL ELEMENTS .sp The following prints all \fIinstructions\fP, \fIsymbols\fP and \fItypes\fP that contain \fB‘inte’\fP or \fB‘movl’\fP in their names or types, using a tab layout and given the number of matches. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level \-\-select\-nocase \-\-select\-regex \-\-select=INTe \-\-select=movl \-\-report=list \-\-print=symbols,types,instructions,summary test\-dwarf\-clang.o Logical View: [000] {File} \(aqtest\-dwarf\-clang.o\(aq [001] {CompileUnit} \(aqtest.cpp\(aq [003] {Code} \(aqmovl $0x7, \-0x1c(%rbp)\(aq [003] {Code} \(aqmovl $0x7, \-0x4(%rbp)\(aq [003] {Code} \(aqmovl %eax, \-0x4(%rbp)\(aq [003] {Code} \(aqmovl %esi, \-0x14(%rbp)\(aq [003] {Code} \(aqmovl \-0x14(%rbp), %eax\(aq [003] {Code} \(aqmovl \-0x4(%rbp), %eax\(aq [003] 4 {TypeAlias} \(aqINTEGER\(aq \-> \(aqint\(aq [004] 5 {Variable} \(aqCONSTANT\(aq \-> \(aqconst INTEGER\(aq \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Element Total Found \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Scopes 3 0 Symbols 4 1 Types 2 1 Lines 17 6 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Total 26 8 .EE .UNINDENT .UNINDENT .SS COMPARISON MODE .sp In this mode \fBllvm\-debuginfo\-analyzer\fP compares logical views to produce a report with the logical elements that are missing or added. This a very powerful aid in finding semantic differences in the debug information produced by different toolchain versions or even completely different toolchains altogether (For example a compiler producing DWARF can be directly compared against a completely different compiler that produces CodeView). .sp Given the previous example we found the above debug information issue (related to the previous invalid scope location for the \fB‘typedef int INTEGER’\fP) by comparing against another compiler. .sp Using GCC to generate test\-dwarf\-gcc.o, we can apply a selection pattern with the printing mode to obtain the following logical view output. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level \-\-select\-regex \-\-select\-nocase \-\-select=INTe \-\-report=list \-\-print=symbols,types test\-dwarf\-clang.o test\-dwarf\-gcc.o Logical View: [000] {File} \(aqtest\-dwarf\-clang.o\(aq [001] {CompileUnit} \(aqtest.cpp\(aq [003] 4 {TypeAlias} \(aqINTEGER\(aq \-> \(aqint\(aq [004] 5 {Variable} \(aqCONSTANT\(aq \-> \(aqconst INTEGER\(aq Logical View: [000] {File} \(aqtest\-dwarf\-gcc.o\(aq [001] {CompileUnit} \(aqtest.cpp\(aq [004] 4 {TypeAlias} \(aqINTEGER\(aq \-> \(aqint\(aq [004] 5 {Variable} \(aqCONSTANT\(aq \-> \(aqconst INTEGER\(aq .EE .UNINDENT .UNINDENT .sp The output shows that both objects contain the same elements. But the \fB‘typedef INTEGER’\fP is located at different scope level. The GCC generated object, shows \fB‘4’\fP, which is the correct value. .sp Note that there is no requirement that GCC must produce identical or similar DWARF to Clang to allow the comparison. We’re only comparing the semantics. The same case when comparing CodeView debug information generated by MSVC and Clang. .sp There are 2 comparison methods: logical view and logical elements. .SS LOGICAL VIEW .sp It compares the logical view as a whole unit; for a match, each compared logical element must have the same parents and children. .sp Using the \fBllvm\-debuginfo\-analyzer\fP comparison functionality, that issue can be seen in a more global context, that can include the logical view. .sp The output shows in view form the \fBmissing (\-), added (+)\fP elements, giving more context by swapping the reference and target object files. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level \-\-compare=types \-\-report=view \-\-print=symbols,types test\-dwarf\-clang.o test\-dwarf\-gcc.o Reference: \(aqtest\-dwarf\-clang.o\(aq Target: \(aqtest\-dwarf\-gcc.o\(aq Logical View: [000] {File} \(aqtest\-dwarf\-clang.o\(aq [001] {CompileUnit} \(aqtest.cpp\(aq [002] 1 {TypeAlias} \(aqINTPTR\(aq \-> \(aq* const int\(aq [002] 2 {Function} extern not_inlined \(aqfoo\(aq \-> \(aqint\(aq [003] {Block} [004] 5 {Variable} \(aqCONSTANT\(aq \-> \(aqconst INTEGER\(aq +[004] 4 {TypeAlias} \(aqINTEGER\(aq \-> \(aqint\(aq [003] 2 {Parameter} \(aqParamBool\(aq \-> \(aqbool\(aq [003] 2 {Parameter} \(aqParamPtr\(aq \-> \(aqINTPTR\(aq [003] 2 {Parameter} \(aqParamUnsigned\(aq \-> \(aqunsigned int\(aq \-[003] 4 {TypeAlias} \(aqINTEGER\(aq \-> \(aqint\(aq .EE .UNINDENT .UNINDENT .sp The output shows the merging view path (reference and target) with the missing and added elements. .SS LOGICAL ELEMENTS .sp It compares individual logical elements without considering if their parents are the same. For both comparison methods, the equal criteria includes the name, source code location, type, lexical scope level. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level \-\-compare=types \-\-report=list \-\-print=symbols,types,summary test\-dwarf\-clang.o test\-dwarf\-gcc.o Reference: \(aqtest\-dwarf\-clang.o\(aq Target: \(aqtest\-dwarf\-gcc.o\(aq (1) Missing Types: \-[003] 4 {TypeAlias} \(aqINTEGER\(aq \-> \(aqint\(aq (1) Added Types: +[004] 4 {TypeAlias} \(aqINTEGER\(aq \-> \(aqint\(aq \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Element Expected Missing Added \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Scopes 4 0 0 Symbols 0 0 0 Types 2 1 1 Lines 0 0 0 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Total 6 1 1 .EE .UNINDENT .UNINDENT .sp Changing the \fIReference\fP and \fITarget\fP order: .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level \-\-compare=types \-\-report=list \-\-print=symbols,types,summary test\-dwarf\-gcc.o test\-dwarf\-clang.o Reference: \(aqtest\-dwarf\-gcc.o\(aq Target: \(aqtest\-dwarf\-clang.o\(aq (1) Missing Types: \-[004] 4 {TypeAlias} \(aqINTEGER\(aq \-> \(aqint\(aq (1) Added Types: +[003] 4 {TypeAlias} \(aqINTEGER\(aq \-> \(aqint\(aq \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Element Expected Missing Added \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Scopes 4 0 0 Symbols 0 0 0 Types 2 1 1 Lines 0 0 0 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Total 6 1 1 .EE .UNINDENT .UNINDENT .sp As the \fIReference\fP and \fITarget\fP are switched, the \fIAdded Types\fP from the first case now are listed as \fIMissing Types\fP\&. .SS TEST CASE 2 \- ASSEMBLER INSTRUCTIONS .sp The below example is used to show different output generated by \fBllvm\-debuginfo\-analyzer\fP\&. We compiled the example for an X86 Codeview and ELF targets with recent versions of Clang, GCC and MSVC (\-O0 \-g) for Windows and Linux. .INDENT 0.0 .INDENT 3.5 .sp .EX 1 extern int printf(const char * format, ... ); 2 3 int main() 4 { 5 printf(\(dqHello, World\en\(dq); 6 return 0; 7 } .EE .UNINDENT .UNINDENT .sp These are the logical views that \fBllvm\-debuginfo\-analyzer\fP generates for 3 different compilers (MSVC, Clang and GCC), emitting different debug information formats (CodeView, DWARF) on Windows and Linux. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level,format,producer \-\-print=lines,instructions hello\-world\-codeview\-clang.o hello\-world\-codeview\-msvc.o hello\-world\-dwarf\-clang.o hello\-world\-dwarf\-gcc.o .EE .UNINDENT .UNINDENT .SS CodeView \- Clang (Windows) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqhello\-world\-codeview\-clang.o\(aq \-> COFF\-x86\-64 [001] {CompileUnit} \(aqhello\-world.cpp\(aq [002] {Producer} \(aqclang version 14.0.0\(aq [002] {Function} extern not_inlined \(aqmain\(aq \-> \(aqint\(aq [003] 4 {Line} [003] {Code} \(aqsubq $0x28, %rsp\(aq [003] {Code} \(aqmovl $0x0, 0x24(%rsp)\(aq [003] 5 {Line} [003] {Code} \(aqleaq (%rip), %rcx\(aq [003] {Code} \(aqcallq 0x0\(aq [003] 6 {Line} [003] {Code} \(aqxorl %eax, %eax\(aq [003] {Code} \(aqaddq $0x28, %rsp\(aq [003] {Code} \(aqretq\(aq .EE .UNINDENT .UNINDENT .SS CodeView \- MSVC (Windows) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqhello\-world\-codeview\-msvc.o\(aq \-> COFF\-i386 [001] {CompileUnit} \(aqhello\-world.cpp\(aq [002] {Producer} \(aqMicrosoft (R) Optimizing Compiler\(aq [002] {Function} extern not_inlined \(aqmain\(aq \-> \(aqint\(aq [003] 4 {Line} [003] {Code} \(aqpushl %ebp\(aq [003] {Code} \(aqmovl %esp, %ebp\(aq [003] 5 {Line} [003] {Code} \(aqpushl $0x0\(aq [003] {Code} \(aqcalll 0x0\(aq [003] {Code} \(aqaddl $0x4, %esp\(aq [003] 6 {Line} [003] {Code} \(aqxorl %eax, %eax\(aq [003] 7 {Line} [003] {Code} \(aqpopl %ebp\(aq [003] {Code} \(aqretl\(aq .EE .UNINDENT .UNINDENT .SS DWARF \- Clang (Linux) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqhello\-world\-dwarf\-clang.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqhello\-world.cpp\(aq [002] {Producer} \(aqclang version 14.0.0\(aq [002] 3 {Function} extern not_inlined \(aqmain\(aq \-> \(aqint\(aq [003] 4 {Line} [003] {Code} \(aqpushq %rbp\(aq [003] {Code} \(aqmovq %rsp, %rbp\(aq [003] {Code} \(aqsubq $0x10, %rsp\(aq [003] {Code} \(aqmovl $0x0, \-0x4(%rbp)\(aq [003] 5 {Line} [003] {Code} \(aqmovabsq $0x0, %rdi\(aq [003] {Code} \(aqmovb $0x0, %al\(aq [003] {Code} \(aqcallq 0x0\(aq [003] 6 {Line} [003] {Code} \(aqxorl %eax, %eax\(aq [003] {Code} \(aqaddq $0x10, %rsp\(aq [003] {Code} \(aqpopq %rbp\(aq [003] {Code} \(aqretq\(aq [003] 6 {Line} .EE .UNINDENT .UNINDENT .SS DWARF \- GCC (Linux) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqhello\-world\-dwarf\-gcc.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqhello\-world.cpp\(aq [002] {Producer} \(aqGNU C++14 9.3.0\(aq [002] 3 {Function} extern not_inlined \(aqmain\(aq \-> \(aqint\(aq [003] 4 {Line} [003] {Code} \(aqendbr64\(aq [003] {Code} \(aqpushq %rbp\(aq [003] {Code} \(aqmovq %rsp, %rbp\(aq [003] 5 {Line} [003] {Code} \(aqleaq (%rip), %rdi\(aq [003] {Code} \(aqmovl $0x0, %eax\(aq [003] {Code} \(aqcallq 0x0\(aq [003] 6 {Line} [003] {Code} \(aqmovl $0x0, %eax\(aq [003] 7 {Line} [003] {Code} \(aqpopq %rbp\(aq [003] {Code} \(aqretq\(aq [003] 7 {Line} .EE .UNINDENT .UNINDENT .sp The logical views shows the intermixed lines and assembler instructions, allowing to compare the code generated by the different toolchains. .SS TEST CASE 3 \- INCORRECT LEXICAL SCOPE FOR TYPEDEF .sp The below example is used to show different output generated by \fBllvm\-debuginfo\-analyzer\fP\&. We compiled the example for an X86 Codeview and ELF targets with recent versions of Clang, GCC and MSVC (\-O0 \-g). .INDENT 0.0 .INDENT 3.5 .sp .EX 1 int bar(float Input) { return (int)Input; } 2 3 unsigned foo(char Param) { 4 typedef int INT; // ** Definition for INT ** 5 INT Value = Param; 6 { 7 typedef float FLOAT; // ** Definition for FLOAT ** 8 { 9 FLOAT Added = Value + Param; 10 Value = bar(Added); 11 } 12 } 13 return Value + Param; 14 } .EE .UNINDENT .UNINDENT .sp The above test is used to illustrate a scope issue found in the Clang compiler: \fI\%PR44884 (Bugs LLVM)\fP / \fI\%PR44229 (GitHub LLVM)\fP .sp The lines 4 and 7 contains 2 typedefs, defined at different lexical scopes. .INDENT 0.0 .INDENT 3.5 .sp .EX 4 typedef int INT; 7 typedef float FLOAT; .EE .UNINDENT .UNINDENT .sp These are the logical views that \fBllvm\-debuginfo\-analyzer\fP generates for 3 different compilers (MSVC, Clang and GCC), emitting different debug information formats (CodeView, DWARF) on different platforms. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level,format,producer \-\-print=symbols,types,lines \-\-output\-sort=kind pr\-44884\-codeview\-clang.o pr\-44884\-codeview\-msvc.o pr\-44884\-dwarf\-clang.o pr\-44884\-dwarf\-gcc.o .EE .UNINDENT .UNINDENT .SS CodeView \- Clang (Windows) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-44884\-codeview\-clang.o\(aq \-> COFF\-x86\-64 [001] {CompileUnit} \(aqpr\-44884.cpp\(aq [002] {Producer} \(aqclang version 14.0.0\(aq [002] {Function} extern not_inlined \(aqbar\(aq \-> \(aqint\(aq [003] {Parameter} \(aqInput\(aq \-> \(aqfloat\(aq [003] 1 {Line} [002] {Function} extern not_inlined \(aqfoo\(aq \-> \(aqunsigned\(aq [003] {Block} [004] {Variable} \(aqAdded\(aq \-> \(aqfloat\(aq [004] 9 {Line} [004] 10 {Line} [003] {Parameter} \(aqParam\(aq \-> \(aqchar\(aq [003] {TypeAlias} \(aqFLOAT\(aq \-> \(aqfloat\(aq [003] {TypeAlias} \(aqINT\(aq \-> \(aqint\(aq [003] {Variable} \(aqValue\(aq \-> \(aqint\(aq [003] 3 {Line} [003] 5 {Line} [003] 13 {Line} .EE .UNINDENT .UNINDENT .SS CodeView \- MSVC (Windows) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-44884\-codeview\-msvc.o\(aq \-> COFF\-i386 [001] {CompileUnit} \(aqpr\-44884.cpp\(aq [002] {Producer} \(aqMicrosoft (R) Optimizing Compiler\(aq [002] {Function} extern not_inlined \(aqbar\(aq \-> \(aqint\(aq [003] {Variable} \(aqInput\(aq \-> \(aqfloat\(aq [003] 1 {Line} [002] {Function} extern not_inlined \(aqfoo\(aq \-> \(aqunsigned\(aq [003] {Block} [004] {Block} [005] {Variable} \(aqAdded\(aq \-> \(aqfloat\(aq [004] {TypeAlias} \(aqFLOAT\(aq \-> \(aqfloat\(aq [004] 9 {Line} [004] 10 {Line} [003] {TypeAlias} \(aqINT\(aq \-> \(aqint\(aq [003] {Variable} \(aqParam\(aq \-> \(aqchar\(aq [003] {Variable} \(aqValue\(aq \-> \(aqint\(aq [003] 3 {Line} [003] 5 {Line} [003] 13 {Line} [003] 14 {Line} .EE .UNINDENT .UNINDENT .SS DWARF \- Clang (Linux) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-44884\-dwarf\-clang.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr\-44884.cpp\(aq [002] {Producer} \(aqclang version 14.0.0\(aq [002] 1 {Function} extern not_inlined \(aqbar\(aq \-> \(aqint\(aq [003] 1 {Parameter} \(aqInput\(aq \-> \(aqfloat\(aq [003] 1 {Line} [003] 1 {Line} [003] 1 {Line} [002] 3 {Function} extern not_inlined \(aqfoo\(aq \-> \(aqunsigned int\(aq [003] {Block} [004] 9 {Variable} \(aqAdded\(aq \-> \(aqFLOAT\(aq [004] 9 {Line} [004] 9 {Line} [004] 9 {Line} [004] 9 {Line} [004] 9 {Line} [004] 10 {Line} [004] 10 {Line} [004] 10 {Line} [004] 13 {Line} [003] 3 {Parameter} \(aqParam\(aq \-> \(aqchar\(aq [003] 7 {TypeAlias} \(aqFLOAT\(aq \-> \(aqfloat\(aq [003] 4 {TypeAlias} \(aqINT\(aq \-> \(aqint\(aq [003] 5 {Variable} \(aqValue\(aq \-> \(aqINT\(aq [003] 3 {Line} [003] 5 {Line} [003] 5 {Line} [003] 13 {Line} [003] 13 {Line} [003] 13 {Line} [003] 13 {Line} .EE .UNINDENT .UNINDENT .SS DWARF \- GCC (Linux) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-44884\-dwarf\-gcc.o\(aq \-> elf32\-littlearm [001] {CompileUnit} \(aqpr\-44884.cpp\(aq [002] {Producer} \(aqGNU C++14 10.2.1 20201103\(aq [002] 1 {Function} extern not_inlined \(aqbar\(aq \-> \(aqint\(aq [003] 1 {Parameter} \(aqInput\(aq \-> \(aqfloat\(aq [003] 1 {Line} [003] 1 {Line} [003] 1 {Line} [002] 3 {Function} extern not_inlined \(aqfoo\(aq \-> \(aqunsigned int\(aq [003] {Block} [004] {Block} [005] 9 {Variable} \(aqAdded\(aq \-> \(aqFLOAT\(aq [005] 9 {Line} [005] 9 {Line} [005] 9 {Line} [005] 10 {Line} [005] 13 {Line} [004] 7 {TypeAlias} \(aqFLOAT\(aq \-> \(aqfloat\(aq [003] 3 {Parameter} \(aqParam\(aq \-> \(aqchar\(aq [003] 4 {TypeAlias} \(aqINT\(aq \-> \(aqint\(aq [003] 5 {Variable} \(aqValue\(aq \-> \(aqINT\(aq [003] 3 {Line} [003] 5 {Line} [003] 13 {Line} [003] 14 {Line} [003] 14 {Line} .EE .UNINDENT .UNINDENT .sp From the previous logical views, we can see that the Clang compiler emits \fBboth typedefs at the same lexical scope (3)\fP, which is wrong. GCC and MSVC emit correct lexical scope for both typedefs. .sp Using the \fBllvm\-debuginfo\-analyzer\fP selection facilities, we can produce a simple tabular output showing just the logical types that are \fBTypedef\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level,format \-\-output\-sort=name \-\-select\-types=Typedef \-\-report=list \-\-print=types pr\-44884\-*.o Logical View: [000] {File} \(aqpr\-44884\-codeview\-clang.o\(aq \-> COFF\-x86\-64 [001] {CompileUnit} \(aqpr_44884.cpp\(aq [003] {TypeAlias} \(aqFLOAT\(aq \-> \(aqfloat\(aq [003] {TypeAlias} \(aqINT\(aq \-> \(aqint\(aq Logical View: [000] {File} \(aqpr\-44884\-codeview\-msvc.o\(aq \-> COFF\-i386 [001] {CompileUnit} \(aqpr_44884.cpp\(aq [004] {TypeAlias} \(aqFLOAT\(aq \-> \(aqfloat\(aq [003] {TypeAlias} \(aqINT\(aq \-> \(aqint\(aq Logical View: [000] {File} \(aqpr\-44884\-dwarf\-clang.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr_44884.cpp\(aq [003] 7 {TypeAlias} \(aqFLOAT\(aq \-> \(aqfloat\(aq [003] 4 {TypeAlias} \(aqINT\(aq \-> \(aqint\(aq Logical View: [000] {File} \(aqpr\-44884\-dwarf\-gcc.o\(aq \-> elf32\-littlearm [001] {CompileUnit} \(aqpr_44884.cpp\(aq [004] 7 {TypeAlias} \(aqFLOAT\(aq \-> \(aqfloat\(aq [003] 4 {TypeAlias} \(aqINT\(aq \-> \(aqint\(aq .EE .UNINDENT .UNINDENT .sp It also shows, that the CodeView debug information does not generate source code line numbers for the those logical types. The logical view is sorted by the types name. .SS TEST CASE 4 \- MISSING NESTED ENUMERATIONS .sp The below example is used to show different output generated by \fBllvm\-debuginfo\-analyzer\fP\&. We compiled the example for an X86 Codeview and ELF targets with recent versions of Clang, GCC and MSVC (\-O0 \-g). .INDENT 0.0 .INDENT 3.5 .sp .EX 1 struct Struct { 2 union Union { 3 enum NestedEnum { RED, BLUE }; 4 }; 5 Union U; 6 }; 7 8 Struct S; 9 int test() { 10 return S.U.BLUE; 11 } .EE .UNINDENT .UNINDENT .sp The above test is used to illustrate a scope issue found in the Clang compiler: \fI\%PR46466 (Bugs LLVM)\fP / \fI\%PR45811 (GitHub LLVM)\fP .sp These are the logical views that \fBllvm\-debuginfo\-analyzer\fP generates for 3 different compilers (MSVC, Clang and GCC), emitting different debug information formats (CodeView, DWARF) on different platforms. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level,format,producer \-\-output\-sort=name \-\-print=symbols,types pr\-46466\-codeview\-clang.o pr\-46466\-codeview\-msvc.o pr\-46466\-dwarf\-clang.o pr\-46466\-dwarf\-gcc.o .EE .UNINDENT .UNINDENT .SS CodeView \- Clang (Windows) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-46466\-codeview\-clang.o\(aq \-> COFF\-x86\-64 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq [002] {Producer} \(aqclang version 14.0.0\(aq [002] {Variable} extern \(aqS\(aq \-> \(aqStruct\(aq [002] 1 {Struct} \(aqStruct\(aq [003] {Member} public \(aqU\(aq \-> \(aqUnion\(aq [003] 2 {Union} \(aqUnion\(aq [004] 3 {Enumeration} \(aqNestedEnum\(aq \-> \(aqint\(aq [005] {Enumerator} \(aqBLUE\(aq = \(aq0x1\(aq [005] {Enumerator} \(aqRED\(aq = \(aq0x0\(aq .EE .UNINDENT .UNINDENT .SS CodeView \- MSVC (Windows) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-46466\-codeview\-msvc.o\(aq \-> COFF\-i386 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq [002] {Producer} \(aqMicrosoft (R) Optimizing Compiler\(aq [002] {Variable} extern \(aqS\(aq \-> \(aqStruct\(aq [002] 1 {Struct} \(aqStruct\(aq [003] {Member} public \(aqU\(aq \-> \(aqUnion\(aq [003] 2 {Union} \(aqUnion\(aq [004] 3 {Enumeration} \(aqNestedEnum\(aq \-> \(aqint\(aq [005] {Enumerator} \(aqBLUE\(aq = \(aq0x1\(aq [005] {Enumerator} \(aqRED\(aq = \(aq0x0\(aq .EE .UNINDENT .UNINDENT .SS DWARF \- Clang (Linux) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-46466\-dwarf\-clang.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq [002] {Producer} \(aqclang version 14.0.0\(aq [002] 8 {Variable} extern \(aqS\(aq \-> \(aqStruct\(aq [002] 1 {Struct} \(aqStruct\(aq [003] 5 {Member} public \(aqU\(aq \-> \(aqUnion\(aq .EE .UNINDENT .UNINDENT .SS DWARF \- GCC (Linux) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-46466\-dwarf\-gcc.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq [002] {Producer} \(aqGNU C++14 9.3.0\(aq [002] 8 {Variable} extern \(aqS\(aq \-> \(aqStruct\(aq [002] 1 {Struct} \(aqStruct\(aq [003] 5 {Member} public \(aqU\(aq \-> \(aqUnion\(aq [003] 2 {Union} \(aqUnion\(aq [004] 3 {Enumeration} \(aqNestedEnum\(aq \-> \(aqunsigned int\(aq [005] {Enumerator} \(aqBLUE\(aq = \(aq0x1\(aq [005] {Enumerator} \(aqRED\(aq = \(aq0x0\(aq .EE .UNINDENT .UNINDENT .sp From the previous logical views, we can see that the DWARF debug information generated by the Clang compiler does not include any references to the enumerators \fBRED\fP and \fBBLUE\fP\&. The DWARF generated by GCC, CodeView generated by Clang and MSVC, they do include such references. .sp Using the \fBllvm\-debuginfo\-analyzer\fP selection facilities, we can produce a logical view showing just the logical types that are \fBEnumerator\fP and its parents. The logical view is sorted by the types name. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=format,level \-\-output\-sort=name \-\-select\-types=Enumerator \-\-report=parents \-\-print=types pr\-46466\-*.o .EE .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-46466\-codeview\-clang.o\(aq \-> COFF\-x86\-64 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq [002] 1 {Struct} \(aqStruct\(aq [003] 2 {Union} \(aqUnion\(aq [004] 3 {Enumeration} \(aqNestedEnum\(aq \-> \(aqint\(aq [005] {Enumerator} \(aqBLUE\(aq = \(aq0x1\(aq [005] {Enumerator} \(aqRED\(aq = \(aq0x0\(aq Logical View: [000] {File} \(aqpr\-46466\-codeview\-msvc.o\(aq \-> COFF\-i386 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq [002] 1 {Struct} \(aqStruct\(aq [003] 2 {Union} \(aqUnion\(aq [004] 3 {Enumeration} \(aqNestedEnum\(aq \-> \(aqint\(aq [005] {Enumerator} \(aqBLUE\(aq = \(aq0x1\(aq [005] {Enumerator} \(aqRED\(aq = \(aq0x0\(aq Logical View: [000] {File} \(aqpr\-46466\-dwarf\-clang.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq Logical View: [000] {File} \(aqpr\-46466\-dwarf\-gcc.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq [002] 1 {Struct} \(aqStruct\(aq [003] 2 {Union} \(aqUnion\(aq [004] 3 {Enumeration} \(aqNestedEnum\(aq \-> \(aqunsigned int\(aq [005] {Enumerator} \(aqBLUE\(aq = \(aq0x1\(aq [005] {Enumerator} \(aqRED\(aq = \(aq0x0\(aq .EE .UNINDENT .UNINDENT .sp Using the \fBllvm\-debuginfo\-analyzer\fP selection facilities, we can produce a simple tabular output including a summary for the logical types that are \fBEnumerator\fP\&. The logical view is sorted by the types name. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=format,level \-\-output\-sort=name \-\-select\-types=Enumerator \-\-print=types,summary pr\-46466\-*.o .EE .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-46466\-codeview\-clang.o\(aq \-> COFF\-x86\-64 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq [005] {Enumerator} \(aqBLUE\(aq = \(aq0x1\(aq [005] {Enumerator} \(aqRED\(aq = \(aq0x0\(aq \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Element Total Found \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Scopes 5 0 Symbols 2 0 Types 6 2 Lines 0 0 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Total 13 2 Logical View: [000] {File} \(aqpr\-46466\-codeview\-msvc.o\(aq \-> COFF\-i386 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq [005] {Enumerator} \(aqBLUE\(aq = \(aq0x1\(aq [005] {Enumerator} \(aqRED\(aq = \(aq0x0\(aq \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Element Total Found \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Scopes 5 0 Symbols 2 0 Types 7 2 Lines 0 0 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Total 14 2 Logical View: [000] {File} \(aqpr\-46466\-dwarf\-clang.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Element Total Found \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Scopes 4 0 Symbols 0 0 Types 0 0 Lines 0 0 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Total 4 0 Logical View: [000] {File} \(aqpr\-46466\-dwarf\-gcc.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr\-46466.cpp\(aq [005] {Enumerator} \(aqBLUE\(aq = \(aq0x1\(aq [005] {Enumerator} \(aqRED\(aq = \(aq0x0\(aq \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Element Total Found \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Scopes 5 0 Symbols 0 0 Types 2 2 Lines 0 0 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Total 7 2 .EE .UNINDENT .UNINDENT .sp From the values printed under the \fBFound\fP column, we can see that no \fBTypes\fP were found in the DWARF debug information generated by Clang. .SS TEST CASE 5 \- INCORRECT LEXICAL SCOPE FOR VARIABLE .sp The below example is used to show different output generated by \fBllvm\-debuginfo\-analyzer\fP\&. We compiled the example for an X86 Codeview and ELF targets with recent versions of Clang, GCC and MSVC (\-O0 \-g). .INDENT 0.0 .INDENT 3.5 .sp .EX // definitions.h #ifdef _MSC_VER #define forceinline __forceinline #elif defined(__clang__) #if __has_attribute(__always_inline__) #define forceinline inline __attribute__((__always_inline__)) #else #define forceinline inline #endif #elif defined(__GNUC__) #define forceinline inline __attribute__((__always_inline__)) #else #define forceinline inline #error #endif .EE .UNINDENT .UNINDENT .sp As the test is dependent on inline compiler options, the above header file defines \fIforceinline\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX #include \(dqdefinitions.h\(dq .EE .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX 1 #include \(dqdefinitions.h\(dq 2 forceinline int InlineFunction(int Param) { 3 int Var_1 = Param; 4 { 5 int Var_2 = Param + Var_1; 6 Var_1 = Var_2; 7 } 8 return Var_1; 9 } 10 11 int test(int Param_1, int Param_2) { 12 int A = Param_1; 13 A += InlineFunction(Param_2); 14 return A; 15 } .EE .UNINDENT .UNINDENT .sp The above test is used to illustrate a variable issue found in the Clang compiler: \fI\%PR43860 (Bugs LLVM)\fP / \fI\%PR43205 (GitHub)\fP .sp These are the logical views that \fBllvm\-debuginfo\-analyzer\fP generates for 3 different compilers (MSVC, Clang and GCC), emitting different debug information formats (CodeView, DWARF) on different platforms. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level,format,producer \-\-output\-sort=name \-\-print=symbols pr\-43860\-codeview\-clang.o pr\-43860\-codeview\-msvc.o pr\-43860\-dwarf\-clang.o pr\-43860\-dwarf\-gcc.o .EE .UNINDENT .UNINDENT .SS CODEVIEW \- Clang (Windows) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-43860\-codeview\-clang.o\(aq \-> COFF\-x86\-64 [001] {CompileUnit} \(aqpr\-43860.cpp\(aq [002] {Producer} \(aqclang version 14.0.0\(aq [002] 2 {Function} inlined \(aqInlineFunction\(aq \-> \(aqint\(aq [003] {Parameter} \(aq\(aq \-> \(aqint\(aq [002] {Function} extern not_inlined \(aqtest\(aq \-> \(aqint\(aq [003] {Variable} \(aqA\(aq \-> \(aqint\(aq [003] {InlinedFunction} inlined \(aqInlineFunction\(aq \-> \(aqint\(aq [004] {Parameter} \(aqParam\(aq \-> \(aqint\(aq [004] {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [004] {Variable} \(aqVar_2\(aq \-> \(aqint\(aq [003] {Parameter} \(aqParam_1\(aq \-> \(aqint\(aq [003] {Parameter} \(aqParam_2\(aq \-> \(aqint\(aq .EE .UNINDENT .UNINDENT .SS CODEVIEW \- MSVC (Windows) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-43860\-codeview\-msvc.o\(aq \-> COFF\-i386 [001] {CompileUnit} \(aqpr\-43860.cpp\(aq [002] {Producer} \(aqMicrosoft (R) Optimizing Compiler\(aq [002] {Function} extern not_inlined \(aqInlineFunction\(aq \-> \(aqint\(aq [003] {Block} [004] {Variable} \(aqVar_2\(aq \-> \(aqint\(aq [003] {Variable} \(aqParam\(aq \-> \(aqint\(aq [003] {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [002] {Function} extern not_inlined \(aqtest\(aq \-> \(aqint\(aq [003] {Variable} \(aqA\(aq \-> \(aqint\(aq [003] {Variable} \(aqParam_1\(aq \-> \(aqint\(aq [003] {Variable} \(aqParam_2\(aq \-> \(aqint\(aq .EE .UNINDENT .UNINDENT .SS DWARF \- Clang (Linux) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-43860\-dwarf\-clang.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr\-43860.cpp\(aq [002] {Producer} \(aqclang version 14.0.0\(aq [002] 2 {Function} extern inlined \(aqInlineFunction\(aq \-> \(aqint\(aq [003] {Block} [004] 5 {Variable} \(aqVar_2\(aq \-> \(aqint\(aq [003] 2 {Parameter} \(aqParam\(aq \-> \(aqint\(aq [003] 3 {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [002] 11 {Function} extern not_inlined \(aqtest\(aq \-> \(aqint\(aq [003] 12 {Variable} \(aqA\(aq \-> \(aqint\(aq [003] 14 {InlinedFunction} inlined \(aqInlineFunction\(aq \-> \(aqint\(aq [004] {Block} [005] {Variable} \(aqVar_2\(aq \-> \(aqint\(aq [004] {Parameter} \(aqParam\(aq \-> \(aqint\(aq [004] {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [003] 11 {Parameter} \(aqParam_1\(aq \-> \(aqint\(aq [003] 11 {Parameter} \(aqParam_2\(aq \-> \(aqint\(aq .EE .UNINDENT .UNINDENT .SS DWARF \- GCC (Linux) .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-43860\-dwarf\-gcc.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr\-43860.cpp\(aq [002] {Producer} \(aqGNU C++14 9.3.0\(aq [002] 2 {Function} extern declared_inlined \(aqInlineFunction\(aq \-> \(aqint\(aq [003] {Block} [004] 5 {Variable} \(aqVar_2\(aq \-> \(aqint\(aq [003] 2 {Parameter} \(aqParam\(aq \-> \(aqint\(aq [003] 3 {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [002] 11 {Function} extern not_inlined \(aqtest\(aq \-> \(aqint\(aq [003] 12 {Variable} \(aqA\(aq \-> \(aqint\(aq [003] 13 {InlinedFunction} declared_inlined \(aqInlineFunction\(aq \-> \(aqint\(aq [004] {Block} [005] {Variable} \(aqVar_2\(aq \-> \(aqint\(aq [004] {Parameter} \(aqParam\(aq \-> \(aqint\(aq [004] {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [003] 11 {Parameter} \(aqParam_1\(aq \-> \(aqint\(aq [003] 11 {Parameter} \(aqParam_2\(aq \-> \(aqint\(aq .EE .UNINDENT .UNINDENT .sp From the previous logical views, we can see that the CodeView debug information generated by the Clang compiler shows the variables \fBVar_1\fP and \fBVar_2\fP are at the same lexical scope (\fB4\fP) in the function \fBInlineFuction\fP\&. The DWARF generated by GCC/Clang and CodeView generated by MSVC, show those variables at the correct lexical scope: \fB3\fP and \fB4\fP respectively. .sp Using the \fBllvm\-debuginfo\-analyzer\fP selection facilities, we can produce a simple tabular output showing just the logical elements that have in their name the \fIvar\fP pattern. The logical view is sorted by the variables name. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=level,format \-\-output\-sort=name \-\-select\-regex \-\-select\-nocase \-\-select=Var \-\-report=list \-\-print=symbols pr\-43860\-*.o .EE .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX Logical View: [000] {File} \(aqpr\-43860\-codeview\-clang.o\(aq \-> COFF\-x86\-64 [001] {CompileUnit} \(aqpr\-43860.cpp\(aq [004] {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [004] {Variable} \(aqVar_2\(aq \-> \(aqint\(aq Logical View: [000] {File} \(aqpr\-43860\-codeview\-msvc.o\(aq \-> COFF\-i386 [001] {CompileUnit} \(aqpr\-43860.cpp\(aq [003] {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [004] {Variable} \(aqVar_2\(aq \-> \(aqint\(aq Logical View: [000] {File} \(aqpr\-43860\-dwarf\-clang.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr\-43860.cpp\(aq [004] {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [003] 3 {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [005] {Variable} \(aqVar_2\(aq \-> \(aqint\(aq [004] 5 {Variable} \(aqVar_2\(aq \-> \(aqint\(aq Logical View: [000] {File} \(aqpr\-43860\-dwarf\-gcc.o\(aq \-> elf64\-x86\-64 [001] {CompileUnit} \(aqpr\-43860.cpp\(aq [004] {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [003] 3 {Variable} \(aqVar_1\(aq \-> \(aqint\(aq [005] {Variable} \(aqVar_2\(aq \-> \(aqint\(aq [004] 5 {Variable} \(aqVar_2\(aq \-> \(aqint\(aq .EE .UNINDENT .UNINDENT .sp It also shows, that the CodeView debug information does not generate source code line numbers for the those logical symbols. The logical view is sorted by the types name. .SS TEST CASE 6 \- FULL LOGICAL VIEW .sp For advanced users, \fBllvm\-debuginfo\-analyzer\fP can display low level information that includes offsets within the debug information section, debug location operands, linkage names, etc. .INDENT 0.0 .INDENT 3.5 .sp .EX llvm\-debuginfo\-analyzer \-\-attribute=all \-\-print=all test\-dwarf\-clang.o Logical View: [0x0000000000][000] {File} \(aqtest\-dwarf\-clang.o\(aq \-> elf64\-x86\-64 [0x000000000b][001] {CompileUnit} \(aqtest.cpp\(aq [0x000000000b][002] {Producer} \(aqclang version 12.0.0\(aq {Directory} \(aq\(aq {File} \(aqtest.cpp\(aq {Public} \(aqfoo\(aq [0x0000000000:0x000000003a] [0x000000000b][002] {Range} Lines 2:9 [0x0000000000:0x000000003a] [0x00000000bc][002] {BaseType} \(aqbool\(aq [0x0000000099][002] {BaseType} \(aqint\(aq [0x00000000b5][002] {BaseType} \(aqunsigned int\(aq [0x00000000a0][002] {Source} \(aq/test.cpp\(aq [0x00000000a0][002] 1 {TypeAlias} \(aqINTPTR\(aq \-> [0x00000000ab]\(aq* const int\(aq [0x000000002a][002] 2 {Function} extern not_inlined \(aqfoo\(aq \-> [0x0000000099]\(aqint\(aq [0x000000002a][003] {Range} Lines 2:9 [0x0000000000:0x000000003a] [0x000000002a][003] {Linkage} 0x2 \(aq_Z3fooPKijb\(aq [0x0000000071][003] {Block} [0x0000000071][004] {Range} Lines 5:8 [0x000000001c:0x000000002f] [0x000000007e][004] 5 {Variable} \(aqCONSTANT\(aq \-> [0x00000000c3]\(aqconst INTEGER\(aq [0x000000007e][005] {Coverage} 100.00% [0x000000007f][005] {Location} [0x000000007f][006] {Entry} Stack Offset: \-28 (0xffffffffffffffe4) [DW_OP_fbreg] [0x000000001c][004] 5 {Line} {NewStatement} \(aq/test.cpp\(aq [0x000000001c][004] {Code} \(aqmovl $0x7, \-0x1c(%rbp)\(aq [0x0000000023][004] 6 {Line} {NewStatement} \(aq/test.cpp\(aq [0x0000000023][004] {Code} \(aqmovl $0x7, \-0x4(%rbp)\(aq [0x000000002a][004] {Code} \(aqjmp 0x6\(aq [0x000000002f][004] 8 {Line} {NewStatement} \(aq/test.cpp\(aq [0x000000002f][004] {Code} \(aqmovl \-0x14(%rbp), %eax\(aq [0x0000000063][003] 2 {Parameter} \(aqParamBool\(aq \-> [0x00000000bc]\(aqbool\(aq [0x0000000063][004] {Coverage} 100.00% [0x0000000064][004] {Location} [0x0000000064][005] {Entry} Stack Offset: \-21 (0xffffffffffffffeb) [DW_OP_fbreg] [0x0000000047][003] 2 {Parameter} \(aqParamPtr\(aq \-> [0x00000000a0]\(aqINTPTR\(aq [0x0000000047][004] {Coverage} 100.00% [0x0000000048][004] {Location} [0x0000000048][005] {Entry} Stack Offset: \-16 (0xfffffffffffffff0) [DW_OP_fbreg] [0x0000000055][003] 2 {Parameter} \(aqParamUnsigned\(aq \-> [0x00000000b5]\(aqunsigned int\(aq [0x0000000055][004] {Coverage} 100.00% [0x0000000056][004] {Location} [0x0000000056][005] {Entry} Stack Offset: \-20 (0xffffffffffffffec) [DW_OP_fbreg] [0x000000008d][003] 4 {TypeAlias} \(aqINTEGER\(aq \-> [0x0000000099]\(aqint\(aq [0x0000000000][003] 2 {Line} {NewStatement} \(aq/test.cpp\(aq [0x0000000000][003] {Code} \(aqpushq %rbp\(aq [0x0000000001][003] {Code} \(aqmovq %rsp, %rbp\(aq [0x0000000004][003] {Code} \(aqmovb %dl, %al\(aq [0x0000000006][003] {Code} \(aqmovq %rdi, \-0x10(%rbp)\(aq [0x000000000a][003] {Code} \(aqmovl %esi, \-0x14(%rbp)\(aq [0x000000000d][003] {Code} \(aqandb $0x1, %al\(aq [0x000000000f][003] {Code} \(aqmovb %al, \-0x15(%rbp)\(aq [0x0000000012][003] 3 {Line} {NewStatement} {PrologueEnd} \(aq/test.cpp\(aq [0x0000000012][003] {Code} \(aqtestb $0x1, \-0x15(%rbp)\(aq [0x0000000016][003] {Code} \(aqje 0x13\(aq [0x0000000032][003] 8 {Line} \(aq/test.cpp\(aq [0x0000000032][003] {Code} \(aqmovl %eax, \-0x4(%rbp)\(aq [0x0000000035][003] 9 {Line} {NewStatement} \(aq/test.cpp\(aq [0x0000000035][003] {Code} \(aqmovl \-0x4(%rbp), %eax\(aq [0x0000000038][003] {Code} \(aqpopq %rbp\(aq [0x0000000039][003] {Code} \(aqretq\(aq [0x000000003a][003] 9 {Line} {NewStatement} {EndSequence} \(aq/test.cpp\(aq \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Element Total Printed \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Scopes 3 3 Symbols 4 4 Types 5 5 Lines 25 25 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Total 37 37 Scope Sizes: 189 (100.00%) : [0x000000000b][001] {CompileUnit} \(aqtest.cpp\(aq 110 ( 58.20%) : [0x000000002a][002] 2 {Function} extern not_inlined \(aqfoo\(aq \-> [0x0000000099]\(aqint\(aq 27 ( 14.29%) : [0x0000000071][003] {Block} Totals by lexical level: [001]: 189 (100.00%) [002]: 110 ( 58.20%) [003]: 27 ( 14.29%) .EE .UNINDENT .UNINDENT .sp The \fBScope Sizes\fP table shows the contribution in bytes to the debug information by each scope, which can be used to determine unexpected size changes in the DWARF sections between different versions of the same toolchain. .INDENT 0.0 .INDENT 3.5 .sp .EX [0x000000002a][002] 2 {Function} extern not_inlined \(aqfoo\(aq \-> [0x0000000099]\(aqint\(aq [0x000000002a][003] {Range} Lines 2:9 [0x0000000000:0x000000003a] [0x000000002a][003] {Linkage} 0x2 \(aq_Z3fooPKijb\(aq [0x0000000071][003] {Block} [0x0000000071][004] {Range} Lines 5:8 [0x000000001c:0x000000002f] [0x000000007e][004] 5 {Variable} \(aqCONSTANT\(aq \-> [0x00000000c3]\(aqconst INTEGER\(aq [0x000000007e][005] {Coverage} 100.00% [0x000000007f][005] {Location} [0x000000007f][006] {Entry} Stack Offset: \-28 (0xffffffffffffffe4) [DW_OP_fbreg] .EE .UNINDENT .UNINDENT .sp The \fB{Range}\fP attribute describe the line ranges for a logical scope. For this case, the function \fBfoo\fP is within the lines \fB2\fP and \fB9\fP\&. .sp The \fB{Coverage}\fP and \fB{Location}\fP attributes describe the debug location and coverage for logical symbols. For optimized code, the coverage value decreases and it affects the program debuggability. .SH EXIT STATUS .sp \fBllvm\-debuginfo\-analyzer\fP returns 0 if the input files were parsed and printed successfully. Otherwise, it returns 1. .SH SEE ALSO .sp \fBllvm\-dwarfdump\fP .SH AUTHOR Maintained by the LLVM Team (https://llvm.org/). .SH COPYRIGHT 2003-2024, LLVM Project .\" Generated by docutils manpage writer. .