<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 3, 2015 at 12:16 AM, Aboud, Amjad <span dir="ltr"><<a href="mailto:amjad.aboud@intel.com" target="_blank">amjad.aboud@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div><span class="">
<p class="MsoNormal">> Do we really need to touch the AST? Or would it be reasonable to wire up the CGDebugInfo directly to the PPCallbacks, if it isn't already? (perhaps it is already wired up for other reasons?)<u></u><u></u></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">This sound as a good idea, I will check that approach.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">PPCallbacks is only an interface, has nothing connected to it, but we will create a new class, which implement PPCallbacks, for macros.</span></p></div></div></blockquote><div><br></div><div>Right - I was wondering if CGDebugInfo already implemented PPCallbacks or was otherwise being notified of PPCallback related things, possibly through a layer or two of indirection.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"> So we can connect whatever
we want to that class.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">The only drawback with this approach, is that we can test the frontend using the generated LLVM IR, i.e. the whole path, instead of having two tests, AST for
testing the parser, and LLVM IR for testing the Sema.</span></p></div></div></blockquote><div><br></div><div>We don't usually do direct AST tests in Clang for debug info (or for many things, really) - we just do source -> llvm IR anyway, so that's nothing out of the ordinary.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span class="">> I wonder if it'd be better to use a parent chain style approach (DIMacro has a DIMacroFile it refers to, each DIMacroFile has another one that it refers to, up to null)?<br>
> (does it ever make sense/need to have a DIMacroFile without any macros in it? I assume not?)<br>
</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">First, it seems that GCC does emit MacroFile that has no macros inside (I understand that it might not be useful, but I am not sure if we should ignore that or not).</span></p></div></div></blockquote><div><br></div><div>Yeah, that's weird - I'd sort of be inclined to skip it until we know what it's useful for.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Second, I assume that you are suggesting the parent chain style instead to the current children style, right?</span></p></div></div></blockquote><div><br></div><div>Correct</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">In this case, won’t it make the debug emitter code much complicated to figure out the DFS tree, </span></p></div></div></blockquote><div><br></div><div>I don't quite imagine it would be more complicated - we would just be building the file parent chain as we go, and keeping the current macro file around to be used as the parent to any macros we create.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">which should be emitted for the macros, not mentioning the macro
order which will be lost?</span></p></div></div></blockquote><div><br></div><div>Not necessarily, if we kept the macros in order in the list of macros attached to the CU, which I imagine we would.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Also, remember that the command line macros have no DIMacroFile parent.</span></p></div></div></blockquote><div><br></div><div>Fair - they could have the null parent, potentially.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">However, if you meant to use the parent chain in addition to the children list, then what extra information it will give us?<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><br>
<br>
>Might be good to start with dwarfdump support - seems useful regardless of anything else?<u></u><u></u></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">I agree, and in fact, I already have this code implemented, will upload it for review soon.</span></p></div></div></blockquote><div><br></div><div>Cool</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Amjad<u></u><u></u></span></p>
<p class="MsoNormal"><a name="150cc6d4b9a3b1ec__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></a></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>]
<br>
<b>Sent:</b> Tuesday, November 03, 2015 00:32<br>
<b>To:</b> Aboud, Amjad<span class=""><br>
<b>Cc:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> Re: [llvm-dev] RFC: Supporting macros in LLVM debug info<u></u><u></u></span></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Wed, Oct 28, 2015 at 7:56 AM, Aboud, Amjad via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p><div><div class="h5">
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="color:black">Hi,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">I would like to implement macro debug info support in LLVM.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Below you will find 4 parts:</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">1.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">Background on what does it mean to debug macros.</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">2.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">A brief explanation on how to represent macro debug info in DWARF 4.0.</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">3.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">The suggested design.</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">4.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">A full example: Source -> AST -> LLVM IR -> DWARF.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Feel free to skip first two parts if you think you know the background.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Please, let me know if you have any comment or feedback on this approach.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Amjad</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="color:black">[Background]</span></b><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">There are two kind of macro definition:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">1. Simple macro definition, e.g. #define M1 Value1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">2. Function macro definition, e.g. #define M2(x, y) (x) + (y)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Macro scope starts with the "#define" directive and ends with "#undef" directive.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">GDB supports debugging macros. This means, it can evaluate the macro expression for all macros, which have a scope that interleaves with the current breakpoint.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">For example:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">GDB command: print M2(3, 5)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">GDB Result: 8
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">GDB can evaluate the macro expression based on the ".debug_macroinfo" section (DWARF 4.0).</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="color:black">[DWARF 4.0 ".debug_macroinfo" section]</span></b><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">In this section there are 4 kinds of entries</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">1.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">DW_MACROINFO_define</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">2.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">DW_MACROINFO_undef</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">3.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">DW_MACROINFO_start_file</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">4.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">DW_MACROINFO_end_file</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Note: There is a 5th kind of entry for vendor specific macro information, that we do not need to support.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">The first two entries contain information about the line number where the macro is defined/undefined, and a null terminated string, which contain the macro
name (followed by the replacement value in case of a definition, or a list of parameters then the replacement value in case of function macro definition).</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">The third entry contains information about the line where the file was included followed by the file id (an offset into the files table in the debug line
section).</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">The fourth entry contains nothing, and it just close the previous entry of third kind (start_file) .</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Macro definition and file including entries must appear at the same order as they appear in the source file. Where all macro entries between "start_file"
and "end_file" entries represent macros appears directly/indirectly in the included file.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Special cases:</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">1.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">The main source file should be the first "start_file" entry in the sequence, and should have line number "0".</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">2.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">Command line/Compiler definitions must also have line number "0" but must appear before the first "start_file" entry.</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">3.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">Command line include files, must also have line number "0" but will appear straight after the "start_file" of the main source.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="color:black">[Design]</span></b><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">To support macros the following components need to be modified: Clang, LLVM IR, Dwarf Debug emitter.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">In clang, we need to handle these source directives:</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">1.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">#define</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">2.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">#undef</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="color:black">3.</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">#include</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">The idea is to make a use of "PPCallbacks" class, which allows preprocessor to notify the parser each time one of the above directives occurs.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">These are the callbacks that should be implemented:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">"MacroDefined", "MacroUndefined", "FileChanged", and "InclusionDirective".</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">AST will be extended to support two new DECL types: "MacroDecl" and "FileIncludeDecl".</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Do we really need to touch the AST? Or would it be reasonable to wire up the CGDebugInfo directly to the PPCallbacks, if it isn't already? (perhaps it is already wired up for other reasons?)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="color:black">Where "FileIncludeDecl" AST might contain other "FileIncludeDecl"/"MacroDecl" ASTs.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">These two new AST DECLs are not part of TranslationUnitDecl and are handled separately (see AST example below).</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">In the LLVM IR, metadata debug info will be extended to support new DIs as well:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">"DIMacro", "DIFileInclude", and "MacroNode".</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">The last, is needed as we cannot use DINode as a base class of "DIMacro" and DIFileInclude" nodes.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">DIMacro will contain:</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="font-size:10.0pt;font-family:Symbol;color:black">·</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">type (definition/undefinition).</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="font-size:10.0pt;font-family:Symbol;color:black">·</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">line number (interger).</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="font-size:10.0pt;font-family:Symbol;color:black">·</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">name (null terminated string).</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="font-size:10.0pt;font-family:Symbol;color:black">·</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">replacement value (null terminated string - optional).</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">DIFileMacro will contain:</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="font-size:10.0pt;font-family:Symbol;color:black">·</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">line number (interger).</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="font-size:10.0pt;font-family:Symbol;color:black">·</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">file (DIFile).</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:27.0pt;vertical-align:middle">
<span style="font-size:10.0pt;font-family:Symbol;color:black">·</span><span style="font-size:7.0pt;color:black">
</span><span style="color:black">macro list (MacroNodeArray) - optional.</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I wonder if it'd be better to use a parent chain style approach (DIMacro has a DIMacroFile it refers to, each DIMacroFile has another one that it refers to, up to null)?<br>
(does it ever make sense/need to have a DIMacroFile without any macros in it? I assume not?)<br>
<br>
<br>
Might be good to start with dwarfdump support - seems useful regardless of anything else?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">In addition, the DICompileUnit will contain a new optional field of macro list of type (MacroNodeArray).</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Finally, I assume that macro support should be disabled by default, and there should be a flag to enable this feature. I would say that we should introduce
a new specific flag, e.g. "-gmacro", that could be used with "-g". </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="color:black">[Example]</span></b><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Here is an example that demonstrate the macro support from Source->AST->LLVM IR->DWARF.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Source</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">=========================================================</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">mainfile.c:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">--------------------------------------------------------------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">1. #define M1 Value1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">2. #include "myfile.h"</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">3. #define M2( x , y) ( (x) + (y) * Value2)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">--------------------------------------------------------------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">myfile.h:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">--------------------------------------------------------------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">1.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">2.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">3.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">4. #undef M1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">5. #define M1 NewValue1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">--------------------------------------------------------------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">myfile2.h:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">--------------------------------------------------------------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">1. #define M4 Value4</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">--------------------------------------------------------------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">=========================================================</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Command line:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">clang -c -g -gmacro -O0 -DM3=Value3 -include myfile2.h mainfile.c</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">AST</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">=========================================================</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">MacroDecl 0xd6c5c0 <<invalid sloc>> <invalid sloc> __llvm__ defined</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">MacroDecl 0xd6c618 <<invalid sloc>> <invalid sloc> __clang__ defined</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">… <More compiler macros> …</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">MacroDecl 0x11c01b0 <<invalid sloc>> <invalid sloc> M3 defined</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">FileIncludeDecl 0x11c0208 <mainfile.c:1:1> col:1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">|-FileIncludeDecl 0x11c0238 <myfile2.h:1:1> col:1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">| `-MacroDecl 0x11c0268 <<invalid sloc>> <invalid sloc> M4 defined</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">|-MacroDecl 0x11c02c0 <mainfile.c:1:9> col:9 M1 defined</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">|-FileIncludeDecl 0x11c0318 <myfile.h:1:1> col:1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">| |-MacroDecl 0x11c0348 <line:4:8> col:8 M1 undefined</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">| `-MacroDecl 0x11c03a0 <line:5:9> col:9 M1 defined</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">`-MacroDecl 0x11c03f8 <mainfile.c:3:9> col:9 M2 defined</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">TranslationUnitDecl 0xd6c078 <<invalid sloc>> <invalid sloc></span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">|-TypedefDecl 0xd6c330 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">|-TypedefDecl 0xd6c370 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">|-TypedefDecl 0xd6c3c8 <<invalid sloc>> <invalid sloc> implicit __builtin_ms_va_list 'char *'</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">`-TypedefDecl 0xd6c590 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list 'struct __va_list_tag [1]'</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">=========================================================</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">LLVM IR</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">=========================================================</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">target triple = "x86_64-pc-linux"</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!<a href="http://llvm.dbg.cu" target="_blank">llvm.dbg.cu</a> = !{!0}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!llvm.module.flags = !{!327}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!llvm.ident = !{!328}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 251321)", isOptimized: false, runtimeVersion: 0, emissionKind:
1, enums: !2, macros: !3)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!1 = !DIFile(filename: "mainfile.c", directory: "/")</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!2 = !{}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!3 = !{!4, !5, … <More compiler macros> … , !312, !313}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!4 = !DIMacro(macro type: DW_MACINFO_define, name: "__llvm__", value: !"1")</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!5 = !DIMacro(macro type: DW_MACINFO_define, name: "__clang__", value: !"1")</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">… <More compiler macros> …</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!312 = !DIMacro(macro type: DW_MACINFO_define, name: "M3", value: !"Value3")</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!313 = !DIFileInclude(file: !314, nodes: !315)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!314 = !DIFile(filename: "mainfile.c", directory: "/")</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!315 = !{!316, !320, !321, !326}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!316 = !DIFileInclude(file: !317, nodes: !318)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!317 = !DIFile(filename: "myfile2.h", directory: "/")</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!318 = !{!319}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!319 = !DIMacro(macro type: DW_MACINFO_define, name: "M4", value: !"Value4")</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!320 = !DIMacro(macro type: DW_MACINFO_define, name: "M1", line: 1, value: !"Value1")</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!321 = !DIFileInclude(line: 2, file: !322, nodes: !323)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!322 = !DIFile(filename: "myfile.h", directory: "/")</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!323 = !{!324, !325}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!324 = !DIMacro(macro type: DW_MACINFO_undef, name: "M1", line: 4)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!325 = !DIMacro(macro type: DW_MACINFO_define, name: "M1", line: 5, value: !"NewValue1")</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!326 = !DIMacro(macro type: DW_MACINFO_define, name: "M2(x,y)", line: 3, value: !"( (x) + (y) * Value2)")</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!327 = !{i32 2, !"Debug Info Version", i32 3}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">!328 = !{!"clang version 3.8.0 (trunk 251321)"}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">=========================================================</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">DWARF</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">=========================================================</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Command line: llvm-dwarfdump.exe -debug-dump=macro mainfile.o</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">--------------------------------------------------------------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">mainfile3.o: file format ELF64-x86-64</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">.debug_macinfo contents:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">DW_MACINFO_define - lineno: 0 macro: __llvm__ 1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">DW_MACINFO_define - lineno: 0 macro: __clang__ 1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">… <More compiler macros> …</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">DW_MACINFO_define - lineno: 0 macro: M3 Value3</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">DW_MACINFO_start_file - lineno: 0 filenum: 1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> DW_MACINFO_start_file - lineno: 0 filenum: 2</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> DW_MACINFO_define - lineno: 0 macro: M4 Value4</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> DW_MACINFO_end_file</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> DW_MACINFO_define - lineno: 1 macro: M1 Value1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> DW_MACINFO_start_file - lineno: 2 filenum: 3</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> DW_MACINFO_undef - lineno: 4 macro: M1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> DW_MACINFO_define - lineno: 5 macro: M1 NewValue1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> DW_MACINFO_end_file</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> DW_MACINFO_define - lineno: 3 macro: M2(x,y) ( (x) + (y) * Value2)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">DW_MACINFO_end_file</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">--------------------------------------------------------------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">Command line: llvm-dwarfdump.exe -debug-dump=line mainfile.o</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">--------------------------------------------------------------------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">.debug_line contents:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">… <Other line table Info> …</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> Dir Mod Time File Len File Name</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black"> ---- ---------- ---------- ---------------------------</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">file_names[ 1] 1 0x00000000 0x00000000 mainfile.c</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">file_names[ 2] 1 0x00000000 0x00000000 myfile2.h</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">file_names[ 3] 1 0x00000000 0x00000000 myfile.h</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:black">=========================================================</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited<u></u><u></u></p>
<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u></u><u></u></p>
</blockquote>
</div></div></div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div><div><div class="h5">
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited</p>
<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></div></div></div>
</blockquote></div><br></div></div>