Skip to content

Commit

Permalink
Fix Stack and StackTrace exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
korcankaraokcu committed Aug 27, 2023
1 parent 7d3a604 commit 162b254
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
11 changes: 11 additions & 0 deletions PINCE.py
Original file line number Diff line number Diff line change
Expand Up @@ -3214,6 +3214,12 @@ def on_process_stop(self):
self.update_stacktrace()
elif self.stackedWidget_StackScreens.currentWidget() == self.Stack:
self.update_stack()

# These tableWidgets are never emptied but initially both are empty, so this runs only once
if self.tableWidget_StackTrace.rowCount() == 0:
self.update_stacktrace()
if self.tableWidget_Stack.rowCount() == 0:
self.update_stack()
self.refresh_hex_view()
if bring_disassemble_to_front:
self.showMaximized()
Expand Down Expand Up @@ -4059,10 +4065,15 @@ def __init__(self, parent=None):

def update_stacktrace(self):
self.listWidget_ReturnAddresses.clear()
if GDB_Engine.inferior_status == type_defs.INFERIOR_STATUS.INFERIOR_RUNNING:
return
return_addresses = GDB_Engine.get_stack_frame_return_addresses()
self.listWidget_ReturnAddresses.addItems(return_addresses)

def update_frame_info(self, index):
if GDB_Engine.inferior_status == type_defs.INFERIOR_STATUS.INFERIOR_RUNNING:
self.textBrowser_Info.setText(tr.PROCESS_RUNNING)
return
frame_info = GDB_Engine.get_stack_frame_info(index)
self.textBrowser_Info.setText(frame_info)

Expand Down
5 changes: 5 additions & 0 deletions i18n/ts/it_IT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,11 @@ To change the current GDB path, check Settings-&gt;Debug</source>
<source>[stopped]</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../../tr/tr.py" line="0" />
<source>Process is running</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../../tr/tr.py" line="0" />
<source>Enter the new value</source>
Expand Down
5 changes: 5 additions & 0 deletions i18n/ts/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,11 @@ To change the current GDB path, check Settings-&gt;Debug</source>
<source>[stopped]</source>
<translation>[已停止]</translation>
</message>
<message>
<location filename="../../tr/tr.py" line="0" />
<source>Process is running</source>
<translation type="unfinished" />
</message>
<message>
<location filename="../../tr/tr.py" line="0" />
<source>Enter the new value</source>
Expand Down
10 changes: 8 additions & 2 deletions libpince/gdb_python_scripts/GDBCommandExtensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ def invoke(self, arg, from_tty):

# +1 because frame numbers start from 0
for item in range(int(max_frame) + 1):
result = gdb.execute("info frame " + str(item), from_tty, to_string=True)
try:
result = gdb.execute(f"info frame {item}", from_tty, to_string=True)
except:
break
frame_address = common_regexes.frame_address.search(result).group(1)
difference = hex(int(frame_address, 16) - stack_pointer)
frame_address_with_difference = frame_address + "(" + sp_register + "+" + difference + ")"
Expand Down Expand Up @@ -215,7 +218,10 @@ def invoke(self, arg, from_tty):

# +1 because frame numbers start from 0
for item in range(int(max_frame) + 1):
result = gdb.execute("info frame " + str(item), from_tty, to_string=True)
try:
result = gdb.execute(f"info frame {item}", from_tty, to_string=True)
except:
break
return_address = common_regexes.return_address.search(result)
if return_address:
return_address_with_info = ScriptUtils.examine_expression(return_address.group(1)).all
Expand Down
1 change: 1 addition & 0 deletions tr/tr.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def translate():
NO_PROCESS_SELECTED = QT_TR_NOOP("No Process Selected")
STATUS_DETACHED = QT_TR_NOOP("[detached]")
STATUS_STOPPED = QT_TR_NOOP("[stopped]")
PROCESS_RUNNING = QT_TR_NOOP("Process is running")
ENTER_VALUE = QT_TR_NOOP("Enter the new value")
ENTER_DESCRIPTION = QT_TR_NOOP("Enter the new description")
EDIT_ADDRESS = QT_TR_NOOP("Edit Address")
Expand Down

0 comments on commit 162b254

Please sign in to comment.