From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pFMWR-0004XF-Oh for mharc-grub-devel@gnu.org; Tue, 10 Jan 2023 16:51:07 -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 1pFMWP-0004Q4-Sf for grub-devel@gnu.org; Tue, 10 Jan 2023 16:51:05 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFMWO-0002KW-7w for grub-devel@gnu.org; Tue, 10 Jan 2023 16:51:05 -0500 Received: by mail-pl1-x634.google.com with SMTP id 17so14699197pll.0 for ; Tue, 10 Jan 2023 13:51:03 -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=GXw5wf/yT72A4uDonLE/cwNduJOjNcf34xKAO5OuGUUw/F4kJSk/4RTtujL8ZqKkPv OTzVQ4J2N8LDfQW2GSzbSAdcCKLtrDEEjxzOKKyfkiAL6nAjH6vr+SWo/vg3K11Pq26r Y8Jydbm0FW6kUo/zJzs5fpTf+uxnSN6dFOMrwsI5sUVHJzltguL525bIECfIkE0qTm4L 2ol+kZRigT6cQtK9CbmhrRXXRsGqOpS69iavwF2xnZXtham/n+KaPp2o5iVExFHUnaBC xsbU+sae3JPgikYyzoEKmuSTulQWfZBqoO12OGYpoH/mUtxlN9Lggy0k75YUeKHqbOpU //gA== 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=PEr/zmfUjncxfSWiyHcdUmPFLGCBMXNNhrtrEIYdpamYpAb6N9Huue/xh/YRadtFTE oK7lXq0pizqo7SIM5rxmf4Lc3oFe4lcKdReFmv+zB/oF4AFN1cvxepDfR6goi35lJf3T GYl0bBsPpG+jyePISljCdqkg9v46SlOfiqw1OSqeI00soOu6Pq5xIcpSCBtZmDymJYc0 bbSzVpWqYVnDHQbgV3Rh/Ele3YUBSACiEolQ3K3dNpqxQxG6NdkbSv9/B6Sc5p9qtQxT 6WUngbX5Z5KyVP1OWuQd0m/mDoKxh1CMQN4dC4oZBcQzH/FJyH5JkPMW3id+jkXMyzVD u0Nw== X-Gm-Message-State: AFqh2krk1md/OSn5FPiVePJbqs4tpJqNZR5opC19TDcY1mcku0pW0t1C TE8kpnpfYmVUU4svay+qit+YldY1m4fsmANM X-Google-Smtp-Source: AMrXdXsV3akOuwu9YbQqvm2uGWApf/Lhctix+/gDAgTnOLhSkRKOlVdhUBRffTU8pKFI/CpLGH5L2w== X-Received: by 2002:a17:902:ecc1:b0:192:760f:c35e with SMTP id a1-20020a170902ecc100b00192760fc35emr75462364plh.53.1673387462324; Tue, 10 Jan 2023 13:51:02 -0800 (PST) Received: from crass-HP-ZBook-15-G2.lan ([199.254.238.56]) by smtp.gmail.com with ESMTPSA id u15-20020a1709026e0f00b00186c3af9644sm7760798plk.273.2023.01.10.13.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 13:51:01 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Robbie Harwood , Peter Jones , Glenn Washburn Subject: [PATCH v6 01/14] gdb: Fix redirection issue in dump_module_sections Date: Tue, 10 Jan 2023 15:50:28 -0600 Message-Id: <20230110215041.1247699-2-development@efficientek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230110215041.1247699-1-development@efficientek.com> References: <20230110215041.1247699-1-development@efficientek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=development@efficientek.com; helo=mail-pl1-x634.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: Tue, 10 Jan 2023 21:51:06 -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