mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 19:21:35 +01:00
port gdbserver
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import glob
|
||||
import imp
|
||||
import re
|
||||
import subprocess
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import signal
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
this = sys.modules[__name__]
|
||||
@@ -151,6 +152,10 @@ def get_stats(stat_re=None, stats_file=None):
|
||||
ret.append(cols[1])
|
||||
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):
|
||||
"""
|
||||
Format a command given as a list of strings so that it can
|
||||
|
||||
46
rungdbserver
46
rungdbserver
@@ -1,20 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
||||
while getopts "${common_getopts_flags}" OPT; do
|
||||
case "$OPT" in
|
||||
?)
|
||||
common_getopts_case "$OPT"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift "$(($OPTIND - 1))"
|
||||
executable="$1"
|
||||
common_setup
|
||||
"${common_host_dir}/usr/bin/${common_arch}-linux-gdb" \
|
||||
-q \
|
||||
-ex "set sysroot ${common_buildroot_out_dir}/staging" \
|
||||
-ex "target remote localhost:${common_qemu_hostfwd_generic_port}" \
|
||||
-ex 'tb main' \
|
||||
-ex 'c' \
|
||||
"${common_build_dir}/${executable}" \
|
||||
;
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import common
|
||||
|
||||
parser = common.get_argparse(argparse_args={
|
||||
'description':'Connect to gdbserver running on the guest.'
|
||||
})
|
||||
parser.add_argument(
|
||||
'executable',
|
||||
help='''Path to the executable to be debugged relative to the Buildroot build directory.'''
|
||||
)
|
||||
args = common.setup(parser)
|
||||
sys.exit(subprocess.Popen([
|
||||
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
9
runtc
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -10,10 +9,10 @@ import common
|
||||
parser = common.get_argparse(argparse_args={
|
||||
'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:
|
||||
@@ -32,6 +31,4 @@ parser.add_argument(
|
||||
nargs='*'
|
||||
)
|
||||
args = common.setup(parser)
|
||||
paths = glob.glob(os.path.join(common.host_bin_dir, '*-buildroot-*-{}'.format(args.tool)))
|
||||
assert len(paths) == 1
|
||||
sys.exit(subprocess.Popen(paths + args.extra_args).wait())
|
||||
sys.exit(subprocess.Popen([common.get_toolchain_tool(args.tool)] + args.extra_args).wait())
|
||||
|
||||
Reference in New Issue
Block a user