Skip to content

Commit 2b10066

Browse files
committed
run: forward --userland and --baremetal to tmux! It's just beautiful.
1 parent 7816f1f commit 2b10066

File tree

2 files changed

+53
-44
lines changed

2 files changed

+53
-44
lines changed

README.adoc

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,11 +2900,11 @@ The target Linux kernel of the executable is a GCC toolchain build-time configur
29002900
First let's run a dynamically linked executable built with the Buildroot toolchain:
29012901

29022902
....
2903-
./build-qemu --arch arm --userland
2904-
./build-userland --arch arm
2905-
./build-buildroot --arch arm
2903+
./build-qemu --arch aarch64 --userland
2904+
./build-userland --arch aarch64
2905+
./build-buildroot --arch aarch64
29062906
./run \
2907-
--arch arm \
2907+
--arch aarch64 \
29082908
--userland print_argv \
29092909
-- \
29102910
asdf qwer \
@@ -2923,12 +2923,12 @@ You can also try statically linked executables with:
29232923

29242924
....
29252925
./build-userland \
2926-
--arch arm \
2926+
--arch aarch64 \
29272927
--make-args='CCFLAGS_EXTRA=-static' \
29282928
--userland-build-id static \
29292929
;
29302930
./run \
2931-
--arch arm \
2931+
--arch aarch64 \
29322932
--userland-build-id static \
29332933
--userland print_argv \
29342934
-- \
@@ -2940,13 +2940,13 @@ Or you can run statically linked built by the host packaged toolchain with:
29402940

29412941
....
29422942
./build-userland \
2943-
--arch arm \
2943+
--arch aarch64 \
29442944
--host \
29452945
--make-args='-B CFLAGS_EXTRA=-static' \
29462946
--userland-build-id host-static \
29472947
;
29482948
./run \
2949-
--arch arm \
2949+
--arch aarch64 \
29502950
--userland-build-id host-static \
29512951
--userland print_argv \
29522952
-- \
@@ -2962,9 +2962,9 @@ It's nice when <<gdb,the obvious>> just works, right?
29622962

29632963
....
29642964
./run \
2965-
--arch arm \
2966-
--wait-gdb \
2965+
--arch aarch64 \
29672966
--userland print_argv \
2967+
--wait-gdb \
29682968
-- \
29692969
asdf qwer \
29702970
;
@@ -2974,13 +2974,26 @@ and on another shell:
29742974

29752975
....
29762976
./run-gdb \
2977-
--arch arm \
2977+
--arch aarch64 \
29782978
--userland print_argv \
29792979
main \
29802980
;
29812981
....
29822982

2983-
or to stop at the very first instruction of a freestanding program, just use `--no-continue` TODO example.
2983+
Or alternatively, if you are using <<tmux>>, do everything in one go with:
2984+
2985+
....
2986+
./run \
2987+
--arch aarch64 \
2988+
--userland print_argv \
2989+
--tmux=main \
2990+
--wait-gdb \
2991+
-- \
2992+
asdf qwer \
2993+
;
2994+
....
2995+
2996+
To stop at the very first instruction of a freestanding program, just use `--no-continue` TODO example.
29842997

29852998
=== gem5 syscall emulation mode
29862999

@@ -10231,40 +10244,32 @@ For example, on the first shell:
1023110244
then on the second shell:
1023210245

1023310246
....
10234-
./run-gdb --arch arm --baremetal interactive/prompt --no-continue
10247+
./run-gdb --arch arm --baremetal interactive/prompt -- main
1023510248
....
1023610249

10237-
and now we are left at the very first executed instruction of our tiny <<baremetal-bootloaders>>.
10238-
10239-
Then just use `stepi` to when jumping into main to go to the C code in link:baremetal/interactive/prompt.c[].
10240-
10241-
You can also find executables that don't use the bootloader at all under `baremetal/arch/<arch>/no_bootloader/*.S`, e.g.:
10250+
Or if you are a <<tmux,tmux pro>>, do everything in one go with:
1024210251

1024310252
....
10244-
./run --arch arm --baremetal arch/arm/no_bootloader/semihost_exit --wait-gdb
10253+
./run --arch arm --baremetal interactive/prompt --wait-gdb --tmux=main
1024510254
....
1024610255

10247-
The cool thing about those examples is that you start at the very first instruction of your program, which gives more control.
10248-
10249-
Alternatively, skip directly to the C program main function with:
10256+
Alternatively, to start from the very first executed instruction of our tiny <<baremetal-bootloaders>>:
1025010257

1025110258
....
10252-
./run-gdb --arch arm --baremetal interactive/prompt main
10259+
./run --arch arm --baremetal interactive/prompt --wait-gdb --tmux=--no-continue
1025310260
....
1025410261

10255-
and then proceed as usual:
10262+
Now you can just `stepi` to when jumping into main to go to the C code in link:baremetal/interactive/prompt.c[].
1025610263

10257-
....
10258-
./run --arch arm --baremetal interactive/prompt --wait-gdb --gem5
10259-
....
10260-
10261-
and on another shell:
10264+
This is specially interesting for the executables that don't use the bootloader from under `baremetal/arch/<arch>/no_bootloader/*.S`, e.g.:
1026210265

1026310266
....
10264-
./run-gdb --arch arm --baremetal interactive/prompt --gem5 --no-continue
10267+
./run --arch arm --baremetal arch/arm/no_bootloader/semihost_exit --wait-gdb --tmux=--no-continue
1026510268
....
1026610269

10267-
`aarch64` GDB step debug is broken as mentioned at: <<gem5-gdb-step-debug-kernel-aarch64>>.
10270+
The cool thing about those examples is that you start at the very first instruction of your program, which gives more control.
10271+
10272+
`aarch64` gem5 GDB step debug is broken as mentioned at: <<gem5-gdb-step-debug-kernel-aarch64>>.
1026810273

1026910274
=== Baremetal bootloaders
1027010275

run

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -367,25 +367,29 @@ def main(args, extra_args=None):
367367
if args.baremetal is None:
368368
cmd.extend(append)
369369
if args.tmux is not None:
370+
tmux_args = '--run-id {}'.format(args.run_id)
370371
if common.emulator == 'gem5':
371-
subprocess.Popen([os.path.join(common.root_dir, 'tmu'),
372-
'sleep 2;./gem5-shell -n {} {}' \
373-
.format(args.run_id, args.tmux)
374-
])
372+
tmux_cmd = './gem5-shell'
375373
elif args.wait_gdb:
374+
tmux_cmd = './run-gdb'
376375
# TODO find a nicer way to forward all those args automatically.
377376
# Part of me wants to: https://github.com/jonathanslenders/pymux
378377
# but it cannot be used as a library properly it seems, and it is
379378
# slower than tmux.
380-
subprocess.Popen([os.path.join(common.root_dir, 'tmu'),
381-
"sleep 2;./run-gdb --arch '{}' --linux-build-id '{}' --run-id '{}' {}" \
382-
.format(
383-
args.arch,
384-
args.linux_build_id,
385-
args.run_id,
386-
args.tmux
387-
)
388-
])
379+
tmux_args += " --arch {} --linux-build-id '{}' --run-id '{}'".format(
380+
args.arch,
381+
args.linux_build_id,
382+
args.run_id,
383+
)
384+
if args.baremetal:
385+
tmux_args += " --baremetal '{}'".format(args.baremetal)
386+
if args.userland:
387+
tmux_args += " --userland '{}'".format(args.userland)
388+
tmux_args += ' {}'.format(args.tmux)
389+
subprocess.Popen([
390+
os.path.join(common.root_dir, 'tmu'),
391+
"sleep 2;{} {}".format(tmux_cmd, tmux_args)
392+
])
389393
cmd.extend(extra_emulator_args)
390394
cmd.extend(args.extra_emulator_args)
391395
if debug_vm or args.terminal:

0 commit comments

Comments
 (0)