port gdbserver

This commit is contained in:
Ciro Santilli
2018-08-31 15:38:07 +01:00
parent 04b878dfa7
commit e8bb30963d
3 changed files with 36 additions and 28 deletions

View File

@@ -2,13 +2,14 @@
import argparse import argparse
import base64 import base64
import glob
import imp import imp
import re
import subprocess
import os import os
import re
import shlex import shlex
import signal import signal
import stat import stat
import subprocess
import sys import sys
this = sys.modules[__name__] this = sys.modules[__name__]
@@ -151,6 +152,10 @@ def get_stats(stat_re=None, stats_file=None):
ret.append(cols[1]) ret.append(cols[1])
return ret return ret
def get_toolchain_tool(tool):
global this
return glob.glob(os.path.join(this.host_bin_dir, '*-buildroot-*-{}'.format(tool)))[0]
def print_cmd(cmd, cmd_file=None, extra_env=None): def print_cmd(cmd, cmd_file=None, extra_env=None):
""" """
Format a command given as a list of strings so that it can Format a command given as a list of strings so that it can

View File

@@ -1,20 +1,26 @@
#!/usr/bin/env bash #!/usr/bin/env python3
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
while getopts "${common_getopts_flags}" OPT; do import glob
case "$OPT" in import os
?) import subprocess
common_getopts_case "$OPT" import sys
;;
esac import common
done
shift "$(($OPTIND - 1))" parser = common.get_argparse(argparse_args={
executable="$1" 'description':'Connect to gdbserver running on the guest.'
common_setup })
"${common_host_dir}/usr/bin/${common_arch}-linux-gdb" \ parser.add_argument(
-q \ 'executable',
-ex "set sysroot ${common_buildroot_out_dir}/staging" \ help='''Path to the executable to be debugged relative to the Buildroot build directory.'''
-ex "target remote localhost:${common_qemu_hostfwd_generic_port}" \ )
-ex 'tb main' \ args = common.setup(parser)
-ex 'c' \ sys.exit(subprocess.Popen([
"${common_build_dir}/${executable}" \ common.get_toolchain_tool('gdb'),
; '-q',
'-ex', 'set sysroot {}'.format(common.staging_dir),
'-ex', 'target remote localhost:{}'.format(common.qemu_hostfwd_generic_port),
'-ex', 'tbreak main',
'-ex', 'continue',
os.path.join(common.build_dir, args.executable),
]).wait())

9
runtc
View File

@@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import glob
import os import os
import subprocess import subprocess
import sys import sys
@@ -10,10 +9,10 @@ import common
parser = common.get_argparse(argparse_args={ parser = common.get_argparse(argparse_args={
'description':'''Run a Buildroot ToolChain tool like readelf or objdump. 'description':'''Run a Buildroot ToolChain tool like readelf or objdump.
For example, to run `readelf -h` for the `arm` architecture, use: For example, to get some information about the arm vmlinux:
.... ....
./%(prog)s -a arm readelf -- -h ./%(prog)s readelf -- -e "$(./getvar vmlinux)"
.... ....
Get the list of available tools with: Get the list of available tools with:
@@ -32,6 +31,4 @@ parser.add_argument(
nargs='*' nargs='*'
) )
args = common.setup(parser) args = common.setup(parser)
paths = glob.glob(os.path.join(common.host_bin_dir, '*-buildroot-*-{}'.format(args.tool))) sys.exit(subprocess.Popen([common.get_toolchain_tool(args.tool)] + args.extra_args).wait())
assert len(paths) == 1
sys.exit(subprocess.Popen(paths + args.extra_args).wait())