From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p63Jt-0004Ii-C5 for mharc-grub-devel@gnu.org; Fri, 16 Dec 2022 00:31:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p63JO-00047V-VJ for grub-devel@gnu.org; Fri, 16 Dec 2022 00:31:25 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p63JI-0004AQ-Pa for grub-devel@gnu.org; Fri, 16 Dec 2022 00:31:09 -0500 Received: by mail-pl1-x62b.google.com with SMTP id w23so1231146ply.12 for ; Thu, 15 Dec 2022 21:31:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XPWklus9aN2iNYEqbe5kXilTjw+QbspPGkD8gAJR8xM=; b=gC4BaeGbjF/U0Ec+KzgdPb5vCVQGmJ44IufGfFLNMOvPICf3hlZnBh7iU9IN/RZfnf czliKPb1nQj90RxK4l2WTWiGsJPNZ9o6Gzwxa0RmPekWmKXUYEOdUjWKCPkpU6OvlpSV Sf3M85EbHfohS958Gac5XeisygsNvDGPKc0LxUsEzsuOE8HvLwLL0XbG/ePTsuor3RMs 7dCk1fUOMbjZ4SyQHCZGOcbYjBpL8x8TGtD+KAKh2H5rlxYqbtRKVeTeTvzPAB6V3fC4 Ep9Xp+ZXxd4EftTkx7jn1c3RA/Rtr4uC6m8wxWT+WAKMyy9zzv7J+ibaV3kpbkfJeIHo Uefw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XPWklus9aN2iNYEqbe5kXilTjw+QbspPGkD8gAJR8xM=; b=BtW4o+jWI1C8xFq46LhKGrw/LtwMTjlZlQBsw9v5g2ocEyT/hEfgo7AUdrQn6+7YPr Yym6V42shwYcYFGJucY1+AftI4254QZzx+6VPC9S0lRolpl2ZezwiT2i3EySNgk9mH+S d0JJWb6MQseK+SEOVqemQPzAlQoK7V8qVpOT25w/iX+Q7KCvBEBw1kDhPkWnJsP9/tyf ULq4F9AuYEV7XNA7IcKjPDuiJJjc3U8kJ87yivNPIRec8eAimjB/MBqCwdMuxxVQeSO4 Ed1jGIu5XuTZF7KSh89UGEVL/LQQNzSLy8vaABCa6MdTn4AWWkrAuQGcphyw9TkMLUtL YNYg== X-Gm-Message-State: ANoB5pmuQjXjkS6ml158furywrlphW7PdBLQR2csWg96p8iftOS+XWrY qXbOwnWwFC4tFpLElkI6AWpw0xIvN6uQ1S3b X-Google-Smtp-Source: AA0mqf6/gTLUqTKVvpI6vme853XPfEpBjBm2g6XVE7nOsm3FOM3/Vx9LHACjEsFoMVuy449X7Rfzig== X-Received: by 2002:a17:902:a611:b0:188:92ee:e73 with SMTP id u17-20020a170902a61100b0018892ee0e73mr29186654plq.13.1671168662885; Thu, 15 Dec 2022 21:31:02 -0800 (PST) Received: from crass-HP-ZBook-15-G2.lan ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id u4-20020a17090341c400b00187033cac81sm577714ple.145.2022.12.15.21.30.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 21:31:02 -0800 (PST) From: Glenn Washburn To: "grub-devel @ gnu . org" , Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v4 12/15] gdb: Allow running user-defined commands at GRUB start Date: Thu, 15 Dec 2022 23:29:35 -0600 Message-Id: <20221216052938.224564-13-development@efficientek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221216052938.224564-1-development@efficientek.com> References: <20221216052938.224564-1-development@efficientek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=development@efficientek.com; helo=mail-pl1-x62b.google.com X-Spam_score_int: 14 X-Spam_score: 1.4 X-Spam_bar: + X-Spam_report: (1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2022 05:31:30 -0000 A new command, run_on_start, is created which handles some complexities of the EFI platform when breaking on GRUB start. If GRUB start is hooked, run "onstart" command if it is defned. Signed-off-by: Glenn Washburn --- grub-core/gdb_grub.in | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/grub-core/gdb_grub.in b/grub-core/gdb_grub.in index 8ae6344edf..3b3cea1a4d 100644 --- a/grub-core/gdb_grub.in +++ b/grub-core/gdb_grub.in @@ -36,6 +36,8 @@ end define dynamic_load_symbols dynamic_load_kernel_exec_symbols $arg0 + run_on_start + # We may have been very late to loading the kernel.exec symbols and # and modules may already be loaded. So load symbols for any already # loaded. @@ -134,6 +136,41 @@ document runtime_load_module Load module symbols at runtime as they are loaded. end +define run_on_start + # TODO: Add check to see if _start symbol is defined, if not, then + # the symbols have not yet been loaded and this command will not work. + watch *_start + set $break_efi_start_bpnum = $bpnum + commands + silent + delete $break_efi_start_bpnum + break _start + commands + silent + delete $break_efi_start_bpnum + set $onstart_name = "onstart" + is_user_command $onstart_name + if $ret + onstart + end + continue + end + set $break_efi_start_bpnum = $bpnum + continue + end +end +document run_on_start + On some targets, such as x86_64-efi, even if you know where the + firmware will load the grub image, you can not simply set a break + point before the image is loaded because loading the image + overwrites the break point in memory. So setup a hardware watch + point, which does not have that problem, and if that gets triggered, + then reset the break point. If a user-defined command named + "onstart" exists it will be run after the start is hit. + NOTE: This assumes symbols have already been correctly loaded for + the EFI application. +end + ### set confirm off @@ -151,6 +188,7 @@ if ! $runonce exec-file kernel.exec else file kernel.exec + run_on_start runtime_load_module end -- 2.34.1