Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1npeTB-0006Yv-FT for mharc-grub-devel@gnu.org; Fri, 13 May 2022 19:13:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npeT8-0006Wd-RB for grub-devel@gnu.org; Fri, 13 May 2022 19:13:10 -0400 Received: from mail-ua1-x92e.google.com ([2607:f8b0:4864:20::92e]:45575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1npeT7-0007P2-9i for grub-devel@gnu.org; Fri, 13 May 2022 19:13:10 -0400 Received: by mail-ua1-x92e.google.com with SMTP id n8so466977uaj.12 for ; Fri, 13 May 2022 16:13:08 -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=o8TR/0WS9f3qeM7t+mcScXkrSPfVdYpomYTZeWaxmE0=; b=Wu17OzS909dLF7SgJr6iZuuLxL7HUzeaTOAaCsttDdK5lbEL7xlYVQhtshoRA/MUbv jMkY4p6gD5+yls6BZa6BuQUVilwVxYG4vevOnF6aveY4LKNxvb5i7iNFTTDBIjfTLXHC z6MnbjG2Bt73XM+1p70900nM8y/bBATCIfy+AMr8oTsHx1RtkgZZ+C8VMc0c9egjPPk8 yOjjdhIOGIwEHydFIb/Zq4fwK1NnLOFtk5QVl2W4aClMHr3brUlpfDUMwnLYeRMvJCAs E75/+b960M4SNePmHUugZNSE8W0kJBt7M9RDRBN4mEWSS0VhH3kG6ehrZm1uGmFC8ED3 ALXw== 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=o8TR/0WS9f3qeM7t+mcScXkrSPfVdYpomYTZeWaxmE0=; b=TG06NiSFfYxcd9C12DAUOyT54O9KJLeAxzMMInM6bRz5FXyE3ZsQ7eP/1nt+xIk6GB QlAiP7rsHRQyL+LXYUI6ipZYafh0V+PtIafa5ECyVXsFSNb6k1McIYtoJZtyy2UNhd1n CeqevTeB0gxLnVlFpdsZyVdxlQOTH2EalT2LmdT3YwGqkr3BbnzJAjS+TBTHeKo+PcSP efSrTLF68iKoog86jIWC7uyI2oWBPTYTSKvDcgY407PNUUPbEhlM+HkJBcQszAlpBs41 oz0k9jrJaUv9UW3fzyOHLdD9GexFsG0sgB0gRPYE9ZjWHvcpNLuQASvYlVBQRNU0DmnN Fixw== X-Gm-Message-State: AOAM531sh86mdakXt6g2N6RFAuBo72JcHMTlh2phN0gLWW1+5lL4Ydon azc606V6VTqVJc7HqHwFY7cbUiIC3sePX3HH X-Google-Smtp-Source: ABdhPJyM8uVxYydXKYaM1qbg4y5JLIzf+Gp3H89Sewd+7ro1ZGpl2loaQykYpC/o8A+ph28iNZeHdg== X-Received: by 2002:ab0:7290:0:b0:34b:71ac:96c2 with SMTP id w16-20020ab07290000000b0034b71ac96c2mr3221934uao.102.1652483588170; Fri, 13 May 2022 16:13:08 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 16:13:07 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Peter Jones , Robbie Harwood , Glenn Washburn Subject: [PATCH v2 01/15] gdb: Fix redirection issue in dump_module_sections Date: Fri, 13 May 2022 18:12:34 -0500 Message-Id: <1cc0b2564f8faf473ab8ad49f03ee7d4b4e6b2ec.1652482822.git.development@efficientek.com> 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::92e; envelope-from=development@efficientek.com; helo=mail-ua1-x92e.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:11 -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. Signed-off-by: Glenn Washburn --- grub-core/gdb_grub.in | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/grub-core/gdb_grub.in b/grub-core/gdb_grub.in index e322d3dc1..bdf743f0d 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 -- 2.34.1