Skip to content

Commit 94288d3

Browse files
author
Stanca Serban
committed
Backed out 5 changesets (bug 1794063, bug 1790873) for causing Linux spidermonkey builds bustages in Printer.h. CLOSED TREE
Backed out changeset c729aa80e73e (bug 1794063) Backed out changeset 442a0de27b61 (bug 1790873) Backed out changeset 6934f2978802 (bug 1790873) Backed out changeset 296f6da7b6ed (bug 1790873) Backed out changeset 01ddb562d770 (bug 1790873)
1 parent 973287f commit 94288d3

File tree

10 files changed

+214
-207
lines changed

10 files changed

+214
-207
lines changed

config/check_spidermonkey_style.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"jit/LIROpsGenerated.h", # generated in $OBJDIR
7070
"jit/MIROpsGenerated.h", # generated in $OBJDIR
7171
"js/ProfilingCategoryList.h", # comes from mozglue/baseprofiler
72-
"mozilla/glue/Debug.h", # comes from mozglue/misc, shadowed by <mozilla/Debug.h>
7372
"jscustomallocator.h", # provided by embedders; allowed to be missing
7473
"js-config.h", # generated in $OBJDIR
7574
"fdlibm.h", # fdlibm

config/check_vanilla_allocations.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ def main():
147147
"Decimal.o",
148148
# Ignore use of std::string in regexp AST debug output.
149149
"regexp-ast.o",
150-
# mozglue/misc/Debug.cpp contains a call to `printf_stderr("%s", aStr.str().c_str())`
151-
# where `aStr` is a `std::stringstream`. In inlined opt builds, this calls
152-
# `operator new()` and `operator delete` for a temporary.
153-
"Debug.o",
154150
]
155151
all_ignored_files = set((f, 1) for f in ignored_files)
156152

gfx/layers/opengl/CompositorOGL.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,13 +1464,16 @@ void CompositorOGL::InitializeVAO(const GLuint aAttrib, const GLint aComponents,
14641464
#ifdef MOZ_DUMP_PAINTING
14651465
template <typename T>
14661466
void WriteSnapshotToDumpFile_internal(T* aObj, DataSourceSurface* aSurf) {
1467+
nsCString string(aObj->Name());
1468+
string.Append('-');
1469+
string.AppendInt((uint64_t)aObj);
14671470
if (gfxUtils::sDumpPaintFile != stderr) {
1468-
gfxUtils::DumpAsDataURI(aSurf, gfxUtils::sDumpPaintFile);
1469-
} else {
1470-
nsCString uri = gfxUtils::GetAsDataURI(aSurf);
1471-
nsPrintfCString string(R"(array["%s-%)" PRIu64 R"("]="%s";\n)",
1472-
aObj->Name(), uint64_t(aObj), uri.BeginReading());
1473-
fprintf_stderr(gfxUtils::sDumpPaintFile, "%s", string.get());
1471+
fprintf_stderr(gfxUtils::sDumpPaintFile, R"(array["%s"]=")",
1472+
string.BeginReading());
1473+
}
1474+
gfxUtils::DumpAsDataURI(aSurf, gfxUtils::sDumpPaintFile);
1475+
if (gfxUtils::sDumpPaintFile != stderr) {
1476+
fprintf_stderr(gfxUtils::sDumpPaintFile, R"(";)");
14741477
}
14751478
}
14761479

intl/lwbrk/nsUniscribeBreaker.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,20 @@ void NS_GetComplexLineBreaks(const char16_t* aText, uint32_t aLength,
126126
}
127127

128128
if (mismatch) {
129-
nsCString line("uniscribe: ");
130129
// The logging here doesn't handle surrogates, but we only have tests using
131130
// Thai currently, which is BMP-only.
131+
printf_stderr("uniscribe: ");
132132
for (uint32_t i = 0; i < aLength; ++i) {
133-
if (aBreakBefore[i]) line.Append('#');
134-
line.Append(NS_ConvertUTF16toUTF8(aText + i, 1).get());
133+
if (aBreakBefore[i]) printf_stderr("#");
134+
printf_stderr("%s", NS_ConvertUTF16toUTF8(aText + i, 1).get());
135135
}
136-
printf_stderr("%s\n", line.get());
137-
line.Assign("brokered : ");
136+
printf_stderr("\n");
137+
printf_stderr("brokered : ");
138138
for (uint32_t i = 0; i < aLength; ++i) {
139-
if (brokeredBreaks[i]) line.Append('#');
140-
line.Append(NS_ConvertUTF16toUTF8(aText + i, 1).get());
139+
if (brokeredBreaks[i]) printf_stderr("#");
140+
printf_stderr("%s", NS_ConvertUTF16toUTF8(aText + i, 1).get());
141141
}
142-
printf_stderr("%s\n", line.get());
142+
printf_stderr("\n");
143143
MOZ_CRASH("Brokered breaks did not match.");
144144
}
145145
#endif

js/public/Printer.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#define js_Printer_h
99

1010
#include "mozilla/Attributes.h"
11-
#include "mozilla/glue/Debug.h"
1211
#include "mozilla/Range.h"
1312

1413
#include <stdarg.h>
@@ -340,22 +339,7 @@ class JS_PUBLIC_API Fprinter final : public GenericPrinter {
340339

341340
// Puts |len| characters from |s| at the current position and
342341
// return true on success, false on failure.
343-
bool put(const char* s, size_t len) override;
344-
using GenericPrinter::put; // pick up |inline bool put(const char* s);|
345-
};
346-
347-
// SEprinter, print using printf_stderr (goes to Android log, Windows debug,
348-
// else just stderr).
349-
class SEprinter final : public GenericPrinter {
350-
public:
351-
constexpr SEprinter() {}
352-
353-
// Puts |len| characters from |s| at the current position and
354-
// return true on success, false on failure.
355-
virtual bool put(const char* s, size_t len) override {
356-
printf_stderr("%.*s", int(len), s);
357-
return true;
358-
}
342+
virtual void put(const char* s, size_t len) override;
359343
using GenericPrinter::put; // pick up |inline bool put(const char* s);|
360344
};
361345

mozglue/misc/Debug.cpp

Lines changed: 0 additions & 123 deletions
This file was deleted.

mozglue/misc/Debug.h

Lines changed: 39 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
#ifndef mozilla_glue_Debug_h
88
#define mozilla_glue_Debug_h
99

10-
#include "mozilla/Attributes.h" // For MOZ_FORMAT_PRINTF
11-
#include "mozilla/Types.h" // For MFBT_API
12-
13-
#include <cstdarg>
14-
#include <sstream>
15-
1610
/* This header file intends to supply debugging utilities for use in code
1711
* that cannot use XPCOM debugging facilities like nsDebug.h.
1812
* e.g. mozglue, browser/app
@@ -21,53 +15,52 @@
2115
* care; avoid including from header files.
2216
*/
2317

18+
#include <io.h>
19+
#if defined(XP_WIN)
20+
# include <windows.h>
21+
#endif // defined(XP_WIN)
22+
#include "mozilla/Attributes.h"
23+
#include "mozilla/Sprintf.h"
24+
25+
#if defined(MOZILLA_INTERNAL_API)
26+
# error Do not include this file from XUL sources.
27+
#endif
28+
29+
// Though this is a separate implementation than nsDebug's, we want to make the
30+
// declarations compatible to avoid confusing the linker if both headers are
31+
// included.
2432
#ifdef __cplusplus
2533
extern "C" {
2634
#endif // __cplusplus
2735

28-
/**
29-
* printf_stderr(...) is much like fprintf(stderr, ...), except that:
30-
* - on Android and Firefox OS, *instead* of printing to stderr, it
31-
* prints to logcat. (Newlines in the string lead to multiple lines
32-
* of logcat, but each function call implicitly completes a line even
33-
* if the string does not end with a newline.)
34-
* - on Windows, if a debugger is present, it calls OutputDebugString
35-
* in *addition* to writing to stderr
36-
*/
37-
MFBT_API void printf_stderr(const char* aFmt, ...) MOZ_FORMAT_PRINTF(1, 2);
36+
void printf_stderr(const char* fmt, ...) MOZ_FORMAT_PRINTF(1, 2);
37+
inline void printf_stderr(const char* fmt, ...) {
38+
#if defined(XP_WIN)
39+
if (IsDebuggerPresent()) {
40+
char buf[2048];
41+
va_list args;
42+
va_start(args, fmt);
43+
VsprintfLiteral(buf, fmt, args);
44+
va_end(args);
45+
OutputDebugStringA(buf);
46+
}
47+
#endif // defined(XP_WIN)
3848

39-
/**
40-
* Same as printf_stderr, but taking va_list instead of varargs
41-
*/
42-
MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs)
43-
MOZ_FORMAT_PRINTF(1, 0);
49+
// stderr is unbuffered by default so we open a new FILE (which is buffered)
50+
// so that calls to printf_stderr are not as likely to get mixed together.
51+
int fd = _fileno(stderr);
52+
if (fd == -2) return;
4453

45-
/**
46-
* fprintf_stderr is like fprintf, except that if its file argument
47-
* is stderr, it invokes printf_stderr instead.
48-
*
49-
* This is useful for general debugging code that logs information to a
50-
* file, but that you would like to be useful on Android and Firefox OS.
51-
* If you use fprintf_stderr instead of fprintf in such debugging code,
52-
* then callers can pass stderr to get logging that works on Android and
53-
* Firefox OS (and also the other side-effects of using printf_stderr).
54-
*
55-
* Code that is structured this way needs to be careful not to split a
56-
* line of output across multiple calls to fprintf_stderr, since doing
57-
* so will cause it to appear in multiple lines in logcat output.
58-
* (Producing multiple lines at once is fine.)
59-
*/
60-
MFBT_API void fprintf_stderr(FILE* aFile, const char* aFmt, ...)
61-
MOZ_FORMAT_PRINTF(2, 3);
54+
FILE* fp = _fdopen(_dup(fd), "a");
55+
if (!fp) return;
6256

63-
/*
64-
* print_stderr and fprint_stderr are like printf_stderr and fprintf_stderr,
65-
* except they deal with Android logcat line length limitations. They do this
66-
* by printing individual lines out of the provided stringstream using separate
67-
* calls to logcat.
68-
*/
69-
MFBT_API void print_stderr(std::stringstream& aStr);
70-
MFBT_API void fprint_stderr(FILE* aFile, std::stringstream& aStr);
57+
va_list args;
58+
va_start(args, fmt);
59+
vfprintf(fp, fmt, args);
60+
va_end(args);
61+
62+
fclose(fp);
63+
}
7164

7265
#ifdef __cplusplus
7366
}

mozglue/misc/moz.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ if CONFIG["OS_ARCH"] == "WINNT":
4343
SOURCES += [
4444
"AutoProfilerLabel.cpp",
4545
"AwakeTimeStamp.cpp",
46-
"Debug.cpp",
4746
"MmapFaultHandler.cpp",
4847
"Printf.cpp",
4948
"SIMD.cpp",

0 commit comments

Comments
 (0)