[Lldb-commits] [lldb] 3775be2 - Target: correct the return value for `GetImageAddrFromToken`

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 6 19:05:18 PDT 2020


This should be easy to test.  If you have a running process, and haven’t called “process load” then:

(lldb) process unload 12345

Should return the error:

failed to unload image: invalid image token

But instead on x86_64 it returns the error:

failed to unload image: expression failed: "dlclose((void *)0xffffffff)”

Should be enough to run process unload with a bogus token and make sure the error is “invalid image token”.

Jim



> On Apr 6, 2020, at 6:48 PM, Shafik Yaghmour via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> Hello Saleem,
> 
> I am not familiar with this part of the code but is there an easy way to test this failure? We should add a test to make sure we don’t break this accidentally in the future.
> 
> Thank you!
> 
>> On Apr 6, 2020, at 5:38 PM, Saleem Abdulrasool via lldb-commits <lldb-commits at lists.llvm.org> wrote:
>> 
>> 
>> Author: Saleem Abdulrasool
>> Date: 2020-04-06T17:37:57-07:00
>> New Revision: 3775be2d8e17aaeae62ab83ded005867f4bf70ac
>> 
>> URL: https://github.com/llvm/llvm-project/commit/3775be2d8e17aaeae62ab83ded005867f4bf70ac
>> DIFF: https://github.com/llvm/llvm-project/commit/3775be2d8e17aaeae62ab83ded005867f4bf70ac.diff
>> 
>> LOG: Target: correct the return value for `GetImageAddrFromToken`
>> 
>> We would return `LLDB_INVALID_IMAGE_TOKEN` for the address rather than
>> the correct value of `LLDB_IMAGE_ADDRESS`.  This would result in the
>> check for the return value to silently pass on x64 as the invalid
>> address and invalid token are of different sizes (`size_t` vs
>> `uintprr_t`).  This corrects the return value to `LLDB_INVALID_ADDRESS`
>> and addresses the rest to reset the mapped address to the invalid value.
>> 
>> This was found by inspection when trying to implement module support for
>> Windows.
>> 
>> Added: 
>> 
>> 
>> Modified: 
>>   lldb/source/Target/Process.cpp
>> 
>> Removed: 
>> 
>> 
>> 
>> ################################################################################
>> diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
>> index a39999776f95..7797a4c60964 100644
>> --- a/lldb/source/Target/Process.cpp
>> +++ b/lldb/source/Target/Process.cpp
>> @@ -5796,12 +5796,12 @@ size_t Process::AddImageToken(lldb::addr_t image_ptr) {
>> lldb::addr_t Process::GetImagePtrFromToken(size_t token) const {
>>  if (token < m_image_tokens.size())
>>    return m_image_tokens[token];
>> -  return LLDB_INVALID_IMAGE_TOKEN;
>> +  return LLDB_INVALID_ADDRESS;
>> }
>> 
>> void Process::ResetImageToken(size_t token) {
>>  if (token < m_image_tokens.size())
>> -    m_image_tokens[token] = LLDB_INVALID_IMAGE_TOKEN;
>> +    m_image_tokens[token] = LLDB_INVALID_ADDRESS;
>> }
>> 
>> Address
>> 
>> 
>> 
>> _______________________________________________
>> lldb-commits mailing list
>> lldb-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list