mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-26 03:31:36 +01:00
bak
This commit is contained in:
29
rungdb
29
rungdb
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import copy
|
||||
import os
|
||||
import shlex
|
||||
import sys
|
||||
@@ -8,7 +9,29 @@ import subprocess
|
||||
|
||||
import common
|
||||
|
||||
def main(args):
|
||||
defaults = {
|
||||
'after': '',
|
||||
'before': '',
|
||||
'no_continue': False,
|
||||
'kgdb': False,
|
||||
'no_lxsymbols': False,
|
||||
'break_at': None,
|
||||
}
|
||||
|
||||
def main(args, extra_args=None):
|
||||
"""
|
||||
:param args: argparse parse_argument() output. Must contain all the common options,
|
||||
but does not need GDB specific ones.
|
||||
:type args: argparse.Namespace
|
||||
|
||||
:param extra_args: extra arguments to be added to args
|
||||
:type extra_args: Dict[str,Any]
|
||||
"""
|
||||
global defaults
|
||||
if extra_args is None:
|
||||
extra_args = {}
|
||||
args = copy.copy(args)
|
||||
args.__dict__ = dict(list(defaults.items()) + list(args.__dict__.items()) + list(extra_args.items()))
|
||||
after = shlex.split(args.after)
|
||||
before = shlex.split(args.before)
|
||||
if args.no_lxsymbols:
|
||||
@@ -61,11 +84,11 @@ def main(args):
|
||||
if __name__ == '__main__':
|
||||
parser = common.get_argparse(argparse_args={'description':'Connect with GDB to an emulator to debug Linux itself'})
|
||||
parser.add_argument(
|
||||
'-A', '--after', default='',
|
||||
'-A', '--after', default=defaults['after'],
|
||||
help='Pass extra arguments to GDB, to be appended after all other arguments'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-b', '--before', default='',
|
||||
'-b', '--before', default=defaults['before'],
|
||||
help='Pass extra arguments to GDB to be prepended before any of the arguments passed by this script'
|
||||
)
|
||||
parser.add_argument(
|
||||
|
||||
@@ -36,10 +36,11 @@ for line in readelf_header.decode().split('\n'):
|
||||
addr = line.split()[-1]
|
||||
break
|
||||
print(addr)
|
||||
args.before = '-ex \"add-symbol-file {} {}\"'.format(args.executable, addr)
|
||||
extra_args = {}
|
||||
extra_args['before'] = '-ex \"add-symbol-file {} {}\"'.format(args.executable, addr)
|
||||
# Or else lx-symbols throws for arm:
|
||||
# gdb.MemoryError: Cannot access memory at address 0xbf0040cc
|
||||
# TODO understand better.
|
||||
# Also, lx-symbols overrides the add-symbol-file commands.
|
||||
args.no_lxsymbols = True
|
||||
rungdb.main(args)
|
||||
extra_args['no_lxsymbols'] = True
|
||||
rungdb.main(args, extra_args)
|
||||
|
||||
Reference in New Issue
Block a user