In my setup (Fedora 34, gcc 11.2.1), suddenly the gdb scripts'
unique_ptr_get() stopped working in "osv info threads" and also in one
of the tests - see issues #1175 and #1176.

The following patch, "inspired" by gcc's "printers.py" fixes it on
my setup. However, I can't explain why this particular change is
suddenly needed. printers.py is similar to what I did but not quite
the same, and the old code should have continued to work. I'll
appreciate it if someone with a different compiler version can check
if this patch doesn't break "osv info threads" on different compiler
versions.

Fixes #1175
Fixes #1176 (but the test fails in a new place, I guess I need to fix
another problem).

Signed-off-by: Nadav Har'El <n...@scylladb.com>
---
 scripts/loader.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/scripts/loader.py b/scripts/loader.py
index 7706ba38..63334e19 100644
--- a/scripts/loader.py
+++ b/scripts/loader.py
@@ -1000,10 +1000,17 @@ def find_or_give_last(predicate, seq):
 
 def unique_ptr_get(u):
     try:
-        # Since gcc 7
-        return u['_M_t']['_M_t']['_M_head_impl']
+        tuple_member = u['_M_t']['_M_t']
+        tuple_impl_type = tuple_member.type.fields()[0].type # _Tuple_impl
+        tuple_head_type = tuple_impl_type.fields()[1].type   # _Head_base
+        head_field = tuple_head_type.fields()[0]
+        return tuple_member.cast(head_field.type)
     except:
-        return u['_M_t']['_M_head_impl']
+        try:
+            # Since gcc 7
+            return u['_M_t']['_M_t']['_M_head_impl']
+        except:
+            return u['_M_t']['_M_head_impl']
 
 def thread_cpu(t):
     d = unique_ptr_get(t['_detached_state'])
-- 
2.31.1

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20211122125620.589606-1-nyh%40scylladb.com.

Reply via email to