Commit f74dc0f5 authored by Simon Sobisch's avatar Simon Sobisch Committed by Simon Sobisch
Browse files

cleanup for exception checks

parent cbfcece4
......@@ -4496,8 +4496,9 @@ class ModuleState():
# sanity check first
try:
gdb.selected_frame()
except gdb.error:
ConditionalRaise("No stack.")
except gdb.error as ex:
# Depending on the scenario commonly raises one of "No stack.", "No frame currently selected." or others
ConditionalRaise(str(ex))
return
# Go read the frame and stack, and, if necessary, fetch the VARIABLE_STRING
......@@ -5519,13 +5520,6 @@ class CPrintWorker():
if not args or not args[0]:
return
# Since there are additional arguments, we're going to need a stack
# to work with. We do the test here so that instructions like
# cprint/v3
# get processed even though no debugging has started.
GV_ModuleState.EstablishModuleState(True)
if args[0][0] == '"':
# The user is talking to himself for some reason. Just play along.
self.HandleDoubleQuote(arguments)
......@@ -5541,7 +5535,7 @@ class CPrintWorker():
# "No stack." is the message GDB reports when debugging statements
# are issued when the program hasn't been run, which is checked in the
# caller, we get here for "internal" reasons during resolve.
ConditionalRaise("No stack.")
ConditionalRaise("This doesn't look like a COBOL frame.")
return
# Initialize for subsequent processing:
......@@ -5672,8 +5666,8 @@ class CPrintWorker():
class CobolAfterWatchBreakpoint(gdb.Breakpoint):
def __init__(self, creating_wp):
if GV_GlobalVariables.gdb_version < 80300:
ConditionalRaise("pure COBOL cwatch needs GDB 8.3+")
return
# sanity check, this code is only executed on manual function call
raise gdb.GdbError("pure COBOL cwatch needs GDB 8.3+")
frame = gdb.newest_frame()
cob_frame = CFrameWorker.Frame(True, 0)
......@@ -5767,8 +5761,8 @@ class CobolWatchpointHandler():
class CobolWatchBreakpoint(gdb.Breakpoint):
def __init__(self, payload, bp_spec, bp_action):
if GV_GlobalVariables.gdb_version < 80300:
ConditionalRaise("pure COBOL cwatch needs GDB 8.3+")
return
# sanity check, this code is only executed on manual function call
raise gdb.GdbError("pure COBOL cwatch needs GDB 8.3+")
try:
super(CobolWatchBreakpoint, self).__init__(bp_spec, gdb.BP_WATCHPOINT, bp_action)
CBLDBG_CBREAK_WORKER.cobol_breaks.append(self)
......@@ -5903,6 +5897,9 @@ class CobolBreakpoint(gdb.Breakpoint):
else:
super(CobolBreakpoint, self).__init__(bp_spec, type=gdb.BP_BREAKPOINT, internal=i_flag)
CBLDBG_CBREAK_WORKER.cobol_breaks.append(self)
except gdb.error:
# pass errors as is, most likely: malformed bp_spec
raise
except Exception as ex:
ConditionalRaise(ex)
return
......@@ -6304,6 +6301,7 @@ class CPrint(gdb.Command):
def invoke(self, arguments, from_tty):
try:
GV_ModuleState.EstablishModuleState(True) # we want errors seen early
self.worker.ProcessArguments(arguments)
# pass user errors unchanged
except gdb.GdbError:
......@@ -6891,8 +6889,9 @@ class CFrameWorker:
try:
frame = gdb.selected_frame()
except gdb.error:
ConditionalRaise("No stack.")
except gdb.error as ex:
# Depending on the scenario commonly raises one of "No stack.", "No frame currently selected." or others
ConditionalRaise(str(ex))
return
while True:
......@@ -7025,8 +7024,9 @@ Applies to any out-of-line PERFORM."""
# sanity check: Do we have any frame at all?
try:
frame = gdb.selected_frame()
except gdb.error:
ConditionalRaise("No stack.")
except gdb.error as ex:
# Depending on the scenario commonly raises one of "No stack.", "No frame currently selected." or others
ConditionalRaise(str(ex))
return
if not CFrameWorker.is_cobol_inner_frame(frame):
......@@ -7052,8 +7052,9 @@ class CFinishModule(gdb.Command):
# sanity check: Do we have any frame at all?
try:
frame = gdb.selected_frame()
except gdb.error:
ConditionalRaise("No stack.")
except gdb.error as ex:
# Depending on the scenario commonly raises one of "No stack.", "No frame currently selected." or others
ConditionalRaise(str(ex))
return
cobol, inner = CFrameWorker.is_cobol_frame(frame)
......@@ -7082,8 +7083,9 @@ class CUntilCobol(gdb.Command):
# the only reason also done here is the use of ConditionalRaise
try:
frame = gdb.selected_frame()
except gdb.error:
ConditionalRaise("No stack.")
except gdb.error as ex:
# Depending on the scenario commonly raises one of "No stack.", "No frame currently selected." or others
ConditionalRaise(str(ex))
return
cob_frame = CFrameWorker.Frame(True, 0)
......@@ -7213,8 +7215,9 @@ class CLocalBacktrace(gdb.Command):
# sanity check: Do we have any frame at all?
try:
frame = gdb.selected_frame()
except gdb.error:
ConditionalRaise("No stack.")
except gdb.error as ex:
# Depending on the scenario commonly raises one of "No stack.", "No frame currently selected." or others
ConditionalRaise(str(ex))
return
if not CFrameWorker.is_cobol_inner_frame(frame):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment