User forums > Using Code::Blocks

c::b's macro replace map sometime doe not work correctly

<< < (3/3)

ollydbg:
Hi, all, I finally find a solution, this method is just like way currently used in

--- Code: ---int CompilerGCC::Run(ProjectBuildTarget* target)
{
...
    if (!target)
    {
        if (m_RealTargetIndex == -1) // only ask for target if a virtual target is selected
        {
            int idx = -1;
            int bak = m_RealTargetIndex;
            if (m_pProject->GetBuildTargetsCount() == 1)
                idx = 0;
            else
                idx = DoGUIAskForTarget();

            m_RealTargetIndex = idx;
            target = DoAskForTarget();
            m_RealTargetIndex = bak;
        }
        else
            target = DoAskForTarget();
    }
//    DBGLOG(_T("2) target=%s, m_RealTargetIndex=%d, m_TargetIndex=%d"), target ? target->GetTitle().c_str() : _T("null"), m_RealTargetIndex, m_TargetIndex);

    if (!target)
        return -1;

    m_pProject->SetCurrentlyCompilingTarget(target); // help macros manager

.....[prepare many run command]
.....

    m_pProject->SetCurrentlyCompilingTarget(0);

    Manager::Get()->GetProjectManager()->SetIsRunning(this);
    return 0;

}

--- End code ---
See: it use SetCurrentlyCompilingTarget() to dynamically handle the target related variable for Macromanager.

So, I create a patch (against an quite old svn revision ;))which did same thing as this for debugger plugin.

--- Code: ---Index: E:/code/cb/cb_trunk/src/plugins/debuggergdb/debuggergdb.cpp
===================================================================
--- E:/code/cb/cb_trunk/src/plugins/debuggergdb/debuggergdb.cpp (revision 8190)
+++ E:/code/cb/cb_trunk/src/plugins/debuggergdb/debuggergdb.cpp (working copy)
@@ -632,12 +632,17 @@
         else
             target = m_pProject->GetBuildTarget(m_ActiveBuildTarget);
 
+        // the macro manager will internal use this current compiling target to initial
+        // some target related variables
+        m_pProject->SetCurrentlyCompilingTarget(target);
+
         // make sure it's not a commands-only target
         if (target->GetTargetType() == ttCommandsOnly)
         {
             cbMessageBox(_("The selected target is only running pre/post build step commands\n"
                         "Can't debug such a target..."), _("Information"), wxICON_INFORMATION);
             Log(_("aborted"));
+            m_pProject->SetCurrentlyCompilingTarget(0);
             return 3;
         }
         Log(target->GetTitle());
@@ -654,6 +659,7 @@
         msg.Printf(_("This %s is configured to use an invalid debugger.\nThe operation failed..."), target ? _("target") : _("project"));
         cbMessageBox(msg, _("Error"), wxICON_ERROR);
         m_Canceled = true;
+        m_pProject->SetCurrentlyCompilingTarget(0);
         return 9;
     }
 
@@ -677,6 +683,7 @@
         }
 
         m_Canceled = true;
+        m_pProject->SetCurrentlyCompilingTarget(0);
         return -1;
     }
 
@@ -685,6 +692,7 @@
     {
         cbMessageBox(_T("Could not decide which debugger to use!"), _T("Error"), wxICON_ERROR);
         m_Canceled = true;
+        m_pProject->SetCurrentlyCompilingTarget(0);
         return -1;
     }
 
@@ -698,6 +706,7 @@
         cbMessageBox(_T("A plugin interrupted the debug process."));
         Log(_("Aborted by plugin"));
         m_Canceled = true;
+        m_pProject->SetCurrentlyCompilingTarget(0);
         return -1;
     }
     // Continue
@@ -817,6 +826,7 @@
     if (ret != 0)
     {
         m_Canceled = true;
+        m_pProject->SetCurrentlyCompilingTarget(0);
         return ret;
     }
 
@@ -836,8 +846,12 @@
         --i;
     }
     if (!m_State.HasDriver())
+    {
+        m_pProject->SetCurrentlyCompilingTarget(0);
         return -1;
+    }
 
+
     bool isConsole = (target && target->GetTargetType() == ttConsoleOnly);
     m_State.GetDriver()->Prepare(isConsole, m_printElements);
     m_State.ApplyBreakpoints();
@@ -871,6 +885,7 @@
     if (m_pProcess)
         SwitchToDebuggingLayout();
 
+    m_pProject->SetCurrentlyCompilingTarget(0);
     return 0;
 } // Debug
 


--- End code ---

Tested and works fine. :)

MortenMacFly:

--- Quote from: ollydbg on August 30, 2012, 02:31:19 am ---Tested and works fine. :)

--- End quote ---
Good to hear... I'll give it a shot, too.

ollydbg:
I accidentally see this patch is still on testing stage for a long time. (I really forget this)
What's your opinion?
Do you think it should go to trunk?

MortenMacFly:

--- Quote from: ollydbg on July 31, 2013, 01:15:32 am ---Do you think it should go to trunk?

--- End quote ---
I got it applied still and I see no problems. I think obfuscated should tell.

oBFusCATed:
It looks strange to me and I suppose this is not the proper solution, just a hack.
I'll look at it a bit more thoroughly in the next days and then I'll tell.

Also this m_pProject->SetCurrentlyCompilingTarget(0); is pretty bad, RAII should be used here.

Navigation

[0] Message Index

[*] Previous page

Go to full version