Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix gdb bthread stack lookup symbol error when using libc++ #2516

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tools/gdb_bthread_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ def get_bthread_num():
global_res = int(gdb.parse_and_eval("((*bthread::g_task_control)._nbthreads)._combiner._global_result"))
get_agent = "(*(('bvar::detail::AgentCombiner<long, long, bvar::detail::AddTo<long> >::Agent' *){}))"
last_node = root_agent
long_type = gdb.lookup_type("long")
while True:
agent = gdb.parse_and_eval(get_agent.format(last_node))
if last_node != root_agent:
val = int(agent["element"]["_value"]["_M_i"])
val = int(agent["element"]["_value"].cast(long_type))
gdb.parse_and_eval(get_agent.format(last_node))
global_res += val
if agent["next_"] == root_agent:
return global_res
Expand All @@ -72,13 +74,13 @@ def get_all_bthreads(total):
global bthreads
bthreads = []
count = 0
groups = int(gdb.parse_and_eval("'butil::ResourcePool<bthread::TaskMeta>::_ngroup'")["val"])
groups = int(gdb.parse_and_eval("butil::ResourcePool<bthread::TaskMeta>::_ngroup")["val"])
for group in range(groups):
blocks = int(gdb.parse_and_eval("(*((*((('butil::static_atomic<butil::ResourcePool<bthread::TaskMeta>::BlockGroup*>' *)('butil::ResourcePool<bthread::TaskMeta>::_block_groups')) + {})).val)).nblock._M_i".format(group)))
blocks = int(gdb.parse_and_eval("(unsigned long)(*((*((('butil::static_atomic<butil::ResourcePool<bthread::TaskMeta>::BlockGroup*>' *)('butil::ResourcePool<bthread::TaskMeta>::_block_groups')) + {})).val)).nblock".format(group)))
for block in range(blocks):
items = int(gdb.parse_and_eval("(*(*(('butil::atomic<butil::ResourcePool<bthread::TaskMeta>::Block*>' *)((*((*((('butil::static_atomic<butil::ResourcePool<bthread::TaskMeta>::BlockGroup*>' *)('butil::ResourcePool<bthread::TaskMeta>::_block_groups')) + {})).val)).blocks) + {}))._M_b._M_p).nitem".format(group, block)))
items = int(gdb.parse_and_eval("(*(*((butil::ResourcePool<bthread::TaskMeta>::Block**)((*((*((('butil::static_atomic<butil::ResourcePool<bthread::TaskMeta>::BlockGroup*>' *)('butil::ResourcePool<bthread::TaskMeta>::_block_groups')) + {})).val)).blocks) + {}))).nitem".format(group, block)))
for item in range(items):
task_meta = gdb.parse_and_eval("*(('bthread::TaskMeta' *)((*(*(('butil::atomic<butil::ResourcePool<bthread::TaskMeta>::Block*>' *)((*((*((('butil::static_atomic<butil::ResourcePool<bthread::TaskMeta>::BlockGroup*>' *)('butil::ResourcePool<bthread::TaskMeta>::_block_groups')) + {})).val)).blocks) + {}))._M_b._M_p).items) + {})".format(group, block, item))
task_meta = gdb.parse_and_eval("*(('bthread::TaskMeta' *)((*(*((butil::ResourcePool<bthread::TaskMeta>::Block**)((*((*((('butil::static_atomic<butil::ResourcePool<bthread::TaskMeta>::BlockGroup*>' *)('butil::ResourcePool<bthread::TaskMeta>::_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"]))
if version_tid == int(version_butex) and int(task_meta["attr"]["stack_type"]) != 0:
Expand Down
Loading