Fix stack_trace_len

This commit is contained in:
Rich Chiodo false 2024-04-30 17:14:47 -07:00
parent fcc292e736
commit 6ceee0a85f
2 changed files with 3 additions and 10 deletions

View file

@ -290,7 +290,8 @@ class Adapter:
if thread is None:
raise request.isnt_valid(f'Unknown thread with "threadId":{thread_id}')
stop_frame = None if levels is None else start_frame + levels
stop_frame = thread.stack_trace_len() if levels == () or levels == 0 else start_frame + levels
log.info(f"stackTrace info {start_frame} {stop_frame}")
frames = None
try:
frames = islice(thread.stack_trace(), start_frame, stop_frame)

View file

@ -261,15 +261,7 @@ class Thread:
"""
Returns the total count of frames in this thread's stack.
"""
try:
with _cvar:
python_frame = self.current_frame
except ValueError:
raise ValueError(f"Can't get frames for inactive Thread({self.id})")
try:
return len(tuple(traceback.walk_stack(python_frame)))
finally:
del python_frame
return len(list(self.stack_trace()))
def stack_trace(self) -> Iterable["StackFrame"]:
"""