From fa50ed35f9e440d334eb6da8a44023a4561f380c Mon Sep 17 00:00:00 2001 From: Reset816 Date: Sat, 27 Apr 2024 17:33:17 +0000 Subject: [PATCH] debug: use tmux in debugging Using tmux to facilitate user-friendly Linux kernel debugging in the CLI. Signed-off-by: Reset816 --- .labbegin | 7 +++++++ Makefile | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.labbegin b/.labbegin index cf295bd..e8621c6 100644 --- a/.labbegin +++ b/.labbegin @@ -32,6 +32,13 @@ ifneq ($(QEMU),) endif endif +# With tmux, the Linux kernel can be debugged in the CLI +ifneq ($(findstring debug,$(firstword $(MAKECMDGOALS)))),) + ifeq ($(wildcard /usr/bin/tmux),) + PKGS += tmux + endif +endif + # gcc 4.3 must work with 2.24 binutils (ld), otherwise, the kernel compiled not boot # LS is a predefined variable, use LDT (ld tool) instead here ifeq ($(CCORI),internal) diff --git a/Makefile b/Makefile index c75bf67..075c865 100644 --- a/Makefile +++ b/Makefile @@ -4607,7 +4607,7 @@ ifneq ($(DEBUG),0) # Debug listen on a unqiue port, should run exclusively DEBUG_LOCK := $(GDBINIT_DIR)/.lock KEEP_UNIQUE := flock -n -x $(DEBUG_LOCK) - RUN_BOOT_CMD := $(KEEP_UNIQUE) $(BOOT_CMD) || $(GDB_CMD) + RUN_BOOT_CMD := tmux new-session -d '$(KEEP_UNIQUE) $(BOOT_CMD)' \; split-window -h '$(GDB_CMD)' \; attach else RUN_BOOT_CMD := $(BOOT_CMD) endif -- Gitee