Add #include <config.h> to the beginning of all cc files

Added
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
to the beginning of all source files that didn't have it.

This ensures that configuration options are respected in all source
files. In particular, it ensures that the defines needed to fix Large
File System issues are set before including system headers.

More generally, it ensures consistency between the source files, and
avoids the possibility of ODR violations between source files that were
including config.h and source files that were not.

Process:
Ran
find . \( -name third_party -prune \) -o \( -name '.git*' -prune \) -o \( \( -name '*.cc' -o -name '*.c' \) -exec sed -i '0,/^#include/ s/^#include/#ifdef HAVE_CONFIG_H\n#include <config.h>  \/\/ Must come first\n#endif\n\n#include/' {} + \)
and then manually fixed up src/common/linux/guid_creator.cc,
src/tools/solaris/dump_syms/testdata/dump_syms_regtest.cc,
src/tools/windows/dump_syms/testdata/dump_syms_regtest.cc,
src/common/stabs_reader.h, and src/common/linux/breakpad_getcontext.h.

BUG=google-breakpad:877
Fixed: google-breakpad:877
TEST=./configure && make && make check
TEST=Did the find/sed in ChromeOS's copy, ensured emerge-hana google-breakpad
worked and had fewer LFS violations.
TEST=Did the find/sed in Chrome's copy, ensured compiling hana, windows, linux, and
eve still worked (since Chrome doesn't used config.h)

Change-Id: I16cededbba0ea0c28e919b13243e35300999e799
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4289676
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Ian Barkley-Yeung
2023-02-24 11:14:53 -08:00
parent abb105db21
commit f5123d7196
264 changed files with 1046 additions and 9 deletions

View File

@@ -28,6 +28,10 @@
// core2md.cc: A utility to convert an ELF core file to a minidump file.
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <stdio.h>
#include "client/linux/minidump_writer/minidump_writer.h"

View File

@@ -28,6 +28,10 @@
// core_handler.cc: A tool to handle coredumps on Linux
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>

View File

@@ -26,6 +26,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <paths.h>
#include <stdio.h>
#include <unistd.h>

View File

@@ -30,6 +30,10 @@
// Large parts lifted from the userspace core dumper:
// http://code.google.com/p/google-coredumper/
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <elf.h>
#include <errno.h>
#include <limits.h>

View File

@@ -29,6 +29,10 @@
// minidump_memory_range_unittest.cc:
// Unit tests for google_breakpad::MinidumpMemoryRange.
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include "breakpad_googletest_includes.h"
#include "tools/linux/md2core/minidump_memory_range.h"

View File

@@ -28,6 +28,10 @@
// pid2md.cc: An utility to generate a minidump from a running process
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

View File

@@ -33,6 +33,10 @@
// ver: the product version
// symbol_file: the breakpad format symbol file
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

View File

@@ -38,6 +38,10 @@
// cpu: the CPU that the module was built for
// symbol_file: the contents of the breakpad-format symbol file
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@@ -31,6 +31,10 @@
// dump_syms_tool.cc: Command line tool that uses the DumpSymbols class.
// TODO(waylonis): accept stdin
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <mach-o/arch.h>
#include <unistd.h>

View File

@@ -31,6 +31,10 @@
// macho_dump.cc: Dump the contents of a Mach-O file. This is mostly
// a test program for the Mach_O::FatReader and Mach_O::Reader classes.
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <errno.h>
#include <fcntl.h>
#include <mach-o/arch.h>

View File

@@ -28,6 +28,10 @@
// Author: Alfred Peng
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <string>
#include <cstdio>

View File

@@ -28,6 +28,10 @@
// ./dump_syms dump_syms_regtest.pdb > dump_syms_regtest.sym
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
namespace google_breakpad {
class C {

View File

@@ -33,6 +33,10 @@
//
// Author: Mark Mentovai
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <windows.h>
#include <dbghelp.h>
#include <pathcch.h>

View File

@@ -31,6 +31,10 @@
#pragma comment(lib, "diaguids.lib")
#pragma comment(lib, "imagehlp.lib")
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <cassert>
#include <cstdio>
#include <ctime>

View File

@@ -26,6 +26,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include "tools/windows/converter_exe/escaping.h"
#include <assert.h>

View File

@@ -26,6 +26,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <assert.h>
#include <stdio.h>
#include <Windows.h>

View File

@@ -26,6 +26,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <assert.h>
#include "tools/windows/converter_exe/tokenizer.h"

View File

@@ -26,6 +26,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include "tools/windows/converter_exe/winhttp_client.h"
#include <assert.h>

View File

@@ -26,6 +26,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include "tools/windows/converter_exe/wininet_client.h"
#include <assert.h>

View File

@@ -29,6 +29,10 @@
// Windows utility to dump the line number data from a pdb file to
// a text-based format that we can use from the minidump processor.
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <stdio.h>
#include <wchar.h>

View File

@@ -26,6 +26,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <Windows.h>
#include <shellapi.h>

View File

@@ -35,6 +35,11 @@
// cl /Zi dump_syms_regtest64.cc /link /PROFILE
// dump_syms dump_syms_regtest64.pdb > dump_syms_regtest64.sym
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
namespace google_breakpad {
class C {

View File

@@ -42,6 +42,10 @@
// cpu: the CPU that the module was built for, typically "x86".
// symbol_file: the contents of the breakpad-format symbol file
#ifdef HAVE_CONFIG_H
#include <config.h> // Must come first
#endif
#include <windows.h>
#include <dbghelp.h>
#include <wininet.h>