Bug 856566 - Fixed crashreporter compilation and profiler on mingw. r=ted

This commit is contained in:
Jacek Caban 2013-04-05 11:29:50 +02:00
parent 1a316eb8fb
commit d7cdcba080
8 changed files with 39 additions and 26 deletions

View File

@ -6020,7 +6020,7 @@ if test -n "$MOZ_CRASHREPORTER"; then
AC_SUBST(MOZ_GTHREAD_LIBS)
fi
if test "$OS_ARCH" != "$HOST_OS_ARCH"; then
if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT"; then
AC_MSG_ERROR([Breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH. Use --disable-crashreporter.])
fi

View File

@ -22,8 +22,6 @@
#include "nsWindowsHelpers.h"
namespace {
typedef const unsigned char* FileView;
template<>
@ -43,8 +41,6 @@ public:
}
};
} // anonymous namespace
#ifndef IMAGE_SIZEOF_BASE_RELOCATION
// Vista SDKs no longer define IMAGE_SIZEOF_BASE_RELOCATION!?
#define IMAGE_SIZEOF_BASE_RELOCATION (sizeof(IMAGE_BASE_RELOCATION))
@ -436,5 +432,5 @@ static void* MemoryGetProcAddress(PMEMORYMODULE module, const char *name)
}
// AddressOfFunctions contains the RVAs to the "real" functions
return (FARPROC) (module->remoteCodeBase + (*(DWORD *) (localCodeBase + exports->AddressOfFunctions + (idx*4))));
return module->remoteCodeBase + (*(DWORD *) (localCodeBase + exports->AddressOfFunctions + (idx*4)));
}

View File

@ -7,6 +7,8 @@
#undef WIN32_LEAN_AND_MEAN
#endif
#define NOMINMAX
#include "crashreporter.h"
#include <windows.h>
@ -893,7 +895,7 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
hwnd = GetDlgItem(hwndDlg, IDC_SUBMITREPORTCHECK);
GetRelativeRect(hwnd, hwndDlg, &rect);
int maxdiff = ResizeControl(hwnd, rect, Str(ST_CHECKSUBMIT), false,
long maxdiff = ResizeControl(hwnd, rect, Str(ST_CHECKSUBMIT), false,
gCheckboxPadding);
SetDlgItemText(hwndDlg, IDC_SUBMITREPORTCHECK,
Str(ST_CHECKSUBMIT).c_str());
@ -920,9 +922,9 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
hwnd = GetDlgItem(hwndDlg, IDC_INCLUDEURLCHECK);
GetRelativeRect(hwnd, hwndDlg, &rect);
int diff = ResizeControl(hwnd, rect, Str(ST_CHECKURL), false,
long diff = ResizeControl(hwnd, rect, Str(ST_CHECKURL), false,
gCheckboxPadding);
maxdiff = max(diff, maxdiff);
maxdiff = std::max(diff, maxdiff);
SetDlgItemText(hwndDlg, IDC_INCLUDEURLCHECK, Str(ST_CHECKURL).c_str());
// want this on by default
@ -937,7 +939,7 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
GetRelativeRect(hwnd, hwndDlg, &rect);
diff = ResizeControl(hwnd, rect, Str(ST_CHECKEMAIL), false,
gCheckboxPadding);
maxdiff = max(diff, maxdiff);
maxdiff = std::max(diff, maxdiff);
SetDlgItemText(hwndDlg, IDC_EMAILMECHECK, Str(ST_CHECKEMAIL).c_str());
if (CheckBoolKey(gCrashReporterKey.c_str(), EMAIL_ME_VALUE, &enabled) &&
@ -995,7 +997,7 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
restartRect.right - restartRect.left + 6 * 3;
GetClientRect(hwndDlg, &r);
// We may already have resized one of the checkboxes above
maxdiff = max(maxdiff, neededSize - (r.right - r.left));
maxdiff = std::max(maxdiff, neededSize - (r.right - r.left));
if (maxdiff > 0) {
// widen window
@ -1222,10 +1224,10 @@ static wstring UTF8ToWide(const string& utf8, bool *success)
return str;
}
string WideToUTF8(const wstring& wide, bool* success)
static string WideToMBCP(const wstring& wide, unsigned int cp, bool* success = nullptr)
{
char* buffer = NULL;
int buffer_size = WideCharToMultiByte(CP_UTF8, 0, wide.c_str(),
int buffer_size = WideCharToMultiByte(cp, 0, wide.c_str(),
-1, NULL, 0, NULL, NULL);
if(buffer_size == 0) {
if (success)
@ -1240,15 +1242,20 @@ string WideToUTF8(const wstring& wide, bool* success)
return "";
}
WideCharToMultiByte(CP_UTF8, 0, wide.c_str(),
WideCharToMultiByte(cp, 0, wide.c_str(),
-1, buffer, buffer_size, NULL, NULL);
string utf8 = buffer;
string mb = buffer;
delete [] buffer;
if (success)
*success = true;
return utf8;
return mb;
}
string WideToUTF8(const wstring& wide, bool* success)
{
return WideToMBCP(wide, CP_UTF8, success);
}
/* === Crashreporter UI Functions === */
@ -1424,8 +1431,11 @@ ifstream* UIOpenRead(const string& filename)
#if _MSC_VER >= 1400 // MSVC 2005/8
ifstream* file = new ifstream();
file->open(UTF8ToWide(filename).c_str(), ios::in);
#else // _MSC_VER >= 1400
#elif defined(_MSC_VER)
ifstream* file = new ifstream(_wfopen(UTF8ToWide(filename).c_str(), L"r"));
#else // GCC
ifstream* file = new ifstream(WideToMBCP(UTF8ToWide(filename), CP_ACP).c_str(),
ios::in);
#endif // _MSC_VER >= 1400
return file;
@ -1443,9 +1453,12 @@ ofstream* UIOpenWrite(const string& filename, bool append) // append=false
ofstream* file = new ofstream();
file->open(UTF8ToWide(filename).c_str(), append ? ios::out | ios::app
: ios::out);
#else // _MSC_VER >= 1400
#elif defined(_MSC_VER)
ofstream* file = new ofstream(_wfopen(UTF8ToWide(filename).c_str(),
append ? L"a" : L"w"));
#else // GCC
ofstream* file = new ofstream(WideToMBCP(UTF8ToWide(filename), CP_ACP).c_str(),
append ? ios::out | ios::app : ios::out);
#endif // _MSC_VER >= 1400
return file;

View File

@ -24,4 +24,8 @@ include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src
LDFLAGS += -ENTRY:DummyEntryPoint
ifndef GNU_CC
LDFLAGS += -ENTRY:DummyEntryPoint
else
LDFLAGS += -Wl,-e,_DummyEntryPoint@12
endif

View File

@ -9,9 +9,9 @@
using google_breakpad::ExceptionHandler;
using std::wstring;
BOOL WINAPI DummyEntryPoint(HINSTANCE instance,
DWORD reason,
void* reserved)
extern "C" BOOL WINAPI DummyEntryPoint(HINSTANCE instance,
DWORD reason,
void* reserved)
{
__debugbreak();

View File

@ -22,7 +22,7 @@
#include "client/windows/crash_generation/client_info.h"
#include "client/windows/crash_generation/crash_generation_server.h"
#include "client/windows/handler/exception_handler.h"
#include <DbgHelp.h>
#include <dbghelp.h>
#include <string.h>
#include "nsDirectoryServiceUtils.h"

View File

@ -59,12 +59,12 @@
# define SPS_ARCH_x86 1
# define SPS_OS_darwin 1
#elif defined(_MSC_VER) && defined(_M_IX86)
#elif (defined(_MSC_VER) || defined(__MINGW32__)) && (defined(_M_IX86) || defined(__i386__))
# define SPS_PLAT_x86_windows 1
# define SPS_ARCH_x86 1
# define SPS_OS_windows 1
#elif defined(_MSC_VER) && defined(_M_X64)
#elif (defined(_MSC_VER) || defined(__MINGW32__)) && (defined(_M_X64) || defined(__x86_64__))
# define SPS_PLAT_amd64_windows 1
# define SPS_ARCH_amd64 1
# define SPS_OS_windows 1

View File

@ -16,7 +16,7 @@
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include <windows.h>
#include <Ws2spi.h>
#include <ws2spi.h>
namespace mozilla {
namespace crashreporter {