The _only_ use of DPRINTF(..., LIBUSB_DEBUG_TRANSFER, ...) is in the function libusb10_do_transfer_cb of libusb10_io.c https://github.com/freebsd/freebsd/blob/master/lib/libusb/libusb10_io.c#L500 The function uses it as: ctx = GET_CONTEXT(NULL); DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "sync I/O done"); Since the ctx context is fetched from NULL it has default values and ctx->debug is 0. DPRINTF() definition uses ctx->debug to know the debug level. https://github.com/freebsd/freebsd/blob/master/lib/libusb/libusb10.h#L44 In the present case the debug level will be 0 so nothing is logged. I don't know how to get the libusb context from a libusb_transfer, the only parameter passed to libusb10_do_transfer_cb(). Another idea for improvement would be to use a bitmap for ctx->debug so it would be possible to enable both LIBUSB_DEBUG_TRANSFER and LIBUSB_DEBUG_FUNCTION at the same time.
Created attachment 197047 [details] Correctly et the context
The code ctx = GET_CONTEXT(NULL); is also used in libusb_bulk_transfer() at https://github.com/freebsd/freebsd/blob/master/lib/libusb/libusb10_io.c#L588 and libusb_interrupt_transfer() at https://github.com/freebsd/freebsd/blob/master/lib/libusb/libusb10_io.c#L606 Patch attached. It works for me.
Patch looks good.
The patch does not fix the problem for libusb10_do_transfer_cb(). Only for the 2 other uses of GET_CONTEXT(NULL).
Created attachment 197056 [details] LibUSB patch Can you try this updated patch instead? Does it work for you?
This new patch works for me. I would like to be able to have LIBUSB_DEBUG_FUNCTION *and* LIBUSB_DEBUG_TRANSFER logs. This is easy to do using: libusb_set_debug(ctx, LIBUSB_DEBUG_FUNCTION | LIBUSB_DEBUG_TRANSFER); and the attached patch.
Created attachment 197089 [details] allows LIBUSB_DEBUG_FUNCTION and LIBUSB_DEBUG_TRANSFER
A commit references this bug: Author: hselasky Date: Fri Sep 14 13:41:37 UTC 2018 New revision: 338679 URL: https://svnweb.freebsd.org/changeset/base/338679 Log: Improve LibUSB debugging by simultaneously allowing both function and transfer prints. Make sure the debug level comes from the correct USB context. Found by: Ludovic Rousseau <ludovic.rousseau+freebsd@gmail.com> PR: 231264 MFC after: 1 week Approved by: re (kib) Sponsored by: Mellanox Technologies Changes: head/lib/libusb/libusb10.h head/lib/libusb/libusb10_io.c
A commit references this bug: Author: hselasky Date: Wed Sep 19 08:11:44 UTC 2018 New revision: 338791 URL: https://svnweb.freebsd.org/changeset/base/338791 Log: MFC r338679: Improve LibUSB debugging by simultaneously allowing both function and transfer prints. Make sure the debug level comes from the correct USB context. Found by: Ludovic Rousseau <ludovic.rousseau+freebsd@gmail.com> PR: 231264 Sponsored by: Mellanox Technologies Changes: _U stable/11/ stable/11/lib/libusb/libusb10.h stable/11/lib/libusb/libusb10_io.c
A commit references this bug: Author: hselasky Date: Wed Sep 19 08:12:41 UTC 2018 New revision: 338792 URL: https://svnweb.freebsd.org/changeset/base/338792 Log: MFC r338679: Improve LibUSB debugging by simultaneously allowing both function and transfer prints. Make sure the debug level comes from the correct USB context. Found by: Ludovic Rousseau <ludovic.rousseau+freebsd@gmail.com> PR: 231264 Sponsored by: Mellanox Technologies Changes: _U stable/10/ stable/10/lib/libusb/libusb10.h stable/10/lib/libusb/libusb10_io.c
A commit references this bug: Author: hselasky Date: Wed Sep 19 08:13:58 UTC 2018 New revision: 338793 URL: https://svnweb.freebsd.org/changeset/base/338793 Log: MFC r338679: Improve LibUSB debugging by simultaneously allowing both function and transfer prints. Make sure the debug level comes from the correct USB context. Found by: Ludovic Rousseau <ludovic.rousseau+freebsd@gmail.com> PR: 231264 Sponsored by: Mellanox Technologies Changes: _U stable/9/lib/ _U stable/9/lib/libusb/ stable/9/lib/libusb/libusb10.h stable/9/lib/libusb/libusb10_io.c