<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:Consolas">llvm-diva - Debug Information Visual Analyzer<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Carlos Alberto Enciso, Sony Interactive Entertainment<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">LLVM supports multiple debug information formats (namely DWARF and CodeView)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">in different binary formats (e.g. ELF, PDB, Mach-O). Understanding the mappings<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">between source code and debug information can be complex, and it's a problem<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">we've commonly encountered when triaging debug information issues.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The output from tools such as llvm-dwarfdump or llvm-readobj use a close<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">representation of the internal debug information format and in our experience<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">we've found that they require a good knowledge of those formats to understand<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">the output, limiting who can triage and address such issues quickly. Even for<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">the experts, it can sometimes take a lot of time and effort to triage issues<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">due to the inherent complexity.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">=========<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">llvm-diva<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">=========<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">At Sony, we've been developing an LLVM-based debug information analysis tool<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">which we've called llvm-diva (short for LLVM debug information visual analyzer),<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">designed to visualize these mappings. It's based entirely on the existing LLVM<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">libraries for debug info parsing, target support, etc. and at this stage we<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">believe that its proven its worth internally to the point where we would like<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">to propose upstreaming it as part of the mainline LLVM project alongside<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">existing tools such as llvm-dwarfdump.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">llvm-diva is a command line tool that process debug info contained in a binary<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">file produces a debug information format agnostic "Logical View", which is a<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">high-level semantic representation of the debug info, independent of the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">low-level format.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The logical view is composed of the tradition programming elements as: scopes,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">types, symbols, lines. These elements can display additional information, such<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">as variable coverage factor, lexical block level, disassembly code, code<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">ranges, etc.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The diversity of llvm-diva command line options enables the creation of very<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">rich logical views to include more low-level debug information:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">disassembly code associated with the debug lines, variables runtime location<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">and coverage, internal offsets for the elements within the binary file, etc.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">With llvm-diva, we aim to address the following points:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">* Which variables are dropped due to optimization?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">* Why I can't stop at a particular line?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">* Which lines are associated to a specific code range?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">* Does the debug information represent the original source?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">* What is the semantic difference between the debug info generated by different<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> toolchain versions?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">=============<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Printing Mode<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">=============<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">In this mode llvm-diva prints the logical view or portions of it, based on<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">criteria patterns (including regular expressions) to select the kind of logical<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">elements to be included in the output.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The below example is used to show different output generated by llvm-diva.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">We then compiled it for an x86 elf target with a recent version of clang (-O0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-g):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">1 using INTPTR = const int *;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">2 int foo(INTPTR ParamPtr, unsigned ParamUnsigned, bool ParamBool) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">3 if (ParamBool) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">4 typedef int INTEGER;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">5 const INTEGER CONSTANT = 7;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">6 return CONSTANT;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">7 }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">8 return ParamUnsigned;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">9 }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Print basic details<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The following command prints basic details for the all logical elements sorted<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">by the debug information internal offset; it includes its lexical level. Each<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">row represents some element that is present within the debug information. The<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">first column represents the scope level, followed by the associated line number<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">(if any), and finally the description of the element.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">llvm-diva --sort=offset<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> --attribute=level<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> --print=scopes,symbols,types,lines<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> test.o<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Logical View:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[000] {File} 'test.o'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[001] {CompileUnit} 'test.cpp'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] 2 {Function} extern not_inlined 'foo' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 2 {Parameter} 'ParamPtr' -> 'INTPTR'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 2 {Parameter} 'ParamUnsigned' -> 'unsigned int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 2 {Parameter} 'ParamBool' -> 'bool'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Block}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] 5 {Variable} 'CONSTANT' -> 'const INTEGER'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] 5 {Line}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] 6 {Line}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 4 {TypeAlias} 'INTEGER' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 2 {Line}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 3 {Line}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 8 {Line}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 8 {Line}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 9 {Line}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] 1 {TypeAlias} 'INTPTR' -> '* const int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] 9 {Line}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Looking at the output we can see that it shows the semantics of the debug<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">information but decoupled from the underlying DWARF representation.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">On closer inspection, we can see what could be a potential debug issue:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Block}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 4 {TypeAlias} 'INTEGER' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The 'INTEGER' definition is at level [003], the same lexical scope as the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">anonymous {Block} ('true' branch for the 'if' statement) whereas in the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">original source code the typedef statement is clearly inside that block, so the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">'INTEGER' definition should also be at level [004] inside the block.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Select logical elements<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">This feature allow selecting specific logical elements; the patterns used as<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">criteria can include regular expressions. The output layout is controlled by<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">the '--report' option to have a tabular report, a tree view showing the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">parents hierarchy for the logical element that matches the criteria, or just a<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">summary with the number of occurrences.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The following prints all symbols and types that contain 'inte' in their names<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">or types, using a tab layout and given the number of matches.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">llvm-diva --select-nocase --select-regex --report=details,summary<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> --select=INTe<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> --attribute=level --print=symbols,types,instructions<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> test.o<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Logical View:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[000] {File} 'test.o'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 4 {TypeAlias} 'INTEGER' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] 5 {Variable} 'CONSTANT' -> 'const INTEGER'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Element Total Found<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Scopes 4 0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Symbols 4 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Types 2 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Lines 16 0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Total 26 2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">===============<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Comparison Mode<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">===============<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">In this mode llvm-diva compares logical views to produce a report with the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">logical elements that are missing or added. We've found this a very powerful<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">aid in finding semantic differences in the debug information produced by<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">different toolchain versions or even completely different toolchains altogether<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">(For example a compiler producing DWARF can be directly compared against a<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">completely different compiler that produces CodeView).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">There are 2 comparison methods: logical view and logical elements. The first<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">one compares the logical view as a whole unit; for a match, each compared<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">logical element must have the same parents and children. The second one<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">compares individual logical elements without considering if their parents are<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">the same. For both comparison methods, the equal criteria includes the name,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">source code location, type, lexical scope level.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Given our previous example we found the above debug information issue (related<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">to the previous invalid scope location for the 'typedef int INTEGER') by<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">comparing against another compiler.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">1 using INTPTR = const int *;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">2 int foo(INTPTR ParamPtr, unsigned ParamUnsigned, bool ParamBool) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">3 if (ParamBool) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">4 typedef int INTEGER;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">5 const INTEGER CONSTANT = 7;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">6 return CONSTANT;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">7 }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">8 return ParamUnsigned;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">9 }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Using GCC to generate test-gcc.o, we can apply a selection pattern with the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">printing mode to obtain the following output.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">llvm-diva --select-regex --select-nocase --report=details<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> --select=INTe<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> --attribute=level<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> --print=symbols,types<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> test.o test-gcc.o<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Logical View:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[000] {File} 'test.o'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 4 {TypeAlias} 'INTEGER' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] 5 {Variable} 'CONSTANT' -> 'const INTEGER'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Logical View:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[000] {File} 'test-gcc.o'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] 4 {TypeAlias} 'INTEGER' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] 5 {Variable} 'CONSTANT' -> 'const INTEGER'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The output shows that both objects contain the same elements. But the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">'typedef INTEGER' is located at different scope level. The GCC generated<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">object, shows '4', which is the correct value.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Note that there is no requirement that GCC must produce identical or similar<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">DWARF to clang in this case to allow the comparison. We're only comparing the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">semantics.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Using the llvm-diva comparison functionality, that issue can be seen in a more<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">global context, that can include the logical view.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">llvm-diva --compare=types --report=details,summary<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> --attribute=level<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> --print=symbols,types<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> test.o test-gcc.o<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Reference: 'test.o'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Target: 'test-gcc.o'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">(1) Missing Types:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-[003] 4 {TypeAlias} 'INTEGER' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">(1) Added Types:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">+[004] 4 {TypeAlias} 'INTEGER' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">----------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Element Expected Missing Added<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">----------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Scopes 4 0 0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Symbols 0 0 0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Types 2 1 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Lines 0 0 0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">----------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Total 6 1 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The output shows in tabular form the missing (-), added (+) elements, giving<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">more context by swapping the reference and target object files.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">llvm-diva --compare=types --report=view<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> --attribute=level<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> --print=symbols,types<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> test.o test-gcc.o<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Reference: 'test.o'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Target: 'test-gcc.o'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Logical View:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[000] {File} 'test.o'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[001] {CompileUnit} 'test.cpp'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] 1 {TypeAlias} 'INTPTR' -> '* const int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] 2 {Function} extern not_inlined 'foo' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Block}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] 5 {Variable} 'CONSTANT' -> 'const INTEGER'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">+[004] 4 {TypeAlias} 'INTEGER' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 2 {Parameter} 'ParamBool' -> 'bool'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 2 {Parameter} 'ParamPtr' -> 'INTPTR'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 2 {Parameter} 'ParamUnsigned' -> 'unsigned int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-[003] 4 {TypeAlias} 'INTEGER' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The output shows the merging view path (reference and target) with the missing<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">and added elements.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Comparing toolchains<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">--------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">In the previous section, we compared GCC and Clang. The current implementation<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">of llvm-diva have sufficient support for CodeView format, making possible the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">comparison between MSVC and Clang compilers.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">pr_44884.cpp<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">1 int bar(float Input) { return (int)Input; }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">2 <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> 3 unsigned foo(char Param) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">4 typedef int INT; // ** Definition for INT **<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">5 INT Value = Param;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">6 {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">7 typedef float FLOAT; // ** Definition for FLOAT **<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">8 {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">9 FLOAT Added = Value + Param;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">10 Value = bar(Added);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">11 }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">12 }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">13 return Value + Param;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">14 }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The above test (from PR44884) is used to illustrates a scope issue found in<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">the Clang compiler.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">See: https://bugs.llvm.org/show_bug.cgi?id=44884<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The lines 4 and 7 contains 2 typedefs, defined at different lexical scopes.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">4 typedef int INT;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">7 typedef float FLOAT;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">These are the logical views that llvm-diva generates for 3 different compilers<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">(MSVC, Clang and GCC), emitting different debug info formats (CodeView, DWARF)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">on different platforms.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">pr_44884_dw.o - Compiled with Clang (DWARF format).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Logical View:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[000] {File} 'pr_44884_dw.o' -> elf64-x86-64<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[001] {CompileUnit} 'pr_44884.cpp'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] {Producer} 'clang version 11.0.0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] 7 {Function} extern not_inlined 'bar' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 7 {Parameter} 'Input' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] 9 {Function} extern not_inlined 'foo' -> 'unsigned int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Block}
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] 15 {Variable} 'Added' -> 'FLOAT'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 9 {Parameter} 'Param' -> 'char'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 13 {TypeAlias} 'FLOAT' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 10 {TypeAlias} 'INT' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 11 {Variable} 'Value' -> 'INT'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">pr_44884_gc.o - Compiled with GCC (DWARF Format).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Logical View:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[000] {File} 'pr_44884_gc.o' -> elf64-x86-64<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[001] {CompileUnit} 'pr_44884.cpp'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] {Producer} 'GNU C++ 5.5.0 20171010'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] 7 {Function} extern not_inlined 'bar' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 7 {Parameter} 'Input' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] 9 {Function} extern not_inlined 'foo' -> 'unsigned int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Block}
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] {Block}
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[005] 15 {Variable} 'Added' -> 'FLOAT'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] 13 {TypeAlias} 'FLOAT' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 9 {Parameter} 'Param' -> 'char'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 10 {TypeAlias} 'INT' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] 11 {Variable} 'Value' -> 'INT'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">pr_44884_cv.o - Compiled with Clang (CodeView format).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Logical View:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[000] {File} 'pr_44884_cv.o' -> COFF-x86-64<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[001] {CompileUnit} 'pr_44884.cpp'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] {Producer} 'clang version 11.0.0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] {Function} extern not_inlined 'bar' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Parameter} 'Input' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] {Function} extern not_inlined 'foo' -> 'unsigned'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Block}
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] {Variable} 'Added' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Parameter} 'Param' -> 'char'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {TypeAlias} 'FLOAT' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {TypeAlias} 'INT' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Variable} 'Value' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">pr_44884_ms.o - Compiled with MSVC (CodeView Format).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-----------------------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Logical View:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[000] {File} 'pr_44884_ms.o' -> COFF-i386<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[001] {CompileUnit} 'pr_44884.cpp'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] {Producer} 'Microsoft (R) Optimizing Compiler'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] {Function} extern not_inlined 'bar' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Parameter} 'Input' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[002] {Function} extern not_inlined 'foo' -> 'unsigned'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Block}
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] {Block}
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[005] {Variable} 'Added' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[004] {TypeAlias} 'FLOAT' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Parameter} 'Param' -> 'char'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {TypeAlias} 'INT' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">[003] {Variable} 'Value' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">From the previous logical views, we can see that the Clang compiler emits both<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">typedefs at the same lexical scope (3), which is wrong, while GCC and MSVC emit<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">correct lexical scope for both typedefs.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">---------+----------+----------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Compiler | Format | Lexical Scope<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">---------|----------|----------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Clang | DWARF | [003] 13 {TypeAlias} 'FLOAT' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> | | [003] 10 {TypeAlias} 'INT' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">---------|----------+----------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">GCC | DWARF | [004] 13 {TypeAlias} 'FLOAT' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> | | [003] 10 {TypeAlias} 'INT' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">---------|----------|----------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Clang | CodeView | [003] {TypeAlias} 'FLOAT' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> | | [003] {TypeAlias} 'INT' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">---------|----------|----------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">MSVC | CodeView | [004] {TypeAlias} 'FLOAT' -> 'float'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"> | | [003] {TypeAlias} 'INT' -> 'int'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">---------+----------+----------------------------------------------------------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Note: One of the main limitations while processing CodeView debug info, is the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">reduced line information emitted for types and symbols, making difficult to use<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">the comparison feature within llvm-diva, as the line numbers are one of the<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">criteria for logical element match. In the meantime, any graphical comparison<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">tool is able to compare and show the logical view differences.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The above table shows the omitted line numbers for the referenced typedefs.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">==============<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Current Status<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">==============<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Generates complete logical views for DWARF including:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- Scopes, symbols, types, lines.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- Variable location, coverage and location gaps.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- Disassembly of text sections associated with .debug_line records.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- Emission of warnings for invalid ranges, lines with line zero.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- Comparison: logical views and elements.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Generates partial logical views for COFF/CodeView (objects and PDB), including:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- Scopes, symbols, types, lines.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- Comparison: logical views and elements.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">During the development of llvm-diva, we have found the following LLVM debug<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">issues:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- PR43860 - COFF Debug info shows variable at the wrong lexical scope<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- PR43905 - COFF Debug info missing nested enumeration<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- PR44884 - Debug information shows incorrect lexical scope for typedef<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- PR46361 - [CodeView] Omitted class member function declaration for lambda<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- PR46394 - [CodeView] Missing LF_NESTTYPE with nested templates<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">==============<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Work remaining<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">==============<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The following are the main tasks that needs to be finished:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- Logical View in JSON format. Currently it uses free form text style.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- COFF/CodeView disassembly text sections.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">- COFF/CodeView ranges and locations.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">==========<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Conclusion<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">==========<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The source code has been uploaded for review on phabricator at this link:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">https://reviews.llvm.org/Dxxxx.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">The review covers two patches:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">A first patch with a IntervalTree data structure implementation which is<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">required by llvm-diva.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">A second patch with the actual tool (in llvm/tools/llvm-diva).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Once these first two patches are committed, the plan is to keep working on<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">llvm-diva with the help of the community to address current limitations and<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">find good solutions/fixes for any design issues.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">We hope the community will find llvm-diva useful like we have.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Special thanks to Orlando Cazalet-Hyams by testing the tool and to Greg Bedwell,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Phillip Power and Paul Robinson by suggesting improvements and reviewing the tool
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">documentation.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">Thanks for your time.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">-Carlos<o:p></o:p></span></p>
</div>
<style type="text/css">.style1 {font-family: "Times New Roman";}</style><mc type="body"><br>
<br>
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"><br>
********************************************************************** <br>
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify
</span><a href="mailto:siee.postmaster@sony.com" target="_blank"><span style="font-size:10.0pt;font-family:">siee.postmaster@sony.com</span></a><span style="font-size:10.0pt;font-family:"><br>
This footnote also confirms that this email message has been checked for all known viruses.<br>
Sony Interactive Entertainment Europe Limited<br>
Registered Office: 10 Great Marlborough Street, London W1F 7LP, United Kingdom<br>
Registered in England: 3277793<br>
**********************************************************************<br>
</span><span style="font-size:18.0pt;font-family:Webdings;color:green"><br>
P</span><b><i><span style="font-size:10.0pt;font-family:"> Please consider the environment before printing this e-mail</span></i></b>
</p>
</div>
</body>
</html>