From patchwork Wed Mar 23 20:13:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 553796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4998EC433F5 for ; Wed, 23 Mar 2022 20:13:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344548AbiCWUPT (ORCPT ); Wed, 23 Mar 2022 16:15:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240376AbiCWUPO (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 CBE2F6576 for ; Wed, 23 Mar 2022 13:13:43 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id w21so2062415pgm.7 for ; Wed, 23 Mar 2022 13:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=vMcsHhBjZa8B7B2vdvhCMgDV2TBVZD3rYdNk5h4gG+4=; b=Xy+MIo18qQBqWvbyVIF8zToOjhiulDNFojeTUdfYv2BJAmj+0HHC+NTkXtHGpc6PCE bp04kO7LJqNGVAt0uqDLc+VH4WAsYyouWDvIVfhiykZBFSmvE82Ee0jcoeONhH2Ka3iC ulN5C5x1XVoJBmd4QWfuOI7s0fNjuCTGwRFOEC4O4jlh5m7m+ctH4n/spxsglLc8YfvY YbpBHiMkthCtbmSWBlHu3cfmx0ExBlJE+GthB8bFDRbEHgV3Ygqw/jBfiNlRcf1+jgQI TEkRGMtRRpwn6+1HHaz/dHnM5uhD9kufmHioRZ7J5wVM4/7pJp3md93mWYOpqUJvxL2l 1uqg== 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:mime-version :content-transfer-encoding; bh=vMcsHhBjZa8B7B2vdvhCMgDV2TBVZD3rYdNk5h4gG+4=; b=Y5y2A5GoqEWQ64ZrWIKztrxLaespF560062gjhE8Bvrd5JCMNz71iZJlm7zSbwDFcx wfS/i7lqePDEZkjRfwpCR/zF140D7qI29q/Vpo81EwwaKqj3qodh1yV6ZKDLQiVb1Tmu sTVaWAEY/dsY8QlhbRJ0NKOpTHau92dFjhLoZVnDKG1X2kH9SSyzpfpXniAjYRCmliPO ufFJdb97z4EGlZ92QptIO+0wzaRhRrF0ZQ/0HV/lcTGDOn+eI0s3SHNyjIPYedFvb/sy IK5tj3eb8TPqW38SnTVGQSeBcSp/f6K27H5i/C10IpyfAvvt/StSrP2n/MHnFH1aHqZf SjKw== X-Gm-Message-State: AOAM533Wi2bwLltP1zPZj4BriYHr4nOQzfMOfZ7gDneVPv720ZF96OZE wLV+5wmR4pL/JBsNyB4UMo1UJ/F/ddc= X-Google-Smtp-Source: ABdhPJzGskYnr6Q3tgxzUUlOB8NVRwD5RKInzX46XiiFN0H2MSAh2UXbxkWrXuRBL2qzrHI0Ky8nMw== X-Received: by 2002:a05:6a00:24cc:b0:4fa:a9c5:4b04 with SMTP id d12-20020a056a0024cc00b004faa9c54b04mr1600990pfv.63.1648066423041; 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.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 13:13:42 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 1/9] log: Don't log __FILE__ and __func__ with DBG_IDX Date: Wed, 23 Mar 2022 13:13:32 -0700 Message-Id: <20220323201341.3596128-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This removes __FILE__ and __func__ from DBG_IDX since users of it may already contain such information embedded in the format. --- src/log.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/log.h b/src/log.h index 74941beb2..a244fc4d8 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))); @@ -52,10 +53,11 @@ void __btd_enable_debug(struct btd_debug_desc *start, .file = __FILE__, .flags = BTD_DEBUG_FLAG_DEFAULT, \ }; \ if (__btd_debug_desc.flags & BTD_DEBUG_FLAG_PRINT) \ - btd_debug(idx, "%s:%s() " fmt, __FILE__, __func__ , ## arg); \ + btd_debug(idx, fmt, ## arg); \ } while (0) -#define DBG(fmt, arg...) DBG_IDX(0xffff, fmt, ## arg) +#define DBG(fmt, arg...) \ + DBG_IDX(0xffff, "%s:%s() " fmt, __FILE__, __func__ , ## arg) #define error(fmt, arg...) \ btd_error(0xffff, "%s:%s() " fmt, __FILE__, __func__, ## arg) #define warn(fmt, arg...) \ From patchwork Wed Mar 23 20:13:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 553795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0F59C433EF for ; Wed, 23 Mar 2022 20:13:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344552AbiCWUPU (ORCPT ); Wed, 23 Mar 2022 16:15:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239771AbiCWUPQ (ORCPT ); Wed, 23 Mar 2022 16:15:16 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74B5E8933B for ; Wed, 23 Mar 2022 13:13:45 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id gb19so2810901pjb.1 for ; Wed, 23 Mar 2022 13:13:45 -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=lMeVwZRc+kCFv6ywPENuuniweobbSTLYVjAmAjxzwIE=; b=NfzgRo2RTkRfThXJJc2bShOzQK2488gfl7PltLMV19W3Zdu8vrsRQV3sOHTZ51OPmM HG9nVDeY+Z63z+QlSBU7gte66M614sGvHOS63WnYTB6cITod5yrkkHz+Z6mi4POwHKXi kyRLkbdUqP/T5Q9115/+0r2Fek3Kuo+5GkMtzxRTyhElVm9Gat3oWJGRRc18E8v/UAy7 iVno/m9bdzkl/H6MMaBZdrTNyEe3pSwhKsliy5pk0W1slPYDM765W4op7f+2fEYrHCuT KMR8bMuYLwGHcaWxUdAmjhQp9MCj+jaQ+gM/eEuNyRC/rFkZ1gfe4LA9s1Tb0pJehzJI CBmA== 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=lMeVwZRc+kCFv6ywPENuuniweobbSTLYVjAmAjxzwIE=; b=JrSCJw5V7kVKQVIPmIJ03ugZTX1EcZYT4mz0kCLnO5dWi6sp41PvDKX6uBL5ZU/t43 YZ6Frjtp48jY2qX0J17nNo2zPupNy/qgrlBQqU3b+4GCp18zkQVmvVWsn9xG2DAdBzyt h7w7H80W6qCa5Qaa9bRYbxFDgAPR/gtcG0x4yFwSqLGbK+aqfFUoqA3AAY/842x6jKrD dRJrS0tm4wpbIT7amhtVTcCBDquS5/XbWb2Jk0YIGT4KfLBsavjI59NrDZtzDce41I5U tIKfkhXjVdyDf1jpPf93T5VbVK+Iz/MEU+elxqgpuAzHTiDOGaJSaaxun5bIwoTXlpG2 aRXA== X-Gm-Message-State: AOAM531wcrciAsSkb5uLCt8nd6tSllcsFW9pEXPNhnf09DFxv2B+78yS luFa2Hfn+G2ECIg5wpjY/9uydwxTy/M= X-Google-Smtp-Source: ABdhPJzUlH0kmoSZ2cifYJKXdWww4LHmhkh9rODjZLOgGH1oy0Z9x6f10vprzHZcg0O6vhdeb//DOA== X-Received: by 2002:a17:902:cec5:b0:154:6b18:6157 with SMTP id d5-20020a170902cec500b001546b186157mr1759632plg.145.1648066424610; Wed, 23 Mar 2022 13:13:44 -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.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 13:13:44 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 2/9] mgmt: Add DBG macro Date: Wed, 23 Mar 2022 13:13:34 -0700 Message-Id: <20220323201341.3596128-3-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds mgmt_log wrapper for util_debug and DBG so file and function names are printed with the logs. --- src/shared/mgmt.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c index 95229c248..c7e6a6c1d 100644 --- a/src/shared/mgmt.c +++ b/src/shared/mgmt.c @@ -27,6 +27,9 @@ #include "src/shared/mgmt.h" #include "src/shared/timeout.h" +#define DBG(_mgmt, _format, arg...) \ + mgmt_log(_mgmt, "%s:%s() " _format, __FILE__, __func__, ## arg) + struct mgmt { int ref_count; int fd; @@ -177,6 +180,18 @@ static bool request_timeout(void *data) return false; } +static void mgmt_log(struct mgmt *mgmt, const char *format, ...) +{ + va_list ap; + + if (!mgmt || !format || !mgmt->debug_callback) + return; + + va_start(ap, format); + util_debug_va(mgmt->debug_callback, mgmt->debug_data, format, ap); + va_end(ap); +} + static bool send_request(struct mgmt *mgmt, struct mgmt_request *request) { struct iovec iov; @@ -187,8 +202,8 @@ static bool send_request(struct mgmt *mgmt, struct mgmt_request *request) ret = io_send(mgmt->io, &iov, 1); if (ret < 0) { - util_debug(mgmt->debug_callback, mgmt->debug_data, - "write failed: %s", strerror(-ret)); + DBG(mgmt, "write failed: %s", strerror(-ret)); + if (request->callback) request->callback(MGMT_STATUS_FAILED, 0, NULL, request->user_data); @@ -202,9 +217,7 @@ static bool send_request(struct mgmt *mgmt, struct mgmt_request *request) request, NULL); - util_debug(mgmt->debug_callback, mgmt->debug_data, - "[0x%04x] command 0x%04x", - request->index, request->opcode); + DBG(mgmt, "[0x%04x] command 0x%04x", request->index, request->opcode); util_hexdump('<', request->buf, ret, mgmt->debug_callback, mgmt->debug_data); @@ -283,9 +296,7 @@ static void request_complete(struct mgmt *mgmt, uint8_t status, request = queue_remove_if(mgmt->pending_list, match_request_opcode_index, &match); if (!request) { - util_debug(mgmt->debug_callback, mgmt->debug_data, - "Unable to find request for opcode 0x%04x", - opcode); + DBG(mgmt, "Unable to find request for opcode 0x%04x", opcode); /* Attempt to remove with no opcode */ request = queue_remove_if(mgmt->pending_list, @@ -383,8 +394,7 @@ static bool can_read_data(struct io *io, void *user_data) cc = mgmt->buf + MGMT_HDR_SIZE; opcode = btohs(cc->opcode); - util_debug(mgmt->debug_callback, mgmt->debug_data, - "[0x%04x] command 0x%04x complete: 0x%02x", + DBG(mgmt, "[0x%04x] command 0x%04x complete: 0x%02x", index, opcode, cc->status); request_complete(mgmt, cc->status, opcode, index, length - 3, @@ -394,15 +404,13 @@ static bool can_read_data(struct io *io, void *user_data) cs = mgmt->buf + MGMT_HDR_SIZE; opcode = btohs(cs->opcode); - util_debug(mgmt->debug_callback, mgmt->debug_data, - "[0x%04x] command 0x%02x status: 0x%02x", + DBG(mgmt, "[0x%04x] command 0x%02x status: 0x%02x", index, opcode, cs->status); request_complete(mgmt, cs->status, opcode, index, 0, NULL); break; default: - util_debug(mgmt->debug_callback, mgmt->debug_data, - "[0x%04x] event 0x%04x", index, event); + DBG(mgmt, "[0x%04x] event 0x%04x", index, event); process_notify(mgmt, event, index, length, mgmt->buf + MGMT_HDR_SIZE); From patchwork Wed Mar 23 20:13:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 554669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4302C433FE for ; Wed, 23 Mar 2022 20:13:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344551AbiCWUPT (ORCPT ); Wed, 23 Mar 2022 16:15:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344544AbiCWUPQ (ORCPT ); Wed, 23 Mar 2022 16:15:16 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52397635F for ; Wed, 23 Mar 2022 13:13:46 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id b8so2792637pjb.4 for ; Wed, 23 Mar 2022 13:13:46 -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=oA2b2MSFZ5xMIcZQftlPk/BJnbKEpfSvA/B3B3AZtBo=; b=MXnoelzMi+QjHshprhZA/AEVSmHPqLrKX5O5YgsCVLdiMPIRrc1OpMgUeWmQOB4QTy C5MEwMWOkRqpDCA0dSwBoUgSrT7ocT6UzqWRIVC6+S5CrUm9sMs25LtTkglefJdCM56w KLPS5JEb1/cr1tj/xL4TslFbURXQfKjSoqpySXcMLfukndOLwCRYnhBXYZj9wmMF0ekz cdMS1EOK77O2N9UKPYnAS0QUbeWA1Vie91Zv72CqqKBgRHWyoYg/h9eMU+7j3hqAJNFY K2s/x9RSmfTeHBoFc9NFRZhdVlSEIGesxNG5KgJ8S8+3ZzaaT22COkQ+Yn5sLWc3tYbr Jtkw== 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=oA2b2MSFZ5xMIcZQftlPk/BJnbKEpfSvA/B3B3AZtBo=; b=Amc15l6uaDn8RNnXQZUc70gjKeFKIwGERQpiTDEMgeD/+s27/fhCH6UUSYQF2FGPad hRff1g52JG1/HAmqQOypF3zzF+u67oDYrQ852Ogt85QtQIO9jOAt4Oxa7ZPBa3SBlfte tzN6/jmth3iRhwmZyk28ZbRBujoP8nF9dV2rALGGXqHbrwM+z3Pymglz18dD5o2DzFVg rz+18G811ed5R7/8GRNvQaq4pdad0D+4I0nvYjO8pWUwVPSVX5LDj3CxlCRXPMhzmCd+ b8L0FmpV/kl8hqP083a7ossc1z/mmVAYtvYDztpAJ/fsdEUaVC7u6ZIbRE4LzzAb3+F+ O9Gg== X-Gm-Message-State: AOAM532ZOfUC3YMlcwTiLTN32ieGcHxsog55FMpLHZ9w3gsDxA/xg9nL FfMGwPQSUU5AS2kVrAlkCpPs0Z3XH9w= X-Google-Smtp-Source: ABdhPJxWlRC8E+RKRxsmOfHlKJ3LN5gEPusRI0SIwssSjLoUxiyITORe5z3vFhGCePiE/OiacJv0Pw== X-Received: by 2002:a17:902:ca13:b0:153:db88:92cc with SMTP id w19-20020a170902ca1300b00153db8892ccmr1841193pld.80.1648066425590; Wed, 23 Mar 2022 13:13:45 -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.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 13:13:45 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 3/9] mgmt: Introduce mgmt_set_verbose Date: Wed, 23 Mar 2022 13:13:35 -0700 Message-Id: <20220323201341.3596128-4-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This introduces mgmt_set_verbose which can be used to enable printing the the likes hexdump of packets, by default it is disabled since in most cases the hexdump is not very useful and there are better tools to collect the hexdumo like btmon. --- src/shared/mgmt.c | 24 ++++++++++++++++++++---- src/shared/mgmt.h | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c index c7e6a6c1d..cf518cc2b 100644 --- a/src/shared/mgmt.c +++ b/src/shared/mgmt.c @@ -50,6 +50,7 @@ struct mgmt { mgmt_debug_func_t debug_callback; mgmt_destroy_func_t debug_destroy; void *debug_data; + bool verbose; }; struct mgmt_request { @@ -192,6 +193,15 @@ static void mgmt_log(struct mgmt *mgmt, const char *format, ...) va_end(ap); } +static void mgmt_hexdump(struct mgmt *mgmt, char dir, const void *data, + size_t len) +{ + if (!mgmt->verbose) + return; + + util_hexdump(dir, data, len, mgmt->debug_callback, mgmt->debug_data); +} + static bool send_request(struct mgmt *mgmt, struct mgmt_request *request) { struct iovec iov; @@ -219,8 +229,7 @@ static bool send_request(struct mgmt *mgmt, struct mgmt_request *request) DBG(mgmt, "[0x%04x] command 0x%04x", request->index, request->opcode); - util_hexdump('<', request->buf, ret, mgmt->debug_callback, - mgmt->debug_data); + mgmt_hexdump(mgmt, '<', request->buf, ret); queue_push_tail(mgmt->pending_list, request); @@ -373,8 +382,7 @@ static bool can_read_data(struct io *io, void *user_data) if (bytes_read < 0) return false; - util_hexdump('>', mgmt->buf, bytes_read, - mgmt->debug_callback, mgmt->debug_data); + mgmt_hexdump(mgmt, '>', mgmt->buf, bytes_read); if (bytes_read < MGMT_HDR_SIZE) return true; @@ -594,6 +602,14 @@ bool mgmt_set_debug(struct mgmt *mgmt, mgmt_debug_func_t callback, return true; } +void mgmt_set_verbose(struct mgmt *mgmt, bool value) +{ + if (!mgmt) + return; + + mgmt->verbose = value; +} + bool mgmt_set_close_on_unref(struct mgmt *mgmt, bool do_close) { if (!mgmt) diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h index b413cea78..0f3e54c16 100644 --- a/src/shared/mgmt.h +++ b/src/shared/mgmt.h @@ -28,6 +28,7 @@ typedef void (*mgmt_debug_func_t)(const char *str, void *user_data); bool mgmt_set_debug(struct mgmt *mgmt, mgmt_debug_func_t callback, void *user_data, mgmt_destroy_func_t destroy); +void mgmt_set_verbose(struct mgmt *mgmt, bool value); bool mgmt_set_close_on_unref(struct mgmt *mgmt, bool do_close); From patchwork Wed Mar 23 20:13:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 553794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28A9AC433F5 for ; Wed, 23 Mar 2022 20:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344566AbiCWUPW (ORCPT ); Wed, 23 Mar 2022 16:15:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344550AbiCWUPR (ORCPT ); Wed, 23 Mar 2022 16:15:17 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C2677655 for ; Wed, 23 Mar 2022 13:13:47 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id mj15-20020a17090b368f00b001c637aa358eso7511961pjb.0 for ; Wed, 23 Mar 2022 13:13:47 -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=FMwbFQa5JHQe75eN4X8D/2kRfU5RTU2M/iRq1EKBwjk=; b=Ff4+xdsSUU5j5e9I6KpRT+CncE4oZDHADK+noSSQHXVPakCeGeHVpMIqpk4h3+KwJ5 1vPyvxeSKMeJYtQlPzbaRqruXIaMAos3aVzefotcoCGTLPWVXvRZm9E4oJ5ma7rF3WgB Bq3BQ4RoTe2+rpnN9If310ZagaoR5oHqk7fJgo/V/2JsUdFqHSwKdfK7vCsxFZdpIMkY pzmlxvSXX9/2UQrxoUrE7sVsWYn5ulDbMJ/OdbhBGN4cWbzdhCs6s0USsPtMxWBjyWxi iDMYlLT/JfgCxor8/uBO6O2ZEXpoCFS/sYJJcM8s7pjQ90NUJkQV0ioy+lnQ/mY+123l 3UIA== 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=FMwbFQa5JHQe75eN4X8D/2kRfU5RTU2M/iRq1EKBwjk=; b=MUdtfNWT52pTVz0WZHYDkMIYQK6hv9hSwkPz3xooWL+a0tzyb+WMf1+sF5QOyIcCrA a8KSGhIKoz9VLGh6iEONCwLUI5JafhtJEbhTUtFk9jR/jZ7vOjcBjCdmJOJqpfqCU5do PtbSFA1QQsiFfjLzpJhgGOI5A1vp4TcPhvDdud3ltIIbqISnE2prqpkLO9FjSysZi9Ey p+BPEEqFKFOCurOpCLdrc5XbYCeVs1dUrll+27v4m5p8WN6K4vq5RC/7v3DPU6zYCs88 Mtq48fF8sjfrpkdcsvEDZ5gqYWvWi5/JW+rUGU1QGr4LN6dcQbFv+OY8s1DnpzJg7kie 0XUQ== X-Gm-Message-State: AOAM5303JFrr+236932gCqO4h7ww4NwyF0ynQIgpMD8NpZbr6ttMa6XI vArxw+4FMUP4TR9xY0ZwEcsi8vZ8Q4w= X-Google-Smtp-Source: ABdhPJzQDSG9HrLsjhjtBEBZElLqJSS9mfDBCqrWIxoWHcjnbO3wXQZu2KwjGdQnjHZI8qQMoeuVdQ== X-Received: by 2002:a17:903:2288:b0:153:bfbe:7354 with SMTP id b8-20020a170903228800b00153bfbe7354mr1836904plh.112.1648066426354; Wed, 23 Mar 2022 13:13:46 -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.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 13:13:46 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 4/9] adapter: Don't use DBG in mgmt_debug Date: Wed, 23 Mar 2022 13:13:36 -0700 Message-Id: <20220323201341.3596128-5-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz mgmt_debug callback is used to print debug strings from mgmt instances which includes the file and function names so using DBG would add yet another set of file and function prefixes which makes the logs confusing. --- src/adapter.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 97ce26f8e..9f003346d 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -10327,9 +10327,7 @@ static void read_version_complete(uint8_t status, uint16_t length, static void mgmt_debug(const char *str, void *user_data) { - const char *prefix = user_data; - - info("%s%s", prefix, str); + DBG_IDX(0xffff, "%s", str); } int adapter_init(void) @@ -10342,8 +10340,7 @@ int adapter_init(void) return -EIO; } - if (getenv("MGMT_DEBUG")) - mgmt_set_debug(mgmt_primary, mgmt_debug, "mgmt: ", NULL); + mgmt_set_debug(mgmt_primary, mgmt_debug, NULL, NULL); DBG("sending read version command"); From patchwork Wed Mar 23 20:13:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 554668 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8717C4332F for ; Wed, 23 Mar 2022 20:13:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344561AbiCWUPV (ORCPT ); Wed, 23 Mar 2022 16:15:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244619AbiCWUPS (ORCPT ); Wed, 23 Mar 2022 16:15:18 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF4AE8A31B for ; Wed, 23 Mar 2022 13:13:47 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id mp6-20020a17090b190600b001c6841b8a52so7450863pjb.5 for ; Wed, 23 Mar 2022 13:13:47 -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=/j7e/CWw6oRrnkQVp/KphTi81K+8ZW6pXdZNgewlKz0=; b=Ab0VD8ceTkG8fpaqCmLVSsw+gP7Cuuz1a+E+9+a4ewSr6wE9ouej2vV9h8tpCG2hta xjcuSbLHmY3tu86aSk4e4y3eO/PhUscZcoaQK0PFPrwoB1Qe7OIQhvQAK9WynytCg5F9 YKvdZz4kZmOFF/ndCwHj9tVw+OTOKaZkXLnNc74HgabfQVG/+QaEG8A6FSDB+oHut35O e2oA7MyfigU8rsvnY2cT563PKIRK3yjygJLNIG6gQKRWIKi1pURPcfLIIln95190KxXF 9+ZaS6VPRpchSw4z3OW16PD/dQldgVlM7U3z2DuCfHJjL6b8uy2g0S/J5bmMg2xC9SgK swNg== 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=/j7e/CWw6oRrnkQVp/KphTi81K+8ZW6pXdZNgewlKz0=; b=NJYsQc40VH7MO6uuQyXC+EiuDVSnhsnH9fvtm+elz/SE0Ebn5CICJIsBcZ+qbc7kEn uj3jlxDe4BuUXgAzME9UYR4fcz36lZhVaOhfQTPaxV8EahCk9HKv0VehAdeu4/oda+mr 20grsXxcsSywNcTh8r1V1HYZbVV1b50C6pBsoPdPh5/hOM8BYBEGWbMaLNnWidM6V6kk Ja6Cfe8FEHCKMzE8Kk3ucd74BxvwOnaA7pY1YKYlN9PpsFYgpLcfrWfrnddWRPPm8U3f x8QwBYmPowLRuPrECkuDn5QpwbB+hNPp5b7Wj79+I49zdb3sRXOuxqaGDY3K+J6ZRE79 umUw== X-Gm-Message-State: AOAM531L/RCCEqL2nkU31F45LatJLknYLKQJAjJO5ZrYOOavdErPPc2x QiK3WdmIClYLmz3Da3R9nTLg3q1B6+A= X-Google-Smtp-Source: ABdhPJw+1Wdv1daRIxzVok+heMtDU4AKn7MQCse4XXxDvs6s19AOnx1Fcg1bSwcAFxZ99AipdExgdQ== X-Received: by 2002:a17:902:b7c2:b0:153:b7fb:14c3 with SMTP id v2-20020a170902b7c200b00153b7fb14c3mr1842601plz.134.1648066427068; Wed, 23 Mar 2022 13:13:47 -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.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 13:13:46 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 5/9] att: Log file and function names Date: Wed, 23 Mar 2022 13:13:37 -0700 Message-Id: <20220323201341.3596128-6-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds logging of file and function names. --- src/shared/att.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shared/att.c b/src/shared/att.c index 169f726e4..7344b0c46 100644 --- a/src/shared/att.c +++ b/src/shared/att.c @@ -308,10 +308,12 @@ static void att_log(struct bt_att *att, uint8_t level, const char *format, } #define att_debug(_att, _format, _arg...) \ - att_log(_att, BT_ATT_DEBUG, _format, ## _arg) + att_log(_att, BT_ATT_DEBUG, "%s:%s() " _format, __FILE__, __func__,\ + ## _arg) #define att_verbose(_att, _format, _arg...) \ - att_log(_att, BT_ATT_DEBUG_VERBOSE, _format, ## _arg) + att_log(_att, BT_ATT_DEBUG_VERBOSE, "%s:%s() " _format, __FILE__, \ + __func__, ## _arg) static void att_hexdump(struct bt_att *att, char dir, const void *data, size_t len) From patchwork Wed Mar 23 20:13:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 553793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2451C433EF for ; Wed, 23 Mar 2022 20:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344563AbiCWUPX (ORCPT ); Wed, 23 Mar 2022 16:15:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240376AbiCWUPT (ORCPT ); Wed, 23 Mar 2022 16:15:19 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D175D6576 for ; Wed, 23 Mar 2022 13:13:48 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id k14so2089887pga.0 for ; Wed, 23 Mar 2022 13:13:48 -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=YgL1QjGsntEM/sKI8J2WatVdiyjYA18RaC7riKp34Dw=; b=WUe905u/cAu0K+fVf/4gTWcLqUey7PYV5avexmZRp9/p8h6Yq6CJO3M8U/+85HPjth EB3whT+5jYwXJyYvrmhuoq4SUGLZ+ehcuqJVEHBPVpmQFoe5ASn25Ay0t2Gdfu5XrLwv +aJ62+fshXB37iTutm+y9wFz2f+DBCZTPvsH8LtMYSP5S5TTEBEjV+DeLajivS8fZw4n vNOH35xtos/WulrGlGzPyyMwRUCVJlttYRc1VRKNcUJ+HoxX+oz+RG2u8sH8ie6S7CBR 45SdEqPaI9xHOJn9ap0UYKWzWBS7eD3i6AYu0EyD232nDS/E0AM7zIkkkbQcVngdVbmM aB2w== 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=YgL1QjGsntEM/sKI8J2WatVdiyjYA18RaC7riKp34Dw=; b=PKlcqgM4ES//pPPyO0GBo6VOF/hBhPUAdpb67bJRfDFnmL9QHBOkivM3/L++B7xx9g 2MjRswlyc3FaIHFJuvZ5c+CpOR4/3xE4KChb8gM7DBp911eJMCu00nELMAhR5K3rIRam a38tkKjNLUnbcFNy3PlOe3gAVau3ei/M8uXm2Kss1B87k/4+4VcraydXykMdQb9nmh+w r/O5nIr9wHgxbV3YBxqlmIVB+gyuFuJEovyaJwZs8Mc/wC2SxhwZyIVqc+m7oyj1SM8p MDcDSjRzs4ZbirArEgh0FtR0nOE8w/4Qx1VwzNpJPmjvTuSNPI0zhIVXfi9AddGffyN5 XIZg== X-Gm-Message-State: AOAM532X6yBIVvtQj0NZjJ9lRG2089Auv8wcT5iUmnSpUbzlVwDQmr77 ksABamXtGEo+Ifp/KterDkzha8muLrc= X-Google-Smtp-Source: ABdhPJxyERjTLnqVcROuh5+RcZQYjU+vO+WxmtnMz+R8fLwty+iDzctfiqu7YvIBen7puWAbcwTSlQ== X-Received: by 2002:a05:6a00:2485:b0:4f7:37cd:d040 with SMTP id c5-20020a056a00248500b004f737cdd040mr1604187pfv.55.1648066427873; Wed, 23 Mar 2022 13:13:47 -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.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 13:13:47 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 6/9] gatt-client: Add DBG macro Date: Wed, 23 Mar 2022 13:13:38 -0700 Message-Id: <20220323201341.3596128-7-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds gatt_log wrapper for util_debug and DBG macro so file and function names are printed which is more consistent with other parts of the daemon code. --- src/shared/gatt-client.c | 160 +++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 90 deletions(-) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index e24c9603c..ba9228ddf 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -37,6 +37,8 @@ #define GATT_SVC_UUID 0x1801 #define SVC_CHNGD_UUID 0x2a05 +#define DBG(_client, _format, arg...) \ + gatt_log(_client, "%s:%s() " _format, __FILE__, __func__, ## arg) struct ready_cb { bt_gatt_client_callback_t callback; @@ -376,6 +378,18 @@ static void discovery_op_free(struct discovery_op *op) static bool read_db_hash(struct discovery_op *op); +static void gatt_log(struct bt_gatt_client *client, const char *format, ...) +{ + va_list ap; + + if (!client || !format || !client->debug_callback) + return; + + va_start(ap, format); + util_debug_va(client->debug_callback, client->debug_data, format, ap); + va_end(ap); +} + static void discovery_op_complete(struct discovery_op *op, bool success, uint8_t err) { @@ -406,9 +420,8 @@ static void discovery_op_complete(struct discovery_op *op, bool success, gatt_db_attribute_get_service_data(attr, &start, &end, NULL, NULL); - util_debug(op->client->debug_callback, op->client->debug_data, - "service disappeared: start 0x%04x end 0x%04x", - start, end); + DBG(op->client, "service disappeared: start 0x%04x end 0x%04x", + start, end); gatt_db_remove_service(op->client->db, attr); } @@ -542,9 +555,7 @@ static void discover_incl_cb(bool success, uint8_t att_ecode, if (includes_count == 0) goto failed; - util_debug(client->debug_callback, client->debug_data, - "Included services found: %u", - includes_count); + DBG(client, "Included services found: %u", includes_count); for (i = 0; i < includes_count; i++) { if (!bt_gatt_iter_next_included_service(&iter, &handle, &start, @@ -555,13 +566,12 @@ static void discover_incl_cb(bool success, uint8_t att_ecode, /* Log debug message */ bt_uuid_to_string(&uuid, uuid_str, sizeof(uuid_str)); - util_debug(client->debug_callback, client->debug_data, - "handle: 0x%04x, start: 0x%04x, end: 0x%04x," + DBG(client, "handle: 0x%04x, start: 0x%04x, end: 0x%04x," "uuid: %s", handle, start, end, uuid_str); attr = gatt_db_get_attribute(client->db, start); if (!attr) { - util_debug(client->debug_callback, client->debug_data, + DBG(client, "Unable to find attribute at 0x%04x: skipping", start); continue; @@ -569,7 +579,7 @@ static void discover_incl_cb(bool success, uint8_t att_ecode, attr = gatt_db_insert_included(client->db, handle, attr); if (!attr) { - util_debug(client->debug_callback, client->debug_data, + DBG(client, "Unable to add include attribute at 0x%04x", handle); goto failed; @@ -582,7 +592,7 @@ static void discover_incl_cb(bool success, uint8_t att_ecode, * attribute. */ if (gatt_db_attribute_get_handle(attr) != handle) { - util_debug(client->debug_callback, client->debug_data, + DBG(client, "Invalid attribute 0x%04x expect it at 0x%04x", gatt_db_attribute_get_handle(attr), handle); goto failed; @@ -604,8 +614,8 @@ next: if (client->discovery_req) return; - util_debug(client->debug_callback, client->debug_data, - "Failed to start characteristic discovery"); + DBG(client, "Failed to start characteristic discovery"); + discovery_op_unref(op); failed: discovery_op_complete(op, false, att_ecode); @@ -656,7 +666,7 @@ static bool discover_descs(struct discovery_op *op, bool *discovering) NULL, NULL, NULL); if (!attr) { - util_debug(client->debug_callback, client->debug_data, + DBG(client, "Failed to insert characteristic at 0x%04x", chrc_data->value_handle); @@ -729,8 +739,8 @@ static bool discover_descs(struct discovery_op *op, bool *discovering) goto done; } - util_debug(client->debug_callback, client->debug_data, - "Failed to start descriptor discovery"); + DBG(client, "Failed to start descriptor discovery"); + discovery_op_unref(op); goto failed; @@ -750,8 +760,7 @@ static void ext_prop_write_cb(struct gatt_db_attribute *attrib, { struct bt_gatt_client *client = user_data; - util_debug(client->debug_callback, client->debug_data, - "Value set status: %d", err); + DBG(client, "Value set status: %d", err); } static void ext_prop_read_cb(bool success, uint8_t att_ecode, @@ -790,8 +799,7 @@ static void ext_prop_read_cb(bool success, uint8_t att_ecode, if (!success) goto done; - util_debug(client->debug_callback, client->debug_data, - "Ext. prop value: 0x%04x", (uint16_t)value[0]); + DBG(client, "Ext. prop value: 0x%04x", (uint16_t)value[0]); desc_attr = queue_pop_head(op->ext_prop_desc); if (!desc_attr) @@ -857,8 +865,7 @@ static void discover_descs_cb(bool success, uint8_t att_ecode, if (desc_count == 0) goto failed; - util_debug(client->debug_callback, client->debug_data, - "Descriptors found: %u", desc_count); + DBG(client, "Descriptors found: %u", desc_count); bt_uuid16_create(&ext_prop_uuid, GATT_CHARAC_EXT_PROPER_UUID); @@ -867,9 +874,8 @@ static void discover_descs_cb(bool success, uint8_t att_ecode, /* Log debug message */ bt_uuid_to_string(&uuid, uuid_str, sizeof(uuid_str)); - util_debug(client->debug_callback, client->debug_data, - "handle: 0x%04x, uuid: %s", - handle, uuid_str); + + DBG(client, "handle: 0x%04x, uuid: %s", handle, uuid_str); attr = gatt_db_insert_descriptor(client->db, handle, &uuid, 0, NULL, NULL, @@ -880,8 +886,7 @@ static void discover_descs_cb(bool success, uint8_t att_ecode, gatt_db_attribute_get_type(attr))) continue; - util_debug(client->debug_callback, client->debug_data, - "Failed to insert descriptor at 0x%04x", + DBG(client, "Failed to insert descriptor at 0x%04x", handle); goto failed; } @@ -947,8 +952,8 @@ static void discover_chrcs_cb(bool success, uint8_t att_ecode, goto failed; chrc_count = bt_gatt_result_characteristic_count(result); - util_debug(client->debug_callback, client->debug_data, - "Characteristics found: %u", chrc_count); + + DBG(client, "Characteristics found: %u", chrc_count); if (chrc_count == 0) goto failed; @@ -959,8 +964,7 @@ static void discover_chrcs_cb(bool success, uint8_t att_ecode, /* Log debug message */ bt_uuid_to_string(&uuid, uuid_str, sizeof(uuid_str)); - util_debug(client->debug_callback, client->debug_data, - "start: 0x%04x, end: 0x%04x, value: 0x%04x, " + DBG(client, "start: 0x%04x, end: 0x%04x, value: 0x%04x, " "props: 0x%02x, uuid: %s", start, end, value, properties, uuid_str); @@ -997,8 +1001,7 @@ next: if (client->discovery_req) return; - util_debug(client->debug_callback, client->debug_data, - "Failed to start included services discovery"); + DBG(client, "Failed to start included services discovery"); discovery_op_unref(op); @@ -1110,8 +1113,7 @@ static bool discovery_parse_services(struct discovery_op *op, bool primary, /* Log debug message */ bt_uuid_to_string(&uuid, uuid_str, sizeof(uuid_str)); - util_debug(client->debug_callback, client->debug_data, - "start: 0x%04x, end: 0x%04x, uuid: %s", + DBG(client, "start: 0x%04x, end: 0x%04x, uuid: %s", start, end, uuid_str); /* Store the service */ @@ -1122,9 +1124,7 @@ static bool discovery_parse_services(struct discovery_op *op, bool primary, attr = gatt_db_insert_service(client->db, start, &uuid, false, end - start + 1); if (!attr) { - util_debug(client->debug_callback, - client->debug_data, - "Failed to store service"); + DBG(client, "Failed to store service"); return false; } /* Database has changed adjust last handle */ @@ -1157,8 +1157,7 @@ static void discover_secondary_cb(bool success, uint8_t att_ecode, att_ecode = 0; goto next; default: - util_debug(client->debug_callback, client->debug_data, - "Secondary service discovery failed." + DBG(client, "Secondary service discovery failed." " ATT ECODE: 0x%02x", att_ecode); goto done; } @@ -1169,8 +1168,7 @@ static void discover_secondary_cb(bool success, uint8_t att_ecode, goto done; } - util_debug(client->debug_callback, client->debug_data, - "Secondary services found: %u", + DBG(client, "Secondary services found: %u", bt_gatt_result_service_count(result)); if (!discovery_parse_services(op, false, &iter)) { @@ -1199,8 +1197,8 @@ next: if (client->discovery_req) return; - util_debug(client->debug_callback, client->debug_data, - "Failed to start included services discovery"); + DBG(client, "Failed to start included services discovery"); + discovery_op_unref(op); success = false; @@ -1226,8 +1224,7 @@ static void discover_primary_cb(bool success, uint8_t att_ecode, att_ecode = 0; goto secondary; default: - util_debug(client->debug_callback, client->debug_data, - "Primary service discovery failed." + DBG(client, "Primary service discovery failed." " ATT ECODE: 0x%02x", att_ecode); goto done; } @@ -1238,8 +1235,7 @@ static void discover_primary_cb(bool success, uint8_t att_ecode, goto done; } - util_debug(client->debug_callback, client->debug_data, - "Primary services found: %u", + DBG(client, "Primary services found: %u", bt_gatt_result_service_count(result)); if (!discovery_parse_services(op, true, &iter)) { @@ -1266,8 +1262,8 @@ secondary: if (client->discovery_req) return; - util_debug(client->debug_callback, client->debug_data, - "Failed to start secondary service discovery"); + DBG(client, "Failed to start secondary service discovery"); + discovery_op_unref(op); success = false; @@ -1331,8 +1327,7 @@ static void discover_all(struct discovery_op *op) if (client->discovery_req) return; - util_debug(client->debug_callback, client->debug_data, - "Failed to initiate primary service discovery"); + DBG(client, "Failed to initiate primary service discovery"); client->in_init = false; notify_client_ready(client, false, BT_ATT_ERROR_UNLIKELY); @@ -1345,8 +1340,7 @@ static void db_hash_write_value_cb(struct gatt_db_attribute *attrib, { struct bt_gatt_client *client = user_data; - util_debug(client->debug_callback, client->debug_data, - "Value set status: %d", err); + DBG(client, "Value set status: %d", err); } static void db_hash_read_value_cb(struct gatt_db_attribute *attrib, @@ -1377,9 +1371,8 @@ static void db_hash_read_cb(bool success, uint8_t att_ecode, bt_gatt_iter_init(&iter, result); bt_gatt_iter_next_read_by_type(&iter, &handle, &len, &value); - util_debug(client->debug_callback, client->debug_data, - "DB Hash found: handle 0x%04x length 0x%04x", - handle, len); + DBG(client, "DB Hash found: handle 0x%04x length 0x%04x", + handle, len); if (len != 16) goto discover; @@ -1390,15 +1383,14 @@ static void db_hash_read_cb(bool success, uint8_t att_ecode, /* Check if the has has changed since last time */ if (hash && !memcmp(hash, value, len)) { - util_debug(client->debug_callback, client->debug_data, - "DB Hash match: skipping discovery"); + DBG(client, "DB Hash match: skipping discovery"); queue_remove_all(op->pending_svcs, NULL, NULL, NULL); discovery_op_complete(op, true, 0); return; } - util_debug(client->debug_callback, client->debug_data, - "DB Hash value:"); + DBG(client, "DB Hash value:"); + util_hexdump(' ', value, len, client->debug_callback, client->debug_data); @@ -1469,8 +1461,7 @@ static void db_server_feat_read(bool success, uint8_t att_ecode, bt_gatt_iter_init(&iter, result); bt_gatt_iter_next_read_by_type(&iter, &handle, &len, &value); - util_debug(client->debug_callback, client->debug_data, - "Server Features found: handle 0x%04x " + DBG(client, "Server Features found: handle 0x%04x " "length 0x%04x value 0x%02x", handle, len, value[0]); @@ -1524,8 +1515,7 @@ static void exchange_mtu_cb(bool success, uint8_t att_ecode, void *user_data) client->mtu_req_id = 0; if (!success) { - util_debug(client->debug_callback, client->debug_data, - "MTU Exchange failed. ATT ECODE: 0x%02x", + DBG(client, "MTU Exchange failed. ATT ECODE: 0x%02x", att_ecode); /* @@ -1543,8 +1533,7 @@ static void exchange_mtu_cb(bool success, uint8_t att_ecode, void *user_data) return; } - util_debug(client->debug_callback, client->debug_data, - "MTU exchange complete, with MTU: %u", + DBG(client, "MTU exchange complete, with MTU: %u", bt_att_get_mtu(client->att)); discover: @@ -1749,7 +1738,7 @@ static void service_changed_register_cb(uint16_t att_ecode, void *user_data) struct bt_gatt_client *client = user_data; if (att_ecode) { - util_debug(client->debug_callback, client->debug_data, + DBG(client, "Failed to register handler for \"Service Changed\""); success = false; client->svc_chngd_ind_id = 0; @@ -1758,8 +1747,7 @@ static void service_changed_register_cb(uint16_t att_ecode, void *user_data) client->svc_chngd_registered = true; success = true; - util_debug(client->debug_callback, client->debug_data, - "Registered handler for \"Service Changed\": %u", + DBG(client, "Registered handler for \"Service Changed\": %u", client->svc_chngd_ind_id); done: @@ -1807,7 +1795,7 @@ static void service_changed_complete(struct discovery_op *op, bool success, client->in_svc_chngd = false; if (!success && att_ecode != BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND) { - util_debug(client->debug_callback, client->debug_data, + DBG(client, "Failed to discover services within changed range - " "error: 0x%02x", att_ecode); @@ -1841,7 +1829,7 @@ static void service_changed_complete(struct discovery_op *op, bool success, if (register_service_changed(client)) return; - util_debug(client->debug_callback, client->debug_data, + DBG(client, "Failed to re-register handler for \"Service Changed\""); } @@ -1877,9 +1865,8 @@ static void process_service_changed(struct bt_gatt_client *client, discovery_op_free(op); fail: - util_debug(client->debug_callback, client->debug_data, - "Failed to initiate service discovery" - " after Service Changed"); + DBG(client, + "Failed to initiate service discovery after Service Changed"); } static void service_changed_cb(uint16_t value_handle, const uint8_t *value, @@ -1896,13 +1883,12 @@ static void service_changed_cb(uint16_t value_handle, const uint8_t *value, end = get_le16(value + 2); if (start > end) { - util_debug(client->debug_callback, client->debug_data, + DBG(client, "Service Changed received with invalid handles"); return; } - util_debug(client->debug_callback, client->debug_data, - "Service Changed received - start: 0x%04x end: 0x%04x", + DBG(client, "Service Changed received - start: 0x%04x end: 0x%04x", start, end); if (!client->in_svc_chngd) { @@ -1923,8 +1909,7 @@ static void server_feat_write_value(struct gatt_db_attribute *attrib, { struct bt_gatt_client *client = user_data; - util_debug(client->debug_callback, client->debug_data, - "Server Features Value set status: %d", err); + DBG(client, "Server Features Value set status: %d", err); } static void write_server_features(struct bt_gatt_client *client, uint8_t feat) @@ -1943,8 +1928,7 @@ static void write_server_features(struct bt_gatt_client *client, uint8_t feat) if (!gatt_db_attribute_write(attr, 0, &feat, sizeof(feat), 0, NULL, server_feat_write_value, client)) - util_debug(client->debug_callback, client->debug_data, - "Unable to store Server Features"); + DBG(client, "Unable to store Server Features"); } static void write_client_features(struct bt_gatt_client *client) @@ -1981,8 +1965,7 @@ static void write_client_features(struct bt_gatt_client *client) client->features |= BT_GATT_CHRC_CLI_FEAT_NFY_MULTI; - util_debug(client->debug_callback, client->debug_data, - "Writing Client Features 0x%02x", client->features); + DBG(client, "Writing Client Features 0x%02x", client->features); bt_gatt_client_write_value(client, handle, &client->features, sizeof(client->features), NULL, NULL, NULL); @@ -2006,13 +1989,11 @@ static void init_complete(struct discovery_op *op, bool success, if (register_service_changed(client)) goto done; - util_debug(client->debug_callback, client->debug_data, - "Failed to register handler for \"Service Changed\""); + DBG(client, "Failed to register handler for \"Service Changed\""); success = false; fail: - util_debug(client->debug_callback, client->debug_data, - "Failed to initialize gatt-client"); + DBG(client, "Failed to initialize gatt-client"); op->success = false; @@ -3501,8 +3482,7 @@ unsigned int bt_gatt_client_prepare_write(struct bt_gatt_client *client, * prepare writes or this is brand new reliable session (id == 0) */ if (id != client->reliable_write_session_id) { - util_debug(client->debug_callback, client->debug_data, - "There is other reliable write session ongoing %u", + DBG(client, "There is other reliable write session ongoing %u", client->reliable_write_session_id); return 0; From patchwork Wed Mar 23 20:13:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 554667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BF40C433FE for ; Wed, 23 Mar 2022 20:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344565AbiCWUPY (ORCPT ); Wed, 23 Mar 2022 16:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344553AbiCWUPU (ORCPT ); Wed, 23 Mar 2022 16:15:20 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7EDC7655 for ; Wed, 23 Mar 2022 13:13:49 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id u17so2289153pfk.11 for ; Wed, 23 Mar 2022 13:13:49 -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=GFc9sXDCUSGMKzcmjKZL85zsIJOnPsCDkSf/Z7ucJ1E=; b=eYRmh8bMpjq60OForJLANcqAfIcK3DUJFYq/yZ67qH1owJfgZHMw24XUZCtKhduorC 99RW0owf2KwWSfao3fp6F9+Gp0nySaRuktipHOW6y7x+54WGD4ivP2dOPcoZz7EeYSZe f9KKheWHpW/ZVQglx2IIsUDbwTfZEfv04mx3n4rHEGTBOvtHQV+32b9baWJQgnoyuN8A CCurs4O5SIp2WOwRxok9pF8mFaobM9/2ixR+l15sDjDfDcVpadAy7hzpKAK5EmaPaK+d WLAAalhrhaLsme6Gdc5b/yCO/A/PxlFPk+Snz62wo1UXwS6XnfWxI6sd3CPTsf+ursqV J/kg== 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=GFc9sXDCUSGMKzcmjKZL85zsIJOnPsCDkSf/Z7ucJ1E=; b=KTkF87xfjed7BEC2k4MZAzwFGZ35oMxuZTml7RkPFsY0ZURMaBpXJfT7Iv4Oxrbtp6 I8uU1ZaYrzP7W3a5M48RfilbcmdzmY1Eya2fpuVCqiLdMxaYbLHAcD5j9up/uFqxiXsG qAeNAxM6lxuste7La278mM3o40EtzY44JX+C8SmbaLmcgzvlDL1XSJd6Mq7yuyuYpXwO 0Xwvu6Q36ygR2jnf9nNZVXm1baQHkMhNy/eV3OxtBzjBCZOvesV6rzVN5k669A5ayu4l cyeGyONeqyAYiIeNuLgjapvKQAgcUFLBd3qZZn/6Qe+sx4AHkzsh36WUqIVwJH7Pn/3B p9aw== X-Gm-Message-State: AOAM533nYWz5VEe0J+0opOJaAApF9YNIhecXLXCk1MuMcQ8s9qdIqdTs IIHjddklGuZcyQSi+WYc7SNmU7yXGaA= X-Google-Smtp-Source: ABdhPJxGZKh496622iTltAIEXhGzOoxI+mDsDGr+eqVooYkUVe09sSeL4MgsP6LWw1MBc0+mIyVhFQ== X-Received: by 2002:a63:4b1e:0:b0:365:8bc:6665 with SMTP id y30-20020a634b1e000000b0036508bc6665mr1208809pga.445.1648066428928; Wed, 23 Mar 2022 13:13:48 -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.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 13:13:48 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 7/9] gatt-server: Add DBG macro Date: Wed, 23 Mar 2022 13:13:39 -0700 Message-Id: <20220323201341.3596128-8-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds gatt_log wrapper for util_debug and DBG so file and function names are printed with the logs. --- src/shared/gatt-server.c | 64 ++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c index 776e5ce2b..2adb4afbf 100644 --- a/src/shared/gatt-server.c +++ b/src/shared/gatt-server.c @@ -41,6 +41,9 @@ #define NFY_MULT_TIMEOUT 10 +#define DBG(_server, _format, arg...) \ + gatt_log(_server, "%s:%s() " _format, __FILE__, __func__, ## arg) + struct async_read_op { struct bt_att_chan *chan; struct bt_gatt_server *server; @@ -233,6 +236,18 @@ static bool encode_read_by_grp_type_rsp(struct gatt_db *db, struct queue *q, return true; } +static void gatt_log(struct bt_gatt_server *server, const char *format, ...) +{ + va_list ap; + + if (!server || !format || !server->debug_callback) + return; + + va_start(ap, format); + util_debug_va(server->debug_callback, server->debug_data, format, ap); + va_end(ap); +} + static void read_by_grp_type_cb(struct bt_att_chan *chan, uint8_t opcode, const void *pdu, uint16_t length, void *user_data) @@ -259,9 +274,7 @@ static void read_by_grp_type_cb(struct bt_att_chan *chan, uint8_t opcode, end = get_le16(pdu + 2); get_uuid_le(pdu + 4, length - 4, &type); - util_debug(server->debug_callback, server->debug_data, - "Read By Grp Type - start: 0x%04x end: 0x%04x", - start, end); + DBG(server, "Read By Grp Type - start: 0x%04x end: 0x%04x", start, end); if (!start || !end) { ecode = BT_ATT_ERROR_INVALID_HANDLE; @@ -483,9 +496,7 @@ static void read_by_type_cb(struct bt_att_chan *chan, uint8_t opcode, end = get_le16(pdu + 2); get_uuid_le(pdu + 4, length - 4, &type); - util_debug(server->debug_callback, server->debug_data, - "Read By Type - start: 0x%04x end: 0x%04x", - start, end); + DBG(server, "Read By Type - start: 0x%04x end: 0x%04x", start, end); if (!start || !end) { ecode = BT_ATT_ERROR_INVALID_HANDLE; @@ -605,9 +616,7 @@ static void find_info_cb(struct bt_att_chan *chan, uint8_t opcode, start = get_le16(pdu); end = get_le16(pdu + 2); - util_debug(server->debug_callback, server->debug_data, - "Find Info - start: 0x%04x end: 0x%04x", - start, end); + DBG(server, "Find Info - start: 0x%04x end: 0x%04x", start, end); if (!start || !end) { ecode = BT_ATT_ERROR_INVALID_HANDLE; @@ -708,9 +717,10 @@ static void find_by_type_val_cb(struct bt_att_chan *chan, uint8_t opcode, end = get_le16(pdu + 2); uuid16 = get_le16(pdu + 4); - util_debug(server->debug_callback, server->debug_data, - "Find By Type Value - start: 0x%04x end: 0x%04x uuid: 0x%04x", - start, end, uuid16); + DBG(server, + "Find By Type Value - start: 0x%04x end: 0x%04x uuid: 0x%04x", + start, end, uuid16); + ehandle = start; if (start > end) { data.ecode = BT_ATT_ERROR_INVALID_HANDLE; @@ -756,8 +766,7 @@ static void write_complete_cb(struct gatt_db_attribute *attr, int err, return; } - util_debug(server->debug_callback, server->debug_data, - "Write Complete: err %d", err); + DBG(server, "Write Complete: err %d", err); handle = gatt_db_attribute_get_handle(attr); @@ -818,10 +827,8 @@ static void write_cb(struct bt_att_chan *chan, uint8_t opcode, const void *pdu, goto error; } - util_debug(server->debug_callback, server->debug_data, - "Write %s - handle: 0x%04x", - (opcode == BT_ATT_OP_WRITE_REQ) ? "Req" : "Cmd", - handle); + DBG(server, "Write %s - handle: 0x%04x", + (opcode == BT_ATT_OP_WRITE_REQ) ? "Req" : "Cmd", handle); ecode = check_length(length, 0); if (ecode) @@ -885,8 +892,7 @@ static void read_complete_cb(struct gatt_db_attribute *attr, int err, uint16_t mtu; uint16_t handle; - util_debug(server->debug_callback, server->debug_data, - "Read Complete: err %d", err); + DBG(server, "Read Complete: err %d", err); mtu = bt_att_get_mtu(server->att); handle = gatt_db_attribute_get_handle(attr); @@ -922,10 +928,8 @@ static void handle_read_req(struct bt_att_chan *chan, goto error; } - util_debug(server->debug_callback, server->debug_data, - "Read %sReq - handle: 0x%04x", - opcode == BT_ATT_OP_READ_BLOB_REQ ? "Blob " : "", - handle); + DBG(server, "Read %sReq - handle: 0x%04x", + opcode == BT_ATT_OP_READ_BLOB_REQ ? "Blob " : "", handle); ecode = check_permissions(server, attr, BT_ATT_PERM_READ_MASK); if (ecode) @@ -1125,8 +1129,7 @@ static void read_multiple_cb(struct bt_att_chan *chan, uint8_t opcode, handle = data->handles[0]; - util_debug(server->debug_callback, server->debug_data, - "%s Req - %zu handles, 1st: 0x%04x", + DBG(server, "%s Req - %zu handles, 1st: 0x%04x", data->opcode == BT_ATT_OP_READ_MULT_REQ ? "Read Multiple" : "Read Multiple Variable Length", data->num_handles, handle); @@ -1312,8 +1315,7 @@ static void prep_write_cb(struct bt_att_chan *chan, uint8_t opcode, goto error; } - util_debug(server->debug_callback, server->debug_data, - "Prep Write Req - handle: 0x%04x", handle); + DBG(server, "Prep Write Req - handle: 0x%04x", handle); ecode = check_length(length, offset); if (ecode) @@ -1433,8 +1435,7 @@ static void exec_write_cb(struct bt_att_chan *chan, uint8_t opcode, flags = ((uint8_t *) pdu)[0]; - util_debug(server->debug_callback, server->debug_data, - "Exec Write Req - flags: 0x%02x", flags); + DBG(server, "Exec Write Req - flags: 0x%02x", flags); if (flags == 0x00) write = false; @@ -1505,8 +1506,7 @@ static void exchange_mtu_cb(struct bt_att_chan *chan, uint8_t opcode, server->mtu = final_mtu; bt_att_set_mtu(server->att, final_mtu); - util_debug(server->debug_callback, server->debug_data, - "MTU exchange complete, with MTU: %u", final_mtu); + DBG(server, "MTU exchange complete, with MTU: %u", final_mtu); } static bool gatt_server_register_att_handlers(struct bt_gatt_server *server) From patchwork Wed Mar 23 20:13:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 554666 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A8EEC4332F for ; Wed, 23 Mar 2022 20:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344567AbiCWUPY (ORCPT ); Wed, 23 Mar 2022 16:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344555AbiCWUPV (ORCPT ); Wed, 23 Mar 2022 16:15:21 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80D7C6576 for ; Wed, 23 Mar 2022 13:13:50 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id t13so829204pgn.8 for ; Wed, 23 Mar 2022 13:13:50 -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=A5mU7ZW/EoX09OtoTGJHt6b6/ozCCsZy6iGJ/CCN76Y=; b=H3FzOY1VOLiGbSf3bcZgwJOAog+ocvS09VQY+JEa5jE+OFZRUhfDVnygVE2emEz8vz WxU5+tO8N0AKUAP/kuhx6L8r7BUHzNjBD0wNFO63shiKZUnEYaZoNwU3efsyltuvr7iu bzyQS7r6whNn7sGJbO557ThH8ujuKmETYvK6ZyfLNVZ0IsBmgipLcCR2w2avlWnnBOXt 0fK3arbJxuZv6bUeDl1hwNpjTPiCq3nFeaZvWEOzeVqswU/9hg6qTabDDeC9bZrkwjCu EWQgBgsjXDe9Jxg8jpgBL6dxaPxIRL4kaLS00/JHH3NCd3o6vISEX3UI9hjD55M9DTzO OWFA== 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=A5mU7ZW/EoX09OtoTGJHt6b6/ozCCsZy6iGJ/CCN76Y=; b=RjZdsD+uTI/TEY45hOdNkCgDFcQBIYPn6UzZOMs/cA92AovgFggwPep+kOnz+ycEQy xqcLQYsoECN9Bt7mujesenG5gH7zG8XSmeit0aN8sSAXndcqVn2JyQylYSq5fXesQ9cN +63CePL9WqH5H6WrzNwCwW9Cbd8pjhjASboZkIJrP3yh0fjUx5ERiW6uPa2fOUH4p554 8GwmkFXwu6Ioqs5QPVyvvjauHdogkj3hVezjpvY45cZDJbLQr73+aBqU7f4G+QCgbw0J hdR4u0w+talTNaiisNsWXcz1SLd4gx/ncP+CbdWb8kGsTZ4/ZnSoulO5Voe17syLMtu+ QUSw== X-Gm-Message-State: AOAM5325KINUBiyHQbZt77duK0Ty1+eluGp0IRnIJDQbRVm8oHwR8QbT XQgDFn+y1p/ARcZTZItuFKY/sDGQZoU= X-Google-Smtp-Source: ABdhPJzqMRoNlOnQXBRGFrj7rPUVMQC4fKdB5XuvZGEWuxSrXfu/y8Wqi/H07ewMAhR78jY1cOgnVQ== X-Received: by 2002:a05:6a00:1312:b0:4e1:58c4:ddfd with SMTP id j18-20020a056a00131200b004e158c4ddfdmr1207246pfu.65.1648066429649; Wed, 23 Mar 2022 13:13:49 -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.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 13:13:49 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 8/9] att: Rename att_debug and att_verbose to DBG and VERBOSE Date: Wed, 23 Mar 2022 13:13:40 -0700 Message-Id: <20220323201341.3596128-9-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz att_debug and att_verbose are macros which are more common to be used as uppercase, this also change them to use DBG like other parts of the code. --- src/shared/att.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/shared/att.c b/src/shared/att.c index 7344b0c46..f7bef08bc 100644 --- a/src/shared/att.c +++ b/src/shared/att.c @@ -307,11 +307,11 @@ static void att_log(struct bt_att *att, uint8_t level, const char *format, va_end(va); } -#define att_debug(_att, _format, _arg...) \ +#define DBG(_att, _format, _arg...) \ att_log(_att, BT_ATT_DEBUG, "%s:%s() " _format, __FILE__, __func__,\ ## _arg) -#define att_verbose(_att, _format, _arg...) \ +#define VERBOSE(_att, _format, _arg...) \ att_log(_att, BT_ATT_DEBUG_VERBOSE, "%s:%s() " _format, __FILE__, \ __func__, ## _arg) @@ -359,7 +359,7 @@ static bool encode_pdu(struct bt_att *att, struct att_send_op *op, sign_cnt, &((uint8_t *) op->pdu)[1 + length]))) return true; - att_debug(att, "ATT unable to generate signature"); + DBG(att, "ATT unable to generate signature"); fail: free(op->pdu); @@ -488,7 +488,7 @@ static bool timeout_cb(void *user_data) if (!op) return false; - att_debug(att, "(chan %p) Operation timed out: 0x%02x", chan, + DBG(att, "(chan %p) Operation timed out: 0x%02x", chan, op->opcode); if (att->timeout_callback) @@ -524,11 +524,11 @@ static ssize_t bt_att_chan_write(struct bt_att_chan *chan, uint8_t opcode, iov.iov_base = (void *) pdu; iov.iov_len = len; - att_verbose(att, "(chan %p) ATT op 0x%02x", chan, opcode); + VERBOSE(att, "(chan %p) ATT op 0x%02x", chan, opcode); ret = io_send(chan->io, &iov, 1); if (ret < 0) { - att_debug(att, "(chan %p) write failed: %s", chan, + DBG(att, "(chan %p) write failed: %s", chan, strerror(-ret)); return ret; } @@ -661,12 +661,12 @@ static bool disconnect_cb(struct io *io, void *user_data) len = sizeof(err); if (getsockopt(chan->fd, SOL_SOCKET, SO_ERROR, &err, &len) < 0) { - att_debug(att, "(chan %p) Failed to obtain disconnect " + DBG(att, "(chan %p) Failed to obtain disconnect " "error: %s", chan, strerror(errno)); err = 0; } - att_debug(att, "Channel %p disconnected: %s", chan, strerror(err)); + DBG(att, "Channel %p disconnected: %s", chan, strerror(err)); /* Dettach channel */ queue_remove(att->chans, chan); @@ -795,7 +795,7 @@ static bool handle_error_rsp(struct bt_att_chan *chan, uint8_t *pdu, op->timeout_id = 0; } - att_debug(att, "(chan %p) Retrying operation %p", chan, op); + DBG(att, "(chan %p) Retrying operation %p", chan, op); chan->pending_req = NULL; @@ -818,7 +818,7 @@ static void handle_rsp(struct bt_att_chan *chan, uint8_t opcode, uint8_t *pdu, * the bearer. */ if (!op) { - att_debug(att, "(chan %p) Received unexpected ATT response", + DBG(att, "(chan %p) Received unexpected ATT response", chan); io_shutdown(chan->io); return; @@ -850,7 +850,7 @@ static void handle_rsp(struct bt_att_chan *chan, uint8_t opcode, uint8_t *pdu, goto done; fail: - att_debug(att, "(chan %p) Failed to handle response PDU; opcode: " + DBG(att, "(chan %p) Failed to handle response PDU; opcode: " "0x%02x", chan, opcode); rsp_opcode = BT_ATT_OP_ERROR_RSP; @@ -875,7 +875,7 @@ static void handle_conf(struct bt_att_chan *chan, uint8_t *pdu, ssize_t pdu_len) * invalid. */ if (!op || pdu_len) { - att_debug(att, "(chan %p) Received unexpected/invalid ATT " + DBG(att, "(chan %p) Received unexpected/invalid ATT " "confirmation", chan); io_shutdown(chan->io); return; @@ -949,7 +949,7 @@ static bool handle_signed(struct bt_att *att, uint8_t *pdu, ssize_t pdu_len) return true; fail: - att_debug(att, "ATT failed to verify signature: 0x%02x", opcode); + DBG(att, "ATT failed to verify signature: 0x%02x", opcode); return false; } @@ -1032,7 +1032,7 @@ static bool can_read_data(struct io *io, void *user_data) if (bytes_read < 0) return false; - att_verbose(att, "(chan %p) ATT received: %zd", chan, bytes_read); + VERBOSE(att, "(chan %p) ATT received: %zd", chan, bytes_read); att_hexdump(att, '>', chan->buf, bytes_read); @@ -1047,12 +1047,12 @@ static bool can_read_data(struct io *io, void *user_data) /* Act on the received PDU based on the opcode type */ switch (get_op_type(opcode)) { case ATT_OP_TYPE_RSP: - att_verbose(att, "(chan %p) ATT response received: 0x%02x", + VERBOSE(att, "(chan %p) ATT response received: 0x%02x", chan, opcode); handle_rsp(chan, opcode, pdu + 1, bytes_read - 1); break; case ATT_OP_TYPE_CONF: - att_verbose(att, "(chan %p) ATT confirmation received: 0x%02x", + VERBOSE(att, "(chan %p) ATT confirmation received: 0x%02x", chan, opcode); handle_conf(chan, pdu + 1, bytes_read - 1); break; @@ -1063,7 +1063,7 @@ static bool can_read_data(struct io *io, void *user_data) * promptly notify the upper layer via disconnect handlers. */ if (chan->in_req) { - att_debug(att, "(chan %p) Received request while " + DBG(att, "(chan %p) Received request while " "another is pending: 0x%02x", chan, opcode); io_shutdown(chan->io); @@ -1083,7 +1083,7 @@ static bool can_read_data(struct io *io, void *user_data) /* For all other opcodes notify the upper layer of the PDU and * let them act on it. */ - att_debug(att, "(chan %p) ATT PDU received: 0x%02x", chan, + DBG(att, "(chan %p) ATT PDU received: 0x%02x", chan, opcode); handle_notify(chan, pdu, bytes_read); break; @@ -1237,7 +1237,7 @@ static void bt_att_attach_chan(struct bt_att *att, struct bt_att_chan *chan) io_set_close_on_destroy(chan->io, att->close_on_unref); - att_debug(att, "Channel %p attached", chan); + DBG(att, "Channel %p attached", chan); wakeup_chan_writer(chan, NULL); } From patchwork Wed Mar 23 20:13:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 553792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09953C43217 for ; Wed, 23 Mar 2022 20:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344564AbiCWUPZ (ORCPT ); Wed, 23 Mar 2022 16:15:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344556AbiCWUPV (ORCPT ); Wed, 23 Mar 2022 16:15:21 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1ED38A31B for ; Wed, 23 Mar 2022 13:13:50 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id o8so2058467pgf.9 for ; Wed, 23 Mar 2022 13:13:50 -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=JQd7+rMFUQKBJW1Dugx9ash6Vc9jS9PWkT5mnwXt32w=; b=QtLFqSb3zcPnDFnpKUpG2vzQHW7T+AWIGWavqAJ1TGl1WPBLxelDhbmaO89T0eS7LR AXhjQyHsQceU/Q8QHluUUH3oUVwTw3OjJHptCKLWZ/L5aGsyAhJpBIbbFEC1RTYwuc3+ lloRgBMcVvM2r+2SIBOYsnZMpxcVIUMe92fRU2vhrsbCZr+N5jkEvW4FjE6LdMlD21UT +salQU/wD5OVh0BpwXLQ38NZAU6VRrCuYh0l3kjjCA4OnNeSUwlJ+oZH+BQQleuZagSo vxZSP36wBpPCOOGQNHiUE3pHRqNG/UEpHMMnKt+eqYRJ2B+4g0aEutlC4I1rRm8YQk6g WuGw== 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=JQd7+rMFUQKBJW1Dugx9ash6Vc9jS9PWkT5mnwXt32w=; b=6gujcIfKxiSG2Payn86rWYzc4/Tt8sBhwIf6XRDQQ/RmZ8FdBdzN3CX9vJ7zPpJEzL nOnaP/Q1XgOPXkwd0hmS6c3sSwtZ/8UIndlwbhKUtMRUwHfdamwd8ZuEEwuQDy2lQEXZ 4wcjUnaVa6lNUUGWumXk4BQyQn3r8OeYlDKGBwVc9DPd78vtjFlCnsd0/afhbKYvHmGe OuCBegS4LauiHk0cdcMApj2xH+clC+9QfqKXm9ATpe1HsH35kDuCWqg6uDahPmjdUaBe QiULwEdO074jqlWTL6ObiLLfl4wJLSMFF7RbQz7l/OGgLcYIe6j5eC1ZqCiwDFTrpTx+ IPPQ== X-Gm-Message-State: AOAM530UAA9larNAeqZpoz6fma2uvhID1B0qIuRwDQEigIBwbfEUjnEE hPf7j5riKo6ngwGT42UhQ/zbuzhNTOI= X-Google-Smtp-Source: ABdhPJyaa4sK27w5t1aCNBfVH1SnMGrkSaEuxD/BXrzk7O9TLSscqLu7xW4nD9WcJAvtFgHO+7YDVA== X-Received: by 2002:a63:4721:0:b0:382:70fa:479d with SMTP id u33-20020a634721000000b0038270fa479dmr1240455pga.259.1648066430230; Wed, 23 Mar 2022 13:13:50 -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.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 13:13:49 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 9/9] device: Don't use DBG in gatt_debug Date: Wed, 23 Mar 2022 13:13:41 -0700 Message-Id: <20220323201341.3596128-10-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 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz gatt_debug callback is used to print debug strings from bt_att which includes the file and function names so using DBG would add yet another set of file and function prefixes which makes the logs confusing. --- src/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index 3992f9a0c..381faf91c 100644 --- a/src/device.c +++ b/src/device.c @@ -5545,7 +5545,7 @@ static void gatt_client_service_changed(uint16_t start_handle, static void gatt_debug(const char *str, void *user_data) { - DBG("%s", str); + DBG_IDX(0xffff, "%s", str); } static void gatt_client_init(struct btd_device *device)