10-18-2024 12:45 AM - edited 10-18-2024 12:58 AM
@Sable a écrit :
I successfully opened the CVI project file in CVI 2013 and recompiled the DLL.
Great, that was a very important milestone!
@Sable a écrit :
Could you please clarify the section highlighted in blue?
For debugging and tracing purposes, I am using
OutputDebugStringA()
, and the output can be captured using DebugView from Sysinternals.
Yes, sure. This is a very simple way to debug your library. DebugView is very small but useful utility that lets you monitor debug output. This tool will capture output of the OutputDebugStringA Function. (A at the end means Ascii ver).
For example, if I have the code like this:
int Your_Functions_Here (int x)
{
char buf[256];
sprintf(buf, "Debug Info: x = %d", x);
OutputDebugStringA(buf);
x = x * x;
return x;
}
//==============================================================================
// DLL main entry-point functions
int __stdcall DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
OutputDebugStringA("Attached to Process"); break;
case DLL_PROCESS_DETACH:
OutputDebugStringA("Detached from Process"); break;
case DLL_THREAD_ATTACH:
OutputDebugStringA("Attached to Thread"); break;
case DLL_THREAD_DETACH:
OutputDebugStringA("Detached from Thread"); break;
}
return 1;
}
Then output shown in DebugView will be:
And you will be not blind at least. DebugView will capture all outputs from all windows processes, but you can apply filter if this annoying.
By the way, you can call this function directly from LabVIEW, sometimes its also useful (don't forget to switch to WinAPI calling convention):
and output will be here:
But the "classical" debug technique also will work with CVI and LabVIEW, then in CVI you will set breakpoint:
Then build Debug verision instead of release, then you can start LabVIEW and attach to that process from CVI:
and when you will call it from LabVIEW, the CVI will be stopped on the breakpoint:
So, you can debug you DLL (don't forget to build release after that).
And just one more thing — in LabVIEW you have "embedded" debug console, you can call DbgPrintf() from LabVIEW.exe, like OutputDebugString from kernel, then output will appear in small window:
and this can be called from your DLL same way, of course:
int Your_Functions_Here (int x)
{
DbgPrintf("Debug Info: x = %d", x);
x = x * x;
return x;
}
I hope this info above will be helpful for you.