diff options
author | John Hodge <tpg@mutabah.net> | 2018-03-04 20:04:31 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2018-03-17 18:52:16 +0800 |
commit | 5d78f1ba303a0e8196e62d4bd0c7708387164993 (patch) | |
tree | 1e87aa7a6bc6ef985c865c8e746851be5b046141 /tools/standalone_miri/value.cpp | |
parent | dcf1204a8bae3f15e875ffe9c861c38789f524fe (diff) | |
download | mrust-5d78f1ba303a0e8196e62d4bd0c7708387164993.tar.gz |
Standalone Miri - More work blasting along
Diffstat (limited to 'tools/standalone_miri/value.cpp')
-rw-r--r-- | tools/standalone_miri/value.cpp | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/tools/standalone_miri/value.cpp b/tools/standalone_miri/value.cpp index 51bf6b94..745e9b1b 100644 --- a/tools/standalone_miri/value.cpp +++ b/tools/standalone_miri/value.cpp @@ -581,13 +581,57 @@ void Value::write_usize(size_t ofs, uint64_t v) } extern ::std::ostream& operator<<(::std::ostream& os, const ValueRef& v) { - if( v.m_alloc ) + if( v.m_alloc || v.m_value->allocation ) { - os << v.m_alloc.alloc(); + const auto& alloc_ptr = v.m_alloc ? v.m_alloc : v.m_value->allocation; + // TODO: What if alloc_ptr isn't a data allocation? + const auto& alloc = alloc_ptr.alloc(); + + for(size_t i = v.m_offset; i < ::std::min(alloc.size(), v.m_offset + v.m_size); i++) + { + if( i != 0 ) + os << " "; + + if( alloc.mask[i/8] & (1 << i%8) ) + { + os << ::std::setw(2) << ::std::setfill('0') << (int)alloc.data_ptr()[i]; + } + else + { + os << "--"; + } + } + + os << " {"; + for(const auto& r : alloc.relocations) + { + if( v.m_offset <= r.slot_ofs && r.slot_ofs < v.m_offset + v.m_size ) + { + os << " @" << (r.slot_ofs - v.m_offset) << "=" << r.backing_alloc; + } + } + os << " }"; } else { - os << *v.m_value; + const auto& direct = v.m_value->direct_data; + + auto flags = os.flags(); + os << ::std::hex; + for(size_t i = v.m_offset; i < ::std::min(static_cast<size_t>(direct.size), v.m_offset + v.m_size); i++) + { + if( i != 0 ) + os << " "; + if( direct.mask[i/8] & (1 << i%8) ) + { + os << ::std::setw(2) << ::std::setfill('0') << (int)direct.data[i]; + } + else + { + os << "--"; + } + } + os.setf(flags); } return os; } |