From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p63Jx-0004Ln-No for mharc-grub-devel@gnu.org; Fri, 16 Dec 2022 00:31:45 -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 1p63JN-00042t-KE for grub-devel@gnu.org; Fri, 16 Dec 2022 00:31:14 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p63JE-00049t-3Y for grub-devel@gnu.org; Fri, 16 Dec 2022 00:31:01 -0500 Received: by mail-pj1-x102c.google.com with SMTP id hd14-20020a17090b458e00b0021909875bccso7687166pjb.1 for ; Thu, 15 Dec 2022 21:30:59 -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=ffQ6t23G0/hWVmkPky2O/93+ssX2daH5gN14sogFV5w=; b=PCmtGmxOaLXwbMu34HC/KYKZSIKrxHw8ngrRZJlWFr9b6yX1Su7xn4cAupeP9KGaeK mZbMSeqPmx2rDCh8IlU2zxXCf/D+uVYnu3uTilGrq4My2f6T1n+LgIa/h0eZkJF7iPrC RPnBAjUMvvHr5Mt2BXuRBSr9Wy5eL4ut7m1ObGK/6baF2A6WXm3RA3+J3SQ1eqG3FGBi obYM5/MsmgHY12jNNosf45kZ0NQSoAWYHTP0At7JjFDGcxuNTvQSCxtu4o/q8bU1JuBc kkGmYIM8L8Le9GMvCrjMq7gWIsESpNxE4k8aVDqhsLt+mVc84fySnEheOZW8wZBhm0rQ lTxQ== 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=ffQ6t23G0/hWVmkPky2O/93+ssX2daH5gN14sogFV5w=; b=O+YZi7TUdqac3OWySv5aLrhBupdTu8lDtfaQr4mInv+aNe7aYViCSq6z0zCOzAbDxc g4owgV/vIJgIGkeRxwV/XKkLeDQARWEFkCJTYfv616mDYaHb8iUq7uXWRvpiSlETHbGJ 6jhfqEJLCCocxNniKDUJGad92Fju6iiH3s8FI/CpQVS4wS2hBghpd3tX3csxsksjD03I YuqvdGSDeXu7hz24KL3hpxv1030Q1n2GLO2EvG0kxfqadWBnsKCQbcXpFf0AK6UUIT7C aWDptjpGZe2tL/M+BglLBLsiBADUhvWeK7uDr+6y+vVbeUiYigSY4ro2/UoT1o5ZjwzB V+zw== X-Gm-Message-State: ANoB5pnkN5XFIK104E4h6/nzkeomNpuvesbz13bmKnBmGsTszcKjYVng E5fYroSfOdHJtjM5DcYVdPr3JXDgu/RqXLpR X-Google-Smtp-Source: AA0mqf5iTe7oI0CVTJ88VIhqxDQF6ctvq9w4CBTbXbbFyEpc/nHgy4l4+v24M0MY4IDs5zp0i3kiWw== X-Received: by 2002:a17:902:9b8d:b0:188:caf1:ef65 with SMTP id y13-20020a1709029b8d00b00188caf1ef65mr28849702plp.49.1671168657647; Thu, 15 Dec 2022 21:30:57 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 21:30:56 -0800 (PST) From: Glenn Washburn To: "grub-devel @ gnu . org" , Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v4 11/15] gdb: Allow user defined "onload_" command to be run when module is loaded Date: Thu, 15 Dec 2022 23:29:34 -0600 Message-Id: <20221216052938.224564-12-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::102c; envelope-from=development@efficientek.com; helo=mail-pj1-x102c.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:28 -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 a0c6b1ae07..8ae6344edf 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