Ejemplo n.º 1
0
void
mozilla_sampler_log(const char *fmt, va_list args)
{
  if (profiler_is_active()) {
    // nsAutoCString AppendPrintf would be nicer but
    // this is mozilla external code
    char buf[2048];
    va_list argsCpy;
    VARARGS_ASSIGN(argsCpy, args);
    int required = vsnprintf(buf, sizeof(buf), fmt, argsCpy);
    va_end(argsCpy);

    if (required < 0) {
      return; // silently drop for now
    } else if (required < 2048) {
      profiler_tracing("log", buf, TRACING_EVENT);
    } else {
      char* heapBuf = new char[required+1];
      va_list argsCpy;
      VARARGS_ASSIGN(argsCpy, args);
      vsnprintf(heapBuf, required+1, fmt, argsCpy);
      va_end(argsCpy);
      // EVENT_BACKTRACE could be used to get a source
      // for all log events. This could be a runtime
      // flag later.
      profiler_tracing("log", heapBuf, TRACING_EVENT);
      delete[] heapBuf;
    }
  }
}
Ejemplo n.º 2
0
void
vprintf_stderr(const char* aFmt, va_list aArgs)
{
  if (sStderrCallback) {
    va_list argsCpy;
    VARARGS_ASSIGN(argsCpy, aArgs);
    sStderrCallback(aFmt, aArgs);
    va_end(argsCpy);
  }

  if (IsDebuggerPresent()) {
    char buf[2048];
    va_list argsCpy;
    VARARGS_ASSIGN(argsCpy, aArgs);
    vsnprintf(buf, sizeof(buf), aFmt, argsCpy);
    buf[sizeof(buf) - 1] = '\0';
    va_end(argsCpy);
    OutputDebugStringA(buf);
  }

  FILE* fp = _fdopen(_dup(2), "a");
  if (!fp) {
    return;
  }

  vfprintf(fp, aFmt, aArgs);

  fclose(fp);
}
Ejemplo n.º 3
0
void
vprintf_stderr(const char* aFmt, va_list aArgs)
{
  if (sStderrCallback) {
    va_list argsCpy;
    VARARGS_ASSIGN(argsCpy, aArgs);
    sStderrCallback(aFmt, aArgs);
    va_end(argsCpy);
  }

  vfprintf(stderr, aFmt, aArgs);
}
Ejemplo n.º 4
0
void
vprintf_stderr(const char* aFmt, va_list aArgs)
{
  if (sStderrCallback) {
    va_list argsCpy;
    VARARGS_ASSIGN(argsCpy, aArgs);
    sStderrCallback(aFmt, aArgs);
    va_end(argsCpy);
  }

  __android_log_vprint(ANDROID_LOG_INFO, "Gecko", aFmt, aArgs);
}