DebugClients/Python/DebugClientBase.py

changeset 5964
066e6c78a367
parent 5957
0c10d2701adb
child 5966
3325ecd87c7c
diff -r 14522ec8cd08 -r 066e6c78a367 DebugClients/Python/DebugClientBase.py
--- a/DebugClients/Python/DebugClientBase.py	Tue Nov 07 19:37:17 2017 +0100
+++ b/DebugClients/Python/DebugClientBase.py	Wed Nov 08 19:05:55 2017 +0100
@@ -393,12 +393,14 @@
         
         if method == "RequestVariables":
             self.__dumpVariables(
-                params["frameNumber"], params["scope"], params["filters"])
+                params["frameNumber"], params["scope"], params["filters"],
+                params["maxSize"])
         
         elif method == "RequestVariable":
             self.__dumpVariable(
                 params["variable"], params["frameNumber"],
-                params["scope"], params["filters"])
+                params["scope"], params["filters"],
+                params["maxSize"])
         
         elif method == "RequestThreadList":
             self.dumpThreadList()
@@ -1321,15 +1323,20 @@
         # reset coding
         self.__coding = self.defaultCoding
 
-    def __dumpVariables(self, frmnr, scope, filterList):
+    def __dumpVariables(self, frmnr, scope, filterList, maxSize):
         """
         Private method to return the variables of a frame to the debug server.
         
         @param frmnr distance of frame reported on. 0 is the current frame
-            (int)
-        @param scope 1 to report global variables, 0 for local variables (int)
+        @type int
+        @param scope 1 to report global variables, 0 for local variables
+        @type int
         @param filterList the indices of variable types to be filtered
-            (list of int)
+        @type list of int
+        @param maxSize maximum size the formatted value of a variable will
+            be shown. If it is bigger than that, a 'too big' indication will
+            be given.
+        @type int
         """
         if self.currentThread is None:
             return
@@ -1362,7 +1369,7 @@
             keylist = varDict.keys()
             
             vlist = self.__formatVariablesList(
-                keylist, varDict, scope, filterList)
+                keylist, varDict, scope, filterList, maxSize=maxSize)
             varlist.extend(vlist)
         
         self.sendJsonCommand("ResponseVariables", {
@@ -1370,17 +1377,21 @@
             "variables": varlist,
         })
     
-    def __dumpVariable(self, var, frmnr, scope, filterList):
+    def __dumpVariable(self, var, frmnr, scope, filterList, maxSize):
         """
         Private method to return the variables of a frame to the debug server.
         
         @param var list encoded name of the requested variable
-            (list of strings)
+        @type list of strings
         @param frmnr distance of frame reported on. 0 is the current frame
-            (int)
+        @type int
         @param scope 1 to report global variables, 0 for local variables (int)
         @param filterList the indices of variable types to be filtered
-            (list of int)
+        @type list of int
+        @param maxSize maximum size the formatted value of a variable will
+            be shown. If it is bigger than that, a 'too big' indication will
+            be given.
+        @type int
         """
         if self.currentThread is None:
             return
@@ -1429,7 +1440,8 @@
                 elif resolver:
                     varDict = resolver.getDictionary(variable)
                     vlist = self.__formatVariablesList(
-                        list(varDict.keys()), varDict, scope, filterList)
+                        list(varDict.keys()), varDict, scope, filterList,
+                        maxSize=maxSize)
                     varlist.extend(vlist)
         
         self.sendJsonCommand("ResponseVariable", {
@@ -1600,7 +1612,7 @@
         return varlist
     
     def __formatVariablesList(self, keylist, dict_, scope, filterList=None,
-                              formatSequences=False):
+                              formatSequences=False, maxSize=0):
         """
         Private method to produce a formated variables list.
         
@@ -1610,21 +1622,31 @@
         expressions. The formated variables list (a list of tuples of 3
         values) is returned.
         
-        @param keylist keys of the dictionary
+        @param keylist keys of the dictionary to be formatted
+        @type list of str
         @param dict_ the dictionary to be scanned
+        @type dict
         @param scope 1 to filter using the globals filter, 0 using the locals
-            filter (int).
+            filter.
             Variables are only added to the list, if their name do not match
             any of the filter expressions.
+        @type int
         @param filterList the indices of variable types to be filtered.
             Variables are only added to the list, if their type is not
             contained in the filter list.
+        @type list of int
         @param formatSequences flag indicating, that sequence or dictionary
             variables should be formatted. If it is 0 (or false), just the
-            number of items contained in these variables is returned. (boolean)
+            number of items contained in these variables is returned.
+        @type bool
+        @param maxSize maximum size the formatted value of a variable will
+            be shown. If it is bigger than that, a 'too big' indication will
+            be placed in the value field.
+        @type int
         @return A tuple consisting of a list of formatted variables. Each
             variable entry is a tuple of three elements, the variable name,
             its type and value.
+        @rtype list of tuple of (str, str, str)
         """
         filterList = [] if filterList is None else filterList[:]
         
@@ -1724,6 +1746,8 @@
                         if valtype.startswith('class') and \
                            rvalue[0] in ['{', '(', '[']:
                             rvalue = ""
+                        elif maxSize and len(rvalue) > maxSize:
+                            rvalue = "@@TOO_BIG_TO_SHOW@@"
                 except Exception:
                     rvalue = ''
             

eric ide

mercurial