Skip to content

Commit

Permalink
signal for monitoring status
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddie committed Sep 15, 2023
1 parent bc35c6e commit 8e51b4f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
9 changes: 9 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(self):
self.elf_parser = ExtractGlobalVariablesThread(None, self.ui.tbl_vars)
self.var_watcher = MonitoringThread(self.vars_watched_dict)
self.var_watcher.signal_update_variable.connect(self.update_variable_in_table) # Assuming 'self.update_variable_in_table' is a method that handles the update
self.var_watcher.var_monitor_active.connect(self.update_var_monitor_active)
# USE CUSTOM TITLE BAR | USE AS "False" FOR MAC OR LINUX
Settings.ENABLE_CUSTOM_TITLE_BAR = False
# used to store the current popup window when selecting var type
Expand Down Expand Up @@ -793,6 +794,14 @@ def mousePressEvent(self, event):
if event.buttons() == Qt.RightButton:
pass
#print('Mouse click: RIGHT CLICK')
def update_var_monitor_active(self, state):
if state == False:
# change button text to start
self.ui.btn_monitor.setText.setText("Start")
else:
# change button text to stop
self.ui.btn_monitor.setText.setText("Stop")

def update_variable_in_table(self, var_name, value):
# Check if the variable name is in the dictionary
if var_name in self.vars_watched_dict:
Expand Down
3 changes: 1 addition & 2 deletions modules/btn_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,10 @@ def handle_symbol_extracted(name, address):
def start_monitoring(main_window):
if main_window.var_watcher.isRunning():
main_window.var_watcher.exit_early = True
main_window.ui.btn_monitor.setText("Start Monitoring")
main_window.stop_monitoringThread()
else:
main_window.var_watcher.start()
main_window.ui.btn_monitor.setText("Stop Monitoring")


def get_core_regs(main_window):
logger = logging.getLogger("PDexLogger")
Expand Down
4 changes: 4 additions & 0 deletions modules/elf_insights.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def run(self):

class MonitoringThread(QThread):
signal_update_variable = Signal(str, object) # Signal to update the variable value
var_monitor_active = Signal(bool)
monitor_active = False
exit_early = False
logger = logging.getLogger("PDexLogger")
Expand Down Expand Up @@ -99,13 +100,15 @@ def run(self):
self.logger.info("Monitoring variables ended")
self.exit_early = False
monitor_active = False
self.var_monitor_active.emit(False)
# TODO emit signal to update UI monitoring button
return

with probe:
monitor_active = True
target = probe.target
target.resume()
self.var_monitor_active.emit(True)
self.print_core_registers(target)
self.monitor_variables(target, self.address_dict)

Expand Down Expand Up @@ -150,6 +153,7 @@ def monitor_variables(self, target, addresses):
#target.close() # Replace this with the appropriate method to close the connection to the target
# You can also add any other cleanup code that needs to be executed here
self.logger.info("Monitoring variables ended")
self.var_monitor_active.emit(False)
self.exit_early = False
monitor_active = False

Expand Down

0 comments on commit 8e51b4f

Please sign in to comment.