From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p8w1K-0002r8-9X for mharc-grub-devel@gnu.org; Fri, 23 Dec 2022 23:20:26 -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 1p8w1I-0002qZ-QO for grub-devel@gnu.org; Fri, 23 Dec 2022 23:20:24 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p8w1H-0000YP-1e for grub-devel@gnu.org; Fri, 23 Dec 2022 23:20:24 -0500 Received: by mail-pf1-x432.google.com with SMTP id t18so4378464pfq.13 for ; Fri, 23 Dec 2022 20:20:20 -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=7WgdgjxzbWezsJ0Q2ejbQ4EmVmPz+AxK2eJxd5BcRgOs7hO+RoFOw69LlXnr02x+D2 AqgaE5YkeWRB3FXuaBoyFfiNitYAK6P+HW3JB3tGjtaUQ4xPAy9IfOkrwL1RW1vz9Tyu Wu1GUiI2yw0XiFAVkEvBjT6IxY9KZi2sPlRnBNVMrfKkU7bmVCQzHCzGPcYeJXjVVPR7 wb7KkBa7WNLyiLlf7AlThgPG+AE7cZjM+fv+DWU+9aqURD/IBQRuBWfk/YfScA/hRS7P TKdEVZifJcmm2D0PYw7CUIsP0oIDywBBQEavCtWflD6lFrv76gl5X5uh7vY0OWcm43Wz qN2Q== 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=oy5QHMXQ/5p0kjl9d5StwOPEtTdGBNDnS2AEB/tXvfVXbdJZ+QReK6r6Eu2Bku4GkR 4X9NUMz/pJMCSkLYJXL19BelascTtu3YKrdP6r3B6YqjKnck3xGYgKtDElX2KTz+UvIs SVmuLbm1KoJ7RMwAPGB9DslbyMLTrfJWwTTipI763kqeU/PSU3qCR4PURmdrcWXcfpOA NaPj55eaNHxPwgIE7Qe1vyekv5CrplyzWgmwXh42wPvgHVRgoyaAxA5HkZK9J7YBBHmQ Kum3dvcCmViCHCcOhS5KsLJi7EQh237wVP0cHMTE5pHCYbqAuYM6n8QaXjh6cZZo1tUE 1qIA== X-Gm-Message-State: AFqh2kofPGRhbr0A8W7krGF2jHXST1I6YVDiToWQeAx/eOt99/hcxBit l0/fnu1+Up3eZAZmHdVnLM8kbtfFpsieGAKo X-Google-Smtp-Source: AMrXdXupWaGkAFN0w4UKIUTD8vNApWiqrqNBX56cKlFeeBIy6xLsgX2b4PKzceH/qsp5EYE7Lf6gww== X-Received: by 2002:a62:65c3:0:b0:566:900d:6073 with SMTP id z186-20020a6265c3000000b00566900d6073mr12301410pfb.24.1671855618775; Fri, 23 Dec 2022 20:20:18 -0800 (PST) Received: from localhost.localdomain ([204.13.164.84]) by smtp.gmail.com with ESMTPSA id x19-20020aa79413000000b005743b5ebd7csm3324185pfo.92.2022.12.23.20.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Dec 2022 20:20:17 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Robbie Harwood , Peter Jones , Glenn Washburn Subject: [PATCH v5 10/14] gdb: Allow running user-defined commands at GRUB start Date: Fri, 23 Dec 2022 22:19:31 -0600 Message-Id: <20221224041935.787292-11-development@efficientek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221224041935.787292-1-development@efficientek.com> References: <20221224041935.787292-1-development@efficientek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=development@efficientek.com; helo=mail-pf1-x432.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: Sat, 24 Dec 2022 04:20:25 -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