run-gdb-user 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python3
  2. import imp
  3. import os
  4. import sys
  5. import common
  6. rungdb = imp.load_source('rungdb', os.path.join(common.root_dir, 'run-gdb'))
  7. parser = common.get_argparse(argparse_args={
  8. 'description': '''GDB step debug guest userland processes without gdbserver.
  9. More information at: https://github.com/cirosantilli/linux-kernel-module-cheat#gdb-step-debug-userland-processes
  10. '''
  11. })
  12. parser.add_argument(
  13. 'executable',
  14. help='Path to the executable to be debugged relative to the Buildroot build directory.'
  15. )
  16. parser.add_argument(
  17. 'break',
  18. default=None,
  19. help='Break at this point, e.g. main.',
  20. nargs='?'
  21. )
  22. args = common.setup(parser)
  23. addr = common.get_elf_entry(os.path.join(common.build_dir, args.executable))
  24. extra_args = {}
  25. extra_args['before'] = '-ex \"add-symbol-file {} {}\"'.format(args.executable, hex(addr))
  26. # Or else lx-symbols throws for arm:
  27. # gdb.MemoryError: Cannot access memory at address 0xbf0040cc
  28. # TODO understand better.
  29. # Also, lx-symbols overrides the add-symbol-file commands.
  30. extra_args['no_lxsymbols'] = True
  31. sys.exit(rungdb.main(args, extra_args))