Skip to content

Commit

Permalink
Trace stdlib and built-in function with verbose option
Browse files Browse the repository at this point in the history
This commit modifies the tracing conditions in PyftraceSetprofile so that
standard library functions are included when verbose mode is enabled.

Previously, stdlib functions were only traced if they were 'builtins' under -v  mode.
Now, any stdlib function will be traced in verbose mode.
  • Loading branch information
kangtegong committed Dec 18, 2024
1 parent 3732308 commit e9aa263
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions pyftrace/engine/pyftrace_setprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ def handle_call_event(self, frame, arg, is_c_call=False):
trace_this = False

if self.is_stdlib_code(filename):
if not (self.verbose and module_name == 'builtins'):
if not self.verbose:
return

if self.should_trace(filename):
trace_this = True
elif self.verbose:
if module_name == 'builtins':
else:
if self.should_trace(filename):
trace_this = True
elif self.verbose and module_name == 'builtins':
trace_this = True

if trace_this:
Expand Down Expand Up @@ -176,16 +176,22 @@ def handle_return_event(self, frame, arg, is_c_return):
if func_name == '<module>':
return

if self.is_stdlib_code(filename):
if not (self.verbose and module_name == 'builtins'):
return

trace_this = False

if self.call_stack and self.call_stack[-1] == func_name:
if self.is_stdlib_code(filename):
if not self.verbose:
return
trace_this = True
else:
if self.call_stack and self.call_stack[-1] == func_name:
trace_this = True

if trace_this:
if not trace_this:
if self.verbose and module_name == 'builtins':
if self.call_stack and self.call_stack[-1] == func_name:
trace_this = True

if trace_this and self.call_stack and self.call_stack[-1] == func_name:
func_name = self.call_stack.pop()

indent = " " * self.current_depth()
Expand Down

0 comments on commit e9aa263

Please sign in to comment.