callstack fixed, wrong file listed
[scilab.git] / scilab / modules / ast / src / cpp / ast / debuggervisitor.cpp
index 38438b1..fffeef8 100644 (file)
@@ -25,7 +25,6 @@
 
 extern "C"
 {
-#include "filemanager_interface.h"
 #include "FileExist.h"
 }
 
@@ -252,20 +251,22 @@ void DebuggerVisitor::visit(const SeqExp  &e)
             setExpectedSize(iExpectedSize);
             types::InternalType * pIT = getResult();
 
-            // In case of exec file, set the file name in the Macro to store where it is defined.
-            int iFileID = ConfigVariable::getExecutedFileID();
-            if (iFileID && exp->isFunctionDec())
+            if(exp->isFunctionDec())
             {
-                types::InternalType* pITMacro = symbol::Context::getInstance()->get(exp->getAs<ast::FunctionDec>()->getSymbol());
-                if (pITMacro)
+                // In case of exec file, set the file name in the Macro to store where it is defined.
+                std::wstring strFile = ConfigVariable::getExecutedFile();
+                const std::vector<ConfigVariable::WhereEntry>& lWhereAmI = ConfigVariable::getWhere();
+
+                if (strFile != L"" &&  // check if we are executing a script or a macro
+                    lWhereAmI.empty() == false &&
+                    lWhereAmI.back().m_file_name != nullptr && // check the last function execution is a macro
+                    *(lWhereAmI.back().m_file_name) == strFile) // check the last execution is the same macro as the executed one
                 {
-                    types::Macro* pMacro = pITMacro->getAs<types::Macro>();
-                    const wchar_t* filename = getfile_filename(iFileID);
-                    // scilab.quit is not open with mopen
-                    // in this case filename is NULL because FileManager have not been filled.
-                    if (filename)
+                    types::InternalType* pITMacro = symbol::Context::getInstance()->get(exp->getAs<FunctionDec>()->getSymbol());
+                    if (pITMacro)
                     {
-                        pMacro->setFileName(filename);
+                        types::Macro* pMacro = pITMacro->getAs<types::Macro>();
+                        pMacro->setFileName(strFile);
                     }
                 }
             }