create strict mode and enable it for tests

This commit is contained in:
Jake Hillion 2023-07-07 03:55:40 -07:00 committed by Jake Hillion
parent 56b5873e77
commit 17633983b5
6 changed files with 26 additions and 4 deletions

View File

@ -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:

View File

@ -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.<oid-pid>.<arg>.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();

View File

@ -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(

View File

@ -254,6 +254,11 @@ void TreeBuilder::build(const std::vector<uint64_t>& 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 "

View File

@ -45,6 +45,7 @@ class TreeBuilder {
bool logAllStructs;
bool dumpDataSegment;
std::optional<std::string> jsonPath;
bool strict;
};
TreeBuilder(Config);

View File

@ -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