Skip to content

Commit

Permalink
- new flag –lv=LOG_TRACE to control TRACE-dump for debugging purpose
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23957 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Jan 7, 2015
1 parent 9b0d7a8 commit f1d0190
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
7 changes: 7 additions & 0 deletions SimulationRuntime/c/simulation/simulation_runtime.cpp
Expand Up @@ -240,6 +240,13 @@ void setGlobalVerboseLevel(int argc, char**argv)
if(useStream[LOG_DSS_JAC])
useStream[LOG_DSS] = 1;

#ifndef USE_DEBUG_TRACE
if(useStream[LOG_TRACE])
{
warningStreamPrint(LOG_STDOUT, 0, "LOG_TRACE is not available. Please recompile runtime with '#define USE_DEBUG_TRACE' and try again.");
}
#endif

delete flags;
}

Expand Down
5 changes: 4 additions & 1 deletion SimulationRuntime/c/simulation/solver/perform_simulation.c
Expand Up @@ -130,7 +130,10 @@ int prefixedName_performSimulation(DATA* data, SOLVER_INFO* solverInfo)
threadData->currentErrorStage = ERROR_SIMULATION;

#ifdef USE_DEBUG_TRACE
printf("TRACE: push loop step=%ld, time=%.12g\n", __currStepNo, solverInfo->currentTime);
if(useStream[LOG_TRACE])
{
printf("TRACE: push loop step=%ld, time=%.12g\n", __currStepNo, solverInfo->currentTime);
}
#endif

omc_alloc_interface.collect_a_little();
Expand Down
22 changes: 22 additions & 0 deletions SimulationRuntime/c/util/omc_error.c
Expand Up @@ -68,6 +68,7 @@ const char *LOG_STREAM_NAME[SIM_LOG_MAX] = {
"LOG_SOTI",
"LOG_STATS",
"LOG_STATS_V",
"LOG_TRACE",
"LOG_UTIL",
"LOG_ZEROCROSSINGS",
};
Expand Down Expand Up @@ -104,6 +105,7 @@ const char *LOG_STREAM_DESC[SIM_LOG_MAX] = {
"final solution of the initialization", /* LOG_SOTI */
"additional statistics about timer/events/solver", /* LOG_STATS */
"additional statistics for LOG_STATS", /* LOG_STATS_V */
"call stack for debugging purpose" /* LOG_TRACE */
"???", /* LOG_UTIL*/
"additional information about the zerocrossings" /* LOG_ZEROCROSSINGS */
};
Expand All @@ -123,6 +125,26 @@ int lastType[SIM_LOG_MAX];
int lastStream = LOG_UNKNOWN;
int showAllWarnings = 0;

#ifdef USE_DEBUG_TRACE
int DEBUG_TRACE_PUSH_HELPER(const char* pFnc, const char* pFile, const long ln)
{
if(useStream[LOG_TRACE])
{
printf("TRACE: push %s (%s:%d)\n", pFnc, pFile, ln);
}
return 0;
}

int DEBUG_TRACE_POP_HELPER(int traceID)
{
if(useStream[LOG_TRACE])
{
printf("TRACE: pop\n");
}
return 0;
}
#endif

void initDumpSystem()
{
int i;
Expand Down
7 changes: 5 additions & 2 deletions SimulationRuntime/c/util/omc_error.h
Expand Up @@ -102,6 +102,7 @@ enum LOG_STREAM
LOG_SOTI,
LOG_STATS,
LOG_STATS_V,
LOG_TRACE,
LOG_UTIL,
LOG_ZEROCROSSINGS,

Expand Down Expand Up @@ -143,8 +144,10 @@ void setStreamPrintXML(int isXML);
#endif

#ifdef USE_DEBUG_TRACE
#define TRACE_PUSH printf("TRACE: push %s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);
#define TRACE_POP printf("TRACE: pop\n");
extern int DEBUG_TRACE_PUSH_HELPER(const char* pFnc, const char* pFile, const long ln);
extern int DEBUG_TRACE_POP_HELPER(int traceID);
#define TRACE_PUSH int __DEBUG_TRACE_HELPER = DEBUG_TRACE_PUSH_HELPER(__FUNCTION__, __FILE__, __LINE__);
#define TRACE_POP DEBUG_TRACE_POP_HELPER(__DEBUG_TRACE_HELPER);
#else
#define TRACE_PUSH
#define TRACE_POP
Expand Down

0 comments on commit f1d0190

Please sign in to comment.