VirtualBox

Ignore:
Timestamp:
Aug 23, 2022 10:35:23 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
153292
Message:

IPRT/nocrt: A few tricks to avoid dragging in log.cpp into static binaries, unless there is an explicit log creation or debug logging in the app (or IPRT for the latter). bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/assert.cpp

    r96407 r96448  
    186186
    187187#else  /* !IN_RING0 */
    188 # if !defined(IN_RING3) && !defined(LOG_NO_COM)
    189 #  if 0 /* Enable this iff you have a COM port and really want this debug info. */
    190         RTLogComPrintf("\n!!Assertion Failed!!\n"
    191                        "Expression: %s\n"
    192                        "Location  : %s(%d) %s\n",
    193                        pszExpr, pszFile, uLine, pszFunction);
    194 #  endif
    195 # endif
    196 
    197         PRTLOGGER pLog = RTLogRelGetDefaultInstance();
    198         if (pLog)
    199         {
    200             RTLogRelPrintf("\n!!Assertion Failed!!\n"
    201                            "Expression: %s\n"
    202                            "Location  : %s(%d) %s\n",
    203                            pszExpr, pszFile, uLine, pszFunction);
     188
     189
     190# if defined(IN_RING3) && (defined(IN_RT_STATIC) || defined(IPRT_NO_CRT)) /* ugly */
     191        if (g_pfnRTLogAssert)
     192            g_pfnRTLogAssert(
     193# else
     194        RTLogAssert(
     195# endif
     196                             "\n!!Assertion Failed!!\n"
     197                             "Expression: %s\n"
     198                             "Location  : %s(%d) %s\n"
    204199# ifdef IPRT_WITH_ASSERT_STACK
    205             RTLogRelPrintf("Stack     :\n%s\n", szStack);
    206 # endif
    207 # ifndef IN_RC /* flushing is done automatically in RC */
    208             RTLogFlush(pLog);
    209 # endif
    210         }
    211 
    212 # ifndef LOG_ENABLED
    213         if (!pLog)
    214 # endif
    215         {
    216             pLog = RTLogDefaultInstance();
    217             if (pLog)
    218             {
    219                 RTLogPrintf("\n!!Assertion Failed!!\n"
    220                             "Expression: %s\n"
    221                             "Location  : %s(%d) %s\n",
    222                             pszExpr, pszFile, uLine, pszFunction);
     200                             "Stack     :\n%s\n"
     201# endif
     202                             , pszExpr, pszFile, uLine, pszFunction
    223203# ifdef IPRT_WITH_ASSERT_STACK
    224                 RTLogPrintf("Stack     :\n%s\n", szStack);
    225 # endif
    226 # ifndef IN_RC /* flushing is done automatically in RC */
    227                 RTLogFlush(pLog);
    228 # endif
    229             }
    230         }
     204                             , szStack
     205# endif
     206                             );
    231207
    232208# ifdef IN_RING3
     
    323299
    324300#else  /* !IN_RING0 */
    325 # if !defined(IN_RING3) && !defined(LOG_NO_COM)
    326 #  if 0 /* Enable this iff you have a COM port and really want this debug info. */
    327         va_copy(vaCopy, va);
    328         RTLogComPrintfV(pszFormat, vaCopy);
    329         va_end(vaCopy);
    330 #  endif
    331 # endif
    332 
    333         PRTLOGGER pLog = RTLogRelGetDefaultInstance();
    334         if (pLog)
     301
     302# if defined(IN_RING3) && (defined(IN_RT_STATIC) || defined(IPRT_NO_CRT))
     303        if (g_pfnRTLogAssert)
     304# endif
    335305        {
    336306            va_copy(vaCopy, va);
    337             RTLogRelPrintfV(pszFormat, vaCopy);
     307# if defined(IN_RING3) && (defined(IN_RT_STATIC) || defined(IPRT_NO_CRT))
     308            g_pfnRTLogAssertV(pszFormat, vaCopy);
     309# else
     310            RTLogAssertV(pszFormat, vaCopy);
     311# endif
    338312            va_end(vaCopy);
    339 # ifndef IN_RC /* flushing is done automatically in RC */
    340             RTLogFlush(pLog);
    341 # endif
    342         }
    343 
    344         pLog = RTLogDefaultInstance();
    345         if (pLog)
    346         {
    347             va_copy(vaCopy, va);
    348             RTLogPrintfV(pszFormat, vaCopy);
    349             va_end(vaCopy);
    350 # ifndef IN_RC /* flushing is done automatically in RC */
    351             RTLogFlush(pLog);
    352 #endif
    353313        }
    354314
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette