lkmc v2-rc

Unsquashed version at v2-rc-unsquashed, but that cannot be merged as it
breaks bisects at several points. All bugs will not bisect to this
humongous change.

It all started with a conversion of the Bash scripts to Python, mainly
because I couldn't stand not being able to properly use --options for
run which has a million options.

Then since that required a full testing, I decided to do all the
refactorings that I had in mind at once, and so I did and it became
v2-rc.

This is the largest patch I have ever done! OMG a few weeks of extra time.
I'm never writing a Bash script for anything that starts getting big again.

Some of the features are:

* separate build-qemu and build-gem5 commands
* common: convert scripts to python. Add --option for everything
* rename build to build-buildroot now that we are splitting all the build
  commands, Linux kernel to follow
* move all git submodules to submodules/ and all buildroot packages to
  packages/
* refactor the out/ structure. Keep projects on toplevel, because guest
  projects separate archs and host ones don't, making a toplevel arch wrong
* do-release: rename to just release
  https://stackoverflow.com/questions/16174992/cant-get-argparse-to-read-quoted-string-with-dashes-in-it
* run: add --terminal and explain gem5 pdb
* just track the lvimrc
* store CLI kernel config fragment inside buildlroot to avoid conflicts
* gem5: document m5 initparam
* readme: make a bunch of things awesomer
* readme: fix broken refs
* parsec-benchmark: update to 75d55ac446a43c47efb1044844a108c6c330184c
  Could not fetch otherwise.
* gem5: M5_OVERRIDE_PY_SOURCE
This commit is contained in:
Ciro Santilli
2018-08-23 09:25:21 +01:00
parent 83b36867cf
commit 56738a1c70
162 changed files with 4524 additions and 3455 deletions

195
rungdb
View File

@@ -1,87 +1,108 @@
#!/usr/bin/env bash
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
after=
before=
lx_symbols="-ex 'lx-symbols ../kernel_module-1.0/' \\
"
kgdb=false
docontinue=true
while getopts "A:a:b:CgkL:n:X${common_getopts_flags}" OPT; do
case "$OPT" in
A)
after="$OPTARG"
;;
b)
before="$OPTARG"
;;
C)
# No Continue.
docontinue=false
;;
k)
kgdb=true
;;
X)
lx_symbols=
;;
?)
common_getopts_case "$OPT"
;;
esac
done
shift "$(($OPTIND - 1))"
if [ "$#" -gt 0 ]; then
brk="-ex 'break ${1}' \\
"
shift
else
brk=
fi
common_setup
gdb="${common_host_dir}/usr/bin/${common_arch}-linux-gdb \\
${before}"
if "$kgdb"; then
cmd="\
${gdb}\
-q \\
-ex 'add-auto-load-safe-path $(pwd)' \\
-ex 'file vmlinux' \\
-ex 'target remote localhost:${common_gdb_port}' \\
"
else
# ## lx-symbols
#
# ### lx-symbols after continue
#
# lx symbols must be run after continue.
#
# running it immediately after the connect on the bootloader leads to failure,
# likely because kernel structure on which it depends are not yet available.
#
# With this setup, continue runs, and lx-symbols only runs when a break happens,
# either by hitting the breakpoint, or by entering Ctrl + C.
#
# Sure, if the user sets a break on a raw address of the bootloader,
# problems will still arise, but let's think about that some other time.
#
# ### lx-symbols autoload
#
# The lx-symbols commands gets loaded through the file vmlinux-gdb.py
# which gets put on the kernel build root when python debugging scripts are enabled.
cmd="\
${gdb}\
-q \\
-ex 'add-auto-load-safe-path $(pwd)' \\
-ex 'file vmlinux' \\
-ex 'target remote localhost:${common_gdb_port}' \\
${brk}\
"
fi
if "$docontinue"; then
cmd="${cmd}\
-ex continue \\
${lx_symbols}\
"
fi
"${common_root_dir}/eeval" "cd '${common_linux_variant_dir}' && \\
$cmd $after" "${common_run_dir}/rungdb.sh"
#!/usr/bin/env python3
import os
import shlex
import sys
import signal
import subprocess
import common
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]
:return: GDB exit status
:rtype: int
'''
global defaults
args = common.resolve_args(defaults, args, extra_args)
after = shlex.split(args.after)
before = shlex.split(args.before)
if args.no_lxsymbols:
lx_symbols = []
else:
lx_symbols = ['-ex', 'lx-symbols ../kernel_modules-1.0/']
if args.break_at is not None:
break_at = ['-ex', 'break {}'.format(args.break_at)]
else:
break_at = []
cmd = (
[
os.path.join(common.host_bin_dir,
'{}-linux-gdb'.format(args.arch))
] +
before +
[
'-q',
'-ex', 'add-auto-load-safe-path {}'.format(common.linux_variant_dir),
'-ex', 'file {}'.format(common.vmlinux),
'-ex', 'target remote localhost:{}'.format(common.gdb_port),
]
)
if not args.kgdb:
cmd.extend(break_at)
if not args.no_continue:
# ## lx-symbols
#
# ### lx-symbols after continue
#
# lx symbols must be run after continue.
#
# running it immediately after the connect on the bootloader leads to failure,
# likely because kernel structure on which it depends are not yet available.
#
# With this setup, continue runs, and lx-symbols only runs when a break happens,
# either by hitting the breakpoint, or by entering Ctrl + C.
#
# Sure, if the user sets a break on a raw address of the bootloader,
# problems will still arise, but let's think about that some other time.
#
# ### lx-symbols autoload
#
# The lx-symbols commands gets loaded through the file vmlinux-gdb.py
# which gets put on the kernel build root when python debugging scripts are enabled.
cmd.extend(['-ex', 'continue'] + lx_symbols)
cmd.extend(after)
return common.run_cmd(cmd, cmd_file=os.path.join(common.run_dir, 'rungdb.sh'), cwd=common.linux_variant_dir)
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=defaults['after'],
help='Pass extra arguments to GDB, to be appended after all other arguments'
)
parser.add_argument(
'-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(
'-C', '--no-continue', default=defaults['no_continue'], action='store_true',
help="Don't run continue after connecting"
)
parser.add_argument(
'-k', '--kgdb', default=defaults['kgdb'], action='store_true'
)
parser.add_argument(
'-X', '--no-lxsymbols', default=defaults['no_lxsymbols'], action='store_true'
)
parser.add_argument(
'break_at', nargs='?',
help='Extra options to append at the end of the emulator command line'
)
args = common.setup(parser)
sys.exit(main(args))