Author Topic: symbol browser show global variables instead of global functions  (Read 8071 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5280
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
symbol browser show global variables instead of global functions
« on: February 10, 2012, 03:59:33 am »
When I'm checking the bug: CC can`t add register variable

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

Code: [Select]
register uint8_t MyVarName asm("r2");

AAA BBB CCC("aaaa");

DDD EEE FFF GGG("bbbb");



Looks like a bug.

The strange thing is: some times, they go to the global function folder.
« Last Edit: February 10, 2012, 04:22:42 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9606
Re: symbol browser show global variables instead of global functions
« Reply #1 on: February 10, 2012, 08:59:48 am »
I found that the function declaration becomes variable declaration, see below:
Code: [Select]
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5280
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: symbol browser show global variables instead of global functions
« Reply #2 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: [Select]
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.

« Last Edit: February 10, 2012, 10:20:28 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9606
Re: symbol browser show global variables instead of global functions
« Reply #3 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5280
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: symbol browser show global variables instead of global functions
« Reply #4 on: February 10, 2012, 11:25:11 am »
Ok, I see some code
Code: [Select]
    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. :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.