From patchwork Fri Jan 8 21:15:10 2021 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: 359162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19619C433DB for ; Fri, 8 Jan 2021 21:15:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D110423A80 for ; Fri, 8 Jan 2021 21:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729515AbhAHVP4 (ORCPT ); Fri, 8 Jan 2021 16:15:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727325AbhAHVPz (ORCPT ); Fri, 8 Jan 2021 16:15:55 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65876C061757 for ; Fri, 8 Jan 2021 13:15:15 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id v1so4332259pjr.2 for ; Fri, 08 Jan 2021 13:15:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ylsb5NyQ3oFVpAQCIHeIiDlXNUKeqObj9MTroL10KcE=; b=WiQa6uLaEAImOKmyuyDkdvQ877KCudHQbVvHf1T2Zca+yH1uQmCceYKH2ba9F3N11G CX8EOw2ZK6BU0Gz0lgwkgT1jw9Us5yHg+w41SwS2sRs3e53T1nAW/JfxVQqgKiLujb18 sM2AxQOWdIycL5Lz1dIE4BoRSruZ5mecFfg/U5ee5bEDhvJmF/8lM5Txa4kj/6sxd57y uX3Evd+GSWE9NiXXkz+aEvSahZZM7sKNeO+GbKMTLk0ZegI05t+f5k3eprCDymI+aPQi saIJ3O90NQf8wnsVHTR5I3DF/g/c3Z0882q0QnLPC5dCNTb+PlmfPegWZWydyamn66uv ybCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ylsb5NyQ3oFVpAQCIHeIiDlXNUKeqObj9MTroL10KcE=; b=d8K74mRiisZnr+fpP0/Jogh0UucESoD2E+SxHQackjSNGeyRVDGJXhSwO3uhC0O1Ts x4GtkOJFaXeTmhzFEfzqf8IU1kDspnmyEn0kXLw1srxknwnBbVR6doogjyFVbibyBSJI 3PpjwMbohw8JdBse73428oRO0wN0974p0LxPhRb3XzDSZjTl/ajTTYmIs/ZtKlDy6xnW s/Q2rp4lkeSJJKDNatxeHx4YlO+86gl+C9BbRWAnPC6c4AKdHEtk6v8ZZMXxQAOgdZVS IVk7W6zuLHkllHUdSw1r7k2/G4yoJw0qHGcv9BFwN3bnpanTFCpASDgmDmkDm8KazpT3 zM0g== X-Gm-Message-State: AOAM5308/hzBpJ3dN3JmdlKDdh4FUKZSjBdiuuJAN4AUoLr/6/e8/6si ZwWoXIifGHGe5Wu6T3zEAnDsXzTfK5U= X-Google-Smtp-Source: ABdhPJwOsM4zWjcQej4XxaOUdbDnNZeZGHN1qm2MIoTWahGyUfo8cKZDKmr4m5NGcTisl1kfZtJ3mw== X-Received: by 2002:a17:902:ea94:b029:da:a547:b6a6 with SMTP id x20-20020a170902ea94b02900daa547b6a6mr5703029plb.78.1610140514709; Fri, 08 Jan 2021 13:15:14 -0800 (PST) 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 21sm9721699pfx.84.2021.01.08.13.15.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 13:15:14 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/4] util: Introduce util_debug_va Date: Fri, 8 Jan 2021 13:15:10 -0800 Message-Id: <20210108211513.5180-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This introduces util_debug_va which can take a va_list that enables callers to create wrapper functions if they need to. --- src/shared/util.c | 19 ++++++++++++++----- src/shared/util.h | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/shared/util.c b/src/shared/util.c index 525302164..9c2054211 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -15,7 +15,6 @@ #define _GNU_SOURCE #include #include -#include #include #include #include @@ -42,20 +41,30 @@ void *btd_malloc(size_t size) return NULL; } +void util_debug_va(util_debug_func_t function, void *user_data, + const char *format, va_list va) +{ + char str[78]; + + if (!function || !format) + return; + + vsnprintf(str, sizeof(str), format, va); + + function(str, user_data); +} + void util_debug(util_debug_func_t function, void *user_data, const char *format, ...) { - char str[78]; va_list ap; if (!function || !format) return; va_start(ap, format); - vsnprintf(str, sizeof(str), format, ap); + util_debug_va(function, user_data, format, ap); va_end(ap); - - function(str, user_data); } void util_hexdump(const char dir, const unsigned char *buf, size_t len, diff --git a/src/shared/util.h b/src/shared/util.h index 6fb702797..d6de55885 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -89,6 +90,9 @@ void *btd_malloc(size_t size); typedef void (*util_debug_func_t)(const char *str, void *user_data); +void util_debug_va(util_debug_func_t function, void *user_data, + const char *format, va_list va); + void util_debug(util_debug_func_t function, void *user_data, const char *format, ...) __attribute__((format(printf, 3, 4))); From patchwork Fri Jan 8 21:15:12 2021 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: 359161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49731C433DB for ; Fri, 8 Jan 2021 21:16:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C8E923A9B for ; Fri, 8 Jan 2021 21:16:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729614AbhAHVP7 (ORCPT ); Fri, 8 Jan 2021 16:15:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729606AbhAHVP6 (ORCPT ); Fri, 8 Jan 2021 16:15:58 -0500 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 C72E7C061793 for ; Fri, 8 Jan 2021 13:15:17 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id b5so6902804pjl.0 for ; Fri, 08 Jan 2021 13:15:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JEXWlJdDePFBm/HsaJp0B5wQRXw/bAWWRY47hJSwmwk=; b=aVqkssl8SOQPvp8wTGTwTEDaW2fcPgFHKle6CEVwCykstkoauJBEK7EoGXcfqQgv08 qtKkj+5gYRDjprZA2V8Agj5QvPK/QeGBe7WKE73pyx7NqwGJp27fXd2FDFB7jk0qy8/N P+PnRiEKClnpqAjCl+DtyDvS+pMY45i+BXMU3fTVABO5dsFfg0WHsg7PQ/ecQ0CVqk+Y duAC6xS0LaencojiL63AVKZO4CFvs9T8c1rGCBEamnUAHvsBG3pWXpV5LYPyEAwKZHst /xxqeqphpfYPz9gjWsCCGwS6T5jXKhS+nBv/nV7Bq52KnxZE0+NWpfnm6TjWGDfY8+Gp 10ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JEXWlJdDePFBm/HsaJp0B5wQRXw/bAWWRY47hJSwmwk=; b=LhYpeFPGL6SduyY4JjThj4iayK4zcG0fll8GyCQTbDjAs9sQiS6BE2UXKC5HKO+0gY kz+2X+vpLzOZDRn9D+TMgz3Wipy2XK2YTNjwmW0iY1FpRDUtYeKjkMEmyreDNLuns2kS C2KXODbGvpk0t8KYepCiAwE3ZI3XroL85DPt6RXG0+XA/G/CxV6p08HDdcxEJmL+y/hE ZIiKmEkglD2b329LvTiuFKqodiU2DAYj3wIN3J/blMUn/KYK0PXwrn0z7fWDHRvMRDXj vLU/pzePgUnx/BLsw1yuiHu2GOzP2l/HNdLBBByas0qhPLBZEkeZNF5mCuQphs4lmDGL BCww== X-Gm-Message-State: AOAM530ebGffsFDBHZP8qPgV4maoDfJB4vxTj62mSxvmYLNKawAGCZvi XJj1ThKVAtkcsoeqO3/XO8/sjsayVsA= X-Google-Smtp-Source: ABdhPJyM1zlkQtHqgGeBjMPsTlB5iO5hsX68FOGD/oIFRuTWeA+ld2WLin+4iv88w6fpNOOiLa/U4Q== X-Received: by 2002:a17:902:6807:b029:db:f60f:52f7 with SMTP id h7-20020a1709026807b02900dbf60f52f7mr5752345plk.54.1610140517167; Fri, 08 Jan 2021 13:15:17 -0800 (PST) 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 21sm9721699pfx.84.2021.01.08.13.15.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 13:15:16 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 3/4] device: Enable ATT layer debugging Date: Fri, 8 Jan 2021 13:15:12 -0800 Message-Id: <20210108211513.5180-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210108211513.5180-1-luiz.dentz@gmail.com> References: <20210108211513.5180-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 uses bt_att_set_debug to enable ATT debugging which is useful for detecting error such as an ATT transaction timing out. --- src/device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/device.c b/src/device.c index 2e97876ec..fe885aa64 100644 --- a/src/device.c +++ b/src/device.c @@ -5336,6 +5336,8 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io) bt_att_ref(dev->att); + bt_att_set_debug(dev->att, BT_ATT_DEBUG, gatt_debug, NULL, NULL); + dev->att_disconn_id = bt_att_register_disconnect(dev->att, att_disconnected_cb, dev, NULL); bt_att_set_close_on_unref(dev->att, true);