Página 1 de 1
harbour Question .... how to get list and values of active variables ?
Publicado: Jue Jul 10, 2014 12:29 pm
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
harbour Question .... how to get list and values of active variables ?
Publicado: Jue Jul 10, 2014 4:45 pm
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
harbour Question .... how to get list and values of active variables ?
Publicado: Jue Jul 10, 2014 5:13 pm
por ChrisGillard
Ignacio,
Excellent ... will need a little study!
Thanks you very much for the pointer to debugger.prg.
Chris
harbour Question .... how to get list and values of active variables ?
Publicado: Jue Jul 10, 2014 7:18 pm
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
harbour Question .... how to get list and values of active variables ?
Publicado: Jue Jul 10, 2014 8:10 pm
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,
harbour Question .... how to get list and values of active variables ?
Publicado: Jue Jul 10, 2014 10:27 pm
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
harbour Question .... how to get list and values of active variables ?
Publicado: Jue Jul 10, 2014 10:58 pm
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
harbour Question .... how to get list and values of active variables ?
Publicado: Vie Jul 11, 2014 10:59 am
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,
harbour Question .... how to get list and values of active variables ?
Publicado: Vie Jul 11, 2014 3:40 pm
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