|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# Copyright (C) 2020 Rocky Bernstein |
| 3 | +# |
| 4 | +# This program is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +# Our local modules |
| 18 | +from trepan.processor.command import base_subcmd as Mbase_subcmd |
| 19 | + |
| 20 | + |
| 21 | +class SetPatSub(Mbase_subcmd.DebuggerSubcommand): |
| 22 | + """**set patsub** *from-re* *replace-string* |
| 23 | +
|
| 24 | +Add a substitution pattern rule replacing *patsub* with |
| 25 | +*replace-string* anywhere it is found in source file names. If a |
| 26 | +substitution rule was previously set for *from-re*, the old rule is |
| 27 | +replaced by the new one. |
| 28 | +
|
| 29 | +In the following example, suppose in a docker container /mnt/project is |
| 30 | +the mount-point for /home/rocky/project. You are running the code |
| 31 | +from the docker container, but debugging this from outside of that. |
| 32 | +
|
| 33 | +Example: |
| 34 | +-------- |
| 35 | +
|
| 36 | + set patsub ^/mmt/project /home/rocky/project |
| 37 | +
|
| 38 | + """ |
| 39 | + |
| 40 | + in_list = True |
| 41 | + min_abbrev = len("pats") |
| 42 | + short_help = "Set pattern substitution rule" |
| 43 | + |
| 44 | + def run(self, args): |
| 45 | + if len(args) != 2: |
| 46 | + self.errmsg("Expecting two arguments; got %d." % len(args)) |
| 47 | + return |
| 48 | + self.proc.add_remap_pat(args[0], args[1]) |
| 49 | + |
| 50 | + pass |
| 51 | + |
| 52 | + |
| 53 | +if __name__ == "__main__": |
| 54 | + from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper |
| 55 | + |
| 56 | + Mhelper.demo_run(SetPatSub) |
| 57 | + pass |
0 commit comments