diff --git a/.circleci/config.yml b/.circleci/config.yml index bb3883d..72578db 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,14 +20,14 @@ workflows: - build-gcc oid_test_args: "-ftype-graph" tests_regex: "OidIntegration\\..*" - exclude_regex: ".*inheritance_polymorphic.*" + exclude_regex: ".*inheritance_polymorphic.*|.*pointers_incomplete_containing_struct|.*ignored_a|.*arrays_member_int0" - test: name: test-typed-data-segment-gcc requires: - build-gcc oid_test_args: "-ftyped-data-segment" tests_regex: "OidIntegration\\..*" - exclude_regex: ".*inheritance_polymorphic.*|.*cycles_.*" + exclude_regex: ".*inheritance_polymorphic.*|.*pointers.*|.*ignored_a|.*arrays_member_int0|.*cycles_.*" - coverage: name: coverage requires: @@ -57,7 +57,7 @@ workflows: oid_test_args: "-ftype-graph" tests_regex: "OidIntegration\\..*" # Tests disabled due to bad DWARF generated by the old clang compiler in CI - exclude_regex: ".*inheritance_polymorphic.*|.*fbstring.*|.*std_string_*|.*multi_arg_tb_.*|.*ignored_a" + exclude_regex: ".*inheritance_polymorphic.*|.*pointers_incomplete_containing_struct|.*arrays_member_int0|.*fbstring.*|.*std_string_*|.*multi_arg_tb_.*|.*ignored_a" executors: ubuntu-docker: diff --git a/oi/OID.cpp b/oi/OID.cpp index 0ed3f29..50673f0 100644 --- a/oi/OID.cpp +++ b/oi/OID.cpp @@ -143,7 +143,7 @@ constexpr static OIOpts opts{ "Dump the data segment's content, before TreeBuilder processes it\n" "Each argument gets its own dump file: 'dataseg...dump'"}, OIOpt{'a', "log-all-structs", no_argument, nullptr, "Log all structures"}, - OIOpt{'m', "mode", required_argument, "[prod]", + OIOpt{'m', "mode", required_argument, "MODE", "Allows to specify a mode of operation/group of settings"}, OIOpt{'f', "enable-feature", required_argument, "FEATURE", "Enable feature"}, @@ -156,6 +156,14 @@ void usage() { std::cerr << opts << std::endl; featuresHelp(std::cerr); + std::cerr << std::endl << "MODES SUMMARY" << std::endl; + std::cerr << " prod Disable drgn, enable remote caching, and chase raw " + "pointers." + << std::endl; + std::cerr << " strict Enable additional fatal error conditions such as " + "TreeBuilder reading too little data." + << std::endl; + std::cerr << "\n\tFor problem reporting, questions and general comments " "please pop along" "\n\tto the Object Introspection Workplace group at " @@ -254,6 +262,7 @@ struct Config { bool genPaddingStats = true; bool attachToProcess = true; bool hardDisableDrgn = false; + bool strict = false; }; } // namespace Oid @@ -292,6 +301,7 @@ static ExitStatus::ExitStatus runScript( } oid->setCustomCodeFile(oidConfig.customCodeFile); oid->setHardDisableDrgn(oidConfig.hardDisableDrgn); + oid->setStrict(oidConfig.strict); VLOG(1) << "OIDebugger constructor took " << std::dec << time_ns(time_hr::now() - progStart) << " nsecs"; @@ -497,6 +507,8 @@ int main(int argc, char* argv[]) { oidConfig.cacheRemoteDownload = true; oidConfig.cacheBasePath = "/tmp/oid-cache"; features[Feature::ChaseRawPointers] = true; + } else if (strcmp("strict", optarg) == 0) { + oidConfig.strict = true; } else { LOG(ERROR) << "Invalid mode: " << optarg << " specified!"; usage(); diff --git a/oi/OIDebugger.h b/oi/OIDebugger.h index 483012b..b22c666 100644 --- a/oi/OIDebugger.h +++ b/oi/OIDebugger.h @@ -104,6 +104,9 @@ class OIDebugger { void setHardDisableDrgn(bool val) { symbols->setHardDisableDrgn(val); } + void setStrict(bool val) { + treeBuilderConfig.strict = val; + } bool uploadCache() { return std::all_of( diff --git a/oi/TreeBuilder.cpp b/oi/TreeBuilder.cpp index 6655f46..a99f3f8 100644 --- a/oi/TreeBuilder.cpp +++ b/oi/TreeBuilder.cpp @@ -254,6 +254,11 @@ void TreeBuilder::build(const std::vector& data, // Were all object sizes consumed? if (oidDataIndex != oidData->size()) { + if (config.strict) { + LOG(FATAL) << "some object sizes not consumed and OID is in strict mode!" + << "reported: " << oidData->size() << " consumed " + << oidDataIndex; + } LOG(WARNING) << "WARNING: some object sizes not consumed;" << "object tree may be inaccurate. " << "reported: " << oidData->size() << " consumed " diff --git a/oi/TreeBuilder.h b/oi/TreeBuilder.h index ec5063c..05da4d9 100644 --- a/oi/TreeBuilder.h +++ b/oi/TreeBuilder.h @@ -45,6 +45,7 @@ class TreeBuilder { bool logAllStructs; bool dumpDataSegment; std::optional jsonPath; + bool strict; }; TreeBuilder(Config); diff --git a/test/integration/runner_common.cpp b/test/integration/runner_common.cpp index 98c9127..2ad7aa7 100644 --- a/test/integration/runner_common.cpp +++ b/test/integration/runner_common.cpp @@ -230,6 +230,7 @@ OidProc OidIntegration::runOidOnProcess(OidOpts opts, "--dump-json"s, "--config-file"s, thisConfig.string(), "--script-source"s, opts.scriptSource, + "--mode=strict"s, "--pid"s, std::to_string(targetProcess.id()), }; // clang-format on