Hi Przemek,

Thanks a lot,
I was in meeting since Friday in Deutchland (Dark Forest) (without computer 
:-() for a martial art meeting so, I just discovered your mails today.

I see now was I was missing. I will try now to implement it here. 

Again, many thanks for your time.

JF,

-----Message d'origine-----
De : harbour-boun...@harbour-project.org 
[mailto:harbour-boun...@harbour-project.org] De la part de Przemyslaw Czerpak
Envoyé : lundi 15 juin 2009 1:09
À : Harbour Project Main Developer List.
Objet : Re: RE: RE: [Harbour] HRB question ??? Possible bug !

On Wed, 10 Jun 2009, J. Lefebvre wrote:

Hi,

> Sorry to annoy you with thisbut I became crazy.
> I was thinking I understanded how it work and tryed to implement a solution
> allowing the load and unload of hrb file without changing any structure.
> So the idea is the following ;
> 1) if  hb_dynsymFind( pSymbol->szName ) find something,I first change
> the name of the actual symbol, replacing it with a string from the new
> function pointer, then simply adding the new pSymbol calling
> hb_dynsymNew( pSymbol ).
> The idea is that if we unload the HRB file, I could retrieve the original
> Symbol by doing an hb_dynsymNew( "NewName_fromptr" ) and then restoring
> the name to the actual name of the unloaded symbol. Doing so, it should
> work even in case of many hrb load and unload, despite the load/unload
> order.

I guess that you want to use dynamic symbol table as temporary old symbol
holder but it's not enough. In such case symbol table will work like hash
array so it should be possible to use it instead. Anyhow I do not know
how do you want to resolve the references chains and update them when
.hrb modules are unloaded in different order. I do not understand
what you are trying to do or the construction you are using is not enough
to implement clean unload.

> But I never reach to test load/unload as It simply does'nt work.
> So, in hb_vmRegisterSymbols(...), when the new function symbol name
> already exist (found by hb_dynsymNew()), I first change the name of
> the actual symbol, then add the new symbol. If I then check with
> hb_dynsymNew( ), it return me the new function symbol, with the good
> function pointer ...
> But, in any case, from the prg point of view, it always launch the
> function from the exe :-(
> Any idea ? 
> PS :  I also tried to simply replace the actual symbol with the new one
> with the same effect ... 
> PS2 : Trying to just replace the function ptr do cause a GPF :-(
> ....
>       if( fPublic )
>       {
>          if( fDynLib && HB_VM_ISFUNC( pSymbol ) )   // ok trying to add 
> dynamic function
>          {
>             PHB_DYNS pDynSym;
>             pDynSym = hb_dynsymFind( pSymbol->szName );  
>             if( pDynSym )                           // ok symbol of that name 
> already exist
>             {
>                if( pDynSym->pSymbol != pSymbol && HB_VM_ISFUNC( 
> pDynSym->pSymbol ) )  // not same symbol pointer
>                {
>                   if (pSymbol->value.pFunPtr == 
> pDynSym->pSymbol->value.pFunPtr) // keep actual way if function pointer are 
> the same
>                   {
>                     pSymbol->pDynSym = pDynSym;
>                     pSymbol->scope.value =
>                      ( pSymbol->scope.value & ~( HB_FS_PCODEFUNC | 
> HB_FS_LOCAL ) ) |
>                      ( pDynSym->pSymbol->scope.value & HB_FS_PCODEFUNC );
>                     pSymbol->value.pFunPtr = pDynSym->pSymbol->value.pFunPtr;
>                   }
>                   else
>                   { 
>                     sprintf((char *) szTmp , (const char *) "~%p", 
> pSymbol->value.pFunPtr) ;
>                     pDynSym->pSymbol->szName = szTmp ;  // change the name to 
> a string created from the new function pointer

Here you are breaking dynamic symbol table. It has to be well sorted by
symbol name and above change dynamic symbol name without resorting it.
Never made anything like that.
It also does not update all other references to old functions which exists
in other modules symbol tables. Modification in pDynSym change only next
references and macro compiler calls. If you want to fully overload public
function you have to also scan all other modules for public references
to the function and update them. If you plan to make such updating very
often then internal structures should be modified to keep linked list
of references which probably can be also used to keep list of overloaded
functions.

>                     printf("Registring: %s:%s scope %04x\r\n", szModuleName, 
> pSymbol->szName, hSymScope ); fflush(stdout);
>                     printf("Old funct renamed to %s \r\n", 
> pDynSym->pSymbol->szName ); fflush(stdout);
>                     hb_dynsymNew( pSymbol );   // add new symbol ptr
>                   } 
>                }
>                else
>                {
>                   pSymbol->pDynSym = pDynSym;
>                   pDynSym->pSymbol = pSymbol;
>                }
>                continue;

The above will not work as you want and I do not see how it can help in
clean module unloading.
I sent to your private address two functions which made some modifications
on symbol tables. Look at them.

best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour


_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to