summaryrefslogtreecommitdiff
path: root/share/qtcreator/debugger
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-05-14 00:57:31 +0200
committerhjk <hjk121@nokiamail.com>2014-05-15 10:12:51 +0200
commit55c19c50429d29ce165f7bff51723da0fbebc559 (patch)
treee2f7e826b7b702c3f529719456e4f4e6758bca8e /share/qtcreator/debugger
parent9ab72ac045ea3b258bed792db89af2b6ae99356f (diff)
downloadqt-creator-55c19c50429d29ce165f7bff51723da0fbebc559.tar.gz
Debugger: More flexibility for "ranged expressions"
The range boundary and stride can be integral expressions. Also ( ) are valid delimiters now, making descriptions like list.at(2.(4).100+2) acceptable. Change-Id: Ief68c0a1b0b0d3813b2939d60e0806f5cd3ff0b0 Reviewed-by: Christian Stenger <christian.stenger@digia.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Diffstat (limited to 'share/qtcreator/debugger')
-rw-r--r--share/qtcreator/debugger/dumper.py47
1 files changed, 41 insertions, 6 deletions
diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py
index 8b09b72471..1e1d281623 100644
--- a/share/qtcreator/debugger/dumper.py
+++ b/share/qtcreator/debugger/dumper.py
@@ -1332,15 +1332,50 @@ class DumperBase:
# Parses a..b and a.(s).b
def parseRange(self, exp):
- match = re.search("\[(.+?)\.(\(.+?\))?\.(.+?)\]", exp)
+
+ # Search for the first unbalanced delimiter in s
+ def searchUnbalanced(s, upwards):
+ paran = 0
+ bracket = 0
+ if upwards:
+ open_p, close_p, open_b, close_b = '(', ')', '[', ']'
+ else:
+ open_p, close_p, open_b, close_b = ')', '(', ']', '['
+ for i in range(len(s)):
+ c = s[i]
+ if c == open_p:
+ paran += 1
+ elif c == open_b:
+ bracket += 1
+ elif c == close_p:
+ paran -= 1
+ if paran < 0:
+ return i
+ elif c == close_b:
+ bracket -= 1
+ if bracket < 0:
+ return i
+ return len(s)
+
+ match = re.search("(\.)(\(.+?\))?(\.)", exp)
if match:
- a = match.group(1)
s = match.group(2)
- b = match.group(3)
+ left_e = match.start(1)
+ left_s = 1 + left_e - searchUnbalanced(exp[left_e::-1], False)
+ right_s = match.end(3)
+ right_e = right_s + searchUnbalanced(exp[right_s:], True)
+ template = exp[:left_s] + '%s' + exp[right_e:]
+
+ a = exp[left_s:left_e]
+ b = exp[right_s:right_e]
+
try:
- step = toInteger(s[1:len(s)-1]) if s else 1
- template = exp[:match.start(1)] + '%s' + exp[match.end(3):]
- return True, toInteger(a), step, toInteger(b) + 1, template
+ # Allow integral expressions.
+ ss = toInteger(self.parseAndEvaluate(s[1:len(s)-1]) if s else 1)
+ aa = toInteger(self.parseAndEvaluate(a))
+ bb = toInteger(self.parseAndEvaluate(b))
+ if aa < bb and ss > 0:
+ return True, aa, ss, bb + 1, template
except:
pass
return False, 0, 1, 1, exp