Skip to content

Commit

Permalink
Add the option --output-trace-rep=
Browse files Browse the repository at this point in the history
  • Loading branch information
lathuili committed Jun 7, 2021
1 parent 3a76198 commit da3f439
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 25 deletions.
8 changes: 8 additions & 0 deletions docs/valgrind-manpage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@
xmlns:xi="http://www.w3.org/2001/XInclude" />
</refsect2>

<refsect2>
<title>Coverage generation</title>
<xi:include href="../../verrou/docs/vr-manual.xml"
xpointer="vr.opts.coverage.list"
xmlns:xi="http://www.w3.org/2001/XInclude" />
</refsect2>

<refsect2>
<title>Detection options</title>
<xi:include href="../../verrou/docs/vr-manual.xml"
xpointer="vr.opts.detection.list"
xmlns:xi="http://www.w3.org/2001/XInclude" />
</refsect2>


<refsect2>
<title>Performance optimization</title>
<xi:include href="../../verrou/docs/vr-manual.xml"
Expand Down
8 changes: 8 additions & 0 deletions docs/vr-manual.xml
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,15 @@ det2
Activate the <link linkend="vr-manual.localization.CovBB" >Basic Blocks Coverage</link> for the symbols specified in <computeroutput> FILE</computeroutput>.
</para></listitem>
</varlistentry>

<varlistentry id="vr.opt.output-trace-rep" xreflabel="--output-trace-rep">
<term><option><![CDATA[--output-trace-rep=REP]]></option></term>
<listitem><para>
Specify the <computeroutput>REP</computeroutput> directory for the trace output files.
</para></listitem>
</varlistentry>
</variablelist>

</section>

