Debugging a loaded library

Just starting out? Need help? Post your questions and find answers here.
Yann64
User
User
Posts: 32
Joined: Wed Nov 10, 2004 1:06 pm
Contact:

Debugging a loaded library

Post 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?
User avatar
spikey
Enthusiast
Enthusiast
Posts: 750
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Debugging a loaded library

Post 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
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Debugging a loaded library

Post 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)
Yann64
User
User
Posts: 32
Joined: Wed Nov 10, 2004 1:06 pm
Contact:

Re: Debugging a loaded library

Post 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).
Post Reply