diff --git a/README.adoc b/README.adoc index 98823ea..2ac9bfc 100644 --- a/README.adoc +++ b/README.adoc @@ -1426,13 +1426,25 @@ Bibliography: https://unix.stackexchange.com/questions/152738/how-to-split-a-new ==== tmux gem5 -If you are using gem5 instead of QEMU, `--tmux` has a different effect: it opens the gem5 terminal instead of the debugger: +If you are using gem5 instead of QEMU, `--tmux` has a different effect by default: it opens the gem5 terminal instead of the debugger: .... ./run --emulator gem5 --tmux .... -If you also want to use the debugger with gem5, you will need to create new terminals as usual. +To open a new pane with GDB instead of the terminal, use: + +.... +./run --emulator gem5 --gdb-wait --tmux --tmux-program gdb +.... + +`--tmux-program` implies `--tmux`, so we can just write: + +.... +./run --emulator gem5 --gdb-wait --tmux-program gdb +.... + +If you also want to see both GDB and the terminal with gem5, then you will need to open a separate shell manuall as usual with `./gem5-shell`. From inside tmux, you can do that with `Ctrl-B C` or `Ctrl-B %`. diff --git a/run b/run index d1beac2..dde9b88 100755 --- a/run +++ b/run @@ -278,6 +278,15 @@ See: https://github.com/cirosantilli/linux-kernel-module-cheat#tmux '--tmux-args', help='''\ Parameters to pass to the program running on the tmux split. Implies --tmux. +''' + ) + self.add_argument( + '--tmux-program', + choices=('gdb', 'shell'), + help='''\ +Which program to run in tmux. Implies --tmux. Defaults: +* 'gdb' in qemu +* 'shell' in gem5. 'shell' is only supported in gem5 currently. ''' ) self.add_argument( @@ -312,8 +321,13 @@ Extra options to append at the end of the emulator command line. kernel_cli_after_dash = ' lkmc_home={}'.format(self.env['guest_lkmc_home']) extra_emulator_args = [] extra_qemu_args = [] - if self.env['tmux_args'] is not None: + if self.env['tmux_args'] is not None or self.env['_args_given']['tmux_program']: self.env['tmux'] = True + if not self.env['_args_given']['tmux_program']: + if self.env['emulator'] == 'qemu': + self.env['tmux_program'] = 'gdb' + elif self.env['emulator'] == 'gem5': + self.env['tmux_program'] = 'shell' if self.env['debug_vm'] or self.env['debug_vm_args']: debug_vm = ['gdb', LF, '-q', LF] + self.sh.shlex_split(self.env['debug_vm_args']) + ['--args', LF] else: @@ -659,16 +673,20 @@ Extra options to append at the end of the emulator command line. cmd.extend(append) if self.env['tmux']: tmux_args = '--run-id {}'.format(self.env['run_id']) - if self.env['emulator'] == 'gem5': - tmux_cmd = './gem5-shell' - else: + if self.env['tmux_program'] == 'shell': + if self.env['emulator'] == 'gem5': + tmux_cmd = './gem5-shell' + else: + raise Exception('--tmux-program is only supported in gem5 currently.') + elif self.env['tmux_program'] == 'gdb': tmux_cmd = './run-gdb' # TODO find a nicer way to forward all those args automatically. # Part of me wants to: https://github.com/jonathanslenders/pymux # but it cannot be used as a library properly it seems, and it is # slower than tmux. - tmux_args += " --arch {} --linux-build-id '{}' --run-id '{}' --userland-build-id '{}'".format( + tmux_args += " --arch {} --emulator '{}' --linux-build-id '{}' --run-id '{}' --userland-build-id '{}'".format( self.env['arch'], + self.env['emulator'], self.env['linux_build_id'], self.env['run_id'], self.env['userland_build_id'],