Debug outputs via UDP network

Share your advanced PureBasic knowledge/code with the community.
PeDe
Enthusiast
Enthusiast
Posts: 284
Joined: Sun Nov 26, 2017 3:13 pm

Debug outputs via UDP network

Post by PeDe »

In my programs for Windows I use debug outputs in each procedure, which are output with 'OutputDebugString_()' and displayed with the program 'DebugView++'.

As I now also want to use Linux or the Raspberry P400, I am missing the usual debug outputs. I have created a simple program that receives and displays the debug output via UDP packets. I thought this might be of interest to someone else. That's why I created two projects and translated the comments in the code to English.

The program is only intended for the loopback address 127.0.0.1, as only a maximum of 1024 characters are used per output and no check is carried out for complete packets. However, it also works in the local network. You can pass the program parameters '/DebugIP 192.168.1.100 /DebugPort 5000' for the network.

I have tested the program with Windows 7/10, Debian 12, Raspberry PI OS with PB 6.12b4, and OS X 10.7.5 with PB 5.62. In the code I have inserted issues with 'TODO' where there is 'CompilerIf' for the different systems.
If the program is executed compiled, i.e. without debugger, outputs are only lost if several 1000 outputs are sent at once.

The output list is refreshed once per second on Windows, or scrolled down automatically on Linux and Mac.
I have not considered the scaling for higher monitor resolutions because I cannot test it, but I have added TODOs where the code would have to be adapted. The program interface is very simple, so there should be no difficulties in adapting it.

With OS X 10.7.5 the background color in the ListIconGadget does not work, for this I used the module 'TableViewColor' from mk-soft and Shardik.

Operation - according to the order of the toolbar buttons:
Sav - Saves the output to a file (Ctrl+S, Cmd+S).
Del - Delete the list (D).
Hlt - Pause output (H,P).
Cpy - Copy selected entries to the clipboard (Ctrl+C, Cmd+C). Copy all entries (Ctrl+Shift+C, Cmd+Shift+C).
Scr - Automatically scroll down to the new entries (interval 1 second).
Prc - Display procedure call and end.
Inf - Display information.
Tmp - Show temporary outputs.
Scs - Show successful messages.
Spd - Display result of speed measurements.
ThS - Show start and end of threads.
ThI - Display start and end of thread procedures.
Err - Display error messages (use E and Shift+E to display the error messages).
Def - Display output without formatting.

Screen copy and PB project:
https://www.dreisiebner.at/temp/PB_Debu ... .62x64.png (99 KB)
https://www.dreisiebner.at/temp/PB_DebugViewLan.zip (14 KB)

#########################################################

The 'DebugView-v08.pbi' module is used to output or send debug outputs. To use it, some constants must be defined and present in an 'Application' module. As I have only written these functions for my needs, these defaults have been created in this way, which can of course be changed.

I have written a test project 'DebugViewTest' for the debug outputs, and a minimal example 'Demo-Test-DebugView-Module.pb'.
In addition to the debug outputs, there is also a module 'DebugProfiling-v01.pbi'. If the module 'DebugView-v08.pbi' and the corresponding macros are used in the procedures, the called procedures and the respective speed measurement can be displayed.

The meaning and use of the required constants is described in the test example 'Demo-Test-DebugView-Module.pb'. Information is also available at the beginning of the file 'DebugView-v08.pbi'. Otherwise you can have a look at the project 'DebugViewTest', where pretty much everything is used. The project is relatively complex, but necessary so that you can test the window instances, for example, if you open several windows.

I have tested the program with Windows 7/10, Debian 12, Raspberry PI OS with PB 6.12b4, and OS X 10.7.5 with PB 5.62. In the code of the module 'DebugProfiling-v01.pbi' I have inserted issues with 'TODO' where there is 'CompilerIf' for the different systems.
In the profiling window, the columns of the list adapt to the content under Windows, this function is missing under Linux and Mac. Sorting by clicking on the column header works everywhere on the tested systems.

PB project and test file:
https://www.dreisiebner.at/temp/PB_DebugViewTest.zip (29 KB)


Just as a note, in case the code is displayed badly formatted, I use tabs with 3 characters width, and the font Verdana, standard, 10 point in the IDE.

Peter
infratec
Always Here
Always Here
Posts: 7618
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Debug outputs via UDP network

Post by infratec »

UDP and Debug?
Why Not Syslog?
viewtopic.php?t=41006
Post Reply