Author Topic: zTrace 1.52 (debugging utility)  (Read 32870 times)

0 Members and 1 Guest are viewing this topic.

Offline John Aadnoey

  • Newbie
  • *
  • Posts: 9
Re: zTrace 1.52 (debugging utility)
« Reply #45 on: December 23, 2013, 04:02:38 PM »
Its not embedded in my code. I let my DLL load it.
To me it looks like zTrace is waiting for VB6 to shutdown, not the DLL. (because shutting down the VB6 IDE kills it)

"However if the source code of zTrace doesn't match your level of expectations"

Its definitely up to my expectations. have no doubt about that, I'm just trying to find out why the DLL ain't closing
« Last Edit: December 23, 2013, 04:25:30 PM by Patrice Terrier »

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2400
  • Gender: Male
    • www.zapsolution.com
Re: zTrace 1.52 (debugging utility)
« Reply #46 on: December 23, 2013, 04:24:52 PM »
Again, i have absolutly no knowledge of VB.

Did you try it without the VB6 IDE, i mean as a real standalone EXE ?
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline John Aadnoey

  • Newbie
  • *
  • Posts: 9
Re: zTrace 1.52 (debugging utility)
« Reply #47 on: December 23, 2013, 04:40:36 PM »
Yes just three minutes ago. And then when I run the compiled VB6 code, It shut down as expected.

I wouldn't be surprised if its VB not shutting down the DLL beacuse the DLL has an open window. If window is closed before DLL gets shut down, it'll probably work.
« Last Edit: December 23, 2013, 05:52:19 PM by John Aadnoey »

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2400
  • Gender: Male
    • www.zapsolution.com
Re: zTrace 1.52 (debugging utility)
« Reply #48 on: December 23, 2013, 05:49:04 PM »
Then this means that when you run it within the VB6 IDE, it runs as p-code not native code, that's it.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline John Aadnoey

  • Newbie
  • *
  • Posts: 9
Re: zTrace 1.52 (debugging utility)
« Reply #49 on: December 23, 2013, 07:56:53 PM »
Found out some more. When I run it in p-Native/VB6 IDE, if;
DLL opens a DialogWindow, program closes = crash
DLL opens a DialogWindow, DLL close DialogWindow, program closes = OK

Probably a VB6 bug/feature.
« Last Edit: December 23, 2013, 08:10:55 PM by John Aadnoey »

Offline Norbert Spoerl

  • Newbie
  • *
  • Posts: 39
Re: zTrace 1.52 (debugging utility)
« Reply #50 on: December 24, 2013, 09:46:39 AM »
Hi John,

zTrace is only useable with EXE/DLL of pure native Code. Please see my replys 34 and 36. I made the same experiences with another programming language.

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2400
  • Gender: Male
    • www.zapsolution.com
Re: zTrace 1.52 (debugging utility)
« Reply #51 on: December 24, 2013, 11:29:58 AM »
zTrace is using GetModuleHandle("") to retrieve the instance handle, but in case of a run-time this is of course the handle of the run-time!
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline John Aadnoey

  • Newbie
  • *
  • Posts: 9
Re: zTrace 1.52 (debugging utility)
« Reply #52 on: December 24, 2013, 01:42:09 PM »
Ah oki. That explains it. Then I'll just keep on using it on my pure PB hobby projects.

Thanks all

Offline Norm Cook

  • Newbie
  • *
  • Posts: 8
