summaryrefslogtreecommitdiff
path: root/tools/standalone_miri/value.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-02-25 11:53:56 +0800
committerJohn Hodge <tpg@mutabah.net>2018-02-25 12:59:37 +0800
commit0942ce626ef9b84e9cf0407ecfe1217ca3381c48 (patch)
treee3ed78821835ce1ba932f4627a5cc73b303d12de /tools/standalone_miri/value.cpp
parent166a3999ce4013764046128c28fe8ac223148593 (diff)
downloadmrust-0942ce626ef9b84e9cf0407ecfe1217ca3381c48.tar.gz
Standalone MIR - Better drop handling, RValue::Struct, RValue::SizedArray, ...
Diffstat (limited to 'tools/standalone_miri/value.cpp')
-rw-r--r--tools/standalone_miri/value.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/tools/standalone_miri/value.cpp b/tools/standalone_miri/value.cpp
index 522e40dd..45eb1474 100644
--- a/tools/standalone_miri/value.cpp
+++ b/tools/standalone_miri/value.cpp
@@ -176,16 +176,19 @@ Value Allocation::read_value(size_t ofs, size_t size) const
}
void Allocation::read_bytes(size_t ofs, void* dst, size_t count) const
{
+ if(count == 0)
+ return ;
+
if(ofs >= this->size() ) {
- ::std::cerr << "Value::write_bytes - Out of bounds read, " << ofs << " >= " << this->size() << ::std::endl;
+ LOG_ERROR("Out of bounds read, " << ofs << "+" << count << " > " << this->size());
throw "ERROR";
}
if(count > this->size() ) {
- ::std::cerr << "Value::write_bytes - Out of bounds read, count " << count << " > size " << this->size() << ::std::endl;
+ LOG_ERROR("Out of bounds read, " << ofs << "+" << count << " > " << this->size());
throw "ERROR";
}
if(ofs+count > this->size() ) {
- ::std::cerr << "Value::write_bytes - Out of bounds read, " << ofs << "+" << count << " > size " << this->size() << ::std::endl;
+ LOG_ERROR("Out of bounds read, " << ofs << "+" << count << " > " << this->size());
throw "ERROR";
}
check_bytes_valid(ofs, count);
@@ -259,16 +262,18 @@ void Allocation::write_value(size_t ofs, Value v)
}
void Allocation::write_bytes(size_t ofs, const void* src, size_t count)
{
+ if(count == 0)
+ return ;
if(ofs >= this->size() ) {
- ::std::cerr << "Value::write_bytes - Out of bounds write, " << ofs << " >= " << this->size() << ::std::endl;
+ LOG_ERROR("Out of bounds write, " << ofs << "+" << count << " > " << this->size());
throw "ERROR";
}
if(count > this->size() ) {
- ::std::cerr << "Value::write_bytes - Out of bounds write, count " << count << " > size " << this->size() << ::std::endl;
+ LOG_ERROR("Out of bounds write, " << ofs << "+" << count << " > " << this->size());
throw "ERROR";
}
if(ofs+count > this->size() ) {
- ::std::cerr << "Value::write_bytes - Out of bounds write, " << ofs << "+" << count << " > size " << this->size() << ::std::endl;
+ LOG_ERROR("Out of bounds write, " << ofs << "+" << count << " > " << this->size());
throw "ERROR";
}
@@ -465,6 +470,8 @@ Value Value::read_value(size_t ofs, size_t size) const
}
void Value::read_bytes(size_t ofs, void* dst, size_t count) const
{
+ if(count == 0)
+ return ;
if( this->allocation )
{
this->allocation.alloc().read_bytes(ofs, dst, count);
@@ -473,12 +480,18 @@ void Value::read_bytes(size_t ofs, void* dst, size_t count) const
{
check_bytes_valid(ofs, count);
- if(ofs >= this->direct_data.size )
+ if(ofs >= this->direct_data.size ) {
+ LOG_ERROR("Out of bounds read, " << ofs << "+" << count << " > " << this->size());
throw "ERROR";
- if(count > this->direct_data.size )
+ }
+ if(count > this->direct_data.size ) {
+ LOG_ERROR("Out of bounds read, " << ofs << "+" << count << " > " << this->size());
throw "ERROR";
- if(ofs+count > this->direct_data.size )
+ }
+ if(ofs+count > this->direct_data.size ) {
+ LOG_ERROR("Out of bounds read, " << ofs << "+" << count << " > " << this->size());
throw "ERROR";
+ }
::std::memcpy(dst, this->direct_data.data + ofs, count);
}
}