Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pUXNy-0001v1-1T for mharc-grub-devel@gnu.org; Tue, 21 Feb 2023 13:29:06 -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 1pUXNw-0001uW-HM for grub-devel@gnu.org; Tue, 21 Feb 2023 13:29:04 -0500 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUXNu-0004A9-VQ for grub-devel@gnu.org; Tue, 21 Feb 2023 13:29:04 -0500 Received: by mail-qt1-x833.google.com with SMTP id ay9so5130473qtb.9 for ; Tue, 21 Feb 2023 10:29: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=G8IvqekQ5L1n4A1zcF7qLKBwjLWWvcJ7qMYw+mKSLwCb0iwPoYRC8EZz5db2jkkSRY An3k6Db0jQeolGp4nTIDpL9PDGVR8//pSjYenSIncULvBMp4wDWSFgAhjFOXoUtiRc/f 8G1Gx636mkuQr9J+gBNQ64QU1IOywRXXnW+pWYUFaTx5fF4Y028qxC9FSqpzim97ND5Y 1DvJXJTwqBlp/l6ZbIHMVrVVzFBY0g0ZjKuzk+0D3mpk/Exd0KgOyVCxZvLgX8J8PFdV Vs5b5DiaNiItpVTJ/teaQcBy1OWgiCteGvEik7IbyMbL9Ia0CX4wbamdsfGwd9X2GKQY vdDg== 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=RWYhdgycRVAGdWFl+wTSntYSv+4hmfL2yf+tqYXrG5dSGsg/LYAUP+VxDQ5u8GHAso uuB3x/e3c0doWRLuFNB7+tjJYhinwYyJ0PVd+QPN0fHcLfFCqwgAp5+VtOZ02/+t0Ah8 WuFdSj5cYHkNflYr65fsY8O6MGVv2H8+VJKzYrmpZ2LqHyfQloXlhPFee6vcpliDMDEu K+/jSEoKfGau27bxsfkbxZcm8f44Ylal4bO0ktaGJfQyj7BLcqzOKSzy5HhSFHQBSIve pP1f0N/LRXLLtsyOV3AmjwN+EH9O3sPVjMsYkxbTjrBCpXt4JW840B8Y5/STd1sE8tkB Pfuw== X-Gm-Message-State: AO0yUKUSpsMz4Q8nYwm0872sC4TKT1+dctO890U1v77jEisn6yXs4l8C bdvE8d2e9GJ6l45UV/lBIwAhioPF4t6VXTCS X-Google-Smtp-Source: AK7set/L2UC4EKgDT7oqkwQxIcjWVEbGtTtufJ4Zu7kszjSCdxnx9Vuu3txIKcutQdRbwjy74IayUg== X-Received: by 2002:a05:622a:654:b0:3bd:1728:8886 with SMTP id a20-20020a05622a065400b003bd17288886mr10022684qtb.9.1677004141618; Tue, 21 Feb 2023 10:29:01 -0800 (PST) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id h5-20020ac85045000000b003bd1a464346sm9339118qtm.9.2023.02.21.10.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 10:29:00 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH 1/3] gdb: Fix redirection issue in dump_module_sections Date: Tue, 21 Feb 2023 12:28:46 -0600 Message-Id: <9d267c3e3309b0127f97de6fafbfae46debc5c12.1677003806.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::833; envelope-from=development@efficientek.com; helo=mail-qt1-x833.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, 21 Feb 2023 18:29: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