Trace task (constructing a function graph) - page 4

 
I used a template like this:
/*
extern bool TraceIsAllowed;                              // Показывать трассировку?
//+------------------------------------------------------------------+
//| XXX
//+------------------------------------------------------------------+
void XXX(string MasterName, string ProgramTrace, string Parameter)
  {
   string SlaveName="XXX";                               // Имя функции.
   ProgramTrace=ProgramTrace+"=>"+SlaveName;             // Путь обращения к функции.
   if( Parameter!="" ) ProgramTrace=ProgramTrace+"("+Parameter+")";
   string Message=ProgramTrace;                          // Функциональные сообщения.
   LastErrorCode=GetLastError();
   if( LastErrorCode>0 )
     {                                                   // Ошибка или некорректные параметры.
      Message=Message+" ERROR "+LastErrorCode+" at Start";
      Message=Message+"";                                // Значения параметров.
      Print(Message); return;                            // Функцию не выполнять.
     }
   if( TraceIsAllowed ) Print(Message);                  // Задана трассировка программы .
//----
   
//----
   LastErrorCode=GetLastError();
   if( LastErrorCode>0 ) Message=Message+" ERROR "+LastErrorCode;
   if( Message!=ProgramTrace )
     {                                                   // Были функциональные сообщения.
      Message=Message+" ";                               // Функция выполнена.
      Print(Message);                                    // Печать функциональных сообщений.
     }
   return;
  }
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   string SlaveName="Init";                              // Имя функции.
   string ProgramTrace=SlaveName;                        // Путь обращения к функции.
   string Message=ProgramTrace;                          // Функциональные сообщения.
   LastErrorCode=GetLastError();
   if( LastErrorCode>0 )
     {                                                   // Ошибка или некорректные параметры.
      Message=Message+" ERROR "+LastErrorCode+" at Start";
      Print(Message); return(0);                         // Функцию не выполнять.
     }
   if( TraceIsAllowed ) Print(Message);                  // Задана трассировка программы .
//----
   
//----
   LastErrorCode=GetLastError();
   if( LastErrorCode>0 ) Message=Message+" ERROR "+LastErrorCode;
   if( Message!=ProgramTrace )
     {                                                   // Были функциональные сообщения.
      Message=Message+" ";                               // Функция выполнена.
      Print(Message);                                    // Печать функциональных сообщений.
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   string SlaveName="Start";                             // Имя функции.
   string ProgramTrace=SlaveName;                        // Путь обращения к функции.
   string Message=ProgramTrace;                          // Функциональные сообщения.
   LastErrorCode=GetLastError();
   if( LastErrorCode>0 )
     {                                                   // Ошибка или некорректные параметры.
      Message=Message+" ERROR "+LastErrorCode+" at Start";
      Print(Message); return(0);                         // Функцию не выполнять.
     }
   if( TraceIsAllowed ) Print(Message);                  // Задана трассировка программы .
//----
   
//----
   LastErrorCode=GetLastError();
   if( LastErrorCode>0 ) Message=Message+" ERROR "+LastErrorCode;
   if( Message!=ProgramTrace )
     {                                                   // Были функциональные сообщения.
      Message=Message+" ";                               // Функция выполнена.
      Print(Message);                                    // Печать функциональных сообщений.
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
   string SlaveName="DeInit";                            // Имя функции.
   string ProgramTrace=SlaveName;                        // Путь обращения к функции.
   string Message=ProgramTrace;                          // Функциональные сообщения.
   LastErrorCode=GetLastError();
   if( LastErrorCode>0 )
     {                                                   // Ошибка или некорректные параметры.
      Message=Message+" ERROR "+LastErrorCode+" at Start";
      Print(Message); return(0);                         // Функцию не выполнять.
     }
   if( TraceIsAllowed ) Print(Message);                  // Задана трассировка программы .
//----
   
//----
   LastErrorCode=GetLastError();
   if( LastErrorCode>0 ) Message=Message+" ERROR "+LastErrorCode;
   if( Message!=ProgramTrace )
     {                                                   // Были функциональные сообщения.
      Message=Message+" ";                               // Функция выполнена.
      Print(Message);                                    // Печать функциональных сообщений.
     }
   return(0);
  }
*/
//+------------------------------------------------------------------+
 
tara:
I used a template like this:

it's a little different.
 
sergeev:

I see two blocks in the code too, one at the beginning and one at the end... but I need one.

The one at the end has nothing to do with tracing. You can delete it.
 
tara:
The one at the end is irrelevant to tracing. You can delete it.

Yes. I see. But still... we don't look at errors, we look at each input to the function.
 
sergeev:

Yes. I can see that. But still... We don't look at errors, we look at each input to the function.

Errors can be thrown out, too.

extern bool TraceIsAllowed;                              // Показывать трассировку?
//+------------------------------------------------------------------+
//| XXX
//+------------------------------------------------------------------+
void XXX(string MasterName, string ProgramTrace, string Parameter)
  {
   string SlaveName="XXX";                               // Имя функции.
   ProgramTrace=ProgramTrace+"=>"+SlaveName;             // Путь обращения к функции.
   if( Parameter!="" ) ProgramTrace=ProgramTrace+"("+Parameter+")";
   string Message=ProgramTrace;                          // Функциональные сообщения.
   if( TraceIsAllowed ) Print(Message);                  // Задана трассировка программы .
//----
   
//----
   return;
  }
 
... Is Mql the right language to do tracing in!!!
 
tara:

Mistakes can be thrown out, too.

:))

the task (if you read the first post) comes down to adding just one service-function to each function in the source code - right after "{".

But in such a way to get all passages of source code and build a call tree.

It doesn't change input parameters of source functions in any way, nor does it change results or code inside


jartmailru:
... Is Mql the right language to do tracing in!!!

It's not about pure trace. It's just about constructing a function graph.
 
sergeev:
It's not about pure trace. Only about building the function graph.
Static code analysis... Execution is not required.
The code is broken into functions (blocks) and then it is analyzed who calls whom.
 
jartmailru:
... Is Mql the right language to do tracing in!!!

Why not, if you want to.

 
sergeev:

:))

the problem (if you read the first post) comes down to adding just one service-function to each function in the source code - right after "{".

But in such a way to get all source code passes and build the call tree.

Is it not obvious that this task is unsolvable? That way we could eliminate pairs of arithmetic () [] and operator {} brackets and replace them with a single opening one. Would that be too bad?

;)

Reason: