DebugClients/Python/DebugClientBase.py

changeset 5964
066e6c78a367
parent 5957
0c10d2701adb
child 5966
3325ecd87c7c
equal deleted inserted replaced
5963:14522ec8cd08 5964:066e6c78a367
391 params["filename"] = params["filename"].encode( 391 params["filename"] = params["filename"].encode(
392 sys.getfilesystemencoding()) 392 sys.getfilesystemencoding())
393 393
394 if method == "RequestVariables": 394 if method == "RequestVariables":
395 self.__dumpVariables( 395 self.__dumpVariables(
396 params["frameNumber"], params["scope"], params["filters"]) 396 params["frameNumber"], params["scope"], params["filters"],
397 params["maxSize"])
397 398
398 elif method == "RequestVariable": 399 elif method == "RequestVariable":
399 self.__dumpVariable( 400 self.__dumpVariable(
400 params["variable"], params["frameNumber"], 401 params["variable"], params["frameNumber"],
401 params["scope"], params["filters"]) 402 params["scope"], params["filters"],
403 params["maxSize"])
402 404
403 elif method == "RequestThreadList": 405 elif method == "RequestThreadList":
404 self.dumpThreadList() 406 self.dumpThreadList()
405 407
406 elif method == "RequestThreadSet": 408 elif method == "RequestThreadSet":
1319 }) 1321 })
1320 1322
1321 # reset coding 1323 # reset coding
1322 self.__coding = self.defaultCoding 1324 self.__coding = self.defaultCoding
1323 1325
1324 def __dumpVariables(self, frmnr, scope, filterList): 1326 def __dumpVariables(self, frmnr, scope, filterList, maxSize):
1325 """ 1327 """
1326 Private method to return the variables of a frame to the debug server. 1328 Private method to return the variables of a frame to the debug server.
1327 1329
1328 @param frmnr distance of frame reported on. 0 is the current frame 1330 @param frmnr distance of frame reported on. 0 is the current frame
1329 (int) 1331 @type int
1330 @param scope 1 to report global variables, 0 for local variables (int) 1332 @param scope 1 to report global variables, 0 for local variables
1333 @type int
1331 @param filterList the indices of variable types to be filtered 1334 @param filterList the indices of variable types to be filtered
1332 (list of int) 1335 @type list of int
1336 @param maxSize maximum size the formatted value of a variable will
1337 be shown. If it is bigger than that, a 'too big' indication will
1338 be given.
1339 @type int
1333 """ 1340 """
1334 if self.currentThread is None: 1341 if self.currentThread is None:
1335 return 1342 return
1336 1343
1337 frmnr += self.currentThread.skipFrames 1344 frmnr += self.currentThread.skipFrames
1360 1367
1361 if scope != -1: 1368 if scope != -1:
1362 keylist = varDict.keys() 1369 keylist = varDict.keys()
1363 1370
1364 vlist = self.__formatVariablesList( 1371 vlist = self.__formatVariablesList(
1365 keylist, varDict, scope, filterList) 1372 keylist, varDict, scope, filterList, maxSize=maxSize)
1366 varlist.extend(vlist) 1373 varlist.extend(vlist)
1367 1374
1368 self.sendJsonCommand("ResponseVariables", { 1375 self.sendJsonCommand("ResponseVariables", {
1369 "scope": scope, 1376 "scope": scope,
1370 "variables": varlist, 1377 "variables": varlist,
1371 }) 1378 })
1372 1379
1373 def __dumpVariable(self, var, frmnr, scope, filterList): 1380 def __dumpVariable(self, var, frmnr, scope, filterList, maxSize):
1374 """ 1381 """
1375 Private method to return the variables of a frame to the debug server. 1382 Private method to return the variables of a frame to the debug server.
1376 1383
1377 @param var list encoded name of the requested variable 1384 @param var list encoded name of the requested variable
1378 (list of strings) 1385 @type list of strings
1379 @param frmnr distance of frame reported on. 0 is the current frame 1386 @param frmnr distance of frame reported on. 0 is the current frame
1380 (int) 1387 @type int
1381 @param scope 1 to report global variables, 0 for local variables (int) 1388 @param scope 1 to report global variables, 0 for local variables (int)
1382 @param filterList the indices of variable types to be filtered 1389 @param filterList the indices of variable types to be filtered
1383 (list of int) 1390 @type list of int
1391 @param maxSize maximum size the formatted value of a variable will
1392 be shown. If it is bigger than that, a 'too big' indication will
1393 be given.
1394 @type int
1384 """ 1395 """
1385 if self.currentThread is None: 1396 if self.currentThread is None:
1386 return 1397 return
1387 1398
1388 frmnr += self.currentThread.skipFrames 1399 frmnr += self.currentThread.skipFrames
1427 vlist = self.__formatQtVariable(variable, typeName) 1438 vlist = self.__formatQtVariable(variable, typeName)
1428 varlist.extend(vlist) 1439 varlist.extend(vlist)
1429 elif resolver: 1440 elif resolver:
1430 varDict = resolver.getDictionary(variable) 1441 varDict = resolver.getDictionary(variable)
1431 vlist = self.__formatVariablesList( 1442 vlist = self.__formatVariablesList(
1432 list(varDict.keys()), varDict, scope, filterList) 1443 list(varDict.keys()), varDict, scope, filterList,
1444 maxSize=maxSize)
1433 varlist.extend(vlist) 1445 varlist.extend(vlist)
1434 1446
1435 self.sendJsonCommand("ResponseVariable", { 1447 self.sendJsonCommand("ResponseVariable", {
1436 "scope": scope, 1448 "scope": scope,
1437 "variable": var, 1449 "variable": var,
1598 ("address", "QHostAddress", "{0}".format(value.toString()))) 1610 ("address", "QHostAddress", "{0}".format(value.toString())))
1599 1611
1600 return varlist 1612 return varlist
1601 1613
1602 def __formatVariablesList(self, keylist, dict_, scope, filterList=None, 1614 def __formatVariablesList(self, keylist, dict_, scope, filterList=None,
1603 formatSequences=False): 1615 formatSequences=False, maxSize=0):
1604 """ 1616 """
1605 Private method to produce a formated variables list. 1617 Private method to produce a formated variables list.
1606 1618
1607 The dictionary passed in to it is scanned. Variables are 1619 The dictionary passed in to it is scanned. Variables are
1608 only added to the list, if their type is not contained 1620 only added to the list, if their type is not contained
1609 in the filter list and their name doesn't match any of the filter 1621 in the filter list and their name doesn't match any of the filter
1610 expressions. The formated variables list (a list of tuples of 3 1622 expressions. The formated variables list (a list of tuples of 3
1611 values) is returned. 1623 values) is returned.
1612 1624
1613 @param keylist keys of the dictionary 1625 @param keylist keys of the dictionary to be formatted
1626 @type list of str
1614 @param dict_ the dictionary to be scanned 1627 @param dict_ the dictionary to be scanned
1628 @type dict
1615 @param scope 1 to filter using the globals filter, 0 using the locals 1629 @param scope 1 to filter using the globals filter, 0 using the locals
1616 filter (int). 1630 filter.
1617 Variables are only added to the list, if their name do not match 1631 Variables are only added to the list, if their name do not match
1618 any of the filter expressions. 1632 any of the filter expressions.
1633 @type int
1619 @param filterList the indices of variable types to be filtered. 1634 @param filterList the indices of variable types to be filtered.
1620 Variables are only added to the list, if their type is not 1635 Variables are only added to the list, if their type is not
1621 contained in the filter list. 1636 contained in the filter list.
1637 @type list of int
1622 @param formatSequences flag indicating, that sequence or dictionary 1638 @param formatSequences flag indicating, that sequence or dictionary
1623 variables should be formatted. If it is 0 (or false), just the 1639 variables should be formatted. If it is 0 (or false), just the
1624 number of items contained in these variables is returned. (boolean) 1640 number of items contained in these variables is returned.
1641 @type bool
1642 @param maxSize maximum size the formatted value of a variable will
1643 be shown. If it is bigger than that, a 'too big' indication will
1644 be placed in the value field.
1645 @type int
1625 @return A tuple consisting of a list of formatted variables. Each 1646 @return A tuple consisting of a list of formatted variables. Each
1626 variable entry is a tuple of three elements, the variable name, 1647 variable entry is a tuple of three elements, the variable name,
1627 its type and value. 1648 its type and value.
1649 @rtype list of tuple of (str, str, str)
1628 """ 1650 """
1629 filterList = [] if filterList is None else filterList[:] 1651 filterList = [] if filterList is None else filterList[:]
1630 1652
1631 varlist = [] 1653 varlist = []
1632 if scope: 1654 if scope:
1722 else: 1744 else:
1723 rvalue = repr(value) 1745 rvalue = repr(value)
1724 if valtype.startswith('class') and \ 1746 if valtype.startswith('class') and \
1725 rvalue[0] in ['{', '(', '[']: 1747 rvalue[0] in ['{', '(', '[']:
1726 rvalue = "" 1748 rvalue = ""
1749 elif maxSize and len(rvalue) > maxSize:
1750 rvalue = "@@TOO_BIG_TO_SHOW@@"
1727 except Exception: 1751 except Exception:
1728 rvalue = '' 1752 rvalue = ''
1729 1753
1730 if formatSequences: 1754 if formatSequences:
1731 if str(key) == key: 1755 if str(key) == key:

eric ide

mercurial