<div dir="ltr">I think the capacity mismatch failures are machine specific, and I'm guessing they are tuned differently on armv7 vs x86. So probably just need to change the expectation to be generic. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 10, 2019 at 2:54 PM Adhemerval Zanella <<a href="mailto:adhemerval.zanella@linaro.org">adhemerval.zanella@linaro.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I have fixed most of the issue, the missing one is for vector<bool> <br>
that I can't understand why gdb and pretty-printer are differing.<br>
<br>
The testcase code:<br>
<br>
380 void vector_test() {<br>
381 std::vector<bool> test0 = {true, false};<br>
382 ComparePrettyPrintToChars(test0,<br>
383 "std::vector<bool> of "<br>
384 "length 2, capacity 64 = {1, 0}");<br>
<br>
and<br>
<br>
390 ComparePrettyPrintToRegex(<br>
391 test0,<br>
392 "std::vector<bool> of length 64, "<br>
393 "capacity 64 = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, "<br>
394 "0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, "<br>
395 "0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}");<br>
396 test0.push_back(true);<br>
<br>
Are failing with<br>
<br>
FAIL: /home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/test/pretty_printers/gdb_pretty_printer_test.sh.cpp:382<br>
GDB printed:<br>
std::vector<bool> of length 2, capacity 32 = {1, 0}<br>
Value should match:<br>
std::vector<bool> of length 2, capacity 64 = {1, 0}<br>
PASS: /home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/test/pretty_printers/gdb_pretty_printer_test.sh.cpp:390<br>
FAIL: /home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/test/pretty_printers/gdb_pretty_printer_test.sh.cpp:398<br>
GDB printed:<br>
std::vector<bool> of length 65, capacity 96 = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}<br>
Value should match:<br>
std::vector<bool> of length 65, capacity 128 = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}<br>
<br>
Debugging a little it seems the pretty-printer obtains 1 and 3<br>
respectively for test0.__cap_alloc_.__value_ in such cases. However<br>
attaching gdb directly shows it does contain 2 and 4 as expected.<br>
<br>
I am trying to find out exactly what is happening here.<br>
<br>
These are the changes I am using so far:<br>
<br>
---<br>
Index: test/pretty_printers/gdb_pretty_printer_test.py<br>
===================================================================<br>
--- test/pretty_printers/gdb_pretty_printer_test.py (revision 371324)<br>
+++ test/pretty_printers/gdb_pretty_printer_test.py (working copy)<br>
@@ -50,8 +50,9 @@<br>
check_literal = expectation_val.string()<br>
test_fails = not re.match(check_literal, value)<br>
else:<br>
- check_literal_string = expectation_val.string(encoding="utf-8")<br>
- check_literal = check_literal_string.encode("utf-8")<br>
+ #check_literal_string = expectation_val.string(encoding="utf-8")<br>
+ #check_literal = check_literal_string.encode("utf-8")<br>
+ check_literal = expectation_val.string(encoding="utf-8")<br>
test_fails = value != check_literal<br>
<br>
if test_fails:<br>
Index: utils/gdb/libcxx/printers.py<br>
===================================================================<br>
--- utils/gdb/libcxx/printers.py (revision 371324)<br>
+++ utils/gdb/libcxx/printers.py (working copy)<br>
@@ -13,9 +13,15 @@<br>
<br>
from __future__ import print_function<br>
<br>
+import sys<br>
import re<br>
import gdb<br>
<br>
+if sys.version_info >= (3, 0):<br>
+ py3k = True<br>
+else:<br>
+ py3k = False<br>
+<br>
# One under-documented feature of the gdb pretty-printer API<br>
# is that clients can call any other member of the API<br>
# before they call to_string.<br>
@@ -131,18 +137,23 @@<br>
def __init__(self, val):<br>
self.val = val<br>
self.child_iter = iter(self.val["__base_"].type.fields())<br>
+ if not py3k:<br>
+ self.child_iter.next == self.child_iter.__next__<br>
self.count = 0<br>
<br>
def __iter__(self):<br>
return self<br>
<br>
- def next(self):<br>
+ def __next__(self):<br>
# child_iter raises StopIteration when appropriate.<br>
- field_name = self.child_iter.next()<br>
+ field_name = self.child_iter.__next__()<br>
child = self.val["__base_"][field_name]["__value_"]<br>
self.count += 1<br>
return ("[%d]" % self.count, child)<br>
<br>
+ if not py3k:<br>
+ next = __next__<br>
+<br>
def __init__(self, val):<br>
self.val = val<br>
<br>
@@ -315,7 +326,7 @@<br>
def __iter__(self):<br>
return self<br>
<br>
- def next(self):<br>
+ def __next__(self):<br>
"""Retrieve the next element."""<br>
<br>
self.count += 1<br>
@@ -332,6 +343,9 @@<br>
self.offset = 0<br>
return ("[%d]" % self.count, outbit)<br>
<br>
+ if not py3k:<br>
+ next = __next__<br>
+<br>
class _VectorIterator(object):<br>
"""Class to iterate over the non-bool vector's children."""<br>
<br>
@@ -343,7 +357,7 @@<br>
def __iter__(self):<br>
return self<br>
<br>
- def next(self):<br>
+ def __next__(self):<br>
self.count += 1<br>
if self.item == self.end:<br>
raise StopIteration<br>
@@ -351,6 +365,9 @@<br>
self.item += 1<br>
return ("[%d]" % self.count, entry)<br>
<br>
+ if not py3k:<br>
+ next = __next__<br>
+<br>
def __init__(self, val):<br>
"""Set val, length, capacity, and iterator for bool and normal vectors."""<br>
self.val = val<br>
@@ -404,7 +421,7 @@<br>
while value:<br>
index += 1<br>
will_yield = value % 2<br>
- value /= 2<br>
+ value //= 2<br>
if will_yield:<br>
yield index<br>
---<br>
<br>
<br>
On 10/09/2019 18:45, Sterling Augustine wrote:<br>
> I'll look into sorting this out. Strange that no other build bots are using python3 by default.<br>
> <br>
> On Tue, Sep 10, 2019 at 12:38 PM Adhemerval Zanella <<a href="mailto:adhemerval.zanella@linaro.org" target="_blank">adhemerval.zanella@linaro.org</a> <mailto:<a href="mailto:adhemerval.zanella@linaro.org" target="_blank">adhemerval.zanella@linaro.org</a>>> wrote:<br>
> <br>
> Hi Sterling,<br>
> <br>
> It in indeed a python3 issue, where it is being used as default on the<br>
> bot. Besides the check_literal format issue, python3 next iteration<br>
> method has changed its name to __next__ which requires some internal<br>
> adjustments. I am not trying to fix a remaining issue with bitset<br>
> printer.<br>
> <br>
> On 09/09/2019 16:24, Adhemerval Zanella wrote:<br>
> > At least on my testing it seems the __r_ field does exist:<br>
> ><br>
> > $ gdb ./gdb_pretty_printer_test.sh.cpp.tmp.exe<br>
> > [...]<br>
> > (gdb) b string_test<br>
> > (gdb) r<br>
> > [1]+ Stopped gdb ./gdb_pretty_printer_test.sh.cpp.tmp.exe<br>
> > $ fg<br>
> > [...]<br>
> > Breakpoint 1, string_test () at /home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/test/pretty_printers/gdb_pretty_printer_test.sh.cpp:135<br>
> > 135 std::string short_string("kdjflskdjf");<br>
> > (gdb) n<br>
> > (gdb) p short_string<br>
> > $1 = {<std::__1::__basic_string_common<true>> = {<No data fields>}, static __short_mask = 1, static __long_mask = 1,<br>
> > __r_ = {<std::__1::__compressed_pair_elem<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, 0, false>> = {__value_ = {{__l = {__cap_ = 1784965908,<br>
> > __size_ = 1802726502, __data_ = 0x666a64 <error: Cannot access memory at address 0x666a64>}, __s = {{__size_ = 20 '\024', __lx = 20 '\024'}, __data_ = "kdjflskdjf"}, __r = {__words = {<br>
> > 1784965908, 1802726502,<br>
> > 6711908}}}}}, <std::__1::__compressed_pair_elem<std::__1::allocator<char>, 1, true>> = {<std::__1::allocator<char>> = {<No data fields>}, <No data fields>}, <No data fields>},<br>
> > static npos = 4294967295}<br>
> ><br>
> > The only unexpected thing is for some reason gdb is being stopped just after<br>
> > the program start (not sure how it influences the testcase or if it is something<br>
> > expected).<br>
> ><br>
> > Also adding a 'print("VALUE_FIELD: ", value_field)' just after the value_field<br>
> > attribution I am seeing:<br>
> ><br>
> > $ /usr/bin/gdb -nx -batch -iex "set autoload off" -ex "source /home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/utils/gdb/libcxx/printers.py" -ex "python register_libcxx_printer_loader()" -ex "source /home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/test/pretty_printers/gdb_pretty_printer_test.py" gdb_pretty_printer_test.sh.cpp.tmp.exe 2>&1 | tee _out No symbol table is loaded. Use the "file" command. Breakpoint 1 at 0x1179c: file /home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/test/pretty_printers/gdb_pretty_printer_test.sh.cpp, line 57. <br>
> Loading libc++ pretty-printers. Cannot parse expression `.L1185 4@r4'. warning: Probes-based dynamic linker interface failed. Reverting to original interface.<br>
> ><br>
> > [Thread debugging using libthread_db enabled]<br>
> > Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".<br>
> > FAIL: /home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/test/pretty_printers/gdb_pretty_printer_test.sh.cpp:137<br>
> > GDB printed:<br>
> > VALUE_FIELD: {{__l = {__cap_ = 1784965908, __size_ = 1802726502, __data_ = 0x666a64 <error: Cannot access memory at address 0x666a64>}, __s = {{__size_ = 20 '\024', __lx = 20 '\024'}, __data_ = "kdjflskdjf"}, __r = {__words = {1784965908, 1802726502, 6711908}}}}<br>
> > "kdjflskdjf"<br>
> > Value should match:<br>
> > Traceback (most recent call last):<br>
> > File "/home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/test/pretty_printers/gdb_pretty_printer_test.py", line 64, in invoke<br>
> > print(" " + check_literal)<br>
> > TypeError: Can't convert 'bytes' object to str implicitly<br>
> > terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'<br>
> ><br>
> ><br>
> > On 09/09/2019 15:29, Sterling Augustine wrote:<br>
> >> I think the encoding failure (which would be python 2 vs 3) is a secondary failure--already deep inside the error handling. The real problem is the <br>
> >><br>
> >> File "/home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/utils/gdb/libcxx/printers.py", line 221, in to_string<br>
> >> value_field = _value_of_pair_first(self.val["__r_"])<br>
> >> gdb.error: There is no member named __r_.<br>
> >><br>
> >> Which means that maybe the test case is getting compiled or linked differently. At least in such a way that the field "__r_" doesn't exist (at least not in debug info). But I would be quite puzzled as to why this bot has a different libcxx build or debug info than all the others.<br>
> >><br>
> >> On Mon, Sep 9, 2019 at 11:15 AM Adhemerval Zanella <<a href="mailto:adhemerval.zanella@linaro.org" target="_blank">adhemerval.zanella@linaro.org</a> <mailto:<a href="mailto:adhemerval.zanella@linaro.org" target="_blank">adhemerval.zanella@linaro.org</a>> <mailto:<a href="mailto:adhemerval.zanella@linaro.org" target="_blank">adhemerval.zanella@linaro.org</a> <mailto:<a href="mailto:adhemerval.zanella@linaro.org" target="_blank">adhemerval.zanella@linaro.org</a>>>> wrote:<br>
> >><br>
> >> Hi Sterling,<br>
> >><br>
> >> Maxim has asked to take a loot at it. The failure is essentially:<br>
> >><br>
> >> FAIL: /home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/test/pretty_printers/gdb_pretty_printer_test.sh.cpp:137<br>
> >> GDB printed:<br>
> >> <incomplete type><br>
> >> Value should match:<br>
> >> Traceback (most recent call last):<br>
> >> File "/home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/test/pretty_printers/gdb_pretty_printer_test.py", line 64, in invoke<br>
> >> print(" " + check_literal)<br>
> >> TypeError: Can't convert 'bytes' object to str implicitly<br>
> >><br>
> >> I am not sure if it is something related to python2/3. The system does have<br>
> >> both installed (python 2.7.12 and 3.5.2, with 2 being the default). I tried<br>
> >> to issue the faulty testcase with python3, and it shows the same issue<br>
> >><br>
> >> I am not very familiar with this code, but trying to make peace with<br>
> >> the types by changing it to:<br>
> >><br>
> >> 52 else:<br>
> >> 53 check_literal = expectation_val.string(encoding="utf-8")<br>
> >> 54 check_literal_utf8 = check_literal.encode("utf-8")<br>
> >> 55 test_fails = value.encode("utf-8") != check_literal_utf8<br>
> >><br>
> >> Also does not help either. For the change above, the first failure shows:<br>
> >><br>
> >> FAIL: /home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/test/pretty_printers/gdb_pretty_printer_test.sh.cpp:137<br>
> >> GDB printed:<br>
> >> Traceback (most recent call last):<br>
> >> File "/home/buildslave/buildslave/libcxx-libcxxabi-libunwind-armv8-linux-noexceptions/llvm/projects/libcxx/utils/gdb/libcxx/printers.py", line 221, in to_string<br>
> >> value_field = _value_of_pair_first(self.val["__r_"])<br>
> >> gdb.error: There is no member named __r_.<br>
> >><br>
> >> Value should match:<br>
> >> "kdjflskdjf"<br>
> >><br>
> >> Which indicates that something is still missing here. I am checking if it<br>
> >> is possible to give you direct access to the bot.<br>
> >><br>
> <br>
</blockquote></div>