def plot_images(imgs, loc, title=None, channels=<NUM_LIT:1>):

n = int(np.sqrt(len(imgs)))<EOL>assert n * n == len(imgs), '<STR_LIT>'<EOL>s = int(np.sqrt(len(imgs[<NUM_LIT:0>]) / channels))<EOL>assert s * s == len(imgs[<NUM_LIT:0>]) / channels, '<STR_LIT>'<EOL>img = np.zeros(((s+<NUM_LIT:1>) * n - <NUM_LIT:1>, (s+<NUM_LIT:1>) * n - <NUM_LIT:1>, channels), dtype=imgs[<NUM_LIT:0>].dtype)<EOL>for i, pix in enumerate(imgs):<EOL><INDENT>r, c = divmod(i, n)<EOL>img[r * (s+<NUM_LIT:1>):(r+<NUM_LIT:1>) * (s+<NUM_LIT:1>) - <NUM_LIT:1>,<EOL>c * (s+<NUM_LIT:1>):(c+<NUM_LIT:1>) * (s+<NUM_LIT:1>) - <NUM_LIT:1>] = pix.reshape((s, s, channels))<EOL><DEDENT>img -= img.min()<EOL>img /= img.max()<EOL>ax = plt.gcf().add_subplot(loc)<EOL>ax.xaxis.set_visible(False)<EOL>ax.yaxis.set_visible(False)<EOL>ax.set_frame_on(False)<EOL>ax.imshow(img.squeeze(), cmap=plt.cm.gray)<EOL>if title:<EOL><INDENT>ax.set_title(title)<EOL><DEDENT>

Plot an array of images.

    We assume that we are given a matrix of data whose shape is (n*n, s*s*c) --
    that is, there are n^2 images along the first axis of the array, and each
    image is c squares measuring s pixels on a side. Each row of the input will
    be plotted as a sub-region within a single image array containing an n x n
    grid of images.


def plot_layers(weights, tied_weights=False, channels=<NUM_LIT:1>):

if hasattr(weights[<NUM_LIT:0>], '<STR_LIT>'):<EOL><INDENT>weights = [w.get_value() for w in weights]<EOL><DEDENT>k = min(len(weights), <NUM_LIT:9>)<EOL>imgs = np.eye(weights[<NUM_LIT:0>].shape[<NUM_LIT:0>])<EOL>for i, weight in enumerate(weights[:-<NUM_LIT:1>]):<EOL><INDENT>imgs = np.dot(weight.T, imgs)<EOL>plot_images(imgs,<EOL><NUM_LIT:100> + <NUM_LIT:10> * k + i + <NUM_LIT:1>,<EOL>channels=channels,<EOL>title='<STR_LIT>'.format(i+<NUM_LIT:1>))<EOL><DEDENT>weight = weights[-<NUM_LIT:1>]<EOL>n = weight.shape[<NUM_LIT:1>] / channels<EOL>if int(np.sqrt(n)) ** <NUM_LIT:2> != n:<EOL><INDENT>return<EOL><DEDENT>if tied_weights:<EOL><INDENT>imgs = np.dot(weight.T, imgs)<EOL>plot_images(imgs,<EOL><NUM_LIT:100> + <NUM_LIT:10> * k + k,<EOL>channels=channels,<EOL>title='<STR_LIT>'.format(k))<EOL><DEDENT>else:<EOL><INDENT>plot_images(weight,<EOL><NUM_LIT:100> + <NUM_LIT:10> * k + k,<EOL>channels=channels,<EOL>title='<STR_LIT>')<EOL><DEDENT>

Create a plot of weights, visualized as "bottom-level" pixel arrays.


imgs = filters.get_value()<EOL>N, channels, x, y = imgs.shape<EOL>n = int(np.sqrt(N))<EOL>assert n * n == N, '<STR_LIT>'<EOL>assert channels == <NUM_LIT:1> or channels == <NUM_LIT:3>, '<STR_LIT>'<EOL>img = np.zeros(((y+<NUM_LIT:1>) * n - <NUM_LIT:1>, (x+<NUM_LIT:1>) * n - <NUM_LIT:1>, channels), dtype=imgs[<NUM_LIT:0>].dtype)<EOL>for i, pix in enumerate(imgs):<EOL><INDENT>r, c = divmod(i, n)<EOL>img[r * (y+<NUM_LIT:1>):(r+<NUM_LIT:1>) * (y+<NUM_LIT:1>) - <NUM_LIT:1>,<EOL>c * (x+<NUM_LIT:1>):(c+<NUM_LIT:1>) * (x+<NUM_LIT:1>) - <NUM_LIT:1>] = pix.transpose((<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:0>))<EOL><DEDENT>img -= img.min()<EOL>img /= img.max()<EOL>ax = plt.gcf().add_subplot(<NUM_LIT>)<EOL>ax.xaxis.set_visible(False)<EOL>ax.yaxis.set_visible(False)<EOL>ax.set_frame_on(False)<EOL>ax.imshow(img.squeeze(), cmap=plt.cm.gray)<EOL>

Create a plot of conv filters, visualized as pixel arrays.


stringin                = Mstringarray.StringArrayInput(debugger_cmds)<EOL>stringout               = Mstringarray.StringArrayOutput()<EOL>d_opts                  = {'<STR_LIT:input>' : stringin,<EOL>'<STR_LIT>': stringout}<EOL>d                       = Mdebugger.Trepan(d_opts)<EOL>d.settings['<STR_LIT>']  = True<EOL>d.settings['<STR_LIT>'] = False<EOL>d.settings['<STR_LIT>']  = False<EOL>d.settings['<STR_LIT>'] = '<STR_LIT>'<EOL>return d<EOL>

Common setup to create a debugger with stringio attached


<EOL>a1 = [re.sub(r'<STR_LIT>', r'<STR_LIT>', s) for s in a<EOL>if re.match(r'<STR_LIT>', s)]<EOL>a2 = [re.sub(r'<STR_LIT>', '<STR_LIT>', s) for s in a1]<EOL>a3 = [re.sub(r'<STR_LIT>', '<STR_LIT>', s) for s in a2]<EOL>return a3<EOL>

Return output with source lines prompt and command removed


caller = sys._getframe(<NUM_LIT:1>)<EOL>return caller.f_lineno<EOL>


self.closed = True<EOL>return<EOL>


if isinstance(inp, list):<EOL><INDENT>self.input = inp<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" % (type(inp), inp))<EOL><DEDENT>return<EOL>


def readline(self, use_raw=None, prompt='<STR_LIT>'):

if self.closed: raise ValueError<EOL>if <NUM_LIT:0> == len(self.input):<EOL><INDENT>self.closed = True<EOL>raise EOFError<EOL><DEDENT>line = self.input[<NUM_LIT:0>]<EOL>del self.input[<NUM_LIT:0>]<EOL>return line<EOL>

Read a line of input. EOFError will be raised on EOF.

        Note that we don't support prompting


self.closed = True<EOL>return<EOL>

Nothing to do here. Interface is for compatibility


return<EOL>


if isinstance(output, types.Listype):<EOL><INDENT>self.output = output<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" % (type(output),<EOL>output))<EOL><DEDENT>return<EOL>

Use this to set where to write to. output can be a
        file object or a string. This code raises IOError on error.

        If another file was previously open upon calling this open,
        that will be stacked and will come back into use after
        a close_write().


if self.closed: raise ValueError<EOL>if [] == self.output:<EOL><INDENT>self.output = [msg]<EOL><DEDENT>else:<EOL><INDENT>self.output[-<NUM_LIT:1>] += msg<EOL>pass<EOL><DEDENT>return<EOL>

This method the debugger uses to write. In contrast to
        writeline, no newline is added to the end to `str'.


self.write(msg)<EOL>self.output.append('<STR_LIT>')<EOL>return<EOL>

used to write to a debugger that is connected to this
        server; Here, we use the null string '' as an indicator of a
        newline.


name2id = Mthread.map_thread_names()<EOL>for thread_id, f in list(sys._current_frames().items()):<EOL><INDENT>self.assertEqual(thread_id,<EOL>name2id[Mthread.id2thread_name(thread_id)])<EOL>self.assertNotEqual(f, Mthread.find_debugged_frame(f))<EOL>pass<EOL><DEDENT>

Helper for testing map_thread_names and id2thread


<EOL>if a > b:<EOL><INDENT>(a, b) = (b, a)<EOL>pass<EOL><DEDENT>if a <= <NUM_LIT:0>:<EOL><INDENT>return None<EOL><DEDENT>if a == <NUM_LIT:1> or b-a == <NUM_LIT:0>:<EOL><INDENT>return a<EOL><DEDENT>return gcd(b-a, a)<EOL>


<EOL>if a > b:<EOL><INDENT>(a, b) = (b, a)<EOL><DEDENT>if a <= <NUM_LIT:0>:<EOL><INDENT>debug(step_ignore=<NUM_LIT:0>)<EOL>return None<EOL><DEDENT>if a == <NUM_LIT:1> or b-a == <NUM_LIT:0>:<EOL><INDENT>debug(start_opts={'<STR_LIT>': True})<EOL>return a<EOL><DEDENT>return gcd(b-a, a)<EOL>


dbg = _current[<NUM_LIT:0>]<EOL>if dbg is None or not dbg.active:<EOL><INDENT>dbg = _current[<NUM_LIT:0>] = RemoteCeleryTrepan()<EOL><DEDENT>return dbg<EOL>

Return the current debugger instance (if any),
    or creates a new one.


<EOL>if frame is None:<EOL><INDENT>frame = _frame().f_back<EOL><DEDENT>dbg = RemoteCeleryTrepan()<EOL>dbg.say(BANNER.format(self=dbg))<EOL>trepan.api.debug(dbg_opts=dbg.dbg_opts)<EOL>

Set breakpoint at current location, or a specified frame


substs = [<EOL>(r'<STR_LIT>',        r'<STR_LIT>'),<EOL>(r'<STR_LIT>',         r'<STR_LIT>'),<EOL>(r'<STR_LIT>',        r'<STR_LIT>'),<EOL>(r'<STR_LIT>',         r'<STR_LIT>'),<EOL>(r'<STR_LIT>',        r'<STR_LIT>'),<EOL>(r'<STR_LIT>', r'<STR_LIT>'),<EOL>(r'<STR_LIT>',           r'<STR_LIT>'),<EOL>(r'<STR_LIT>',            r'<STR_LIT>'),<EOL>(r'<STR_LIT>',           r'<STR_LIT:info>'),<EOL>(r'<STR_LIT>',          r'<STR_LIT>'),<EOL>(r'<STR_LIT>',          r'<STR_LIT>'),<EOL>(r'<STR_LIT>',              r'<STR_LIT>'),<EOL>]<EOL>regex_subs = [ (re.compile(regex, re.IGNORECASE), sub) for (regex, sub) in substs ]<EOL>def clean_line(line):<EOL><INDENT>try:<EOL><INDENT>for (regex, sub) in regex_subs:<EOL><INDENT>line = regex.sub(sub, line)<EOL><DEDENT><DEDENT>except Exception as ex:<EOL><INDENT>print("<STR_LIT>"%(regex, sub))<EOL>raise ex<EOL><DEDENT>return line<EOL><DEDENT>for line in lines:<EOL><INDENT>yield clean_line(line)<EOL><DEDENT>

:param file_inp:     a `filename` or ``sys.stdin``?
:param file_out:     a `filename` or ``sys.stdout`?`


if isinstance(output, io.TextIOWrapper) orisinstance(output, io.StringIO) oroutput == sys.stdout:<EOL><INDENT>pass<EOL><DEDENT>elif isinstance(output, '<STR_LIT:string>'.__class__):  <EOL><INDENT>output = open(output, '<STR_LIT:w>')<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" %<EOL>(output.__class__.__name__, output))<EOL><DEDENT>self.output = output<EOL>return<EOL>

Use this to set where to write to. output can be a
        file object or a string. This code raises IOError on error.


if self.output.closed:<EOL><INDENT>raise IOError("<STR_LIT>" % msg)<EOL><DEDENT>self.output.write(msg)<EOL>if self.flush_after_write: self.flush()<EOL>return<EOL>


get_option = lambda key: Mmisc.option_set(opts, key,<EOL>self.DEFAULT_OPEN_READ_OPTS)<EOL>if (isinstance(inp, io.TextIOWrapper) or<EOL>isinstance(inp, io.StringIO) or<EOL>hasattr(inp, '<STR_LIT>') and inp.isatty()):<EOL><INDENT>self.use_raw = get_option('<STR_LIT>')<EOL><DEDENT>elif isinstance(inp, '<STR_LIT:string>'.__class__):  <EOL><INDENT>if opts is None:<EOL><INDENT>self.use_raw = False<EOL><DEDENT>else:<EOL><INDENT>self.use_raw = get_option('<STR_LIT>')<EOL>pass<EOL><DEDENT>inp = open(inp, '<STR_LIT:r>')<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" % (type(inp),<EOL>inp))<EOL><DEDENT>self.input     = inp<EOL>self.line_edit = get_option('<STR_LIT>') and readline_importable()<EOL>self.closed = False<EOL>return<EOL>

Use this to set where to read from.

        Set opts['try_lineedit'] if you want this input to interact
        with GNU-like readline library. By default, we will assume to
        try importing and using readline. If readline is not
        importable, line editing is not available whether or not
        opts['try_readline'] is set.

        Set opts['use_raw'] if input should use Python's use_raw(). If
        however 'inp' is a string and opts['use_raw'] is not set, we
        will assume no raw output. Note that an individual readline
        may override the setting.


<EOL>if use_raw is None:<EOL><INDENT>use_raw = self.use_raw<EOL>pass<EOL><DEDENT>if use_raw:<EOL><INDENT>try:<EOL><INDENT>inp = input(prompt)<EOL>return inp<EOL><DEDENT>except ValueError:<EOL><INDENT>raise EOFError<EOL><DEDENT>pass<EOL><DEDENT>else:<EOL><INDENT>line = self.input.readline()<EOL>if not line: raise EOFError<EOL>return line.rstrip("<STR_LIT:\n>")<EOL><DEDENT>pass<EOL>

Read a line of input. EOFError will be raised on EOF.

        Note: some user interfaces may decide to arrange to call
        DebuggerOutput.write() first with the prompt rather than pass
        it here.. If `use_raw' is set raw_input() will be used in that
        is supported by the specific input input. If this option is
        left None as is normally expected the value from the class
        initialization is used.


raise NotImplementedError(NotImplementedMessage)<EOL>


Read a line of input. EOFError will be raised on EOF.

        Note that we don't support prompting first. Instead, arrange
        to call DebuggerOutput.write() first with the prompt. If
        `use_raw' is set raw_input() will be used in that is supported
        by the specific input input. If this option is left None as is
        normally expected the value from the class initialization is
        used.


self.write("<STR_LIT>" % msg)<EOL>return<EOL>

used to write to a debugger that is connected to this
        server; `str' written will have a newline added to it


if self.inout:<EOL><INDENT>self.inout.close()<EOL>pass<EOL><DEDENT>self.state = '<STR_LIT>'<EOL>return<EOL>


