Re: svn commit: r338679 - head/lib/libusb
On 2019-10-02 14:58, Kyle Evans wrote: Sorry, I missed that the (ctx)->debug checks just moved a little further in... debugging a little better, because LIBUSB_DEBUG=0 doesn't seem to do the trick for this person. I believe the prints are off by default, unless you call libusb_set_debug() in your application. If you want them compile-time removed, you'll need to do something. --HPS ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r338679 - head/lib/libusb
On 2019-10-02 14:55, Kyle Evans wrote: On Fri, Sep 14, 2018 at 8:41 AM Hans Petter Selasky wrote: Author: hselasky Date: Fri Sep 14 13:41:37 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 PR: 231264 MFC after:1 week Approved by: re (kib) Sponsored by: Mellanox Technologies Modified: head/lib/libusb/libusb10.h head/lib/libusb/libusb10_io.c Modified: head/lib/libusb/libusb10.h == --- head/lib/libusb/libusb10.h Fri Sep 14 01:52:34 2018(r338678) +++ head/lib/libusb/libusb10.h Fri Sep 14 13:41:37 2018(r338679) @@ -41,22 +41,24 @@ #defineHOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock) #defineHOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock) -#defineDPRINTF(ctx, dbg, format, args...) do { \ -if ((ctx)->debug == dbg) { \ - switch (dbg) { \ - case LIBUSB_DEBUG_FUNCTION: \ - printf("LIBUSB_FUNCTION: " \ - format "\n", ## args); \ - break; \ - case LIBUSB_DEBUG_TRANSFER: \ - printf("LIBUSB_TRANSFER: " \ - format "\n", ## args); \ - break; \ - default:\ - break; \ - } \ -} \ -} while(0) +#defineDPRINTF(ctx, dbg, format, ...) do { \ + switch (dbg) { \ + case LIBUSB_DEBUG_FUNCTION: \ + if ((ctx)->debug & LIBUSB_DEBUG_FUNCTION) { \ + printf("LIBUSB_FUNCTION: " \ + format "\n", ## __VA_ARGS__);\ + } \ + break; \ + case LIBUSB_DEBUG_TRANSFER: \ + if ((ctx)->debug & LIBUSB_DEBUG_TRANSFER) { \ + printf("LIBUSB_TRANSFER: " \ + format "\n", ## __VA_ARGS__);\ + } \ + break; \ + default:\ + break; \ + } \ +} while (0) /* internal structures */ Hi, How are people/users of libusb supposed to disable these messages after this? The only thing stopping them was the debug level in the context, I guess, because DPRINTF is always compiled to this and the users of DPRINTF are just invoking it all willy-nilly. Feel free to submit a patch. Maybe you need to make a new option for user-space like WITH_USB_DEBUG --HPS ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r338679 - head/lib/libusb
On Wed, Oct 2, 2019 at 7:55 AM Kyle Evans wrote: > > On Fri, Sep 14, 2018 at 8:41 AM Hans Petter Selasky > wrote: > > > > Author: hselasky > > Date: Fri Sep 14 13:41:37 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 > > > > PR: 231264 > > MFC after:1 week > > Approved by: re (kib) > > Sponsored by: Mellanox Technologies > > > > Modified: > > head/lib/libusb/libusb10.h > > head/lib/libusb/libusb10_io.c > > > > Modified: head/lib/libusb/libusb10.h > > == > > --- head/lib/libusb/libusb10.h Fri Sep 14 01:52:34 2018(r338678) > > +++ head/lib/libusb/libusb10.h Fri Sep 14 13:41:37 2018(r338679) > > @@ -41,22 +41,24 @@ > > #defineHOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock) > > #defineHOTPLUG_UNLOCK(ctx) > > pthread_mutex_unlock(&(ctx)->hotplug_lock) > > > > -#defineDPRINTF(ctx, dbg, format, args...) do { \ > > -if ((ctx)->debug == dbg) { \ > > - switch (dbg) { \ > > - case LIBUSB_DEBUG_FUNCTION: \ > > - printf("LIBUSB_FUNCTION: " \ > > - format "\n", ## args); \ > > - break; \ > > - case LIBUSB_DEBUG_TRANSFER: \ > > - printf("LIBUSB_TRANSFER: " \ > > - format "\n", ## args); \ > > - break; \ > > - default:\ > > - break; \ > > - } \ > > -} \ > > -} while(0) > > +#defineDPRINTF(ctx, dbg, format, ...) do { \ > > + switch (dbg) { \ > > + case LIBUSB_DEBUG_FUNCTION: \ > > + if ((ctx)->debug & LIBUSB_DEBUG_FUNCTION) { \ > > + printf("LIBUSB_FUNCTION: " \ > > + format "\n", ## __VA_ARGS__);\ > > + } \ > > + break; \ > > + case LIBUSB_DEBUG_TRANSFER: \ > > + if ((ctx)->debug & LIBUSB_DEBUG_TRANSFER) { \ > > + printf("LIBUSB_TRANSFER: " \ > > + format "\n", ## __VA_ARGS__);\ > > + } \ > > + break; \ > > + default:\ > > + break; \ > > + } \ > > +} while (0) > > > > /* internal structures */ > > > > Hi, > > How are people/users of libusb supposed to disable these messages > after this? The only thing stopping them was the debug level in the > context, I guess, because DPRINTF is always compiled to this and the > users of DPRINTF are just invoking it all willy-nilly. > Sorry, I missed that the (ctx)->debug checks just moved a little further in... debugging a little better, because LIBUSB_DEBUG=0 doesn't seem to do the trick for this person. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r338679 - head/lib/libusb
On Fri, Sep 14, 2018 at 8:41 AM Hans Petter Selasky wrote: > > Author: hselasky > Date: Fri Sep 14 13:41:37 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 > PR: 231264 > MFC after:1 week > Approved by: re (kib) > Sponsored by: Mellanox Technologies > > Modified: > head/lib/libusb/libusb10.h > head/lib/libusb/libusb10_io.c > > Modified: head/lib/libusb/libusb10.h > == > --- head/lib/libusb/libusb10.h Fri Sep 14 01:52:34 2018(r338678) > +++ head/lib/libusb/libusb10.h Fri Sep 14 13:41:37 2018(r338679) > @@ -41,22 +41,24 @@ > #defineHOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock) > #defineHOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock) > > -#defineDPRINTF(ctx, dbg, format, args...) do { \ > -if ((ctx)->debug == dbg) { \ > - switch (dbg) { \ > - case LIBUSB_DEBUG_FUNCTION: \ > - printf("LIBUSB_FUNCTION: " \ > - format "\n", ## args); \ > - break; \ > - case LIBUSB_DEBUG_TRANSFER: \ > - printf("LIBUSB_TRANSFER: " \ > - format "\n", ## args); \ > - break; \ > - default:\ > - break; \ > - } \ > -} \ > -} while(0) > +#defineDPRINTF(ctx, dbg, format, ...) do { \ > + switch (dbg) { \ > + case LIBUSB_DEBUG_FUNCTION: \ > + if ((ctx)->debug & LIBUSB_DEBUG_FUNCTION) { \ > + printf("LIBUSB_FUNCTION: " \ > + format "\n", ## __VA_ARGS__);\ > + } \ > + break; \ > + case LIBUSB_DEBUG_TRANSFER: \ > + if ((ctx)->debug & LIBUSB_DEBUG_TRANSFER) { \ > + printf("LIBUSB_TRANSFER: " \ > + format "\n", ## __VA_ARGS__);\ > + } \ > + break; \ > + default:\ > + break; \ > + } \ > +} while (0) > > /* internal structures */ > Hi, How are people/users of libusb supposed to disable these messages after this? The only thing stopping them was the debug level in the context, I guess, because DPRINTF is always compiled to this and the users of DPRINTF are just invoking it all willy-nilly. Thanks, Kyle Evans ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r338679 - head/lib/libusb
Author: hselasky Date: Fri Sep 14 13:41:37 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 PR: 231264 MFC after:1 week Approved by: re (kib) Sponsored by: Mellanox Technologies Modified: head/lib/libusb/libusb10.h head/lib/libusb/libusb10_io.c Modified: head/lib/libusb/libusb10.h == --- head/lib/libusb/libusb10.h Fri Sep 14 01:52:34 2018(r338678) +++ head/lib/libusb/libusb10.h Fri Sep 14 13:41:37 2018(r338679) @@ -41,22 +41,24 @@ #defineHOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock) #defineHOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock) -#defineDPRINTF(ctx, dbg, format, args...) do { \ -if ((ctx)->debug == dbg) { \ - switch (dbg) { \ - case LIBUSB_DEBUG_FUNCTION: \ - printf("LIBUSB_FUNCTION: " \ - format "\n", ## args); \ - break; \ - case LIBUSB_DEBUG_TRANSFER: \ - printf("LIBUSB_TRANSFER: " \ - format "\n", ## args); \ - break; \ - default:\ - break; \ - } \ -} \ -} while(0) +#defineDPRINTF(ctx, dbg, format, ...) do { \ + switch (dbg) { \ + case LIBUSB_DEBUG_FUNCTION: \ + if ((ctx)->debug & LIBUSB_DEBUG_FUNCTION) { \ + printf("LIBUSB_FUNCTION: " \ + format "\n", ## __VA_ARGS__);\ + } \ + break; \ + case LIBUSB_DEBUG_TRANSFER: \ + if ((ctx)->debug & LIBUSB_DEBUG_TRANSFER) { \ + printf("LIBUSB_TRANSFER: " \ + format "\n", ## __VA_ARGS__);\ + } \ + break; \ + default:\ + break; \ + } \ +} while (0) /* internal structures */ Modified: head/lib/libusb/libusb10_io.c == --- head/lib/libusb/libusb10_io.c Fri Sep 14 01:52:34 2018 (r338678) +++ head/lib/libusb/libusb10_io.c Fri Sep 14 13:41:37 2018 (r338679) @@ -489,13 +489,26 @@ libusb_control_transfer(libusb_device_handle *devh, return (actlen); } +static libusb_context * +libusb10_get_context_by_device_handle(libusb_device_handle *devh) +{ + libusb_context *ctx; + + if (devh != NULL) + ctx = libusb_get_device(devh)->ctx; + else + ctx = NULL; + + return (GET_CONTEXT(ctx)); +} + static void libusb10_do_transfer_cb(struct libusb_transfer *transfer) { libusb_context *ctx; int *pdone; - ctx = GET_CONTEXT(NULL); + ctx = libusb10_get_context_by_device_handle(transfer->dev_handle); DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "sync I/O done"); @@ -585,7 +598,8 @@ libusb_bulk_transfer(libusb_device_handle *devh, libusb_context *ctx; int ret; - ctx = GET_CONTEXT(NULL); + ctx = libusb10_get_context_by_device_handle(devh); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_bulk_transfer enter"); ret = libusb10_do_transfer(devh, endpoint, data, length, transferred, @@ -603,7 +617,8 @@ libusb_interrupt_transfer(libusb_device_handle *devh, libusb_context *ctx; int ret; - ctx = GET_CONTEXT(NULL); + ctx = libusb10_get_context_by_device_handle(devh); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_interrupt_transfer enter"); ret = libusb10_do_transfer(devh, endpoint, data, length, transferred, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"