From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p8w15-0002lj-Li for mharc-grub-devel@gnu.org; Fri, 23 Dec 2022 23:20:11 -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 1p8w0y-0002km-Bi for grub-devel@gnu.org; Fri, 23 Dec 2022 23:20:04 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p8w0w-0008Sc-F6 for grub-devel@gnu.org; Fri, 23 Dec 2022 23:20:03 -0500 Received: by mail-pj1-x102b.google.com with SMTP id k88-20020a17090a4ce100b00219d0b857bcso6554245pjh.1 for ; Fri, 23 Dec 2022 20:20:02 -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=iwCTdfFtZopmRlDmv2YuXRBdiO0FMAje5li4Ft6A6GQ=; b=uYaGRuyENKHKzj15X/hVtGUjN/xVnrgaxMDMy5h5mr2d1+V94VFoqCsZrbYAHBFflz 5Yr+Dla4ps5LimdwlU+npNuxR0XlDy9lgg/VOK657BnnoUzQULd1D/gHzIypLt9VS3b5 8eQGVnmKm/equf3IoRBrjeB1dWwySQdWILZxmuHluka1/N+54RE5s7GzBHPx8O9GiX+C TsRbbtZotJWA9lhGBpS7vFxpdQy8t+aRNxkAJgsh5PW0xFtDzoZMKO7qLycaxBQbHHwD EKXKNhWKmwGrKUtUM39kyLWCSxAWE/XyEQDZUgPWNBDDZXzP7YhGOwd4GDb3aYkhkVgs HWAQ== 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=iwCTdfFtZopmRlDmv2YuXRBdiO0FMAje5li4Ft6A6GQ=; b=HdbQVpPYKkLmjO8gsDqUuDJOYcKmzCqTXxKvv656/nleZzOwAxRmTI75Ugh0SNiDmZ 8kSW6KEmuhBV7s/OddF/Mv3XeedEY/y9r8QkkgyUV659OkbKlDJnAysEP7Qo1EQp8a56 TnCrp6WTebjVDVaWHvJ7/kiqvnLU4bqHeztGRmd1i3QBTVq5IxtetC3sI5Y+89r8VU6l wZh1B2/jqtdCzv8ULv7M6gGBsh50e+VF5gJWR6xi7aemG76yO98lVe2o6xdEpxD5wy96 ZD47CkZQ7LwUV/m254AYz5W7teWmTspj6b+E4IinzBHP9iF5B2awxzZ2f26wDASlwWkU CYKA== X-Gm-Message-State: AFqh2kri63nCTBKgQ4GeaBzYICsBzS3UW21oPXXpMRsVbrYx2uLfX0uo aKGPoM/oTawarq4d9bMnWuKAHOo+e1/B9eqC X-Google-Smtp-Source: AMrXdXsJ2S52b388KuCl9EtjAQpetv6V9Q6ukrl5bbg+49V+BILnLeImHsfBIZmWnl56dC1prDG4zw== X-Received: by 2002:a05:6a20:4c20:b0:b0:c30:1de with SMTP id fm32-20020a056a204c2000b000b00c3001demr12717610pzb.61.1671855600257; Fri, 23 Dec 2022 20:20:00 -0800 (PST) Received: from localhost.localdomain ([204.13.164.84]) by smtp.gmail.com with ESMTPSA id x19-20020aa79413000000b005743b5ebd7csm3324185pfo.92.2022.12.23.20.19.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Dec 2022 20:19:59 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Robbie Harwood , Peter Jones , Glenn Washburn Subject: [PATCH v5 01/14] gdb: Fix redirection issue in dump_module_sections Date: Fri, 23 Dec 2022 22:19:22 -0600 Message-Id: <20221224041935.787292-2-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::102b; envelope-from=development@efficientek.com; helo=mail-pj1-x102b.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:04 -0000 An error in any GDB command causes it to immediately abort with an error, this includes any command that calls that command. This leads to an issue in dump_module_sections where an error causes the command to exit without turning off file redirection. The user then ends up with a GDB command line where commands output nothing to the console. Instead do the work of dump_module_sections in the command dump_module_sections_helper and run the command using GDB's pipe command which does the redirection and undoes the redirection when it finishes regardless of any errors in the command. Also, remove .segments.tmp file prior to loading modules in case one was left from a previous run. Signed-off-by: Glenn Washburn --- grub-core/gdb_grub.in | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/grub-core/gdb_grub.in b/grub-core/gdb_grub.in index e322d3dc10..4e45ad5622 100644 --- a/grub-core/gdb_grub.in +++ b/grub-core/gdb_grub.in @@ -10,15 +10,8 @@ ### # Add section numbers and addresses to .segments.tmp -define dump_module_sections +define dump_module_sections_helper set $mod = $arg0 - - # FIXME: save logging status - set logging file .segments.tmp - set logging redirect on - set logging overwrite off - set logging on - printf "%s", $mod->name set $segment = $mod->segment while ($segment) @@ -26,9 +19,10 @@ define dump_module_sections set $segment = $segment->next end printf "\n" +end - set logging off - # FIXME: restore logging status +define dump_module_sections + pipe dump_module_sections_helper $arg0 | sh -c 'cat >>.segments.tmp' end document dump_module_sections Gather information about module whose mod structure was @@ -59,6 +53,7 @@ document load_module end define load_all_modules + shell rm -f .segments.tmp set $this = grub_dl_head while ($this != 0) dump_module_sections $this -- 2.34.1