-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial Cutter integration #65
Open
xarkes
wants to merge
19
commits into
gaasedelen:develop
Choose a base branch
from
xarkes:cutter_integration
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d627dc1
First pass to add Cutter support
xarkes 20e0572
Use PySide2 for Cutter
xarkes a8488ca
Raising Coverage window upon creation for Cutter
xarkes 1c21bf4
Improved rename hook for Cutter
xarkes 9fa0e5d
Added graph highlighting for Cutter
xarkes d1f46ff
Shutdown Lighthouse on terminate() in Cutter
thestr4ng3r 7ade475
Code cleanup
xarkes 76047d8
Fixed logic bug in _find_fuzzy_name
xarkes 96e0bbf
Cleanup
xarkes bfd7818
additional cleanup
gaasedelen 0e7945b
print to cutter console
gaasedelen c335d02
refresh cutter graph on update
gaasedelen 8dac7ad
remove cutter specific conditional from core
gaasedelen 4717836
Merge branch 'develop' of https://github.com/gaasedelen/lighthouse in…
gaasedelen 6f607b3
fixes bug where external edges were being added to function graph
gaasedelen 2ded7d8
rename hooks still don't work??
gaasedelen 868229a
better handling of cutter api requests
gaasedelen 22dc30d
misc bugfix
gaasedelen 426cb54
help catch errors while debugging perf / metadata collection
gaasedelen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import logging | ||
|
||
import cutter | ||
from lighthouse.core import Lighthouse | ||
from lighthouse.util.disassembler import disassembler as disas | ||
from lighthouse.util.qt import * | ||
|
||
logger = logging.getLogger("Lighthouse.Cutter.Integration") | ||
|
||
|
||
#------------------------------------------------------------------------------ | ||
# Lighthouse Cutter Integration | ||
#------------------------------------------------------------------------------ | ||
|
||
class LighthouseCutter(Lighthouse): | ||
""" | ||
Lighthouse UI Integration for Cutter. | ||
""" | ||
|
||
def __init__(self, plugin, main): | ||
super(LighthouseCutter, self).__init__() | ||
self.plugin = plugin | ||
self.main = main | ||
# Small hack to give main window to DockWidget | ||
disas.main = main | ||
|
||
def interactive_load_file(self, unk): | ||
super(LighthouseCutter, self).interactive_load_file() | ||
|
||
def interactive_load_batch(self, unk): | ||
super(LighthouseCutter, self).interactive_load_batch() | ||
|
||
def _install_load_file(self): | ||
action = QtWidgets.QAction("Lighthouse - Load code coverage file...", self.main) | ||
action.triggered.connect(self.interactive_load_file) | ||
self.main.addMenuFileAction(action) | ||
logger.info("Installed the 'Code coverage file' menu entry") | ||
|
||
def _install_load_batch(self): | ||
action = QtWidgets.QAction("Lighthouse - Load code coverage batch...", self.main) | ||
action.triggered.connect(self.interactive_load_batch) | ||
self.main.addMenuFileAction(action) | ||
logger.info("Installed the 'Code coverage batch' menu entry") | ||
|
||
def _install_open_coverage_overview(self): | ||
logger.info("TODO - Coverage Overview menu entry?") | ||
|
||
def _uninstall_load_file(self): | ||
pass | ||
|
||
def _uninstall_load_batch(self): | ||
pass | ||
|
||
def _uninstall_open_coverage_overview(self): | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import logging | ||
|
||
import CutterBindings | ||
from lighthouse.cutter_integration import LighthouseCutter | ||
|
||
logger = logging.getLogger('Lighthouse.Cutter.Loader') | ||
|
||
#------------------------------------------------------------------------------ | ||
# Lighthouse Cutter Loader | ||
#------------------------------------------------------------------------------ | ||
# | ||
# The Cutter plugin loading process is quite easy. All we need is a function | ||
# create_cutter_plugin that returns an instance of CutterBindings.CutterPlugin | ||
|
||
class LighthouseCutterPlugin(CutterBindings.CutterPlugin): | ||
name = 'Ligthouse' | ||
description = 'Lighthouse plugin for Cutter.' | ||
version = '1.0' | ||
author = 'xarkes' | ||
|
||
def __init__(self): | ||
super(LighthouseCutterPlugin, self).__init__() | ||
self.ui = None | ||
|
||
def setupPlugin(self): | ||
pass | ||
|
||
def setupInterface(self, main): | ||
self.main = main | ||
self.ui = LighthouseCutter(self, main) | ||
self.ui.load() | ||
|
||
def terminate(self): | ||
if self.ui: | ||
self.ui.unload() | ||
|
||
|
||
def create_cutter_plugin(): | ||
try: | ||
return LighthouseCutterPlugin() | ||
except Exception as e: | ||
print('ERROR ---- ', e) | ||
import sys, traceback | ||
traceback.print_exc() | ||
raise e | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import logging | ||
|
||
import cutter | ||
|
||
from lighthouse.util.qt import QtGui | ||
from lighthouse.palette import to_rgb | ||
from lighthouse.painting import DatabasePainter | ||
from lighthouse.util.disassembler import disassembler | ||
|
||
logger = logging.getLogger("Lighthouse.Painting.Cutter") | ||
|
||
#------------------------------------------------------------------------------ | ||
# Cutter Painter | ||
#------------------------------------------------------------------------------ | ||
|
||
class CutterPainter(DatabasePainter): | ||
""" | ||
Asynchronous Cutter database painter. | ||
""" | ||
PAINTER_SLEEP = 0.01 | ||
|
||
def __init__(self, director, palette): | ||
super(CutterPainter, self).__init__(director, palette) | ||
|
||
#-------------------------------------------------------------------------- | ||
# Paint Primitives | ||
#-------------------------------------------------------------------------- | ||
|
||
# | ||
# NOTE: | ||
# due to the manner in which Cutter implements basic block | ||
# (node) highlighting, I am not sure it is worth it to paint individual | ||
# instructions. for now we, will simply make the instruction | ||
# painting functions no-op's | ||
# | ||
|
||
def _paint_instructions(self, instructions): | ||
self._action_complete.set() | ||
|
||
def _clear_instructions(self, instructions): | ||
self._action_complete.set() | ||
|
||
def _paint_nodes(self, nodes_coverage): | ||
b, g, r = to_rgb(self.palette.coverage_paint) | ||
color = QtGui.QColor(r, g, b) | ||
for node_coverage in nodes_coverage: | ||
node_metadata = node_coverage.database._metadata.nodes[node_coverage.address] | ||
disassembler._core.getBBHighlighter().highlight(node_coverage.address, color) | ||
self._painted_nodes.add(node_metadata.address) | ||
self._action_complete.set() | ||
|
||
def _clear_nodes(self, nodes_metadata): | ||
for node_metadata in nodes_metadata: | ||
disassembler._core.getBBHighlighter().clear(node_metadata.address) | ||
self._painted_nodes.discard(node_metadata.address) | ||
self._action_complete.set() | ||
|
||
def _refresh_ui(self): | ||
cutter.refresh() # TODO/CUTTER: Need a graph specific refresh... | ||
|
||
def _cancel_action(self, job): | ||
pass | ||
|
||
#-------------------------------------------------------------------------- | ||
# Priority Painting | ||
#-------------------------------------------------------------------------- | ||
|
||
def _priority_paint(self): | ||
current_address = disassembler.get_current_address() | ||
current_function = disassembler.get_function_at(current_address) | ||
if current_function: | ||
self._paint_function(current_function['offset']) | ||
return True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may have been to account for a bug I fixed in a55ede7, I will see if it is safe to remove this change from your code now.