From: Antonio B. <bor...@gm...> - 2025-08-04 10:22:18
|
Hello! Today we have in OpenOCD enum log_levels { LOG_LVL_SILENT = -3, LOG_LVL_OUTPUT = -2, LOG_LVL_USER = -1, LOG_LVL_ERROR = 0, LOG_LVL_WARNING = 1, LOG_LVL_INFO = 2, LOG_LVL_DEBUG = 3, LOG_LVL_DEBUG_IO = 4, }; If we enable log level "debug", or even worse with "debug_io", we get everything printed out. Too much, not very informative. In my wishlist there I see the possibility to better filter the debug messages, similar to what is done in Linux kernel. Beside the current option of a number for the log levels, I would like to use a list of strings corresponding to subsets in the common log level "debug", while making "debug_io" obsolete. The subsets can be, e.g.: "target", "flash", transport", "io", "usb", "gdb", "socket", ..., and the special string "all" that enables all of them that will work as the full level 3. I mean: "debug_level 3" and "debug_level all" to be equivalent. Then, having the possibility to use "debug level {flash gdb socket}" to enable the level "debug" only for the specified parts of the code. I was considering this for a future activity after v1.0.0 because it could be too invasive for this end of dev cycle. My proposal is, as a first step, to simply add a new entry in "log_level": LOG_LVL_DEBUG_USB. Then convert current _DEBUG_USB_COMMS_ code under this new category. So using separate LOG_DEBUG(), LOG_DEBUG_IO() and the new LOG_DEBUG_USB() in the meantime. This will at least isolate the USB messages from the others, making further work easier. Then, trying to use the new log level for all the USB transfers. And for a longer term and independently from this, we could see the split by subsets. Would it make sense for you? Do you see anything that could prevent using LOG_DEBUG_USB() ? Regards, Antonio On Sun, Aug 3, 2025 at 10:07 PM R. Diez <rdi...@rd...> wrote: > > Hallo Antonio Borneo: > > I wanted to remove configuration option --enable-verbose-usb-comms from configure.ac and replace it with a new run-time option --verbose-usb-comms in the openocd executable. > > My first thought for options.c was (see HAVE_LIBUSB1 below): > > static const struct option long_options[] = { > {"help", no_argument, &help_flag, 1}, > {"version", no_argument, &version_flag, 1}, > {"debug", optional_argument, NULL, 'd'}, > {"file", required_argument, NULL, 'f'}, > {"search", required_argument, NULL, 's'}, > {"log_output", required_argument, NULL, 'l'}, > {"command", required_argument, NULL, 'c'}, > #ifdef HAVE_LIBUSB1 > {"verbose-usb-comms", no_argument, &enable_verbose_usb_comms, 1}, > #endif > {NULL, 0, NULL, 0} > }; > > Where should I place variable 'enable_verbose_usb_comms'? It should be accessible from options.c and from these modules: > > opendous.c > arm-jtag-ew.c > openjtag.c > ti_icdi_usb.c > ulink.c > > My first though was to place it in libusb_helper.h, but that header file is not easily accessible from options.c . > > I was only planning to convert code as follows: > > From: > #ifdef _DEBUG_USB_COMMS_ > opendous_debug_buffer(buffer, (scan_size + 7) / 8); > #endif > > To: > if ( enable_verbose_usb_comms ) > { > opendous_debug_buffer(buffer, (scan_size + 7) / 8); > } > > The refactoring into libusb_helper.h & .c you mentioned is too extensive for a first step. > > Best regards, > rdiez > |