From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1npeTY-0007cp-Ht for mharc-grub-devel@gnu.org; Fri, 13 May 2022 19:13:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npeTX-0007XL-72 for grub-devel@gnu.org; Fri, 13 May 2022 19:13:35 -0400 Received: from mail-vs1-xe36.google.com ([2607:f8b0:4864:20::e36]:42656) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1npeTV-0007Tb-GS for grub-devel@gnu.org; Fri, 13 May 2022 19:13:34 -0400 Received: by mail-vs1-xe36.google.com with SMTP id i186so9879333vsc.9 for ; Fri, 13 May 2022 16:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GRl87JcVzQ1GVvZiKhEcJrT66ckY6i9tpwlRdQUOeL4=; b=SPI5uLHKuni8Lh478n+UiwMadUSCUlz5X4IQqXRswPZIKrHrui1rP+v7u3t4PP15c1 AwDo/I0R+JsDz73dOsWUWzOX23IE+SucZMwMofYrp73rlv1yUkxK1tRwholmMpnyMRO7 0sTy2KFbVXwsQjQj2V59QT9H1Nebn6VPFzwAmsTBAZhJTzsr7B9OQ6ZOGAtTM7xj0kOv Kswv0zRnR4HhFQcICapS973O4YnPq+NOt1O/36MLC/goz/YS8Xaa5esO4nKaXutdwWvB 5G5Apn3sJDgZHvTloTnv/ZAv+k3XjLduJbxuHsHho7RoyBk4q4hPI/hABj0QP3ALL8JZ hJqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GRl87JcVzQ1GVvZiKhEcJrT66ckY6i9tpwlRdQUOeL4=; b=cPUq1R49lCmvNtPlDhvqLL3CIN6dXGzCzLFxQoNgbmTdLmddWL4K3bxFzIQuzF5AFV zw0dLjtyFwqH9QQebtudq02Z5acB90QY3QVeqoesdsr+qQKajG482R7nlMCPwMSCGhVo 89qcosGfPNHXp9mldqvAxI38hsXERrcT0l8UVEWiA8LonsSfgON2zVvY/6w4DXBijvpl 4puaQjgrbV3LQKAGagNArRdOaaAYiNfbfCuYNc3Gx0LmMcXhqby42uE8vXDOqXyOFVqb +DrQa3wwOqluDFSUkKGr4qOqr/ZjWQQLjB7k+zrXtrT8VBUKA8Q3HIp13eD3fpqOpCZY fqfg== X-Gm-Message-State: AOAM531RkbRoT9zTEn5jh9IN8RGA7wXcgBT1xCIecuxf+MuoNjcyi+O9 kHCGJ6j2xzEAnrwMmisnIbT5f2kwKkF6Y/ty X-Google-Smtp-Source: ABdhPJy1S+nareikofMxZcOj+nJ3xem+JBGf2gBFtHZjSKf8k1uHURpMeCwnYpfxmvVVadjlMag3xg== X-Received: by 2002:a67:c419:0:b0:32c:ec4b:ec5f with SMTP id c25-20020a67c419000000b0032cec4bec5fmr3076791vsk.11.1652483612457; Fri, 13 May 2022 16:13:32 -0700 (PDT) Received: from localhost.localdomain ([37.218.244.249]) by smtp.gmail.com with ESMTPSA id 129-20020a1f1387000000b0034e6f1fd067sm423865vkt.49.2022.05.13.16.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 16:13:31 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Peter Jones , Robbie Harwood , Glenn Washburn Subject: [PATCH v2 12/15] gdb: Allow user defined "onload_" command to be run when module is loaded Date: Fri, 13 May 2022 18:12:45 -0500 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::e36; envelope-from=development@efficientek.com; helo=mail-vs1-xe36.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, T_SCC_BODY_TEXT_LINE=-0.01 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: Fri, 13 May 2022 23:13:35 -0000 When debugging a module it can be desirable to set break points on code in the module. This is difficult in GRUB because, at GDB start, the module is not loaded and on EFI platforms its not known ahead of time where the module will be loaded. So allow users to create an "onload_" command which will be run when the module with name "modname" is loaded. Create new command "is_user_command" which sets $ret to true value if the first argument is the name of a user-defined command. Signed-off-by: Glenn Washburn --- grub-core/gdb_grub.in | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/grub-core/gdb_grub.in b/grub-core/gdb_grub.in index f4243bb71..57152b718 100644 --- a/grub-core/gdb_grub.in +++ b/grub-core/gdb_grub.in @@ -9,6 +9,20 @@ ### Lubomir Kundrak ### +define is_user_command + eval "pipe help user-defined | grep -q '%s'", $arg0 + set $ret = ! $_shell_exitcode +end +document is_user_command + Set $ret to true value if first argument is the name of a user-defined + command. +end + +define is_onload_command + eval "set $is_onload_command_name = \"onload_%s\"", $arg0 + is_user_command $is_onload_command_name +end + define dynamic_load_kernel_exec_symbols shell rm -f .remove-kernel.exec.symfile.gdb shell sh gdb_helper.sh gen_kernel_exec_loadsym $arg0 >.kernel.exec.loadsym.gdb @@ -76,8 +90,18 @@ end ### define load_module + set $load_module_onload_cmd = "" + is_onload_command $arg0->name + if $ret + eval "set $load_module_onload_cmd = \"onload_%s (grub_dl_t)%p\"", $arg0->name, $arg0 + end + dump_module_sections $arg0 match_and_load_symbols + + if ! $_streq($load_module_onload_cmd, "") + eval "%s", $load_module_onload_cmd + end end document load_module Load debugging information for module given as argument. -- 2.34.1