From bd3b64572c76339c938c63643646d12951e07392 Mon Sep 17 00:00:00 2001 From: raywang Date: Tue, 19 Sep 2017 16:15:59 -0400 Subject: [PATCH 1/5] Added ability to specify number of bytes to display with args.words --- voltron/plugins/view/memory.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/voltron/plugins/view/memory.py b/voltron/plugins/view/memory.py index 6f9a819..c7a2c9b 100644 --- a/voltron/plugins/view/memory.py +++ b/voltron/plugins/view/memory.py @@ -100,10 +100,12 @@ class MemoryView(TerminalView): if self.args.words: if target['byte_order'] =='little': - byte_array.reverse() - for x in byte_array: - yield x - yield (Text, ' ') + byte_array_words = [byte_array[i:i+ target['addr_size']] for i in range(0, self.args.bytes, target['addr_size'])] + for word in byte_array_words: + word.reverse() + for x in word: + yield x + yield (Text, ' ') else: for x in byte_array: yield x @@ -151,7 +153,7 @@ class MemoryView(TerminalView): if t_res and t_res.is_success and len(t_res.targets) > 0: target = t_res.targets[0] - if self.args.deref or self.args.words: + if self.args.deref: self.args.bytes = target['addr_size'] f = pygments.formatters.get_formatter_by_name(self.config.format.pygments_formatter, From 0df149fcc71dd5dc3eb7cccc38e7ae3947c40598 Mon Sep 17 00:00:00 2001 From: raywang Date: Tue, 19 Sep 2017 20:02:02 -0400 Subject: [PATCH 2/5] Added number parameter to words --- voltron/plugins/view/memory.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/voltron/plugins/view/memory.py b/voltron/plugins/view/memory.py index c7a2c9b..60e5672 100644 --- a/voltron/plugins/view/memory.py +++ b/voltron/plugins/view/memory.py @@ -26,10 +26,11 @@ class MemoryView(TerminalView): help='display the data in a column one CPU word wide and dereference any valid pointers', default=False) group.add_argument('--bytes', '-b', action='store', type=int, help='bytes per line (default 16)', default=16) + group.add_argument('--words', '-w', action='store', type=int, help='display data as machine words (default 1 word per line)', default=1) sp.add_argument('--reverse', '-v', action='store_true', help='reverse the output', default=False) sp.add_argument('--track', '-t', action='store_true', help='track and highlight changes', default=True) sp.add_argument('--no-track', '-T', action='store_false', help='don\'t track and highlight changes') - sp.add_argument('--words', '-w', action='store_true', help='display data as a column of machine words', default=False) + group = sp.add_mutually_exclusive_group(required=False) group.add_argument('--address', '-a', action='store', help='address (in hex or decimal) from which to start reading memory') @@ -81,8 +82,9 @@ class MemoryView(TerminalView): target = t_res.targets[0] if m_res and m_res.is_success: - for c in range(0, m_res.bytes, self.args.bytes): - chunk = m_res.memory[c:c + self.args.bytes] + bytes_per_chunk = self.args.words*target['addr_size'] if self.args.words else self.args.bytes + for c in range(0, m_res.bytes, bytes_per_chunk): + chunk = m_res.memory[c:c + bytes_per_chunk] yield (Name.Label, self.format_address(m_res.address + c, size=target['addr_size'], pad=False)) yield (Name.Label, ': ') @@ -100,7 +102,7 @@ class MemoryView(TerminalView): if self.args.words: if target['byte_order'] =='little': - byte_array_words = [byte_array[i:i+ target['addr_size']] for i in range(0, self.args.bytes, target['addr_size'])] + byte_array_words = [byte_array[i:i+ target['addr_size']] for i in range(0, bytes_per_chunk, target['addr_size'])] for word in byte_array_words: word.reverse() for x in word: @@ -153,7 +155,7 @@ class MemoryView(TerminalView): if t_res and t_res.is_success and len(t_res.targets) > 0: target = t_res.targets[0] - if self.args.deref: + if self.args.deref or self.args.words: self.args.bytes = target['addr_size'] f = pygments.formatters.get_formatter_by_name(self.config.format.pygments_formatter, From 82bf16bcf8c2e296c580909d52e4612233e389ca Mon Sep 17 00:00:00 2001 From: raywang Date: Tue, 19 Sep 2017 20:52:49 -0400 Subject: [PATCH 3/5] Changed default value for words to be 0 --- voltron/plugins/view/memory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voltron/plugins/view/memory.py b/voltron/plugins/view/memory.py index 60e5672..d3fd961 100644 --- a/voltron/plugins/view/memory.py +++ b/voltron/plugins/view/memory.py @@ -26,7 +26,7 @@ class MemoryView(TerminalView): help='display the data in a column one CPU word wide and dereference any valid pointers', default=False) group.add_argument('--bytes', '-b', action='store', type=int, help='bytes per line (default 16)', default=16) - group.add_argument('--words', '-w', action='store', type=int, help='display data as machine words (default 1 word per line)', default=1) + group.add_argument('--words', '-w', action='store', type=int, help='display data as machine words (default 1 word per line)', default=0) sp.add_argument('--reverse', '-v', action='store_true', help='reverse the output', default=False) sp.add_argument('--track', '-t', action='store_true', help='track and highlight changes', default=True) sp.add_argument('--no-track', '-T', action='store_false', help='don\'t track and highlight changes') From 335b2e65c11d4d5bdcff060558fb22e1a6bbbd2b Mon Sep 17 00:00:00 2001 From: raywang Date: Thu, 21 Sep 2017 11:33:27 -0400 Subject: [PATCH 4/5] Removed default help text --- voltron/plugins/view/memory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voltron/plugins/view/memory.py b/voltron/plugins/view/memory.py index d3fd961..baaf270 100644 --- a/voltron/plugins/view/memory.py +++ b/voltron/plugins/view/memory.py @@ -26,7 +26,7 @@ class MemoryView(TerminalView): help='display the data in a column one CPU word wide and dereference any valid pointers', default=False) group.add_argument('--bytes', '-b', action='store', type=int, help='bytes per line (default 16)', default=16) - group.add_argument('--words', '-w', action='store', type=int, help='display data as machine words (default 1 word per line)', default=0) + group.add_argument('--words', '-w', action='store', type=int, help='machine words per line', default=0) sp.add_argument('--reverse', '-v', action='store_true', help='reverse the output', default=False) sp.add_argument('--track', '-t', action='store_true', help='track and highlight changes', default=True) sp.add_argument('--no-track', '-T', action='store_false', help='don\'t track and highlight changes') From 97ff2dabf1b24e7496c029bef8e96e3bcd1b9e26 Mon Sep 17 00:00:00 2001 From: raywang Date: Sat, 11 Nov 2017 11:36:43 -0500 Subject: [PATCH 5/5] Double length of memory view --- voltron/plugins/view/memory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voltron/plugins/view/memory.py b/voltron/plugins/view/memory.py index baaf270..7673731 100644 --- a/voltron/plugins/view/memory.py +++ b/voltron/plugins/view/memory.py @@ -66,7 +66,7 @@ class MemoryView(TerminalView): args['words'] = height args['offset'] = self.scroll_offset if self.args.reverse else -self.scroll_offset else: - args['length'] = height * self.args.bytes + args['length'] = height * self.args.bytes * 2 args['offset'] = self.scroll_offset * self.args.bytes * (1 if self.args.reverse else -1) # get memory and target info