[Lldb-commits] [PATCH] [DWARFExpression] Convert a result of DWARF pieces into a scalar value.
Greg Clayton
clayborg at gmail.com
Thu Apr 30 16:22:04 PDT 2015
> On Apr 30, 2015, at 4:05 PM, Siva Chandra <sivachandra at google.com> wrote:
>
> On Thu, Apr 30, 2015 at 3:41 PM, Greg Clayton <clayborg at gmail.com> wrote:
>
>> This is an incorrect fix. The variable doesn't necessarily need to be a scalar.
>
>> You might be describing where a uint128 or larger value is constructed from
>
>> multiple registers. In your case this works, but this isn't the right fix. We
>
>> should be able to describe a variable's value by saying "here is the buffer that
>
>> contains it".
>
>
> This wording helps understand the code and its meaning better and I now agree that the change is in the wrong place.
>
> I would like to use this as an opportunity to ask about few other pieces of code which don't seem to be in line [per my current understanding that is] with the above meaning.
>
> Look at my comments inline with in code below from ValueObject.cpp:
>
> 1804 addr_t
> 1805 ValueObject::GetAddressOf (bool scalar_is_load_address, AddressType *address_type)
> 1806 {
> 1807 if (!UpdateValueIfNeeded(false))
> 1808 return LLDB_INVALID_ADDRESS;
> 1809
> 1810 switch (m_value.GetValueType())
> 1811 {
> 1812 case Value::eValueTypeScalar:
> 1813 case Value::eValueTypeVector:
> 1814 if (scalar_is_load_address)
> 1815 {
> 1816 if(address_type)
> 1817 *address_type = eAddressTypeLoad;
> 1818 return m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
> 1819 }
> 1820 break;
> 1821
> 1822 case Value::eValueTypeLoadAddress:
> 1823 case Value::eValueTypeFileAddress:
> 1824 case Value::eValueTypeHostAddress:
>
> Can a value of type eValueTypeHostAddress have a valid address in the inferior process space? Even if it does, why is a scalar value being returned on line 1828.
File address means you have debug info that describes 0x1000, but it will get loaded elsewhere and it will need to be mapped to where the image was loaded (convert the file address to a valid load address, then read the variable).
Load address means a live address in the inferior, no translation needed.
Host address: it is in a malloc'ed buffer inside LLDB. This is used for freeze dried values (like all expression results).
So you are correct in that sometimes we have both a host address for the freeze dried bits, and we might have this mirrored down in the process. But the value for that will usually be handed out as a load address.
If a value has a host address, we should assume it is host only.
>
> 1825 {
> 1826 if(address_type)
> 1827 *address_type = m_value.GetValueAddressType ();
> 1828 return m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
> 1829 }
> 1830 break;
> 1831 }
> 1832 if (address_type)
> 1833 *address_type = eAddressTypeInvalid;
> 1834 return LLDB_INVALID_ADDRESS;
> 1835 }
>
> Another one from ValueObject.cpp:
>
> 3802 case eAddressTypeHost:
> 3803 {
> 3804 ClangASTType clang_type = GetClangType();
> 3805 if (clang_type)
> 3806 {
> 3807 std::string name (1, '&');
> 3808 name.append (m_name.AsCString(""));
> 3809 ExecutionContext exe_ctx (GetExecutionContextRef());
> 3810 m_addr_of_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
> 3811 clang_type.GetPointerType(),
> 3812 ConstString (name.c_str()),
> 3813 addr,
>
> Why is the host address being treated as the value's address when the address type is eAddressTypeHost.
We should not allow getting the address of something that is a host address. We currently can though because the pointer itself is in the Value's Scalar which means we would take the address of the integer containing the pointer if we wanted to. But I don't think it is a good idea.
>
> 3814 eAddressTypeInvalid,
> 3815 m_data.GetAddressByteSize());
> 3816 }
>
>
> http://reviews.llvm.org/D9421
>
> EMAIL PREFERENCES
> http://reviews.llvm.org/settings/panel/emailpreferences/
>
>
More information about the lldb-commits
mailing list