Re: zTrace 1.52 (debugging utility)
« Reply #53 on: March 26, 2014, 02:38:08 PM »
Patrice, late to the party, just stumbled onto this.  Thanks so much for sharing this
excellent debugging tool.  Here's a little routine I've been using to make coding/debugging
a little easier.  I've thrown just about everything at it and it seems to work OK.
Code: [Select]
Sub DoTrace(ByVal Msg As Variant)
 Local sz As AsciiZ * 1000
 Select Case VariantVT(Msg)
  Case %VT_BStr
   sz = Variant$(Msg)
  Case %VT_R4, %VT_R8   'single, double
   sz = "#" & Format$(Round(Variant#(Msg), 4))
  Case Else
   sz = "#" & Format$(Variant#(Msg))
 End Select
 zTrace sz
End Sub
« Last Edit: March 26, 2014, 03:13:30 PM by Norm Cook »

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2400
  • Gender: Male
    • www.zapsolution.com
Re: zTrace 1.52 (debugging utility)
« Reply #54 on: March 26, 2014, 04:48:44 PM »
There is no need to use Variant nor Format$ (both are bloated :) ).

You can just use zTrace like this:

zTrace(STR$(Value))
or
zTrace("Value =" + STR$(Value))
and in case of STRING
zTrace((MyString$))
or
zTrace(A$+ B$ + STR$(12))
« Last Edit: March 26, 2014, 04:50:44 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline George Bleck

  • Newbie
  • *
  • Posts: 4
Re: zTrace 1.52 (debugging utility)
« Reply #55 on: May 02, 2017, 10:05:08 PM »
I absolutely love having zTrace in my toolbox and wanted to give back a slight "helper" that I use with it.

Code: [Select]
#IF NOT %DEF( %zTrace )
    %zTrace = 0
#ENDIF

#IF %zTrace = 0
    MACRO zTrace = #UTILITY
    MACRO zDebug = #UTILITY
#ELSE
    DECLARE FUNCTION zTraceX LIB "zTrace.DLL" ALIAS "zTrace" ( zMessage AS ASCIIZ ) AS LONG
    DECLARE FUNCTION zDebugX LIB "zTrace.DLL" ALIAS "zDebug" ( zMessage AS ASCIIZ ) AS LONG
    #IF %zTrace > 0
        MACRO zTrace = zTraceX
        MACRO zDebug = zDebugX
    #ELSE
        MACRO zTrace = zDebugX
        MACRO zDebug = zDebugX
    #ENDIF
#ENDIF

This slight mod allows you to leave zTrace code in and never have to remove it.  PLUS it adds some flexibility to the output path.

  • If %zTrace is defined as a positive number, zTrace and zDebug work exactly as expected.
  • If %zTrace is defined as a negative number, zTrace and zDebug both act like zDebug and send to zDebug.txt (allows you to easily switch to "silent" debugging).
  • If %zTrace is 0, not defined,  or REM'd out, then all zTrace/zDebug lines are compiled as #UTILITY commands, in other words, they are ignored by the compiler.
This allows you to easily include copious real-time logging in your code as well as switch the output (or remove logging completely) with a single constant change.

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2400
  • Gender: Male
    • www.zapsolution.com
Re: zTrace 1.52 (debugging utility)
« Reply #56 on: May 03, 2017, 10:18:35 AM »
George--

Thank you.

The current version of zTrace is able to write to zdebug.txt directly from the contextual popup menu.

PBwin 10, now doesn't compile unused code anymore.
Thus using explicit linking rather than implicit is another solution,
and this is what i am using with the 64-bit version (explicit call is the same for PB) :

Code: [Select]
long zTrace(IN WCHAR* sPtr) {
    long nRet = 0;
    static HMODULE hDll;
    if (hDll == 0) {
        if (sizeof(LONG_PTR) == 8) {
            hDll = LoadLibrary(L"zTrace64");
        }
        else {
            hDll = LoadLibrary(L"zTrace32");
        }
    }
    if (hDll) {
        long_proc(WCHAR*);
        static zProc hProc;
        if (hProc == 0) { hProc = (zProc)GetProcAddress(hDll, "zTrace"); }
        if (hProc) { nRet = hProc(sPtr); }
    }
    return nRet;
}

The C++ 64-bit DLL version is only 11 Kb in size, it can create ANSI or UNICODE debug file.
In case of ANSI, a UTF-8 BOM header is now being used
this version can be downloaded from www.codeproject.com or from my private forum www.objreader.com
https://www.codeproject.com/Articles/1183063/zTrace-for-bit-only

« Last Edit: May 03, 2017, 10:30:00 AM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
Re: zTrace 1.52 (debugging utility)
« Reply #57 on: May 03, 2017, 11:56:07 AM »
Patrice,
  I reverted back to an older version.
The debug.txt output was persistent once set and I often parse the output so I don't want a BOM.

James

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2400
  • Gender: Male
    • www.zapsolution.com
Re: zTrace 1.52 (debugging utility)
« Reply #58 on: May 03, 2017, 02:13:53 PM »
No, it is not, you just have to remember to uncheck the menu option, once you are done, if you don't want it for the next session.

Or feel free to customize the source code to match your preference ;)

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2400
  • Gender: Male
    • www.zapsolution.com
Re: zTrace 1.52 (debugging utility)
« Reply #59 on: May 03, 2017, 08:12:24 PM »
Emil

zTrace is totaly independent from the compiler, it is a standalone DLL.
It has been inspired by the WinDev Trace API.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com