From 63a1ba06477a33891ff68a448ea48c0efa9b558e Mon Sep 17 00:00:00 2001 From: Filip Niksic Date: Mon, 24 Jun 2024 16:36:04 -0700 Subject: [PATCH] Pull out the Centipede defs library into a new common package. With more and more cross-dependencies between FuzzTest and Centipede libraries, it's starting to make sense to have a package for libraries shared between both modules. This is the first step in that direction, with the aim to extract remote_file and blob_file so that they can be used in FuzzTest. PiperOrigin-RevId: 646259827 --- CMakeLists.txt | 1 + centipede/BUILD | 84 +++++++++---------- centipede/analyze_corpora.cc | 2 +- centipede/batch_fuzz_example/BUILD | 4 +- .../customized_centipede.cc | 2 +- .../batch_fuzz_example/customized_centipede.h | 2 +- .../customized_centipede_test.cc | 2 +- centipede/blob_file.cc | 2 +- centipede/blob_file.h | 2 +- centipede/blob_file_converter.cc | 2 +- centipede/blob_file_test.cc | 2 +- centipede/byte_array_mutator.cc | 2 +- centipede/byte_array_mutator.h | 2 +- centipede/byte_array_mutator_test.cc | 2 +- centipede/callstack_test.cc | 2 +- centipede/centipede.cc | 2 +- centipede/centipede.h | 2 +- centipede/centipede_callbacks.cc | 2 +- centipede/centipede_callbacks.h | 2 +- centipede/centipede_default_callbacks.cc | 2 +- centipede/centipede_default_callbacks.h | 2 +- centipede/centipede_interface.cc | 2 +- centipede/centipede_test.cc | 2 +- centipede/control_flow.cc | 2 +- centipede/control_flow.h | 2 +- centipede/corpus.cc | 2 +- centipede/corpus.h | 2 +- centipede/corpus_io.cc | 2 +- centipede/corpus_io.h | 2 +- centipede/corpus_io_test.cc | 2 +- centipede/corpus_test.cc | 2 +- centipede/distill.cc | 2 +- centipede/distill_test.cc | 2 +- centipede/environment.cc | 2 +- centipede/execution_metadata.cc | 2 +- centipede/execution_metadata.h | 2 +- centipede/execution_metadata_test.cc | 2 +- centipede/fuzztest_mutator.cc | 2 +- centipede/fuzztest_mutator.h | 2 +- centipede/fuzztest_mutator_test.cc | 2 +- centipede/hash.cc | 2 +- centipede/knobs.h | 2 +- centipede/minimize_crash.cc | 2 +- centipede/minimize_crash.h | 2 +- centipede/minimize_crash_test.cc | 2 +- centipede/mutation_input.h | 2 +- centipede/mutation_input_test.cc | 2 +- centipede/pc_info.cc | 2 +- centipede/remote_file.cc | 2 +- centipede/remote_file.h | 2 +- centipede/runner.cc | 2 +- centipede/runner_dl_info.h | 3 +- centipede/runner_interface.h | 2 +- centipede/runner_request.cc | 2 +- centipede/runner_request.h | 2 +- centipede/seed_corpus_maker_lib.cc | 2 +- centipede/seed_corpus_maker_lib.h | 2 +- centipede/test_coverage_util.cc | 2 +- centipede/test_coverage_util.h | 2 +- centipede/test_util.h | 2 +- centipede/testing/BUILD | 6 +- centipede/testing/external_target.cc | 2 +- centipede/testing/fuzz_target_with_config.cc | 2 +- centipede/testing/seeded_fuzz_target.cc | 2 +- centipede/util.cc | 5 +- centipede/util.h | 2 +- centipede/util_test.cc | 2 +- common/BUILD | 41 +++++++++ common/CMakeLists.txt | 27 ++++++ {centipede => common}/defs.h | 14 ++-- fuzztest/BUILD | 2 +- fuzztest/internal/centipede_adaptor.cc | 2 +- 72 files changed, 182 insertions(+), 129 deletions(-) create mode 100644 common/BUILD create mode 100644 common/CMakeLists.txt rename {centipede => common}/defs.h (82%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 438042be..1e34de3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,7 @@ endif () add_subdirectory(grammar_codegen) add_subdirectory(tools) +add_subdirectory(common) add_subdirectory(fuzztest) if (FUZZTEST_BUILD_TESTING) diff --git a/centipede/BUILD b/centipede/BUILD index 2000e027..81fb5506 100644 --- a/centipede/BUILD +++ b/centipede/BUILD @@ -90,7 +90,6 @@ cc_binary( deps = [ ":blob_file", ":config_init", - ":defs", ":logging", ":remote_file", ":rusage_profiler", @@ -101,6 +100,7 @@ cc_binary( "@com_google_absl//absl/status", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/time", + "@com_google_fuzztest//common:defs", ], ) @@ -182,9 +182,9 @@ cc_library( hdrs = ["pc_info.h"], visibility = PUBLIC_API_VISIBILITY, deps = [ - ":defs", "@com_google_absl//absl/log:check", "@com_google_absl//absl/types:span", + "@com_google_fuzztest//common:defs", ], ) @@ -203,8 +203,8 @@ cc_library( hdrs = ["knobs.h"], # Avoid non-trivial dependencies here, as this library will be linked to target binaries. deps = [ - ":defs", "@com_google_absl//absl/types:span", + "@com_google_fuzztest//common:defs", ], ) @@ -227,14 +227,6 @@ cc_library( ], ) -# simple definitions only, no code, no deps other than span. -cc_library( - name = "defs", - hdrs = ["defs.h"], - visibility = PUBLIC_API_VISIBILITY, - deps = ["@com_google_absl//absl/types:span"], -) - # Various utilities. cc_library( name = "util", @@ -246,7 +238,6 @@ cc_library( linkopts = ["-Wl,-Bstatic -lcrypto -Wl,-Bdynamic -ldl"], visibility = EXTENDED_API_VISIBILITY, deps = [ - ":defs", ":feature", ":logging", ":remote_file", @@ -257,6 +248,7 @@ cc_library( "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/types:span", + "@com_google_fuzztest//common:defs", ], ) @@ -410,7 +402,6 @@ cc_library( hdrs = ["minimize_crash.h"], deps = [ ":centipede_callbacks", - ":defs", ":early_exit", ":environment", ":logging", @@ -422,6 +413,7 @@ cc_library( "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/synchronization", + "@com_google_fuzztest//common:defs", ], ) @@ -436,7 +428,6 @@ cc_library( ":corpus", ":corpus_io", ":coverage", - ":defs", ":feature", ":logging", ":pc_info", @@ -446,6 +437,7 @@ cc_library( "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", + "@com_google_fuzztest//common:defs", ], ) @@ -459,7 +451,6 @@ cc_library( }), visibility = PUBLIC_API_VISIBILITY, deps = [ - ":defs", ":logging", ":remote_file", ":util", @@ -470,6 +461,7 @@ cc_library( "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/strings:string_view", "@com_google_absl//absl/time", + "@com_google_fuzztest//common:defs", ] + select({ ":disable_riegeli": [], "//conditions:default": [ @@ -500,7 +492,7 @@ cc_library( deps = [ # This target must have a minimal set of dependencies since it is # used in centipede_runner. - ":defs", + "@com_google_fuzztest//common:defs", ":shared_memory_blob_sequence", ], ) @@ -529,7 +521,7 @@ cc_library( ":shared_memory_blob_sequence", ":execution_metadata", ":mutation_input", - ":defs", + "@com_google_fuzztest//common:defs", ], ) @@ -540,7 +532,7 @@ cc_library( deps = [ # This target must have a minimal set of dependencies since it is # used in centipede_runner. - ":defs", + "@com_google_fuzztest//common:defs", ":execution_metadata", ], ) @@ -552,11 +544,11 @@ cc_library( visibility = PUBLIC_API_VISIBILITY, # Avoid non-trivial dependencies here, as this library will be linked to target binaries. deps = [ - ":defs", ":execution_metadata", ":knobs", ":mutation_input", "@com_google_absl//absl/base:nullability", + "@com_google_fuzztest//common:defs", ], ) @@ -598,7 +590,6 @@ cc_library( visibility = PUBLIC_API_VISIBILITY, deps = [ ":command", - ":defs", ":logging", ":pc_info", ":util", @@ -607,6 +598,7 @@ cc_library( "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", + "@com_google_fuzztest//common:defs", ], ) @@ -640,12 +632,12 @@ cc_library( "//conditions:default": [], }), deps = [ - ":defs", ":logging", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/base:nullability", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", + "@com_google_fuzztest//common:defs", ] + select({ ":disable_riegeli": [], "//conditions:default": [ @@ -680,7 +672,6 @@ cc_library( ":binary_info", ":control_flow", ":coverage", - ":defs", ":execution_metadata", ":feature", ":feature_set", @@ -690,6 +681,7 @@ cc_library( "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", + "@com_google_fuzztest//common:defs", ], ) @@ -749,7 +741,6 @@ cc_library( ":byte_array_mutator", ":command", ":control_flow", - ":defs", ":environment", ":fuzztest_mutator", ":logging", @@ -764,6 +755,7 @@ cc_library( "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", "@com_google_absl//absl/time", + "@com_google_fuzztest//common:defs", ], ) @@ -773,7 +765,6 @@ cc_library( hdrs = ["corpus_io.h"], deps = [ ":blob_file", - ":defs", ":feature", ":logging", ":remote_file", @@ -784,6 +775,7 @@ cc_library( "@com_google_absl//absl/status", "@com_google_absl//absl/time", "@com_google_absl//absl/types:span", + "@com_google_fuzztest//common:defs", ], ) @@ -834,7 +826,6 @@ cc_library( ":corpus", ":corpus_io", ":coverage", - ":defs", ":early_exit", ":environment", ":feature", @@ -860,6 +851,7 @@ cc_library( "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/time", + "@com_google_fuzztest//common:defs", ], ) @@ -881,7 +873,6 @@ cc_library( ":command", ":corpus_io", ":coverage", - ":defs", ":distill", ":early_exit", ":environment", @@ -901,6 +892,7 @@ cc_library( "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/time", "@com_google_absl//absl/types:span", + "@com_google_fuzztest//common:defs", "@com_google_fuzztest//fuzztest:configuration", ], ) @@ -919,7 +911,6 @@ cc_library( }), visibility = PUBLIC_API_VISIBILITY, deps = [ - ":defs", ":feature", ":knobs", ":logging", @@ -929,6 +920,7 @@ cc_library( "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", "@com_google_absl//absl/time", + "@com_google_fuzztest//common:defs", ], ) @@ -939,7 +931,6 @@ cc_library( deps = [ ":blob_file", ":corpus_io", - ":defs", ":environment", ":feature", ":feature_set", @@ -959,6 +950,7 @@ cc_library( "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/time", + "@com_google_fuzztest//common:defs", ], ) @@ -969,13 +961,13 @@ cc_library( visibility = EXTENDED_API_VISIBILITY, deps = [ ":centipede_callbacks", - ":defs", ":environment", ":logging", ":mutation_input", ":runner_result", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", + "@com_google_fuzztest//common:defs", ], ) @@ -985,12 +977,12 @@ cc_library( hdrs = ["fuzztest_mutator.h"], deps = [ ":byte_array_mutator", - ":defs", ":execution_metadata", ":knobs", ":mutation_input", "@com_google_absl//absl/random", "@com_google_absl//absl/types:span", + "@com_google_fuzztest//common:defs", "@com_google_fuzztest//fuzztest:coverage", "@com_google_fuzztest//fuzztest:domain_core", ], @@ -1045,7 +1037,6 @@ RUNNER_SOURCES_NO_MAIN = [ "callstack.h", "concurrent_bitset.h", "concurrent_byteset.h", - "defs.h", "execution_metadata.cc", "execution_metadata.h", "runner_request.cc", @@ -1078,6 +1069,7 @@ RUNNER_SOURCES_NO_MAIN = [ "runner_sancov.cc", "shared_memory_blob_sequence.cc", "shared_memory_blob_sequence.h", + "@com_google_fuzztest//common:defs.h", ] RUNNER_SOURCES_WITH_MAIN = RUNNER_SOURCES_NO_MAIN + ["runner_main.cc"] @@ -1150,7 +1142,6 @@ cc_library( deps = [ ":blob_file", ":corpus_io", - ":defs", ":feature", ":logging", ":remote_file", @@ -1165,6 +1156,7 @@ cc_library( "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/time", + "@com_google_fuzztest//common:defs", "@com_google_protobuf//:protobuf", ], ) @@ -1188,12 +1180,12 @@ cc_library( hdrs = ["test_util.h"], deps = [ ":blob_file", - ":defs", ":logging", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest", ], ) @@ -1221,13 +1213,13 @@ cc_library( deps = [ ":centipede_callbacks", ":corpus", - ":defs", ":environment", ":feature", ":mutation_input", ":runner_result", ":util", "@com_google_absl//absl/log:check", + "@com_google_fuzztest//common:defs", ], ) @@ -1323,11 +1315,11 @@ cc_test( srcs = ["util_test.cc"], copts = ["-fno-signed-char"], deps = [ - ":defs", ":feature", ":util", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/log", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) @@ -1380,7 +1372,6 @@ cc_test( deps = [ ":blob_file", ":corpus_io", - ":defs", ":distill", ":environment", ":feature", @@ -1389,6 +1380,7 @@ cc_test( ":workdir", "@com_google_absl//absl/flags:reflection", "@com_google_absl//absl/log:check", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) @@ -1433,7 +1425,6 @@ cc_test( srcs = ["minimize_crash_test.cc"], deps = [ ":centipede_callbacks", - ":defs", ":environment", ":minimize_crash", ":runner_result", @@ -1441,6 +1432,7 @@ cc_test( ":util", ":workdir", "@com_google_absl//absl/base:nullability", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) @@ -1472,9 +1464,9 @@ cc_test( srcs = ["blob_file_test.cc"], deps = [ ":blob_file", - ":defs", ":test_util", "@com_google_absl//absl/status", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) @@ -1492,9 +1484,9 @@ cc_test( name = "execution_metadata_test", srcs = ["execution_metadata_test.cc"], deps = [ - ":defs", ":execution_metadata", ":shared_memory_blob_sequence", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) @@ -1516,8 +1508,8 @@ cc_test( name = "mutation_input_test", srcs = ["mutation_input_test.cc"], deps = [ - ":defs", ":mutation_input", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) @@ -1527,11 +1519,11 @@ cc_test( srcs = ["byte_array_mutator_test.cc"], deps = [ ":byte_array_mutator", - ":defs", ":execution_metadata", ":knobs", ":mutation_input", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) @@ -1564,13 +1556,13 @@ cc_test( name = "fuzztest_mutator_test", srcs = ["fuzztest_mutator_test.cc"], deps = [ - ":defs", ":execution_metadata", ":fuzztest_mutator", ":knobs", ":mutation_input", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/strings", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) @@ -1602,9 +1594,9 @@ cc_test( srcs = ["callstack_test.cc"], deps = [ ":callstack", - ":defs", "@com_google_absl//absl/base:nullability", "@com_google_absl//absl/container:flat_hash_set", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) @@ -1626,13 +1618,13 @@ cc_test( ":blob_file", ":corpus", ":corpus_io", - ":defs", ":feature", ":test_util", ":util", ":workdir", "@com_google_absl//absl/log:check", "@com_google_absl//absl/types:span", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) @@ -1645,12 +1637,12 @@ cc_test( ":call_graph", ":control_flow", ":corpus", - ":defs", ":feature", ":feature_set", ":pc_info", ":test_util", ":util", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) @@ -1771,7 +1763,6 @@ cc_test( ":centipede_callbacks", ":centipede_default_callbacks", ":centipede_interface", - ":defs", ":environment", ":feature", ":logging", @@ -1785,6 +1776,7 @@ cc_test( "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) diff --git a/centipede/analyze_corpora.cc b/centipede/analyze_corpora.cc index 07a298ae..5ce92cf3 100644 --- a/centipede/analyze_corpora.cc +++ b/centipede/analyze_corpora.cc @@ -31,12 +31,12 @@ #include "./centipede/corpus.h" #include "./centipede/corpus_io.h" #include "./centipede/coverage.h" -#include "./centipede/defs.h" #include "./centipede/feature.h" #include "./centipede/logging.h" #include "./centipede/pc_info.h" #include "./centipede/remote_file.h" #include "./centipede/workdir.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/batch_fuzz_example/BUILD b/centipede/batch_fuzz_example/BUILD index cb2e1f01..f5bbe3f9 100644 --- a/centipede/batch_fuzz_example/BUILD +++ b/centipede/batch_fuzz_example/BUILD @@ -27,13 +27,13 @@ cc_library( "@com_google_absl//absl/strings", "@com_google_fuzztest//centipede:centipede_callbacks", "@com_google_fuzztest//centipede:command", - "@com_google_fuzztest//centipede:defs", "@com_google_fuzztest//centipede:environment", "@com_google_fuzztest//centipede:feature", "@com_google_fuzztest//centipede:logging", "@com_google_fuzztest//centipede:runner_result", "@com_google_fuzztest//centipede:shared_memory_blob_sequence", "@com_google_fuzztest//centipede:util", + "@com_google_fuzztest//common:defs", ], ) @@ -77,10 +77,10 @@ cc_test( deps = [ ":customized_centipede_lib", "@com_google_fuzztest//centipede:centipede_callbacks", - "@com_google_fuzztest//centipede:defs", "@com_google_fuzztest//centipede:environment", "@com_google_fuzztest//centipede:runner_result", "@com_google_fuzztest//centipede:test_util", + "@com_google_fuzztest//common:defs", "@com_google_googletest//:gtest_main", ], ) diff --git a/centipede/batch_fuzz_example/customized_centipede.cc b/centipede/batch_fuzz_example/customized_centipede.cc index 2183b6d0..2b38aeda 100644 --- a/centipede/batch_fuzz_example/customized_centipede.cc +++ b/centipede/batch_fuzz_example/customized_centipede.cc @@ -30,13 +30,13 @@ #include "absl/strings/string_view.h" #include "./centipede/centipede_callbacks.h" #include "./centipede/command.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/feature.h" #include "./centipede/logging.h" #include "./centipede/runner_result.h" #include "./centipede/shared_memory_blob_sequence.h" #include "./centipede/util.h" +#include "./common/defs.h" namespace centipede { namespace { diff --git a/centipede/batch_fuzz_example/customized_centipede.h b/centipede/batch_fuzz_example/customized_centipede.h index 262fe500..c80903b1 100644 --- a/centipede/batch_fuzz_example/customized_centipede.h +++ b/centipede/batch_fuzz_example/customized_centipede.h @@ -21,9 +21,9 @@ #include "absl/strings/string_view.h" #include "./centipede/centipede_callbacks.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/runner_result.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/batch_fuzz_example/customized_centipede_test.cc b/centipede/batch_fuzz_example/customized_centipede_test.cc index 4f12671b..b2c93e92 100644 --- a/centipede/batch_fuzz_example/customized_centipede_test.cc +++ b/centipede/batch_fuzz_example/customized_centipede_test.cc @@ -21,10 +21,10 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "./centipede/centipede_callbacks.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/runner_result.h" #include "./centipede/test_util.h" +#include "./common/defs.h" namespace centipede { namespace { diff --git a/centipede/blob_file.cc b/centipede/blob_file.cc index 94bb7845..1c302be8 100644 --- a/centipede/blob_file.cc +++ b/centipede/blob_file.cc @@ -28,10 +28,10 @@ #include "absl/strings/string_view.h" #include "absl/time/clock.h" #include "absl/time/time.h" -#include "./centipede/defs.h" #include "./centipede/logging.h" #include "./centipede/remote_file.h" #include "./centipede/util.h" +#include "./common/defs.h" #ifndef CENTIPEDE_DISABLE_RIEGELI #include "riegeli/base/object.h" #include "riegeli/base/types.h" diff --git a/centipede/blob_file.h b/centipede/blob_file.h index acf5230d..27421a6a 100644 --- a/centipede/blob_file.h +++ b/centipede/blob_file.h @@ -30,7 +30,7 @@ #include #include "absl/status/status.h" -#include "./centipede/defs.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/blob_file_converter.cc b/centipede/blob_file_converter.cc index 0ec67701..986328a5 100644 --- a/centipede/blob_file_converter.cc +++ b/centipede/blob_file_converter.cc @@ -27,10 +27,10 @@ #include "absl/time/time.h" #include "./centipede/blob_file.h" #include "./centipede/config_init.h" -#include "./centipede/defs.h" #include "./centipede/logging.h" #include "./centipede/remote_file.h" #include "./centipede/rusage_profiler.h" +#include "./common/defs.h" ABSL_FLAG(std::string, in, "", "Input path"); ABSL_FLAG(std::string, out, "", "Output path"); diff --git a/centipede/blob_file_test.cc b/centipede/blob_file_test.cc index 81c3c515..f6ca8603 100644 --- a/centipede/blob_file_test.cc +++ b/centipede/blob_file_test.cc @@ -21,8 +21,8 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/status/status.h" -#include "./centipede/defs.h" #include "./centipede/test_util.h" +#include "./common/defs.h" namespace centipede { namespace { diff --git a/centipede/byte_array_mutator.cc b/centipede/byte_array_mutator.cc index 4e672ea7..0d8577af 100644 --- a/centipede/byte_array_mutator.cc +++ b/centipede/byte_array_mutator.cc @@ -21,10 +21,10 @@ #include #include -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" #include "./centipede/knobs.h" #include "./centipede/mutation_input.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/byte_array_mutator.h b/centipede/byte_array_mutator.h index 31465b80..7589a169 100644 --- a/centipede/byte_array_mutator.h +++ b/centipede/byte_array_mutator.h @@ -23,10 +23,10 @@ #include #include "absl/base/nullability.h" -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" #include "./centipede/knobs.h" #include "./centipede/mutation_input.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/byte_array_mutator_test.cc b/centipede/byte_array_mutator_test.cc index 15b5933c..997fb8bf 100644 --- a/centipede/byte_array_mutator_test.cc +++ b/centipede/byte_array_mutator_test.cc @@ -23,10 +23,10 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "absl/container/flat_hash_set.h" -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" #include "./centipede/knobs.h" #include "./centipede/mutation_input.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/callstack_test.cc b/centipede/callstack_test.cc index ee9b5e6e..d19566a9 100644 --- a/centipede/callstack_test.cc +++ b/centipede/callstack_test.cc @@ -24,7 +24,7 @@ #include "gtest/gtest.h" #include "absl/base/nullability.h" #include "absl/container/flat_hash_set.h" -#include "./centipede/defs.h" +#include "./common/defs.h" namespace centipede { namespace { diff --git a/centipede/centipede.cc b/centipede/centipede.cc index 812cc6ed..203c2a7b 100644 --- a/centipede/centipede.cc +++ b/centipede/centipede.cc @@ -81,7 +81,6 @@ #include "./centipede/control_flow.h" #include "./centipede/corpus_io.h" #include "./centipede/coverage.h" -#include "./centipede/defs.h" #include "./centipede/early_exit.h" #include "./centipede/environment.h" #include "./centipede/feature.h" @@ -95,6 +94,7 @@ #include "./centipede/stats.h" #include "./centipede/util.h" #include "./centipede/workdir.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/centipede.h b/centipede/centipede.h index 5b20447d..79c79747 100644 --- a/centipede/centipede.h +++ b/centipede/centipede.h @@ -30,7 +30,6 @@ #include "./centipede/control_flow.h" #include "./centipede/corpus.h" #include "./centipede/coverage.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/feature.h" #include "./centipede/feature_set.h" @@ -40,6 +39,7 @@ #include "./centipede/stats.h" #include "./centipede/symbol_table.h" #include "./centipede/workdir.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/centipede_callbacks.cc b/centipede/centipede_callbacks.cc index b11dac49..8f8985e2 100644 --- a/centipede/centipede_callbacks.cc +++ b/centipede/centipede_callbacks.cc @@ -35,13 +35,13 @@ #include "./centipede/blob_file.h" #include "./centipede/command.h" #include "./centipede/control_flow.h" -#include "./centipede/defs.h" #include "./centipede/logging.h" #include "./centipede/mutation_input.h" #include "./centipede/runner_request.h" #include "./centipede/runner_result.h" #include "./centipede/util.h" #include "./centipede/workdir.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/centipede_callbacks.h b/centipede/centipede_callbacks.h index f4dd42b0..628dd969 100644 --- a/centipede/centipede_callbacks.h +++ b/centipede/centipede_callbacks.h @@ -26,13 +26,13 @@ #include "./centipede/binary_info.h" #include "./centipede/byte_array_mutator.h" #include "./centipede/command.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/fuzztest_mutator.h" #include "./centipede/mutation_input.h" #include "./centipede/runner_result.h" #include "./centipede/shared_memory_blob_sequence.h" #include "./centipede/util.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/centipede_default_callbacks.cc b/centipede/centipede_default_callbacks.cc index 08f94e59..f294c05d 100644 --- a/centipede/centipede_default_callbacks.cc +++ b/centipede/centipede_default_callbacks.cc @@ -22,11 +22,11 @@ #include "absl/log/check.h" #include "absl/log/log.h" #include "./centipede/centipede_callbacks.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/logging.h" // IWYU pragma: keep #include "./centipede/mutation_input.h" #include "./centipede/runner_result.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/centipede_default_callbacks.h b/centipede/centipede_default_callbacks.h index f0ad1e85..61573565 100644 --- a/centipede/centipede_default_callbacks.h +++ b/centipede/centipede_default_callbacks.h @@ -26,10 +26,10 @@ #include #include "./centipede/centipede_callbacks.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/mutation_input.h" #include "./centipede/runner_result.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/centipede_interface.cc b/centipede/centipede_interface.cc index efac95e7..eaf03c21 100644 --- a/centipede/centipede_interface.cc +++ b/centipede/centipede_interface.cc @@ -52,7 +52,6 @@ #include "./centipede/command.h" #include "./centipede/corpus_io.h" #include "./centipede/coverage.h" -#include "./centipede/defs.h" #include "./centipede/distill.h" #include "./centipede/early_exit.h" #include "./centipede/environment.h" @@ -64,6 +63,7 @@ #include "./centipede/stats.h" #include "./centipede/util.h" #include "./centipede/workdir.h" +#include "./common/defs.h" #include "./fuzztest/internal/configuration.h" namespace centipede { diff --git a/centipede/centipede_test.cc b/centipede/centipede_test.cc index afc2e6c4..0fa0fd13 100644 --- a/centipede/centipede_test.cc +++ b/centipede/centipede_test.cc @@ -36,7 +36,6 @@ #include "./centipede/centipede_callbacks.h" #include "./centipede/centipede_default_callbacks.h" #include "./centipede/centipede_interface.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/feature.h" #include "./centipede/logging.h" @@ -45,6 +44,7 @@ #include "./centipede/test_util.h" #include "./centipede/util.h" #include "./centipede/workdir.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/control_flow.cc b/centipede/control_flow.cc index cf7ea16a..1f346d3d 100644 --- a/centipede/control_flow.cc +++ b/centipede/control_flow.cc @@ -32,10 +32,10 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "./centipede/command.h" -#include "./centipede/defs.h" #include "./centipede/logging.h" #include "./centipede/pc_info.h" #include "./centipede/util.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/control_flow.h b/centipede/control_flow.h index a43cd4f1..956811a9 100644 --- a/centipede/control_flow.h +++ b/centipede/control_flow.h @@ -24,9 +24,9 @@ #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/log/check.h" -#include "./centipede/defs.h" #include "./centipede/logging.h" #include "./centipede/pc_info.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/corpus.cc b/centipede/corpus.cc index 4f23ccae..6fa8907a 100644 --- a/centipede/corpus.cc +++ b/centipede/corpus.cc @@ -30,13 +30,13 @@ #include "absl/strings/substitute.h" #include "./centipede/control_flow.h" #include "./centipede/coverage.h" -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" #include "./centipede/feature.h" #include "./centipede/feature_set.h" #include "./centipede/logging.h" // IWYU pragma: keep #include "./centipede/remote_file.h" #include "./centipede/util.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/corpus.h b/centipede/corpus.h index 7b0a2c9f..3c047616 100644 --- a/centipede/corpus.h +++ b/centipede/corpus.h @@ -25,11 +25,11 @@ #include "absl/log/check.h" #include "./centipede/binary_info.h" -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" #include "./centipede/feature.h" #include "./centipede/feature_set.h" #include "./centipede/util.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/corpus_io.cc b/centipede/corpus_io.cc index 1bcc81e6..75c7994d 100644 --- a/centipede/corpus_io.cc +++ b/centipede/corpus_io.cc @@ -28,12 +28,12 @@ #include "absl/time/time.h" #include "absl/types/span.h" #include "./centipede/blob_file.h" -#include "./centipede/defs.h" #include "./centipede/feature.h" #include "./centipede/logging.h" #include "./centipede/remote_file.h" #include "./centipede/rusage_profiler.h" #include "./centipede/util.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/corpus_io.h b/centipede/corpus_io.h index 73aed938..829bea0d 100644 --- a/centipede/corpus_io.h +++ b/centipede/corpus_io.h @@ -20,8 +20,8 @@ #include #include "absl/types/span.h" -#include "./centipede/defs.h" #include "./centipede/feature.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/corpus_io_test.cc b/centipede/corpus_io_test.cc index 610abd75..bde981fc 100644 --- a/centipede/corpus_io_test.cc +++ b/centipede/corpus_io_test.cc @@ -26,11 +26,11 @@ #include "absl/types/span.h" #include "./centipede/blob_file.h" #include "./centipede/corpus.h" -#include "./centipede/defs.h" #include "./centipede/feature.h" #include "./centipede/test_util.h" #include "./centipede/util.h" #include "./centipede/workdir.h" +#include "./common/defs.h" namespace centipede { namespace { diff --git a/centipede/corpus_test.cc b/centipede/corpus_test.cc index 8b5db44b..a1e8d177 100644 --- a/centipede/corpus_test.cc +++ b/centipede/corpus_test.cc @@ -25,12 +25,12 @@ #include "./centipede/binary_info.h" #include "./centipede/call_graph.h" #include "./centipede/control_flow.h" -#include "./centipede/defs.h" #include "./centipede/feature.h" #include "./centipede/feature_set.h" #include "./centipede/pc_info.h" #include "./centipede/test_util.h" #include "./centipede/util.h" +#include "./common/defs.h" namespace centipede { namespace { diff --git a/centipede/distill.cc b/centipede/distill.cc index aa52765c..29d9a90f 100644 --- a/centipede/distill.cc +++ b/centipede/distill.cc @@ -38,7 +38,6 @@ #include "absl/time/time.h" #include "./centipede/blob_file.h" #include "./centipede/corpus_io.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/feature.h" #include "./centipede/feature_set.h" @@ -51,6 +50,7 @@ #include "./centipede/thread_pool.h" #include "./centipede/util.h" #include "./centipede/workdir.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/distill_test.cc b/centipede/distill_test.cc index 9fd4962e..b54f2ebf 100644 --- a/centipede/distill_test.cc +++ b/centipede/distill_test.cc @@ -28,12 +28,12 @@ #include "absl/log/check.h" #include "./centipede/blob_file.h" #include "./centipede/corpus_io.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/feature.h" #include "./centipede/test_util.h" #include "./centipede/util.h" #include "./centipede/workdir.h" +#include "./common/defs.h" namespace centipede { namespace { diff --git a/centipede/environment.cc b/centipede/environment.cc index 104bd952..fda078b1 100644 --- a/centipede/environment.cc +++ b/centipede/environment.cc @@ -28,11 +28,11 @@ #include "absl/log/log.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" -#include "./centipede/defs.h" #include "./centipede/feature.h" #include "./centipede/knobs.h" #include "./centipede/logging.h" #include "./centipede/remote_file.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/execution_metadata.cc b/centipede/execution_metadata.cc index 82742bf8..11e57c94 100644 --- a/centipede/execution_metadata.cc +++ b/centipede/execution_metadata.cc @@ -17,8 +17,8 @@ #include #include -#include "./centipede/defs.h" #include "./centipede/shared_memory_blob_sequence.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/execution_metadata.h b/centipede/execution_metadata.h index 84f060fa..9b0f73ca 100644 --- a/centipede/execution_metadata.h +++ b/centipede/execution_metadata.h @@ -22,8 +22,8 @@ #include -#include "./centipede/defs.h" #include "./centipede/shared_memory_blob_sequence.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/execution_metadata_test.cc b/centipede/execution_metadata_test.cc index 4e8ebdff..ccfb565c 100644 --- a/centipede/execution_metadata_test.cc +++ b/centipede/execution_metadata_test.cc @@ -19,8 +19,8 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "./centipede/defs.h" #include "./centipede/shared_memory_blob_sequence.h" +#include "./common/defs.h" namespace centipede { namespace { diff --git a/centipede/fuzztest_mutator.cc b/centipede/fuzztest_mutator.cc index 14f891e8..fc85d362 100644 --- a/centipede/fuzztest_mutator.cc +++ b/centipede/fuzztest_mutator.cc @@ -24,10 +24,10 @@ #include "absl/random/random.h" #include "absl/types/span.h" #include "./centipede/byte_array_mutator.h" -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" #include "./centipede/knobs.h" #include "./centipede/mutation_input.h" +#include "./common/defs.h" #include "./fuzztest/domain_core.h" #include "./fuzztest/internal/coverage.h" diff --git a/centipede/fuzztest_mutator.h b/centipede/fuzztest_mutator.h index d4c0bbb4..3afa48bb 100644 --- a/centipede/fuzztest_mutator.h +++ b/centipede/fuzztest_mutator.h @@ -20,10 +20,10 @@ #include #include -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" #include "./centipede/knobs.h" #include "./centipede/mutation_input.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/fuzztest_mutator_test.cc b/centipede/fuzztest_mutator_test.cc index d918fd31..79862c31 100644 --- a/centipede/fuzztest_mutator_test.cc +++ b/centipede/fuzztest_mutator_test.cc @@ -22,10 +22,10 @@ #include "gtest/gtest.h" #include "absl/container/flat_hash_set.h" #include "absl/strings/str_join.h" -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" #include "./centipede/knobs.h" #include "./centipede/mutation_input.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/hash.cc b/centipede/hash.cc index 14a4d195..5b2c4cf0 100644 --- a/centipede/hash.cc +++ b/centipede/hash.cc @@ -19,8 +19,8 @@ #include #include -#include "./centipede/defs.h" #include "./centipede/util.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/knobs.h b/centipede/knobs.h index d6b50af3..569e74bd 100644 --- a/centipede/knobs.h +++ b/centipede/knobs.h @@ -22,7 +22,7 @@ #include #include "absl/types/span.h" -#include "./centipede/defs.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/minimize_crash.cc b/centipede/minimize_crash.cc index 6ad2e29f..83823680 100644 --- a/centipede/minimize_crash.cc +++ b/centipede/minimize_crash.cc @@ -28,7 +28,6 @@ #include "absl/log/log.h" #include "absl/synchronization/mutex.h" #include "./centipede/centipede_callbacks.h" -#include "./centipede/defs.h" #include "./centipede/early_exit.h" #include "./centipede/environment.h" #include "./centipede/logging.h" // IWYU pragma: keep @@ -36,6 +35,7 @@ #include "./centipede/runner_result.h" #include "./centipede/util.h" #include "./centipede/workdir.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/minimize_crash.h b/centipede/minimize_crash.h index 62ee23e6..dc6c74c5 100644 --- a/centipede/minimize_crash.h +++ b/centipede/minimize_crash.h @@ -16,8 +16,8 @@ #define THIRD_PARTY_CENTIPEDE_MINIMIZE_CRASH_H_ #include "./centipede/centipede_callbacks.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/minimize_crash_test.cc b/centipede/minimize_crash_test.cc index 28d704ce..d018c624 100644 --- a/centipede/minimize_crash_test.cc +++ b/centipede/minimize_crash_test.cc @@ -24,12 +24,12 @@ #include "gtest/gtest.h" #include "absl/base/nullability.h" #include "./centipede/centipede_callbacks.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/runner_result.h" #include "./centipede/test_util.h" #include "./centipede/util.h" #include "./centipede/workdir.h" +#include "./common/defs.h" namespace centipede { namespace { diff --git a/centipede/mutation_input.h b/centipede/mutation_input.h index 90df2216..1b0191b1 100644 --- a/centipede/mutation_input.h +++ b/centipede/mutation_input.h @@ -21,8 +21,8 @@ #include -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/mutation_input_test.cc b/centipede/mutation_input_test.cc index 1b1a6bf1..3c2f2861 100644 --- a/centipede/mutation_input_test.cc +++ b/centipede/mutation_input_test.cc @@ -18,7 +18,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "./centipede/defs.h" +#include "./common/defs.h" namespace centipede { namespace { diff --git a/centipede/pc_info.cc b/centipede/pc_info.cc index 7e06e93c..1cada394 100644 --- a/centipede/pc_info.cc +++ b/centipede/pc_info.cc @@ -22,7 +22,7 @@ #include "absl/log/check.h" #include "absl/types/span.h" -#include "./centipede/defs.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/remote_file.cc b/centipede/remote_file.cc index 81987a6a..9c933fd6 100644 --- a/centipede/remote_file.cc +++ b/centipede/remote_file.cc @@ -33,8 +33,8 @@ #include "absl/base/nullability.h" #include "absl/log/check.h" #include "absl/log/log.h" -#include "./centipede/defs.h" #include "./centipede/logging.h" +#include "./common/defs.h" #ifndef CENTIPEDE_DISABLE_RIEGELI #include "riegeli/bytes/fd_reader.h" #include "riegeli/bytes/fd_writer.h" diff --git a/centipede/remote_file.h b/centipede/remote_file.h index 9999c3c0..1cc50ea9 100644 --- a/centipede/remote_file.h +++ b/centipede/remote_file.h @@ -31,7 +31,7 @@ #include #include "absl/base/nullability.h" -#include "./centipede/defs.h" +#include "./common/defs.h" #ifndef CENTIPEDE_DISABLE_RIEGELI #include "riegeli/bytes/reader.h" #include "riegeli/bytes/writer.h" diff --git a/centipede/runner.cc b/centipede/runner.cc index d47f4bf9..187a74ee 100644 --- a/centipede/runner.cc +++ b/centipede/runner.cc @@ -48,7 +48,6 @@ #include "absl/base/nullability.h" #include "./centipede/byte_array_mutator.h" -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" #include "./centipede/feature.h" #include "./centipede/int_utils.h" @@ -60,6 +59,7 @@ #include "./centipede/runner_result.h" #include "./centipede/runner_utils.h" #include "./centipede/shared_memory_blob_sequence.h" +#include "./common/defs.h" __attribute__(( weak)) extern centipede::feature_t __start___centipede_extra_features; diff --git a/centipede/runner_dl_info.h b/centipede/runner_dl_info.h index 7493d044..d780415f 100644 --- a/centipede/runner_dl_info.h +++ b/centipede/runner_dl_info.h @@ -19,7 +19,6 @@ #include #include "absl/base/nullability.h" -#include "./centipede/defs.h" namespace centipede { @@ -28,7 +27,7 @@ namespace centipede { struct DlInfo { uintptr_t start_address; // Address in memory where the object is loaded. uintptr_t size; // Number of bytes in the object. - char path[kPathMax]; // Pathname from which the object was loaded. + char path[4096]; // Pathname from which the object was loaded. void Clear() { memset(this, 0, sizeof(*this)); } diff --git a/centipede/runner_interface.h b/centipede/runner_interface.h index 56b4ded8..4d9a7b2a 100644 --- a/centipede/runner_interface.h +++ b/centipede/runner_interface.h @@ -25,8 +25,8 @@ #include #include "absl/base/nullability.h" -#include "./centipede/defs.h" #include "./centipede/mutation_input.h" +#include "./common/defs.h" // Typedefs for the libFuzzer API, https://llvm.org/docs/LibFuzzer.html using FuzzerTestOneInputCallback = int (*)(const uint8_t *data, size_t size); diff --git a/centipede/runner_request.cc b/centipede/runner_request.cc index 5943b878..49324026 100644 --- a/centipede/runner_request.cc +++ b/centipede/runner_request.cc @@ -17,10 +17,10 @@ #include #include -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" #include "./centipede/mutation_input.h" #include "./centipede/shared_memory_blob_sequence.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/runner_request.h b/centipede/runner_request.h index 3d7d83c8..530619c8 100644 --- a/centipede/runner_request.h +++ b/centipede/runner_request.h @@ -20,10 +20,10 @@ #include #include -#include "./centipede/defs.h" #include "./centipede/execution_metadata.h" #include "./centipede/mutation_input.h" #include "./centipede/shared_memory_blob_sequence.h" +#include "./common/defs.h" namespace centipede::runner_request { diff --git a/centipede/seed_corpus_maker_lib.cc b/centipede/seed_corpus_maker_lib.cc index 7a53073c..cb890c5e 100644 --- a/centipede/seed_corpus_maker_lib.cc +++ b/centipede/seed_corpus_maker_lib.cc @@ -45,7 +45,6 @@ #include "absl/time/time.h" #include "./centipede/blob_file.h" #include "./centipede/corpus_io.h" -#include "./centipede/defs.h" #include "./centipede/feature.h" #include "./centipede/logging.h" #include "./centipede/remote_file.h" @@ -54,6 +53,7 @@ #include "./centipede/thread_pool.h" #include "./centipede/util.h" #include "./centipede/workdir.h" +#include "./common/defs.h" #include "google/protobuf/text_format.h" // TODO(ussuri): Implement a smarter on-the-fly sampling to avoid having to diff --git a/centipede/seed_corpus_maker_lib.h b/centipede/seed_corpus_maker_lib.h index 35731169..d238bc30 100644 --- a/centipede/seed_corpus_maker_lib.h +++ b/centipede/seed_corpus_maker_lib.h @@ -19,9 +19,9 @@ #include #include -#include "./centipede/defs.h" #include "./centipede/feature.h" #include "./centipede/seed_corpus_config.pb.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/test_coverage_util.cc b/centipede/test_coverage_util.cc index 2eb4e4bf..9c1819ce 100644 --- a/centipede/test_coverage_util.cc +++ b/centipede/test_coverage_util.cc @@ -20,11 +20,11 @@ #include "absl/log/check.h" #include "./centipede/corpus.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/feature.h" #include "./centipede/runner_result.h" #include "./centipede/util.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/test_coverage_util.h b/centipede/test_coverage_util.h index 619b1e6d..77a851ee 100644 --- a/centipede/test_coverage_util.h +++ b/centipede/test_coverage_util.h @@ -24,11 +24,11 @@ #include "absl/log/check.h" #include "./centipede/centipede_callbacks.h" #include "./centipede/corpus.h" -#include "./centipede/defs.h" #include "./centipede/environment.h" #include "./centipede/feature.h" #include "./centipede/mutation_input.h" #include "./centipede/runner_result.h" +#include "./common/defs.h" namespace centipede { // Runs all `inputs`, returns FeatureVec for every input. // `env` defines what target is executed and with what flags. diff --git a/centipede/test_util.h b/centipede/test_util.h index 0158fc36..e5a83a8b 100644 --- a/centipede/test_util.h +++ b/centipede/test_util.h @@ -25,7 +25,7 @@ #include "absl/log/check.h" #include "absl/strings/str_format.h" #include "./centipede/blob_file.h" -#include "./centipede/defs.h" +#include "./common/defs.h" #include "./centipede/logging.h" diff --git a/centipede/testing/BUILD b/centipede/testing/BUILD index da3798f6..e1ec4a05 100644 --- a/centipede/testing/BUILD +++ b/centipede/testing/BUILD @@ -54,8 +54,8 @@ cc_binary( deps = [ "@com_google_absl//absl/base:nullability", "@com_google_fuzztest//centipede:centipede_runner_no_main", - "@com_google_fuzztest//centipede:defs", "@com_google_fuzztest//centipede:mutation_input", + "@com_google_fuzztest//common:defs", ], ) @@ -90,8 +90,8 @@ cc_binary( deps = [ "@com_google_absl//absl/base:nullability", "@com_google_fuzztest//centipede:centipede_runner_no_main", - "@com_google_fuzztest//centipede:defs", "@com_google_fuzztest//centipede:mutation_input", + "@com_google_fuzztest//common:defs", ], ) @@ -136,8 +136,8 @@ cc_binary( "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", "@com_google_fuzztest//centipede:centipede_runner_no_main", - "@com_google_fuzztest//centipede:defs", "@com_google_fuzztest//centipede:mutation_input", + "@com_google_fuzztest//common:defs", ], ) diff --git a/centipede/testing/external_target.cc b/centipede/testing/external_target.cc index a40ba9d8..19fb113f 100644 --- a/centipede/testing/external_target.cc +++ b/centipede/testing/external_target.cc @@ -26,9 +26,9 @@ #include "absl/base/nullability.h" #include "absl/log/check.h" #include "absl/strings/numbers.h" -#include "./centipede/defs.h" #include "./centipede/mutation_input.h" #include "./centipede/runner_interface.h" +#include "./common/defs.h" namespace { diff --git a/centipede/testing/fuzz_target_with_config.cc b/centipede/testing/fuzz_target_with_config.cc index 28f72271..d0ac8a09 100644 --- a/centipede/testing/fuzz_target_with_config.cc +++ b/centipede/testing/fuzz_target_with_config.cc @@ -18,9 +18,9 @@ #include #include "absl/base/nullability.h" -#include "./centipede/defs.h" #include "./centipede/mutation_input.h" #include "./centipede/runner_interface.h" +#include "./common/defs.h" using ::centipede::ByteSpan; diff --git a/centipede/testing/seeded_fuzz_target.cc b/centipede/testing/seeded_fuzz_target.cc index f42c5b93..dae9d550 100644 --- a/centipede/testing/seeded_fuzz_target.cc +++ b/centipede/testing/seeded_fuzz_target.cc @@ -18,9 +18,9 @@ #include #include "absl/base/nullability.h" -#include "./centipede/defs.h" #include "./centipede/mutation_input.h" #include "./centipede/runner_interface.h" +#include "./common/defs.h" using centipede::ByteSpan; diff --git a/centipede/util.cc b/centipede/util.cc index 69f4b67b..0389a087 100644 --- a/centipede/util.cc +++ b/centipede/util.cc @@ -17,7 +17,6 @@ #include "./centipede/util.h" -#include // NOLINT(PATH_MAX) #include #include @@ -52,15 +51,13 @@ #include "absl/strings/str_split.h" #include "absl/synchronization/mutex.h" #include "absl/types/span.h" -#include "./centipede/defs.h" #include "./centipede/feature.h" #include "./centipede/logging.h" #include "./centipede/remote_file.h" +#include "./common/defs.h" namespace centipede { -static_assert(kPathMax >= PATH_MAX, "kPathMax is too small."); - size_t GetRandomSeed(size_t seed) { if (seed != 0) return seed; return time(nullptr) + getpid() + diff --git a/centipede/util.h b/centipede/util.h index aae536b7..f1246020 100644 --- a/centipede/util.h +++ b/centipede/util.h @@ -25,8 +25,8 @@ #include "absl/base/nullability.h" #include "absl/log/check.h" #include "absl/types/span.h" -#include "./centipede/defs.h" #include "./centipede/feature.h" +#include "./common/defs.h" namespace centipede { diff --git a/centipede/util_test.cc b/centipede/util_test.cc index 783cea57..e4afe43a 100644 --- a/centipede/util_test.cc +++ b/centipede/util_test.cc @@ -26,8 +26,8 @@ #include "gtest/gtest.h" #include "absl/container/flat_hash_map.h" #include "absl/log/log.h" -#include "./centipede/defs.h" #include "./centipede/feature.h" +#include "./common/defs.h" namespace centipede { diff --git a/common/BUILD b/common/BUILD new file mode 100644 index 00000000..5b52d24a --- /dev/null +++ b/common/BUILD @@ -0,0 +1,41 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The package contains libraries that are common to both FuzzTest and Centipede. + +VISIBILITY = ["//visibility:public"] + +PUBLIC_API_VISIBILITY = VISIBILITY + +package(default_visibility = VISIBILITY) + +licenses(["notice"]) + +### Files + +# Centipede runner needs access to this file, since it has special build +# requirements and needs to compile the file directly with specific flags. +exports_files( + srcs = ["defs.h"], + visibility = ["@com_google_fuzztest//centipede:__pkg__"], +) + +### Libraries + +cc_library( + name = "defs", + hdrs = ["defs.h"], + visibility = PUBLIC_API_VISIBILITY, + deps = ["@com_google_absl//absl/types:span"], +) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt new file mode 100644 index 00000000..f40f53ff --- /dev/null +++ b/common/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=0") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=0") + +### Libraries + +fuzztest_cc_library( + NAME + defs + HDRS + "defs.h" + DEPS + absl::span +) diff --git a/centipede/defs.h b/common/defs.h similarity index 82% rename from centipede/defs.h rename to common/defs.h index 9644455c..d95e82d5 100644 --- a/centipede/defs.h +++ b/common/defs.h @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_CENTIPEDE_DEFS_H_ -#define THIRD_PARTY_CENTIPEDE_DEFS_H_ +#ifndef FUZZTEST_COMMON_DEFS_H_ +#define FUZZTEST_COMMON_DEFS_H_ + // Only simple definitions here. No code, no dependencies. // span.h is an exception as it's header-only and very simple. -#include #include #include #include @@ -38,7 +38,7 @@ using ByteSpan = absl::Span; template ByteSpan AsByteSpan(const Container &blob) { return ByteSpan(reinterpret_cast(blob.data()), - blob.size() * sizeof(blob[0])); + blob.size() * sizeof(typename Container::value_type)); } // Reinterprets a `ByteSpan` as a string_view pointing at the same data. The @@ -52,10 +52,6 @@ inline std::string_view AsStringView(ByteSpan str) { #define FRIEND_TEST(test_case_name, test_name) \ friend class test_case_name##_##test_name##_Test -// We don't want to include or equivalent in any of the .h -// files. So we define kPathMax, and verify that it is >= PATH_MAX in util.cc. -constexpr size_t kPathMax = 4096; - } // namespace centipede -#endif // THIRD_PARTY_CENTIPEDE_DEFS_H_ +#endif // FUZZTEST_COMMON_DEFS_H_ diff --git a/fuzztest/BUILD b/fuzztest/BUILD index c5e8216d..06a3ee6e 100644 --- a/fuzztest/BUILD +++ b/fuzztest/BUILD @@ -218,13 +218,13 @@ cc_library( "@com_google_fuzztest//centipede:centipede_callbacks", "@com_google_fuzztest//centipede:centipede_interface", "@com_google_fuzztest//centipede:centipede_runner_no_main", - "@com_google_fuzztest//centipede:defs", "@com_google_fuzztest//centipede:early_exit", "@com_google_fuzztest//centipede:environment", "@com_google_fuzztest//centipede:mutation_input", "@com_google_fuzztest//centipede:runner_result", "@com_google_fuzztest//centipede:shared_memory_blob_sequence", "@com_google_fuzztest//centipede:workdir", + "@com_google_fuzztest//common:defs", ], ) diff --git a/fuzztest/internal/centipede_adaptor.cc b/fuzztest/internal/centipede_adaptor.cc index 4de2dc96..9e270d59 100644 --- a/fuzztest/internal/centipede_adaptor.cc +++ b/fuzztest/internal/centipede_adaptor.cc @@ -51,7 +51,6 @@ #include "absl/types/span.h" #include "./centipede/centipede_callbacks.h" #include "./centipede/centipede_interface.h" -#include "./centipede/defs.h" #include "./centipede/early_exit.h" #include "./centipede/environment.h" #include "./centipede/mutation_input.h" @@ -59,6 +58,7 @@ #include "./centipede/runner_result.h" #include "./centipede/shared_memory_blob_sequence.h" #include "./centipede/workdir.h" +#include "./common/defs.h" #include "./fuzztest/internal/any.h" #include "./fuzztest/internal/configuration.h" #include "./fuzztest/internal/corpus_database.h"