summaryrefslogtreecommitdiffstats
path: root/lldb/utils
diff options
context:
space:
mode:
authorWei Pan <wei.pan@intel.com>2013-10-23 01:18:21 +0000
committerWei Pan <wei.pan@intel.com>2013-10-23 01:18:21 +0000
commit133ac8714da666dc999361bbca0b365ce8a8c4c2 (patch)
tree2634848df73173b4a8291a19e91aa9a60b912cfd /lldb/utils
parent6eac881f665691519409d073836469b6231679e1 (diff)
downloadbcm5719-llvm-133ac8714da666dc999361bbca0b365ce8a8c4c2.tar.gz
bcm5719-llvm-133ac8714da666dc999361bbca0b365ce8a8c4c2.zip
LUI: Fix some issues causing crashes in the source view
llvm-svn: 193217
Diffstat (limited to 'lldb/utils')
-rw-r--r--lldb/utils/lui/sourcewin.py34
1 files changed, 8 insertions, 26 deletions
diff --git a/lldb/utils/lui/sourcewin.py b/lldb/utils/lui/sourcewin.py
index a72d7a5eba6..5e7067fdebe 100644
--- a/lldb/utils/lui/sourcewin.py
+++ b/lldb/utils/lui/sourcewin.py
@@ -87,28 +87,15 @@ class SourceWin(cui.TitledWin):
elif key == curses.KEY_UP:
self.pageUp()
- def updateViewline(self, total_lines):
+ def updateViewline(self):
half = self.height / 2
- if total_lines == 0:
+ if self.pc_line < half:
self.viewline = 0
else:
- lines_before_pc = self.pc_line
- lines_after_pc = total_lines - self.pc_line
- if lines_before_pc < half:
- self.viewline = 0
- elif lines_after_pc < half:
- self.viewline = total_lines - self.height + 1
- else:
- self.viewline = self.pc_line - half + 1
+ self.viewline = self.pc_line - half + 1
- if self.viewline < 0:
- raise Exception("negative viewline: pc=%d viewline=%d" % (self.pc_line, self.viewline))
- end = min(total_lines, self.height - 1)
- if self.viewline + end > len(self.content) + 1:
- raise Exception("viewline too large: PC=%d viewline=%d (to %d of %d)" % (self.pc_line,
- self.viewline,
- self.viewline + end - 1,
- total_lines))
+ if self.viewline < 0:
+ raise Exception("negative viewline: pc=%d viewline=%d" % (self.pc_line, self.viewline))
def refreshSource(self, process = None):
(self.height, self.width) = self.win.getmaxyx()
@@ -126,7 +113,7 @@ class SourceWin(cui.TitledWin):
path = os.path.join(f.GetDirectory(), self.filename)
self.setTitle(path)
self.content = self.getContent(path)
- self.updateViewline(len(self.content))
+ self.updateViewline()
if self.filename is None:
return
@@ -155,13 +142,8 @@ class SourceWin(cui.TitledWin):
source = ""
count = 1
self.win.erase()
- end = min(len(content), self.height -1)
- for i in range(self.viewline, self.viewline + end):
- if i > len(content) - 1:
- raise Exception("Out of range content (%d-%d of %d)" % (self.viewline,
- self.viewline + self.height - 1,
- len(content)))
-
+ end = min(len(content), self.viewline + self.height)
+ for i in range(self.viewline, end):
line_num = i + 1
marker = self.markerNone
attr = curses.A_NORMAL
OpenPOWER on IntegriCloud