Page 1 of 1

Debugging a loaded library

Posted: Wed Aug 21, 2024 3:47 pm
by Yann64
Hi all!

I have a main executable (coded in PB) accessing a dll library (also coded in PB).
In windows, it looks like the -d compiler argument does nothing when the /DLL (or linux/macos equivalent) argument is used.

Does PB give the possibility to debug a loaded library (for example by opening a specific console showing the library dbg messages)? If it exists I could not find it.

When coding in c/cpp, gdb allows debugging loaded libraries (you need to put a break on you main program, then press F11 on the gdb windows to switch to the loaded library provided the debug symbols are available). Is there a workaround to do something similar in PB?

Re: Debugging a loaded library

Posted: Wed Aug 21, 2024 6:22 pm
by spikey
I generally use the OutputDebugString api function which is imported by default as OutputDebugString_ and SysInternals DebugView to receive the messages.

Little John presented some interesting tricks using the JSON library which you could also adapt at https://www.purebasic.fr/english/viewtopic.php?t=60589

Re: Debugging a loaded library

Posted: Thu Aug 22, 2024 6:41 am
by Fred
If possible, I try to create an exe which embed the function DLL directly and so you can use the IDE to debug it as it's a normal exe. If not applicable, outputdebugstring() or a trace file (just write your debug output in a file and use baretail to read it live)

Re: Debugging a loaded library

Posted: Thu Aug 22, 2024 1:28 pm
by Yann64
Thanks all!

As I am looking for an OS agnostic solution, it looks like using a trace file is the way to go for now (unless I find an equivalent to outputdebugstring() in linux).