From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p5iNU-0007Wj-Fd for mharc-grub-devel@gnu.org; Thu, 15 Dec 2022 02:10:00 -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 1p5iNT-0007WZ-2q for grub-devel@gnu.org; Thu, 15 Dec 2022 02:09:59 -0500 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5iNR-00083X-LV for grub-devel@gnu.org; Thu, 15 Dec 2022 02:09:58 -0500 Received: by mail-qt1-x834.google.com with SMTP id ay32so4468666qtb.11 for ; Wed, 14 Dec 2022 23:09:57 -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=L+tjG9jkG7WB35hodmUWzTx+d4qy33/imrNEM8lISKI=; b=LPR/mUrF6i3XoKbPoJ99esmRRhEREZNHkqOtiDKTSLlyNqe3e7fs2v7VzXR0vYFVC0 j1DA0ERzn9cRsJHfgZ2KUXWOAX/EoMzlBNVMHNozTOE1Drg6qQuWCd/W3L8fZYnxMO4q aRCcM0bbwGBtmMWFIpTLf94Ggcwgf7beWIkMlNHREUTj33mRAbuO674gXPWsDZ4ZJBRW xkkflgFblusIOVNWT1y42EMbuxd6G5Do1RwDMSmw1Rpd1kOBqJA9cmV+mYslICBsUKCy 5ZCx0vuHEaycokS6e0OHXDortXUgqpMlZcqiTkA9d7v4dnRHyrDLf7WZV2x0JwaI+05k 9xMg== 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=L+tjG9jkG7WB35hodmUWzTx+d4qy33/imrNEM8lISKI=; b=kaGpT4o+ChpTGF2HC7WndkdIFF6vKyJ6t2LX2YxtF9il+Ce8Uc9nLAg+yvGmtA7cXz xIQzI5JLWmVuoRSZoNfz5quPra4Uto4XsPGgeBkr5otE+8GUjkd394lv2MONpgow4JgY LPbXnF2zkOl0hoLOOczVpmuHZDEi0X8BgMqv36N9xL/eZ7w2CzDqGnxzvsRTPCpa8sOD 2n+xI+lMnqCokv54yDnzuK5bSE5l2JyPx0VHWJl2876agTeOF8pHWSqUsWYC0C9GlSfP evmjlBlsxnJFJXvIuloRPyrW8T3biWbRnbeZRKrLu4kgMr6pNN7r+9bdc8UhYyryHI3U 5blg== X-Gm-Message-State: ANoB5pmpdO4lX5D8zQPha8BQ82eIVinONGGODSOe3thUaRiz+kCloFy7 GMlz5A8KgIv+/5Y3wUO4xKHAQr93oSPgEt92 X-Google-Smtp-Source: AA0mqf6vJAid3vFHHuiFtKkDvE/XLGjlacoL9NYmbyuso/g3Dh+CzchCVMGRVfxAkD8X/VS+1jKRFg== X-Received: by 2002:ac8:4688:0:b0:3a7:d465:e with SMTP id g8-20020ac84688000000b003a7d465000emr37828940qto.13.1671088196558; Wed, 14 Dec 2022 23:09:56 -0800 (PST) Received: from crass-HP-ZBook-15-G2.lan ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id fy16-20020a05622a5a1000b003a7ec97c882sm3125068qtb.6.2022.12.14.23.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 23:09:55 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v3 12/15] gdb: Allow user defined "onload_" command to be run when module is loaded Date: Thu, 15 Dec 2022 01:07:47 -0600 Message-Id: <20221215070750.102591-13-development@efficientek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221215070750.102591-1-development@efficientek.com> References: <20221215070750.102591-1-development@efficientek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=development@efficientek.com; helo=mail-qt1-x834.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: Thu, 15 Dec 2022 07:09:59 -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 f4243bb718..57152b718f 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