Skip to content

Commit

Permalink
Fix #includes
Browse files Browse the repository at this point in the history
 1. #include <abc.h> in preference to <cabc>
 2. In affected files, sort #includes according to modern practice
 3. Where #include order changes resulted in compile errors in other
    code, adhere to the principle of “include what you use”

Step 1 was achieved by the following snippet, plus manual inspection and
modification to move headers to the proper sections.

```
for f in $(git grep -l '^#(include|import) <c.*[^.].>'); do
  sed -E -i '' \
      -e 's/^#(include|import) <c(.*[^.].)>/#include <\2.h>/' \
      "$f"
done
```

Step 2 is achieved by the manual inspection and modification, followed
by `git cl format`.

Step 3 is manual, based on the results of a test build.

Change-Id: I7e43a7a534fab54b6c1d47e442a3573f28996151
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/6023410
Reviewed-by: Joshua Peraza <[email protected]>
  • Loading branch information
markmentovai committed Nov 14, 2024
1 parent c6ec710 commit 1db382f
Show file tree
Hide file tree
Showing 37 changed files with 143 additions and 123 deletions.
2 changes: 1 addition & 1 deletion src/client/linux/handler/minidump_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
#define CLIENT_LINUX_HANDLER_MINIDUMP_DESCRIPTOR_H_

#include <assert.h>
#include <stdint.h>
#include <sys/types.h>

#include <cstdint>
#include <string>

#include "client/linux/handler/microdump_extra_info.h"
Expand Down
4 changes: 2 additions & 2 deletions src/client/linux/minidump_writer/pe_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#ifndef CLIENT_LINUX_MINIDUMP_WRITER_PE_STRUCTS_H_
#define CLIENT_LINUX_MINIDUMP_WRITER_PE_STRUCTS_H_

#include <cstdint>
#include <stdint.h>

namespace google_breakpad {

Expand Down Expand Up @@ -222,4 +222,4 @@ typedef struct _RSDS_DEBUG_FORMAT {

} // namespace google_breakpad

#endif // CLIENT_LINUX_MINIDUMP_WRITER_PE_STRUCTS_H_
#endif // CLIENT_LINUX_MINIDUMP_WRITER_PE_STRUCTS_H_
16 changes: 6 additions & 10 deletions src/client/mac/crash_generation/Inspector.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,23 @@
//
// Utility that can inspect another process and write a crash dump

#include <cstdio>
#include <iostream>
#import "client/mac/crash_generation/Inspector.h"

#import <Foundation/Foundation.h>
#include <servers/bootstrap.h>
#include <stdio.h>
#include <string.h>
#include <string>

#import "client/mac/crash_generation/Inspector.h"
#include <iostream>
#include <string>

#import "GTMDefines.h"
#import "client/mac/Framework/Breakpad.h"
#import "client/mac/handler/minidump_generator.h"

#import "common/mac/MachIPC.h"
#include "common/mac/bootstrap_compat.h"
#include "common/mac/launch_reporter.h"

#import "GTMDefines.h"

#import <Foundation/Foundation.h>

namespace google_breakpad {

//=============================================================================
Expand Down Expand Up @@ -358,4 +355,3 @@
}

} // namespace google_breakpad

20 changes: 9 additions & 11 deletions src/client/mac/handler/minidump_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,19 @@
#include <config.h> // Must come first
#endif

#include <algorithm>
#include <cstdio>
#include "client/mac/handler/minidump_generator.h"

#include <CoreFoundation/CoreFoundation.h>
#include <mach-o/dyld.h>
#include <mach-o/loader.h>
#include <mach/host_info.h>
#include <mach/machine.h>
#include <mach/vm_statistics.h>
#include <mach-o/dyld.h>
#include <mach-o/loader.h>
#include <sys/sysctl.h>
#include <stdio.h>
#include <sys/resource.h>
#include <sys/sysctl.h>

#include <CoreFoundation/CoreFoundation.h>

