Skip to content

Commit 4d587b7

Browse files
committed
Go over set subcommand options
1 parent d9d6175 commit 4d587b7

4 files changed

Lines changed: 49 additions & 35 deletions

File tree

trepan/processor/command/set_subcmd/asmfmt.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from trepan.processor.command.base_subcmd import DebuggerSubcommand
1919
from trepan.lib.complete import complete_token
2020

21+
choices = ["classic", "extended", "extended-bytes", "bytes"]
2122

2223
class SetAsmFmt(DebuggerSubcommand):
2324
"""**set asmfmt** {**classic** | **extended** | **bytes** | **extended-bytes**}
@@ -41,28 +42,32 @@ class SetAsmFmt(DebuggerSubcommand):
4142
`show asmfmt`"""
4243

4344
in_list = True
45+
max_args = 1
4446
min_abbrev = len("asmf")
47+
min_args = 0
4548
short_help = "Set disassembly style"
4649

47-
choices = ("classic", "extended", "extended-bytes", "bytes")
48-
4950
def complete(self, prefix):
50-
return complete_token(SetAsmFmt.choices, prefix)
51+
return complete_token(choices, prefix)
5152

5253
def get_format_type(self, arg):
5354
if not arg:
5455
return "extended"
55-
if arg in SetAsmFmt.choices:
56+
if arg in choices:
5657
return arg
5758
else:
5859
self.errmsg(
5960
'Expecting %s"; got %s'
60-
% (", ".join(SetAsmFmt.choices), arg)
61+
% (", ".join(choices), arg)
6162
)
6263
return None
6364
pass
6465

6566
def run(self, args):
67+
if len(args) == 0:
68+
self.section("disasembly style types: ")
69+
self.msg(self.columnize_commands(choices))
70+
return
6671
format_type = self.get_format_type(args[0])
6772
if not format_type:
6873
return

trepan/processor/command/set_subcmd/events.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2009, 2012-2013, 2015 Rocky Bernstein
2+
# Copyright (C) 2009, 2012-2013, 2015, 2020 Rocky Bernstein
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -46,38 +46,40 @@ class SetEvents(Mbase_subcmd.DebuggerSubcommand):
4646
`set trace`, `show trace`, and `show events`. `help step` lists event names.
4747
"""
4848

49-
in_list = True
50-
min_abbrev = len('ev')
49+
in_list = True
50+
min_args = 0
51+
min_abbrev = len("ev")
5152
short_help = "Set execution-tracing event set"
5253

5354
def run(self, args):
54-
valid_args = tracer.ALL_EVENT_NAMES + ('all',)
55+
valid_args = tracer.ALL_EVENT_NAMES + ("all",)
5556
eventset = []
5657
for arg in args:
5758
if arg not in valid_args:
58-
self.errmsg('set events: Invalid argument %s ignored.' % arg)
59+
self.errmsg("set events: Invalid argument %s ignored." % arg)
5960
continue
6061
if arg in tracer.ALL_EVENTS:
6162
eventset += [arg]
62-
elif 'all' == arg:
63+
elif "all" == arg:
6364
eventset += tracer.ALL_EVENTS
6465
pass
6566
if [] != eventset:
66-
self.debugger.settings['printset'] = frozenset(eventset)
67+
self.debugger.settings["printset"] = frozenset(eventset)
6768
pass
6869
return
6970

7071
pass
7172

72-
if __name__ == '__main__':
73+
74+
if __name__ == "__main__":
7375
from trepan.processor.command import mock, set as Mset
76+
7477
d, cp = mock.dbg_setup()
7578
s = Mset.SetCommand(cp)
7679
sub = SetEvents(s)
77-
sub.name = 'events'
78-
for args in (['line'], ['bogus'],
79-
['call', 'return']):
80+
sub.name = "events"
81+
for args in (["line"], ["bogus"], ["call", "return"]):
8082
sub.run(args)
81-
print(d.settings['printset'])
83+
print(d.settings["printset"])
8284
pass
8385
pass
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2009-2010, 2013, 2015 Rocky Bernstein <rocky@gnu.org>
2+
# Copyright (C) 2009-2010, 2013, 2015, 2020 Rocky Bernstein <rocky@gnu.org>
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -15,11 +15,11 @@
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
# Our local modules
18-
from trepan.processor.command import base_subcmd as Mbase_subcmd
18+
from trepan.processor.command.base_subcmd import DebuggerSubcommand
1919
from trepan.processor import cmdfns as Mcmdfns
2020

2121

22-
class SetMaxString(Mbase_subcmd.DebuggerSubcommand):
22+
class SetMaxString(DebuggerSubcommand):
2323
"""**set maxstring** *number*
2424
2525
Set the number of characters allowed in showing string values
@@ -29,15 +29,22 @@ class SetMaxString(Mbase_subcmd.DebuggerSubcommand):
2929
3030
`show maxstring`
3131
"""
32-
in_list = True
33-
min_abbrev = len('str') # Need at least "set max str"
32+
33+
in_list = True
34+
max_args = 1
35+
min_abbrev = len("str") # Need at least "set max str"
36+
min_args = 1
3437
short_help = "Set maximum characters in showing strings"
3538

3639
def run(self, args):
37-
Mcmdfns.run_set_int(self, ' '.join(args),
38-
"The '%s' command requires a character count"
39-
% self.name,
40-
0, None)
41-
self.proc._repr.maxstring = self.settings[self.name]
40+
Mcmdfns.run_set_int(
41+
self,
42+
" ".join(args),
43+
"The '%s' command requires a character count" % self.name,
44+
0,
45+
None,
46+
)
47+
self.proc._repr.maxstring = self.settings[self.name]
4248
return None
49+
4350
pass

trepan/processor/command/set_subcmd/style.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2015, 2017-2018 Rocky Bernstein
2+
# Copyright (C) 2015, 2017-2018, 2020 Rocky Bernstein
33
#
44

55
from pygments.styles import STYLE_MAP
6+
67
style_names = sorted(list(STYLE_MAP.keys()))
78

89
# Our local modules
@@ -36,19 +37,16 @@ class SetStyle(Mbase_subcmd.DebuggerSubcommand):
3637
def complete(self, prefix):
3738
return Mcomplete.complete_token(style_names, prefix)
3839

39-
in_list = True
40-
min_abbrev = len('sty')
41-
short_help = 'Set the pygments style'
40+
in_list = True
41+
min_abbrev = len("sty")
42+
short_help = "Set the pygments style"
4243

4344
def run(self, args):
4445
if len(args) == 0:
4546
self.section("style names: ")
4647
self.msg(self.columnize_commands(style_names))
4748
return
48-
elif len(args) > 1:
49-
self.errmsg("Expecting zero one one arg")
50-
return
51-
if args[0] == 'none':
49+
if args[0] == "none":
5250
self.debugger.settings[self.name] = None
5351
return
5452

@@ -59,8 +57,10 @@ def run(self, args):
5957

6058
self.debugger.settings[self.name] = args[0]
6159
return
60+
6261
pass
6362

63+
6464
# if __name__ == '__main__':
6565
# from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
6666
# sub = Mhelper.demo_run(SetWidth)

0 commit comments

Comments
 (0)