Detect if particular PRG file was compiled?

201 views
Skip to first unread message

Peter Marsan

unread,
May 24, 2022, 1:41:49 PM5/24/22
to Harbour Users
Hello,
I've been playing around with the VS Code debugger for Harbour and I want to avoid accidently releasing a "debug" version of a program. Is there a way to detect if a particular PRG was compiled within Harbour?

Pseudo code:

If PRGcompiled("debugger.prg")
   AlertUserOfDebugMode()
Endif

If that isn't possible, is it possible to detect if a program was compiled with a particular hbmk2 flag (in this case "-b")?

Thanks!

-Peter

Shaji Thomas

unread,
May 24, 2022, 10:31:02 PM5/24/22
to Harbour Users
Hi Peter,

cMyPrg := "MyFunction()"  // one function in the particular prg 
if type(cMyPrg) == "U"
     alert("Undefined function !!")  // prg not included..
endif

Shaji Thomas

Peter Marsan

unread,
May 24, 2022, 10:54:47 PM5/24/22
to Harbour Users
Thank you! I believe that will do the trick.

Alex Strickland

unread,
May 25, 2022, 3:23:52 AM5/25/22
to harbou...@googlegroups.com

Hi Peter

I use this:

    if hb_isFunction("__DebugItem")
        oAlert := HAlert():New()
        oAlert:Time := ERRORTIMEOUT
        oAlert:Alert("VSCode Debugger is linked in, do not distribute.")
    endif

--

Regards

Alex

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/439b9f64-3e4e-46fa-a795-722ac03ab4b9n%40googlegroups.com.
--

Jayadev U

unread,
May 25, 2022, 10:40:46 AM5/25/22
to harbou...@googlegroups.com

Hi Alex,

 

Thanks for the example.

 

Could you please let me know, in which file is the source of hAlert() defined as also ERRORTIMEOUT.  I could not find the same with a search in the source code of Harbour folder including “C” functions.

 

Warm regards,

 

Jayadev

image001.png

Alex Strickland

unread,
May 25, 2022, 11:25:59 AM5/25/22
to harbou...@googlegroups.com

Hi Jayadev

That is my own code, 

    if hb_isFunction("__DebugItem")

is the answer to the question.

--

Regards

Alex

Eric Lendvai

unread,
May 29, 2022, 2:07:58 AM5/29/22
to Harbour Users
Hello Peter,
Another idea to help you track release and debug versions, like many other project management system do, simply build in different folders.

In my datawharf github repo, from within VSCODE I can build "release" or "debug" which will output to folders like the following:

R:\DataWharf\build\win64\mingw64\release
R:\DataWharf\build\win64\mingw64\debug

Review the following batch files for Windows and Linux
============================
if %BuildMode% == debug (
    copy debugger_on.hbm debugger.hbm
    hbmk2 %EXEName%_windows.hbp %HB_FASTCGI_ROOT%\hb_fcgi\hb_fcgi_windows.hbm -b -p -w3 -dDEBUGVIEW
) else (
    copy debugger_off.hbm debugger.hbm
    hbmk2 %EXEName%_windows.hbp %HB_FASTCGI_ROOT%\hb_fcgi\hb_fcgi_windows.hbm  -w3  -static -dDEBUGVIEW
)

Content of file debugger_off.hbm
================================
#This file will be copied to debugger.hbm when release build was selected
#No inclusion of the vscode_debugger.prg


Content of file debugger_on.hbm
===============================
#This file will be copied to debugger.hbm when debug build was selected
#Ensure to update the following prg when the harbour VSCODE extension is updated.
vscode_debugger.prg


And in your application main app.hbm include the line:
============================================
debugger.hbm

Unlike in VFP, there is a huge performance difference when executing release version debug EXEs

Hope this helps, Eric

I also use the Tasks VSCODE extension from actboy168.

Snag_65f62d3.png

Snag_65fe88e.png

Peter

unread,
May 29, 2022, 2:20:46 AM5/29/22
to Harbour Users
Hi Eric,

It's shocking how similar my build setup already is compared to what you described. I do have separate folders for debug/release, and I have a batch script that accepts arguments to target either version. I pass debugger.prg as an additional argument to hbmk2 to build the debug version in the batch script (which is a bit different than how you describe, but it works). I also use the Tasks extension you mentioned.

My goal was a belt and suspenders approach to make absolutely 100% sure a debug version isn't accidentally released. It's nice to know that someone else has a similar setup to mine, it means what I cobbled together actually makes sense :)

> Unlike in VFP, there is a huge performance difference when executing release version debug EXEs

Do you mean the debug EXEs from Harbour are much slower? That was my general worry which led me down this path in the first place.

-Peter

Eric Lendvai

unread,
May 30, 2022, 3:02:38 AM5/30/22
to Harbour Users
Hello Peter,
My experience creating web apps with Harbour is that debug build are noticeably slower. Release mode FastCGI apps are incredibly fast. If you create Desktop apps I think the difference is not as bad, since the UI is the most CPU intensive to start with.
Eric 

Alex Strickland

unread,
Jun 2, 2022, 3:44:46 AM6/2/22
to harbou...@googlegroups.com

Hi Eric

I release with Debug info enabled, I would be dead without accurate stack traces. I've never noticed any particular slowdown, but I do, as you say, have desktop apps.

The VS Code debugger is pretty slow when not run from within VS Code, I assume because of endless timeouts looking for the debugger server.

--

Regards

Alex

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages