Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

#Centipede make BinaryInfo a struct of references. #436

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions binary_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ namespace centipede {
// Information about the binary being fuzzed. Created once at program startup
// and doesn't change (other than for lazily initialized fields)
struct BinaryInfo {
PCTable pc_table;
SymbolTable symbols;
CFTable cf_table;
ControlFlowGraph control_flow_graph;
CallGraph call_graph;
PCTable &pc_table;
SymbolTable &symbols;
CFTable &cf_table;
ControlFlowGraph &control_flow_graph;
CallGraph &call_graph;
};

} // namespace centipede
Expand Down
9 changes: 8 additions & 1 deletion centipede_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,14 @@ int CentipedeMain(const Environment &env,
RemoteMkdir(env.MakeCoverageDirPath());

auto one_time_callbacks = callbacks_factory.create(env);
BinaryInfo binary_info;
PCTable pct;
CFTable cft;
SymbolTable st;
ControlFlowGraph cfg;
CallGraph cg;
BinaryInfo binary_info = {pct, st, cft, cfg, cg};
// TODO(navidem): Better to load binary_info contents and use those for
// initialization.
one_time_callbacks->PopulateBinaryInfo(binary_info);
callbacks_factory.destroy(one_time_callbacks);

Expand Down
28 changes: 21 additions & 7 deletions corpus_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "./coverage.h"
#include "./defs.h"
#include "./feature.h"
#include "./symbol_table.h"
#include "./util.h"

namespace centipede {
Expand Down Expand Up @@ -154,7 +155,10 @@ TEST(FeatureSet, CountUnseenAndPruneFrequentFeatures_IncrementFrequencies) {
TEST(Corpus, GetCmpArgs) {
PCTable pc_table(100);
CFTable cf_table(100);
CoverageFrontier coverage_frontier({pc_table, {}, cf_table, {}, {}});
SymbolTable sym;
ControlFlowGraph cfg;
CallGraph cg;
CoverageFrontier coverage_frontier({pc_table, sym, cf_table, cfg, cg});
FeatureSet fs(3);
Corpus corpus;
ByteArray cmp_args{2, 0, 1, 2, 3};
Expand All @@ -168,7 +172,10 @@ TEST(Corpus, GetCmpArgs) {
TEST(Corpus, PrintStats) {
PCTable pc_table(100);
CFTable cf_table(100);
CoverageFrontier coverage_frontier({pc_table, {}, cf_table, {}, {}});
SymbolTable sym;
ControlFlowGraph cfg;
CallGraph cg;
CoverageFrontier coverage_frontier({pc_table, sym, cf_table, cfg, cg});
FeatureSet fs(3);
Corpus corpus;
FeatureVec features1 = {10, 20, 30};
Expand All @@ -189,7 +196,10 @@ TEST(Corpus, Prune) {
// Prune will remove an input if all of its features appear at least 3 times.
PCTable pc_table(100);
CFTable cf_table(100);
CoverageFrontier coverage_frontier({pc_table, {}, cf_table, {}, {}});
SymbolTable sym;
ControlFlowGraph cfg;
CallGraph cg;
CoverageFrontier coverage_frontier({pc_table, sym, cf_table, cfg, cg});
FeatureSet fs(3);
Corpus corpus;
Rng rng(0);
Expand Down Expand Up @@ -247,7 +257,10 @@ TEST(Corpus, Prune) {
TEST(Corpus, PruneRegressionTest1) {
PCTable pc_table(100);
CFTable cf_table(100);
CoverageFrontier coverage_frontier({pc_table, {}, cf_table, {}, {}});
SymbolTable sym;
ControlFlowGraph cfg;
CallGraph cg;
CoverageFrontier coverage_frontier({pc_table, sym, cf_table, cfg, cg});
FeatureSet fs(2);
Corpus corpus;
Rng rng(0);
Expand Down Expand Up @@ -413,7 +426,8 @@ TEST(CoverageFrontier, Compute) {

ControlFlowGraph cfg(cf_table, pc_table);
CallGraph call_graph(cf_table, pc_table);
BinaryInfo bin_info = {pc_table, {}, cf_table, cfg, call_graph};
SymbolTable sym;
BinaryInfo bin_info = {pc_table, sym, cf_table, cfg, call_graph};
CoverageFrontier frontier(bin_info);

FeatureVec pcs(pc_table.size());
Expand Down Expand Up @@ -492,8 +506,8 @@ TEST(CoverageFrontierDeath, InvalidIndexToFrontier) {

ControlFlowGraph cfg(cf_table, pc_table);
CallGraph call_graph(cf_table, pc_table);

BinaryInfo bin_info = {pc_table, {}, cf_table, cfg, call_graph};
SymbolTable sym;
BinaryInfo bin_info = {pc_table, sym, cf_table, cfg, call_graph};
CoverageFrontier frontier(bin_info);

Corpus corpus;
Expand Down