- Timestamp:
- Aug 19, 2018 1:43:17 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 124445
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/assert.h
r69105 r73762 72 72 RT_C_DECLS_BEGIN 73 73 74 #if !defined(IPRT_WITHOUT_ASSERT_STACK) \ 75 && defined(IN_RING3) \ 76 && (defined(RT_ARCH_AMD64) /*|| defined(RT_ARCH_X86)*/) \ 77 && (defined(RT_OS_WINDOWS) /*|| ... */) 78 /** @def IPRT_WITH_ASSERT_STACK 79 * Indicates that we collect a callstack stack on assertion. */ 80 # define IPRT_WITH_ASSERT_STACK 81 #endif 82 74 83 /** 75 84 * The 1st part of an assert message. … … 216 225 * @{ 217 226 */ 218 /** The last assert message, 1st part. */227 /** The last assertion message, 1st part. */ 219 228 extern RTDATADECL(char) g_szRTAssertMsg1[1024]; 220 /** The last assert message, 2nd part. */229 /** The last assertion message, 2nd part. */ 221 230 extern RTDATADECL(char) g_szRTAssertMsg2[4096]; 222 /** The last assert message, expression. */ 231 #ifdef IPRT_WITH_ASSERT_STACK 232 /** The last assertion message, stack part. */ 233 extern RTDATADECL(char) g_szRTAssertStack[4096]; 234 #endif 235 /** The last assertion message, expression. */ 223 236 extern RTDATADECL(const char * volatile) g_pszRTAssertExpr; 224 /** The last assert message, file name. */237 /** The last assertion message, file name. */ 225 238 extern RTDATADECL(const char * volatile) g_pszRTAssertFile; 226 /** The last assert message, line number. */239 /** The last assertion message, line number. */ 227 240 extern RTDATADECL(uint32_t volatile) g_u32RTAssertLine; 228 /** The last assert message, function name. */241 /** The last assertion message, function name. */ 229 242 extern RTDATADECL(const char * volatile) g_pszRTAssertFunction; 230 243 /** @} */ -
trunk/src/VBox/Runtime/common/misc/assert.cpp
r69111 r73762 33 33 34 34 #include <iprt/asm.h> 35 #ifdef IPRT_WITH_ASSERT_STACK 36 # ifndef IN_RING3 37 # error "IPRT_WITH_ASSERT_STACK is only for ring-3 at present." 38 # endif 39 # include <iprt/dbg.h> 40 #endif 35 41 #include <iprt/err.h> 36 42 #include <iprt/log.h> … … 46 52 * Global Variables * 47 53 *********************************************************************************************************************************/ 48 /** The last assert message, 1st part. */54 /** The last assertion message, 1st part. */ 49 55 RTDATADECL(char) g_szRTAssertMsg1[1024]; 50 56 RT_EXPORT_SYMBOL(g_szRTAssertMsg1); 51 /** The last assert message, 2nd part. */57 /** The last assertion message, 2nd part. */ 52 58 RTDATADECL(char) g_szRTAssertMsg2[4096]; 53 59 RT_EXPORT_SYMBOL(g_szRTAssertMsg2); 60 #ifdef IPRT_WITH_ASSERT_STACK 61 /** The last assertion message, stack part. */ 62 RTDATADECL(char) g_szRTAssertStack[4096]; 63 RT_EXPORT_SYMBOL(g_szRTAssertStack); 64 #endif 54 65 /** The length of the g_szRTAssertMsg2 content. 55 66 * @remarks Race. */ 56 67 static uint32_t volatile g_cchRTAssertMsg2; 57 /** The last assert message, expression. */68 /** The last assertion message, expression. */ 58 69 RTDATADECL(const char * volatile) g_pszRTAssertExpr; 59 70 RT_EXPORT_SYMBOL(g_pszRTAssertExpr); 60 /** The last assert message, function name. */71 /** The last assertion message, function name. */ 61 72 RTDATADECL(const char * volatile) g_pszRTAssertFunction; 62 73 RT_EXPORT_SYMBOL(g_pszRTAssertFunction); 63 /** The last assert message, file name. */74 /** The last assertion message, file name. */ 64 75 RTDATADECL(const char * volatile) g_pszRTAssertFile; 65 76 RT_EXPORT_SYMBOL(g_pszRTAssertFile); 66 /** The last assert message, line number. */77 /** The last assertion message, line number. */ 67 78 RTDATADECL(uint32_t volatile) g_u32RTAssertLine; 68 79 RT_EXPORT_SYMBOL(g_u32RTAssertLine); … … 126 137 RTErrVarsSave(&SavedErrVars); 127 138 139 #ifdef IPRT_WITH_ASSERT_STACK 140 /* The stack dump. */ 141 char szStack[sizeof(g_szRTAssertStack)]; 142 size_t cchStack = RTDbgStackDumpSelf(szStack, sizeof(szStack), 0); 143 memcpy(g_szRTAssertStack, szStack, cchStack + 1); 144 #endif 145 128 146 #ifdef IN_RING0 129 147 # ifdef IN_GUEST_R0 … … 153 171 "Location : %s(%d) %s\n", 154 172 pszExpr, pszFile, uLine, pszFunction); 173 # ifdef IPRT_WITH_ASSERT_STACK 174 RTLogRelPrintf("Stack :\n%s\n", szStack); 175 # endif 155 176 # ifndef IN_RC /* flushing is done automatically in RC */ 156 177 RTLogFlush(pLog); … … 169 190 "Location : %s(%d) %s\n", 170 191 pszExpr, pszFile, uLine, pszFunction); 192 # ifdef IPRT_WITH_ASSERT_STACK 193 RTLogPrintf("Stack :\n%s\n", szStack); 194 # endif 171 195 # ifndef IN_RC /* flushing is done automatically in RC */ 172 196 RTLogFlush(pLog); … … 185 209 uLine, 186 210 VALID_PTR(pszFunction) ? pszFunction : ""); 211 # ifdef IPRT_WITH_ASSERT_STACK 212 fprintf(stderr, "Stack :\n%s\n", szStack); 213 # endif 187 214 fflush(stderr); 188 215 # endif
Note:
See TracChangeset
for help on using the changeset viewer.