<section>
Expand Down
5 changes: 5 additions & 0 deletions vr_clo.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void vr_clo_defaults (void) {

vr.genTrace=False;
vr.includeTrace = NULL;
vr.outputTraceRep = NULL;

int opIt;
for(opIt=0 ; opIt<VR_OP ; opIt++){
Expand Down Expand Up @@ -218,6 +219,10 @@ Bool vr_process_clo (const HChar *arg) {
vr.genTrace = True;
}

else if (VG_STR_CLOM (cloPD, arg, "--output-trace-rep", str)) {
//vr.includeSourceFile = VG_(strdup)("vr.process_clo.gen-source", str);
vr.outputTraceRep = VG_(expand_file_name)("vr.process_clo.trace-rep", str);
}
// Instrumentation of only specified source lines
else if (VG_STR_CLOM (cloPD, arg, "--gen-source", str)) {
//vr.includeSourceFile = VG_(strdup)("vr.process_clo.gen-source", str);
Expand Down
22 changes: 15 additions & 7 deletions vr_clo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@
" the verrou backend. If this option is not provided, Verrou always\n"
" rounds to the nearest floating-point. Supported rounding modes are:\n"
"\n"
" Random rounding modes: random, average.\n"
" · Random rounding modes: random, average.\n"
"\n"
" IEEE-754 rounding modes: nearest (default), upward, downward,\n"
" · IEEE-754 rounding modes: nearest (default), upward, downward,\n"
" toward_zero.\n"
"\n"
" Other: farthest, float, ftz(imply checkdenorm backend).\n"
" · Other: farthest, float, ftz(imply checkdenorm backend).\n"
"\n"
" --mca-mode=<mca|rr|pb|ieee> [default=mca]\n"
" Emulate the given MCA mode for operations instrumented with the\n"
" mcaquad backend. Supported mca modes are:\n"
"\n"
" mca : full mca (default)\n"
" · mca : full mca (default)\n"
"\n"
" rr : random rounding\n"
" · rr : random rounding\n"
"\n"
" pb : precision bounding\n"
" · pb : precision bounding\n"
"\n"
" ieee : ieee (rounding to nearest)\n"
" · ieee : ieee (rounding to nearest)\n"
"\n"
" The mcaquad backend implementation come from Verificarlo : More\n"
" information on Verificalo github[1]\n"
Expand Down Expand Up @@ -110,6 +110,14 @@
" In combination with --source, only list source code lines which\n"
" were not already present in the provided list.\n"
"\n"
" Coverage generation\n"
" --trace=FILE\n"
" Activate the Basic Blocks Coverage for the symbols specified in\n"
" FILE.\n"
"\n"
" --output-trace-rep=REP\n"
" Specify the REP directory for the trace output files.\n"
"\n"
" Detection options\n"
" --check-nan=<yes|no> [default=yes]\n"
" Activate NaN detection. NaN produces a valgrind error. This\n"
Expand Down
2 changes: 1 addition & 1 deletion vr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ static void vr_post_clo_init(void)


if(vr.genTrace){
vr_traceBB_initialize();
vr_traceBB_initialize(vr.outputTraceRep);
}

/*If no operation selected the default is all*/
Expand Down
1 change: 1 addition & 0 deletions vr_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ typedef struct {

Bool genTrace;
Vr_Include_Trace* includeTrace;
HChar* outputTraceRep;
} Vr_State;

extern Vr_State vr;
Expand Down
62 changes: 45 additions & 17 deletions vr_traceBB_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/



struct traceBB_T {
IRSB* irsb;
UInt index;
Expand Down Expand Up @@ -114,33 +115,60 @@ void freeTraceBBList(void){
}
}

Bool vr_is_dir ( const HChar* f );
Bool vr_is_dir ( const HChar* f )
{ //copy of /coregrind/m_libcfile.c which is not public
struct vg_stat buf;
SysRes res = VG_(stat)(f, &buf);
return sr_isError(res) ? False
: VKI_S_ISDIR(buf.mode) ? True : False;
}



void vr_traceBB_initialize(char* path);
void vr_traceBB_initialize(char* path){
const HChar * strInfo="./trace_bb_info.log-%p";
const HChar * strCov="./trace_bb_cov.log-%p";

HChar absfileInfo[512];
HChar absfileCov[512];

void vr_traceBB_initialize(void);
void vr_traceBB_initialize(void){
const HChar * strInfo="trace_bb_info.log-%p";
// const HChar * strTrace="trace_bb_trace.log-%p";
const HChar * strCov="trace_bb_cov.log-%p";
// const HChar * strInfoBack="trace_bb_info_backtrace.log-%p";
const HChar * strExpInfo= VG_(expand_file_name)("vr.traceBB.strInfo", strInfo);
// const HChar * strExpTrace= VG_(expand_file_name)("vr.traceBB.strTrace", strTrace);
const HChar * strExpCov= VG_(expand_file_name)("vr.traceBB.strCov", strCov);
// const HChar * strExpBack= VG_(expand_file_name)("vr.traceBB.strBack", strInfoBack);
if (path!=NULL) {
if(VG_(strlen)(path) >400){
VG_(tool_panic)("too long output path\n");
}

if(!vr_is_dir(path) ){
HChar mkdCmd[512];
VG_(sprintf)(mkdCmd, "mkdir -p %s", path);
VG_(umsg)("Cmd : %s\n",mkdCmd);
Int r=VG_(system)(mkdCmd);
if(r){
VG_(tool_panic)("not able to create directory");
}
}
VG_(sprintf)(absfileInfo, "%s/%s", path, strInfo);
VG_(sprintf)(absfileCov, "%s/%s", path, strCov);
} else {
VG_(sprintf)(absfileInfo, "./%s", strInfo);
VG_(sprintf)(absfileCov, "./%s", strCov);
}

const HChar * strExpInfo= VG_(expand_file_name)("vr.traceBB.strInfo", absfileInfo);
const HChar * strExpCov= VG_(expand_file_name)("vr.traceBB.strCov", absfileCov);

vr_out_bb_info = VG_(fopen)(strExpInfo,
VKI_O_WRONLY | VKI_O_CREAT | VKI_O_TRUNC,
VKI_S_IRUSR|VKI_S_IWUSR|VKI_S_IRGRP|VKI_S_IROTH);
/* vr_out_bb_trace = VG_(fopen)(strExpTrace, */
/* VKI_O_WRONLY | VKI_O_CREAT | VKI_O_TRUNC, */
/* VKI_S_IRUSR|VKI_S_IWUSR|VKI_S_IRGRP|VKI_S_IROTH); */

vr_out_bb_cov = VG_(fopen)(strExpCov,
VKI_O_WRONLY | VKI_O_CREAT | VKI_O_TRUNC,
VKI_S_IRUSR|VKI_S_IWUSR|VKI_S_IRGRP|VKI_S_IROTH);
/* vr_out_bb_info_backtrace = VG_(fopen)(strExpBack, */
/* VKI_O_WRONLY | VKI_O_CREAT | VKI_O_TRUNC, */
/* VKI_S_IRUSR|VKI_S_IWUSR|VKI_S_IRGRP|VKI_S_IROTH); */

if(/*vr_out_bb_trace==NULL || */ vr_out_bb_info==NULL /*|| vr_out_bb_info_backtrace==NULL */|| vr_out_bb_cov==NULL){
VG_(tool_panic)("trace file initialization failed\n");
VG_(umsg)("Error with %s or %s",strExpInfo,strExpCov);
VG_(tool_panic)("trace file initialization failed");
}
};

Expand Down

0 comments on commit da3f439

Please sign in to comment.