rajeshgangam / pydevtools

Automatically exported from code.google.com/p/pydevtools
Other
0 stars 0 forks source link

dwarfdump is unable to handle Ubuntu vmlinux file #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Output:

root@newubuntu:~/debug/usr/lib/debug/boot# dwarfdump.py 
vmlinux-2.6.32-27-generic
Traceback (most recent call last):
  File "/usr/local/bin/dwarfdump.py", line 5, in <module>
    pkg_resources.run_script('DevTools==0.1.0', 'dwarfdump.py')
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 461, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1194, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/local/lib/python2.6/dist-packages/DevTools-0.1.0-py2.6.egg/EGG-INFO/scripts/dwarfdump.py", line 19, in <module>
    benchmark(dwarfdump, file_path)
  File "/usr/local/lib/python2.6/dist-packages/DevTools-0.1.0-py2.6.egg/devtools/utils/__init__.py", line 90, in benchmark
    func(*args, **kargs)
  File "/usr/local/lib/python2.6/dist-packages/DevTools-0.1.0-py2.6.egg/EGG-INFO/scripts/dwarfdump.py", line 9, in dwarfdump
    dwarf = DWARF(file_path)
  File "/usr/local/lib/python2.6/dist-packages/DevTools-0.1.0-py2.6.egg/devtools/dwarf/__init__.py", line 35, in __init__
    self.info = DebugInfoLoader(self)
  File "/usr/local/lib/python2.6/dist-packages/DevTools-0.1.0-py2.6.egg/devtools/dwarf/info.py", line 168, in __init__
    cu = CU(dwarf, overall_offset)
  File "/usr/local/lib/python2.6/dist-packages/DevTools-0.1.0-py2.6.egg/devtools/dwarf/info.py", line 110, in __init__
    die = DIE(dwarf, self, abbrevs, level)
  File "/usr/local/lib/python2.6/dist-packages/DevTools-0.1.0-py2.6.egg/devtools/dwarf/info.py", line 60, in __init__
    value = dwarf.read_expr_block(attrib_form.form)
  File "/usr/local/lib/python2.6/dist-packages/DevTools-0.1.0-py2.6.egg/devtools/dwarf/stream.py", line 130, in read_expr_block
    raise ParseError("Not an expression block: %s" % DW_FORM[type])
devtools.elf.exception.ParseError: Not an expression block: data4

When I run dwarfdump/objdump they are able to handle the file fine, but I was 
hoping to pydevtools to script some things out when I encountered this error. 
Unfortunately, the vmlinux file is 133MB so I can't upload it, but you can 
download the file if you want from:

http://ddebs.ubuntu.com/pool/main/l/linux/linux-image-2.6.32-27-generic-dbgsym_2
.6.32-27.49_i386.ddeb

you can extract the vmlinux from the ddeb and test from there or if there is 
more information I can provide then please just respond to this bug filing.

Original issue reported on code.google.com by atc...@gmail.com on 29 Dec 2010 at 7:39

GoogleCodeExporter commented 8 years ago
This is my analysis of the problem. 

* Location descriptors can take two forms - expressions and lists. The current 
code only handles the former. In more detail __init__ for DIE assumes that all 
DW_AT_location and DW_AT_data_member_location attributes must be of one of the 
"block" forms. Which is true for "expression" location descriptors. But is not 
true for "list" location descriptors (they are encoded as a "data" form).

* The opposite problem exists for DW_AT_frame_base. The code currently assumes 
that those are all location lists. But DW_AT_frame_base can also be a location 
expression.

I've tested fixes for these problems but am unable to share those at this stage 
due to internal company restrictions. I will post the diff as soon as I get 
approval. But perhaps the above analysis is enough for the official code 
maintainers to push out a fix earlier.

Original comment by alan.q...@gmail.com on 6 Jan 2012 at 12:46

GoogleCodeExporter commented 8 years ago
Have you tried the latest version directly from SVN? I made some changes on 
this code about a month ago, so it might already work.

Original comment by stefan.h...@gmail.com on 19 Jan 2012 at 6:15

GoogleCodeExporter commented 8 years ago
Yep, the latest code works better and seems to have resolved this problem.

Though I did have to work around this new problem:

$ ./dwarfdump.py 
Traceback (most recent call last):
  File "./dwarfdump.py", line 20, in <module>
    benchmark(dwarfdump, file_path)
  File "../bintools/utils/__init__.py", line 90, in benchmark
    func(*args, **kargs)
  File "./dwarfdump.py", line 10, in dwarfdump
    dwarf = DWARF(file_path)
  File "../bintools/dwarf/__init__.py", line 35, in __init__
    self.info = DebugInfoLoader(self)
  File "../bintools/dwarf/info.py", line 162, in __init__
    cu = CU(dwarf, overall_offset)
  File "../bintools/dwarf/info.py", line 105, in __init__
    die = DIE(dwarf, self, abbrevs, level)
  File "../bintools/dwarf/info.py", line 59, in __init__
    a = Attrib(cu, attrib_form)
  File "../bintools/dwarf/info.py", line 17, in __init__
    self.value = self.cu.dwarf.read_form(attrib_form.form)
  File "../bintools/dwarf/stream.py", line 85, in read_form
    return self.read_type(DW_FORM[form])
  File "../bintools/dwarf/stream.py", line 81, in read_type
    return getattr(self, 'read_'+type_name)()
  File "../bintools/dwarf/stream.py", line 94, in read_string
    if not c[0]: break
IndexError: string index out of range

Original comment by alan.q...@gmail.com on 19 Jan 2012 at 11:29

GoogleCodeExporter commented 8 years ago
Ups! That was my bad. I'm using Python3, so I forgot to check for Python2 
compatibility before commit.
r29 should have that fixed. Please double check that it works for you. Then we 
can close this issue. Thanks!

Original comment by stefan.h...@gmail.com on 21 Jan 2012 at 6:37