From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pFMWp-0004kP-7t for mharc-grub-devel@gnu.org; Tue, 10 Jan 2023 16:51:31 -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 1pFMWn-0004kB-Mf for grub-devel@gnu.org; Tue, 10 Jan 2023 16:51:29 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFMWm-0002K8-4p for grub-devel@gnu.org; Tue, 10 Jan 2023 16:51:29 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d3so14632276plr.10 for ; Tue, 10 Jan 2023 13:51:27 -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=EN6Ctp5r3/rmf1D5hhJZelCTxy0ez5/yW/EfBZiQo08=; b=4/WoII7MNKxhuAHWEL2WFh46W5+bf8HCrzl5B+3hPi1n6vyU6pbxwpQTQk4NX3qnm+ GJ7e04hgiovyqOf3Xd3MBLFtZi4ubcOqNCtiNZ31ozisqhNwWKa5zDbnXtPELLZKPXd4 ELAyagCsEH+xE8rJSWdoC0EleX2LT0aYfastfmW5PtzgAwBCwub6bT6GwvQTy/bg3vHT GstRGncncqu46fLilOvAJ3ZtME0ti7PvtHn1yWckqq1TN0ME+3zAtS0wAmgeroaVTn43 UguHbviXaOSJ7tZ46vol81NyAlltWEN219SR5QRLN5WQgvh6rWtG2NpKiPyrtuqAzgzt yxqw== 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=EN6Ctp5r3/rmf1D5hhJZelCTxy0ez5/yW/EfBZiQo08=; b=x7ysMxQEBJzd39/VhSZZfJWpHO3A8tMohCiyxlfKjzWF/ItKUwJoma0C50Fvloht7s tMvgaIUCNqJ5rW22k8R+Ril/Q6fWh9PpR6fLq4gYWqzPdy8cgOlXZ5nNXbsZ+XlkXKj8 M7GIA6LQd9xesEVcD3jgrRJL0+0HF02TDbj84GeZF91aNZryOzbs+BcWrvowCW00dyN+ R7nhj+7xVk0GPKArj9L1HsqOeV8HjoiwBFSSEW1OktycpKSgBEmtEvvRo+F2HNeBkBBI YzUuLjNGfcAFQcbOGhttoa2WTqhNEVaCi1mtROBA+Lq8tACQKzPGgDxVCEL4Q7lgiHcP I/Dw== X-Gm-Message-State: AFqh2kpnMlIXYktjRC6+1Axf/7UN6eQmXYzw8SAuVDCkDIruppDUSneI rkFj1D98coXkPKjFLodT+pXbKvassRSGgPR+ X-Google-Smtp-Source: AMrXdXukN5R9ns77HnD3sLCLkbwUN4NG6h94JPWLXgkDbX93Pi0kFJBQLRNEKnYlfYuMFaJkolB6Ag== X-Received: by 2002:a17:902:7609:b0:194:4548:29f0 with SMTP id k9-20020a170902760900b00194454829f0mr2291712pll.68.1673387486944; Tue, 10 Jan 2023 13:51:26 -0800 (PST) Received: from crass-HP-ZBook-15-G2.lan ([199.254.238.56]) by smtp.gmail.com with ESMTPSA id u15-20020a1709026e0f00b00186c3af9644sm7760798plk.273.2023.01.10.13.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 13:51:26 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Robbie Harwood , Peter Jones , Glenn Washburn Subject: [PATCH v6 10/14] gdb: Allow running user-defined commands at GRUB start Date: Tue, 10 Jan 2023 15:50:37 -0600 Message-Id: <20230110215041.1247699-11-development@efficientek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230110215041.1247699-1-development@efficientek.com> References: <20230110215041.1247699-1-development@efficientek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=development@efficientek.com; helo=mail-pl1-x62f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Tue, 10 Jan 2023 21:51:29 -0000 A new command, run_on_start, for things to do when just before GRUB starts executing. Currently, this is setting up the loading of module symbols as they are loaded and allowing user-defined script to be run if a command named "onstart" exists. A thbreak, temporary hardware breakpoint, is used because a software breakpoint would be overwritten when the firmware loads the GRUB image into memory. And it should be temporary in order to have as many of the limited hardware breakpoints available to the user as possible. Signed-off-by: Glenn Washburn --- grub-core/gdb_grub.in | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/grub-core/gdb_grub.in b/grub-core/gdb_grub.in index 18ce6b0eb2..281dfb5927 100644 --- a/grub-core/gdb_grub.in +++ b/grub-core/gdb_grub.in @@ -15,6 +15,8 @@ source gdb_helper.py 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. @@ -54,6 +56,33 @@ 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. + thbreak _start + commands + silent + + runtime_load_module + + if $is_user_command("onstart") + onstart + end + 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 @@ -71,6 +100,7 @@ if ! $runonce exec-file kernel.exec else file kernel.exec + run_on_start runtime_load_module end -- 2.34.1