Skip to content

Symbols

Pete edited this page Apr 20, 2020 · 22 revisions

🔙 Home

Dynamic symbol table management

Harbour maintains a dynamic symbol table which can store up to 65.535 4.294.967.295 symbols. Each non-static function, object message, alias, field, private and public name allocates one item in symbol table. The same names share one symbol.
Below, are the available functions that help exporting several info, regarding the dynamic symbol table.

  • __dynsCount() nSymbols
    How much symbols have been already allocated/stored in dynamic symbol table?

  • __dynsGetIndex( <cSymbol> ) ndsIndex
    returns the ordinal index number of the given <cSymbol> into symbol table.

  • __dynsGetName( ndsIndex ) cName
    returns the name of symbol found in ndsIndex position of symbol table.

  • __dynsIsFun( <cSymbol> | <ndsIndex>) TRUE|FALSE
    returns .T. if the given <cSymbol> (or the symbol in <ndsIndex> position) has a function/procedure pointer. In other words the returned value will be either: TRUE if <cSymbol> is a function/procedure or FALSE if it's a variable, alias etc.

  • __dynsGetPRF( <ndsIndex> ) aInfo
    profiling function: It returns an array with two items { nCalls, nTime } where:
    nCalls item represents the number of times the function or procedure, found in <ndsIndex> position of symbol table, has been called
    nTime item represents the total time that has been consumed in executing that function/procedure.

    • NOTES:
      • __SetProfiler( .T. ) must have been invoked prior to calling this function, otherwise values of both items will be zero!
      • In order to use the Harbour Profiler, Harbour itself must have been built using HB_USE_PROFILER, since profiler code (in HVM) is disabled, by default.
  • __dynsN2Ptr( <cSymbol> ) pSymbol
    name to pointer conversion. (valtype: P)

  • __dynsN2Sym( cSymbol ) sSymbol
    name to symbol conversion. (valtype: S)

  • __dynsP2Name( pSymbol ) cName
    pointer to name conversion. (valtype: C)

  • __dynsVerify() nResult
    internal function used to debug dynamic symbol integrity. Returns 0=Ok, < 0=Problem?

  • __SetProfiler( .T.|.F. )
    turns the profiler mechanism ON or OFF. Used along with __dynsGetPRF() to allow gathering symbol usage data.


In a message in Harbour users group, Przemek wrote the bellow comment and code regarding the size of dynamic symbol table:

In normal applications 65535 is reasonable limit,
any how if someone wants to exploit it then it can always
do that regardless of the limit, i.e. using code like:

   PROCEDURE main()
      LOCAL i := 0, v
      WHILE .T.
         v := "var" + LTrim( str( ++i ) )
         PRIVATE &v
      ENDDO
   RETURN 

🔙 Home

Index

Harbour exclusive functions Clipper compatible functions
hb_A A
hb_B B
hb_C C
hb_D D
hb_E E
hb_F F
hb_G G
hb_H H
hb_I I
hb_J_K J K
hb_L L
hb_M M
hb_N_O N O
hb_P P
hb_R Q R
hb_S S
hb_T T
hb_U U
hb_V V W
hb_W X Y

  • Contrib. Libraries
HBWIN WinAPI Library Compress Libraries
HBHPDF Library (Haru) Multi Threading
Harbour Socket API hbCT (Cl*pper tools)
Serial API hbNF (NanForum library)
HBCURL cURL API Library Mini-XML docs

Clone this wiki locally