Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
psimsmt
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
phlo
psimsmt
Commits
31bcd97b
Commit
31bcd97b
authored
Jul 22, 2019
by
phlo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Trace::flush & Trace::print for single steps
parent
edcecc87
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
74 deletions
+98
-74
simulator.cc
simulator.cc
+2
-2
test/test_trace.cc
test/test_trace.cc
+2
-2
trace.cc
trace.cc
+80
-66
trace.hh
trace.hh
+14
-4
No files found.
simulator.cc
View file @
31bcd97b
...
...
@@ -175,7 +175,7 @@ void Simulator::store (word_t address,
if
(
flush
)
{
trace
->
push_back_heap
(
step
,
{
address
,
value
}
);
trace
->
push_back_heap
(
step
,
address
,
value
);
}
else
{
...
...
@@ -195,7 +195,7 @@ void Simulator::flush ()
sb_full
(
false
);
state
[
thread
]
=
State
::
running
;
trace
->
push_back_flush
(
step
-
1
);
trace
->
push_back_heap
(
step
,
{
sb_adr
(),
sb_val
()}
);
trace
->
push_back_heap
(
step
,
sb_adr
(),
sb_val
()
);
}
// Simulator::execute ----------------------------------------------------------
...
...
test/test_trace.cc
View file @
31bcd97b
...
...
@@ -1011,7 +1011,7 @@ TEST_F(Trace, push_back_heap)
for
(
const
auto
&
[
step
,
thread
,
idx
,
val
]
:
data
)
{
expected_adr
.
emplace_hint
(
expected_adr
.
end
(),
step
,
idx
);
trace
->
push_back_heap
(
step
,
{
idx
,
val
}
);
trace
->
push_back_heap
(
step
,
idx
,
val
);
}
ASSERT_EQ
(
data
.
size
(),
trace
->
size
());
...
...
@@ -1121,7 +1121,7 @@ TEST_F(Trace, heap)
for
(
const
auto
&
[
step
,
thread
,
adr
,
val
]
:
data
)
{
trace
->
push_back_heap
(
step
,
{
adr
,
val
}
);
trace
->
push_back_heap
(
step
,
adr
,
val
);
ASSERT_EQ
(
val
,
trace
->
heap
(
adr
));
}
}
...
...
trace.cc
View file @
31bcd97b
...
...
@@ -494,10 +494,10 @@ void Trace::push_back_sb_full (size_t step,
// Trace::push_back_heap -------------------------------------------------------
void
Trace
::
push_back_heap
(
size_t
step
,
const
cell_t
&
heap
)
void
Trace
::
push_back_heap
(
size_t
step
,
const
word_t
adr
,
const
word_t
val
)
{
heap_adr_updates
.
emplace_hint
(
heap_adr_updates
.
end
(),
step
,
heap
.
adr
);
push_back
<
word_t
>
(
heap_val_updates
[
heap
.
adr
],
step
,
heap
.
val
);
heap_adr_updates
.
emplace_hint
(
heap_adr_updates
.
end
(),
step
,
adr
);
push_back
<
word_t
>
(
heap_val_updates
[
adr
],
step
,
val
);
if
(
++
step
>
length
)
length
=
step
;
...
...
@@ -520,6 +520,13 @@ word_t Trace::thread () const
return
thread_updates
.
crbegin
()
->
second
;
}
// Trace::flush ----------------------------------------------------------------
bool
Trace
::
flush
(
const
word_t
step
)
const
{
return
flushes
.
find
(
step
)
!=
flushes
.
end
();
}
// Trace::pc -------------------------------------------------------------------
word_t
Trace
::
pc
(
const
word_t
thread
)
const
...
...
@@ -595,95 +602,102 @@ Trace::iterator Trace::end () const
// Trace::print ----------------------------------------------------------------
std
::
string
Trace
::
print
()
const
std
::
string
Trace
::
print
(
const
Step
&
step
)
const
{
std
::
ostringstream
ss
;
const
char
sep
=
'\t'
;
// trace metadata
for
(
const
Program
&
program
:
*
programs
)
ss
<<
program
.
path
<<
eol
;
// separator + mmap
ss
<<
'.'
;
if
(
mmap
)
ss
<<
' '
<<
mmap
->
path
;
// thread id
ss
<<
step
.
thread
<<
sep
;
ss
<<
eol
;
// reference to program
const
Program
&
program
=
(
*
programs
)[
step
.
thread
];
//
column headers
ss
<<
"# tid
\t
pc
\t
cmd
\t
arg
\t
accu
\t
mem
\t
adr
\t
val
\t
full
\t
heap"
<<
eol
;
//
reference to current instruction
const
Instruction
&
op
=
program
[
step
.
pc
]
;
for
(
const
auto
&
step
:
*
this
)
// program counter
try
{
ss
<<
program
.
get_label
(
step
.
pc
)
<<
sep
;
}
catch
(...)
{
// thread id
ss
<<
step
.
thread
<<
sep
;
ss
<<
step
.
pc
<<
sep
;
}
// reference to program
const
Program
&
program
=
(
*
programs
)[
step
.
thread
];
// instruction symbol / argument
if
(
step
.
flush
)
{
ss
<<
"FLUSH"
<<
sep
<<
'-'
<<
sep
;
}
else
{
ss
<<
op
.
symbol
()
<<
sep
;
// reference to current instruction
const
Instruction
&
op
=
program
[
step
.
pc
];
std
::
string
arg
{
'-'
};
// program counter
try
{
ss
<<
program
.
get_label
(
step
.
pc
)
<<
sep
;
}
catch
(...)
if
(
op
.
is_unary
())
{
ss
<<
step
.
pc
<<
sep
;
}
arg
=
std
::
to_string
(
op
.
arg
());
// instruction symbol / argument
if
(
step
.
flush
)
{
ss
<<
"FLUSH"
<<
sep
<<
'-'
<<
sep
;
if
(
op
.
is_memory
())
{
if
(
op
.
indirect
())
arg
=
'['
+
arg
+
']'
;
}
else
if
(
op
.
is_jump
())
try
{
arg
=
program
.
get_label
(
op
.
arg
());
}
catch
(...)
{}
}
else
{
ss
<<
op
.
symbol
()
<<
sep
;
std
::
string
arg
{
'-'
};
ss
<<
arg
<<
sep
;
}
if
(
op
.
is_unary
())
{
arg
=
std
::
to_string
(
op
.
arg
());
// accumulator / CAS memory register
ss
<<
step
.
accu
<<
sep
<<
step
.
mem
<<
sep
;
if
(
op
.
is_memory
())
{
if
(
op
.
indirect
())
arg
=
'['
+
arg
+
']'
;
}
else
if
(
op
.
is_jump
())
try
{
arg
=
program
.
get_label
(
op
.
arg
());
}
catch
(...)
{}
}
// store buffer
ss
<<
step
.
sb_adr
<<
sep
<<
step
.
sb_val
<<
sep
<<
step
.
sb_full
<<
sep
;
ss
<<
arg
<<
sep
;
}
// heap update
ss
<<
'{'
;
// accumulator / CAS memory register
ss
<<
step
.
accu
<<
sep
<<
step
.
mem
<<
sep
;
if
(
step
.
heap
)
ss
<<
'('
<<
step
.
heap
->
adr
<<
','
<<
step
.
heap
->
val
<<
')'
;
// store buffer
ss
<<
step
.
sb_adr
<<
sep
<<
step
.
sb_val
<<
sep
<<
step
.
sb_full
<<
sep
;
ss
<<
'}'
;
// heap update
ss
<<
'{'
;
// step number
if
(
verbose
)
ss
<<
sep
<<
"# "
<<
std
::
to_string
(
step
.
step
);
if
(
step
.
heap
)
ss
<<
'('
<<
step
.
heap
->
adr
<<
','
<<
step
.
heap
->
val
<<
')'
;
ss
<<
eol
;
ss
<<
'}'
;
return
ss
.
str
();
}
// step number
if
(
verbose
)
ss
<<
sep
<<
"# "
<<
std
::
to_string
(
step
.
step
)
;
std
::
string
Trace
::
print
()
const
{
std
::
ostringstream
ss
;
ss
<<
eol
;
}
// trace metadata
for
(
const
Program
&
program
:
*
programs
)
ss
<<
program
.
path
<<
eol
;
// separator + mmap
ss
<<
'.'
;
if
(
mmap
)
ss
<<
' '
<<
mmap
->
path
;
ss
<<
eol
;
// column headers
ss
<<
"# tid
\t
pc
\t
cmd
\t
arg
\t
accu
\t
mem
\t
adr
\t
val
\t
full
\t
heap"
<<
eol
;
for
(
const
auto
&
step
:
*
this
)
ss
<<
print
(
step
);
return
ss
.
str
();
}
...
...
trace.hh
View file @
31bcd97b
...
...
@@ -40,6 +40,8 @@ struct Trace
// heap cell -----------------------------------------------------------------
//
// TODO: switch to std::pair<word_t, word_t>
//
struct
cell_t
{
word_t
adr
;
...
...
@@ -288,16 +290,20 @@ struct Trace
void
push_back_pc
(
size_t
step
,
word_t
thread
,
word_t
pc
);
void
push_back_accu
(
size_t
step
,
word_t
thread
,
word_t
accu
);
void
push_back_mem
(
size_t
step
,
word_t
thread
,
word_t
mem
);
void
push_back_sb_adr
(
size_t
step
,
word_t
thread
,
word_t
ad
r
);
void
push_back_sb_val
(
size_t
step
,
word_t
thread
,
word_t
val
);
void
push_back_sb_adr
(
size_t
step
,
word_t
thread
,
word_t
ad
dress
);
void
push_back_sb_val
(
size_t
step
,
word_t
thread
,
word_t
val
ue
);
void
push_back_sb_full
(
size_t
step
,
word_t
thread
,
bool
full
);
void
push_back_heap
(
size_t
step
,
const
cell_t
&
heap
);
void
push_back_heap
(
size_t
step
,
const
word_t
address
,
const
word_t
value
);
void
push_back_flush
(
size_t
step
);
// return most recently scheduled thread's id
//
word_t
thread
()
const
;
// return true if a store buffer has been flushed in the given step
//
bool
flush
(
word_t
step
)
const
;
// return most recent register states
//
word_t
pc
(
word_t
thread
)
const
;
...
...
@@ -323,7 +329,11 @@ struct Trace
//
iterator
end
()
const
;
// print trace
// print individual step
//
std
::
string
print
(
const
Step
&
step
)
const
;
// print whole trace
//
std
::
string
print
()
const
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment