Commit 0ca73a7e authored by Mark Florisson's avatar Mark Florisson

More graceful error handling in 'cy bt' when there is no C debug information

parent cfe5930a
...@@ -237,7 +237,7 @@ class CythonBase(object): ...@@ -237,7 +237,7 @@ class CythonBase(object):
lexer = pygments.lexers.PythonLexer() lexer = pygments.lexers.PythonLexer()
else: else:
symbol_and_line_obj = frame.find_sal() symbol_and_line_obj = frame.find_sal()
if symbol_and_line_obj is None: if not symbol_and_line_obj or not symbol_and_line_obj.symtab:
filename = None filename = None
lineno = 0 lineno = 0
else: else:
...@@ -279,7 +279,7 @@ class CythonBase(object): ...@@ -279,7 +279,7 @@ class CythonBase(object):
# variable not initialized yet # variable not initialized yet
pass pass
@default_selected_gdb_frame() @default_selected_gdb_frame(err=False)
def print_stackframe(self, frame, index, is_c=False): def print_stackframe(self, frame, index, is_c=False):
""" """
Print a C, Cython or Python stack frame and the line of source code Print a C, Cython or Python stack frame and the line of source code
...@@ -290,8 +290,12 @@ class CythonBase(object): ...@@ -290,8 +290,12 @@ class CythonBase(object):
selected_frame = gdb.selected_frame() selected_frame = gdb.selected_frame()
frame.select() frame.select()
source_desc, lineno = self.get_source_desc(frame) try:
source_desc, lineno = self.get_source_desc(frame)
except NoFunctionNameInFrameError:
print '#%-2d Unknown Frame (compile with -g)' % index
return
if not is_c and self.is_python_function(frame): if not is_c and self.is_python_function(frame):
pyframe = libpython.Frame(frame).get_pyop() pyframe = libpython.Frame(frame).get_pyop()
if pyframe is None or pyframe.is_optimized_out(): if pyframe is None or pyframe.is_optimized_out():
...@@ -318,13 +322,13 @@ class CythonBase(object): ...@@ -318,13 +322,13 @@ class CythonBase(object):
# Seriously? Why is the address not an int? # Seriously? Why is the address not an int?
func_address = int(str(gdb_value.address).split()[0], 0) func_address = int(str(gdb_value.address).split()[0], 0)
print '#%-2d 0x%016x in %s(%s) at %s:%s' % ( a = ', '.join('%s=%s' % (name, val) for name, val in func_args)
index, print '#%-2d 0x%016x in %s(%s)' % (index, func_address, func_name, a),
func_address,
func_name, if source_desc.filename is not None:
', '.join('%s=%s' % (name, val) for name, val in func_args), print 'at %s:%s' % (source_desc.filename, lineno),
source_desc.filename,
lineno) print
try: try:
print ' ' + source_desc.get_source(lineno) print ' ' + source_desc.get_source(lineno)
...@@ -498,9 +502,9 @@ class CythonCommand(gdb.Command, CythonBase): ...@@ -498,9 +502,9 @@ class CythonCommand(gdb.Command, CythonBase):
@classmethod @classmethod
def _register(cls, clsname, args, kwargs): def _register(cls, clsname, args, kwargs):
if not hasattr(cls, 'completer_class'): if not hasattr(cls, 'completer_class'):
return cls(cls.name, cls.command_class, *args, **kwargs) return cls(clsname, cls.command_class, *args, **kwargs)
else: else:
return cls(cls.name, cls.command_class, cls.completer_class, return cls(clsname, cls.command_class, cls.completer_class,
*args, **kwargs) *args, **kwargs)
@classmethod @classmethod
......
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