News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

handle define

Started by blueshake, July 21, 2009, 05:00:39 AM

Previous topic - Next topic

blueshake

hello :
     I found that the macro tip is a little problem .see the picture in attach .

[attachment deleted by admin]
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

blueshake

#1
I know that ollydbg have done work for the macro parse problem ,I apply the patch .but the tip problem
seem still exist .So I do a little work for it .It's better now . :)
Index: parserthread.cpp
===================================================================
--- parserthread.cpp (revision 5696)
+++ parserthread.cpp (working copy)
@@ -978,14 +978,30 @@
    // BLAH_BLAH
    if (!token.IsEmpty())
    {
-        // skip the rest of the #define
-        wxString defVal = token + m_Tokenizer.ReadToEOL();
-
+                // skip the rest of the #define
+       wxString defVal = token + m_Tokenizer.ReadToEOL();
+        wxString para(_T(""));
+        size_t start = defVal.find('(');
+        size_t end = defVal.find(')');
+        //Manager::Get()->GetLogManager()->DebugLog(F(_T("Saving nesting level: %d,%d"), start, end));
        // make sure preprocessor definitions are not going under namespaces or classes!
+        if (start != wxString::npos && end != wxString::npos)
+        {
+            para = defVal.Mid(start, end-start+1);
+            m_Str = defVal.Mid(end + 1);
+            m_Str.Trim(false);
+        }
+        else
+        {
+            m_Str = defVal.substr(token.length());
+            m_Str.Trim(false);
+            //defVal = _T("");
+        }
        Token* oldParent = m_pLastParent;
        m_pLastParent = 0L;
-        DoAddToken(tkPreprocessor, token, lineNr, lineNr, m_Tokenizer.GetLineNumber(), defVal, false, true);
+        DoAddToken(tkPreprocessor, token, lineNr, lineNr, m_Tokenizer.GetLineNumber(), para, false, true);
        m_pLastParent = oldParent;
+        m_Str.Clear();
    }
}



here aa2 is macro .
and the macro can have param tip now .see the picture in attach.

[attachment deleted by admin]
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

ollydbg

I have applied in my local copy(though I had to manually patch these code, because Tortoise refused to patch on a modified parserthread.cpp, so, if the patch is small, you can also post the whole function)

This patch works perfect!!!

Thanks for your contribution!!!
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.

blueshake

@ollydgb
thank you for your suggestion.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?