From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p5iN6-0007RG-SG for mharc-grub-devel@gnu.org; Thu, 15 Dec 2022 02:09:36 -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 1p5iN4-0007Qd-8c for grub-devel@gnu.org; Thu, 15 Dec 2022 02:09:34 -0500 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5iN2-000820-HN for grub-devel@gnu.org; Thu, 15 Dec 2022 02:09:33 -0500 Received: by mail-qt1-x834.google.com with SMTP id jr11so4484394qtb.7 for ; Wed, 14 Dec 2022 23:09:32 -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=ZkT1q3T7qEKhI+ZsR2CnSjTViLu2jYXVsVXQXbR77rU=; b=2DYbgGagJi4/mExK1RgtoqVWb+l9hcJBLb0W9/7ZE7nmDgnQu3Jbq2cjzrs3Ja/cpG yQyhEtbMyHOOSJIDzw4G+WbVuV+/3UAa+B2L9UTmZIX1G9HP7bRjGnxFkfOiaKrBsxro /ztThHF32LGPQsxbIkxySpsCTVKcF8M03gsKtVpVvkI+5jhW1kS8ERlj24Ie0y/2C/i7 rmmT+ujc32kGV8ct5wYdPbLe0BMn0XHa5Kh5xazbdz7c+bn0ktxePCJkfYL6qQ4CYUC7 D8RYVhpP0f+YlxlUmljy+LkzaImXNwwJneUntUmYfWbfQ2xlM05ncIQcwtZFG4XfQEPm lTyA== 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=ZkT1q3T7qEKhI+ZsR2CnSjTViLu2jYXVsVXQXbR77rU=; b=HB5FXVwlEctrLSKwOcU6yL4CvvQd3bHjBK+0EbNVpRurx/mQEmgy45gykz6lZRZoNL vUrzZXHFQju5Vqxg9CHy4/gYqcv1H+BR+ZaRfgdgcH73xaq1OjY3hZymkq1P9Er7Uc0L dkdnqtzN7jiJVEjp2yU1SIJsB/EUhCNhAgZ0rsnedDYzMSjQ2r1O8nT9bOhCcITYkWsH kRoNvfvM/dtQLUxn+Sdx++/G8sadZdsytOZS8pqmgiVtsAsrb3gV+xPcQOiB2Ew00CHK Npsu4xYeHrgZn0ri9Us+ZEdWwwWkEozFA0HjvcgPk/4172SLivpTvSdrCaEkH4BzfTOe R47Q== X-Gm-Message-State: ANoB5pmCp20u8Y9eZKT35InJ/ZuIyt9FpE1YJOGDAkhx7+6sFrz0A4Cg 5OXKgTq06XKRjlAsdNab/zwfq3QB8WQyNFFk X-Google-Smtp-Source: AA0mqf4OTiZZ6Vy/Fq45no4EKABym3u2WDd5cU8PCgrefhj7hrF6bD3TL39ukMdpLIp0rE+Em3xa5w== X-Received: by 2002:ac8:6646:0:b0:3a8:4b7:5bcb with SMTP id j6-20020ac86646000000b003a804b75bcbmr15661052qtp.62.1671088171185; Wed, 14 Dec 2022 23:09:31 -0800 (PST) Received: from crass-HP-ZBook-15-G2.lan ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id fy16-20020a05622a5a1000b003a7ec97c882sm3125068qtb.6.2022.12.14.23.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 23:09:30 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v3 01/15] gdb: Fix redirection issue in dump_module_sections Date: Thu, 15 Dec 2022 01:07:36 -0600 Message-Id: <20221215070750.102591-2-development@efficientek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221215070750.102591-1-development@efficientek.com> References: <20221215070750.102591-1-development@efficientek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=development@efficientek.com; helo=mail-qt1-x834.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: Thu, 15 Dec 2022 07:09:34 -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 e322d3dc10..bdf743f0d4 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