sedbgmux-dump.py: automatic dump format detection
This commit is contained in:
parent
a378018178
commit
e0538ea1c3
|
@ -26,8 +26,18 @@ from sedbgmux.io import *
|
|||
from sedbgmux import DbgMuxFrame
|
||||
|
||||
|
||||
def dumpio_auto(fname: str, *args, **kw) -> DumpIO:
|
||||
''' Detect dump format automatically '''
|
||||
if fname.endswith('.socat.dump'):
|
||||
return DumpIOSocat(fname, *args, **kw)
|
||||
elif fname.endswith('.dump'):
|
||||
return DumpIONative(fname, *args, **kw)
|
||||
raise DumpIOError('Automatic format detection failed')
|
||||
|
||||
|
||||
class SEDbgMuxDumpApp:
|
||||
FORMATS = {
|
||||
'auto' : (dumpio_auto, 'Automatic dump format detection (by filename)'),
|
||||
'native' : (DumpIONative, 'Native binary dump format for this package'),
|
||||
'socat' : (DumpIOSocat, 'ASCII hexdump generated by socat (-x option)'),
|
||||
}
|
||||
|
@ -93,8 +103,8 @@ ap.add_argument('-v', '--verbose', action='count', default=0,
|
|||
parse = sp.add_parser('parse', help='parse a dump file')
|
||||
parse.add_argument('input', metavar='INPUT', type=str,
|
||||
help='input file to be parsed')
|
||||
parse.add_argument('-f', '--format', type=str,
|
||||
choices=SEDbgMuxDumpApp.FORMATS.keys(), default='native',
|
||||
parse.add_argument('-f', '--format', type=str, default='auto',
|
||||
choices=SEDbgMuxDumpApp.FORMATS.keys(),
|
||||
help='input file format (default: %(default)s)')
|
||||
parse.add_argument('-dp', '--decode-payload', action='store_true',
|
||||
help='decode DebugMux frame contents')
|
||||
|
|
Loading…
Reference in New Issue