[lldb-dev] No machine instructions loaded for symbols or target (python api)

2015-11-17 Thread kwadwo amankwa via lldb-dev

Hi,
I'm building an application on windows using the python api. I need to 
be able to access a code symbols instructions but when I launch the 
process the symbol has no instructions. I can manually read the symbols 
address space but the symbol also has no end_addr set which makes it 
difficult to tell where the symbol ends .
Can anybody help me to find out how to generate the instructions when 
the process is loaded ?


cheers,

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


Re: [lldb-dev] No machine instructions loaded for symbols or target (python api)

2015-11-17 Thread kwadwo amankwa via lldb-dev
Ok I see what you're saying. I was trying to use the next symbol address 
as a delimeter but I realised they were not in order.  It is a PECOFF 
binary that I'm debugging so I will take a look at the code suggested 
below.


Thanks ,

Que

On 17/11/15 18:07, Greg Clayton wrote:

It sounds like the symbols in the symbol table don't have valid sizes when they 
really should. What kind of executable are you debugging? A PECOFF file? If so, 
you should take a look at and fix the code in:

Symtab *
ObjectFilePECOFF::GetSymtab()

What we do for mach-o is to parse the symbol table first and then run back 
through all symbols, and any symbol that have a size of zero, set their sizes 
to the delta between the current symbol and the next addressed symbol. Since 
the symbols are usually out of order address wise, we run through all symbols 
that have addresses and add their indexes to a std::vector, then sort the 
vector of address indexes, and then we can do the above fixups.

Greg Clayton



On Nov 17, 2015, at 4:21 AM, kwadwo amankwa via lldb-dev 
<lldb-dev@lists.llvm.org> wrote:

Hi,
I'm building an application on windows using the python api. I need to be able 
to access a code symbols instructions but when I launch the process the symbol 
has no instructions. I can manually read the symbols address space but the 
symbol also has no end_addr set which makes it difficult to tell where the 
symbol ends .
Can anybody help me to find out how to generate the instructions when the 
process is loaded ?

cheers,

Que
___
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] How to disassemble a section (python api)?

2015-11-13 Thread kwadwo amankwa via lldb-dev



On 13/11/15 19:31, Greg Clayton wrote:

Currently you can't disassemble a section, nor would you probably want to since 
there are padding bytes in between functions.

The easiest way is to get all SBSymbol objects and ask each one for the 
instructions if they are code:

(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.

module = lldb.target.module['a.out']
num_symbols = module.GetNumSymbols()
for i in range(num_symbols):

... symbol = module.GetSymbolAtIndex(i)
... if symbol.GetType() == lldb.eSymbolTypeCode:
... print symbol
... instructions = symbol.GetInstructions(lldb.target)
... for inst in instructions:
... print inst
...
id = {0x0004}, range = [0x00010f00-0x00010f20), name="foo(float)", 
mangled="_Z3foof"
a.out[0x10f00]: pushq  %rbp
a.out[0x10f01]: movq   %rsp, %rbp
a.out[0x10f04]: movss  %xmm0, -0x4(%rbp)
a.out[0x10f09]: cvttss2si -0x4(%rbp), %eax
a.out[0x10f0e]: shll   $0x1, %eax
a.out[0x10f11]: popq   %rbp
a.out[0x10f12]: retq
a.out[0x10f13]: nopw   %cs:(%rax,%rax)
id = {0x0008}, range = [0x00010f20-0x00010f40), name="foo(int)", 
mangled="_Z3fooi"
a.out[0x10f20]: pushq  %rbp
a.out[0x10f21]: movq   %rsp, %rbp
a.out[0x10f24]: movl   %edi, -0x4(%rbp)
a.out[0x10f27]: movl   -0x4(%rbp), %edi
a.out[0x10f2a]: shll   $0x2, %edi
a.out[0x10f2d]: movl   %edi, %eax
a.out[0x10f2f]: popq   %rbp
a.out[0x10f30]: retq
a.out[0x10f31]: nopw   %cs:(%rax,%rax)
id = {0x000c}, range = [0x00010f40-0x00010f90), name="main"
a.out[0x10f40]: pushq  %rbp
a.out[0x10f41]: movq   %rsp, %rbp
a.out[0x10f44]: subq   $0x30, %rsp
a.out[0x10f48]: movss  0x40(%rip), %xmm0
a.out[0x10f50]: movl   $0x0, -0x4(%rbp)
a.out[0x10f57]: movl   %edi, -0x8(%rbp)
a.out[0x10f5a]: movq   %rsi, -0x10(%rbp)
a.out[0x10f5e]: movq   %rdx, -0x18(%rbp)
a.out[0x10f62]: movss  %xmm0, -0x1c(%rbp)
a.out[0x10f67]: movl   $0x4d2, -0x20(%rbp)
a.out[0x10f6e]: movss  -0x1c(%rbp), %xmm0
a.out[0x10f73]: callq  0x10f00
a.out[0x10f78]: movl   -0x20(%rbp), %edi
a.out[0x10f7b]: movl   %eax, -0x24(%rbp)
a.out[0x10f7e]: callq  0x10f20
a.out[0x10f83]: movl   -0x24(%rbp), %edi
a.out[0x10f86]: addl   %eax, %edi
a.out[0x10f88]: movl   %edi, %eax
a.out[0x10f8a]: addq   $0x30, %rsp
a.out[0x10f8e]: popq   %rbp
a.out[0x10f8f]: retq

If you want the symbols only from a specific section you can get the section 
from the symbol's start address and compare that to a given name:

section_name = ".text"
for i in range(num_symbols):
 symbol = module.GetSymbolAtIndex(i)
 if symbol.GetType() == lldb.eSymbolTypeCode:
 symbol_section = symbol.GetStartAddress().GetSection()
 if symbol_section.GetName() == section_name:
 print symbol
 instructions = symbol.GetInstructions(lldb.target)
 for inst in instructions:
         print inst






On Nov 12, 2015, at 2:13 PM, kwadwo amankwa via lldb-dev 
<lldb-dev@lists.llvm.org> wrote:

Hi
I'm writing a small script and need to disassemble a whole section , what would 
be the correct way to go about it ?

Cheers Que,
___
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] " Import error: No module named embedded_interpreter" on windows

2015-10-05 Thread kwadwo amankwa via lldb-dev
e you using MSBuild or Ninja to build (i.e. are you
clicking the Build Solution button in Visual Studio or
running ninja from command line)?  I don't know where it
puts this stuff with a VS2013 build, but with a ninja build,
your directory will be organized like this:

build
|___bin
 |___lldb.exe
 |___liblldb.dll
|___lib
 |___site-packages
   |___lldb
 |___lldb_d.pyd   // If this is a debug
build, lldb.pyd if release

    I'm betting you're missing the pyd file. Can you confirm?
Then we can diagnose that if it turns out to be the problem.

On Mon, Oct 5, 2015 at 5:20 AM kwadwo amankwa via lldb-dev
<lldb-dev@lists.llvm.org <mailto:lldb-dev@lists.llvm.org>>
wrote:

Hi guys,

Can someone point me in the right direction on this . I
have managed to
set up my environment on windows , compiling
python2.7.10 using VS2013
and building llvm/lldb in VS2013. lldb and all its
libraries build
successfully so its just when I import lldb into my
python project I get
this error.

File "", line 1, in 
Import error: No module named embedded_interpreter

  Also when I use the 'script' command in the lldb
interpreter , lldb
completely crashes  with an unhandled exception in the 
python

file_write  function (fileobject.c:1852)

n2 = fwrite(s, 1, n, f->f_fp);

the call to fwrite causes an access violation . My
intuition tells me
that i'm missing  a lib or something but I can't put my
finger on it.
Please Help !


___
lldb-dev mailing list
lldb-dev@lists.llvm.org <mailto: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