User forums > Help

CodeBlocks cash when "Find declaration " on some symbol

<< < (4/5) > >>

ollydbg:

--- Quote from: MortenMacFly on February 23, 2011, 11:08:13 am ---Instead of all this copying (not sure how wxStringTokenizer is implemented though... :oops:)?

--- End quote ---
I'm not sure whether Tokenizer will depend on the wxString, so I just do a copy to avoid the risk :).


--- Quote ---And what about the commented stuff? You change functionality here... was that on purpose (what about side-effects)?
--- End quote ---
Yes, I do change the functionality, but I'm not sure why we care about "local" characters of a token.

So, my patch is only a "candidate to avoid crash". :D

MortenMacFly:

--- Quote from: ollydbg on February 23, 2011, 12:51:38 pm ---I'm not sure whether Tokenizer will depend on the wxString, so I just do a copy to avoid the risk :).

--- End quote ---
Checking the sources revealed a copy is made internally. So you don't need to do this. ;-)

ollydbg:
the code snippet:

--- Code: ---        if (!token->m_IsLocal) // global symbols are linked once
        {
            //Manager::Get()->GetMessageManager()->DebugLog("Removing ancestor string from %s", token->m_Name.c_str(), token->m_Name.c_str());
            token->m_AncestorsString.Clear();
        }

--- End code ---
was added in rev 1711 by rick22 with the log:


--- Quote ---rickg22  2006-1-11 15:19:20            
Revamped the CodeCompletion plugin, Stage 1. Reparsing after saving files is much faster now. Also, the code completion functionality is much faster due to the searchtree structure.
Known issues: The Class browser is NOT updated when using the cache. WARNING: Might cause crashes if you have the cache enabled. Please disable it.

--- End quote ---

I'm not sure why a token with m_IsLocal==true does NOT allowed to remove the m_AncestorsString. But currently rick is not maintain the CC's code, So I guess he nearly forget something. I'll PM him about this.

From my point of view, there is no reason we should keep the ancestorstring if we already use it to calculate the hierarchy. :D

ollydbg:
see the source code:


--- Code: ---void TokensTree::RecalcData()
{
#if CC_TOKEN_DEBUG_OUTPUT
    wxStopWatch sw;
#endif

    TRACE(_T("RecalcData() : Calculating full inheritance tree."));
    // first loop to convert ancestors string to token indices for each token
    for (size_t i = 0; i < size(); ++i)
    {
        Token* token = at(i);
        if (!token)
            continue;

        if (!(token->m_TokenKind & (tkClass | tkTypedef | tkEnum | tkNamespace)))
            continue;
        if (token->m_AncestorsString.IsEmpty())
            continue;
        // only local symbols might change inheritance
//        if (!token->m_IsLocal)
//            continue;



--- End code ---

the last two line was comment out in rev 2855 by mandrav.

Note: currently, the function RecalcData() is not used in CC. we use a new method to dynamically call the hierarchy. which is:


--- Code: ---class A :public B,C{};
class D :public B,C{};
class C :public X{};

--- End code ---

Once the parser finish parsing, then, A's ancestorString is "B,C", D's ancestorString is "B,C", and C's ancestorString is "X".
Now, every thing is OK, we do not call RecalcData(). What's RecalcData() does can divided to two stages:

1, transform the ancestorString to ancestor Idx on evey tokens of the tree. so, A's ancestorIdx will have index to Token B, and index C
   D's ancestorIdx will have index to Token B, and index C ; D's ancestorIdx will have index to Token X. no further hierarchy is calculated.    meanwhile, all the ancestorString will be cleared.(as they were transform to Idxs)

2, calculate the full hierarchy, which means a recursive function call:
   A's ancestorIdx will have index to Token B, Token C and Token X.  (Token X added by calculate the hierarchy)
   D's ancestorIdx will have index to Token B, and Token C and Token X. (Token X added by calculate the hierarchy)
   C's ancestorIdx will have index to Token X. (the same as stage 1)

The currently way we use was "calculate the fully hierarchy on the Tokens we would like to use". which means if we want to query information of Token A, we only calculate the "stage 1 and stage 2" on the exact token A.


BTW:
This thread was suggested to move to CC's sub forum to record such info. :D


  


ollydbg:
patch v2.

--- Code: ---Index: token.cpp
===================================================================
--- token.cpp (revision 7028)
+++ token.cpp (working copy)
@@ -1039,8 +1039,12 @@
 
     TRACE(_T("RecalcInheritanceChain() : Token %s, Ancestors %s"), token->m_Name.wx_str(),
           token->m_AncestorsString.wx_str());
-
     wxStringTokenizer tkz(token->m_AncestorsString, _T(","));
+
+    TRACE(_T("RecalcInheritanceChain() : Removing ancestor string from %s"), token->m_Name.wx_str());
+    token->m_AncestorsString.Clear();
+
+
     while (tkz.HasMoreTokens())
     {
         wxString ancestor = tkz.GetNextToken();
@@ -1111,11 +1115,6 @@
 
         token->m_DirectAncestors = token->m_Ancestors;
 
-        if (!token->m_IsLocal) // global symbols are linked once
-        {
-            TRACE(_T("RecalcInheritanceChain() : Removing ancestor string from %s"), token->m_Name.wx_str());
-            token->m_AncestorsString.Clear();
-        }
     }
 
 #if CC_TOKEN_DEBUG_OUTPUT


--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version