elf_mem_map: parse D23 output directly
This commit is contained in:
parent
8ec4104840
commit
9f40fa6834
|
|
@ -4,6 +4,7 @@ import elftools.elf.elffile
|
||||||
import elftools.dwarf.descriptions
|
import elftools.dwarf.descriptions
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from struct import unpack
|
from struct import unpack
|
||||||
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
SRAM_START = 0x200
|
SRAM_START = 0x200
|
||||||
|
|
@ -264,12 +265,26 @@ def decode_dump(path):
|
||||||
buf_addr = None # starting address
|
buf_addr = None # starting address
|
||||||
buf_data = None # data
|
buf_data = None # data
|
||||||
|
|
||||||
for line in fd:
|
in_dump = False
|
||||||
tokens = line.split(maxsplit=1)
|
for line in enumerate(fd):
|
||||||
if len(tokens) == 0 or tokens[0] == 'ok':
|
line = (line[0], line[1].rstrip())
|
||||||
break
|
tokens = line[1].split(maxsplit=1)
|
||||||
elif len(tokens) < 2 or tokens[0] == 'D2':
|
if not in_dump:
|
||||||
|
if len(tokens) > 0 and tokens[0] in ['D2', 'D23']:
|
||||||
|
in_dump = True
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
|
if len(tokens) < 1:
|
||||||
|
print('malformed line {}: {}'.format(*line), file=sys.stderr)
|
||||||
|
continue
|
||||||
|
elif tokens[0] == 'ok':
|
||||||
|
break
|
||||||
|
elif tokens[0] == 'reason:':
|
||||||
|
# ignored
|
||||||
|
continue
|
||||||
|
elif not re.match(r'[0-9a-fA-F]', tokens[0]):
|
||||||
|
print('malformed line {}: {}'.format(*line), file=sys.stderr)
|
||||||
|
continue
|
||||||
|
|
||||||
addr = int.from_bytes(bytes.fromhex(tokens[0]), 'big')
|
addr = int.from_bytes(bytes.fromhex(tokens[0]), 'big')
|
||||||
data = bytes.fromhex(tokens[1])
|
data = bytes.fromhex(tokens[1])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue