Re: [lldb-dev] OverflowError: in method 'SBProcess_ReadPointerFromMemory', argument 2 of type 'lldb::addr_t'

2016-09-19 Thread Greg Clayton via lldb-dev

> On Sep 19, 2016, at 1:09 PM, Greg Clayton <gclay...@apple.com> wrote:
> 
> 
>> On Sep 19, 2016, at 10:33 AM, Lei Kong <leik...@msn.com> wrote:
>> 
>> You are right, it seems the argument is out of range, both vtableAddr and 
>> vtableAddr-8 are “8.5” byte long. Maybe there is something wrong with the 
>> way I get vtableAddress? I will clean up my full script and send it to you 
>> if the following does not provide enough information, thanks much.
>> 
>> def vtable_addr (vtableSymbol):
>>return vtableSymbol.addr.section.file_addr + vtableSymbol.addr.offset + 
>> 0x10
> 
> You actually want to get the load address when reading from memory. This 
> should be:
> 
> def vtable_addr (vtableSymbol, target):
>return vtableSymbol.addr.GetLoadAddress(target) + 0x10

If you actually wanted the file address of vtableSymbol's address, then you 
would do this:

def vtable_addr (vtableSymbol, target):
   return vtableSymbol.addr.GetFileAddress() + 0x10

No need to do the section + offset math yourself.

> 
>> 
>> 
>> vtableAddr, type=, value=0x1000f
>> vtableAddr-8, type=, value=0x10007
>> Traceback (most recent call last):
>>  File "", line 1, in 
>>  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
>> 199, in findall
>>findtypes(pattern,ignorePureVirtualType)
>>  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
>> 156, in findtypes
>>if ignorePureVirtualType and has_pure_virtual(vtableAddr, 
>> pureVirtualFuncs) :
>>  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
>> 100, in has_pure_virtual
>>vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr-8, error)
>>  File "/home/leikong/bin/lldb/lib/python2.7/site-packages/lldb/__init__.py", 
>> line 9418, in ReadPointerFromMemory
>>return _lldb.SBProcess_ReadPointerFromMemory(self, addr, error)
>> OverflowError: in method 'SBProcess_ReadPointerFromMemory', argument 2 of 
>> type 'lldb::addr_t'
>> 
>> From: Greg Clayton
>> Sent: Monday, September 19, 2016 09:12 AM
>> To: Lei Kong
>> Cc: Jim Ingham; lldb-dev@lists.llvm.org
>> Subject: Re: [lldb-dev] OverflowError: in method 
>> 'SBProcess_ReadPointerFromMemory', argument 2 of type 'lldb::addr_t'
>> 
>> Try printing the type of the value you are passing in the line:
>> 
>>vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr-8, error)
>> 
>> print type(vtableAddr)
>> print type(vtableAddr-8)
>> 
>> It seems like it thinks vtableAddr doesn't fit into a lldb::addr_t which is 
>> a uint64_t
>> 
>> 
>> 
>>> On Sep 16, 2016, at 7:39 PM, Lei Kong via lldb-dev 
>>> <lldb-dev@lists.llvm.org> wrote:
>>> 
>>> I tried printing error.descryption, but it didn't work, because when the 
>>> error happens, it seems ReadPointerFromMemory never returned to my code.
>>> 
>>> 
>>> read from address 01223f68
>>> Traceback (most recent call last):
>>>  File "", line 1, in 
>>>  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
>>> 289, in findall
>>>findtypes(pattern,ignorePureVirtualType)
>>>  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
>>> 246, in findtypes
>>>if ignorePureVirtualType and has_pure_virtual(vtableAddr, 
>>> pureVirtualFuncs) :
>>>  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
>>> 190, in has_pure_virtual
>>>vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr-8, error)
>>>  File 
>>> "/home/leikong/bin/lldb/lib/python2.7/site-packages/lldb/__init__.py", line 
>>> 9418, in ReadPointerFromMemory
>>>return _lldb.SBProcess_ReadPointerFromMemory(self, addr, error)
>>> OverflowError: in method 'SBProcess_ReadPointerFromMemory', argument 2 of 
>>> type 'lldb::addr_t'
>>> 
>>> 
>>>> Subject: Re: [lldb-dev] OverflowError: in method 
>>>> 'SBProcess_ReadPointerFromMemory', argument 2 of type 'lldb::addr_t'
>>>> From: jing...@apple.com
>>>> Date: Fri, 16 Sep 2016 17:12:24 -0700
>>>> CC: lldb-dev@lists.llvm.org
>>>> To: leik...@msn.com
>>>> 
>>>> You passed an error into ReadPointerFromMemory. In the cases where you 
>>>> aren't getting what you expect, what does that error say

Re: [lldb-dev] OverflowError: in method 'SBProcess_ReadPointerFromMemory', argument 2 of type 'lldb::addr_t'

2016-09-19 Thread Lei Kong via lldb-dev
You are right, it seems the argument is out of range, both vtableAddr and 
vtableAddr-8 are “8.5” byte long. Maybe there is something wrong with the way I 
get vtableAddress? I will clean up my full script and send it to you if the 
following does not provide enough information, thanks much.

def vtable_addr (vtableSymbol):
return vtableSymbol.addr.section.file_addr + vtableSymbol.addr.offset + 0x10


vtableAddr, type=, value=0x1000f
vtableAddr-8, type=, value=0x10007
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 199, 
in findall
findtypes(pattern,ignorePureVirtualType)
  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 156, 
in findtypes
if ignorePureVirtualType and has_pure_virtual(vtableAddr, pureVirtualFuncs) 
:
  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 100, 
in has_pure_virtual
vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr-8, error)
  File "/home/leikong/bin/lldb/lib/python2.7/site-packages/lldb/__init__.py", 
line 9418, in ReadPointerFromMemory
return _lldb.SBProcess_ReadPointerFromMemory(self, addr, error)
OverflowError: in method 'SBProcess_ReadPointerFromMemory', argument 2 of type 
'lldb::addr_t'

From: Greg Clayton<mailto:gclay...@apple.com>
Sent: Monday, September 19, 2016 09:12 AM
To: Lei Kong<mailto:leik...@msn.com>
Cc: Jim Ingham<mailto:jing...@apple.com>; 
lldb-dev@lists.llvm.org<mailto:lldb-dev@lists.llvm.org>
Subject: Re: [lldb-dev] OverflowError: in method 
'SBProcess_ReadPointerFromMemory', argument 2 of type 'lldb::addr_t'

Try printing the type of the value you are passing in the line:

vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr-8, error)

print type(vtableAddr)
print type(vtableAddr-8)

It seems like it thinks vtableAddr doesn't fit into a lldb::addr_t which is a 
uint64_t



> On Sep 16, 2016, at 7:39 PM, Lei Kong via lldb-dev <lldb-dev@lists.llvm.org> 
> wrote:
>
> I tried printing error.descryption, but it didn't work, because when the 
> error happens, it seems ReadPointerFromMemory never returned to my code.
>
>
> read from address 01223f68
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
> 289, in findall
> findtypes(pattern,ignorePureVirtualType)
>   File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
> 246, in findtypes
> if ignorePureVirtualType and has_pure_virtual(vtableAddr, 
> pureVirtualFuncs) :
>   File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
> 190, in has_pure_virtual
> vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr-8, error)
>   File "/home/leikong/bin/lldb/lib/python2.7/site-packages/lldb/__init__.py", 
> line 9418, in ReadPointerFromMemory
> return _lldb.SBProcess_ReadPointerFromMemory(self, addr, error)
> OverflowError: in method 'SBProcess_ReadPointerFromMemory', argument 2 of 
> type 'lldb::addr_t'
>
>
> > Subject: Re: [lldb-dev] OverflowError: in method 
> > 'SBProcess_ReadPointerFromMemory', argument 2 of type 'lldb::addr_t'
> > From: jing...@apple.com
> > Date: Fri, 16 Sep 2016 17:12:24 -0700
> > CC: lldb-dev@lists.llvm.org
> > To: leik...@msn.com
> >
> > You passed an error into ReadPointerFromMemory. In the cases where you 
> > aren't getting what you expect, what does that error say?
> >
> > Jim
> >
> > > On Sep 16, 2016, at 5:06 PM, Lei Kong via lldb-dev 
> > > <lldb-dev@lists.llvm.org> wrote:
> > >
> > > I ran into the error in the subject when running a python script with 
> > > "script myfile.myscript()".
> > >
> > > The value addr_t parameter used is 0x01223f68, the following 
> > > works fine:
> > >
> > > (lldb) scr
> > > Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or 
> > > Ctrl-D.
> > > >>> e = lldb.SBError()
> > > >>> ptr = lldb.process.ReadPointerFromMemory(0x01223f68, e)
> > > >>> print ptr
> > > 0
> > > >>>
> > >
> > > Any suggestion how to further investigate? Thanks.
> > >
> > > myfile.myscript() calls the following function in a loop (iterate through 
> > > all vtable symbols), which contains the call ReadPointerFromMemory.
> > >
> > > def dump_vtbl(vtableAddr) :
> > > error = lldb.SBError()
> > > vtableEndAddr = lldb.process.ReadPointerFromMemory(vta

Re: [lldb-dev] OverflowError: in method 'SBProcess_ReadPointerFromMemory', argument 2 of type 'lldb::addr_t'

2016-09-19 Thread Greg Clayton via lldb-dev
If you want to send your fabdbg.py we can try it out and see if we see anything 
wrong.

> On Sep 19, 2016, at 9:12 AM, Greg Clayton <gclay...@apple.com> wrote:
> 
> Try printing the type of the value you are passing in the line:
> 
>vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr-8, error)
> 
> print type(vtableAddr)
> print type(vtableAddr-8)
> 
> It seems like it thinks vtableAddr doesn't fit into a lldb::addr_t which is a 
> uint64_t
> 
> 
> 
>> On Sep 16, 2016, at 7:39 PM, Lei Kong via lldb-dev <lldb-dev@lists.llvm.org> 
>> wrote:
>> 
>> I tried printing error.descryption, but it didn't work, because when the 
>> error happens, it seems ReadPointerFromMemory never returned to my code.
>> 
>> 
>> read from address 01223f68
>> Traceback (most recent call last):
>>  File "", line 1, in 
>>  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
>> 289, in findall
>>findtypes(pattern,ignorePureVirtualType)
>>  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
>> 246, in findtypes
>>if ignorePureVirtualType and has_pure_virtual(vtableAddr, 
>> pureVirtualFuncs) :
>>  File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
>> 190, in has_pure_virtual
>>vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr-8, error)
>>  File "/home/leikong/bin/lldb/lib/python2.7/site-packages/lldb/__init__.py", 
>> line 9418, in ReadPointerFromMemory
>>return _lldb.SBProcess_ReadPointerFromMemory(self, addr, error)
>> OverflowError: in method 'SBProcess_ReadPointerFromMemory', argument 2 of 
>> type 'lldb::addr_t'
>> 
>> 
>>> Subject: Re: [lldb-dev] OverflowError: in method 
>>> 'SBProcess_ReadPointerFromMemory', argument 2 of type 'lldb::addr_t'
>>> From: jing...@apple.com
>>> Date: Fri, 16 Sep 2016 17:12:24 -0700
>>> CC: lldb-dev@lists.llvm.org
>>> To: leik...@msn.com
>>> 
>>> You passed an error into ReadPointerFromMemory. In the cases where you 
>>> aren't getting what you expect, what does that error say?
>>> 
>>> Jim
>>> 
>>>> On Sep 16, 2016, at 5:06 PM, Lei Kong via lldb-dev 
>>>> <lldb-dev@lists.llvm.org> wrote:
>>>> 
>>>> I ran into the error in the subject when running a python script with 
>>>> "script myfile.myscript()".
>>>> 
>>>> The value addr_t parameter used is 0x01223f68, the following works 
>>>> fine:
>>>> 
>>>> (lldb) scr
>>>> Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>>>>>> e = lldb.SBError()
>>>>>>> ptr = lldb.process.ReadPointerFromMemory(0x01223f68, e)
>>>>>>> print ptr
>>>> 0
>>>>>>> 
>>>> 
>>>> Any suggestion how to further investigate? Thanks.
>>>> 
>>>> myfile.myscript() calls the following function in a loop (iterate through 
>>>> all vtable symbols), which contains the call ReadPointerFromMemory.
>>>> 
>>>> def dump_vtbl(vtableAddr) :
>>>> error = lldb.SBError()
>>>> vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr+8, error)
>>>> if not error.success :
>>>> return False
>>>> print "vtable: [%0.16x, %0.16x)" % (vtableAddr, vtableEndAddr)
>>>> for addr in range(vtableAddr, vtableEndAddr, 8) :
>>>> print "read from address %.016x" % addr
>>>> try:
>>>> funcAddr = lldb.process.ReadPointerFromMemory(addr, error)
>>>> except:
>>>> sys.exc_clear()
>>>> continue
>>>> if not error.success :
>>>> continue
>>>> 
>>>> ___
>>>> lldb-dev mailing list
>>>> lldb-dev@lists.llvm.org
>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
>>> 
>> ___
>> lldb-dev mailing list
>> lldb-dev@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
> 

___
lldb-dev mailing list
lldb-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev


Re: [lldb-dev] OverflowError: in method 'SBProcess_ReadPointerFromMemory', argument 2 of type 'lldb::addr_t'

2016-09-19 Thread Greg Clayton via lldb-dev
Try printing the type of the value you are passing in the line:

vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr-8, error)

print type(vtableAddr)
print type(vtableAddr-8)

It seems like it thinks vtableAddr doesn't fit into a lldb::addr_t which is a 
uint64_t



> On Sep 16, 2016, at 7:39 PM, Lei Kong via lldb-dev <lldb-dev@lists.llvm.org> 
> wrote:
> 
> I tried printing error.descryption, but it didn't work, because when the 
> error happens, it seems ReadPointerFromMemory never returned to my code.
>  
>  
> read from address 01223f68
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
> 289, in findall
> findtypes(pattern,ignorePureVirtualType)
>   File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
> 246, in findtypes
> if ignorePureVirtualType and has_pure_virtual(vtableAddr, 
> pureVirtualFuncs) :
>   File "/home/leikong/repo/WindowsFabric/build.prod/test/fabdbg.py", line 
> 190, in has_pure_virtual
> vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr-8, error)
>   File "/home/leikong/bin/lldb/lib/python2.7/site-packages/lldb/__init__.py", 
> line 9418, in ReadPointerFromMemory
>     return _lldb.SBProcess_ReadPointerFromMemory(self, addr, error)
> OverflowError: in method 'SBProcess_ReadPointerFromMemory', argument 2 of 
> type 'lldb::addr_t'
> 
>  
> > Subject: Re: [lldb-dev] OverflowError: in method 
> > 'SBProcess_ReadPointerFromMemory', argument 2 of type 'lldb::addr_t'
> > From: jing...@apple.com
> > Date: Fri, 16 Sep 2016 17:12:24 -0700
> > CC: lldb-dev@lists.llvm.org
> > To: leik...@msn.com
> > 
> > You passed an error into ReadPointerFromMemory. In the cases where you 
> > aren't getting what you expect, what does that error say?
> > 
> > Jim
> > 
> > > On Sep 16, 2016, at 5:06 PM, Lei Kong via lldb-dev 
> > > <lldb-dev@lists.llvm.org> wrote:
> > > 
> > > I ran into the error in the subject when running a python script with 
> > > "script myfile.myscript()".
> > >  
> > > The value addr_t parameter used is 0x01223f68, the following 
> > > works fine:
> > > 
> > > (lldb) scr
> > > Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or 
> > > Ctrl-D.
> > > >>> e = lldb.SBError()
> > > >>> ptr = lldb.process.ReadPointerFromMemory(0x01223f68, e)
> > > >>> print ptr
> > > 0
> > > >>> 
> > >  
> > > Any suggestion how to further investigate? Thanks.
> > >  
> > > myfile.myscript() calls the following function in a loop (iterate through 
> > > all vtable symbols), which contains the call ReadPointerFromMemory.
> > >  
> > > def dump_vtbl(vtableAddr) :
> > > error = lldb.SBError()
> > > vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr+8, error)
> > > if not error.success :
> > > return False
> > > print "vtable: [%0.16x, %0.16x)" % (vtableAddr, vtableEndAddr)
> > > for addr in range(vtableAddr, vtableEndAddr, 8) :
> > > print "read from address %.016x" % addr
> > > try:
> > > funcAddr = lldb.process.ReadPointerFromMemory(addr, error)
> > > except:
> > > sys.exc_clear()
> > > continue
> > > if not error.success :
> > > continue
> > > 
> > > ___
> > > lldb-dev mailing list
> > > lldb-dev@lists.llvm.org
> > > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
> > 
> ___
> lldb-dev mailing list
> lldb-dev@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

___
lldb-dev mailing list
lldb-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev


Re: [lldb-dev] OverflowError: in method 'SBProcess_ReadPointerFromMemory', argument 2 of type 'lldb::addr_t'

2016-09-16 Thread Jim Ingham via lldb-dev
You passed an error into ReadPointerFromMemory.  In the cases where you aren't 
getting what you expect, what does that error say?

Jim

> On Sep 16, 2016, at 5:06 PM, Lei Kong via lldb-dev  
> wrote:
> 
> I ran into the error in the subject when running a python script with "script 
> myfile.myscript()".
>  
> The value addr_t parameter used is 0x01223f68, the following works 
> fine:
> 
> (lldb) scr
> Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
> >>> e = lldb.SBError()
> >>> ptr = lldb.process.ReadPointerFromMemory(0x01223f68, e)
> >>> print ptr
> 0
> >>> 
>  
> Any suggestion how to further investigate? Thanks.
>  
> myfile.myscript() calls the following function in a loop (iterate through all 
> vtable symbols), which contains the call ReadPointerFromMemory.
>  
> def dump_vtbl(vtableAddr) :
> error = lldb.SBError()
> vtableEndAddr = lldb.process.ReadPointerFromMemory(vtableAddr+8, error)
> if not error.success :
> return False
> print "vtable: [%0.16x, %0.16x)" % (vtableAddr, vtableEndAddr)
> for addr in range(vtableAddr, vtableEndAddr, 8) :
> print "read from address %.016x" % addr
> try:
> funcAddr = lldb.process.ReadPointerFromMemory(addr, error)
> except:
> sys.exc_clear()
> continue
> if not error.success :
> continue
> 
> ___
> lldb-dev mailing list
> lldb-dev@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

___
lldb-dev mailing list
lldb-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev