Changeset 16782 in webkit for trunk/JavaScriptCore/wtf


Ignore:
Timestamp:
Oct 4, 2006, 1:34:21 PM (19 years ago)
Author:
darin
Message:

Reviewed by Adam.

  • wtf/Assertions.cpp: Changed assertion formatting to omit the "======" lines so you can see more assertions in less space. Also improved format of file/line information so it works with more development environments.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/Assertions.cpp

    r16484 r16782  
    3939#define _WIN32_WINNT 0x0500
    4040#include <windows.h>
     41#include <crtdbg.h>
    4142#endif
    4243
     
    4546// This is to work around the "you should use a printf format attribute" warning on GCC
    4647// We can't use _attribute__ ((format (printf, 2, 3))) since we allow %@
    47 static int (* vfprintf_no_warning)(FILE *, const char *, va_list) = vfprintf;
     48static int (* vfprintf_no_warning)(FILE *, const char*, va_list) = vfprintf;
    4849
    49 static void vprintf_stderr_common(const char *format, va_list args)
     50static void vprintf_stderr_common(const char* format, va_list args)
    5051{
    5152#if PLATFORM(MAC)
     
    5556       
    5657        int length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8);
    57         char *buffer = (char *)malloc(length + 1);
     58        char* buffer = (char*)malloc(length + 1);
    5859
    5960        CFStringGetCString(str, buffer, length, kCFStringEncodingUTF8);
     
    6667    } else
    6768#elif PLATFORM(WIN)
    68     if (IsDebuggerPresent())
    69     {
     69    if (IsDebuggerPresent()) {
    7070        size_t size = 1024;
    7171
    72         do
    73         {
     72        do {
    7473            char* buffer = (char*)malloc(size);
    7574
     
    7776                break;
    7877
    79             if (_vsnprintf(buffer, size, format, args) != -1)
    80             {
     78            if (_vsnprintf(buffer, size, format, args) != -1) {
    8179                OutputDebugStringA(buffer);
    8280                free(buffer);
     
    9290}
    9391
    94 static void printf_stderr_common(const char * format, ...)
     92static void printf_stderr_common(const char* format, ...)
    9593{
    9694    va_list args;
     
    10098}
    10199
    102 void WTFReportAssertionFailure(const char *file, int line, const char *function, const char *assertion)
     100static void printCallSite(const char* file, int line, const char* function)
     101{
     102#if PLATFORM(WIN)
     103    _CrtDbgReport(_CRT_WARN, file, line, NULL, "%s\n", function);
     104#else
     105    printf_stderr_common("(%s:%d %s)\n", file, line, function);
     106#endif
     107}
     108
     109void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion)
    103110{
    104111    if (assertion)
    105         printf_stderr_common("=================\nASSERTION FAILED: %s (%s:%d %s)\n=================\n", assertion, file, line, function);
     112        printf_stderr_common("ASSERTION FAILED: %s\n", assertion);
    106113    else
    107         printf_stderr_common("=================\nSHOULD NEVER BE REACHED (%s:%d %s)\n=================\n", file, line, function);
     114        printf_stderr_common("SHOULD NEVER BE REACHED\n");
     115    printCallSite(file, line, function);
    108116}
    109117
    110 void WTFReportAssertionFailureWithMessage(const char *file, int line, const char *function, const char *assertion, const char *format, ...)
     118void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...)
    111119{
    112     printf_stderr_common("=================\nASSERTION FAILED: ");
     120    printf_stderr_common("ASSERTION FAILED: ");
    113121    va_list args;
    114122    va_start(args, format);
    115123    vprintf_stderr_common(format, args);
    116124    va_end(args);
    117     printf_stderr_common("\n%s (%s:%d %s)\n=================\n", assertion, file, line, function);
     125    printf_stderr_common("\n%s\n", assertion);
     126    printCallSite(file, line, function);
    118127}
    119128
    120 void WTFReportArgumentAssertionFailure(const char *file, int line, const char *function, const char *argName, const char *assertion)
     129void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion)
    121130{
    122     printf_stderr_common("=================\nARGUMENT BAD: %s, %s (%s:%d %s)\n=================\n", argName, assertion, file, line, function);
     131    printf_stderr_common("ARGUMENT BAD: %s, %s\n", argName, assertion);
     132    printCallSite(file, line, function);
    123133}
    124134
    125 void WTFReportFatalError(const char *file, int line, const char *function, const char *format, ...)
     135void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...)
    126136{
    127     printf_stderr_common("=================\nFATAL ERROR: ");
     137    printf_stderr_common("FATAL ERROR: ");
    128138    va_list args;
    129139    va_start(args, format);
    130140    vprintf_stderr_common(format, args);
    131141    va_end(args);
    132     printf_stderr_common("\n(%s:%d %s)\n=================\n", file, line, function);
     142    printf_stderr_common("\n");
     143    printCallSite(file, line, function);
    133144}
    134145
    135 void WTFReportError(const char *file, int line, const char *function, const char *format, ...)
     146void WTFReportError(const char* file, int line, const char* function, const char* format, ...)
    136147{
    137     printf_stderr_common("=================\nERROR: ");
     148    printf_stderr_common("ERROR: ");
    138149    va_list args;
    139150    va_start(args, format);
    140151    vprintf_stderr_common(format, args);
    141152    va_end(args);
    142     printf_stderr_common("\n(%s:%d %s)\n=================\n", file, line, function);
     153    printf_stderr_common("\n");
     154    printCallSite(file, line, function);
    143155}
    144156
    145 void WTFLog(const char*, int, const char*, WTFLogChannel *channel, const char *format, ...)
     157void WTFLog(const char*, int, const char*, WTFLogChannel *channel, const char* format, ...)
    146158{   
    147159    if (channel->state != WTFLogChannelOn)
Note: See TracChangeset for help on using the changeset viewer.