Commit 9a387a73 authored by Mark Florisson's avatar Mark Florisson

Support python 2.5

Fix pygments stripall bug
parent 9bdfe330
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
GDB extension that adds Cython support. GDB extension that adds Cython support.
""" """
from __future__ import with_statement
import os import os
import sys import sys
import textwrap import textwrap
...@@ -224,7 +226,7 @@ class CythonBase(object): ...@@ -224,7 +226,7 @@ class CythonBase(object):
filename = self.get_cython_function(frame).module.filename filename = self.get_cython_function(frame).module.filename
lineno = self.get_cython_lineno(frame) lineno = self.get_cython_lineno(frame)
if pygments: if pygments:
lexer = pygments.lexers.CythonLexer() lexer = pygments.lexers.CythonLexer(stripall=False)
elif self.is_python_function(frame): elif self.is_python_function(frame):
pyframeobject = libpython.Frame(frame).get_pyop() pyframeobject = libpython.Frame(frame).get_pyop()
...@@ -234,7 +236,7 @@ class CythonBase(object): ...@@ -234,7 +236,7 @@ class CythonBase(object):
filename = pyframeobject.filename() filename = pyframeobject.filename()
lineno = pyframeobject.current_line_num() lineno = pyframeobject.current_line_num()
if pygments: if pygments:
lexer = pygments.lexers.PythonLexer() lexer = pygments.lexers.PythonLexer(stripall=False)
else: else:
symbol_and_line_obj = frame.find_sal() symbol_and_line_obj = frame.find_sal()
if not symbol_and_line_obj or not symbol_and_line_obj.symtab: if not symbol_and_line_obj or not symbol_and_line_obj.symtab:
...@@ -244,7 +246,7 @@ class CythonBase(object): ...@@ -244,7 +246,7 @@ class CythonBase(object):
filename = symbol_and_line_obj.symtab.filename filename = symbol_and_line_obj.symtab.filename
lineno = symbol_and_line_obj.line lineno = symbol_and_line_obj.line
if pygments: if pygments:
lexer = pygments.lexers.CLexer() lexer = pygments.lexers.CLexer(stripall=False)
return SourceFileDescriptor(filename, lexer), lineno return SourceFileDescriptor(filename, lexer), lineno
...@@ -362,13 +364,14 @@ class SourceFileDescriptor(object): ...@@ -362,13 +364,14 @@ class SourceFileDescriptor(object):
def _get_source(self, start, stop, lex_source, mark_line): def _get_source(self, start, stop, lex_source, mark_line):
with open(self.filename) as f: with open(self.filename) as f:
if lex_source: if lex_source:
# to provide proper colouring, the entire code needs to be # to provide proper colouring, the entire code needs to be
# lexed # lexed
lines = self.lex(f.read()).splitlines() lines = self.lex(f.read()).splitlines()
else: else:
lines = f lines = f
for idx, line in enumerate(itertools.islice(lines, start - 1, stop - 1)): slice = itertools.islice(lines, start - 1, stop - 1)
for idx, line in enumerate(slice):
if start + idx == mark_line: if start + idx == mark_line:
prefix = '>' prefix = '>'
else: else:
...@@ -381,7 +384,8 @@ class SourceFileDescriptor(object): ...@@ -381,7 +384,8 @@ class SourceFileDescriptor(object):
if not self.filename: if not self.filename:
raise exc raise exc
start = max(start, 1)
if stop is None: if stop is None:
stop = start + 1 stop = start + 1
...@@ -804,7 +808,7 @@ class CythonCodeStepper(CythonCommand, libpython.GenericCodeStepper): ...@@ -804,7 +808,7 @@ class CythonCodeStepper(CythonCommand, libpython.GenericCodeStepper):
class CyStep(CythonCodeStepper): class CyStep(CythonCodeStepper):
"Step through Python code." "Step through Cython, Python or C code."
name = 'cy step' name = 'cy step'
stepper = True stepper = True
...@@ -904,7 +908,10 @@ class CyBacktrace(CythonCommand): ...@@ -904,7 +908,10 @@ class CyBacktrace(CythonCommand):
is_c = False is_c = False
if print_all or self.is_relevant_function(frame): if print_all or self.is_relevant_function(frame):
self.print_stackframe(frame, index) try:
self.print_stackframe(frame, index)
except gdb.GdbError:
print 'Unable to fsdk.fjkds'
index += 1 index += 1
frame = frame.newer() frame = frame.newer()
......
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