<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=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.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="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">In SymbolFileDWARF::FindFunctions (), there is code that runs only for Linux and BSD. That finds the function in global namespace.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Abid<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> lldb-dev-bounces@cs.uiuc.edu [mailto:lldb-dev-bounces@cs.uiuc.edu]
<b>On Behalf Of </b>Zachary Turner<br>
<b>Sent:</b> 12 January 2015 19:51<br>
<b>To:</b> lldb-dev@cs.uiuc.edu; Jim Ingham<br>
<b>Subject:</b> [lldb-dev] Problem with ClangExpressionDeclMap<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Was looking into <a href="http://llvm.org/bugs/show_bug.cgi?id=22177">
this bug</a> on Windows, and I traced it down to an issue in ClangExpressionDeclMap. ClangExpressionDeclMap::FindExternalVisibleDecls has a piece of code that looks like this:<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"> if (namespace_decl && module_sp)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> const bool include_symbols = false;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> module_sp->FindFunctions(name,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> &namespace_decl,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> eFunctionNameTypeBase,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> include_symbols,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> include_inlines,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> append,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> sc_list);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> }<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> else if (target && !namespace_decl)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> const bool include_symbols = true;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> // TODO Fix FindFunctions so that it doesn't return<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> // instance methods for eFunctionNameTypeBase.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> target->GetImages().FindFunctions(name,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> eFunctionNameTypeFull,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> include_symbols,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> include_inlines,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> append,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> sc_list);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> }<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">So it's only searching for the base name if the function is in a namespace, and if it's at global scope it's searching for the full name.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I'm not sure why this works on other platforms, but on Windows it doesn't work because if I have this code:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">int foo(int x)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">{<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">then the full name of this function is ?foo@@YAHH@Z<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">If I change eFunctionNameTypeFull to eFunctionNameTypeBase then everything works, and "p foo" finds the function. So I've got a couple of questions:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">1) Why all this complicated logic? I would expect that if I type "p foo" then it would just print everything whose base name is foo and is visible from within the current scope? Am I underthinking this? There's special cases for namespaces,
global scope, instance methods, variables, functions, and it looks for things in certain orders, etc. Is there any reason why it can't just find everything with a basename of foo visible within the current stack frame?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">2) I'm not sure what this comment means: <o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"> // TODO Fix FindFunctions so that it doesn't return<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> // instance methods for eFunctionNameTypeBase.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal">I changed it to eFunctionNameTypeBase and it fixes the original bug on Windows. I inserted a class with an instance method named foo() and also a global method named foo(), and running "p foo" doesn't find the instance method, only the
global method. Is it possible this was somehow fixed, and it was forgotten to change this back to eFunctionNameTypeBase?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">3) Why does this work on other platforms? full names are mangled on other platforms too, so I don't know how "p foo" doesn't run into this same issue on other platforms. Any ideas?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Currently the best fix I have for this bug on Windows is to change eFunctionNameTypeFull to eFunctionNameTypeBase. but I want to get some thoughts on that worrisome comment before I go forward with that patch.<o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>