Changeset 295661 in webkit for trunk/Source/JavaScriptCore/tools
- Timestamp:
- Jun 18, 2022, 9:13:05 PM (3 years ago)
- Location:
- trunk/Source/JavaScriptCore/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/tools/Integrity.cpp
r295660 r295661 35 35 #include "Options.h" 36 36 #include "VMInspectorInlines.h" 37 #include <wtf/DataLog.h> 38 #include <wtf/OSLogPrintStream.h> 37 39 38 40 namespace JSC { … … 41 43 namespace IntegrityInternal { 42 44 static constexpr bool verbose = false; 45 } 46 47 PrintStream& logFile() 48 { 49 #if OS(DARWIN) 50 static PrintStream* s_file; 51 static std::once_flag once; 52 std::call_once(once, [] { 53 // We want to use OS_LOG_TYPE_ERROR because we want to guarantee that the log makes it into 54 // the file system, and is not potentially stuck in some memory buffer. Integrity audit logs 55 // are used for debugging error states. So, this is an appropriate use of OS_LOG_TYPE_ERROR. 56 s_file = OSLogPrintStream::open("com.apple.JavaScriptCore", "Integrity", OS_LOG_TYPE_ERROR).release(); 57 }); 58 return *s_file; 59 #else 60 return WTF::dataFile(); 61 #endif 62 } 63 64 void logF(const char* format, ...) 65 { 66 va_list argList; 67 va_start(argList, format); 68 logFile().vprintf(format, argList); 69 va_end(argList); 70 } 71 72 void logLnF(const char* format, ...) 73 { 74 va_list argList; 75 va_start(argList, format); 76 logFile().vprintf(format, argList); 77 va_end(argList); 78 logFile().println(); 43 79 } 44 80 … … 141 177 #define AUDIT_VERIFY(cond, format, ...) do { \ 142 178 IA_ASSERT_WITH_ACTION(cond, { \ 143 WTFLogAlways(" cell %p", cell); \179 Integrity::logLnF(" cell %p", cell); \ 144 180 if (action == Action::LogAndCrash) \ 145 RELEASE_ASSERT((cond) , ##__VA_ARGS__); \181 RELEASE_ASSERT((cond)); \ 146 182 else \ 147 183 return false; \ 148 } , format, ##__VA_ARGS__); \184 }); \ 149 185 } while (false) 150 186 … … 153 189 #define AUDIT_VERIFY(cond, format, ...) do { \ 154 190 IA_ASSERT_WITH_ACTION(cond, { \ 155 WTFLogAlways(" cell %p", cell); \191 Integrity::logLnF(" cell %p", cell); \ 156 192 if (action == Action::LogAndCrash) \ 157 193 RELEASE_ASSERT((cond) __VA_OPT__(,) __VA_ARGS__); \ … … 291 327 { 292 328 bool valid = Analyzer::analyzeCell(cell, Analyzer::Action::LogOnly); 293 WTFLogAlways("Cell %p is %s", cell, valid ? "VALID" : "INVALID");329 Integrity::logLnF("Cell %p is %s", cell, valid ? "VALID" : "INVALID"); 294 330 return valid; 295 331 } … … 298 334 { 299 335 bool valid = Analyzer::analyzeCell(vm, cell, Analyzer::Action::LogOnly); 300 WTFLogAlways("Cell %p is %s", cell, valid ? "VALID" : "INVALID");336 Integrity::logLnF("Cell %p is %s", cell, valid ? "VALID" : "INVALID"); 301 337 return valid; 302 338 } -
trunk/Source/JavaScriptCore/tools/Integrity.h
r294287 r295661 49 49 typedef struct OpaqueJSValue* JSObjectRef; 50 50 51 namespace WTF { 52 class PrintStream; 53 } 54 51 55 namespace JSC { 52 56 … … 178 182 179 183 #define IA_LOG(assertion, format, ...) do { \ 180 WTFLogAlways("Integrity ERROR: %s @ %s:%d\n", #assertion, __FILE__, __LINE__); \ 181 WTFLogAlways(" " format, ##__VA_ARGS__); \ 184 Integrity::logLnF("ERROR: %s @ %s:%d", #assertion, __FILE__, __LINE__); \ 182 185 } while (false) 183 186 … … 185 188 if (UNLIKELY(!(assertion))) { \ 186 189 IA_LOG(assertion, __VA_ARGS__); \ 187 WTFReportBacktraceWithPrefix (" "); \190 WTFReportBacktraceWithPrefixAndPrintStream(Integrity::logFile(), " "); \ 188 191 action; \ 189 192 } \ … … 192 195 #define IA_ASSERT(assertion, ...) \ 193 196 IA_ASSERT_WITH_ACTION(assertion, { \ 194 RELEASE_ASSERT((assertion) , ##__VA_ARGS__); \195 } , ## __VA_ARGS__)197 RELEASE_ASSERT((assertion)); \ 198 }) 196 199 197 200 #else // not (COMPILER(MSVC) || !VA_OPT_SUPPORTED) 198 201 199 202 #define IA_LOG(assertion, format, ...) do { \ 200 WTFLogAlways("Integrity ERROR: %s @ %s:%d\n", #assertion, __FILE__, __LINE__); \201 WTFLogAlways(" " format __VA_OPT__(,) __VA_ARGS__); \203 Integrity::logLnF("ERROR: %s @ %s:%d", #assertion, __FILE__, __LINE__); \ 204 Integrity::logLnF(" " format __VA_OPT__(,) __VA_ARGS__); \ 202 205 } while (false) 203 206 … … 205 208 if (UNLIKELY(!(assertion))) { \ 206 209 IA_LOG(assertion, __VA_ARGS__); \ 207 WTFReportBacktraceWithPrefix (" "); \210 WTFReportBacktraceWithPrefixAndPrintStream(Integrity::logFile(), " "); \ 208 211 action; \ 209 212 } \ … … 217 220 #endif // COMPILER(MSVC) || !VA_OPT_SUPPORTED 218 221 222 JS_EXPORT_PRIVATE WTF::PrintStream& logFile(); 223 JS_EXPORT_PRIVATE void logF(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2); 224 JS_EXPORT_PRIVATE void logLnF(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2); 225 219 226 } // namespace Integrity 220 227
Note:
See TracChangeset
for help on using the changeset viewer.