Index: tools/gdb/utils-gdb.py
===================================================================
--- tools/gdb/utils-gdb.py	(revision 2e94d94fdd1e3631b3b3f437b963922e6522db38)
+++ tools/gdb/utils-gdb.py	(revision cca034e78c063229f7fccb63e0fc61c8a2232f40)
@@ -23,5 +23,5 @@
 gdb.execute('handle SIGUSR1 nostop noprint pass')
 
-CfaTypes = collections.namedtuple('CfaTypes', 'cluster_ptr processor_ptr thread_ptr int_ptr thread_state yield_state')
+CfaTypes = collections.namedtuple('CfaTypes', 'cluster_ptr processor_ptr thread_ptr int_ptr uintptr thread_state yield_state')
 
 class ThreadInfo:
@@ -55,4 +55,5 @@
 		thread_ptr = gdb.lookup_type('struct thread$').pointer(),
 		int_ptr = gdb.lookup_type('int').pointer(),
+		uintptr = gdb.lookup_type('uintptr_t'),
 		thread_state = gdb.lookup_type('enum __Coroutine_State'),
 		yield_state = gdb.lookup_type('enum __Preemption_Reason'))
@@ -89,4 +90,43 @@
 	return argv
 
+def single_field(obj):
+	"""
+	If the struct only has one field return it, otherwise error
+	"""
+
+	_type = obj.type
+	if len(_type.fields()) != 1:
+		return None
+
+	return obj[_type.fields()[0].name]
+
+
+def start_from_dlist(dlist):
+	fs = dlist.type.fields()
+	if len(fs) != 1:
+		print("Error, can't understand dlist type for", dlist, dlist.name, dlist.type)
+		return None
+
+	return dlist[fs[0]]
+
+def fix_dlink(ptr):
+	"""
+	Remove the higher order bit from the pointer
+	"""
+	ptype = ptr.type
+	size = ptype.sizeof
+	if size == 8:
+		bit = 1 << ((size*8)-1)
+		mask = bit - 1
+	elif size == 4:
+		bit = 0
+		mask = 1
+	else:
+		print("Unexpected pointer size while fixing dlink", size)
+
+	cfa_t = get_cfa_types()
+	uptr = ptr.cast(cfa_t.uintptr)
+	return ptr if 0 == uptr & mask else gdb.Value(b'\x00'*size, ptype)
+
 class ClusterIter:
 	def __init__(self, root):
@@ -139,7 +179,5 @@
 	def check(self):
 		# check if this is the last value
-		addr = int(self.curr)
-		mask = 1 << ((8 * int(gdb.parse_and_eval('sizeof(void*)'))) - 1)
-		if 0 != (mask & addr):
+		if not fix_dlink(self.curr):
 			raise StopIteration
 
@@ -168,12 +206,4 @@
 		return self.curr
 
-def start_from_dlist(dlist):
-	fs = dlist.type.fields()
-	if len(fs) != 1:
-		print("Error, can't understand dlist type for", dlist, dlist.name, dlist.type)
-		return None
-
-	return dlist[fs[0]]
-
 def proc_list(cluster):
 	"""
@@ -183,6 +213,6 @@
 	proclist = cluster['_X5procsS19__cluster_proc_list_1']
 
-	idle = start_from_dlist(proclist['_X5idlesS5dlist_S9processorS5dlink_S9processor___1'])
-	active = start_from_dlist(proclist['_X7activesS5dlist_S9processorS5dlink_S9processor___1'])
+	idle = start_from_dlist(proclist['_X5idlesS5dlist_S9processorS5dlink_S9processor___1'])['_X4nextPY13__tE_generic__1']
+	active = start_from_dlist(proclist['_X7activesS5dlist_S9processorS5dlink_S9processor___1'])['_X4nextPY13__tE_generic__1']
 	return ProcIter(active.cast(cfa_t.processor_ptr)), ProcIter(idle.cast(cfa_t.processor_ptr))
 
@@ -261,5 +291,6 @@
 
 		cfa_t = get_cfa_types()
-		root = cluster['_X7threadsS8__dllist_S7thread$__1']['_X4headPY15__TYPE_generic__1'].cast(cfa_t.thread_ptr)
+		head = single_field(cluster['_X7threadsS5dlist_S7thread$S18__thread_user_link__1'])
+		root = head['_X4nextPY13__tE_generic__1'].cast(cfa_t.thread_ptr)
 
 		if root == 0x0 or root.address == 0x0:
@@ -282,5 +313,5 @@
 			threads.append(t)
 
-			curr = curr['node']['next']
+			curr = fix_dlink(single_field(curr['cltr_link'])['_X4nextPY13__tE_generic__1']).cast(cfa_t.thread_ptr)
 			if curr == root or curr == 0x0:
 				break
@@ -409,7 +440,9 @@
 
 	def print_formatted(self, marked, tid, name, state, address):
+		# print(marked, tid, name, state, address)
 		print('{:>1}  {:>4}  {:>20}  {:>10}  {:>20}'.format('*' if marked else ' ', tid, name, state, address))
 
 	def print_thread(self, thread, tid, marked):
+		# print("print", thread, tid, marked)
 		cfa_t = get_cfa_types()
 		ys = str(thread['preempted'].cast(cfa_t.yield_state))
@@ -439,5 +472,4 @@
 
 		self.print_formatted(False, '', 'Name', 'State', 'Address')
-
 		for t in threads:
 			if not t.is_system() or print_system:
