Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp125430pxb; Wed, 23 Mar 2022 14:34:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbppacJqlrxFt7N4Y9CGuerHrMdS7r1nGOf8atNFPKarrHwCJiBNuiWvg3IE2GuUB+BJFR X-Received: by 2002:a63:e74d:0:b0:37c:728a:e06f with SMTP id j13-20020a63e74d000000b0037c728ae06fmr1431873pgk.458.1648071243913; Wed, 23 Mar 2022 14:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648071243; cv=none; d=google.com; s=arc-20160816; b=w++w/rijGjjF//xyUPyHbi+6fp3b1cJPQ/fNm+M504KPZepyjGU5yZmQO4/r4uVJME Bo2BElUpWBTcpg0gLyrVZINJlPRoQ/+50SXbwGZqI3O044MmvNoBJZp0/qaBvapR/6PO /ZKwUaSiUG+/korjZ0tEdjgS+GaC/bxx6U7q4ltnYInhtWAClxKT2bLBHPmNLvbySp45 N3H8FtRFm91cKqA8QyXUFsxPyk0VXJERkWgsoIxChsfJKdUFsn1LseLnklr6tKEOAzoi wluYVoutW1kYOSzOjO9UitxB+xWCu0OxWGEujdixgJfbkZHWmFJhw1K8eV0I0c02+T5y a/vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=IP07YkQg0rPEBTHMn8DcG1oqgtBsAiOLeh56Bth5JYA=; b=Ekzm7dN661K+QZmq5iUFFiMOyjdCjtxd9TmQLkmPeCpdM+A8OH0YaypJgLJNG+X/Ig hEsXLcVK9G6evXr05K5BSglS43L0tN+i7d7Ky0VK1QLt5iEG8p73HY20nTJYut52ucdO etce8lFlvLepR7zajAMPrptzJHUzd8Z8sAUYt6yy73g7aK479IZeP71llNMhPs0XDVTw lOWlTSl3APgYW9TZPbZD9zV9RBjvLI90jDY+eZHc37IVDeMrLAvE2bxD0quQXcfZsPdQ 1Uy231C5gQgdBhFpU8dZkSeWgkeXTyAuGF2Pl5Df5X+z3CBOtHT8QLd9b12aVvPMZv9k 2HHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="cyESw/5I"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8-20020a056a00228800b004fa3a8dff50si17466429pfe.7.2022.03.23.14.33.29; Wed, 23 Mar 2022 14:34:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="cyESw/5I"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344547AbiCWUPQ (ORCPT + 99 others); Wed, 23 Mar 2022 16:15:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244619AbiCWUPO (ORCPT ); Wed, 23 Mar 2022 16:15:14 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A55F36450 for ; Wed, 23 Mar 2022 13:13:44 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id o13so2049317pgc.12 for ; Wed, 23 Mar 2022 13:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=IP07YkQg0rPEBTHMn8DcG1oqgtBsAiOLeh56Bth5JYA=; b=cyESw/5IbCg0TBBMMJSmU4eDHeLpsGugfyrLP1x3XdAJPY2f5ewzEhzytb9Z3W3/n4 y9Dy1vLKc5Yl5wOAYqwVHJGc3B2CapvM1BSMrqsGC+BF4ZEj+KWTA2Zu9YwWMCIFB9/L 6/lGQCIwlIGHa8qXCPhXGLdxK2jjxnIpvz2vGwmJFldlOqBIjDuaSc5oEPzr4TxS5LSL TFuAl5zUBtx3YSZTszeHMDbWSHNd3MnCC7+y10epYSLhxfsrc9y75p76NTDfm85jDzlF lDq0PY9SwbXwhf66BgU1nxXKwqCXNlVdZWCPXzfDCG0i34mrUBA8i6vsVEg2qpx3htWV kqYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IP07YkQg0rPEBTHMn8DcG1oqgtBsAiOLeh56Bth5JYA=; b=ee25C6WRkurEYSQWTu9agZZTxuduyCVrMw7lGkXP36o9pc8T22Ddr/ZgIcl9cykjvy b0m5r9SZqPSMQJt2p3MX5z59LP1d0aSWYuPlSXOamp8RoKqEi3NIBGN+sWfGhtRV14AG v2KTrmHlqQnD7tVu8mzDQ/NdkkS1XN8ZD5XQka4e36Q/uFlJ0kjq5w96Oz2H6yNxN6lq QJhSj7Nvuk0yt+2iF7pmJYQ9qb3ueFAkoIBVuCaAjwRsYl23Cz8tkLvOYPwTti6Oi/9W LYpac82/zwLQzR9kL5ionN2mC7JRpyhpzzNgZhzAe0g4QDlPSyddEnrxk584xoNumL3D s7Aw== X-Gm-Message-State: AOAM532CSEyundVldFvIax2vj3dzTm0X9DO9i+380lNIEw92P3s8cF3s cSzGBlc0J2Lb7ifMG9LcmxG3fl7WntE= X-Received: by 2002:a63:4041:0:b0:37f:8077:e0de with SMTP id n62-20020a634041000000b0037f8077e0demr1228436pga.138.1648066423866; Wed, 23 Mar 2022 13:13:43 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id m4-20020a17090a7f8400b001bef3fc3938sm478361pjl.49.2022.03.23.13.13.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 13:13:43 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 1/9] log: Introduce DBG_IS_ENABLED Date: Wed, 23 Mar 2022 13:13:33 -0700 Message-Id: <20220323201341.3596128-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323201341.3596128-1-luiz.dentz@gmail.com> References: <20220323201341.3596128-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This introduces DBG_IS_ENABLE macro which can be used to check if BTD_DEBUG_FLAG_PRINT has been enabled for the current file. --- src/log.c | 12 ++++++++++++ src/log.h | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/log.c b/src/log.c index 0155a6bba..1157859ef 100644 --- a/src/log.c +++ b/src/log.c @@ -179,6 +179,18 @@ void __btd_log_init(const char *debug, int detach) info("Bluetooth daemon %s", VERSION); } +bool __btd_log_is_enabled(const char *file) +{ + struct btd_debug_desc *desc; + + for (desc = __start___debug; desc < __stop___debug; desc++) { + if (desc->file && g_pattern_match_simple(file, desc->file)) + return desc->flags & BTD_DEBUG_FLAG_PRINT; + } + + return false; +} + void __btd_log_cleanup(void) { closelog(); diff --git a/src/log.h b/src/log.h index 74941beb2..e35238870 100644 --- a/src/log.h +++ b/src/log.h @@ -9,6 +9,7 @@ */ #include +#include void info(const char *format, ...) __attribute__((format(printf, 1, 2))); @@ -27,6 +28,7 @@ void btd_debug(uint16_t index, const char *format, ...) void __btd_log_init(const char *debug, int detach); void __btd_log_cleanup(void); void __btd_toggle_debug(void); +bool __btd_log_is_enabled(const char *file); struct btd_debug_desc { const char *file; @@ -38,6 +40,15 @@ struct btd_debug_desc { void __btd_enable_debug(struct btd_debug_desc *start, struct btd_debug_desc *stop); +/* DBG_IS_ENABLED: + * + * Simple macro that can be used to check if debug has been enabled for the + * __FILE__. + * Note: This does a lookup thus why it was not used by the likes of + * DBG/DBG_IDX which loads it directly from section("__debug"). + */ +#define DBG_IS_ENABLED() __btd_log_is_enabled(__FILE__) + /** * DBG: * @fmt: format string -- 2.35.1