From patchwork Wed Mar 23 22:39:55 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: 554664 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 B3756C433F5 for ; Wed, 23 Mar 2022 22:40:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345288AbiCWWlh (ORCPT ); Wed, 23 Mar 2022 18:41:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234878AbiCWWlg (ORCPT ); Wed, 23 Mar 2022 18:41:36 -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 24A3D3631A for ; Wed, 23 Mar 2022 15:40:06 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id o6-20020a17090a9f8600b001c6562049d9so3286595pjp.3 for ; Wed, 23 Mar 2022 15:40:06 -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=FHmrDzWf34S+VIdONSZXDksFW5be3bZdPT1V47AMKuk=; b=U0+ijJyuiwN/VsQM0kUvQ1kUQa4l+CrFTIKKdQezUq/d/snnt7xsZnPrl4UnKu5oCH uBJ3Xj2oO24jMbIHceYxtFUNeuhW0pkkKP31bkdw/qt+9wjUyZ6YL55+SsnV+ti0xy3X wFaTWssaYUjCLHQP83/f7DgetQCqc/QkG6gqZuOYhQLemfay3g5gog0hrEgO/p/kvILE gWoDzm+lsPlJ/sNNDETWp67pK0NqkUcMtI9Kx+SDC6WHI0PBkk4JI910nhDSoT0p0Psm gh3tBBCKA1cK4Sj4GZibV/uLLtEOEdUc0xc7XPIphUP611uFQrelbFd1bwRrrOx6jDZm q2sg== 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=FHmrDzWf34S+VIdONSZXDksFW5be3bZdPT1V47AMKuk=; b=ohG1DAV61RmY9JOIMI+UdkbSx4cAfhmAUmyL3LmbF6K65vY6cSk53rIQICCuJrnOJ4 JD5jAxn5KrAyO0aD7u7/11x65gC6BfHJBES4Lbxy/E3iO4sWRnHp5xvfiWCPfL6GGjFn 4pxaB05gtCmliKyE19Xc1YpYE5/UvrAfKpIVQ7z+uA6ky6fXRjJI7AKq9kpZM4Zo2xcI xC/14mha6Tv/zIvjQ2PWg7IjpOdCnNhMmvdCE/t90dIA34gKJflvDtn2W2V+YIorXTnf G19LOyaaGt/V5QPD5M6YWOHmMNG1OwHU40TAplJ/WnXVV7lLwoT5dy0G9q3AqD1GzVzh 0ohA== X-Gm-Message-State: AOAM5333AgP8flu+kxTEYKGhfyDf/xxgKz0o4b+fgidJeLTzeZbu0NqM obJYLrm80f+GZwV34lqXp2E35anoKLg= X-Google-Smtp-Source: ABdhPJz392a64SXhInlh6t/l3RPZXBbr2o2kRDxgcA98Ub6Xiw/tmSmEs065Ay7QMEFBM7VXEA62EA== X-Received: by 2002:a17:90b:33d2:b0:1c6:f3c1:49c3 with SMTP id lk18-20020a17090b33d200b001c6f3c149c3mr2309990pjb.82.1648075205426; Wed, 23 Mar 2022 15:40:05 -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 z14-20020aa7888e000000b004f79f59827asm825109pfe.139.2022.03.23.15.40.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 15:40:05 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 1/9] log: Don't log __FILE__ and __func__ with DBG_IDX Date: Wed, 23 Mar 2022 15:39:55 -0700 Message-Id: <20220323224003.3736525-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323224003.3736525-1-luiz.dentz@gmail.com> References: <20220323224003.3736525-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 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..1ed742a0d 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 22:39:56 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: 553789 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 1AAA9C433EF for ; Wed, 23 Mar 2022 22:40:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345293AbiCWWli (ORCPT ); Wed, 23 Mar 2022 18:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345286AbiCWWlh (ORCPT ); Wed, 23 Mar 2022 18:41:37 -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 EA046369F7 for ; Wed, 23 Mar 2022 15:40:06 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id l4-20020a17090a49c400b001c6840df4a3so3323013pjm.0 for ; Wed, 23 Mar 2022 15:40:06 -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=YPFTFboKlOndWgAUCm6AvrIuwl1S7MFfxR9g/5W7N4RjfcDndJkrYpZ9GyicikdWpr IULDJncDyVX/7Mnm9nA8yhpl3N9ntTLE9WoClz4g4zswV3C23eGU3YaLmB7rTwaDWfwk gNNu0MVwnS+4uWwJLCI3yOTvMoNvNrXXmB/x72ecuvVDskTSTnzdc4uabwtX9YDuC3tQ o6h1cyiU4iFOCiGNr80YS8sNFO/AhB0tbGQedZ9QS1fY9PrMUtvJfenySs53erLd5VpJ EGf7tio1VcKhKbhNRUfDXYX96ABN55CO1HvIqwI9nPlRtg25tIA1mlqGzfsXz5ZwwwGh aSwQ== 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=tMHF3zZmEbyGTJatqd04MkDVbs5UH9h5BApao8Z8b/mR4Te5LXlWpu8XoEDXzYDIdy 2QmZN/vu5wOpxmtL/pZZlJj6Xr63kUSP9pX7/QvdF+W1HO1VDJ3bltJPwpzFxiZmjlYa gEe82wzT/zaATdcEWDQ9ijw2yXkvckK53fzGDcb7ZIaleepFvs/HASt0MZF7UQuPXQ97 2u75Ea4hdzsZZIHZJXRSRfLdUcJXY3ZAF5BiuKme1KzyiMRRMzjkLvVKvVLdMm0BRMHM vTVmAQGQ0vOe7y3CsEwpinTVFJh8gX2NdALHcCVtaf/fiL+OkSGYQxIZxo8dkL0Sjyw3 Yq5A== X-Gm-Message-State: AOAM531VZZ1lKDuqWhsDsQlN+26K16r4YVhongxEz6xh2Yxep7R64V6z QBtbDRwBTnt/F5HRvB3FrdqfOBycmcU= X-Google-Smtp-Source: ABdhPJzXwjyHoTMz/lTwRHmwE3nFJMfVwdPN9ivACe14eFv/vsKf7444Fne+KaYF/0FdAdwZ/5KGsA== X-Received: by 2002:a17:902:bcc2:b0:14f:23c6:c8c5 with SMTP id o2-20020a170902bcc200b0014f23c6c8c5mr2237566pls.131.1648075206182; Wed, 23 Mar 2022 15:40:06 -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 z14-20020aa7888e000000b004f79f59827asm825109pfe.139.2022.03.23.15.40.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 15:40:05 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 2/9] mgmt: Add DBG macro Date: Wed, 23 Mar 2022 15:39:56 -0700 Message-Id: <20220323224003.3736525-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323224003.3736525-1-luiz.dentz@gmail.com> References: <20220323224003.3736525-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 22:39:57 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: 554663 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 1F63AC433FE for ; Wed, 23 Mar 2022 22:40:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345295AbiCWWlj (ORCPT ); Wed, 23 Mar 2022 18:41:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234878AbiCWWli (ORCPT ); Wed, 23 Mar 2022 18:41:38 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1AA53700E for ; Wed, 23 Mar 2022 15:40:07 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id q11so2934086pln.11 for ; Wed, 23 Mar 2022 15:40:07 -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=OCoJjugXv3fAwv37gTfyfV/CRW9+mGz4qfNPMBLYwzQwoRlOOXhCYSMbwge4dCw5Zb ngZ7mn2bgUDST6e0Ii+1Hh2MP3K1ya/UU8iYIcZOmtyoLEz2Ppy4dNL7dnuDArjJkIYZ 5hMoA7dczU3ZttBxQFahoeaboQlEE0V9LDRELSHFGLTbqL0O0vdvwU3WeIJQWUjMEZ+4 rBAa7aGcOb4IKZpvzgeyQIQ8m8ov501ktmBU6eD9JrKmUCduGL1BR4JDjeSf/kKit9OW +j/RYz8M+8etYiha6jAMp3ifakHPZvdRn3U5ewkfA3TIXbcoG0hlO9ejRCyXN050CLra Ch4w== 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=uLyX0zy2mxSS7Z4P8ZEFr+x/F9AVnlc7pBb9NTCoIAcvJ8799XT+w+NL726553Rk9b jdcmrGJXK714KFBA7tkioH5xhH+zZDhZlmDEhp8ASlmYX7A+vNFmXAQ7dtWr5ICWh5ZR W9JtpZV/49+wcslUk1roNEenBUcsZekWs6/8Sp4qybTxTWyqP58ubsXgwN1EpvL2Iam5 wbvw/Q4338Zr1PJ+8YhDfF9gMtaP6ZtrTAdbh3uruvJpXuZgXTPwlnBMeoFn/uIqWTrk 7ADnCBQz8xpe9hlZFX+4YynivkYXFNZbog7vvLGaYybMRu32cXMZzCW3tpcU12Q841te X1qQ== X-Gm-Message-State: AOAM530wfpJHXMOxvBaPzbgNyWMJyKF6qkcSALspcrhXXcaTnAanbvr1 JGetlUqBXGOiTGDRevyvV7R67EcUZxM= X-Google-Smtp-Source: ABdhPJwRN43kPjKvGz8jivr0VbM2Sw/jmKlatPhEpgQ9pk9AYhCALBZrXT2l7/xvKuUdLNdZPeSQzA== X-Received: by 2002:a17:903:2311:b0:154:609e:1e1e with SMTP id d17-20020a170903231100b00154609e1e1emr2502588plh.119.1648075206973; Wed, 23 Mar 2022 15:40:06 -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 z14-20020aa7888e000000b004f79f59827asm825109pfe.139.2022.03.23.15.40.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 15:40:06 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 3/9] mgmt: Introduce mgmt_set_verbose Date: Wed, 23 Mar 2022 15:39:57 -0700 Message-Id: <20220323224003.3736525-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323224003.3736525-1-luiz.dentz@gmail.com> References: <20220323224003.3736525-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 22:39:58 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: 553788 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 8F7F5C433EF for ; Wed, 23 Mar 2022 22:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345282AbiCWWlk (ORCPT ); Wed, 23 Mar 2022 18:41:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345294AbiCWWli (ORCPT ); Wed, 23 Mar 2022 18:41:38 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AB4D377EE for ; Wed, 23 Mar 2022 15:40:08 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id mr5-20020a17090b238500b001c67366ae93so7758937pjb.4 for ; Wed, 23 Mar 2022 15:40:08 -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=OYMwBDqTPNO8GyuQ80dCFEskMbxUjic7bnPds+7aFQQfWABsBtMugv4fjAWh8J6eFm n0RDNWFbFTVhqgJX1ZVv8Rnr5tCPIfrVvxPowInb+mduXE5LZQMgIFSLIeWZOIXPNVKa +5T7n2X2U9H7Quoj0HRJD9lhjOIlhQWwgPP3wfyWaQBkzi3a9UDcCp2j87sq/6D+GoDV +VknyMI7aA12bZ/tJlcWdWe3gOeiL35KvJRrYtfT1SZlQWiEI78A6+BQX2IhdrraTlz1 GlT0rBWZnhUFswbTmaQTsG1n8WS2JvWIGeKBAGbb38WHFEZGaCa8cQoNQ/WEU/FfcFcT wS1w== 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=QFOXoSaa8oDAbC1KuwWaeAdptFxFmgq+G25ajhqZJVsHTXwNNTTtiaopOOt8kUImH4 +k9VPsBfr8m6611U4qOXUIxnR5S9SueCfaN8PM5vgQ2PCtZC/ZRP912y3S/EW57QVN1/ NmPrUJL6EfUEKL8esx6zrPRQ2a4osvJrMMedKmlkdvGW+aX+M9n9LxkUGClsxulVU6Ws 0OmpXfVQjXIiQztt5A8NWaF4RTubkDOdy5/kWGz+NZysmgSzR3quS/P+ihjHq+C/x+fL 4A8VMA8FAKSyRzy9hK5dIUHeIeQSDeeSzp651gayiesAwpx+RzdX+NdJva9slfGev3dQ x8sw== X-Gm-Message-State: AOAM531e+hpG7LQOEBw+IsdvKIY0HGK+Xl8FSgFel0fkps+vKVMLkn8f AiM8NGojrGOk5Nf+0r0PQHICluJ7c7g= X-Google-Smtp-Source: ABdhPJxIPMz576KDA9TefTQb1t+03xiwbNYyrhWs415yGDrht0uOyiXCCrsTZ69888XntsMrywusug== X-Received: by 2002:a17:902:ac88:b0:153:a34f:5648 with SMTP id h8-20020a170902ac8800b00153a34f5648mr2396864plr.121.1648075207739; Wed, 23 Mar 2022 15:40:07 -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 z14-20020aa7888e000000b004f79f59827asm825109pfe.139.2022.03.23.15.40.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 15:40:07 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 4/9] adapter: Don't use DBG in mgmt_debug Date: Wed, 23 Mar 2022 15:39:58 -0700 Message-Id: <20220323224003.3736525-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323224003.3736525-1-luiz.dentz@gmail.com> References: <20220323224003.3736525-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 22:39:59 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: 554662 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 43244C433FE for ; Wed, 23 Mar 2022 22:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345306AbiCWWln (ORCPT ); Wed, 23 Mar 2022 18:41:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345292AbiCWWlj (ORCPT ); Wed, 23 Mar 2022 18:41:39 -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 59E0A37A87 for ; Wed, 23 Mar 2022 15:40:09 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id l4-20020a17090a49c400b001c6840df4a3so3323087pjm.0 for ; Wed, 23 Mar 2022 15:40:09 -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=gaN6Sk3iynJub0LEby4Jvvie7+P0Mavk4AtDvEVqxc78dnUQgfvr+BzEfB/si20Nb6 FupS2cZ9m+rhuVHOm1SJH31OrNUSnZFZ4ZM1L+ydHSZX8f7qzOyzCnKF/zafflrOEz26 FPYJIrhc8IHElcRWayR2D9tRQsP9vUXuzNhc65HKggqlOmA1vsa4nUhKQL1W1oBPX/+l WgJ0GVxVrFy1aYCCskqgeSV0GZ/xo4XqIea9s7RSqUD1re9bxaZdZvDsaCvLBhBI2U4g 4kIOHmMoV0Fn5DKtbg+kp1ujOwWyE8E2SnP/YQFJw3vZcqfzJauKCVUFc/GXwHc6u6ZD 090Q== 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=VDvWaHoqdEx2Y7coAXS3kDkvbtYDUtVHSq7jf0nvlwhyLccZni+5Ayno+uAM3ADTPz k/gH8aZLd39p9k6bVPAhPxYdViOfxhIM4AAyCdL2BFnv03LsQWBOwtzVJbsnSIhd1XR5 pphwMUDRSuJ4B5mekq1z8uoT3GK95IKwKGQEDEyxPbZ5B8ptaAhTQvhPS13Ue3DKWLmN LkpkcRWIWiuTIB68df+dfQ3IF4xNV5oSrpPdyX/GOOW0tWvBwa3SNchBqmrelpXPD75l KfxmoINZrxc00xvLE3W6RgV9NmNzR03ydVPyTvPgH9SFNnseUCy+aYxATpD7qpl/ivVo 4C2Q== X-Gm-Message-State: AOAM531j9nQJ4Igz5XOUGwj21mloRgTJrtDFs/FSaNh/Pybq1k/Mm4RR 2OyYRf8HoyxY8jewd+V5R5E2P3RHRlo= X-Google-Smtp-Source: ABdhPJw9nWfr6yGgypcQ9M5fFHAyxFkPj1jUddw0Uofc2LtkJMYr3VBM9koBsmZ6kjeoF/jNmanXXg== X-Received: by 2002:a17:903:32c7:b0:154:4156:f384 with SMTP id i7-20020a17090332c700b001544156f384mr2457714plr.34.1648075208508; Wed, 23 Mar 2022 15:40:08 -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 z14-20020aa7888e000000b004f79f59827asm825109pfe.139.2022.03.23.15.40.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 15:40:08 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 5/9] att: Log file and function names Date: Wed, 23 Mar 2022 15:39:59 -0700 Message-Id: <20220323224003.3736525-6-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323224003.3736525-1-luiz.dentz@gmail.com> References: <20220323224003.3736525-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 22:40:00 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: 553787 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 2566EC433EF for ; Wed, 23 Mar 2022 22:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345314AbiCWWlp (ORCPT ); Wed, 23 Mar 2022 18:41:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345297AbiCWWll (ORCPT ); Wed, 23 Mar 2022 18:41:41 -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 1D3B136B6A for ; Wed, 23 Mar 2022 15:40:10 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id o3-20020a17090a3d4300b001c6bc749227so3304319pjf.1 for ; Wed, 23 Mar 2022 15:40:10 -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=DfHofTRb2eMAB4NLCCMw+4TWW7dsPGq6iz32jx6sfLuscGNj/46Px1gNW20YFFEFEk ej2c4+CZXi9+OoswDCVfSMivsjpNhBmDPdrfSz/HsDS+dv7SlEfpJeS+x669bvHaDS7b OpibU1kzpMDoAow2ZRE+XZGnMeAmYUwg6SjXeeSOtZ9MwsqeiLsiiJIbCqXqovhjiEGg 9yvcSwJSUYDi3+Nn2ndkt4tGCygZoD1Sbw9zzS5WDAjaN5EGrMnRYwgXW5fOvZfpo3Ux jK5J9t3ngkrQC4A92k/auWKBSxRXtIsBE0RRVICuEBTG64Z5vo1z94sPKCDir1dCjgXz rYgw== 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=bKzUqfmZYRzCE++ERQ9t6qY6DdE6piwzzQX8w+63whNyWlPRZ79dgGbE6KAj51j/Nb Z7bs/5moPeeQCqLY/rKNmj6G8ktSeu6zftxQu34XQszZgzR9UZirtH1vbPVKHLMRJfiI rOwjGeRabgOJYWzjPB9tcPs69WR50SxDAqfSAxmjYIdjbEOgqAFB7u2BrGe8079gwE4M IHFcbl7LrYwuzb/h2iPqIGyoi3B9zZlzmfx6oTTfUI29EG2HR3wAz6QJtmDilwws16EN 7nGQKjByKbJ+PgnEQkxf5XOtuhZqBkbknSvxjXMVs9AZvGYmNbFsOqldt/PrNJqyJ3r0 rPXg== X-Gm-Message-State: AOAM530CeQd7Xgt56OdSN/c7w0s1Zxok6/LrWDkocMdTrbXXrXVrZMvT aypxqiJN4+nN5f3RvZRdyXrR8LjOyGI= X-Google-Smtp-Source: ABdhPJw+Vu0z8WSk4U5Ks3WN3oQMLYZszEOp5HV592x+wRZtdK0XJtyu7eydrorDILiHjg1i7Hbb1Q== X-Received: by 2002:a17:903:281:b0:14c:f3b3:209b with SMTP id j1-20020a170903028100b0014cf3b3209bmr2361611plr.87.1648075209188; Wed, 23 Mar 2022 15:40:09 -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 z14-20020aa7888e000000b004f79f59827asm825109pfe.139.2022.03.23.15.40.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 15:40:08 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 6/9] gatt-client: Add DBG macro Date: Wed, 23 Mar 2022 15:40:00 -0700 Message-Id: <20220323224003.3736525-7-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323224003.3736525-1-luiz.dentz@gmail.com> References: <20220323224003.3736525-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 22:40:01 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: 554661 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 A0673C4332F for ; Wed, 23 Mar 2022 22:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345292AbiCWWlp (ORCPT ); Wed, 23 Mar 2022 18:41:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345299AbiCWWll (ORCPT ); Wed, 23 Mar 2022 18:41:41 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00C8A3819E for ; Wed, 23 Mar 2022 15:40:10 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id mm17-20020a17090b359100b001c6da62a559so7761716pjb.3 for ; Wed, 23 Mar 2022 15:40:10 -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=EWanTqBbrzfO5rczKfYNwHtoyH6e8nPeQ6FG9r2qUb7I9rwdTCXbw3/U08CTdPJfPY 7dcQ1Mpn+/RR7NZ38ECHZRJ/6rhJls5zMaAHguhQhozZX6SqnHEUD/AyoJpAaxXU//OV UfZBr08d93OaZ12LhoaXDzPT1VErZkTzEIDLvClwo4lsOKX/YhbBfyvrnEg4uXUM9mUc XIbw8U4iVDQOZ5kTv8Www3vKyLBj9ZMAhCXCent833wNX747UZW5dCGY8ED9CISxP0MG XMv0dMlDgxF6jRz8nelsw/W67HhHx+fzByN7xPkqjETFl+7DqAjUMUWfIkVlSavyeWHu sLjg== 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=Bs9QCDkNaRc0dhIMF8YMSDcSz1lug492aS0mwjcs9ctVfQzgGt6u0hu4GLzCsWrafV GPm5VN4SIr91CHSyUzgRDmp6HDIOG+r5uL+HXbOgJuws1cxjGunfHRBPj4DZIWFHuKWQ bvs37rM18JWD3ndAza34S3+N5IG+/teeMD1l6ijeju3iy9RQ4WhCNcK5IKh7wLDlQyh5 Jim8rWiQaA4iEv7eqchboE7B30FtWoIVneWzLPdxCXGumuBpWZ2/RbzaZ4ruoyJOqC/y qjl8vTDqX4cFHB06lIrc+i2VBYD0YPRU6DHOtPYiD2R9gtIbYclj4gWelvr+SsT/v9wW JKMQ== X-Gm-Message-State: AOAM530nFBMMAqE6p5eydsHB8FpNCEmQv0W4BJcZzB/+hCGw8QK/AKFW JNoXC4N5qk0qb8awzNS7HaSbXmBWFFc= X-Google-Smtp-Source: ABdhPJytbiTSm1JFh+pUbJ1EVvW6dIq1Uukikv8U2nk6ZW3ePGgSGsuCy5zSA06Y7hOP3Maz1i+TKA== X-Received: by 2002:a17:902:a415:b0:153:a1b6:729f with SMTP id p21-20020a170902a41500b00153a1b6729fmr2395508plq.52.1648075210136; Wed, 23 Mar 2022 15:40:10 -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 z14-20020aa7888e000000b004f79f59827asm825109pfe.139.2022.03.23.15.40.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 15:40:09 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 7/9] gatt-server: Add DBG macro Date: Wed, 23 Mar 2022 15:40:01 -0700 Message-Id: <20220323224003.3736525-8-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323224003.3736525-1-luiz.dentz@gmail.com> References: <20220323224003.3736525-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 22:40:02 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: 554660 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 F26DBC433F5 for ; Wed, 23 Mar 2022 22:40:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345298AbiCWWlr (ORCPT ); Wed, 23 Mar 2022 18:41:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345305AbiCWWln (ORCPT ); Wed, 23 Mar 2022 18:41:43 -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 86AA4381A4 for ; Wed, 23 Mar 2022 15:40:11 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id mm17-20020a17090b359100b001c6da62a559so7761734pjb.3 for ; Wed, 23 Mar 2022 15:40:11 -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=ZdfyZGcnWsgdnPJEMGBRArNbpVzBpvqK5UFP+MKhhJvK0OV+0yWVl39/f/Z1SFe3Id j9Ijjjh/iRTsgDNZtihSXkPq63AKLBShejG0483n3b6AbGCmcIFg7G13hN+3k/nWUSoO xjqFVdcFPhGskgo5uDpz6ziTrpODPnO0DkuHAUOLFYF3p8j3+Wbr1hhH3pBKD8KZoBip FR6H1n9GDZzLfewgrWkYj1jLCeI2ry6T08F2hJQzAKXD2NoPJT26Qg12a7rg6u7L/Oyd m1izBOYn4QaVxqjPcp14ZxIqKDQIPWhfu/cNAFbChmIE5t59YrkS/QMGPXwmQExEOGde 39wQ== 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=kfuRy2DkxYx4+4Fv4Q0Jid1T8jKojMeWeeRw55KfIbHv0g9syqpMdARGaIa5tnVI03 z+QgLDiu6bjblhMd/wubY5TN56ONM+m9eVP4GtO0rApRMwBHTnEIiTJrUfulXo23UE7u h/drSEgsk4Omvs5kZIGz+YakJTMkic5PQi+bs9eGuVZ7e08THe82daC4xhmMECIJUPcH GmbdVBlaec/uULXwb8eehW8R8PFFEbumL064K8tMGm1DIx+UXxFH2XkH7PMi6l33WnG9 OPBku3rSuOOqM59KI8zoV+IFAFODoha7Gp5CdVPXQ30YpxSPQmF2hZZG+PhwWi9l56d2 2c2w== X-Gm-Message-State: AOAM533Y5yoeC2yKVnX+y1R41ANNMwECjBvVh5bGOgE6hcLq0bur/vHk Tthkf/hYM2eW4QDr4J51ekrEYybSTXI= X-Google-Smtp-Source: ABdhPJwMqYJ/M4IZQF5rMAm0ASFrH0uSHJ5ohYvwORQKJGfQuoRtb/xStXt+nn5ZYCJzKNN3gbADaw== X-Received: by 2002:a17:902:ce8b:b0:154:42e2:924e with SMTP id f11-20020a170902ce8b00b0015442e2924emr2329795plg.138.1648075210704; Wed, 23 Mar 2022 15:40:10 -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 z14-20020aa7888e000000b004f79f59827asm825109pfe.139.2022.03.23.15.40.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 15:40:10 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 8/9] att: Rename att_debug and att_verbose to DBG and VERBOSE Date: Wed, 23 Mar 2022 15:40:02 -0700 Message-Id: <20220323224003.3736525-9-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323224003.3736525-1-luiz.dentz@gmail.com> References: <20220323224003.3736525-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 22:40:03 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: 553786 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 807CAC433FE for ; Wed, 23 Mar 2022 22:40:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345302AbiCWWlq (ORCPT ); Wed, 23 Mar 2022 18:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345303AbiCWWln (ORCPT ); Wed, 23 Mar 2022 18:41:43 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE41C381BB for ; Wed, 23 Mar 2022 15:40:11 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id x2so2950502plm.7 for ; Wed, 23 Mar 2022 15:40:11 -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=gtej16MkQjFGX5FckYPmI080fHE6CeM9NNAGeixVVCl/YZg263RMZbU77w4P856Bbl GUCpQCGPgC0z4uTEgT6RMVNf4WBWCt5JThI7+uYOdXYeGxv5Cq4q06PvRcVDG57dYF3q qnh9fduFop+392SO0/HKIIPHDbaybdii6rSsIhrGfrvZC+gc+yaoBuamE7ZY3P7X8XU2 dfEoRgSMcyx1/ts2DegyDyHV5cU335JxOLgCqoIZCgc87Vun4b32wKf+1HRINQ0h+4p+ jEtv94QDRjc5oIsuk/h+yiEwrIdxsxvc3qbZyhP72jFg3jrvoOO0mSSwESK8/FMZCFFa mwnw== 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=hVqsBeh+LlYsqs9K3tFaLgH6rCMxqiiQfLJRHzheWpius105/Mwqdu9l0hofj9rEYx hwS/FIVVKUwNVjgUOgFJYhkrpuUF4v/OuoNLoIF0FVWM7tkKBDyGYiUwM2trksljb+NC mbHiD0e1e99fBLphHbddVKAHVHwIajpl1WU1ysWBLFrd/CLdiq7NioLmiVv3P+YMDdLP jpLz9MgFXNdxm3OaFCjsfvKaOo30Y9PDMGquBT2XMpwEKnZMydxnlQVAZFNbt44ygcok 3q+Bl30knNceEbs8YZfkAVZCqeaOMpvB8kK5tweAHjBVpArWuo420Hwk+lhtFIe8GYZB 26jw== X-Gm-Message-State: AOAM530sbcMIoFVQdbKrvzx44TFzrqbbzURHEIn0EWcTKWiQMLM5UmKl ylKiAote/CN/IqxlSJK+JQ5nRpJLbPU= X-Google-Smtp-Source: ABdhPJxxi7886NMnYfVShPLU/jGsEd6fwqbNOzbfGYga6KmlvTw7Cu9HFjUAks4P4dGpJfwheCBY1A== X-Received: by 2002:a17:902:9a46:b0:14e:ea0f:28cf with SMTP id x6-20020a1709029a4600b0014eea0f28cfmr2405179plv.43.1648075211259; Wed, 23 Mar 2022 15:40:11 -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 z14-20020aa7888e000000b004f79f59827asm825109pfe.139.2022.03.23.15.40.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 15:40:11 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 9/9] device: Don't use DBG in gatt_debug Date: Wed, 23 Mar 2022 15:40:03 -0700 Message-Id: <20220323224003.3736525-10-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323224003.3736525-1-luiz.dentz@gmail.com> References: <20220323224003.3736525-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)