Skip to content

Commit

Permalink
Rewrote the initial DW_OP_piece support to be able to support opcodes…
Browse files Browse the repository at this point in the history
… like:

DW_OP_fbreg(N) DW_OP_piece(4) DW_OP_fbreg(M) DW_OP_piece(8)
DW_OP_fbreg(N) DW_OP_piece(4) DW_OP_piece(8)

The first grabs 4 bytes from FP+N followed by 8 bytes from FP+M, the second grabs 4 bytes from FP+N followed by zero filling 8 bytes which are unavailable. Of course regiters are stuff supported:

DW_OP_reg3 DW_OP_piece(4) DW_OP_reg8 DW_OP_piece(8)

The fix does the following:
1 - don't push the full piece value onto the stack, keep it on the side
2 - fill zeros for DW_OP_piece(N) opcodes that have nothing on the stack (instead of previously consuming the full piece that was pushed onto the stack)
3 - simplify the logic

<rdar://problem/16930524>



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@214415 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Greg Clayton committed Jul 31, 2014
1 parent 5ebb9d1 commit aeb77e1
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 110 deletions.
5 changes: 4 additions & 1 deletion include/lldb/Core/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,11 @@ class Value
return false;
}

void
size_t
ResizeData(size_t len);

size_t
AppendDataToHostBuffer (const Value &rhs);

DataBufferHeap &
GetBuffer ()
Expand Down
64 changes: 63 additions & 1 deletion source/Core/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,74 @@ Value::GetType()
return NULL;
}

void
size_t
Value::AppendDataToHostBuffer (const Value &rhs)
{
size_t curr_size = m_data_buffer.GetByteSize();
Error error;
switch (rhs.GetValueType())
{
case eValueTypeScalar:
{
const size_t scalar_size = rhs.m_value.GetByteSize();
if (scalar_size > 0)
{
const size_t new_size = curr_size + scalar_size;
if (ResizeData(new_size) == new_size)
{
rhs.m_value.GetAsMemoryData (m_data_buffer.GetBytes() + curr_size,
scalar_size,
lldb::endian::InlHostByteOrder(),
error);
return scalar_size;
}
}
}
break;
case eValueTypeVector:
{
const size_t vector_size = rhs.m_vector.length;
if (vector_size > 0)
{
const size_t new_size = curr_size + vector_size;
if (ResizeData(new_size) == new_size)
{
::memcpy (m_data_buffer.GetBytes() + curr_size,
rhs.m_vector.bytes,
vector_size);
return vector_size;
}
}
}
break;
case eValueTypeFileAddress:
case eValueTypeLoadAddress:
case eValueTypeHostAddress:
{
const uint8_t *src = rhs.GetBuffer().GetBytes();
const size_t src_len = rhs.GetBuffer().GetByteSize();
if (src && src_len > 0)
{
const size_t new_size = curr_size + src_len;
if (ResizeData(new_size) == new_size)
{
::memcpy (m_data_buffer.GetBytes() + curr_size, src, src_len);
return src_len;
}
}
}
break;
}
return 0;
}

size_t
Value::ResizeData(size_t len)
{
m_value_type = eValueTypeHostAddress;
m_data_buffer.SetByteSize(len);
m_value = (uintptr_t)m_data_buffer.GetBytes();
return m_data_buffer.GetByteSize();
}

bool
Expand Down
Loading

0 comments on commit aeb77e1

Please sign in to comment.