#include "client/mac/handler/minidump_generator.h"
#include <algorithm>

#if defined(HAS_ARM_SUPPORT) || defined(HAS_ARM64_SUPPORT)
#include <mach/arm/thread_status.h>
Expand Down Expand Up @@ -1071,9 +1070,8 @@ bool MinidumpGenerator::WriteMemoryListStream(
ip_memory_d.start_of_memory_range =
std::max(uintptr_t(addr),
uintptr_t(ip - (kIPMemorySize / 2)));
uintptr_t end_of_range =
std::min(uintptr_t(ip + (kIPMemorySize / 2)),
uintptr_t(addr + size));
uintptr_t end_of_range = std::min(uintptr_t(ip + (kIPMemorySize / 2)),
uintptr_t(addr + size));
uintptr_t range_diff = end_of_range -
static_cast<uintptr_t>(ip_memory_d.start_of_memory_range);
ip_memory_d.memory.data_size = static_cast<uint32_t>(range_diff);
Expand Down
10 changes: 5 additions & 5 deletions src/client/solaris/handler/exception_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
#include <config.h> // Must come first
#endif

#include "client/solaris/handler/exception_handler.h"

#include <assert.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>

#include <cassert>
#include <cstdlib>
#include <ctime>

#include "client/solaris/handler/exception_handler.h"
#include "common/solaris/guid_creator.h"
#include "common/solaris/message_output.h"
#include "google_breakpad/common/minidump_format.h"
Expand Down
12 changes: 6 additions & 6 deletions src/client/solaris/handler/exception_handler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
#include <config.h> // Must come first
#endif

#include "client/solaris/handler/exception_handler.h"

#include <assert.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include "client/solaris/handler/exception_handler.h"
#include "client/solaris/handler/solaris_lwp.h"

using namespace google_breakpad;
Expand Down
24 changes: 12 additions & 12 deletions src/client/solaris/handler/minidump_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
#include <config.h> // Must come first
#endif

#include "client/solaris/handler/minidump_generator.h"

#include <fcntl.h>
#include <stdlib.h>
#include <sys/frame.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>

#include <cstdlib>
#include <ctime>

#include "client/solaris/handler/minidump_generator.h"
#include "client/minidump_file_writer-inl.h"
#include "common/solaris/file_id.h"

Expand Down Expand Up @@ -337,7 +337,7 @@ bool WriteCPUInformation(MDRawSystemInfo* sys_info) {
build = strchr(uts.version, '_');
++build;
sys_info->build_number = atoi(build);

return true;
}

Expand Down Expand Up @@ -596,8 +596,8 @@ bool WriteExceptionStream(MinidumpFileWriter* minidump_writer,

#if TARGET_CPU_SPARC
if (writer_args->sig_ctx != NULL) {
exception.get()->exception_record.exception_address =
writer_args->sig_ctx->uc_mcontext.gregs[REG_PC];
exception.get()->exception_record.exception_address =
writer_args->sig_ctx->uc_mcontext.gregs[REG_PC];
} else {
return true;
}
Expand Down Expand Up @@ -700,14 +700,14 @@ void* Write(void* argument) {
if (writer_args->sighandler_ebp != 0 &&
writer_args->lwp_lister->FindSigContext(writer_args->sighandler_ebp,
&writer_args->sig_ctx)) {
writer_args->crashed_stack_bottom =
writer_args->lwp_lister->GetLwpStackBottom(
writer_args->crashed_stack_bottom =
writer_args->lwp_lister->GetLwpStackBottom(
#if TARGET_CPU_SPARC
writer_args->sig_ctx->uc_mcontext.gregs[REG_O6]
writer_args->sig_ctx->uc_mcontext.gregs[REG_O6]
#elif TARGET_CPU_X86
writer_args->sig_ctx->uc_mcontext.gregs[UESP]
writer_args->sig_ctx->uc_mcontext.gregs[UESP]
#endif
);
);

int crashed_lwpid = FindCrashingLwp(writer_args->crashed_stack_bottom,
writer_args->requester_pid,
Expand Down
13 changes: 7 additions & 6 deletions src/client/solaris/handler/solaris_lwp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,25 @@
#include <config.h> // Must come first
#endif

#include "client/solaris/handler/solaris_lwp.h"

#include <assert.h>
#include <dirent.h>
#include <elf.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/frame.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <functional>

#include "client/solaris/handler/solaris_lwp.h"
#include "common/solaris/message_output.h"

using namespace google_breakpad;
Expand Down Expand Up @@ -320,7 +321,7 @@ int SolarisLwp::ListModules(
return -1;

/*
* Determine number of mappings, this value must be
* Determine number of mappings, this value must be
* larger than the actual module count
*/
size = status.st_size;
Expand All @@ -337,7 +338,7 @@ int SolarisLwp::ListModules(
prmap_t* _maps;
int _num;
int module_count = 0;

/*
* Scan each mapping - note it is assummed that the mappings are
* presented in order. We fill holes between mappings. On intel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
#endif

#include "client/windows/crash_generation/crash_generation_client.h"
#include <cassert>

#include <assert.h>

#include <utility>

#include "client/windows/common/ipc_protocol.h"

namespace google_breakpad {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
#endif

#include "client/windows/crash_generation/crash_generation_server.h"

#include <windows.h>
#include <cassert>

#include <assert.h>

#include <list>

#include "client/windows/common/auto_critical_section.h"
#include "common/scoped_ptr.h"

#include "client/windows/crash_generation/client_info.h"

namespace google_breakpad {
Expand Down
10 changes: 5 additions & 5 deletions src/client/windows/handler/exception_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
#include <config.h> // Must come first
#endif

#include "client/windows/handler/exception_handler.h"

#include <assert.h>
#include <objbase.h>
#include <stdio.h>

#include <algorithm>
#include <cassert>
#include <cstdio>

#include "common/windows/string_utils-inl.h"

#include "client/windows/common/ipc_protocol.h"
#include "client/windows/handler/exception_handler.h"
#include "common/windows/guid_string.h"
#include "common/windows/string_utils-inl.h"

namespace google_breakpad {

Expand Down
11 changes: 5 additions & 6 deletions src/common/solaris/file_id.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@
#include <config.h> // Must come first
#endif

#include "common/solaris/file_id.h"

#include <assert.h>
#include <elf.h>
#include <fcntl.h>
#include <gelf.h>
#include <sys/mman.h>
#include <sys/ksyms.h>
#include <stdio.h>
#include <string.h>
#include <sys/ksyms.h>
#include <sys/mman.h>
#include <unistd.h>

#include <cassert>
#include <cstdio>

#include "common/md5.h"
#include "common/solaris/file_id.h"
#include "common/solaris/message_output.h"
#include "google_breakpad/common/minidump_format.h"

Expand Down
7 changes: 3 additions & 4 deletions src/common/solaris/guid_creator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@
#include <config.h> // Must come first
#endif

#include <cassert>
#include <ctime>
#include "common/solaris/guid_creator.h"

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>

#include "common/solaris/guid_creator.h"

//
// GUIDGenerator
//
Expand Down
8 changes: 6 additions & 2 deletions src/common/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
#ifndef COMMON_STRING_VIEW_H__
#define COMMON_STRING_VIEW_H__

#include <cassert>
#include <cstring>
#include <assert.h>
#include <stddef.h>
#include <string.h>

#include <cstddef>
#include <ostream>

#include "common/using_std_string.h"

namespace google_breakpad {
Expand Down
2 changes: 1 addition & 1 deletion src/common/windows/omap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@

#include "common/windows/omap.h"

#include <assert.h>
#include <atlbase.h>

#include <algorithm>
#include <cassert>
#include <set>

#include "common/windows/dia_util.h"
Expand Down
Loading

0 comments on commit 1db382f

Please sign in to comment.