Skip to content
Snippets Groups Projects
Commit 4e6c77f6 authored by Laura Abbott's avatar Laura Abbott
Browse files

linux-ramdump-parser-v2: cleanup output of tracing

When tracing with read_physical, the result of what was read is printed.
The result may contain unprintable characters which wreak havok on
terminals. re-use the cleanupString function which is already in use
in several places to make the output readable.

Change-Id: I1a62c88f1d51038ba2c429d8ec918c58d39af4bf
parent 80268207
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ import os
import platform
import glob
import re
import string
_parsers = []
......@@ -29,6 +30,11 @@ class ParserConfig(object):
self.shortopt = shortopt
self.optional = optional
def cleanupString(unclean_str):
if unclean_str is None:
return unclean_str
else:
return ''.join([c for c in unclean_str if c in string.printable])
def register_parser(longopt, desc, shortopt=None, optional=False):
"""Decorator to register a parser class (a class that inherits from
......
......@@ -13,7 +13,7 @@ import re
import string
from print_out import print_out_str
from parser_util import register_parser, RamParser
from parser_util import register_parser, RamParser, cleanupString
@register_parser('--dmesg', 'Print the dmesg', shortopt='-d')
......@@ -23,17 +23,11 @@ class Dmesg(RamParser):
super(Dmesg, self).__init__(*args)
self.wrap_cnt = 0
def cleanupString(self, unclean_str):
if unclean_str is None:
return str
else:
return ''.join([c for c in unclean_str if c in string.printable])
def extract_dmesg_flat(self, ramdump):
addr = ramdump.read_word(ramdump.addr_lookup('log_buf'))
size = ramdump.read_word(ramdump.addr_lookup('log_buf_len'))
dmesg = ramdump.read_physical(ramdump.virt_to_phys(addr), size)
print_out_str(self.cleanupString(dmesg.decode('ascii', 'ignore')))
print_out_str(cleanupString(dmesg.decode('ascii', 'ignore')))
def log_from_idx(self, ramdump, idx, logbuf):
len_offset = ramdump.field_offset('struct log', 'len')
......
......@@ -11,14 +11,7 @@
import string
from print_out import print_out_str
from parser_util import register_parser, RamParser
def cleanupString(str):
if str is None:
return str
else:
return ''.join([c for c in str if c in string.printable])
from parser_util import register_parser, RamParser, cleanupString
cpu_context_save_str = ''.join([
'I', # __u32 r4
......
......@@ -21,6 +21,7 @@ from tempfile import NamedTemporaryFile
import gdbmi
from print_out import print_out_str
from mmu import Armv7MMU, Armv7LPAEMMU
from parser_util import cleanupString
FP = 11
SP = 13
......@@ -898,7 +899,7 @@ class RamDump():
ebi[0].seek(offset)
a = ebi[0].read(length)
if trace:
print_out_str('result = {0}'.format(a))
print_out_str('result = {0}'.format(cleanupString(a)))
print_out_str('lenght = {0}'.format(len(a)))
return a
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment