MCPcopy Create free account
hub / github.com/apache/brpc / get_bthreads_num

Function get_bthreads_num

tools/lldb_bthread_stack.py:107–125  ·  view source on GitHub ↗
(target: lldb.SBTarget)

Source from the content-addressed store, hash-verified

105
106
107def get_bthreads_num(target: lldb.SBTarget):
108 root_agent = find_global_value(
109 target, "bthread::g_task_control._nbthreads._combiner._agents.root_")
110 global_res = find_global_value(
111 target, "bthread::g_task_control._nbthreads._combiner._global_result").GetValueAsSigned()
112 long_type = target.GetBasicType(lldb.eBasicTypeLong)
113
114 last_node = root_agent
115 # agent_type: bvar::detail::AgentCombiner<long, long, bvar::detail::AddTo<long> >::Agent>
116 agent_type: lldb.SBType = last_node.GetType().GetTemplateArgumentType(0)
117 while True:
118 agent = last_node.Cast(agent_type)
119 if (last_node.GetLocation() != root_agent.GetLocation()):
120 val = get_child(agent, "element._value").Cast(
121 long_type).GetValueAsSigned()
122 global_res += val
123 if (get_child(agent, "next_").Dereference().GetLocation() == root_agent.GetLocation()):
124 return global_res
125 last_node = get_child(agent, "next_").Dereference()
126
127
128def get_all_bthreads(target: lldb.SBTarget, total: int):

Callers 2

bthread_beginFunction · 0.85
bthread_numFunction · 0.85

Calls 4

find_global_valueFunction · 0.85
get_childFunction · 0.85
CastMethod · 0.80
DereferenceMethod · 0.80

Tested by

no test coverage detected