Avoid O_BINARY redefinition warning on Cygwin

Avoid O_BINARY redefinition warning compiling processor for Cygwin

On Cygwin, WIN32 not defined, but O_BINARY is defined by fcntl.h, so avoid a
redefinition warning.

../src/processor/minidump.cc:55:0: warning: "O_BINARY" redefined [enabled by default]
 #define O_BINARY 0
 ^
In file included from /usr/include/sys/fcntl.h:3:0,
                 from /usr/include/fcntl.h:14,
                 from ../src/processor/minidump.cc:39:
/usr/include/sys/_default_fcntl.h:52:0: note: this is the location of the previous definition
 #define O_BINARY _FBINARY
 ^

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Build minidump_upload, sym_upload for all targets

Rather than duplicating these tools for any target which has libcurl
- Introduce src/tools/common/ and move minidump_upload, sym_upload there from src/tools/linux/
- Move linux/http_upload.cc,.h up to src/common/ from src/common/linux/

Don't link with -ldl and use dlopen to use libcurl.so, but just link with
libcurl.

XXX: Perhaps retaining linking with -dl and just teaching it the name of curl
shared object on Cygwin would be more upstreamable, although the reasons for not
linking with libcurl are obscure...
Remove local copy of curl headers

This reverts commit d9d863e153d12532fc85bd8b44bc47f079ed064c.
This reverts commit 68e380d5a73a0d657693f166fbcb1dd77027766b.
Add support for DWARF in PECOFF as used by Cygwin and MinGW

For cygwin and mingw targets, build a dump_syms tool which can read DWARF
symbols contained in a PE/COFF executable.

I felt bad about making another copy of dump_symbols.cc, so this one has the
beginnings of being parameterized by an image file reader class, so we can apply
it to a pecoff-format image file reading class

Write pecoff format image file reading class which
- knows how to read PE32 and PE32+ image files
- makes PECOFF file id by fetching from a CV record or by hashing
- can read PECOFF exports as a fallback if there is no DWARF information

v2:
Don't include arpa/inet.h on MinGW

v3:
Use AM_CPPFLAGS for NO_STABS_SUPPORT
Fix building minidump processor for MinGW

This is mainly the configure.ac and Makefile.am changes left over from
https://breakpad.appspot.com/548002/ with a bit of updating

- Link minidump_stackwalk, minidump_dump with PTHREAD_LIBS as pthread_cancel is used
- Link minidump_stackwalk with ws2_32 as ntoh functions are used
- Don't try to build upload tools, dump_syms_dwarf for MinGW
- _s function variants should only be used if _MSC_VER, use _r variants with
MinGW (and define _POSIX to ensure they are prototyped)
- Don't try to include arpa/inet.h on Windows
Build PECOFF/DWARF dump_syms for MinGW

- Substitute MapViewOfFile() for mmap()
- Link dump_syms_dwarf with ws2_32 as ntoh functions are used
Fix building client library and upload tools for MinGW

This is the rest of https://breakpad.appspot.com/548002/, brought up to date

v2:
Refine MinGW changes in HTTPUpload::GetFileContents so it closes file after use

v3:
For consistency, write conditionals in terms of _MSC_VER, not __MINGW32__

v4:
Use fd rather than FILE * in HTTPUpload::GetFileContents

It appears that constructing a stdio_filebuf from a FILE * does a fflush(0),
which has been seen to occasionally fail EBADF (on at least W7 x64).

Both of these things seem like they might be bugs

Workaround for the moment by constructing stdio_filebuf from a fd instead.

v5:
Drop HTTPUpload::GetFileContents() changes as upstream now uses WideTOMBCP()
Drop changes to avoid stdext::checked_array_iterator, as upstream
Fix common.gypi to allow gyp to generate Makefiles on Windows

The MSVS_VERSION variable does not exist unless we are using the MSVS generator
Teach gyp generated Makefile to build crash_generation_app correctly

- Use linker flag for Windows subsystem
- Use linker flag for unicode
- Add rule for compiling windows resources, using $RC to name the resource compiler
- Rename crash_generation_app.rc to avoid a clash in corresponding .o names

Also
- Fix linking of unit test when built using gyp generated Makefile by providing
needed library

XXX: We need to arrange for the gyp Makefile generator to set
CXXFLAGS="-DUNICODE -D_UNICODE" somewhere when generating for Windows.  This is
already done in generated MSVS projects.
Default debug_file to the code_file basename

Strip any path from code_file, and use that as debug_file if one isn't recorded
in the codeview record.

The current implementation of 'ld --build-id' doesn't write a pdbfilename in the
codeview record, not least because we don't have such a thing.

The minidump processor requires both debug_file and debug_identifier (the
build-id) to locate the symbol file.

v2:
Correctly make debug-file a basename when code-file has a windows-style path
Fix by Ivan Gubarev
Fix building windows client unit-tests with gcc

- MinGW doesn't have  _CrtSetReportMode

- Trying to call PureVirtual() on a base class object give a linker error

(Presumably gcc can see that base class will be used for virtual function call,
so requires  an implementation (which is prohibited because it's pure virtual)
at link time.)

XXX: crash_generatation_app manages to contain a pure virtual call without
tripping over this, so look how it does that...
Add symsrv_convert

- Add symsrv_convert from  http://hg.mozilla.org/users/tmielczarek_mozilla.com/fetch-win32-symbols/
- Add building symsrv_convert to .gyp file
- Fix compilation with MSVS 2013
- NOMINMAX should not be needed as that comes from target_defaults
Build MinGW client library using gyp-generated Makefile

Make what it's possible to make with gyp for MinGW.

Tools which rely on DIA (dump_syms, ms_symbol_server_converter) cannot be built
for MinGW.

In theory it should be possible to build symupload, because it doesn't depend on
DIA, but it depends on the common_windows_libs, which does have a dependency on
DIA.

v2:
Use configure to find WINDRES
Use a default debug-id of all zeros when no CV record is present

This lets us do something slightly useful with current binaries
which are produced without a CV record, but there is no guarantee
that the actually match.
Increase RA scanning to 60 words

http://code.google.com/p/google-breakpad/issues/detail?id=452
Use __USE_MINGW_ANSI_STDIO for MinGW build

Use __USE_MINGW_ANSI_STDIO for ANSI C99 compatible implementation of printf()
and friends on MinGW
Provide a working strtok_r for MinGW

Emulating it using strtok will not work as re-entrancy is required
Add a README.md with notes on what is left to do
Support for multiple upload files in Breakpad

https://bugzilla.mozilla.org/show_bug.cgi?id=1048091
Fallback to synthesizing a debug-id from version and architecture, if possible

Based on an idea by Ivan Gubarev

Ideally there would be a similar change in PeCoffFileIdentifierFromMappedFile(),
but that is not written yet...