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.
On Tue, Dec 15, 2015 at 3:16 AM Tamas Berghammer <tbergham...@google.com> wrote: > 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). > > On Mon, Dec 14, 2015 at 11:01 PM Zachary Turner via lldb-commits < > lldb-commits@lists.llvm.org> wrote: > >> Alright, I'll revert this loop for now. This is in at r255567. >> >> On Mon, Dec 14, 2015 at 2:33 PM Siva Chandra <sivachan...@google.com> >> wrote: >> >>> On Mon, Dec 14, 2015 at 2:15 PM, Zachary Turner <ztur...@google.com> >>> wrote: >>> > Diff looks like this: >>> > >>> > - @dwarf_test >>> > - @wraps(attrvalue) >>> > - def dwarf_test_method(self, attrvalue=attrvalue): >>> > - self.debug_info = "dwarf" >>> > - return attrvalue(self) >>> > - dwarf_method_name = attrname + "_dwarf" >>> > - dwarf_test_method.__name__ = dwarf_method_name >>> > - newattrs[dwarf_method_name] = dwarf_test_method >>> > >>> > ... >>> > >>> > + for category in supported_categories: >>> > + @add_test_categories([category]) >>> > + @wraps(attrvalue) >>> > + def test_method(self, attrvalue=attrvalue): >>> > + self.debug_info = category >>> > + return attrvalue(self) >>> > + method_name = attrname + "_" + category >>> > + test_method.__name__ = method_name >>> > + newattrs[method_name] = test_method >>> > >>> > >>> > So it looks like it's still under a different function. The >>> difference is >>> > that before (in the - section of the diff) there were 3 different >>> functions >>> > with 3 different names. For example `dwarf_test_method` above. In >>> the new >>> > code (+ section of the diff) it looks like one function defined 3 >>> different >>> > times with the same name `test_method`. But each of these should be a >>> > distinct function object that is defined in the context of the closure >>> > determined by the enclosing scope (the for loop in this case). So all >>> 3 >>> > functions are actually different. self is just an argument to the >>> function, >>> > not some magic value like `this` in C++, so as in the previous >>> version, the >>> > `debug_info` that gets modified is on whatever instance of `self` gets >>> > passed into the function, same as before. >>> >>> I think you are right. I am only basing my theories by feeling the >>> elephant blind here. When running TestWithLimitDebugInfo, I have >>> printed the |category| value from test_method and it only prints >>> "dwo". So, it is |category| which is at fault here as it is the loop >>> variable. Though two different methods are actually getting added, >>> self.debug_info refers to the last value of |category|. >>> >>> > Tamas or Pavel can probably clarify, but that's my understanding. >>> >> _______________________________________________ > > >> lldb-commits mailing list >> lldb-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits >> >
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits