In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

harbour Question .... how to get list and values of active variables ?

Xailer professional forum in English
Responder
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

harbour Question .... how to get list and values of active variables ?

Mensaje por ChrisGillard »

Hi,
Not strictly a Xailer question but I want to list all the active vars at a certain point in the execution of my code .... like the Private, Public, Local, Static list of vars in the Xailer debug window.
I have found the Harbour function __MVDBGINFO .... is this what I want?
Or maybe how does Xailer get this information for the debug window ... unless its a secret?
Any suggestions would be appreciated.
Thanks
Chris
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9442
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

harbour Question .... how to get list and values of active variables ?

Mensaje por ignacio »

Hello Crhis,
I include with this message some copy&paste code from Harbour itself. I believe is self explanatory:
From SrcDebugDebugger.prg
METHOD LoadVars() CLASS HBDebugger // updates monitored variables
LOCAL nCount
LOCAL n
LOCAL m
LOCAL xValue
LOCAL cName
LOCAL aVars
LOCAL aBVars
LOCAL hSkip
aBVars := {}
IF ::lShowPublics
nCount := __mvDbgInfo( HB_MV_PUBLIC )
FOR n := nCount TO 1 STEP -1
xValue := __mvDbgInfo( HB_MV_PUBLIC, n, @cName )
AAdd( aBVars, { cName, xValue, "Public" } )
NEXT
ENDIF
IF ::lShowPrivates
/* CA-Cl*pper shows only local private variables in monitor
* We are marking non local private variables with "^" character
*/
nCount := __mvDbgInfo( HB_MV_PRIVATE )
IF nCount > 0
m := __mvDbgInfo( HB_MV_PRIVATE_LOCAL, ::nProcLevel )
hSkip := { => }
hb_HAllocate( hSkip, nCount )
FOR n := nCount TO 1 STEP -1
xValue := __mvDbgInfo( HB_MV_PRIVATE, n, @cName )
IF ! cName $ hSkip
AAdd( aBVars, { cName, xValue, iif( m > 0, "Private", "Private^" ) } )
hSkip[ cName ] := NIL
ENDIF
--m
NEXT
ENDIF
ENDIF
IF ::aProcStack[ ::oBrwStack:Cargo ][ CSTACK_LINE ] != NIL
IF ::lShowGlobals
cName := ::aProcStack[ ::oBrwStack:Cargo ][ CSTACK_MODULE ]
FOR n := 1 TO Len( ::aModules )
IF ! ::lShowAllGlobals
IF ! hb_FileMatch( ::aModules[ n ][ MODULE_NAME ], cName )
LOOP
ENDIF
ENDIF
aVars := ::aModules[ n ][ MODULE_GLOBALS ]
FOR m := 1 TO Len( aVars )
AAdd( aBVars, aVars[ m ] )
NEXT
IF ! ::lShowAllGlobals
aVars := ::aModules[ n ][ MODULE_EXTERNGLOBALS ]
FOR m := 1 TO Len( aVars )
AAdd( aBVars, aVars[ m ] )
NEXT
ENDIF
NEXT
ENDIF
IF ::lShowStatics
cName := ::aProcStack[ ::oBrwStack:Cargo ][ CSTACK_MODULE ]
n := AScan( ::aModules, {| a | hb_FileMatch( a[ MODULE_NAME ], cName ) } )
IF n > 0
aVars := ::aModules[ n ][ MODULE_STATICS ]
FOR m := 1 TO Len( aVars )
AAdd( aBVars, aVars[ m ] )
NEXT
ENDIF
aVars := ::aProcStack[ ::oBrwStack:Cargo ][ CSTACK_STATICS ]
FOR n := 1 TO Len( aVars )
AAdd( aBVars, aVars[ n ] )
NEXT
ENDIF
IF ::lShowLocals
aVars := ::aProcStack[ ::oBrwStack:Cargo ][ CSTACK_LOCALS ]
FOR n := 1 TO Len( aVars )
cName := aVars[ n ][ VAR_NAME ]
m := AScan( aBVars, ; // Is there another var with this name ?
{| aVar | aVar[ VAR_NAME ] == cName .AND. Left( aVar[ VAR_TYPE ], 1 ) == "S" } )
IF m > 0
aBVars[ m ] := aVars[ n ]
ELSE
AAdd( aBVars, aVars[ n ] )
ENDIF
NEXT
ENDIF
ENDIF
IF ::oBrwVars != NIL .AND. ::oBrwVars:cargo[ 1 ] > Len( aBVars )
::oBrwVars:GoTop()
ENDIF
::aVars := aBVars
IF ::lSortVars .AND. ! Empty( ::aVars )
::Sort()
ENDIF
RETURN NIL
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

harbour Question .... how to get list and values of active variables ?

Mensaje por ChrisGillard »

Ignacio,
Excellent ... will need a little study!
Thanks you very much for the pointer to debugger.prg.
Chris
Cassiano de Oliveira
Mensajes: 475
Registrado: Mar Jul 24, 2012 10:21 pm

harbour Question .... how to get list and values of active variables ?

Mensaje por Cassiano de Oliveira »

Legal...
E seria possí­vel EXCLUIR (DELETE) uma variável seja PUBLIC ou outro tipo?
"Chris Gillard" wrote in message news:53bead81$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
Ignacio,
Excellent ... will need a little study!
Thanks you very much for the pointer to debugger.prg.
Chris
---
Este email está limpo de ví­rus e malwares porque a proteção do avast! Antiví­rus está ativa.
http://www.avast.com
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9442
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

harbour Question .... how to get list and values of active variables ?

Mensaje por ignacio »

Cassiano de Oliveira escribió el jue, 10 julio 2014 19:18Legal...
E seria possí­vel EXCLUIR (DELETE) uma variável seja PUBLIC ou outro tipo?
"Chris Gillard" wrote in message news:53bead81$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email][/email][/email]
Ignacio,
Excellent ... will need a little study!
Thanks you very much for the pointer to debugger.prg.
Chris
---
Este email está limpo de ví­rus e malwares porque a proteção do avast! Antiví­rus está ativa.
http://www.avast.com
__mvrelease( cVarName )
Regards,
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Cassiano de Oliveira
Mensajes: 475
Registrado: Mar Jul 24, 2012 10:21 pm

harbour Question .... how to get list and values of active variables ?

Mensaje por Cassiano de Oliveira »

fantástico... Gracias.
"Ignacio Ortiz de Zúñiga" wrote in message
news:53bed70f$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
Cassiano de Oliveira escribió el jue, 10 julio 2014
19:18
> Legal...
>
> E seria possí­vel EXCLUIR (DELETE) uma variável seja
> PUBLIC ou outro tipo?
>
>
>
> "Chris Gillard" wrote in message
> news:53bead81$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email][/email]
>
> Ignacio,
>
> Excellent ... will need a little study!
>
> Thanks you very much for the pointer to debugger.prg.
>
> Chris
>
> ---
> Este email está limpo de ví­rus e malwares porque a
> proteção do avast! Antiví­rus está ativa.
> http://www.avast.com
_mvrelease( cVarName )
Regards,
--
Ignacio Ortiz de Zúñiga
[Equipo de Xailer/Xailer team]
http://www.xailer.com
http://www.xailer.info
---
Este email está limpo de ví­rus e malwares porque a proteção do avast! Antiví­rus está ativa.
http://www.avast.com
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

harbour Question .... how to get list and values of active variables ?

Mensaje por ChrisGillard »

Hi Ignacio,
Cheeky to ask but I making good progress ...... working through the code in debugger.prg is helping a lot.
I can now get an array of all the Local vars using
aLocalList := __dbgVMLOCALLIST()
? "LocalList", valtype( aLocalList ), len( aLocalList )
and I can also get their VALUES by the position in the array.
for n := 1 to len( aLocalList )
qout( aLocalList[n],__dbgvmVarLGet(__dbgprocLevel()-1,n ) )
next n
Both aLocalList[n] and __dbgvmVarLGet(__dbgprocLevel()-1,n ) give me the VALUE
What I cant find how to get is the NAMES of the Locals by position or any other way.
I have compiled with -b.
Any quick thoughts of how you got the LOCAL NAMES?
I cant see where they get the VAR_NAMES element from in debugger.prg
Would be good to solve this.
Chris
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9442
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

harbour Question .... how to get list and values of active variables ?

Mensaje por ignacio »

ChrisGillard escribió el jue, 10 julio 2014 22:58Hi Ignacio,
Cheeky to ask but I making good progress ...... working through the code in debugger.prg is helping a lot.
I can now get an array of all the Local vars using
aLocalList := __dbgVMLOCALLIST()
? "LocalList", valtype( aLocalList ), len( aLocalList )
and I can also get their VALUES by the position in the array.
for n := 1 to len( aLocalList )
qout( aLocalList[n],__dbgvmVarLGet(__dbgprocLevel()-1,n ) )
next n
Both aLocalList[n] and __dbgvmVarLGet(__dbgprocLevel()-1,n ) give me the VALUE
What I cant find how to get is the NAMES of the Locals by position or any other way.
I have compiled with -b.
Any quick thoughts of how you got the LOCAL NAMES?
I cant see where they get the VAR_NAMES element from in debugger.prg
Would be good to solve this.
Chris

Hello Chris,
I'm afraid that is not so easy. Since that information is received on the procedure __DbgEntry on uParam3 parameter. That function is called by the VM on every line execution. I believe you can not get that information directly.
Regards,
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

harbour Question .... how to get list and values of active variables ?

Mensaje por ChrisGillard »

Hi Ignacio,
By studying debugger.prg and some questions and browsing on Harbour User group it seems that debuggers have to scan the relevant source to pick up the local NAMES as these are not in the .exe ..... bit of a surprise to me!!
Well I have made some simple functions to scan and analyse the Locals of the relevant prg and I have success.
See attached image of what I have achieved with Xailer.
Its aimed at being like your LogDisplay window, but I have functions I can call from xHarbour/Harbour & xBase++ that send an XML message by IP to my DebugServer in Xailer.
A realtime monitoring window that my non Xailer apps can use.
I am quite pleased with this so far.
Thank you for your help and Xailer.
Regards
Chris


Attached files
Responder