Fix Windows client compilation on mingw.

A=Jacek Caban <jacek@codeweavers.com>, R=ted at http://breakpad.appspot.com/548002/

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1399 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
ted.mielczarek@gmail.com 2014-11-03 17:05:39 +00:00
parent 507a09f4de
commit c971cf439c
15 changed files with 45 additions and 32 deletions

View file

@ -30,7 +30,7 @@
#ifndef CLIENT_WINDOWS_COMMON_AUTO_CRITICAL_SECTION_H__ #ifndef CLIENT_WINDOWS_COMMON_AUTO_CRITICAL_SECTION_H__
#define CLIENT_WINDOWS_COMMON_AUTO_CRITICAL_SECTION_H__ #define CLIENT_WINDOWS_COMMON_AUTO_CRITICAL_SECTION_H__
#include <Windows.h> #include <windows.h>
namespace google_breakpad { namespace google_breakpad {

View file

@ -30,8 +30,8 @@
#ifndef CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ #ifndef CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__
#define CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ #define CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__
#include <Windows.h> #include <windows.h>
#include <DbgHelp.h> #include <dbghelp.h>
#include <string> #include <string>
#include <utility> #include <utility>
#include "common/windows/string_utils-inl.h" #include "common/windows/string_utils-inl.h"

View file

@ -30,8 +30,8 @@
#ifndef CLIENT_WINDOWS_CRASH_GENERATION_CLIENT_INFO_H__ #ifndef CLIENT_WINDOWS_CRASH_GENERATION_CLIENT_INFO_H__
#define CLIENT_WINDOWS_CRASH_GENERATION_CLIENT_INFO_H__ #define CLIENT_WINDOWS_CRASH_GENERATION_CLIENT_INFO_H__
#include <Windows.h> #include <windows.h>
#include <DbgHelp.h> #include <dbghelp.h>
#include "client/windows/common/ipc_protocol.h" #include "client/windows/common/ipc_protocol.h"
#include "common/scoped_ptr.h" #include "common/scoped_ptr.h"
#include "google_breakpad/common/minidump_format.h" #include "google_breakpad/common/minidump_format.h"

View file

@ -176,9 +176,14 @@ bool HandleTraceData::CollectHandleData(
stream_data->Reserved = 0; stream_data->Reserved = 0;
std::copy(operations_.begin(), std::copy(operations_.begin(),
operations_.end(), operations_.end(),
#ifdef _MSC_VER
stdext::checked_array_iterator<AVRF_HANDLE_OPERATION*>( stdext::checked_array_iterator<AVRF_HANDLE_OPERATION*>(
reinterpret_cast<AVRF_HANDLE_OPERATION*>(stream_data + 1), reinterpret_cast<AVRF_HANDLE_OPERATION*>(stream_data + 1),
operations_.size())); operations_.size())
#else
reinterpret_cast<AVRF_HANDLE_OPERATION*>(stream_data + 1)
#endif
);
return true; return true;
} }
@ -350,7 +355,7 @@ bool MinidumpGenerator::WriteMinidump() {
user_streams.UserStreamArray = user_stream_array.get(); user_streams.UserStreamArray = user_stream_array.get();
MDRawAssertionInfo* actual_assert_info = assert_info_; MDRawAssertionInfo* actual_assert_info = assert_info_;
MDRawAssertionInfo client_assert_info = {0}; MDRawAssertionInfo client_assert_info = {{0}};
if (assert_info_) { if (assert_info_) {
// If the assertion info object lives in the client process, // If the assertion info object lives in the client process,

View file

@ -34,6 +34,7 @@
#include <dbghelp.h> #include <dbghelp.h>
#include <rpc.h> #include <rpc.h>
#include <list> #include <list>
#include <string>
#include "google_breakpad/common/minidump_format.h" #include "google_breakpad/common/minidump_format.h"
namespace google_breakpad { namespace google_breakpad {

View file

@ -27,7 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ObjBase.h> #include <objbase.h>
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>

View file

@ -57,8 +57,8 @@
#define CLIENT_WINDOWS_HANDLER_EXCEPTION_HANDLER_H__ #define CLIENT_WINDOWS_HANDLER_EXCEPTION_HANDLER_H__
#include <stdlib.h> #include <stdlib.h>
#include <Windows.h> #include <windows.h>
#include <DbgHelp.h> #include <dbghelp.h>
#include <rpc.h> #include <rpc.h>
#pragma warning(push) #pragma warning(push)

View file

@ -32,7 +32,7 @@
#ifndef COMMON_WINDOWS_GUID_STRING_H_ #ifndef COMMON_WINDOWS_GUID_STRING_H_
#define COMMON_WINDOWS_GUID_STRING_H_ #define COMMON_WINDOWS_GUID_STRING_H_
#include <Guiddef.h> #include <guiddef.h>
#include <string> #include <string>

View file

@ -327,11 +327,13 @@ bool HTTPUpload::GetFileContents(const wstring &filename,
// wchar_t* filename, so use _wfopen directly in that case. For VC8 and // wchar_t* filename, so use _wfopen directly in that case. For VC8 and
// later, _wfopen has been deprecated in favor of _wfopen_s, which does // later, _wfopen has been deprecated in favor of _wfopen_s, which does
// not exist in earlier versions, so let the ifstream open the file itself. // not exist in earlier versions, so let the ifstream open the file itself.
#if _MSC_VER >= 1400 // MSVC 2005/8 // GCC doesn't support wide file name and opening on FILE* requires ugly
// hacks, so fallback to multi byte file.
#ifdef _MSC_VER
ifstream file; ifstream file;
file.open(filename.c_str(), ios::binary); file.open(filename.c_str(), ios::binary);
#else // _MSC_VER >= 1400 #else // GCC
ifstream file(_wfopen(filename.c_str(), L"rb")); ifstream file(WideToMBCP(filename, CP_ACP).c_str(), ios::binary);
#endif // _MSC_VER >= 1400 #endif // _MSC_VER >= 1400
if (file.is_open()) { if (file.is_open()) {
file.seekg(0, ios::end); file.seekg(0, ios::end);
@ -375,13 +377,13 @@ wstring HTTPUpload::UTF8ToWide(const string &utf8) {
} }
// static // static
string HTTPUpload::WideToUTF8(const wstring &wide) { string HTTPUpload::WideToMBCP(const wstring &wide, unsigned int cp) {
if (wide.length() == 0) { if (wide.length() == 0) {
return string(); return string();
} }
// compute the length of the buffer we'll need // compute the length of the buffer we'll need
int charcount = WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, int charcount = WideCharToMultiByte(cp, 0, wide.c_str(), -1,
NULL, 0, NULL, NULL); NULL, 0, NULL, NULL);
if (charcount == 0) { if (charcount == 0) {
return string(); return string();
@ -389,7 +391,7 @@ string HTTPUpload::WideToUTF8(const wstring &wide) {
// convert // convert
char *buf = new char[charcount]; char *buf = new char[charcount];
WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, buf, charcount, WideCharToMultiByte(cp, 0, wide.c_str(), -1, buf, charcount,
NULL, NULL); NULL, NULL);
string result(buf); string result(buf);

View file

@ -38,8 +38,8 @@
// Disable exception handler warnings. // Disable exception handler warnings.
#pragma warning(disable : 4530) #pragma warning(disable : 4530)
#include <Windows.h> #include <windows.h>
#include <WinInet.h> #include <wininet.h>
#include <map> #include <map>
#include <string> #include <string>
@ -80,7 +80,7 @@ class HTTPUpload {
// this merely checks (via the return value) that we were successfully // this merely checks (via the return value) that we were successfully
// able to retrieve exactly as many bytes of content in the response as // able to retrieve exactly as many bytes of content in the response as
// were specified in the Content-Length header. // were specified in the Content-Length header.
static bool HTTPUpload::ReadResponse(HINTERNET request, wstring* response); static bool ReadResponse(HINTERNET request, wstring* response);
// Generates a new multipart boundary for a POST request // Generates a new multipart boundary for a POST request
static wstring GenerateMultipartBoundary(); static wstring GenerateMultipartBoundary();
@ -104,7 +104,12 @@ class HTTPUpload {
static wstring UTF8ToWide(const string &utf8); static wstring UTF8ToWide(const string &utf8);
// Converts a UTF16 string to UTF8. // Converts a UTF16 string to UTF8.
static string WideToUTF8(const wstring &wide); static string WideToUTF8(const wstring &wide) {
return WideToMBCP(wide, CP_UTF8);
}
// Converts a UTF16 string to specified code page.
static string WideToMBCP(const wstring &wide, unsigned int cp);
// Checks that the given list of parameters has only printable // Checks that the given list of parameters has only printable
// ASCII characters in the parameter name, and does not contain // ASCII characters in the parameter name, and does not contain

View file

@ -58,7 +58,7 @@ bool WindowsStringUtils::safe_mbstowcs(const string &mbs, wstring *wcs) {
} }
assert(wcs_length > 0); assert(wcs_length > 0);
#else // _MSC_VER >= 1400 #else // _MSC_VER >= 1400
if ((wcs_length = mbstowcs(NULL, mbs.c_str(), mbs.length())) < 0) { if ((wcs_length = mbstowcs(NULL, mbs.c_str(), mbs.length())) == (size_t)-1) {
return false; return false;
} }
@ -75,7 +75,7 @@ bool WindowsStringUtils::safe_mbstowcs(const string &mbs, wstring *wcs) {
return false; return false;
} }
#else // _MSC_VER >= 1400 #else // _MSC_VER >= 1400
if (mbstowcs(&wcs_v[0], mbs.c_str(), mbs.length()) < 0) { if (mbstowcs(&wcs_v[0], mbs.c_str(), mbs.length()) == (size_t)-1) {
return false; return false;
} }
@ -101,7 +101,7 @@ bool WindowsStringUtils::safe_wcstombs(const wstring &wcs, string *mbs) {
} }
assert(mbs_length > 0); assert(mbs_length > 0);
#else // _MSC_VER >= 1400 #else // _MSC_VER >= 1400
if ((mbs_length = wcstombs(NULL, wcs.c_str(), wcs.length())) < 0) { if ((mbs_length = wcstombs(NULL, wcs.c_str(), wcs.length())) == (size_t)-1) {
return false; return false;
} }
@ -118,7 +118,7 @@ bool WindowsStringUtils::safe_wcstombs(const wstring &wcs, string *mbs) {
return false; return false;
} }
#else // _MSC_VER >= 1400 #else // _MSC_VER >= 1400
if (wcstombs(&mbs_v[0], wcs.c_str(), wcs.length()) < 0) { if (wcstombs(&mbs_v[0], wcs.c_str(), wcs.length()) == (size_t)-1) {
return false; return false;
} }

View file

@ -58,7 +58,7 @@
*/ */
#include BREAKPAD_CUSTOM_STDINT_H #include BREAKPAD_CUSTOM_STDINT_H
#else #else
#include <WTypes.h> #include <wtypes.h>
typedef unsigned __int8 uint8_t; typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t; typedef unsigned __int16 uint16_t;

View file

@ -34,8 +34,8 @@
// //
// Author: Mark Mentovai // Author: Mark Mentovai
#include <Windows.h> #include <windows.h>
#include <DbgHelp.h> #include <dbghelp.h>
#include <cassert> #include <cassert>
#include <cstdio> #include <cstdio>

View file

@ -65,7 +65,7 @@
#ifndef TOOLS_WINDOWS_MS_SYMBOL_SERVER_CONVERTER_H_ #ifndef TOOLS_WINDOWS_MS_SYMBOL_SERVER_CONVERTER_H_
#define TOOLS_WINDOWS_MS_SYMBOL_SERVER_CONVERTER_H_ #define TOOLS_WINDOWS_MS_SYMBOL_SERVER_CONVERTER_H_
#include <Windows.h> #include <windows.h>
#include <string> #include <string>
#include <vector> #include <vector>

View file

@ -42,9 +42,9 @@
// cpu: the CPU that the module was built for, typically "x86". // cpu: the CPU that the module was built for, typically "x86".
// symbol_file: the contents of the breakpad-format symbol file // symbol_file: the contents of the breakpad-format symbol file
#include <Windows.h> #include <windows.h>
#include <DbgHelp.h> #include <dbghelp.h>
#include <WinInet.h> #include <wininet.h>
#include <cstdio> #include <cstdio>
#include <map> #include <map>