Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mciuT-0004sR-E2 for mharc-grub-devel@gnu.org; Tue, 19 Oct 2021 02:47:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mciuP-0004lu-90 for grub-devel@gnu.org; Tue, 19 Oct 2021 02:47:39 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:37764) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mciuN-0007bL-Mc for grub-devel@gnu.org; Tue, 19 Oct 2021 02:47:36 -0400 Received: by mail-qt1-x829.google.com with SMTP id w8so17431861qts.4 for ; Mon, 18 Oct 2021 23:47:35 -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=LviIoGwxQX4s4ewSh4uedo38IqycmgK/CUDps/zNll4=; b=jISBM4HqPpX5M9O3K5KT4gd9b70meGJD7OMet9GCh75nAZ7PYwBRy/YeQvXA0ncrJE n0SGdy0b/LsXB/aamlUGZ/hT66F+d+kdlSnUJZEPHoxyNx0ZhYf6F46/zyw5poOdZ9o0 egYf+aHMuG7OGMKdbxnMTCehUnr9/jlzM6Gd7yEB/9pyYHSdbGgpQd6QmhwSjFFt8NlF 6VoDCz1C0A6agKTiQRtrr+iexesnpM2sdl5KvG7cLe1/KG9tvWVJtoaPPeSnV7mVoXCn n3W2L52YenTxLB7t0u5H1lVfkWtFw+gqFaFaglOpajWNVj/0JaSz2a0/+ZfT3+zT8j/e TN8A== 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=LviIoGwxQX4s4ewSh4uedo38IqycmgK/CUDps/zNll4=; b=bDuST38q++UPZHPdEvAHmXx06v+vNTpuIgv5hSz6zLzzfgCLF4/3csyJLyhoyyJ/zj k7lEzAG4LbXM32K+2Wm9jhgtCmYDUVEyNPT2lxZJn6IotjGkBEBCqWdtcDm1975u0LmK 6nvLbsTwrK/t0LgNLCIxdBq/ZQf0DOq67iE+NpfgTu/+aVxsCrp0DjDh7JAGpnTGksm+ RSBPp1wLsWPTpFZFpmD/4NNxBKmC+XJNOGqIk+1juc6xSVKs3haYT0Ti4aQpMH8ueHCz biIHpmT2kphcowWuF7JS2ZoTxM1A8xnZ5XJab2ZCXCqSa0jR2bu7XfVfqbUhjwhIKtr/ mXjw== X-Gm-Message-State: AOAM533I049v+tY7+XNFZw9iz6/vmVfVJ5+D39HJz8f8dV74vwM/TI4l ERMrFD33gMCpG5flduk/sYNYk3lHlliaww== X-Google-Smtp-Source: ABdhPJzJGQ+IvGhC4G3ul8bywU9Xa0fsNTHr1ydrge5jX1Os0Us+/8yVE9ZL+osQ7kaIEVcXfNDaZQ== X-Received: by 2002:ac8:de:: with SMTP id d30mr33442624qtg.377.1634626054679; Mon, 18 Oct 2021 23:47:34 -0700 (PDT) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id k9sm6476818qkj.75.2021.10.18.23.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 23:47:34 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Michael Schierl , Glenn Washburn Subject: [DEBUG 1/2] misc: Allow selective disabling of debug conditionals Date: Tue, 19 Oct 2021 01:47:02 -0500 Message-Id: <244f7f85841dacaa9eedbd85b6d1a2c8bb717a81.1634625674.git.development@efficientek.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=development@efficientek.com; helo=mail-qt1-x829.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.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Oct 2021 06:47:39 -0000 Sometimes you know only know which debug logging conditionals you want to turn off, not necessarily all the ones you want enabled. This patch allows the debug string to contain conditionals in the $debug variable which are prefixed with a "-" to disable debug log messages for that conditional. This is only significant when "all" is a word in the comma-separated list of the $debug variable. Say you want all debug logging on except for btrfs and scripting, then do "set debug=all,-btrfs,-scripting". Note, only the first occurance of the conditional is searched for to determine if the conditional is enabled. So simply appending ",-conditional" to the $debug variable may not disable that conditional, if, for example, the conditional is already present. To illustrate, the command "set debug=all,btrfs,-scripting,-btrfs" will not disable btrfs. Signed-off-by: Glenn Washburn --- grub-core/kern/misc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 3af336ee2..ecef4839e 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -162,13 +162,28 @@ __attribute__ ((alias("grub_printf"))); int grub_debug_enabled (const char * condition) { - const char *debug; + const char *debug, *found; + char found_end; debug = grub_env_get ("debug"); if (!debug) return 0; - if (grub_strword (debug, "all") || grub_strword (debug, condition)) + if (grub_strword (debug, "all")) + { + if (debug[3] == '\0') + return 1; + found = grub_strstr (debug, condition); + /* If found conditional is preceeded by a '-' and whole, disable debug */ + if (found > debug && *(found-1) == '-') + { + found_end = *(found + grub_strlen (condition)); + if (found_end == '\0' || grub_iswordseparator (found_end)) + return 0; + } + return 1; + } + else if (grub_strword (debug, condition)) return 1; return 0; -- 2.27.0