Skip to content

Commit

Permalink
create strict mode and enable it for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHillion committed Jul 7, 2023
1 parent 8cb0823 commit 8dc18fd
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 13 additions & 1 deletion oi/OID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -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 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 "
Expand Down Expand Up @@ -254,6 +262,7 @@ struct Config {
bool genPaddingStats = true;
bool attachToProcess = true;
bool hardDisableDrgn = false;
bool strict = false;
};

} // namespace Oid
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions oi/OIDebugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions oi/TreeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
1 change: 1 addition & 0 deletions oi/TreeBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class TreeBuilder {
bool logAllStructs;
bool dumpDataSegment;
std::optional<std::string> jsonPath;
bool strict;
};

TreeBuilder(Config);
Expand Down
1 change: 1 addition & 0 deletions test/integration/runner_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8dc18fd

Please sign in to comment.