diff --git a/tools/gdb_bthread_stack.py b/tools/gdb_bthread_stack.py index bb5001184c..acb6628a4e 100644 --- a/tools/gdb_bthread_stack.py +++ b/tools/gdb_bthread_stack.py @@ -74,15 +74,16 @@ def get_all_bthreads(total): global bthreads bthreads = [] count = 0 - groups = int(gdb.parse_and_eval("butil::ResourcePool::_ngroup")["val"]) + groups = int(gdb.parse_and_eval("(size_t)'butil::ResourcePool::_ngroup'")) for group in range(groups): blocks = int(gdb.parse_and_eval("(unsigned long)(*((*((('butil::static_atomic::BlockGroup*>' *)('butil::ResourcePool::_block_groups')) + {})).val)).nblock".format(group))) for block in range(blocks): - items = int(gdb.parse_and_eval("(*(*((butil::ResourcePool::Block**)((*((*((('butil::static_atomic::BlockGroup*>' *)('butil::ResourcePool::_block_groups')) + {})).val)).blocks) + {}))).nitem".format(group, block))) + items = int(gdb.parse_and_eval("(*(*(('butil::ResourcePool::Block' **)((*((*((('butil::static_atomic::BlockGroup*>' *)('butil::ResourcePool::_block_groups'))+ {})).val)).blocks) + {}))).nitem".format(group, block))) for item in range(items): - task_meta = gdb.parse_and_eval("*(('bthread::TaskMeta' *)((*(*((butil::ResourcePool::Block**)((*((*((('butil::static_atomic::BlockGroup*>' *)('butil::ResourcePool::_block_groups')) + {})).val)).blocks) + {}))).items) + {})".format(group, block, item)) + task_meta = gdb.parse_and_eval("*(('bthread::TaskMeta' *)((*(*(('butil::ResourcePool::Block' **)((*((*((('butil::static_atomic::BlockGroup*>' *)('butil::ResourcePool::_block_groups')) + {})).val)).blocks) + {}))).items) + {})".format(group, block, item)) version_tid = (int(task_meta["tid"]) >> 32) - version_butex = gdb.parse_and_eval("*(uint32_t *){}".format(task_meta["version_butex"])) + version_butex = gdb.parse_and_eval( + "*(uint32_t *){}".format(task_meta["version_butex"])) if version_tid == int(version_butex) and int(task_meta["attr"]["stack_type"]) != 0: bthreads.append(task_meta) count += 1