if self.state == '<STR_LIT>':<EOL><INDENT>if <NUM_LIT:0> == len(self.buf):<EOL><INDENT>self.buf = self.inout.recv(Mtcpfns.TCP_MAX_PACKET)<EOL>if <NUM_LIT:0> == (self.buf):<EOL><INDENT>self.state = '<STR_LIT>'<EOL>raise EOFError<EOL><DEDENT>pass<EOL><DEDENT>self.buf, data = Mtcpfns.unpack_msg(self.buf)<EOL>return data.decode('<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" % self.state)<EOL><DEDENT>

Read one message unit. It's possible however that
        more than one message will be set in a receive, so we will
        have to buffer that for the next read.
        EOFError will be raised on EOF.


<EOL>return self.inout.send(Mtcpfns.pack_msg(msg))<EOL>

This method the debugger uses to write a message unit.


self.state = '<STR_LIT>'<EOL>if self.inout:<EOL><INDENT>self.inout.close()<EOL>pass<EOL><DEDENT>self.state = '<STR_LIT>'<EOL>if self.conn:<EOL><INDENT>self.conn.close()<EOL><DEDENT>self.state = '<STR_LIT>'<EOL>return<EOL>

Closes both socket and server connection.


if self.state != '<STR_LIT>':<EOL><INDENT>self.wait_for_connect()<EOL>pass<EOL><DEDENT>if self.state == '<STR_LIT>':<EOL><INDENT>if <NUM_LIT:0> == len(self.buf):<EOL><INDENT>self.buf = self.conn.recv(Mtcpfns.TCP_MAX_PACKET)<EOL>if <NUM_LIT:0> == len(self.buf):<EOL><INDENT>self.state = '<STR_LIT>'<EOL>raise EOFError<EOL><DEDENT>pass<EOL><DEDENT>self.buf, data = Mtcpfns.unpack_msg(self.buf)<EOL>return data.decode('<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" % self.state)<EOL><DEDENT>


if self.state != '<STR_LIT>':<EOL><INDENT>self.wait_for_connect()<EOL>pass<EOL><DEDENT>buffer = Mtcpfns.pack_msg(msg)<EOL>while len(buffer) > Mtcpfns.TCP_MAX_PACKET:<EOL><INDENT>self.conn.send(buffer[:Mtcpfns.TCP_MAX_PACKET])<EOL>buffer = buffer[Mtcpfns.TCP_MAX_PACKET:]<EOL><DEDENT>return self.conn.send(buffer)<EOL>

This method the debugger uses to write. In contrast to
        writeline, no newline is added to the end to `str'. Also
        msg doesn't have to be a string.


self.closed = True<EOL>return<EOL>


if isinstance(inp, list):<EOL><INDENT>self.input = inp<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" % (type(inp), inp))<EOL><DEDENT>return<EOL>


if self.closed: raise ValueError<EOL>if <NUM_LIT:0> == len(self.input):<EOL><INDENT>self.closed = True<EOL>raise EOFError<EOL><DEDENT>line = self.input[<NUM_LIT:0>]<EOL>del self.input[<NUM_LIT:0>]<EOL>return line<EOL>

Read a line of input. EOFError will be raised on EOF.

        Note that we don't support prompting


self.closed = True<EOL>return<EOL>

Nothing to do here. Interface is for compatibility


return<EOL>


if isinstance(output, types.Listype):<EOL><INDENT>self.output = output<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" % (type(output),<EOL>output))<EOL><DEDENT>return<EOL>

Use this to set where to write to. output can be a
        file object or a string. This code raises IOError on error.

        If another file was previously open upon calling this open,
        that will be stacked and will come back into use after
        a close_write().


if self.closed: raise ValueError<EOL>if [] == self.output:<EOL><INDENT>self.output = [msg]<EOL><DEDENT>else:<EOL><INDENT>self.output[-<NUM_LIT:1>] += msg<EOL>pass<EOL><DEDENT>return<EOL>

This method the debugger uses to write. In contrast to
        writeline, no newline is added to the end to `str'.


self.write(msg)<EOL>self.output.append('<STR_LIT>')<EOL>return<EOL>

used to write to a debugger that is connected to this
        server; Here, we use the null string '' as an indicator of a
        newline.


if isinstance(inp, io.TextIOWrapper):<EOL><INDENT>self.input = inp<EOL><DEDENT>elif isinstance(inp, '<STR_LIT:string>'.__class__):  <EOL><INDENT>self.name  = inp<EOL>self.input = open(inp, '<STR_LIT:r>')<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" %<EOL>(inp.__class__.__name__, inp))<EOL><DEDENT>return<EOL>


def readline(self, prompt='<STR_LIT>', use_raw=None):

line = self.input.readline()<EOL>if not line: raise EOFError<EOL>return line.rstrip("<STR_LIT:\n>")<EOL>

Read a line of input. Prompt and use_raw exist to be
        compatible with other input routines and are ignored.
        EOFError will be raised on EOF.


self.state = '<STR_LIT>'<EOL>if self.input:<EOL><INDENT>self.input.close()<EOL>pass<EOL><DEDENT>if self.output:<EOL><INDENT>self.output.close()<EOL>pass<EOL><DEDENT>self.state = '<STR_LIT>'<EOL>return<EOL>


<EOL>if self.state == '<STR_LIT>':<EOL><INDENT>if not self.input:<EOL><INDENT>self.input = open(self.in_name, '<STR_LIT:r>')<EOL>pass<EOL><DEDENT>line = self.input.readline()<EOL>if not line:<EOL><INDENT>self.state = '<STR_LIT>'<EOL>raise EOFError<EOL><DEDENT>return line.encode("<STR_LIT:utf-8>")<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" % self.state)<EOL><DEDENT>return<EOL>


if self.state == '<STR_LIT>':<EOL><INDENT>if not self.output:<EOL><INDENT>self.output = open(self.out_name, '<STR_LIT:w>')<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>else:<EOL><INDENT>raise EOFError<EOL><DEDENT>self.output.write(msg)<EOL>if self.flush_after_write: self.flush()<EOL>return<EOL>


def run(self, cmd, start_opts=None, globals_=None, locals_=None):

if globals_ is None:<EOL><INDENT>globals_ = globals()<EOL><DEDENT>if locals_ is None:<EOL><INDENT>locals_ = globals_<EOL><DEDENT>if not isinstance(cmd, types.CodeType):<EOL><INDENT>self.eval_string = cmd<EOL>cmd = cmd+'<STR_LIT:\n>'<EOL>pass<EOL><DEDENT>retval = None<EOL>self.core.start(start_opts)<EOL>try:<EOL><INDENT>retval = eval(cmd, globals_, locals_)<EOL><DEDENT>except SyntaxError:<EOL><INDENT>try:<EOL><INDENT>exec(cmd, globals_, locals_)<EOL><DEDENT>except DebuggerQuit:<EOL><INDENT>pass<EOL><DEDENT>except DebuggerQuit:<EOL><INDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>except DebuggerQuit:<EOL><INDENT>pass<EOL><DEDENT>finally:<EOL><INDENT>self.core.stop()<EOL><DEDENT>return retval<EOL>

Run debugger on string `cmd' using builtin function eval
        and if that builtin exec.  Arguments `globals_' and `locals_'
        are the dictionaries to use for local and global variables. By
        default, the value of globals is globals(), the current global
        variables. If `locals_' is not given, it becomes a copy of
        `globals_'.

        Debugger.core.start settings are passed via optional
        dictionary `start_opts'. Overall debugger settings are in
        Debugger.settings which changed after an instance is created
        . Also see `run_eval' if what you want to run is an
        run_eval'able expression have that result returned and
        `run_call' if you want to debug function run_call.


def run_exec(self, cmd, start_opts=None, globals_=None, locals_=None):

if globals_ is None:<EOL><INDENT>globals_ = globals()<EOL><DEDENT>if locals_ is None:<EOL><INDENT>locals_ = globals_<EOL><DEDENT>if not isinstance(cmd, types.CodeType):<EOL><INDENT>cmd = cmd+'<STR_LIT:\n>'<EOL>pass<EOL><DEDENT>self.core.start(start_opts)<EOL>try:<EOL><INDENT>exec(cmd, globals_, locals_)<EOL><DEDENT>except DebuggerQuit:<EOL><INDENT>pass<EOL><DEDENT>finally:<EOL><INDENT>self.core.stop()<EOL><DEDENT>return<EOL>

Run debugger on string `cmd' which will executed via the
        builtin function exec. Arguments `globals_' and `locals_' are
        the dictionaries to use for local and global variables. By
        default, the value of globals is globals(), the current global
        variables. If `locals_' is not given, it becomes a copy of
        `globals_'.

        Debugger.core.start settings are passed via optional
        dictionary `start_opts'. Overall debugger settings are in
        Debugger.settings which changed after an instance is created
        . Also see `run_eval' if what you want to run is an
        run_eval'able expression have that result returned and
        `run_call' if you want to debug function run_call.


def run_call(self, func, start_opts=None, *args, **kwds):

res = None<EOL>self.core.start(opts=start_opts)<EOL>try:<EOL><INDENT>res = func(*args, **kwds)<EOL><DEDENT>except DebuggerQuit:<EOL><INDENT>pass<EOL><DEDENT>finally:<EOL><INDENT>self.core.stop()<EOL><DEDENT>return res<EOL>

Run debugger on function call: `func(*args, **kwds)'

        See also `run_eval' if what you want to run is an eval'able
        expression have that result returned and `run' if you want to
        debug a statment via exec.


def run_eval(self, expr, start_opts=None, globals_=None, locals_=None):

if globals_ is None:<EOL><INDENT>globals_ = globals()<EOL><DEDENT>if locals_ is None:<EOL><INDENT>locals_ = globals_<EOL><DEDENT>if not isinstance(expr, types.CodeType):<EOL><INDENT>self.eval_string = expr<EOL>expr = expr+'<STR_LIT:\n>'<EOL>pass<EOL><DEDENT>retval = None<EOL>self.core.start(start_opts)<EOL>try:<EOL><INDENT>retval = eval(expr, globals_, locals_)<EOL><DEDENT>except DebuggerQuit:<EOL><INDENT>pass<EOL><DEDENT>finally:<EOL><INDENT>pyficache.remove_remap_file('<STR_LIT>')<EOL>self.core.stop()<EOL><DEDENT>return retval<EOL>

Run debugger on string `expr' which will executed via the
        built-in Python function: eval; `globals_' and `locals_' are
        the dictionaries to use for local and global variables. If
        `globals' is not given, __main__.__dict__ (the current global
        variables) is used. If `locals_' is not given, it becomes a
        copy of `globals_'.

        See also `run_call' if what you to debug a function call and
        `run' if you want to debug general Python statements.


def run_script(self, filename, start_opts=None, globals_=None,<EOL>locals_=None):

self.mainpyfile = self.core.canonic(filename)<EOL>if globals_ is None:<EOL><INDENT>import __main__  <EOL>globals_ = {"<STR_LIT>" : "<STR_LIT:__main__>",<EOL>"<STR_LIT>" : self.mainpyfile,<EOL>"<STR_LIT>" : __builtins__<EOL>}  <EOL><DEDENT>if locals_ is None:<EOL><INDENT>locals_ = globals_<EOL><DEDENT>retval = False<EOL>self.core.execution_status = '<STR_LIT>'<EOL>try:<EOL><INDENT>compiled = compile(open(self.mainpyfile).read(),<EOL>self.mainpyfile, '<STR_LIT>')<EOL>self.core.start(start_opts)<EOL>exec(compiled, globals_, locals_)<EOL>retval = True<EOL><DEDENT>except SyntaxError:<EOL><INDENT>print(sys.exc_info()[<NUM_LIT:1>])<EOL>retval = False<EOL>pass<EOL><DEDENT>except IOError:<EOL><INDENT>print(sys.exc_info()[<NUM_LIT:1>])<EOL><DEDENT>except DebuggerQuit:<EOL><INDENT>retval = False<EOL>pass<EOL><DEDENT>except DebuggerRestart:<EOL><INDENT>self.core.execution_status = '<STR_LIT>'<EOL>raise DebuggerRestart<EOL><DEDENT>finally:<EOL><INDENT>self.core.stop(options={'<STR_LIT>': True})<EOL><DEDENT>return retval<EOL>

Run debugger on Python script `filename'. The script may
        inspect sys.argv for command arguments. `globals_' and
        `locals_' are the dictionaries to use for local and global
        variables. If `globals' is not given, globals() (the current
        global variables) is used. If `locals_' is not given, it
        becomes a copy of `globals_'.

        True is returned if the program terminated normally and False
        if the debugger initiated a quit or the program did not normally
        terminate.

        See also `run_call' if what you to debug a function call,
        `run_eval' if you want to debug an expression, and `run' if you
        want to debug general Python statements not inside a file.


return self.orig_sys_argv or self.program_sys_argv<EOL>

Return an array that would be execv-ed  to restart the program


import trepan.lib.core as Mcore<EOL>self.mainpyfile  = None<EOL>self.thread      = None<EOL>self.eval_string = None<EOL>get_option = lambda key: option_set(opts, key,<EOL>self.DEFAULT_INIT_OPTS)<EOL>completer  = lambda text, state: self.complete(text, state)<EOL>for opt in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>setattr(self, opt, get_option(opt))<EOL>pass<EOL><DEDENT>core_opts = {}<EOL>for opt in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>',):<EOL><INDENT>core_opts[opt] = get_option(opt)<EOL>pass<EOL><DEDENT>interface_opts={'<STR_LIT>': completer}<EOL>interface = (get_option('<STR_LIT>') or<EOL>Muser.UserInterface(opts=interface_opts))<EOL>self.intf = [interface]<EOL>inp = get_option('<STR_LIT:input>')<EOL>if inp:<EOL><INDENT>self.intf[-<NUM_LIT:1>].input = inp<EOL>pass<EOL><DEDENT>out = get_option('<STR_LIT>')<EOL>if out:<EOL><INDENT>self.intf[-<NUM_LIT:1>].output = out<EOL>pass<EOL><DEDENT>self.core = Mcore.TrepanCore(self, core_opts)<EOL>self.core.add_ignore(self.core.stop)<EOL>self.core.trace_hook_suspend = False<EOL>if get_option('<STR_LIT>'):<EOL><INDENT>self.program_sys_argv = list(sys.argv)<EOL><DEDENT>else:<EOL><INDENT>self.program_sys_argv = None<EOL>pass<EOL><DEDENT>self.sigmgr = Msig.SignalManager(self)<EOL>if get_option('<STR_LIT>'):<EOL><INDENT>self.core.start(get_option('<STR_LIT>'))<EOL>pass<EOL><DEDENT>return<EOL>

Create a debugger object. But depending on the value of
        key 'start' inside hash 'opts', we may or may not initially
        start debugging.

        See also Debugger.start and Debugger.stop.


d = os.path.dirname(callername)<EOL>glob(os.path.join(d, '<STR_LIT>'))<EOL>py_files = glob(os.path.join(d, '<STR_LIT>'))<EOL>return [ os.path.basename(filename[<NUM_LIT:0>:-<NUM_LIT:3>]) for filename in py_files ]<EOL>

All python files caller's dir without the path and trailing .py


global __title__<EOL>orig_sys_argv = list(sys_argv)<EOL>opts, dbg_opts, sys_argv  = Moptions.process_options(__title__,<EOL>VERSION,<EOL>sys_argv)<EOL>if opts.server is not None:<EOL><INDENT>if opts.server == '<STR_LIT>':<EOL><INDENT>connection_opts={'<STR_LIT>': '<STR_LIT>', '<STR_LIT>': opts.port}<EOL><DEDENT>else:<EOL><INDENT>connection_opts={'<STR_LIT>': '<STR_LIT>'}<EOL><DEDENT>intf = Mserver.ServerInterface(connection_opts=connection_opts)<EOL>dbg_opts['<STR_LIT>'] = intf<EOL>if '<STR_LIT>' == intf.server_type:<EOL><INDENT>print('<STR_LIT>' % os.getpid())<EOL><DEDENT>elif '<STR_LIT>' == intf.server_type:<EOL><INDENT>print('<STR_LIT>' %<EOL>intf.inout.PORT)<EOL>pass<EOL><DEDENT><DEDENT>elif opts.client:<EOL><INDENT>Mclient.run(opts, sys_argv)<EOL>return<EOL><DEDENT>dbg_opts['<STR_LIT>'] = orig_sys_argv<EOL>if dbg is None:<EOL><INDENT>dbg = Mdebugger.Trepan(dbg_opts)<EOL>dbg.core.add_ignore(main)<EOL>pass<EOL><DEDENT>Moptions._postprocess_options(dbg, opts)<EOL>if len(sys_argv) == <NUM_LIT:0>:<EOL><INDENT>mainpyfile = None<EOL><DEDENT>else:<EOL><INDENT>mainpyfile = sys_argv[<NUM_LIT:0>]  <EOL>if not osp.isfile(mainpyfile):<EOL><INDENT>mainpyfile=Mclifns.whence_file(mainpyfile)<EOL>is_readable = Mfile.readable(mainpyfile)<EOL>if is_readable is None:<EOL><INDENT>print("<STR_LIT>"<EOL>% (__title__, mainpyfile,))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>elif not is_readable:<EOL><INDENT>print("<STR_LIT>"<EOL>% (__title__, mainpyfile, ))<EOL>sys.exit(<NUM_LIT:1>)<EOL>return<EOL><DEDENT><DEDENT>if Mfile.is_compiled_py(mainpyfile):<EOL><INDENT>try:<EOL><INDENT>from xdis import load_module, PYTHON_VERSION, IS_PYPY<EOL>(python_version, timestamp, magic_int, co, is_pypy,<EOL>source_size) = load_module(mainpyfile, code_objects=None,<EOL>fast_load=True)<EOL>assert is_pypy == IS_PYPY<EOL>assert python_version == PYTHON_VERSION,"<STR_LIT>" % (<EOL>python_version, PYTHON_VERSION)<EOL>py_file = co.co_filename<EOL>if osp.isabs(py_file):<EOL><INDENT>try_file = py_file<EOL><DEDENT>else:<EOL><INDENT>mainpydir = osp.dirname(mainpyfile)<EOL>tag = sys.implementation.cache_tag<EOL>dirnames = [osp.join(mainpydir, tag),<EOL>mainpydir] + os.environ['<STR_LIT>'].split(osp.pathsep) + ['<STR_LIT:.>']<EOL>try_file = Mclifns.whence_file(py_file, dirnames)<EOL><DEDENT>if osp.isfile(try_file):<EOL><INDENT>mainpyfile = try_file<EOL>pass<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" % try_file)<EOL><DEDENT><DEDENT>except IOError:<EOL><INDENT>try:<EOL><INDENT>from uncompyle6 import decompile_file<EOL><DEDENT>except ImportError:<EOL><INDENT>print("<STR_LIT>"<EOL>% (__title__, mainpyfile), file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL>return<EOL><DEDENT>short_name = osp.basename(mainpyfile).strip('<STR_LIT>')<EOL>fd = tempfile.NamedTemporaryFile(suffix='<STR_LIT>',<EOL>prefix=short_name + "<STR_LIT:_>",<EOL>delete=False)<EOL>old_write = fd.file.write<EOL>def write_wrapper(*args, **kwargs):<EOL><INDENT>if isinstance(args[<NUM_LIT:0>], str):<EOL><INDENT>new_args = list(args)<EOL>new_args[<NUM_LIT:0>] = args[<NUM_LIT:0>].encode('<STR_LIT:utf-8>')<EOL>old_write(*new_args, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>old_write(*args, **kwargs)<EOL><DEDENT><DEDENT>fd.file.write = write_wrapper<EOL>try:<EOL><INDENT>decompile_file(mainpyfile, fd.file, mapstream=fd)<EOL><DEDENT>except:<EOL><INDENT>print("<STR_LIT>"<EOL>% (__title__, mainpyfile), file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL>return<EOL><DEDENT>mainpyfile = fd.name<EOL>fd.close()<EOL>print("<STR_LIT>"<EOL>% (__title__, mainpyfile), file=sys.stderr)<EOL>pass<EOL><DEDENT><DEDENT>mainpyfile_noopt = pyficache.pyc2py(mainpyfile)<EOL>if mainpyfile != mainpyfile_nooptand Mfile.readable(mainpyfile_noopt):<EOL><INDENT>print("<STR_LIT>"<EOL>% __title__)<EOL>print("<STR_LIT>" % (<EOL>__title__, mainpyfile_noopt,))<EOL>mainpyfile = mainpyfile_noopt<EOL>pass<EOL><DEDENT>sys.path[<NUM_LIT:0>] = dbg.main_dirname = osp.dirname(mainpyfile)<EOL><DEDENT>dbg.sig_received = False<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>if dbg.program_sys_argv and mainpyfile:<EOL><INDENT>normal_termination = dbg.run_script(mainpyfile)<EOL>if not normal_termination: break<EOL><DEDENT>else:<EOL><INDENT>dbg.core.execution_status = '<STR_LIT>'<EOL>dbg.core.processor.process_commands()<EOL>pass<EOL><DEDENT>dbg.core.execution_status = '<STR_LIT>'<EOL>dbg.intf[-<NUM_LIT:1>].msg("<STR_LIT>")<EOL>dbg.core.processor.process_commands()<EOL><DEDENT>except Mexcept.DebuggerQuit:<EOL><INDENT>break<EOL><DEDENT>except Mexcept.DebuggerRestart:<EOL><INDENT>dbg.core.execution_status = '<STR_LIT>'<EOL>if dbg.program_sys_argv:<EOL><INDENT>sys.argv = list(dbg.program_sys_argv)<EOL>part1 = ('<STR_LIT>' %<EOL>dbg.core.filename(mainpyfile))<EOL>args  = '<STR_LIT:U+0020>'.join(dbg.program_sys_argv[<NUM_LIT:1>:])<EOL>dbg.intf[-<NUM_LIT:1>].msg(<EOL>Mmisc.wrapped_lines(part1, args,<EOL>dbg.settings['<STR_LIT:width>']))<EOL><DEDENT>else: break<EOL><DEDENT>except SystemExit:<EOL><INDENT>break<EOL><DEDENT>pass<EOL><DEDENT>sys.argv = orig_sys_argv<EOL>return<EOL>

Routine which gets run if we were invoked directly


def parse_list_cmd(proc, args, listsize=<NUM_LIT:10>):

text = proc.current_command[len(args[<NUM_LIT:0>])+<NUM_LIT:1>:].strip()<EOL>if text in frozenset(('<STR_LIT>', '<STR_LIT:.>', '<STR_LIT:+>', '<STR_LIT:->')):<EOL><INDENT>if text == '<STR_LIT:.>':<EOL><INDENT>location = resolve_location(proc, '<STR_LIT:.>')<EOL>return location.path, location.line_number, listsize<EOL><DEDENT>else:<EOL><INDENT>if proc.list_lineno is None:<EOL><INDENT>proc.errmsg("<STR_LIT>")<EOL>return INVALID_PARSE_LIST<EOL><DEDENT>filename = proc.list_filename<EOL>if text == '<STR_LIT:+>':<EOL><INDENT>first = max(<NUM_LIT:1>, proc.list_lineno + listsize)<EOL><DEDENT>elif text == '<STR_LIT:->':<EOL><INDENT>if proc.list_lineno == <NUM_LIT:1> + listsize:<EOL><INDENT>proc.errmsg("<STR_LIT>" % proc.list_filename)<EOL>return INVALID_PARSE_LIST<EOL><DEDENT>first = max(<NUM_LIT:1>, proc.list_lineno - (<NUM_LIT:2>*listsize) - <NUM_LIT:1>)<EOL><DEDENT>elif text == '<STR_LIT>':<EOL><INDENT>first = proc.list_lineno + <NUM_LIT:1><EOL><DEDENT><DEDENT>last = first + listsize - <NUM_LIT:1><EOL>return filename, first, last<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>list_range = build_range(text)<EOL><DEDENT>except LocationError as e:<EOL><INDENT>proc.errmsg("<STR_LIT>")<EOL>proc.errmsg(e.text)<EOL>proc.errmsg(e.text_cursor)<EOL>return INVALID_PARSE_LIST<EOL><DEDENT>except ScannerError as e:<EOL><INDENT>proc.errmsg("<STR_LIT>")<EOL>proc.errmsg(e.text)<EOL>proc.errmsg(e.text_cursor)<EOL>return INVALID_PARSE_LIST<EOL><DEDENT>if list_range.first is None:<EOL><INDENT>assert isinstance(list_range.last, Location)<EOL>location = resolve_location(proc, list_range.last)<EOL>if not location:<EOL><INDENT>return INVALID_PARSE_LIST<EOL><DEDENT>last     = location.line_number<EOL>first    = max(<NUM_LIT:1>, last - listsize)<EOL>return location.path, first, last<EOL><DEDENT>elif isinstance(list_range.first, int):<EOL><INDENT>first    = list_range.first<EOL>location = resolve_location(proc, list_range.last)<EOL>if not location:<EOL><INDENT>return INVALID_PARSE_LIST<EOL><DEDENT>filename = location.path<EOL>last     = location.line_number<EOL>if last < first:<EOL><INDENT>last = first + last<EOL><DEDENT>return location.path, first, last<EOL><DEDENT>else:<EOL><INDENT>assert isinstance(list_range.first, Location)<EOL>location = resolve_location(proc, list_range.first)<EOL>if not location:<EOL><INDENT>return INVALID_PARSE_LIST<EOL><DEDENT>first    = location.line_number<EOL>last     = list_range.last<EOL>if location.method:<EOL><INDENT>first -= listsize // <NUM_LIT:2><EOL><DEDENT>if isinstance(last, str):<EOL><INDENT>assert last[<NUM_LIT:0>] == '<STR_LIT:+>'<EOL>last = first + int(last[<NUM_LIT:1>:])<EOL><DEDENT>elif not last:<EOL><INDENT>last = first + listsize<EOL><DEDENT>elif last < first:<EOL><INDENT>last = first + last<EOL><DEDENT>return location.path, first, last<EOL><DEDENT>pass<EOL><DEDENT>return<EOL>

Parses arguments for the "list" command and returns the tuple:
    (filename, first line number, last line number)
    or sets these to None if there was some problem.


def parse_addr_list_cmd(proc, args, listsize=<NUM_LIT>):

text = proc.current_command[len(args[<NUM_LIT:0>])+<NUM_LIT:1>:].strip()<EOL>if text in frozenset(('<STR_LIT>', '<STR_LIT:.>', '<STR_LIT:+>', '<STR_LIT:->')):<EOL><INDENT>if text == '<STR_LIT:.>':<EOL><INDENT>location = resolve_address_location(proc, '<STR_LIT:.>')<EOL>return (location.path, location.line_number, True,<EOL>location.line_number + listsize, True,<EOL>location.method)<EOL><DEDENT>if proc.list_offset is None:<EOL><INDENT>proc.errmsg("<STR_LIT>")<EOL>return INVALID_PARSE_LIST<EOL><DEDENT>filename = proc.list_filename<EOL>if text == '<STR_LIT:+>':<EOL><INDENT>first = max(<NUM_LIT:0>, proc.list_offset-<NUM_LIT:1>)<EOL><DEDENT>elif text == '<STR_LIT:->':<EOL><INDENT>if proc.list_lineno == <NUM_LIT:1> + listsize:<EOL><INDENT>proc.errmsg("<STR_LIT>" % proc.list_filename)<EOL>return INVALID_PARSE_LIST<EOL><DEDENT>first = max(<NUM_LIT:1>, proc.list_lineno - (<NUM_LIT:2>*listsize) - <NUM_LIT:1>)<EOL><DEDENT>elif text == '<STR_LIT>':<EOL><INDENT>first = proc.list_offset + <NUM_LIT:1><EOL>last = first + listsize - <NUM_LIT:1><EOL>return filename, first, True, last, True, proc.list_object<EOL><DEDENT>last = first + listsize - <NUM_LIT:1><EOL>return filename, first, True, last, True, proc.list_object<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>list_range = build_arange(text)<EOL><DEDENT>except LocationError as e:<EOL><INDENT>proc.errmsg("<STR_LIT>")<EOL>proc.errmsg(e.text)<EOL>proc.errmsg(e.text_cursor)<EOL>return INVALID_PARSE_LIST<EOL><DEDENT>except ScannerError as e:<EOL><INDENT>proc.errmsg("<STR_LIT>")<EOL>proc.errmsg(e.text)<EOL>proc.errmsg(e.text_cursor)<EOL>return INVALID_PARSE_LIST<EOL><DEDENT>if list_range.first is None:<EOL><INDENT>assert isinstance(list_range.last, Location)<EOL>location = resolve_address_location(proc, list_range.last)<EOL>if not location:<EOL><INDENT>return INVALID_PARSE_LIST<EOL><DEDENT>last     = location.line_number<EOL>if location.is_address:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>first    = max(<NUM_LIT:1>, last - listsize)<EOL><DEDENT>return location.path, first, False, last, False, location.method<EOL><DEDENT>elif isinstance(list_range.first, int):<EOL><INDENT>first    = list_range.first<EOL>location = resolve_address_location(proc, list_range.last)<EOL>if not location:<EOL><INDENT>return INVALID_PARSE_LIST<EOL><DEDENT>filename = location.path<EOL>last     = location.line_number<EOL>if not location.is_address and last < first:<EOL><INDENT>last = first + last<EOL><DEDENT>return location.path, first, False, last, location.is_address, location.method<EOL><DEDENT>else:<EOL><INDENT>assert isinstance(list_range.first, Location)<EOL>location = resolve_address_location(proc, list_range.first)<EOL>if not location:<EOL><INDENT>return INVALID_PARSE_LIST<EOL><DEDENT>first    = location.line_number<EOL>first_is_addr = location.is_address<EOL>last_is_addr  = False<EOL>last     = list_range.last<EOL>if isinstance(last, str):<EOL><INDENT>assert last[<NUM_LIT:0>] in ('<STR_LIT:+>', '<STR_LIT:*>')<EOL>last_is_addr = last[<NUM_LIT:0>] == '<STR_LIT:*>'<EOL>if last_is_addr:<EOL><INDENT>last = int(last[<NUM_LIT:1>:])<EOL><DEDENT>else:<EOL><INDENT>last = first + int(last[<NUM_LIT:1>:])<EOL><DEDENT><DEDENT>elif not last:<EOL><INDENT>last_is_addr = True<EOL>last = first + listsize<EOL><DEDENT>elif last < first:<EOL><INDENT>last = first + last<EOL><DEDENT>return location.path, first, first_is_addr, last, last_is_addr, location.method<EOL><DEDENT>pass<EOL><DEDENT>return<EOL>


def adjust_frame(proc_obj, name, pos, absolute_pos):

if not proc_obj.curframe:<EOL><INDENT>proc_obj.errmsg("<STR_LIT>")<EOL>return<EOL><DEDENT>if absolute_pos:<EOL><INDENT>if pos >= <NUM_LIT:0>:<EOL><INDENT>pos = frame_num(proc_obj, pos)<EOL><DEDENT>else:<EOL><INDENT>pos = -pos - <NUM_LIT:1><EOL>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pos += proc_obj.curindex<EOL>pass<EOL><DEDENT>if pos < <NUM_LIT:0>:<EOL><INDENT>proc_obj.errmsg("<STR_LIT>")<EOL>return<EOL><DEDENT>elif pos >= len(proc_obj.stack):<EOL><INDENT>proc_obj.errmsg("<STR_LIT>")<EOL>return<EOL><DEDENT>proc_obj.curindex = pos<EOL>proc_obj.curframe = proc_obj.stack[proc_obj.curindex][<NUM_LIT:0>]<EOL>proc_obj.location()<EOL>proc_obj.list_lineno   = None<EOL>proc_obj.list_offset   = proc_obj.curframe.f_lasti<EOL>proc_obj.list_object   = proc_obj.curframe<EOL>proc_obj.list_filename = proc_obj.curframe.f_code.co_filename<EOL>return<EOL>

Adjust stack frame by pos positions. If absolute_pos then
    pos is an absolute number. Otherwise it is a relative number.

    A negative number indexes from the other end.


curframe = proc.curframe<EOL>if location == '<STR_LIT:.>':<EOL><INDENT>if not curframe:<EOL><INDENT>proc.errmsg("<STR_LIT>")<EOL>return INVALID_LOCATION<EOL><DEDENT>filename = Mstack.frame2file(proc.core, curframe, canonic=False)<EOL>lineno   = inspect.getlineno(curframe)<EOL>return Location(filename, lineno, False, None)<EOL><DEDENT>assert isinstance(location, Location)<EOL>is_address = False<EOL>if proc.curframe:<EOL><INDENT>g = curframe.f_globals<EOL>l = curframe.f_locals<EOL><DEDENT>else:<EOL><INDENT>g = globals()<EOL>l = locals()<EOL>pass<EOL><DEDENT>if location.method:<EOL><INDENT>filename = lineno = None<EOL>msg = ('<STR_LIT>' % location.method)<EOL>try:<EOL><INDENT>modfunc = eval(location.method, g, l)<EOL><DEDENT>except:<EOL><INDENT>proc.errmsg(msg)<EOL>return INVALID_LOCATION<EOL><DEDENT>try:<EOL><INDENT>if inspect.isfunction(modfunc) or hasattr(modfunc, '<STR_LIT>'):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>proc.errmsg(msg)<EOL>return INVALID_LOCATION<EOL><DEDENT><DEDENT>except:<EOL><INDENT>proc.errmsg(msg)<EOL>return INVALID_LOCATION<EOL><DEDENT>filename = proc.core.canonic(modfunc.__code__.co_filename)<EOL>lineno   = modfunc.__code__.co_firstlineno<EOL><DEDENT>elif location.path:<EOL><INDENT>filename = proc.core.canonic(location.path)<EOL>lineno  =  location.line_number<EOL>modfunc  = None<EOL>msg = "<STR_LIT>" % location.path<EOL>if not osp.isfile(filename):<EOL><INDENT>try:<EOL><INDENT>modfunc = eval(location.path, g, l)<EOL><DEDENT>except:<EOL><INDENT>msg = ("<STR_LIT>"<EOL>% location.path)<EOL>proc.errmsg(msg)<EOL>return INVALID_LOCATION<EOL><DEDENT>pass<EOL>is_address = location.is_address<EOL>if inspect.ismodule(modfunc):<EOL><INDENT>if hasattr(modfunc, '<STR_LIT>'):<EOL><INDENT>filename = pyficache.pyc2py(modfunc.__file__)<EOL>filename = proc.core.canonic(filename)<EOL>if not lineno:<EOL><INDENT>lineno = <NUM_LIT:1><EOL>is_address = False<EOL><DEDENT>return Location(filename, lineno, is_address, modfunc)<EOL><DEDENT>else:<EOL><INDENT>msg = ("<STR_LIT>" %<EOL>location.path)<EOL><DEDENT><DEDENT>proc.errmsg(msg)<EOL>return INVALID_LOCATION<EOL><DEDENT>maxline = pyficache.maxline(filename)<EOL>if maxline and lineno > maxline:<EOL><INDENT>proc.errmsg("<STR_LIT>"<EOL>% (lineno, filename, maxline))<EOL>return INVALID_LOCATION<EOL><DEDENT><DEDENT>elif location.line_number:<EOL><INDENT>filename   = Mstack.frame2file(proc.core, curframe, canonic=False)<EOL>lineno     = location.line_number<EOL>is_address = location.is_address<EOL>modfunc  = None<EOL><DEDENT>return Location(filename, lineno, is_address, modfunc)<EOL>

Expand fields in Location namedtuple. If:
       '.':  get fields from stack
       function/module: get fields from evaluation/introspection
       location file and line number: use that


curframe = proc.curframe<EOL>if location == '<STR_LIT:.>':<EOL><INDENT>filename = Mstack.frame2file(proc.core, curframe, canonic=False)<EOL>offset   = curframe.f_lasti<EOL>is_address = True<EOL>return Location(filename, offset, False, None)<EOL><DEDENT>assert isinstance(location, Location)<EOL>is_address = True<EOL>if proc.curframe:<EOL><INDENT>g = curframe.f_globals<EOL>l = curframe.f_locals<EOL><DEDENT>else:<EOL><INDENT>g = globals()<EOL>l = locals()<EOL>pass<EOL><DEDENT>if location.method:<EOL><INDENT>filename = offset = None<EOL>msg = ('<STR_LIT>' % location.method)<EOL>try:<EOL><INDENT>modfunc = eval(location.method, g, l)<EOL><DEDENT>except:<EOL><INDENT>proc.errmsg(msg)<EOL>return INVALID_LOCATION<EOL><DEDENT>try:<EOL><INDENT>if inspect.isfunction(modfunc) or hasattr(modfunc, '<STR_LIT>'):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>proc.errmsg(msg)<EOL>return INVALID_LOCATION<EOL><DEDENT><DEDENT>except:<EOL><INDENT>proc.errmsg(msg)<EOL>return INVALID_LOCATION<EOL><DEDENT>filename = proc.core.canonic(modfunc.func_code.co_filename)<EOL>offset   = <NUM_LIT:0><EOL><DEDENT>elif location.path:<EOL><INDENT>filename = proc.core.canonic(location.path)<EOL>offset  =  location.line_number<EOL>is_address = location.is_address<EOL>modfunc  = None<EOL>msg = "<STR_LIT>" % location.path<EOL>if not osp.isfile(filename):<EOL><INDENT>try:<EOL><INDENT>modfunc = eval(location.path, g, l)<EOL><DEDENT>except:<EOL><INDENT>msg = ("<STR_LIT>"<EOL>% location.path)<EOL>proc.errmsg(msg)<EOL>return INVALID_LOCATION<EOL><DEDENT>pass<EOL>is_address = location.is_address<EOL>if inspect.ismodule(modfunc):<EOL><INDENT>if hasattr(modfunc, '<STR_LIT>'):<EOL><INDENT>filename = pyficache.pyc2py(modfunc.__file__)<EOL>filename = proc.core.canonic(filename)<EOL>if not offset:<EOL><INDENT>offset = <NUM_LIT:0><EOL>is_address = True<EOL><DEDENT>return Location(filename, offset, is_address, modfunc)<EOL><DEDENT>else:<EOL><INDENT>msg = ("<STR_LIT>" %<EOL>location.path)<EOL><DEDENT><DEDENT>proc.errmsg(msg)<EOL>return INVALID_LOCATION<EOL><DEDENT>maxline = pyficache.maxline(filename)<EOL>if maxline and offset > maxline:<EOL><INDENT>proc.errmsg("<STR_LIT>"<EOL>% (offset, filename, maxline))<EOL>return INVALID_LOCATION<EOL><DEDENT><DEDENT>elif location.line_number is not None:<EOL><INDENT>filename   = Mstack.frame2file(proc.core, curframe, canonic=False)<EOL>offset     = location.line_number<EOL>is_address = location.is_address<EOL>modfunc    = proc.list_object<EOL><DEDENT>return Location(filename, offset, is_address, modfunc)<EOL>


if len(args) <= <NUM_LIT:1>:<EOL><INDENT>step_ignore = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>step_ignore = self.proc.get_int(args[<NUM_LIT:1>], default=<NUM_LIT:1>,<EOL>cmdname='<STR_LIT>')<EOL>if step_ignore is None: return False<EOL>step_ignore -= <NUM_LIT:1><EOL>pass<EOL><DEDENT>self.core.different_line   =Mcmdfns.want_different_line(args[<NUM_LIT:0>],<EOL>self.debugger.settings['<STR_LIT>'])<EOL>self.core.set_next(self.proc.frame, step_ignore)<EOL>self.proc.continue_running = True   <EOL>return True<EOL>

**next**[**+**|**-**] [*count*]

Step one statement ignoring steps into function calls at this level.

With an integer argument, perform `next` that many times. However if
an exception occurs at this level, or we *return*, *yield* or the
thread changes, we stop regardless of count.

A suffix of `+` on the command or an alias to the command forces to
move to another line, while a suffix of `-` does the opposite and
disables the requiring a move to a new line. If no suffix is given,
the debugger setting 'different-line' determines this behavior.

See also:
---------

`step`, `skip`, `jump` (there's no `hop` yet), `continue`, and
`finish` for other ways to progress execution.


Mframe.adjust_relative(self.proc, self.name, args, self.signum)<EOL>return False<EOL>

**up** [*count*]

Move the current frame up in the stack trace (to an older frame). 0 is
the most recent frame. If no count is given, move up 1.

See also:
---------

`down` and `frame`.


Mbase_cmd.DebuggerCommand.__init__(self, proc)<EOL>if name is None: name  = self.__module__.split('<STR_LIT:.>')[-<NUM_LIT:1>]<EOL>self.__class__.name = name<EOL>self.cmds = Msubcmd.Subcmd(name, self)<EOL>self.name = name<EOL>self._load_debugger_subcommands(name)<EOL>self.proc = proc<EOL>return<EOL>

Initialize show subcommands. Note: instance variable name
        has to be setcmds ('set' + 'cmds') for subcommand completion
        to work.


<EOL>cmd_instances     = []<EOL>class_prefix      = capitalize(name)  <EOL>module_dir        = '<STR_LIT>' % name<EOL>mod               = __import__(module_dir, None, None, ['<STR_LIT:*>'])<EOL>eval_cmd_template = '<STR_LIT>'<EOL>for module_name in mod.__modules__:<EOL><INDENT>import_name = module_dir + '<STR_LIT:.>' + module_name<EOL>try:<EOL><INDENT>command_mod = importlib.import_module(import_name)<EOL><DEDENT>except ImportError:<EOL><INDENT>print(("<STR_LIT>" %<EOL>(import_name, module_name, sys.exc_info()[<NUM_LIT:0>])))<EOL>continue<EOL><DEDENT>classnames = [ classname for classname, classvalue in<EOL>inspect.getmembers(command_mod, inspect.isclass)<EOL>if ('<STR_LIT>' != classname and<EOL>classname.startswith(class_prefix)) ]<EOL>for classname in classnames:<EOL><INDENT>eval_cmd = eval_cmd_template % classname<EOL>try:<EOL><INDENT>instance = eval(eval_cmd)<EOL>self.cmds.add(instance)<EOL><DEDENT>except:<EOL><INDENT>print("<STR_LIT>" % classname)<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>return cmd_instances<EOL>

Create an instance of each of the debugger
        subcommands. Commands are found by importing files in the
        directory 'name' + 'sub'. Some files are excluded via an array set
        in __init__.  For each of the remaining files, we import them
        and scan for class names inside those files and for each class
        name, we will create an instance of that class. The set of
        DebuggerCommand class instances form set of possible debugger
        commands.


if len(args) <= <NUM_LIT:2>:<EOL><INDENT>doc = self.__doc__ or self.run.__doc__<EOL>if doc:<EOL><INDENT>self.rst_msg(doc.rstrip('<STR_LIT:\n>'))<EOL><DEDENT>else:<EOL><INDENT>self.proc.intf[-<NUM_LIT:1>].errmsg('<STR_LIT>' +<EOL>'<STR_LIT>' +<EOL>self.name)<EOL>pass<EOL><DEDENT>return<EOL><DEDENT>subcmd_name = args[<NUM_LIT:2>]<EOL>if '<STR_LIT:*>' == subcmd_name:<EOL><INDENT>self.section("<STR_LIT>" % self.name)<EOL>self.msg(self.columnize_commands(self.cmds.list()))<EOL>return<EOL><DEDENT>cmd = self.cmds.lookup(subcmd_name)<EOL>if cmd:<EOL><INDENT>doc = cmd.__doc__ or cmd.run.__doc__<EOL>if doc:<EOL><INDENT>self.proc.rst_msg(doc.rstrip('<STR_LIT:\n>'))<EOL><DEDENT>else:<EOL><INDENT>self.proc.intf[-<NUM_LIT:1>].errmsg('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(subcmd_name, self.name))<EOL>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>cmds = [c for c in self.cmds.list()<EOL>if re.match('<STR_LIT>' + subcmd_name, c) ]<EOL>if cmds == []:<EOL><INDENT>self.errmsg("<STR_LIT>"<EOL>"<STR_LIT>" % (self.name, subcmd_name))<EOL><DEDENT>else:<EOL><INDENT>self.section("<STR_LIT>" %<EOL>(self.name, subcmd_name,))<EOL>self.msg_nocr(self.columnize_commands(cmds))<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>return<EOL>

Give help for a command which has subcommands. This can be
        called in several ways:
            help cmd
            help cmd subcmd
            help cmd commands

        Our shtick is to give help for the overall command only if
        subcommand or 'commands' is not given. If a subcommand is given and
        found, then specific help for that is given. If 'commands' is given
        we will list the all the subcommands.


if len(args) < <NUM_LIT:2>:<EOL><INDENT>self.section("<STR_LIT>"<EOL>"<STR_LIT>" % self.name)<EOL>for subcmd_name in self.cmds.list():<EOL><INDENT>subcmd = self.cmds.subcmds[subcmd_name]<EOL>self.summary_help(subcmd_name, subcmd)<EOL>pass<EOL><DEDENT>return False<EOL><DEDENT>subcmd_prefix = args[<NUM_LIT:1>]<EOL>subcmd = self.cmds.lookup(subcmd_prefix)<EOL>if subcmd:<EOL><INDENT>nargs = len(args) - <NUM_LIT:2><EOL>if nargs < subcmd.min_args:<EOL><INDENT>self.errmsg(("<STR_LIT>" +<EOL>"<STR_LIT>") %<EOL>(self.name, subcmd.name, subcmd.min_args, nargs))<EOL>return False<EOL><DEDENT>if subcmd.max_args is not None and nargs > subcmd.max_args:<EOL><INDENT>self.errmsg(("<STR_LIT>" +<EOL>"<STR_LIT>") %<EOL>(self.name, subcmd.name, subcmd.max_args, nargs))<EOL>return False<EOL><DEDENT>return subcmd.run(args[<NUM_LIT:2>:])<EOL><DEDENT>else:<EOL><INDENT>return self.undefined_subcmd(self.name, subcmd_prefix)<EOL><DEDENT>return<EOL>

Ooops -- the debugger author didn't redefine this run docstring.


def undefined_subcmd(self, cmd, subcmd):

self.proc.intf[-<NUM_LIT:1>].errmsg(('<STR_LIT>' +<EOL>'<STR_LIT>') % (cmd, subcmd, cmd))<EOL>return<EOL>

Error message when subcommand asked for but doesn't exist


**down** [*count*]

Move the current frame down in the stack trace (to a newer frame). 0
is the most recent frame. If no count is given, move down 1.

See also:
---------

`up` and `frame`.


self.proc = proc<EOL>self.core     = proc.core<EOL>self.debugger = proc.debugger<EOL>self.settings = self.debugger.settings<EOL>return<EOL>

proc contains the command processor object that this
        command is invoked through.  A debugger field gives access to
        the stack frame and I/O.


commands.sort()<EOL>width = self.debugger.settings['<STR_LIT:width>']<EOL>return columnize.columnize(commands, displaywidth=width,<EOL>lineprefix='<STR_LIT:U+0020>')<EOL>

List commands arranged in an aligned columns


return self.debugger.intf[-<NUM_LIT:1>].confirm(msg, default)<EOL>

Convenience short-hand for self.debugger.intf[-1].confirm


try:<EOL><INDENT>return(self.debugger.intf[-<NUM_LIT:1>].errmsg(msg))<EOL><DEDENT>except EOFError:<EOL><INDENT>pass<EOL><DEDENT>return None<EOL>

Convenience short-hand for self.debugger.intf[-1].errmsg


try:<EOL><INDENT>return(self.debugger.intf[-<NUM_LIT:1>].msg(msg))<EOL><DEDENT>except EOFError:<EOL><INDENT>pass<EOL><DEDENT>return None<EOL>

Convenience short-hand for self.debugger.intf[-1].msg


try:<EOL><INDENT>return(self.debugger.intf[-<NUM_LIT:1>].msg_nocr(msg))<EOL><DEDENT>except EOFError:<EOL><INDENT>pass<EOL><DEDENT>return None<EOL>

Convenience short-hand for self.debugger.intf[-1].msg_nocr


text = Mformat.rst_text(text,<EOL>'<STR_LIT>' == self.debugger.settings['<STR_LIT>'],<EOL>self.debugger.settings['<STR_LIT:width>'])<EOL>return self.msg(text)<EOL>

Convert ReStructuredText and run through msg()


raise NotImplementedError(NotImplementedMessage)<EOL>

The method that implements the debugger command.
        Help on the command comes from the docstring of this method.


while f:<EOL><INDENT>if (not self.core.ignore_filter.is_included(f)<EOL>or self.settings['<STR_LIT>']):<EOL><INDENT>s = Mstack.format_stack_entry(self, (f, f.f_lineno))<EOL>self.msg("<STR_LIT:U+0020>"*<NUM_LIT:4> + s)<EOL>pass<EOL><DEDENT>f = f.f_back<EOL>pass<EOL><DEDENT>return<EOL>


if len(args) == <NUM_LIT:0>:<EOL><INDENT>if not self.proc.curframe:<EOL><INDENT>self.errmsg("<STR_LIT>")<EOL>return False<EOL><DEDENT>filename = self.proc.curframe.f_code.co_filename<EOL><DEDENT>else:<EOL><INDENT>filename = args[<NUM_LIT:0>]<EOL>pass<EOL><DEDENT>m = filename + '<STR_LIT>'<EOL>filename_cache = self.core.filename_cache<EOL>if filename in filename_cache:<EOL><INDENT>m += "<STR_LIT>"<EOL>if filename_cache[filename] != filename:<EOL><INDENT>m += '<STR_LIT>'<EOL>m = Mmisc.wrapped_lines(m, filename_cache[filename] + '<STR_LIT:.>',<EOL>self.settings['<STR_LIT:width>'])<EOL><DEDENT>else:<EOL><INDENT>m += '<STR_LIT:.>'<EOL>pass<EOL><DEDENT>self.msg(m)<EOL><DEDENT>else:<EOL><INDENT>matches = [file for file in file_list() if<EOL>file.endswith(filename)]<EOL>if (len(matches) > <NUM_LIT:1>):<EOL><INDENT>self.msg("<STR_LIT>")<EOL>for match_file in matches:<EOL><INDENT>self.msg("<STR_LIT>" % match_file)<EOL>pass<EOL><DEDENT><DEDENT>elif len(matches) == <NUM_LIT:1>:<EOL><INDENT>canonic_name = pyficache.unmap_file(matches[<NUM_LIT:0>])<EOL>m += "<STR_LIT>"  + canonic_name<EOL>self.msg(m)<EOL><DEDENT>else:<EOL><INDENT>self.msg(m + '<STR_LIT>')<EOL><DEDENT>pass<EOL><DEDENT>canonic_name = self.core.canonic(filename)<EOL>self.msg(Mmisc.wrapped_lines('<STR_LIT>', canonic_name,<EOL>self.settings['<STR_LIT:width>']))<EOL>for name in (canonic_name, filename):<EOL><INDENT>if name in sys.modules:<EOL><INDENT>for key in [k for k, v in list(sys.modules.items())<EOL>if name == v]:<EOL><INDENT>self.msg("<STR_LIT>", key)<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>for arg in args[<NUM_LIT:1>:]:<EOL><INDENT>processed_arg = False<EOL>if arg in ['<STR_LIT:all>', '<STR_LIT:size>']:<EOL><INDENT>if pyficache.size(canonic_name):<EOL><INDENT>self.msg("<STR_LIT>" %<EOL>pyficache.size(canonic_name))<EOL>pass<EOL><DEDENT>processed_arg = True<EOL>pass<EOL><DEDENT>if arg in ['<STR_LIT:all>', '<STR_LIT>']:<EOL><INDENT>self.msg("<STR_LIT>" % pyficache.sha1(canonic_name))<EOL>processed_arg = True<EOL>pass<EOL><DEDENT>if arg in ['<STR_LIT:all>', '<STR_LIT>']:<EOL><INDENT>lines = pyficache.trace_line_numbers(canonic_name)<EOL>if lines:<EOL><INDENT>self.section("<STR_LIT>")<EOL>fmt_lines = columnize.columnize(lines, ljust = False,<EOL>arrange_vertical = False,<EOL>lineprefix='<STR_LIT:U+0020>')<EOL>self.msg(fmt_lines)<EOL>pass<EOL><DEDENT>processed_arg = True<EOL>pass<EOL><DEDENT>if not processed_arg:<EOL><INDENT>self.errmsg("<STR_LIT>" % arg)<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>return<EOL>


mainfile = self.core.filename(None)<EOL>if self.core.is_running():<EOL><INDENT>if mainfile:<EOL><INDENT>part1 = "<STR_LIT>" % mainfile<EOL><DEDENT>else:<EOL><INDENT>part1 = '<STR_LIT>'<EOL>pass<EOL><DEDENT>if self.proc.event:<EOL><INDENT>msg = '<STR_LIT>' % self.proc.event<EOL><DEDENT>else:<EOL><INDENT>msg = '<STR_LIT:.>'<EOL><DEDENT>self.msg(Mmisc.wrapped_lines(part1, msg,<EOL>self.settings['<STR_LIT:width>']))<EOL>if self.proc.curframe:<EOL><INDENT>self.msg("<STR_LIT>" % self.proc.curframe.f_lasti)<EOL><DEDENT>if self.proc.event == '<STR_LIT>':<EOL><INDENT>val = self.proc.event_arg<EOL>part1 = '<STR_LIT>'<EOL>self.msg(Mmisc.wrapped_lines(part1, self.proc._saferepr(val),<EOL>self.settings['<STR_LIT:width>']))<EOL>pass<EOL><DEDENT>elif self.proc.event == '<STR_LIT>':<EOL><INDENT>exc_type, exc_value, exc_tb = self.proc.event_arg<EOL>self.msg('<STR_LIT>' %<EOL>self.proc._saferepr(exc_type))<EOL>if exc_value:<EOL><INDENT>self.msg('<STR_LIT>' %<EOL>self.proc._saferepr(exc_value))<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>self.msg('<STR_LIT>' % self.core.stop_reason)<EOL>if self.proc.event in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>self.msg('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if mainfile:<EOL><INDENT>part1 = "<STR_LIT>" % mainfile<EOL>msg   = "<STR_LIT>"<EOL>self.msg(Mmisc.wrapped_lines(part1, msg,<EOL>self.settings['<STR_LIT:width>']))<EOL><DEDENT>else:<EOL><INDENT>self.msg('<STR_LIT>')<EOL>pass<EOL><DEDENT>self.msg(self.core.execution_status)<EOL>pass<EOL><DEDENT>return False<EOL>


mainfile = self.core.filename(None)<EOL>if self.core.is_running():<EOL><INDENT>curframe = self.proc.curframe<EOL>if curframe:<EOL><INDENT>line_no = inspect.getlineno(curframe)<EOL>offset  = curframe.f_lasti<EOL>self.msg("<STR_LIT>" % offset)<EOL>offset = max(offset, <NUM_LIT:0>)<EOL>code = curframe.f_code<EOL>co_code = code.co_code<EOL>disassemble_bytes(self.msg, self.msg_nocr,<EOL>co_code, offset, line_no, line_no-<NUM_LIT:1>, line_no+<NUM_LIT:1>,<EOL>constants=code.co_consts, cells=code.co_cellvars,<EOL>varnames=code.co_varnames, freevars=code.co_freevars,<EOL>linestarts=dict(findlinestarts(code)),<EOL>end_offset=offset+<NUM_LIT:10>)<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if mainfile:<EOL><INDENT>part1 = "<STR_LIT>" % mainfile<EOL>msg   = "<STR_LIT>"<EOL>self.msg(Mmisc.wrapped_lines(part1, msg,<EOL>self.settings['<STR_LIT:width>']))<EOL><DEDENT>else:<EOL><INDENT>self.msg('<STR_LIT>')<EOL>pass<EOL><DEDENT>self.msg(self.core.execution_status)<EOL>pass<EOL><DEDENT>return False<EOL>


<EOL>if not self.proc.curframe:<EOL><INDENT>self.errmsg("<STR_LIT>")<EOL>return<EOL><DEDENT>if len(args) == <NUM_LIT:3>:<EOL><INDENT>answer = self.lineinfo(args[<NUM_LIT:2>])<EOL>if answer[<NUM_LIT:0>]:<EOL><INDENT>item, filename, lineno = answer<EOL>if not os.path.isfile(filename):<EOL><INDENT>filename = Mclifns.search_file(filename,<EOL>self.core.search_path,<EOL>self.main_dirname)<EOL><DEDENT>self.msg('<STR_LIT>' %<EOL>(lineno, filename, item))<EOL><DEDENT>return<EOL><DEDENT>filename=self.core.canonic_filename(self.proc.curframe)<EOL>if not os.path.isfile(filename):<EOL><INDENT>filename = Mclifns.search_file(filename, self.core.search_path,<EOL>self.main_dirname)<EOL>pass<EOL><DEDENT>filename = self.core.canonic_filename(self.proc.curframe)<EOL>msg1 = '<STR_LIT>'  % (inspect.getlineno(self.proc.curframe),<EOL>self.core.filename(filename))<EOL>msg2 = ('<STR_LIT>' % self.proc.curframe.f_lasti)<EOL>if self.proc.event:<EOL><INDENT>msg2 += '<STR_LIT>' % self.proc.event<EOL>pass<EOL><DEDENT>self.msg(Mmisc.wrapped_lines(msg1, msg2, self.settings['<STR_LIT:width>']))<EOL>return False<EOL>


caller = sys._getframe(<NUM_LIT:2>)<EOL>filename = caller.f_code.co_filename<EOL>filename = os.path.normcase(os.path.basename(filename))<EOL>return os.path.splitext(filename)[<NUM_LIT:0>]<EOL>

Get the name caller's caller.
    NB: f_code.co_filenames and thus this code kind of broken for
    zip'ed eggs circa Jan 2009


self.section("<STR_LIT>")<EOL>cats = list(categories.keys())<EOL>cats.sort()<EOL>for cat in cats:  <EOL><INDENT>self.msg("<STR_LIT>" % (cat, categories[cat]))<EOL>pass<EOL><DEDENT>final_msg =

List the command categories and a short description of each.


def show_category(self, category, args):

n2cmd = self.proc.commands<EOL>names = list(n2cmd.keys())<EOL>if len(args) == <NUM_LIT:1> and args[<NUM_LIT:0>] == '<STR_LIT:*>':<EOL><INDENT>self.section("<STR_LIT>" % category)<EOL>cmds = [cmd for cmd in names if category == n2cmd[cmd].category]<EOL>cmds.sort()<EOL>self.msg_nocr(self.columnize_commands(cmds))<EOL>return<EOL><DEDENT>self.msg("<STR_LIT>" % categories[category])<EOL>self.section("<STR_LIT>")<EOL>names.sort()<EOL>for name in names:  <EOL><INDENT>if category != n2cmd[name].category: continue<EOL>self.msg("<STR_LIT>" % (name, n2cmd[name].short_help,))<EOL>pass<EOL><DEDENT>return<EOL>

Show short help for all commands in `category'.


self.debugger.core.stop()<EOL>self.debugger.core.execution_status = '<STR_LIT>'<EOL>raise Mexcept.DebuggerQuit<EOL>

quit command when there's just one thread.


threading_list = threading.enumerate()<EOL>mythread =  threading.currentThread()<EOL>for t in threading_list:<EOL><INDENT>if t != mythread:<EOL><INDENT>ctype_async_raise(t, Mexcept.DebuggerQuit)<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>raise Mexcept.DebuggerQuit<EOL>

quit command when several threads are involved.


def find_and_set_debugged_frame(self, frame, thread_id):

thread = threading._active[thread_id]<EOL>thread_name = thread.getName()<EOL>if (not self.settings['<STR_LIT>'] and<EOL>thread_name == Mthread.current_thread_name()):<EOL><INDENT>newframe = Mthread.find_debugged_frame(frame)<EOL>if newframe is not None:  frame = newframe<EOL>pass<EOL><DEDENT>self.stack, self.curindex = Mcmdproc.get_stack(frame, None,<EOL>self.proc)<EOL>self.proc.stack, self.proc.curindex = self.stack, self.curindex<EOL>self.proc.frame_thread_name = thread_name<EOL>return<EOL>

The dance we have to do to set debugger frame state to
        *frame*, which is in the thread with id *thread_id*. We may
        need to the hide initial debugger frames.


frame_num = self.proc.get_an_int(position_str,<EOL>("<STR_LIT>" +<EOL>"<STR_LIT>") %<EOL>position_str)<EOL>if frame_num is None: return False<EOL>i_stack = len(self.proc.stack)<EOL>if i_stack == <NUM_LIT:0>:<EOL><INDENT>self.errmsg('<STR_LIT>')<EOL>return False<EOL><DEDENT>if frame_num < -i_stack or frame_num > i_stack-<NUM_LIT:1>:<EOL><INDENT>self.errmsg(('<STR_LIT>' +<EOL>'<STR_LIT>') % (-i_stack, i_stack-<NUM_LIT:1>,<EOL>frame_num, position_str))<EOL>return False<EOL><DEDENT>else:<EOL><INDENT>Mframe.adjust_frame(self.proc, '<STR_LIT>', pos=frame_num,<EOL>absolute_pos=True)<EOL>return True<EOL><DEDENT>return<EOL>

The simple case: thread frame switching has been done or is
        not needed and we have an explicit position number as a string


def get_from_thread_name_or_id(self, name_or_id, report_error=True):

thread_id = self.proc.get_int_noerr(name_or_id)<EOL>if thread_id is None:<EOL><INDENT>name2id = Mthread.map_thread_names()<EOL>if name_or_id == '<STR_LIT:.>':<EOL><INDENT>name_or_id = Mthread.current_thread_name()<EOL>pass<EOL><DEDENT>thread_id = name2id.get(name_or_id)<EOL>if thread_id is None:<EOL><INDENT>self.errmsg("<STR_LIT>" %<EOL>name_or_id)<EOL>return None, None<EOL><DEDENT>pass<EOL><DEDENT>threads   = sys._current_frames()<EOL>frame     = threads.get(thread_id)<EOL>if frame is None and report_error:<EOL><INDENT>self.errmsg("<STR_LIT>" %<EOL>name_or_id, thread_id)<EOL>return None, None<EOL><DEDENT>return frame, thread_id<EOL>

See if *name_or_id* is either a thread name or a thread id.
        The frame of that id/name is returned, or None if name_or_id is
        invalid.


if len(args) == <NUM_LIT:1>:<EOL><INDENT>position_str = '<STR_LIT:0>'<EOL><DEDENT>elif len(args) == <NUM_LIT:2>:<EOL><INDENT>name_or_id = args[<NUM_LIT:1>]<EOL>frame, thread_id = self.get_from_thread_name_or_id(name_or_id,<EOL>False)<EOL>if frame is None:<EOL><INDENT>position_str = name_or_id<EOL><DEDENT>else:<EOL><INDENT>position_str = '<STR_LIT:0>'<EOL>self.find_and_set_debugged_frame(frame, thread_id)<EOL>pass<EOL><DEDENT><DEDENT>elif len(args) == <NUM_LIT:3>:<EOL><INDENT>name_or_id = args[<NUM_LIT:1>]<EOL>position_str = args[<NUM_LIT:2>]<EOL>frame, thread_id = self.get_from_thread_name_or_id(name_or_id)<EOL>if frame is None:<EOL><INDENT>return<EOL><DEDENT>self.find_and_set_debugged_frame(frame, thread_id)<EOL>pass<EOL><DEDENT>self.one_arg_run(position_str)<EOL>return False<EOL>

Run a frame command. This routine is a little complex
        because we allow a number parameter variations.


self.cmd = cmd<EOL>self.proc     = cmd.proc<EOL>self.core     = cmd.core<EOL>self.debugger = cmd.debugger<EOL>self.settings = cmd.debugger.settings<EOL>if not hasattr(self, '<STR_LIT>'):<EOL><INDENT>help = self.__doc__.split("<STR_LIT:\n>")<EOL>if len(help) > <NUM_LIT:0>:<EOL><INDENT>if help[<NUM_LIT:0>][<NUM_LIT:0>] == '<STR_LIT:*>' and len(help) > <NUM_LIT:2>:<EOL><INDENT>self.short_help = help[<NUM_LIT:2>]<EOL><DEDENT>else:<EOL><INDENT>self.short_help = help[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>pass<EOL><DEDENT>self.name  = self.__module__.split('<STR_LIT:.>')[-<NUM_LIT:1>]<EOL>return<EOL>

cmd contains the command object that this
        command is invoked through.  A debugger field gives access to
        the stack frame and I/O.


commands.sort()<EOL>width = self.debugger.settings['<STR_LIT:width>']<EOL>return columnize.columnize(commands, displaywidth=width,<EOL>lineprefix='<STR_LIT:U+0020>')<EOL>

List commands arranged in an aligned columns


return(self.debugger.intf[-<NUM_LIT:1>].confirm(msg, default))<EOL>

Convenience short-hand for self.debugger.intf.confirm


return(self.debugger.intf[-<NUM_LIT:1>].errmsg(msg))<EOL>

Convenience short-hand for self.debugger.intf[-1].errmsg


return(self.debugger.intf[-<NUM_LIT:1>].msg(msg))<EOL>

Convenience short-hand for self.debugger.intf[-1].msg


return(self.debugger.intf[-<NUM_LIT:1>].msg_nocr(msg))<EOL>

Convenience short-hand for self.debugger.intf[-1].msg_nocr


Convenience short-hand for self.proc.rst_msg(text)


raise NotImplementedError(NotImplementedMessage)<EOL>

The method that implements the debugger command.
        Help on the command comes from the docstring of this method.


def interact(banner=None, readfunc=None, my_locals=None, my_globals=None):

console = code.InteractiveConsole(my_locals, filename='<STR_LIT>')<EOL>console.runcode = lambda code_obj: runcode(console, code_obj)<EOL>setattr(console, '<STR_LIT>', my_globals)<EOL>if readfunc is not None:<EOL><INDENT>console.raw_input = readfunc<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>import readline<EOL><DEDENT>except ImportError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>console.interact(banner)<EOL>pass<EOL>

Almost a copy of code.interact
    Closely emulate the interactive Python interpreter.

    This is a backwards compatible interface to the InteractiveConsole
    class.  When readfunc is not specified, it attempts to import the
    readline module to enable GNU readline if it is available.

    Arguments (all optional, all default to None):

    banner -- passed to InteractiveConsole.interact()
    readfunc -- if not None, replaces InteractiveConsole.raw_input()
    local -- passed to InteractiveInterpreter.__init__()


Execute a code object.

    When an exception occurs, self.showtraceback() is called to
    display a traceback.  All exceptions are caught except
    SystemExit, which is reraised.

    A note about KeyboardInterrupt: this exception may occur
    elsewhere in this code, and may not always be caught.  The
    caller should be prepared to deal with it.


self.proc.cmd_queue.append(string)<EOL>self.proc.process_command()<EOL>return<EOL>

Invoke a debugger command from inside a IPython shell called
        inside the debugger.


print('<STR_LIT>')<EOL>self.proc.cmd_queue.append(string)<EOL>self.proc.process_command()<EOL>return<EOL>

Invoke a debugger command from inside a python shell called inside
        the debugger.


debug = not sys.flags.optimize if debug_override is None else debug_override<EOL>if debug:<EOL><INDENT>suffixes = DEBUG_BYTECODE_SUFFIXES<EOL><DEDENT>else:<EOL><INDENT>suffixes = OPTIMIZED_BYTECODE_SUFFIXES<EOL>pass<EOL><DEDENT>head, tail = os.path.split(path)<EOL>base_filename, sep, _ = tail.partition('<STR_LIT:.>')<EOL>if not hasattr(sys, '<STR_LIT>'):<EOL><INDENT>raise NotImplementedError('<STR_LIT>')<EOL><DEDENT>tag = sys.implementation.cache_tag<EOL>if tag is None:<EOL><INDENT>raise NotImplementedError('<STR_LIT>')<EOL><DEDENT>filename = '<STR_LIT>'.join([base_filename, sep, tag, suffixes[<NUM_LIT:0>]])<EOL>return os.path.join(head, _PYCACHE, filename)<EOL>

Given the path to a .py file, return the path to its .pyc/.pyo file.

    The .py file does not need to exist; this simply returns the path to the
    .pyc/.pyo file calculated as if the .py file were imported.  The extension
    will be .pyc unless sys.flags.optimize is non-zero, then it will be .pyo.

    If debug_override is not None, then it must be a boolean and is used in
    place of sys.flags.optimize.

    If sys.implementation.cache_tag is None then NotImplementedError is raised.


caller = sys._getframe(<NUM_LIT:2>)<EOL>filename = caller.f_code.co_filename<EOL>filename = os.path.normcase(os.path.basename(filename))<EOL>return os.path.splitext(filename)[<NUM_LIT:0>]<EOL>

Get the name caller's caller.
    NB: f_code.co_filenames and thus this code kind of broken for
    zip'ed eggs circa Jan 2009


def console_runcode(code_obj):<EOL><INDENT>runcode(console, code_obj)<EOL><DEDENT>console = code.InteractiveConsole(my_locals, filename='<STR_LIT>')<EOL>console.runcode = console_runcode<EOL>setattr(console, '<STR_LIT>', my_globals)<EOL>if readfunc is not None:<EOL><INDENT>console.raw_input = readfunc<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>import readline<EOL><DEDENT>except ImportError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>console.interact(banner)<EOL>pass<EOL>


try:<EOL><INDENT>exec(code_obj, obj.locals, obj.globals)<EOL><DEDENT>except SystemExit:<EOL><INDENT>raise<EOL><DEDENT>except:<EOL><INDENT>info = sys.exc_info()<EOL>print("<STR_LIT>" % (info[<NUM_LIT:0>], info[<NUM_LIT:1>]))<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>return<EOL>


def event_processor(self, frame, event, arg):

out = self.debugger.intf[-<NUM_LIT:1>].output<EOL>lineno = frame.f_lineno<EOL>filename = self.core.canonic_filename(frame)<EOL>filename = self.core.filename(filename)<EOL>if not out:<EOL><INDENT>print("<STR_LIT>" % (event, filename, lineno))<EOL><DEDENT>else:<EOL><INDENT>out.write("<STR_LIT>" % (event, filename, lineno))<EOL>if arg is not None:<EOL><INDENT>out.writeline('<STR_LIT>' % repr(arg))<EOL><DEDENT>else:<EOL><INDENT>out.writeline('<STR_LIT>')<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>return self.event_processor<EOL>

A simple event processor that prints out events.


def complete_token_filtered(aliases, prefix, expanded):

complete_ary = list(aliases.keys())<EOL>results = [cmd for cmd in<EOL>complete_ary if cmd.startswith(prefix)] and not (<EOL>cmd in aliases and expanded not in aliases[cmd])<EOL>return sorted(results, key=lambda pair: pair[<NUM_LIT:0>])<EOL>

Find all starting matches in dictionary *aliases* that start
    with *prefix*, but filter out any matches already in
    *expanded*.


if not cmd.proc.curframe: return [None]<EOL>ns = cmd.proc.curframe.f_globals.copy()<EOL>ns.update(cmd.proc.curframe.f_locals)<EOL>if '<STR_LIT:.>' in prefix:<EOL><INDENT>dotted = prefix.split('<STR_LIT:.>')<EOL>try:<EOL><INDENT>obj = ns[dotted[<NUM_LIT:0>]]<EOL>for part in dotted[<NUM_LIT:1>:-<NUM_LIT:1>]:<EOL><INDENT>obj = getattr(obj, part)<EOL><DEDENT><DEDENT>except (KeyError, AttributeError):<EOL><INDENT>return []<EOL><DEDENT>pre_prefix = '<STR_LIT:.>'.join(dotted[:-<NUM_LIT:1>]) + '<STR_LIT:.>'<EOL>return [pre_prefix + n for n in dir(obj) if<EOL>n.startswith(dotted[-<NUM_LIT:1>])]<EOL><DEDENT>else:<EOL><INDENT>return Mcomplete.complete_token(ns.keys(), prefix)<EOL><DEDENT>


for subcmd_name in list(self.subcmds.keys()):<EOL><INDENT>if subcmd_name.startswith(subcmd_prefix)and len(subcmd_prefix) >=self.subcmds[subcmd_name].__class__.min_abbrev:<EOL><INDENT>return self.subcmds[subcmd_name]<EOL><DEDENT>pass<EOL><DEDENT>return None<EOL>


def short_help(self, subcmd_cb, subcmd_name, label=False):

entry = self.lookup(subcmd_name)<EOL>if entry:<EOL><INDENT>if label:<EOL><INDENT>prefix = entry.name<EOL><DEDENT>else:<EOL><INDENT>prefix = '<STR_LIT>'<EOL>pass<EOL><DEDENT>if hasattr(entry, '<STR_LIT>'):<EOL><INDENT>if prefix: prefix += '<STR_LIT>'<EOL>self.cmd_obj.msg(prefix + entry.short_help)<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>else:<EOL><INDENT>self.undefined_subcmd("<STR_LIT>", subcmd_name)<EOL>pass<EOL><DEDENT>return<EOL>


subcmd_name = subcmd_cb.name<EOL>self.subcmds[subcmd_name] = subcmd_cb<EOL>self.cmdlist.append(subcmd_name)<EOL>

Add subcmd to the available subcommands for this object.
        It will have the supplied docstring, and subcmd_cb will be called
        when we want to run the command. min_len is the minimum length
        allowed to abbreviate the command. in_list indicates with the
        show command will be run when giving a list of all sub commands
        of this object. Some commands have long output like "show commands"
        so we might not want to show that.


Run subcmd_name with args using obj for the environent


print(args)<EOL>subcmd_prefix = args[<NUM_LIT:0>]<EOL>if not subcmd_prefix or len(subcmd_prefix) == <NUM_LIT:0>:<EOL><INDENT>self.msg(self.doc)<EOL>self.msg(


self.cmd_obj.errmsg('<STR_LIT>' %<EOL>(cmd, subcmd,))<EOL>return<EOL>

Error message when a subcommand doesn't exist


args_list = [[]]<EOL>if isinstance(s, bytes):<EOL><INDENT>s = s.decode("<STR_LIT:utf-8>")<EOL><DEDENT>lex = shlex.shlex(s, posix=posix)<EOL>lex.whitespace_split = True<EOL>args = list(lex)<EOL>for arg in args:<EOL><INDENT>if '<STR_LIT>' == arg:<EOL><INDENT>args_list.append([])<EOL><DEDENT>else:<EOL><INDENT>args_list[-<NUM_LIT:1>].append(arg)<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>return args_list<EOL>

Split a command line's arguments in a shell-like manner returned
    as a list of lists. Use ';;' with white space to indicate separate
    commands.

    This is a modified version of the standard library's shlex.split()
    function, but with a default of posix=False for splitting, so that quotes
    in inputs are respected.


def get_stack(f, t, botframe, proc_obj=None):

exclude_frame = lambda f: False<EOL>if proc_obj:<EOL><INDENT>settings = proc_obj.debugger.settings<EOL>if not settings['<STR_LIT>']:<EOL><INDENT>exclude_frame = lambda f:proc_obj.core.ignore_filter.is_included(f)<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>stack = []<EOL>if t and t.tb_frame is f:<EOL><INDENT>t = t.tb_next<EOL><DEDENT>while f is not None:<EOL><INDENT>if exclude_frame(f): break  <EOL>stack.append((f, f.f_lineno))<EOL>f = f.f_back<EOL>pass<EOL><DEDENT>stack.reverse()<EOL>i = max(<NUM_LIT:0>, len(stack) - <NUM_LIT:1>)<EOL>while t is not None:<EOL><INDENT>stack.append((t.tb_frame, t.tb_lineno))<EOL>t = t.tb_next<EOL>pass<EOL><DEDENT>return stack, i<EOL>

Return a stack of frames which the debugger will use for in
    showing backtraces and in frame switching. As such various frame
    that are really around may be excluded unless we are debugging the
    sebugger. Also we will add traceback frame on top if that
    exists.


for hook in hooks:<EOL><INDENT>if hook(obj, *args): return True<EOL>pass<EOL><DEDENT>return False<EOL>


def print_source_line(msg, lineno, line, event_str=None):

<EOL>return msg('<STR_LIT>' % (event_str, lineno, line))<EOL>

Print out a source line of text , e.g. the second
    line in:
        (/tmp.py:2):  <module>
        L -- 2 import sys,os
        (trepan3k)

    We define this method
    specifically so it can be customized for such applications
    like ipython.


def print_source_location_info(print_fn, filename, lineno, fn_name=None,<EOL>f_lasti=None, remapped_file=None):

if remapped_file:<EOL><INDENT>mess = '<STR_LIT>' % (remapped_file, lineno, filename)<EOL><DEDENT>else:<EOL><INDENT>mess = '<STR_LIT>' % (filename, lineno)<EOL><DEDENT>if f_lasti and f_lasti != -<NUM_LIT:1>:<EOL><INDENT>mess += '<STR_LIT>' % f_lasti<EOL>pass<EOL><DEDENT>mess += '<STR_LIT>'<EOL>if fn_name and fn_name != '<STR_LIT:?>':<EOL><INDENT>mess += "<STR_LIT>" % fn_name<EOL>pass<EOL><DEDENT>print_fn(mess)<EOL>return<EOL>

Print out a source location , e.g. the first line in
    line in:
        (/tmp.py:2 @21):  <module>
        L -- 2 import sys,os
        (trepan3k)


i_stack = proc_obj.curindex<EOL>if i_stack is None or proc_obj.stack is None:<EOL><INDENT>return False<EOL><DEDENT>core_obj = proc_obj.core<EOL>dbgr_obj = proc_obj.debugger<EOL>intf_obj = dbgr_obj.intf[-<NUM_LIT:1>]<EOL>remapped_file = None<EOL>source_text = None<EOL>while i_stack >= <NUM_LIT:0>:<EOL><INDENT>frame_lineno = proc_obj.stack[i_stack]<EOL>i_stack -= <NUM_LIT:1><EOL>frame, lineno = frame_lineno<EOL><INDENT>if '<STR_LIT>' in frame.f_locals:<EOL><INDENT>if self.run == frame.f_locals['<STR_LIT>']:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>filename = Mstack.frame2file(core_obj, frame, canonic=False)<EOL>if '<STR_LIT>' == filename and dbgr_obj.eval_string:<EOL><INDENT>remapped_file = filename<EOL>filename = pyficache.unmap_file(filename)<EOL>if '<STR_LIT>' == filename:<EOL><INDENT>remapped = cmdfns.source_tempfile_remap('<STR_LIT>',<EOL>dbgr_obj.eval_string)<EOL>pyficache.remap_file(filename, remapped)<EOL>filename = remapped<EOL>lineno = pyficache.unmap_file_line(filename, lineno)<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>elif '<STR_LIT>' == filename:<EOL><INDENT>source_text = deparse_fn(frame.f_code)<EOL>filename = "<STR_LIT>" % source_text<EOL>pass<EOL><DEDENT>else:<EOL><INDENT>m = re.search('<STR_LIT>', filename)<EOL>if m and m.group(<NUM_LIT:1>) in pyficache.file2file_remap:<EOL><INDENT>remapped_file = pyficache.file2file_remap[m.group(<NUM_LIT:1>)]<EOL>pass<EOL><DEDENT>elif filename in pyficache.file2file_remap:<EOL><INDENT>remapped_file = pyficache.unmap_file(filename)<EOL>if remapped_file == filename:<EOL><INDENT>remapped_file = None<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>elif m and m.group(<NUM_LIT:1>) in sys.modules:<EOL><INDENT>remapped_file = m.group(<NUM_LIT:1>)<EOL>pyficache.remap_file(filename, remapped_file)<EOL><DEDENT>pass<EOL><DEDENT>opts = {<EOL>'<STR_LIT>' : proc_obj.settings('<STR_LIT>'),<EOL>'<STR_LIT>'           : proc_obj.settings('<STR_LIT>')<EOL>}<EOL>if '<STR_LIT>' in proc_obj.debugger.settings:<EOL><INDENT>opts['<STR_LIT>'] = proc_obj.settings('<STR_LIT>')<EOL><DEDENT>pyficache.update_cache(filename)<EOL>line = pyficache.getline(filename, lineno, opts)<EOL>if not line:<EOL><INDENT>if (not source_text and<EOL>filename.startswith("<STR_LIT>") and proc_obj.curframe.f_code):<EOL><INDENT>co = proc_obj.curframe.f_code<EOL>temp_filename, name_for_code = deparse_and_cache(co, proc_obj.errmsg)<EOL>lineno = <NUM_LIT:1><EOL>if temp_filename:<EOL><INDENT>filename = temp_filename<EOL><DEDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if source_text:<EOL><INDENT>lines = source_text.split("<STR_LIT:\n>")<EOL>temp_name='<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>lines = linecache.getlines(filename)<EOL>temp_name = filename<EOL><DEDENT>if lines:<EOL><INDENT>prefix = os.path.basename(temp_name).split('<STR_LIT:.>')[<NUM_LIT:0>]<EOL>fd = tempfile.NamedTemporaryFile(suffix='<STR_LIT>',<EOL>prefix=prefix,<EOL>delete=False)<EOL>with fd:<EOL><INDENT>fd.write('<STR_LIT>'.join(lines))<EOL>remapped_file = fd.name<EOL>pyficache.remap_file(remapped_file, filename)<EOL><DEDENT>fd.close()<EOL>pass<EOL><DEDENT><DEDENT>line = linecache.getline(filename, lineno,<EOL>proc_obj.curframe.f_globals)<EOL>if not line:<EOL><INDENT>m = re.search('<STR_LIT>', filename)<EOL>if m and m.group(<NUM_LIT:1>):<EOL><INDENT>remapped_file = m.group(<NUM_LIT:1>)<EOL>try_module = sys.modules.get(remapped_file)<EOL>if (try_module and inspect.ismodule(try_module) and<EOL>hasattr(try_module, '<STR_LIT>')):<EOL><INDENT>remapped_file = sys.modules[remapped_file].__file__<EOL>pyficache.remap_file(filename, remapped_file)<EOL>line = linecache.getline(remapped_file, lineno,<EOL>proc_obj.curframe.f_globals)<EOL><DEDENT>else:<EOL><INDENT>remapped_file = m.group(<NUM_LIT:1>)<EOL>code = proc_obj.curframe.f_code<EOL>filename, line = cmdfns.deparse_getline(code, remapped_file,<EOL>lineno, opts)<EOL><DEDENT>pass<EOL><DEDENT><DEDENT>pass<EOL><DEDENT>try:<EOL><INDENT>match, reason = Mstack.check_path_with_frame(frame, filename)<EOL>if not match:<EOL><INDENT>if filename not in warned_file_mismatches:<EOL><INDENT>proc_obj.errmsg(reason)<EOL>warned_file_mismatches.add(filename)<EOL><DEDENT><DEDENT><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>fn_name = frame.f_code.co_name<EOL>last_i  = frame.f_lasti<EOL>print_source_location_info(intf_obj.msg, filename, lineno, fn_name,<EOL>remapped_file = remapped_file,<EOL>f_lasti = last_i)<EOL>if line and len(line.strip()) != <NUM_LIT:0>:<EOL><INDENT>if proc_obj.event:<EOL><INDENT>print_source_line(intf_obj.msg, lineno, line,<EOL>proc_obj.event2short[proc_obj.event])<EOL><DEDENT>pass<EOL><DEDENT>if '<STR_LIT>' != filename: break<EOL>pass<EOL><DEDENT>if proc_obj.event in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>val = proc_obj.event_arg<EOL>intf_obj.msg('<STR_LIT>' % proc_obj._saferepr(val))<EOL>pass<EOL><DEDENT>return True<EOL>

Show where we are. GUI's and front-end interfaces often
    use this to update displays. So it is helpful to make sure
    we give at least some place that's located in a file.


filename = self.curframe.f_code.co_filename<EOL>if filename == '<STR_LIT>' and self.debugger.mainpyfile:<EOL><INDENT>filename = self.debugger.mainpyfile<EOL>pass<EOL><DEDENT>return filename<EOL>


def event_processor(self, frame, event, event_arg, prompt='<STR_LIT>'):

self.frame     = frame<EOL>self.event     = event<EOL>self.event_arg = event_arg<EOL>filename = frame.f_code.co_filename<EOL>lineno   = frame.f_lineno<EOL>line     = linecache.getline(filename, lineno, frame.f_globals)<EOL>if not line:<EOL><INDENT>opts = {'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': self.settings('<STR_LIT>'),<EOL>'<STR_LIT>': False}<EOL>m = re.search('<STR_LIT>', filename)<EOL>if m and m.group(<NUM_LIT:1>):<EOL><INDENT>filename = pyficache.unmap_file(m.group(<NUM_LIT:1>))<EOL><DEDENT>line = pyficache.getline(filename, lineno, opts)<EOL><DEDENT>self.current_source_text = line<EOL>if self.settings('<STR_LIT>') is not None:<EOL><INDENT>if Mbytecode.is_def_stmt(line, frame):<EOL><INDENT>return True<EOL><DEDENT>if Mbytecode.is_class_def(line, frame):<EOL><INDENT>return True<EOL><DEDENT>pass<EOL><DEDENT>self.thread_name = Mthread.current_thread_name()<EOL>self.frame_thread_name = self.thread_name<EOL>self.set_prompt(prompt)<EOL>self.process_commands()<EOL>if filename == '<STR_LIT>': pyficache.remove_remap_file('<STR_LIT>')<EOL>return True<EOL>

command event processor: reading a commands do something with them.


self.stack       = []<EOL>self.curindex    = <NUM_LIT:0><EOL>self.curframe    = None<EOL>self.thread_name = None<EOL>self.frame_thread_name = None<EOL>return<EOL>

Remove memory of state variables set in the command processor


try:<EOL><INDENT>return eval(arg, self.curframe.f_globals,<EOL>self.curframe.f_locals)<EOL><DEDENT>except:<EOL><INDENT>t, v = sys.exc_info()[:<NUM_LIT:2>]<EOL>if isinstance(t, str):<EOL><INDENT>exc_type_name = t<EOL>pass<EOL><DEDENT>else: exc_type_name = t.__name__<EOL>self.errmsg(str("<STR_LIT>" % (exc_type_name, arg)))<EOL>raise<EOL><DEDENT>return None<EOL>

Eval string arg in the current frame context.


def get_an_int(self, arg, msg_on_error, min_value=None, max_value=None):

ret_value = self.get_int_noerr(arg)<EOL>if ret_value is None:<EOL><INDENT>if msg_on_error:<EOL><INDENT>self.errmsg(msg_on_error)<EOL><DEDENT>else:<EOL><INDENT>self.errmsg('<STR_LIT>' % str(arg))<EOL>pass<EOL><DEDENT>return None<EOL><DEDENT>if min_value and ret_value < min_value:<EOL><INDENT>self.errmsg('<STR_LIT>' %<EOL>(min_value, ret_value))<EOL>return None<EOL><DEDENT>elif max_value and ret_value > max_value:<EOL><INDENT>self.errmsg('<STR_LIT>' %<EOL>(max_value, ret_value))<EOL>return None<EOL><DEDENT>return ret_value<EOL>

Like cmdfns.get_an_int(), but if there's a stack frame use that
        in evaluation.


if self.curframe:<EOL><INDENT>g = self.curframe.f_globals<EOL>l = self.curframe.f_locals<EOL><DEDENT>else:<EOL><INDENT>g = globals()<EOL>l = locals()<EOL>pass<EOL><DEDENT>try:<EOL><INDENT>val = int(eval(arg, g, l))<EOL><DEDENT>except (SyntaxError, NameError, ValueError, TypeError):<EOL><INDENT>return None<EOL><DEDENT>return val<EOL>

Eval arg and it is an integer return the value. Otherwise
        return None


def get_int(self, arg, min_value=<NUM_LIT:0>, default=<NUM_LIT:1>, cmdname=None,<EOL>at_most=None):

if arg is None: return default<EOL>default = self.get_int_noerr(arg)<EOL>if default is None:<EOL><INDENT>if cmdname:<EOL><INDENT>self.errmsg(("<STR_LIT>"<EOL>+ "<STR_LIT>") % (cmdname, str(arg)))<EOL><DEDENT>else:<EOL><INDENT>self.errmsg('<STR_LIT>'<EOL>% str(arg))<EOL>pass<EOL><DEDENT>return None<EOL>pass<EOL><DEDENT>if default < min_value:<EOL><INDENT>if cmdname:<EOL><INDENT>self.errmsg(("<STR_LIT>" +<EOL>'<STR_LIT>')<EOL>% (cmdname, min_value, default))<EOL><DEDENT>else:<EOL><INDENT>self.errmsg(("<STR_LIT>" +<EOL>'<STR_LIT>')<EOL>% (min_value, default))<EOL>pass<EOL><DEDENT>return None<EOL><DEDENT>elif at_most and default > at_most:<EOL><INDENT>if cmdname:<EOL><INDENT>self.errmsg(("<STR_LIT>" +<EOL>'<STR_LIT>')<EOL>% (cmdname, at_most, default))<EOL><DEDENT>else:<EOL><INDENT>self.errmsg(("<STR_LIT>")<EOL>% (at_most, default))<EOL>pass<EOL><DEDENT>pass<EOL><DEDENT>return default<EOL>

If no argument use the default. If arg is a an integer between
        least min_value and at_most, use that. Otherwise report an error.
        If there's a stack frame use that in evaluation.


def ok_for_running(self, cmd_obj, name, nargs):

if hasattr(cmd_obj, '<STR_LIT>'):<EOL><INDENT>if not (self.core.execution_status in cmd_obj.execution_set):<EOL><INDENT>part1 = ("<STR_LIT>"<EOL>% name)<EOL>mess = Mmisc.wrapped_lines(part1,<EOL>self.core.execution_status,<EOL>self.debugger.settings['<STR_LIT:width>'])<EOL>self.errmsg(mess)<EOL>return False<EOL><DEDENT>pass<EOL><DEDENT>if self.frame is None and cmd_obj.need_stack:<EOL><INDENT>self.intf[-<NUM_LIT:1>].errmsg("<STR_LIT>"<EOL>% name)<EOL>return False<EOL><DEDENT>if nargs < cmd_obj.min_args:<EOL><INDENT>self.errmsg(("<STR_LIT>" +<EOL>"<STR_LIT>") %<EOL>(name, cmd_obj.min_args, nargs))<EOL>return False<EOL><DEDENT>elif cmd_obj.max_args is not None and nargs > cmd_obj.max_args:<EOL><INDENT>self.errmsg(("<STR_LIT>" +<EOL>"<STR_LIT>") %<EOL>(name, cmd_obj.max_args, nargs))<EOL>return False<EOL><DEDENT>return True<EOL>

We separate some of the common debugger command checks here:
        whether it makes sense to run the command in this execution state,
        if the command has the right number of arguments and so on.


if self.core.execution_status != '<STR_LIT>':<EOL><INDENT>self.setup()<EOL>self.location()<EOL>pass<EOL><DEDENT>leave_loop = run_hooks(self, self.preloop_hooks)<EOL>self.continue_running = False<EOL>while not leave_loop:<EOL><INDENT>try:<EOL><INDENT>run_hooks(self, self.precmd_hooks)<EOL>leave_loop = self.process_command()<EOL>if leave_loop or self.continue_running: break<EOL><DEDENT>except EOFError:<EOL><INDENT>if len(self.debugger.intf) > <NUM_LIT:1>:<EOL><INDENT>del self.debugger.intf[-<NUM_LIT:1>]<EOL>self.last_command = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>if self.debugger.intf[-<NUM_LIT:1>].output:<EOL><INDENT>self.debugger.intf[-<NUM_LIT:1>].output.writeline('<STR_LIT>')<EOL>raise Mexcept.DebuggerQuit<EOL>pass<EOL><DEDENT>break<EOL><DEDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>return run_hooks(self, self.postcmd_hooks)<EOL>


self.forget()<EOL>if self.settings('<STR_LIT>'):<EOL><INDENT>self.frame = inspect.currentframe()<EOL>pass<EOL><DEDENT>if self.event in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>exc_type, exc_value, exc_traceback = self.event_arg<EOL><DEDENT>else:<EOL><INDENT>_, _, exc_traceback = (None, None, None,)  <EOL>pass<EOL><DEDENT>if self.frame or exc_traceback:<EOL><INDENT>self.stack, self.curindex =get_stack(self.frame, exc_traceback, None, self)<EOL>self.curframe = self.stack[self.curindex][<NUM_LIT:0>]<EOL>self.thread_name = Mthread.current_thread_name()<EOL>if exc_traceback:<EOL><INDENT>self.list_lineno = traceback.extract_tb(exc_traceback, <NUM_LIT:1>)[<NUM_LIT:0>][<NUM_LIT:1>]<EOL>self.list_offset = self.curframe.f_lasti<EOL>self.list_object = self.curframe<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.stack = self.curframe =self.botframe = None<EOL>pass<EOL><DEDENT>if self.curframe:<EOL><INDENT>self.list_lineno =max(<NUM_LIT:1>, inspect.getlineno(self.curframe)<EOL>- int(self.settings('<STR_LIT>') / <NUM_LIT:2>)) - <NUM_LIT:1><EOL>self.list_offset   = self.curframe.f_lasti<EOL>self.list_filename = self.curframe.f_code.co_filename<EOL>self.list_object   = self.curframe<EOL><DEDENT>else:<EOL><INDENT>if not exc_traceback: self.list_lineno = None<EOL>pass<EOL><DEDENT>return False<EOL>

Initialization done before entering the debugger-command
        loop. In particular we set up the call stack used for local
        variable lookup and frame/up/down commands.

        We return True if we should NOT enter the debugger-command
        loop.


expanded_cmdfile = os.path.expanduser(cmdfile)<EOL>is_readable = Mfile.readable(expanded_cmdfile)<EOL>if is_readable:<EOL><INDENT>self.cmd_queue.append('<STR_LIT>' + expanded_cmdfile)<EOL><DEDENT>elif is_readable is None:<EOL><INDENT>self.errmsg("<STR_LIT>" % expanded_cmdfile)<EOL><DEDENT>else:<EOL><INDENT>self.errmsg("<STR_LIT>" %<EOL>expanded_cmdfile)<EOL>pass<EOL><DEDENT>return<EOL>

Arrange for file of debugger commands to get read in the
        process-command loop.


self.errmsg('<STR_LIT>' % cmd)<EOL>return<EOL>

Error message when a command doesn't exist


histfile = self.debugger.intf[-<NUM_LIT:1>].histfile<EOL>try:<EOL><INDENT>import readline<EOL>readline.read_history_file(histfile)<EOL><DEDENT>except IOError:<EOL><INDENT>pass<EOL><DEDENT>except ImportError:<EOL><INDENT>pass<EOL><DEDENT>return<EOL>

Read the command history file -- possibly.


settings = self.debugger.settings<EOL>histfile = self.debugger.intf[-<NUM_LIT:1>].histfile<EOL>if settings['<STR_LIT>']:<EOL><INDENT>try:<EOL><INDENT>import readline<EOL>try:<EOL><INDENT>readline.write_history_file(histfile)<EOL><DEDENT>except IOError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>except ImportError:<EOL><INDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>return<EOL>

Write the command history file -- possibly.


from trepan.processor import command as Mcommand<EOL>if hasattr(Mcommand, '<STR_LIT>'):<EOL><INDENT>return self.populate_commands_easy_install(Mcommand)<EOL><DEDENT>else:<EOL><INDENT>return self.populate_commands_pip(Mcommand)<EOL><DEDENT>

Create an instance of each of the debugger
        commands. Commands are found by importing files in the
        directory 'command'. Some files are excluded via an array set
        in __init__.  For each of the remaining files, we import them
        and scan for class names inside those files and for each class
        name, we will create an instance of that class. The set of
        DebuggerCommand class instances form set of possible debugger
        commands.


self.commands = {}<EOL>self.aliases = {}<EOL>self.category = {}<EOL><INDENT>self.short_help = {}<EOL><DEDENT>for cmd_instance in self.cmd_instances:<EOL><INDENT>if not hasattr(cmd_instance, '<STR_LIT>'): continue<EOL>alias_names = cmd_instance.aliases<EOL>cmd_name = cmd_instance.name<EOL>self.commands[cmd_name] = cmd_instance<EOL>for alias_name in alias_names:<EOL><INDENT>self.aliases[alias_name] = cmd_name<EOL>pass<EOL><DEDENT>cat  = getattr(cmd_instance, '<STR_LIT>')<EOL>if cat and self.category.get(cat):<EOL><INDENT>self.category[cat].append(cmd_name)<EOL><DEDENT>else:<EOL><INDENT>self.category[cat] = [cmd_name]<EOL>pass<EOL>

Populate self.lists and hashes:
        self.commands, and self.aliases, self.category


def get_an_int(errmsg, arg, msg_on_error, min_value=None, max_value=None):

ret_value = None<EOL>if arg:<EOL><INDENT>try:<EOL><INDENT>ret_value = int(eval(arg))<EOL><DEDENT>except (SyntaxError, NameError, ValueError):<EOL><INDENT>if errmsg:<EOL><INDENT>errmsg(msg_on_error)<EOL><DEDENT>else:<EOL><INDENT>errmsg('<STR_LIT>' % str(arg))<EOL><DEDENT>return None<EOL><DEDENT><DEDENT>if min_value and ret_value < min_value:<EOL><INDENT>errmsg('<STR_LIT>' %<EOL>(min_value, ret_value))<EOL>return None<EOL><DEDENT>elif max_value and ret_value > max_value:<EOL><INDENT>errmsg('<STR_LIT>' %<EOL>(max_value, ret_value))<EOL>return None<EOL><DEDENT>return ret_value<EOL>

Another get_int() routine, this one simpler and less stylized
    than get_int(). We eval arg return it as an integer value or
    None if there was an error in parsing this.


def get_int(errmsg, arg, default=<NUM_LIT:1>, cmdname=None):

if arg:<EOL><INDENT>try:<EOL><INDENT>default = int(eval(arg))<EOL><DEDENT>except (SyntaxError, NameError, ValueError):<EOL><INDENT>if cmdname:<EOL><INDENT>errmsg("<STR_LIT>" %<EOL>(cmdname, str(arg)))<EOL><DEDENT>else:<EOL><INDENT>errmsg('<STR_LIT>' % str(arg))<EOL>pass<EOL><DEDENT>raise ValueError<EOL><DEDENT><DEDENT>return default<EOL>

If arg is an int, use that otherwise take default.


def get_onoff(errmsg, arg, default=None, print_error=True):

if not arg:<EOL><INDENT>if default is None:<EOL><INDENT>if print_error:<EOL><INDENT>errmsg("<STR_LIT>")<EOL>pass<EOL><DEDENT>raise ValueError<EOL><DEDENT>return default<EOL><DEDENT>if arg == '<STR_LIT:1>' or arg == '<STR_LIT>': return True<EOL>if arg == '<STR_LIT:0>' or arg =='<STR_LIT>': return False<EOL>if print_error:<EOL><INDENT>errmsg("<STR_LIT>" % str(arg))<EOL><DEDENT>raise ValueError<EOL>

Return True if arg is 'on' or 1 and False arg is 'off' or 0.
    Any other value is raises ValueError.


try:<EOL><INDENT>if <NUM_LIT:0> == len(args): args = ['<STR_LIT>']<EOL>obj.debugger.settings[obj.name] = get_onoff(obj.errmsg, args[<NUM_LIT:0>])<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT>return<EOL>

set a Boolean-valued debugger setting. 'obj' is a generally a
    subcommand that has 'name' and 'debugger.settings' attributes


def run_set_int(obj, arg, msg_on_error, min_value=None, max_value=None):

if '<STR_LIT>' == arg.strip():<EOL><INDENT>obj.errmsg("<STR_LIT>")<EOL>return<EOL><DEDENT>obj.debugger.settings[obj.name] =get_an_int(obj.errmsg, arg, msg_on_error, min_value, max_value)<EOL>return obj.debugger.settings[obj.name]<EOL>

set an Integer-valued debugger setting. 'obj' is a generally a
    subcommand that has 'name' and 'debugger.settings' attributes


val = show_onoff(obj.debugger.settings[obj.name])<EOL>if not what: what = obj.name<EOL>return obj.msg("<STR_LIT>" % (what, val))<EOL>

Generic subcommand showing a boolean-valued debugger setting.
    'obj' is generally a subcommand that has 'name' and
    'debugger.setting' attributes.


val = obj.debugger.settings[obj.name]<EOL>if not what: what = obj.name<EOL>return obj.msg("<STR_LIT>" % (what, val))<EOL>

Generic subcommand integer value display


if not isinstance(b, bool):<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>if b:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>return "<STR_LIT>"<EOL>

Return 'on' for True and 'off' for False, and ?? for anything
    else.


val = obj.debugger.settings[obj.name]<EOL>obj.msg("<STR_LIT>" % (obj.name, obj.cmd.proc._saferepr(val),))<EOL>return False<EOL>


bp_start    ::= opt_space location_if opt_space


arange_start  ::= opt_space arange
arange ::= range
arange ::= addr_location opt_space COMMA opt_space NUMBER
arange ::= addr_location opt_space COMMA opt_space OFFSET
arange ::= addr_location opt_space COMMA opt_space ADDRESS
arange ::= location opt_space COMMA opt_space ADDRESS
arange ::= addr_location opt_space COMMA
arange ::= addr_location

# Unlike ranges, We don't allow ending at an address
# arange ::= COMMA opt_space addr_location

addr_location ::= location
addr_location ::= ADDRESS


range_start  ::= opt_space range
range ::= location
range ::= location opt_space COMMA opt_space NUMBER
range ::= location opt_space COMMA opt_space OFFSET
range ::= COMMA opt_space location
range ::= location opt_space COMMA
range ::= location
range ::= DIRECTION


opt_space   ::= SPACE?

location_if ::= location
location_if ::= location SPACE IF tokens

# Note no space is allowed between FILENAME COLON, and NUMBER
location    ::= FILENAME COLON NUMBER
location    ::= FUNCNAME

# If just a number is given, the filename is implied
location    ::= NUMBER
location    ::= OFFSET

# For tokens we accept anything. Were really just
# going to use the underlying string from the part
# after "if".  So below we all of the possible tokens

tokens      ::= token+
token       ::= COLON
token       ::= COMMA
token       ::= DIRECTION
token       ::= FILENAME
token       ::= FUNCNAME
token       ::= NUMBER
token       ::= OFFSET
token       ::= SPACE


if isinstance(o, Token):<EOL><INDENT>return (self.kind == o.kind)<EOL><DEDENT>else:<EOL><INDENT>return self.kind == o<EOL><DEDENT>

==', but it's okay if offset is different


<EOL>raise ScannerError( ("<STR_LIT:%s>" % s),<EOL>("<STR_LIT>" % ("<STR_LIT:U+0020>"*(self.pos-<NUM_LIT:1>))) )<EOL>

Show text and a caret under that. For example:
x = 2y + z
     ^


self.add_token('<STR_LIT>', s)<EOL>self.pos += len(s)<EOL>pass<EOL>


maybe_funcname = True<EOL>if s == '<STR_LIT>':<EOL><INDENT>self.add_token('<STR_LIT>', s)<EOL>return<EOL><DEDENT>if s[<NUM_LIT:0>] in frozenset(('<STR_LIT:">', "<STR_LIT:'>")):<EOL><INDENT>if ( (s.startswith("<STR_LIT>") and s.endswith("<STR_LIT>") ) or<EOL>(s.startswith('<STR_LIT>') and s.endswith('<STR_LIT>') ) ):<EOL><INDENT>base = s[<NUM_LIT:3>:-<NUM_LIT:3>]<EOL><DEDENT>else:<EOL><INDENT>base = s[<NUM_LIT:1>:-<NUM_LIT:1>]<EOL><DEDENT>maybe_funcname = False<EOL><DEDENT>else:<EOL><INDENT>base = s<EOL><DEDENT>if maybe_funcname and re.match('<STR_LIT>', s):<EOL><INDENT>self.add_token('<STR_LIT>', base)<EOL><DEDENT>else:<EOL><INDENT>self.add_token('<STR_LIT>', base)<EOL><DEDENT>self.pos += len(s)<EOL>


<EOL>base = s[<NUM_LIT:1>:-<NUM_LIT:1>]<EOL>self.add_token('<STR_LIT>', base)<EOL>self.pos += len(s)<EOL>


<EOL>self.add_token('<STR_LIT>', s)<EOL>self.pos += len(s)<EOL>


pos = self.pos<EOL>self.add_token('<STR_LIT>', int(s))<EOL>self.pos = pos + len(s)<EOL>


pos = self.pos<EOL>self.add_token('<STR_LIT>', s)<EOL>self.pos = pos + len(s)<EOL>


file_dir = os.path.join(os.environ.get('<STR_LIT>', '<STR_LIT>'), '<STR_LIT>', '<STR_LIT>')<EOL>file_dir = Mclifns.path_expanduser_abs(file_dir)<EOL>if not os.path.isdir(file_dir):<EOL><INDENT>os.makedirs(file_dir, mode=<NUM_LIT>)<EOL><DEDENT>return os.path.join(file_dir, base_filename)<EOL>

Return fully expanded configuration filename location for
    base_filename. python2 and  python3 debuggers share the smae
    directory: ~/.config/trepan.py


startup_python_file = default_configfile('<STR_LIT>')<EOL>if Mfile.readable(startup_python_file):<EOL><INDENT>with codecs.open(startup_python_file, '<STR_LIT:r>', encoding='<STR_LIT:utf8>') as fp:<EOL><INDENT>exec(fp.read())<EOL><DEDENT><DEDENT>startup_trepan_file = default_configfile('<STR_LIT>')<EOL>if Mfile.readable(startup_trepan_file):<EOL><INDENT>if startup_trepan_file not in dbg_initfiles:<EOL><INDENT>dbg_initfiles.append(startup_trepan_file)<EOL><DEDENT>pass<EOL><DEDENT>return<EOL>

Read debugger startup file(s): both python code and
    debugger profile to dbg_initfiles.