MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / Trace

Class Trace

tools/python-3.11.9-amd64/Lib/trace.py:387–591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385 return _find_lines(code, strs)
386
387class Trace:
388 def __init__(self, count=1, trace=1, countfuncs=0, countcallers=0,
389 ignoremods=(), ignoredirs=(), infile=None, outfile=None,
390 timing=False):
391 """
392 @param count true iff it should count number of times each
393 line is executed
394 @param trace true iff it should print out each line that is
395 being counted
396 @param countfuncs true iff it should just output a list of
397 (filename, modulename, funcname,) for functions
398 that were called at least once; This overrides
399 `count' and `trace'
400 @param ignoremods a list of the names of modules to ignore
401 @param ignoredirs a list of the names of directories to ignore
402 all of the (recursive) contents of
403 @param infile file from which to read stored counts to be
404 added into the results
405 @param outfile file in which to write the results
406 @param timing true iff timing information be displayed
407 """
408 self.infile = infile
409 self.outfile = outfile
410 self.ignore = _Ignore(ignoremods, ignoredirs)
411 self.counts = {} # keys are (filename, linenumber)
412 self.pathtobasename = {} # for memoizing os.path.basename
413 self.donothing = 0
414 self.trace = trace
415 self._calledfuncs = {}
416 self._callers = {}
417 self._caller_cache = {}
418 self.start_time = None
419 if timing:
420 self.start_time = _time()
421 if countcallers:
422 self.globaltrace = self.globaltrace_trackcallers
423 elif countfuncs:
424 self.globaltrace = self.globaltrace_countfuncs
425 elif trace and count:
426 self.globaltrace = self.globaltrace_lt
427 self.localtrace = self.localtrace_trace_and_count
428 elif trace:
429 self.globaltrace = self.globaltrace_lt
430 self.localtrace = self.localtrace_trace
431 elif count:
432 self.globaltrace = self.globaltrace_lt
433 self.localtrace = self.localtrace_count
434 else:
435 # Ahem -- do nothing? Okay.
436 self.donothing = 1
437
438 def run(self, cmd):
439 import __main__
440 dict = __main__.__dict__
441 self.runctx(cmd, dict, dict)
442
443 def runctx(self, cmd, globals=None, locals=None):
444 if globals is None: globals = {}

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected