Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Seva Alekseyev committed Feb 6, 2020
1 parent 6e89bfd commit b913aed
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ debugging information in executable files, built on top of of [pyelftools](https
- Mach-O (MacOS X, iOS)
- PE (Windows, Cygwin)

This project came from my desire to see and navigate the DWARF tree of compiled binaries. Seeing the DIEs is easy enough with utilities like `readelf` or `dwarfdump`. However, chasing inter-DIE references back and forth is not straightforward with those.
This project came from my desire to see and navigate the DWARF tree of compiled Android and iOS binaries. Seeing the DIEs is easy enough with utilities like `readelf` or `dwarfdump`. However, chasing inter-DIE references back and forth is not straightforward with those.

The utility might be of use for anyone who is building DWARF parsers for one or another reason, especially if their preferred parsing library is `pyelftools`.

Note that regular Windows executables (EXE/DLL files) are PE files but don't, as a rule, contain DWARF information. The Microsoft toolchains (Visual Studio and the like) produce debugging information in Microsoft's own format, Program Database (PDB). There are, though, a couple of toolchains that produce PE files with DWARF debug info in them - notably GCC under Cygwin. DWARF Explorer is compatible with those.

DWARF Explorer supports DWARF version 2-4, like the pyelftools library it's based on.

Requirements
------------
- Python 3.5+
Expand All @@ -19,15 +23,16 @@ Requirements
Installlation
-------------

Run `pip install dwex`, under `sudo` if necessary.
Run `pip install dwex` from the command line, under `sudo` or elevated command line if necessary.

On Windows, if `pip` and/or Python is not in PATH, use `c:\Python38\python -m pip install dwex`, substituting your own path to Python 3.

Alternatively, get the Python sources from Github, and run `python setup.py install` using your favorite Python 3 interpreter in the root folder of the package. In this scenario, you'd have
to install PyQt5 separately - with `pip install pyqt5`.
Alternatively, get the Python source tree from Github, and run `python setup.py install` in the root folder of the package. In this scenario, you'd have to install PyQt5 separately - with `pip install pyqt5`.

On Windows, if `pip` and/or Python is not in PATH, use `c:\Python35\python -m pip install pyqt5`, substituting your own path to Python.
On Linux, sometimes the `python` command defaults to Python 2 while Python 3 is installed side by side. In this case, use `python3` and `pip3`, respectively. Use `python -V` to check.

Once you install it, there will be a `dwex` command. On Windows, there will be a `dwex.exe` in
`Scripts` under the Python folder, and also a start menu item "DWARF Explorer".
the `Scripts` folder under the Python folder, and also a start menu item "DWARF Explorer".

Usage
-----
Expand Down
7 changes: 4 additions & 3 deletions dwex/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys, os, io
import sys, os, io, platform
from PyQt5.QtCore import Qt, QAbstractItemModel, QAbstractTableModel, QModelIndex, QSettings, QUrl
from PyQt5.QtGui import QFontMetrics, QKeySequence, QDesktopServices
from PyQt5.QtWidgets import *
Expand All @@ -7,14 +7,15 @@
from .tree import DWARFTreeModel, has_code_location
from .scriptdlg import ScriptDlg

version=(0,51)
version=(0,52)

# TODO:
# Low level raw bytes for expressions in location lists
# Autotest on corpus
# What else is section_offset?
# const_value as FORM_block1: an array of 4 bytes, found in iOS/4.69.8/ARMv7/DecompItem.mm
# Test back-forward mouse buttons
# On MacOS, start without a main window, instead show the Open dialog


#-----------------------------------------------------------------
Expand Down Expand Up @@ -446,7 +447,6 @@ def on_updatecheck(self):
try:
self.start_wait()
resp = urlopen('https://api.github.com/repos/sevaa/dwex/releases')
#resp = urlopen('https://api.github.com/repos/jazzband/pip-tools/releases')
if resp.getcode() == 200:
releases = resp.read()
self.end_wait()
Expand Down Expand Up @@ -572,5 +572,6 @@ def main():
the_window = TheWindow()
the_app.exec_()

# For running via "python -m dwex"
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion dwex/die.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def format_value(self, attr):
elif val == b'':
return '[]'
else:
return hex(val)
return val.hex()
elif form == 'DW_FORM_addr' and isinstance(val, int):
return hex(val)
elif form == 'DW_FORM_flag_present':
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def run(self):

setup(
name='dwex',
version='0.51',
version='0.52',
packages=['dwex',
'dwex.dwex_elftools',
'dwex.dwex_elftools.elf',
Expand Down
8 changes: 4 additions & 4 deletions test/testall.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os, sys
from PyQt5.QtCore import Qt, QAbstractItemModel, QAbstractTableModel, QModelIndex
sys.path.insert(1, os.path.join(os.getcwd(), "dwex"))
from elftools.dwarf.locationlists import LocationParser, LocationExpr
from formats import read_dwarf
from die import DIETableModel
from tree import strip_path
from dwex.dwex_elftools.dwarf.locationlists import LocationParser, LocationExpr
from dwex.formats import read_dwarf
from dwex.die import DIETableModel
from dwex.tree import strip_path

def test_dwarfinfo(di):
# Some global cache setup in line with the app proper
Expand Down

0 comments on commit b913aed

Please sign in to comment.