<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Erik,<div class="">thanks for sending out this email. It is appreciated and valuable that you took the time to write this list of problems you encountered.<br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 20, 2014, at 3:42 PM, Erik Olofsson <<a href="mailto:erik.olofsson@hansoft.com" class="">erik.olofsson@hansoft.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi, </div><div class=""><br class=""></div><div class="">These are some of the issues I have run into when trying to add synthetic children and summary providers with the python API.</div><div class=""><br class=""></div><div class=""><b class="">Access to nested classes and typedefs</b></div><div class="">The first problem I ran into was accessing member typedefs of a SBType, for which I have found no API. The workaround for this was to create static variables with types I needed. This practice however would not be advisable in Release builds as it bloats the executable. This brings us to the second problem.</div></div></div></blockquote><div><br class=""></div><div>You are probably correct about this. On the other hand, I don’t think I ever needed this ability. When exactly would this be useful?</div><div>I am of course not implying that we would not care to have this ability, just that I expect workarounds to exist.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><b class="">Access to class member static variables</b></div><div class="">There is no way to access static member variables directly from a SBValue or SBType. The current method I use works for some cases but not all:</div><div class=""><br class=""></div><div class="">SBValue.CreateValueFromExpression(SBValue.get_expr_path() + ("." or "->") + StaticVarName) </div><div class=""><span class="Apple-tab-span" style="white-space:pre">      </span>This works for normal SBValues, but not synthetic SBValues</div><div class=""><br class=""></div></div></div></blockquote><div><br class=""></div><div>Indeed. Known problem, but most likely very hard to solve, and not even desirable in all cases. See below, but this has been discussed already somewhere in greater detail.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">SBValue.CreateValueFromExpression(SBType.GetName() + "::" + StaticVarName) </div><div class=""><span class="Apple-tab-span" style="white-space:pre">  </span>This fails for template types as it fails to parse the template</div><div class=""><br class=""></div><div class="">SBValue.GetFrame().GetVariables(False, False, True, False); </div><div class=""><span class="Apple-tab-span" style="white-space:pre">  </span>This fails for statics not in the current compilation unit</div><div class=""><br class=""></div><div class="">SBValue.GetTarget().FindGlobalVariables(StaticVarName, 1024); </div><div class=""><span class="Apple-tab-span" style="white-space:pre">       </span>This fails because not nearly all statics are returned. Also if you specify the class, it is just ignored and you need to compare SBValue.GetName() against the SBType.GetName() + StaticVarName. But that also fails sometimes because the name in SBType and SBValue is not always formatted the same way for template (non-type) params.</div></div></div></blockquote><div><br class=""></div><div>Worth filing a bugzilla for. Or maybe Greg has some magical insight on how to find all the things.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><b class="">Expressions on synthetic SBValues</b></div><div class="">You cannot access synthetic SBValues in an expression in any way as far as I can tell. I have found no way to get an arbitrary type and pointer into an expression for evaluation. For simple types it works to just use the address and cast it to the correct type:  "(Type *)0xXXXXXXXX". But this does not work for template types as parsing them invariably fails (error: no type named 'X' in namespace 'X::X’).</div></div></div></blockquote><div><br class=""></div><div>You can’t. That is entirely by design. Imagine having an std::map<string,int></div><div>In code, you write myMap[“key”], but synthetic children are exposed as myMap[0], as a pair<keyType,valueType></div><div>If synthetic children were allowed, now you could write myMap[0] = 12, or myMap[0] = {“1”,2} or other horrible things that you should not be allowed to write, with dubious semantics at best.</div><div>There are a few more caveats, but long story short, it’s a tricky business, and we just don’t have enough of a compelling use case/right answers to want to delve into it</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><div class=""><b class="">Non Type Template Params</b></div><div class="">For some types I need to get non type template param values. I have found no API for this, although this can be worked around by adding static variables with the values in them.</div></div></div></div></blockquote><div><br class=""></div><div>This sounds like a bug. Maybe a DWARF problem. Do you have a reproduction case handy?</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><b class="">Access to posix thread locals</b></div><div class="">I have found no way to access pthread thread locals, or reading through the GS segment of a thread from the python API, so I have to resort to calling into the target. But I guess that is no problem as long as I don't need to debug a core dump (if or when this is supported).</div><div class=""><br class=""></div><div class=""><b class="">Suggestions</b></div><div class="">To get everything working:</div><div class="">* Add API for saving a SBValue as a persistent variable. This would allow a workaround for doing expressions on synthetic SBValues</div></div></div></blockquote><div><br class=""></div><div>This might be interesting. Worth filing a bugzilla ER for.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">or</div><div class="">* You should be able to access the SBValue in the expression when calling: SBValue.CreateValueFromExpression. For example: $var, or the context of the evaluation should be as if inside a class function of the type of the SBValue, which would allow you to access the member vars directly.</div></div></div></blockquote><div><br class=""></div><div>I don’t think we’d want to go for language extensions. Doesn’t this->whatever work, if you are currently stopped in a class context?</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">To not have to add helpers in target executable:</div><div class="">* Add API to access nested types and typedefs in a SBType</div><div class="">* Add API to get static class members: SBValue.GetChildStaticMemberWithName, and SBType.GetChildStaticMemberWithName</div><div class="">* Add API to read the from the GS segment of a thread, or support for reading pthread thread locals.</div></div></div></blockquote><div><br class=""></div><div>These seem all worth of bug/ER reports, although Greg might know more about thread local access</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Any ideas for workarounds for these issue would be appreciated. Currently I would be happy to just get it to work reliably, for which all I need is to be able to get an arbitrary SBValue into an expression. </div></div></div></blockquote><div><br class=""></div><div>Why do you need to use an expression? For 99% of formatters, that is usually not desirable nor necessary.</div><div>Not desirable for performance and stability reasons. Not necessary because most often all the expression does is memory access and basic manipulations that are doable via Python anyway</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">If I were to try to patch this myself, what do you think would be the easiest:</div><div class="">* Fix the template parsing in expressions.</div></div></div></blockquote><div><br class=""></div><div>If you have cases of expressions that we should parse and aren’t, please file bugs</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">* Save SBValue as persistent variable.</div></div></div></blockquote><div><br class=""></div><div>Not a bad idea, but probably not necessary either</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">* Access SBValue directly in expression through $var</div></div></div></blockquote><div><br class=""></div><div>There are good reasons to not do that</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">* Access the SBValue directly in expression by being evaluated in the context of type of the SBValue</div></div></div></blockquote><div><br class=""></div><div>Depending on where you’re stopped this should either work already or hardly be meaningful (if I understand what you mean)</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Regards,</div><div class="">Erik</div><div class=""><br class=""></div></div>_______________________________________________<br class="">lldb-dev mailing list<br class=""><a href="mailto:lldb-dev@cs.uiuc.edu" class="">lldb-dev@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev<br class=""></div></blockquote></div><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Thanks,</div><div class=""><i class="">- Enrico</i><br class="">📩 egranata@<font color="#ff2600" class=""></font>.com ☎️ 27683</div><div class=""><br class=""></div></div></div></div></div></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br class=""></div></div></body></html>