Commit 5cff0323 authored by Jason Hiser's avatar Jason Hiser 🚜

renamed some class variables with m_

parent 6f109380
Pipeline #2622 passed with stages
in 13 minutes and 10 seconds
......@@ -67,10 +67,10 @@ namespace InitStack
void initStack(Function_t* f);
// data
set<Function_t*> m_funcs_to_init; // the functions whose stacks this object should initialize
int m_init_value; // the value with which to init the stack.
bool m_verbose; // do verbose logging
int m_num_transformed; // stats about how many functions that this object has transformed
set<Function_t*> m_funcs_to_init; // the functions whose stacks this object should initialize
int m_init_value; // the value with which to init the stack.
bool m_verbose; // do verbose logging
int m_num_transformed; // stats about how many functions that this object has transformed
};
}
......
......@@ -61,8 +61,8 @@ static Relocation_t* findRelocation(Instruction_t* insn, const string& type)
StackStamp_t::StackStamp_t(FileIR_t *p_variantIR, StampValue_t sv, bool p_verbose)
:
Transform_t(p_variantIR),
stamp_value(sv),
verbose(p_verbose)
m_stamp_value(sv),
m_verbose(p_verbose)
{
}
......@@ -71,7 +71,7 @@ StackStamp_t::StackStamp_t(FileIR_t *p_variantIR, StampValue_t sv, bool p_verbos
//
StampValue_t StackStamp_t::get_stamp(Function_t* f)
{
return stamp_value;
return m_stamp_value;
}
//
......@@ -222,14 +222,14 @@ Instruction_t* StackStamp_t::stamp(Function_t* f, Instruction_t* i)
(void)insertAssemblyBefore(i, assembly.str());
// logging
if (verbose)
if (m_verbose)
{
cout << "\tAdding: " << assembly.str() << " before : " << hex<<i->getBaseID()<<":"<<i->getDisassembly()
<< "@0x"<<i->getAddress()->getVirtualOffset()<<endl;
}
// update stats
instructions_added++;
m_instructions_added++;
return i;
}
......@@ -384,8 +384,8 @@ void StackStamp_t::stamp(Function_t* f)
if(!can_stamp(f))
{
// No, record stats.
cout<<"Skipping "<<dec<<functions_transformed<<": "<<f->getName()<<endl;
functions_not_transformed++;
cout<<"Skipping "<<dec<<m_functions_transformed<<": "<<f->getName()<<endl;
m_functions_not_transformed++;
// and exit.
return;
......@@ -395,8 +395,8 @@ void StackStamp_t::stamp(Function_t* f)
assert(f->getEntryPoint());
// Yes, we can stamp. Do log/stats.
cout<<"Doing "<<dec<<functions_transformed<<": "<<f->getName()<<endl;
functions_transformed++;
cout<<"Doing "<<dec<<m_functions_transformed<<": "<<f->getName()<<endl;
m_functions_transformed++;
const auto fix_call_fallthrough_string=string("fix_call_fallthrough");
......@@ -416,7 +416,7 @@ void StackStamp_t::stamp(Function_t* f)
// stamp all returns
if(di->isReturn())
{
if(verbose) cout<<"Stamping return"<<endl;
if(m_verbose) cout<<"Stamping return"<<endl;
stamp(f,insn);
}
// check for calls specially.
......@@ -432,7 +432,7 @@ void StackStamp_t::stamp(Function_t* f)
// not handled yet as we have to instrument oddly.
assert(!insn->getFallthrough());
if(verbose) cout<<"Stamping with target!=function"<<endl;
if(m_verbose) cout<<"Stamping with target!=function"<<endl;
stamp(f,insn);
}
else if(di->isUnconditionalBranch() && icfs)
......@@ -440,7 +440,6 @@ void StackStamp_t::stamp(Function_t* f)
// jump with IB targets are likely switches.
assert(!insn->getFallthrough());
// This is similar to the logic in can_stamp. We should isolate into a function/method that
// avoids the code duplication. For now, though....
......@@ -467,7 +466,7 @@ void StackStamp_t::stamp(Function_t* f)
// an indirect jump at a function entry needs a stamp
if(insn==f->getEntryPoint())
{
if(verbose) cout << "Stamping IB at entry of function" << endl;
if(m_verbose) cout << "Stamping IB at entry of function" << endl;
stamp(f,insn);
}
// stamp if we definitely are leaving this function.
......@@ -475,8 +474,8 @@ void StackStamp_t::stamp(Function_t* f)
// this is probably a tail jump that leaves the func, or a plt entry
else if(definitely_leaves || (might_leave && !icfs->isComplete()))
{
if(verbose && definitely_leaves ) cout << "Stamping IB because definitely_leaves " << endl;
else if(verbose) cout << "Stamping IB because might_leave && icfs->isComplete() " << endl;
if(m_verbose && definitely_leaves ) cout << "Stamping IB because definitely_leaves " << endl;
else if(m_verbose) cout << "Stamping IB because might_leave && icfs->isComplete() " << endl;
stamp(f,insn);
}
}
......@@ -538,7 +537,7 @@ bool StackStamp_t::execute()
for(auto func : sorted_funcs)
{
// check to see if we've transformed everything we want already.
if (ss_max_do_transform && functions_transformed > atoi(ss_max_do_transform))
if (ss_max_do_transform && m_functions_transformed > atoi(ss_max_do_transform))
{
continue;
}
......@@ -551,23 +550,23 @@ bool StackStamp_t::execute()
cleanup_eh_pgms();
// calculate and output stats
const auto pct_transformed=((double)functions_transformed/(double)((functions_transformed+functions_not_transformed)))*100.00;
const auto pct_not_transformed=((double)functions_not_transformed/(double)(functions_transformed+functions_not_transformed))*100.00;
const auto pct_transformed=((double)m_functions_transformed/(double)((m_functions_transformed+m_functions_not_transformed)))*100.00;
const auto pct_not_transformed=((double)m_functions_not_transformed/(double)(m_functions_transformed+m_functions_not_transformed))*100.00;
cout << "# ATTRIBUTE ASSURANCE_Stack_Stamping::Instructions_added=" << dec << instructions_added << endl;
cout << "# ATTRIBUTE ASSURANCE_Stack_Stamping::Total_number_of_functions=" << dec << functions_transformed+functions_not_transformed << endl;
cout << "# ATTRIBUTE ASSURANCE_Stack_Stamping::Functions_Transformed=" << dec << functions_transformed << endl;
cout << "# ATTRIBUTE ASSURANCE_Stack_Stamping::Functions_Not_Transformed=" << dec << functions_not_transformed << endl;
cout << "# ATTRIBUTE ASSURANCE_Stack_Stamping::Instructions_added=" << dec << m_instructions_added << endl;
cout << "# ATTRIBUTE ASSURANCE_Stack_Stamping::Total_number_of_functions=" << dec << m_functions_transformed+m_functions_not_transformed << endl;
cout << "# ATTRIBUTE ASSURANCE_Stack_Stamping::Functions_Transformed=" << dec << m_functions_transformed << endl;
cout << "# ATTRIBUTE ASSURANCE_Stack_Stamping::Functions_Not_Transformed=" << dec << m_functions_not_transformed << endl;
cout << "# ATTRIBUTE ASSURANCE_Stack_Stamping::Percent_Functions_Transformed=" << fixed << setprecision(1) << pct_transformed << "%" << endl;
cout << "# ATTRIBUTE ASSURANCE_Stack_Stamping::Percent_Functions_Not_Transformed=" << fixed << setprecision(1) << pct_not_transformed << "%" << endl;
// used in testing harness to verify that the stats are correct.
assert(getenv("SELF_VALIDATE")==nullptr || instructions_added > 10);
assert(getenv("SELF_VALIDATE")==nullptr || pct_transformed > 20); // can be kind of low for small files
assert(getenv("SELF_VALIDATE")==nullptr || functions_transformed > 5 );
assert(getenv("SELF_VALIDATE")==nullptr || m_instructions_added > 10);
assert(getenv("SELF_VALIDATE")==nullptr || pct_transformed > 20); // can be kind of low for small files
assert(getenv("SELF_VALIDATE")==nullptr || m_functions_transformed > 5 );
return 1; // true means success
return m_functions_transformed > 0; // true means success
}
//
......
......@@ -124,16 +124,16 @@ namespace Stamper
};
// data
StampValue_t stamp_value = (StampValue_t)0; // how to stamp, for now this value is shared across all functions in the IR
bool verbose = false; // how verbose to be
StampValue_t m_stamp_value = (StampValue_t)0; // how to stamp, for now this value is shared across all functions in the IR
bool m_verbose = false; // how verbose to be
// a "cache" for EH programs (related to stack unwinding) so we can re-use newly created EH programs
map<EhProgramPlaceHolder_t, EhProgram_t*> all_eh_pgms;
// stats
int instructions_added = 0; // how many instructions were added
int functions_transformed = 0; // how many functions were transformed
int functions_not_transformed = 0; // how many functions were skipped
int m_instructions_added = 0; // how many instructions were added
int m_functions_transformed = 0; // how many functions were transformed
int m_functions_not_transformed = 0; // how many functions were skipped
// friends
friend bool operator<(const EhProgramPlaceHolder_t &a, const EhProgramPlaceHolder_t& b) ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment