<div dir="ltr">Yea I realized this after.  At this point everything seems to be working and I need to finish other stuff, but I might come back to this if I have spare cycles.  Anyone else feel free to do the same.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 15, 2015 at 3:16 AM Tamas Berghammer <<a href="mailto:tberghammer@google.com">tberghammer@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think the problem is that you don't make a copy of the category variable manually. The function you are creating capture category by reference and when you update the value of category in the next loop iteration you also update the value captured by the previous function. As a result all of your test method will have the same category value. The canonical way to solve these issues is to add a new argument called category and set its default value to category (same as I did for argvalue).</div><br><div class="gmail_quote"></div><div class="gmail_quote"><div dir="ltr">On Mon, Dec 14, 2015 at 11:01 PM Zachary Turner via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>> wrote:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Alright, I'll revert this loop for now.  This is in at r255567.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 14, 2015 at 2:33 PM Siva Chandra <<a href="mailto:sivachandra@google.com" target="_blank">sivachandra@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Dec 14, 2015 at 2:15 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
> Diff looks like this:<br>
><br>
> -                @dwarf_test<br>
> -                @wraps(attrvalue)<br>
> -                def dwarf_test_method(self, attrvalue=attrvalue):<br>
> -                    self.debug_info = "dwarf"<br>
> -                    return attrvalue(self)<br>
> -                dwarf_method_name = attrname + "_dwarf"<br>
> -                dwarf_test_method.__name__ = dwarf_method_name<br>
> -                newattrs[dwarf_method_name] = dwarf_test_method<br>
><br>
> ...<br>
><br>
> +                for category in supported_categories:<br>
> +                    @add_test_categories([category])<br>
> +                    @wraps(attrvalue)<br>
> +                    def test_method(self, attrvalue=attrvalue):<br>
> +                        self.debug_info = category<br>
> +                        return attrvalue(self)<br>
> +                    method_name = attrname + "_" + category<br>
> +                    test_method.__name__ = method_name<br>
> +                    newattrs[method_name] = test_method<br>
><br>
><br>
> So it looks like it's still under a different function.  The difference is<br>
> that before (in the - section of the diff) there were 3 different functions<br>
> with 3 different names.  For example `dwarf_test_method` above.  In the new<br>
> code (+ section of the diff) it looks like one function defined 3 different<br>
> times with the same name `test_method`.  But each of these should be a<br>
> distinct function object that is defined in the context of the closure<br>
> determined by the enclosing scope (the for loop in this case).  So all 3<br>
> functions are actually different.  self is just an argument to the function,<br>
> not some magic value like `this` in C++, so as in the previous version, the<br>
> `debug_info` that gets modified is on whatever instance of `self` gets<br>
> passed into the function, same as before.<br>
<br>
I think you are right. I am only basing my theories by feeling the<br>
elephant blind here. When running TestWithLimitDebugInfo, I have<br>
printed the |category| value from test_method and it only prints<br>
"dwo". So, it is |category| which is at fault here as it is the loop<br>
variable. Though two different methods are actually getting added,<br>
self.debug_info refers to the last value of |category|.<br>
<br>
> Tamas or Pavel can probably clarify, but that's my understanding.<br>
</blockquote></div></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
_______________________________________________</blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div></blockquote></div>