From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p63IQ-0003IF-9U for mharc-grub-devel@gnu.org; Fri, 16 Dec 2022 00:30:10 -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 1p63IP-0003I7-72 for grub-devel@gnu.org; Fri, 16 Dec 2022 00:30:09 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p63IN-0003mb-Hq for grub-devel@gnu.org; Fri, 16 Dec 2022 00:30:08 -0500 Received: by mail-pj1-x102e.google.com with SMTP id hd14-20020a17090b458e00b0021909875bccso7685834pjb.1 for ; Thu, 15 Dec 2022 21:30:07 -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=yJt4JbnUDOOdrvp8xNRpTGKErvOPWC5K82Czpp6tIv/AvDrhbnK19rYxGAJGWlatXv ujzP3oTdOOvfdhdSGjlpmgWNb8abBC6gY3DjLqsRRnqmlsXb1lWkDolHnFphWUuIhTyH Ho/jNwmsvFY4xMOWjWq5XRrWQ9Q954rAreqKgwCh2fpLz9mniXXA8RR5C4r0WRIoTw0g CGOWgiiuvresbM2bVC6i6ozYbSQFu4s8l9ICeCFFh6VzjpQRmQfneJUl0qeiU5POt8YO tonrFyrQ1ZYOFaMTFuvy5U1ujgCFeEtq1c1nzGZ9nIMnIbTDh82xuQYpgKFhM2P4+E/y 63nw== 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=JwJW83RAOXwNtLBoq2PJiTT9pSJAD+Lih6xr6dcq056Kxt3y0zEnwFMExZm80ngZjW 721dpJ2H5MNx80a+831gG6Jtx8UPtrFt/P74UGmHfNw+0w6MQFhjKd2pg6jV5sDfK56m QjnpwDpOu7WQotzxOc2M5tfN4rctC/5m4hHOMr7vAuqDtorgbaBQ8j1mOyL56w7kO7R+ Y4lrSXrUQLXllFc9OMMA2ogtv6NUp5+bdO8dYZj/XMfPCivx69F+X186PoMdCmWbGWyT mh0GAeND9w6AYY3XxAJE5Kdr8Qvn85xOg7x7v6GGh1NFWKkFVrFUXdP441t9mD66NhBI oK7g== X-Gm-Message-State: ANoB5pkOP3dYMaOeAcvMxmX1/k9XAXOFM1+xnNPNFQerNbTi1Ho5Pdfn Jwme9k1arn/Y5Ycv3CbeoG/JBWq6BJn3JoyQ X-Google-Smtp-Source: AA0mqf6TLw0Y6wneXbxmvPEyBogz3t3Aw7HI1kH+xcrriioamTEIOVerHZ0Al3lBcgsdfCaKuUboJw== X-Received: by 2002:a17:903:330d:b0:18f:9b13:5fc2 with SMTP id jk13-20020a170903330d00b0018f9b135fc2mr20723602plb.52.1671168605508; Thu, 15 Dec 2022 21:30:05 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 21:30:04 -0800 (PST) From: Glenn Washburn To: "grub-devel @ gnu . org" , Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v4 01/15] gdb: Fix redirection issue in dump_module_sections Date: Thu, 15 Dec 2022 23:29:24 -0600 Message-Id: <20221216052938.224564-2-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::102e; envelope-from=development@efficientek.com; helo=mail-pj1-x102e.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:30:09 -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