Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: ollydbg on February 10, 2012, 03:59:33 am

Title: symbol browser show global variables instead of global functions
Post by: ollydbg on February 10, 2012, 03:59:33 am
When I'm checking the bug: CC can`t add register variable (https://developer.berlios.de/bugs/?func=detailbug&bug_id=18411&group_id=5358)

I found that the function declaration becomes variable declaration, see below:

Code
register uint8_t MyVarName asm("r2");

AAA BBB CCC("aaaa");

DDD EEE FFF GGG("bbbb");

(http://i683.photobucket.com/albums/vv194/ollydbg_cb/2012-02-10104510.png)

Looks like a bug.

The strange thing is: some times, they go to the global function folder.
Title: Re: symbol browser show global variables instead of global functions
Post by: MortenMacFly on February 10, 2012, 08:59:48 am
I found that the function declaration becomes variable declaration, see below:
Code
register uint8_t MyVarName asm("r2");
AAA BBB CCC("aaaa");
DDD EEE FFF GGG("bbbb");
Yes, I noticed this, too. I've even marked the part in the CC parser thread (GetTokenBaseType) where this fails (look for a TODO / FIXME item).

It's not easy to resolve though without knowing base variable types before.
Title: Re: symbol browser show global variables instead of global functions
Post by: ollydbg on February 10, 2012, 10:04:06 am
It looks like the parserthread works OK parsing on such code, they were recognized as functions (when debugging cc plugins).

When debug parsertest.cbp, it always recognized them as global functions (See the call HandleFunction) , they were update to global variables later, see the log:
Code
000001. --------------M-a-i-n--L-o-g--------------


000002. -----------I-n-t-e-r-i-m--L-o-g-----------
000003. InitTokenizer() : m_Filename='test.h', m_FileSize=107.
000004. Init() : m_Filename='test.h'
000005. test.h
000006. Parse() : Parsing 'test.h'
000007. SkipComment() : Start from line = 1
000008. SkipComment() : Need to call SkipToEOL() here at line = 1
000009. bool Tokenizer::SkipToInlineCommentEnd() : line=1, CurrentChar='r', PreviousChar='/', NextChar='e'
000010. SkipToInlineCommentEnd(): (END) We are now at line 1, CurrentChar='\n', PreviousChar='\r', NextChar='X'
000011. DoParse() : Loop:m_Str='', token='XXX'
000012. DoParse() : Loop:m_Str='XXX ', token='YYY'
000013. ReadParentheses(): ("aaaa"), line=2
000014. HandleFunction() : Adding function 'YYY': m_Str='XXX '
000015. HandleFunction() : name='YYY', args='("aaaa")', peek=';'
000016. HandleFunction() : !(Ctor/Dtor) 'YYY', m_Str='XXX ', localParent='<none>'
000017. HandleFunction() : Adding function 'YYY', ': m_Str='XXX ', enc_ns='nil'.
000018. HandleFunction() : Add token name='YYY', args='("aaaa")', return type='XXX '
000019. GetBaseArgs() : args='("aaaa")'.
000020. DoAddToken() : Created token='YYY', file_idx=1, line=2, ticket=
000021. GetTokenBaseType() : Searching within m_Str='XXX'
000022. GetTokenBaseType() : Compensated m_Str='XXX'
000023. GetTokenBaseType() : Found 'XXX'
000024. DoAddToken() : Prepending ''
000025. DoAddToken() : Added/updated token 'YYY' (0), kind 'variable', type 'XXX', actual 'XXX'. Parent is  (-1)
000026. DoParse() : Loop:m_Str='', token=';'
000027. DoParse() : Loop:m_Str='', token='AAA'
000028. DoParse() : Loop:m_Str='AAA ', token='BBB'
000029. DoParse() : Loop:m_Str='AAA BBB ', token='CCC'
000030. ReadParentheses(): ("aaaa"), line=3
000031. HandleFunction() : Adding function 'CCC': m_Str='AAA BBB '
000032. HandleFunction() : name='CCC', args='("aaaa")', peek=';'
000033. HandleFunction() : !(Ctor/Dtor) 'CCC', m_Str='AAA BBB ', localParent='<none>'
000034. HandleFunction() : Adding function 'CCC', ': m_Str='AAA BBB ', enc_ns='nil'.
000035. HandleFunction() : Add token name='CCC', args='("aaaa")', return type='AAA BBB '
000036. GetBaseArgs() : args='("aaaa")'.
000037. DoAddToken() : Created token='CCC', file_idx=1, line=3, ticket=
000038. GetTokenBaseType() : Searching within m_Str='AAA BBB'
000039. GetTokenBaseType() : Compensated m_Str='AAA BBB'
000040. GetTokenBaseType() : Found 'BBB'
000041. DoAddToken() : Prepending ''
000042. DoAddToken() : Added/updated token 'CCC' (1), kind 'variable', type 'AAA BBB', actual 'BBB'. Parent is  (-1)
000043. DoParse() : Loop:m_Str='', token=';'
000044. DoParse() : Loop:m_Str='', token='DDD'
000045. DoParse() : Loop:m_Str='DDD ', token='EEE'
000046. DoParse() : Loop:m_Str='DDD EEE ', token='FFF'
000047. DoParse() : Loop:m_Str='DDD EEE FFF ', token='GGG'
000048. ReadParentheses(): ("bbbb"), line=4
000049. HandleFunction() : Adding function 'GGG': m_Str='DDD EEE FFF '
000050. HandleFunction() : name='GGG', args='("bbbb")', peek=';'
000051. HandleFunction() : !(Ctor/Dtor) 'GGG', m_Str='DDD EEE FFF ', localParent='<none>'
000052. HandleFunction() : Adding function 'GGG', ': m_Str='DDD EEE FFF ', enc_ns='nil'.
000053. HandleFunction() : Add token name='GGG', args='("bbbb")', return type='DDD EEE FFF '
000054. GetBaseArgs() : args='("bbbb")'.
000055. DoAddToken() : Created token='GGG', file_idx=1, line=4, ticket=
000056. GetTokenBaseType() : Searching within m_Str='DDD EEE FFF'
000057. GetTokenBaseType() : Compensated m_Str='DDD EEE FFF'
000058. GetTokenBaseType() : Found 'FFF'
000059. DoAddToken() : Prepending ''
000060. DoAddToken() : Added/updated token 'GGG' (2), kind 'variable', type 'DDD EEE FFF', actual 'FFF'. Parent is  (-1)
000061. DoParse() : Loop:m_Str='', token=';'
000062. --------------T-r-e-e--L-o-g--------------

000063. XXX YYY("aaaa") [2,0]
000064. AAA BBB CCC("aaaa") [3,0]
000065. DDD EEE FFF GGG("bbbb") [4,0]
000066. --------------L-i-s-t--L-o-g--------------

000067. variable XXX YYY("aaaa") [2,0]
000068. variable AAA BBB CCC("aaaa") [3,0]
000069. variable DDD EEE FFF GGG("bbbb") [4,0]
000070. The parser contains 3 tokens, found in 1 files.

Strange.

Title: Re: symbol browser show global variables instead of global functions
Post by: MortenMacFly on February 10, 2012, 11:06:14 am
When debug parsertest.cbp, it always recognized them as global functions (See the call HandleFunction) , they were update to global variables later, see the log:
Not strange, but the true parser (in CC) parses and resolves macros correct from the priority header files before parsing this.
Title: Re: symbol browser show global variables instead of global functions
Post by: ollydbg on February 10, 2012, 11:25:11 am
Ok, I see some code
Code
    wxString baseArgs;
    if (kind & tkAnyFunction)
    {
        if (!GetBaseArgs(args, baseArgs))
            kind = tkVariable;
    }

So, there is a potential cases that the "function" token becomes "variable" token (depend on the arguments).
I think I will add some comments here. :)