diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-06 10:59:36 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-06 10:59:36 -0500 |
| commit | 203b6609e0ede49eb0b97008b1150c69e9d2ffd3 (patch) | |
| tree | 7d9c1227eeec17f75b2a827e385387f640a365a6 /tools/perf/scripts/python/exported-sql-viewer.py | |
| parent | 3478588b5136966c80c571cf0006f08e9e5b8f04 (diff) | |
| parent | c978b9460fe1d4a1e1effa0abd6bd69b18a098a8 (diff) | |
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar:
"Lots of tooling updates - too many to list, here's a few highlights:
- Various subcommand updates to 'perf trace', 'perf report', 'perf
record', 'perf annotate', 'perf script', 'perf test', etc.
- CPU and NUMA topology and affinity handling improvements,
- HW tracing and HW support updates:
- Intel PT updates
- ARM CoreSight updates
- vendor HW event updates
- BPF updates
- Tons of infrastructure updates, both on the build system and the
library support side
- Documentation updates.
- ... and lots of other changes, see the changelog for details.
Kernel side updates:
- Tighten up kprobes blacklist handling, reduce the number of places
where developers can install a kprobe and hang/crash the system.
- Fix/enhance vma address filter handling.
- Various PMU driver updates, small fixes and additions.
- refcount_t conversions
- BPF updates
- error code propagation enhancements
- misc other changes"
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (238 commits)
perf script python: Add Python3 support to syscall-counts-by-pid.py
perf script python: Add Python3 support to syscall-counts.py
perf script python: Add Python3 support to stat-cpi.py
perf script python: Add Python3 support to stackcollapse.py
perf script python: Add Python3 support to sctop.py
perf script python: Add Python3 support to powerpc-hcalls.py
perf script python: Add Python3 support to net_dropmonitor.py
perf script python: Add Python3 support to mem-phys-addr.py
perf script python: Add Python3 support to failed-syscalls-by-pid.py
perf script python: Add Python3 support to netdev-times.py
perf tools: Add perf_exe() helper to find perf binary
perf script: Handle missing fields with -F +..
perf data: Add perf_data__open_dir_data function
perf data: Add perf_data__(create_dir|close_dir) functions
perf data: Fail check_backup in case of error
perf data: Make check_backup work over directories
perf tools: Add rm_rf_perf_data function
perf tools: Add pattern name checking to rm_rf
perf tools: Add depth checking to rm_rf
perf data: Add global path holder
...
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
| -rwxr-xr-x | tools/perf/scripts/python/exported-sql-viewer.py | 511 |
1 files changed, 351 insertions, 160 deletions
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index f278ce5ebab7..09ce73b07d35 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #!/usr/bin/python2 | 1 | #!/usr/bin/env python2 |
| 2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | # exported-sql-viewer.py: view data from sql database | 3 | # exported-sql-viewer.py: view data from sql database |
| 4 | # Copyright (c) 2014-2018, Intel Corporation. | 4 | # Copyright (c) 2014-2018, Intel Corporation. |
| @@ -1398,18 +1398,28 @@ class BranchModel(TreeModel): | |||
| 1398 | def HasMoreRecords(self): | 1398 | def HasMoreRecords(self): |
| 1399 | return self.more | 1399 | return self.more |
| 1400 | 1400 | ||
| 1401 | # Report Variables | ||
| 1402 | |||
| 1403 | class ReportVars(): | ||
| 1404 | |||
| 1405 | def __init__(self, name = "", where_clause = "", limit = ""): | ||
| 1406 | self.name = name | ||
| 1407 | self.where_clause = where_clause | ||
| 1408 | self.limit = limit | ||
| 1409 | |||
| 1410 | def UniqueId(self): | ||
| 1411 | return str(self.where_clause + ";" + self.limit) | ||
| 1412 | |||
| 1401 | # Branch window | 1413 | # Branch window |
| 1402 | 1414 | ||
| 1403 | class BranchWindow(QMdiSubWindow): | 1415 | class BranchWindow(QMdiSubWindow): |
| 1404 | 1416 | ||
| 1405 | def __init__(self, glb, event_id, name, where_clause, parent=None): | 1417 | def __init__(self, glb, event_id, report_vars, parent=None): |
| 1406 | super(BranchWindow, self).__init__(parent) | 1418 | super(BranchWindow, self).__init__(parent) |
| 1407 | 1419 | ||
| 1408 | model_name = "Branch Events " + str(event_id) | 1420 | model_name = "Branch Events " + str(event_id) + " " + report_vars.UniqueId() |
| 1409 | if len(where_clause): | ||
| 1410 | model_name = where_clause + " " + model_name | ||
| 1411 | 1421 | ||
| 1412 | self.model = LookupCreateModel(model_name, lambda: BranchModel(glb, event_id, where_clause)) | 1422 | self.model = LookupCreateModel(model_name, lambda: BranchModel(glb, event_id, report_vars.where_clause)) |
| 1413 | 1423 | ||
| 1414 | self.view = QTreeView() | 1424 | self.view = QTreeView() |
| 1415 | self.view.setUniformRowHeights(True) | 1425 | self.view.setUniformRowHeights(True) |
| @@ -1427,7 +1437,7 @@ class BranchWindow(QMdiSubWindow): | |||
| 1427 | 1437 | ||
| 1428 | self.setWidget(self.vbox.Widget()) | 1438 | self.setWidget(self.vbox.Widget()) |
| 1429 | 1439 | ||
| 1430 | AddSubWindow(glb.mainwindow.mdi_area, self, name + " Branch Events") | 1440 | AddSubWindow(glb.mainwindow.mdi_area, self, report_vars.name + " Branch Events") |
| 1431 | 1441 | ||
| 1432 | def ResizeColumnToContents(self, column, n): | 1442 | def ResizeColumnToContents(self, column, n): |
| 1433 | # Using the view's resizeColumnToContents() here is extrememly slow | 1443 | # Using the view's resizeColumnToContents() here is extrememly slow |
| @@ -1472,47 +1482,134 @@ class BranchWindow(QMdiSubWindow): | |||
| 1472 | else: | 1482 | else: |
| 1473 | self.find_bar.NotFound() | 1483 | self.find_bar.NotFound() |
| 1474 | 1484 | ||
| 1475 | # Dialog data item converted and validated using a SQL table | 1485 | # Line edit data item |
| 1476 | 1486 | ||
| 1477 | class SQLTableDialogDataItem(): | 1487 | class LineEditDataItem(object): |
| 1478 | 1488 | ||
| 1479 | def __init__(self, glb, label, placeholder_text, table_name, match_column, column_name1, column_name2, parent): | 1489 | def __init__(self, glb, label, placeholder_text, parent, id = "", default = ""): |
| 1480 | self.glb = glb | 1490 | self.glb = glb |
| 1481 | self.label = label | 1491 | self.label = label |
| 1482 | self.placeholder_text = placeholder_text | 1492 | self.placeholder_text = placeholder_text |
| 1483 | self.table_name = table_name | ||
| 1484 | self.match_column = match_column | ||
| 1485 | self.column_name1 = column_name1 | ||
| 1486 | self.column_name2 = column_name2 | ||
| 1487 | self.parent = parent | 1493 | self.parent = parent |
| 1494 | self.id = id | ||
| 1488 | 1495 | ||
| 1489 | self.value = "" | 1496 | self.value = default |
| 1490 | 1497 | ||
| 1491 | self.widget = QLineEdit() | 1498 | self.widget = QLineEdit(default) |
| 1492 | self.widget.editingFinished.connect(self.Validate) | 1499 | self.widget.editingFinished.connect(self.Validate) |
| 1493 | self.widget.textChanged.connect(self.Invalidate) | 1500 | self.widget.textChanged.connect(self.Invalidate) |
| 1494 | self.red = False | 1501 | self.red = False |
| 1495 | self.error = "" | 1502 | self.error = "" |
| 1496 | self.validated = True | 1503 | self.validated = True |
| 1497 | 1504 | ||
| 1498 | self.last_id = 0 | ||
| 1499 | self.first_time = 0 | ||
| 1500 | self.last_time = 2 ** 64 | ||
| 1501 | if self.table_name == "<timeranges>": | ||
| 1502 | query = QSqlQuery(self.glb.db) | ||
| 1503 | QueryExec(query, "SELECT id, time FROM samples ORDER BY id DESC LIMIT 1") | ||
| 1504 | if query.next(): | ||
| 1505 | self.last_id = int(query.value(0)) | ||
| 1506 | self.last_time = int(query.value(1)) | ||
| 1507 | QueryExec(query, "SELECT time FROM samples WHERE time != 0 ORDER BY id LIMIT 1") | ||
| 1508 | if query.next(): | ||
| 1509 | self.first_time = int(query.value(0)) | ||
| 1510 | if placeholder_text: | ||
| 1511 | placeholder_text += ", between " + str(self.first_time) + " and " + str(self.last_time) | ||
| 1512 | |||
| 1513 | if placeholder_text: | 1505 | if placeholder_text: |
| 1514 | self.widget.setPlaceholderText(placeholder_text) | 1506 | self.widget.setPlaceholderText(placeholder_text) |
| 1515 | 1507 | ||
| 1508 | def TurnTextRed(self): | ||
| 1509 | if not self.red: | ||
| 1510 | palette = QPalette() | ||
| 1511 | palette.setColor(QPalette.Text,Qt.red) | ||
| 1512 | self.widget.setPalette(palette) | ||
| 1513 | self.red = True | ||
| 1514 | |||
| 1515 | def TurnTextNormal(self): | ||
| 1516 | if self.red: | ||
| 1517 | palette = QPalette() | ||
| 1518 | self.widget.setPalette(palette) | ||
| 1519 | self.red = False | ||
| 1520 | |||
| 1521 | def InvalidValue(self, value): | ||
| 1522 | self.value = "" | ||
| 1523 | self.TurnTextRed() | ||
| 1524 | self.error = self.label + " invalid value '" + value + "'" | ||
| 1525 | self.parent.ShowMessage(self.error) | ||
| 1526 | |||
| 1527 | def Invalidate(self): | ||
| 1528 | self.validated = False | ||
| 1529 | |||
| 1530 | def DoValidate(self, input_string): | ||
| 1531 | self.value = input_string.strip() | ||
| 1532 | |||
| 1533 | def Validate(self): | ||
| 1534 | self.validated = True | ||
| 1535 | self.error = "" | ||
| 1536 | self.TurnTextNormal() | ||
| 1537 | self.parent.ClearMessage() | ||
| 1538 | input_string = self.widget.text() | ||
| 1539 | if not len(input_string.strip()): | ||
| 1540 | self.value = "" | ||
| 1541 | return | ||
| 1542 | self.DoValidate(input_string) | ||
| 1543 | |||
| 1544 | def IsValid(self): | ||
| 1545 | if not self.validated: | ||
| 1546 | self.Validate() | ||
| 1547 | if len(self.error): | ||
| 1548 | self.parent.ShowMessage(self.error) | ||
| 1549 | return False | ||
| 1550 | return True | ||
| 1551 | |||
| 1552 | def IsNumber(self, value): | ||
| 1553 | try: | ||
| 1554 | x = int(value) | ||
| 1555 | except: | ||
| 1556 | x = 0 | ||
| 1557 | return str(x) == value | ||
| 1558 | |||
| 1559 | # Non-negative integer ranges dialog data item | ||
| 1560 | |||
| 1561 | class NonNegativeIntegerRangesDataItem(LineEditDataItem): | ||
| 1562 | |||
| 1563 | def __init__(self, glb, label, placeholder_text, column_name, parent): | ||
| 1564 | super(NonNegativeIntegerRangesDataItem, self).__init__(glb, label, placeholder_text, parent) | ||
| 1565 | |||
| 1566 | self.column_name = column_name | ||
| 1567 | |||
| 1568 | def DoValidate(self, input_string): | ||
| 1569 | singles = [] | ||
| 1570 | ranges = [] | ||
| 1571 | for value in [x.strip() for x in input_string.split(",")]: | ||
| 1572 | if "-" in value: | ||
| 1573 | vrange = value.split("-") | ||
| 1574 | if len(vrange) != 2 or not self.IsNumber(vrange[0]) or not self.IsNumber(vrange[1]): | ||
| 1575 | return self.InvalidValue(value) | ||
| 1576 | ranges.append(vrange) | ||
| 1577 | else: | ||
| 1578 | if not self.IsNumber(value): | ||
| 1579 | return self.InvalidValue(value) | ||
| 1580 | singles.append(value) | ||
| 1581 | ranges = [("(" + self.column_name + " >= " + r[0] + " AND " + self.column_name + " <= " + r[1] + ")") for r in ranges] | ||
| 1582 | if len(singles): | ||
| 1583 | ranges.append(self.column_name + " IN (" + ",".join(singles) + ")") | ||
| 1584 | self.value = " OR ".join(ranges) | ||
| 1585 | |||
| 1586 | # Positive integer dialog data item | ||
| 1587 | |||
| 1588 | class PositiveIntegerDataItem(LineEditDataItem): | ||
| 1589 | |||
| 1590 | def __init__(self, glb, label, placeholder_text, parent, id = "", default = ""): | ||
| 1591 | super(PositiveIntegerDataItem, self).__init__(glb, label, placeholder_text, parent, id, default) | ||
| 1592 | |||
| 1593 | def DoValidate(self, input_string): | ||
| 1594 | if not self.IsNumber(input_string.strip()): | ||
| 1595 | return self.InvalidValue(input_string) | ||
| 1596 | value = int(input_string.strip()) | ||
| 1597 | if value <= 0: | ||
| 1598 | return self.InvalidValue(input_string) | ||
| 1599 | self.value = str(value) | ||
| 1600 | |||
| 1601 | # Dialog data item converted and validated using a SQL table | ||
| 1602 | |||
| 1603 | class SQLTableDataItem(LineEditDataItem): | ||
| 1604 | |||
| 1605 | def __init__(self, glb, label, placeholder_text, table_name, match_column, column_name1, column_name2, parent): | ||
| 1606 | super(SQLTableDataItem, self).__init__(glb, label, placeholder_text, parent) | ||
| 1607 | |||
| 1608 | self.table_name = table_name | ||
| 1609 | self.match_column = match_column | ||
| 1610 | self.column_name1 = column_name1 | ||
| 1611 | self.column_name2 = column_name2 | ||
| 1612 | |||
| 1516 | def ValueToIds(self, value): | 1613 | def ValueToIds(self, value): |
| 1517 | ids = [] | 1614 | ids = [] |
| 1518 | query = QSqlQuery(self.glb.db) | 1615 | query = QSqlQuery(self.glb.db) |
| @@ -1523,6 +1620,42 @@ class SQLTableDialogDataItem(): | |||
| 1523 | ids.append(str(query.value(0))) | 1620 | ids.append(str(query.value(0))) |
| 1524 | return ids | 1621 | return ids |
| 1525 | 1622 | ||
| 1623 | def DoValidate(self, input_string): | ||
| 1624 | all_ids = [] | ||
| 1625 | for value in [x.strip() for x in input_string.split(",")]: | ||
| 1626 | ids = self.ValueToIds(value) | ||
| 1627 | if len(ids): | ||
| 1628 | all_ids.extend(ids) | ||
| 1629 | else: | ||
| 1630 | return self.InvalidValue(value) | ||
| 1631 | self.value = self.column_name1 + " IN (" + ",".join(all_ids) + ")" | ||
| 1632 | if self.column_name2: | ||
| 1633 | self.value = "( " + self.value + " OR " + self.column_name2 + " IN (" + ",".join(all_ids) + ") )" | ||
| 1634 | |||
| 1635 | # Sample time ranges dialog data item converted and validated using 'samples' SQL table | ||
| 1636 | |||
| 1637 | class SampleTimeRangesDataItem(LineEditDataItem): | ||
| 1638 | |||
| 1639 | def __init__(self, glb, label, placeholder_text, column_name, parent): | ||
| 1640 | self.column_name = column_name | ||
| 1641 | |||
| 1642 | self.last_id = 0 | ||
| 1643 | self.first_time = 0 | ||
| 1644 | self.last_time = 2 ** 64 | ||
| 1645 | |||
| 1646 | query = QSqlQuery(glb.db) | ||
| 1647 | QueryExec(query, "SELECT id, time FROM samples ORDER BY id DESC LIMIT 1") | ||
| 1648 | if query.next(): | ||
| 1649 | self.last_id = int(query.value(0)) | ||
| 1650 | self.last_time = int(query.value(1)) | ||
| 1651 | QueryExec(query, "SELECT time FROM samples WHERE time != 0 ORDER BY id LIMIT 1") | ||
| 1652 | if query.next(): | ||
| 1653 | self.first_time = int(query.value(0)) | ||
| 1654 | if placeholder_text: | ||
| 1655 | placeholder_text += ", between " + str(self.first_time) + " and " + str(self.last_time) | ||
| 1656 | |||
| 1657 | super(SampleTimeRangesDataItem, self).__init__(glb, label, placeholder_text, parent) | ||
| 1658 | |||
| 1526 | def IdBetween(self, query, lower_id, higher_id, order): | 1659 | def IdBetween(self, query, lower_id, higher_id, order): |
| 1527 | QueryExec(query, "SELECT id FROM samples WHERE id > " + str(lower_id) + " AND id < " + str(higher_id) + " ORDER BY id " + order + " LIMIT 1") | 1660 | QueryExec(query, "SELECT id FROM samples WHERE id > " + str(lower_id) + " AND id < " + str(higher_id) + " ORDER BY id " + order + " LIMIT 1") |
| 1528 | if query.next(): | 1661 | if query.next(): |
| @@ -1560,7 +1693,6 @@ class SQLTableDialogDataItem(): | |||
| 1560 | return str(lower_id) | 1693 | return str(lower_id) |
| 1561 | 1694 | ||
| 1562 | def ConvertRelativeTime(self, val): | 1695 | def ConvertRelativeTime(self, val): |
| 1563 | print "val ", val | ||
| 1564 | mult = 1 | 1696 | mult = 1 |
| 1565 | suffix = val[-2:] | 1697 | suffix = val[-2:] |
| 1566 | if suffix == "ms": | 1698 | if suffix == "ms": |
| @@ -1582,29 +1714,23 @@ class SQLTableDialogDataItem(): | |||
| 1582 | return str(val) | 1714 | return str(val) |
| 1583 | 1715 | ||
| 1584 | def ConvertTimeRange(self, vrange): | 1716 | def ConvertTimeRange(self, vrange): |
| 1585 | print "vrange ", vrange | ||
| 1586 | if vrange[0] == "": | 1717 | if vrange[0] == "": |
| 1587 | vrange[0] = str(self.first_time) | 1718 | vrange[0] = str(self.first_time) |
| 1588 | if vrange[1] == "": | 1719 | if vrange[1] == "": |
| 1589 | vrange[1] = str(self.last_time) | 1720 | vrange[1] = str(self.last_time) |
| 1590 | vrange[0] = self.ConvertRelativeTime(vrange[0]) | 1721 | vrange[0] = self.ConvertRelativeTime(vrange[0]) |
| 1591 | vrange[1] = self.ConvertRelativeTime(vrange[1]) | 1722 | vrange[1] = self.ConvertRelativeTime(vrange[1]) |
| 1592 | print "vrange2 ", vrange | ||
| 1593 | if not self.IsNumber(vrange[0]) or not self.IsNumber(vrange[1]): | 1723 | if not self.IsNumber(vrange[0]) or not self.IsNumber(vrange[1]): |
| 1594 | return False | 1724 | return False |
| 1595 | print "ok1" | ||
| 1596 | beg_range = max(int(vrange[0]), self.first_time) | 1725 | beg_range = max(int(vrange[0]), self.first_time) |
| 1597 | end_range = min(int(vrange[1]), self.last_time) | 1726 | end_range = min(int(vrange[1]), self.last_time) |
| 1598 | if beg_range > self.last_time or end_range < self.first_time: | 1727 | if beg_range > self.last_time or end_range < self.first_time: |
| 1599 | return False | 1728 | return False |
| 1600 | print "ok2" | ||
| 1601 | vrange[0] = self.BinarySearchTime(0, self.last_id, beg_range, True) | 1729 | vrange[0] = self.BinarySearchTime(0, self.last_id, beg_range, True) |
| 1602 | vrange[1] = self.BinarySearchTime(1, self.last_id + 1, end_range, False) | 1730 | vrange[1] = self.BinarySearchTime(1, self.last_id + 1, end_range, False) |
| 1603 | print "vrange3 ", vrange | ||
| 1604 | return True | 1731 | return True |
| 1605 | 1732 | ||
| 1606 | def AddTimeRange(self, value, ranges): | 1733 | def AddTimeRange(self, value, ranges): |
| 1607 | print "value ", value | ||
| 1608 | n = value.count("-") | 1734 | n = value.count("-") |
| 1609 | if n == 1: | 1735 | if n == 1: |
| 1610 | pass | 1736 | pass |
| @@ -1622,111 +1748,31 @@ class SQLTableDialogDataItem(): | |||
| 1622 | return True | 1748 | return True |
| 1623 | return False | 1749 | return False |
| 1624 | 1750 | ||
| 1625 | def InvalidValue(self, value): | 1751 | def DoValidate(self, input_string): |
| 1626 | self.value = "" | 1752 | ranges = [] |
| 1627 | palette = QPalette() | 1753 | for value in [x.strip() for x in input_string.split(",")]: |
| 1628 | palette.setColor(QPalette.Text,Qt.red) | 1754 | if not self.AddTimeRange(value, ranges): |
| 1629 | self.widget.setPalette(palette) | 1755 | return self.InvalidValue(value) |
| 1630 | self.red = True | 1756 | ranges = [("(" + self.column_name + " >= " + r[0] + " AND " + self.column_name + " <= " + r[1] + ")") for r in ranges] |
| 1631 | self.error = self.label + " invalid value '" + value + "'" | 1757 | self.value = " OR ".join(ranges) |
| 1632 | self.parent.ShowMessage(self.error) | ||
| 1633 | 1758 | ||
| 1634 | def IsNumber(self, value): | 1759 | # Report Dialog Base |
| 1635 | try: | ||
| 1636 | x = int(value) | ||
| 1637 | except: | ||
| 1638 | x = 0 | ||
| 1639 | return str(x) == value | ||
| 1640 | 1760 | ||
| 1641 | def Invalidate(self): | 1761 | class ReportDialogBase(QDialog): |
| 1642 | self.validated = False | ||
| 1643 | 1762 | ||
| 1644 | def Validate(self): | 1763 | def __init__(self, glb, title, items, partial, parent=None): |
| 1645 | input_string = self.widget.text() | 1764 | super(ReportDialogBase, self).__init__(parent) |
| 1646 | self.validated = True | ||
| 1647 | if self.red: | ||
| 1648 | palette = QPalette() | ||
| 1649 | self.widget.setPalette(palette) | ||
| 1650 | self.red = False | ||
| 1651 | if not len(input_string.strip()): | ||
| 1652 | self.error = "" | ||
| 1653 | self.value = "" | ||
| 1654 | return | ||
| 1655 | if self.table_name == "<timeranges>": | ||
| 1656 | ranges = [] | ||
| 1657 | for value in [x.strip() for x in input_string.split(",")]: | ||
| 1658 | if not self.AddTimeRange(value, ranges): | ||
| 1659 | return self.InvalidValue(value) | ||
| 1660 | ranges = [("(" + self.column_name1 + " >= " + r[0] + " AND " + self.column_name1 + " <= " + r[1] + ")") for r in ranges] | ||
| 1661 | self.value = " OR ".join(ranges) | ||
| 1662 | elif self.table_name == "<ranges>": | ||
| 1663 | singles = [] | ||
| 1664 | ranges = [] | ||
| 1665 | for value in [x.strip() for x in input_string.split(",")]: | ||
| 1666 | if "-" in value: | ||
| 1667 | vrange = value.split("-") | ||
| 1668 | if len(vrange) != 2 or not self.IsNumber(vrange[0]) or not self.IsNumber(vrange[1]): | ||
| 1669 | return self.InvalidValue(value) | ||
| 1670 | ranges.append(vrange) | ||
| 1671 | else: | ||
| 1672 | if not self.IsNumber(value): | ||
| 1673 | return self.InvalidValue(value) | ||
| 1674 | singles.append(value) | ||
| 1675 | ranges = [("(" + self.column_name1 + " >= " + r[0] + " AND " + self.column_name1 + " <= " + r[1] + ")") for r in ranges] | ||
| 1676 | if len(singles): | ||
| 1677 | ranges.append(self.column_name1 + " IN (" + ",".join(singles) + ")") | ||
| 1678 | self.value = " OR ".join(ranges) | ||
| 1679 | elif self.table_name: | ||
| 1680 | all_ids = [] | ||
| 1681 | for value in [x.strip() for x in input_string.split(",")]: | ||
| 1682 | ids = self.ValueToIds(value) | ||
| 1683 | if len(ids): | ||
| 1684 | all_ids.extend(ids) | ||
| 1685 | else: | ||
| 1686 | return self.InvalidValue(value) | ||
| 1687 | self.value = self.column_name1 + " IN (" + ",".join(all_ids) + ")" | ||
| 1688 | if self.column_name2: | ||
| 1689 | self.value = "( " + self.value + " OR " + self.column_name2 + " IN (" + ",".join(all_ids) + ") )" | ||
| 1690 | else: | ||
| 1691 | self.value = input_string.strip() | ||
| 1692 | self.error = "" | ||
| 1693 | self.parent.ClearMessage() | ||
| 1694 | |||
| 1695 | def IsValid(self): | ||
| 1696 | if not self.validated: | ||
| 1697 | self.Validate() | ||
| 1698 | if len(self.error): | ||
| 1699 | self.parent.ShowMessage(self.error) | ||
| 1700 | return False | ||
| 1701 | return True | ||
| 1702 | |||
| 1703 | # Selected branch report creation dialog | ||
| 1704 | |||
| 1705 | class SelectedBranchDialog(QDialog): | ||
| 1706 | |||
| 1707 | def __init__(self, glb, parent=None): | ||
| 1708 | super(SelectedBranchDialog, self).__init__(parent) | ||
| 1709 | 1765 | ||
| 1710 | self.glb = glb | 1766 | self.glb = glb |
| 1711 | 1767 | ||
| 1712 | self.name = "" | 1768 | self.report_vars = ReportVars() |
| 1713 | self.where_clause = "" | ||
| 1714 | 1769 | ||
| 1715 | self.setWindowTitle("Selected Branches") | 1770 | self.setWindowTitle(title) |
| 1716 | self.setMinimumWidth(600) | 1771 | self.setMinimumWidth(600) |
| 1717 | 1772 | ||
| 1718 | items = ( | 1773 | self.data_items = [x(glb, self) for x in items] |
| 1719 | ("Report name:", "Enter a name to appear in the window title bar", "", "", "", ""), | 1774 | |
| 1720 | ("Time ranges:", "Enter time ranges", "<timeranges>", "", "samples.id", ""), | 1775 | self.partial = partial |
| 1721 | ("CPUs:", "Enter CPUs or ranges e.g. 0,5-6", "<ranges>", "", "cpu", ""), | ||
| 1722 | ("Commands:", "Only branches with these commands will be included", "comms", "comm", "comm_id", ""), | ||
| 1723 | ("PIDs:", "Only branches with these process IDs will be included", "threads", "pid", "thread_id", ""), | ||
| 1724 | ("TIDs:", "Only branches with these thread IDs will be included", "threads", "tid", "thread_id", ""), | ||
| 1725 | ("DSOs:", "Only branches with these DSOs will be included", "dsos", "short_name", "samples.dso_id", "to_dso_id"), | ||
| 1726 | ("Symbols:", "Only branches with these symbols will be included", "symbols", "name", "symbol_id", "to_symbol_id"), | ||
| 1727 | ("Raw SQL clause: ", "Enter a raw SQL WHERE clause", "", "", "", ""), | ||
| 1728 | ) | ||
| 1729 | self.data_items = [SQLTableDialogDataItem(glb, *x, parent=self) for x in items] | ||
| 1730 | 1776 | ||
| 1731 | self.grid = QGridLayout() | 1777 | self.grid = QGridLayout() |
| 1732 | 1778 | ||
| @@ -1758,23 +1804,28 @@ class SelectedBranchDialog(QDialog): | |||
| 1758 | self.setLayout(self.vbox); | 1804 | self.setLayout(self.vbox); |
| 1759 | 1805 | ||
| 1760 | def Ok(self): | 1806 | def Ok(self): |
| 1761 | self.name = self.data_items[0].value | 1807 | vars = self.report_vars |
| 1762 | if not self.name: | 1808 | for d in self.data_items: |
| 1809 | if d.id == "REPORTNAME": | ||
| 1810 | vars.name = d.value | ||
| 1811 | if not vars.name: | ||
| 1763 | self.ShowMessage("Report name is required") | 1812 | self.ShowMessage("Report name is required") |
| 1764 | return | 1813 | return |
| 1765 | for d in self.data_items: | 1814 | for d in self.data_items: |
| 1766 | if not d.IsValid(): | 1815 | if not d.IsValid(): |
| 1767 | return | 1816 | return |
| 1768 | for d in self.data_items[1:]: | 1817 | for d in self.data_items[1:]: |
| 1769 | if len(d.value): | 1818 | if d.id == "LIMIT": |
| 1770 | if len(self.where_clause): | 1819 | vars.limit = d.value |
| 1771 | self.where_clause += " AND " | 1820 | elif len(d.value): |
| 1772 | self.where_clause += d.value | 1821 | if len(vars.where_clause): |
| 1773 | if len(self.where_clause): | 1822 | vars.where_clause += " AND " |
| 1774 | self.where_clause = " AND ( " + self.where_clause + " ) " | 1823 | vars.where_clause += d.value |
| 1775 | else: | 1824 | if len(vars.where_clause): |
| 1776 | self.ShowMessage("No selection") | 1825 | if self.partial: |
| 1777 | return | 1826 | vars.where_clause = " AND ( " + vars.where_clause + " ) " |
| 1827 | else: | ||
| 1828 | vars.where_clause = " WHERE " + vars.where_clause + " " | ||
| 1778 | self.accept() | 1829 | self.accept() |
| 1779 | 1830 | ||
| 1780 | def ShowMessage(self, msg): | 1831 | def ShowMessage(self, msg): |
| @@ -1783,6 +1834,23 @@ class SelectedBranchDialog(QDialog): | |||
| 1783 | def ClearMessage(self): | 1834 | def ClearMessage(self): |
| 1784 | self.status.setText("") | 1835 | self.status.setText("") |
| 1785 | 1836 | ||
| 1837 | # Selected branch report creation dialog | ||
| 1838 | |||
| 1839 | class SelectedBranchDialog(ReportDialogBase): | ||
| 1840 | |||
| 1841 | def __init__(self, glb, parent=None): | ||
| 1842 | title = "Selected Branches" | ||
| 1843 | items = (lambda g, p: LineEditDataItem(g, "Report name:", "Enter a name to appear in the window title bar", p, "REPORTNAME"), | ||
| 1844 | lambda g, p: SampleTimeRangesDataItem(g, "Time ranges:", "Enter time ranges", "samples.id", p), | ||
| 1845 | lambda g, p: NonNegativeIntegerRangesDataItem(g, "CPUs:", "Enter CPUs or ranges e.g. 0,5-6", "cpu", p), | ||
| 1846 | lambda g, p: SQLTableDataItem(g, "Commands:", "Only branches with these commands will be included", "comms", "comm", "comm_id", "", p), | ||
| 1847 | lambda g, p: SQLTableDataItem(g, "PIDs:", "Only branches with these process IDs will be included", "threads", "pid", "thread_id", "", p), | ||
| 1848 | lambda g, p: SQLTableDataItem(g, "TIDs:", "Only branches with these thread IDs will be included", "threads", "tid", "thread_id", "", p), | ||
| 1849 | lambda g, p: SQLTableDataItem(g, "DSOs:", "Only branches with these DSOs will be included", "dsos", "short_name", "samples.dso_id", "to_dso_id", p), | ||
| 1850 | lambda g, p: SQLTableDataItem(g, "Symbols:", "Only branches with these symbols will be included", "symbols", "name", "symbol_id", "to_symbol_id", p), | ||
| 1851 | lambda g, p: LineEditDataItem(g, "Raw SQL clause: ", "Enter a raw SQL WHERE clause", p)) | ||
| 1852 | super(SelectedBranchDialog, self).__init__(glb, title, items, True, parent) | ||
| 1853 | |||
| 1786 | # Event list | 1854 | # Event list |
| 1787 | 1855 | ||
| 1788 | def GetEventList(db): | 1856 | def GetEventList(db): |
| @@ -1793,6 +1861,16 @@ def GetEventList(db): | |||
| 1793 | events.append(query.value(0)) | 1861 | events.append(query.value(0)) |
| 1794 | return events | 1862 | return events |
| 1795 | 1863 | ||
| 1864 | # Is a table selectable | ||
| 1865 | |||
| 1866 | def IsSelectable(db, table): | ||
| 1867 | query = QSqlQuery(db) | ||
| 1868 | try: | ||
| 1869 | QueryExec(query, "SELECT * FROM " + table + " LIMIT 1") | ||
| 1870 | except: | ||
| 1871 | return False | ||
| 1872 | return True | ||
| 1873 | |||
| 1796 | # SQL data preparation | 1874 | # SQL data preparation |
| 1797 | 1875 | ||
| 1798 | def SQLTableDataPrep(query, count): | 1876 | def SQLTableDataPrep(query, count): |
| @@ -1818,12 +1896,13 @@ class SQLTableModel(TableModel): | |||
| 1818 | 1896 | ||
| 1819 | progress = Signal(object) | 1897 | progress = Signal(object) |
| 1820 | 1898 | ||
| 1821 | def __init__(self, glb, sql, column_count, parent=None): | 1899 | def __init__(self, glb, sql, column_headers, parent=None): |
| 1822 | super(SQLTableModel, self).__init__(parent) | 1900 | super(SQLTableModel, self).__init__(parent) |
| 1823 | self.glb = glb | 1901 | self.glb = glb |
| 1824 | self.more = True | 1902 | self.more = True |
| 1825 | self.populated = 0 | 1903 | self.populated = 0 |
| 1826 | self.fetcher = SQLFetcher(glb, sql, lambda x, y=column_count: SQLTableDataPrep(x, y), self.AddSample) | 1904 | self.column_headers = column_headers |
| 1905 | self.fetcher = SQLFetcher(glb, sql, lambda x, y=len(column_headers): SQLTableDataPrep(x, y), self.AddSample) | ||
| 1827 | self.fetcher.done.connect(self.Update) | 1906 | self.fetcher.done.connect(self.Update) |
| 1828 | self.fetcher.Fetch(glb_chunk_sz) | 1907 | self.fetcher.Fetch(glb_chunk_sz) |
| 1829 | 1908 | ||
| @@ -1861,6 +1940,12 @@ class SQLTableModel(TableModel): | |||
| 1861 | def HasMoreRecords(self): | 1940 | def HasMoreRecords(self): |
| 1862 | return self.more | 1941 | return self.more |
| 1863 | 1942 | ||
| 1943 | def columnCount(self, parent=None): | ||
| 1944 | return len(self.column_headers) | ||
| 1945 | |||
| 1946 | def columnHeader(self, column): | ||
| 1947 | return self.column_headers[column] | ||
| 1948 | |||
| 1864 | # SQL automatic table data model | 1949 | # SQL automatic table data model |
| 1865 | 1950 | ||
| 1866 | class SQLAutoTableModel(SQLTableModel): | 1951 | class SQLAutoTableModel(SQLTableModel): |
| @@ -1870,12 +1955,12 @@ class SQLAutoTableModel(SQLTableModel): | |||
| 1870 | if table_name == "comm_threads_view": | 1955 | if table_name == "comm_threads_view": |
| 1871 | # For now, comm_threads_view has no id column | 1956 | # For now, comm_threads_view has no id column |
| 1872 | sql = "SELECT * FROM " + table_name + " WHERE comm_id > $$last_id$$ ORDER BY comm_id LIMIT " + str(glb_chunk_sz) | 1957 | sql = "SELECT * FROM " + table_name + " WHERE comm_id > $$last_id$$ ORDER BY comm_id LIMIT " + str(glb_chunk_sz) |
| 1873 | self.column_headers = [] | 1958 | column_headers = [] |
| 1874 | query = QSqlQuery(glb.db) | 1959 | query = QSqlQuery(glb.db) |
| 1875 | if glb.dbref.is_sqlite3: | 1960 | if glb.dbref.is_sqlite3: |
| 1876 | QueryExec(query, "PRAGMA table_info(" + table_name + ")") | 1961 | QueryExec(query, "PRAGMA table_info(" + table_name + ")") |
| 1877 | while query.next(): | 1962 | while query.next(): |
| 1878 | self.column_headers.append(query.value(1)) | 1963 | column_headers.append(query.value(1)) |
| 1879 | if table_name == "sqlite_master": | 1964 | if table_name == "sqlite_master": |
| 1880 | sql = "SELECT * FROM " + table_name | 1965 | sql = "SELECT * FROM " + table_name |
| 1881 | else: | 1966 | else: |
| @@ -1888,14 +1973,8 @@ class SQLAutoTableModel(SQLTableModel): | |||
| 1888 | schema = "public" | 1973 | schema = "public" |
| 1889 | QueryExec(query, "SELECT column_name FROM information_schema.columns WHERE table_schema = '" + schema + "' and table_name = '" + select_table_name + "'") | 1974 | QueryExec(query, "SELECT column_name FROM information_schema.columns WHERE table_schema = '" + schema + "' and table_name = '" + select_table_name + "'") |
| 1890 | while query.next(): | 1975 | while query.next(): |
| 1891 | self.column_headers.append(query.value(0)) | 1976 | column_headers.append(query.value(0)) |
| 1892 | super(SQLAutoTableModel, self).__init__(glb, sql, len(self.column_headers), parent) | 1977 | super(SQLAutoTableModel, self).__init__(glb, sql, column_headers, parent) |
| 1893 | |||
| 1894 | def columnCount(self, parent=None): | ||
| 1895 | return len(self.column_headers) | ||
| 1896 | |||
| 1897 | def columnHeader(self, column): | ||
| 1898 | return self.column_headers[column] | ||
| 1899 | 1978 | ||
| 1900 | # Base class for custom ResizeColumnsToContents | 1979 | # Base class for custom ResizeColumnsToContents |
| 1901 | 1980 | ||
| @@ -1998,6 +2077,103 @@ def GetTableList(glb): | |||
| 1998 | tables.append("information_schema.columns") | 2077 | tables.append("information_schema.columns") |
| 1999 | return tables | 2078 | return tables |
| 2000 | 2079 | ||
| 2080 | # Top Calls data model | ||
| 2081 | |||
| 2082 | class TopCallsModel(SQLTableModel): | ||
| 2083 | |||
| 2084 | def __init__(self, glb, report_vars, parent=None): | ||
| 2085 | text = "" | ||
| 2086 | if not glb.dbref.is_sqlite3: | ||
| 2087 | text = "::text" | ||
| 2088 | limit = "" | ||
| 2089 | if len(report_vars.limit): | ||
| 2090 | limit = " LIMIT " + report_vars.limit | ||
| 2091 | sql = ("SELECT comm, pid, tid, name," | ||
| 2092 | " CASE" | ||
| 2093 | " WHEN (short_name = '[kernel.kallsyms]') THEN '[kernel]'" + text + | ||
| 2094 | " ELSE short_name" | ||
| 2095 | " END AS dso," | ||
| 2096 | " call_time, return_time, (return_time - call_time) AS elapsed_time, branch_count, " | ||
| 2097 | " CASE" | ||
| 2098 | " WHEN (calls.flags = 1) THEN 'no call'" + text + | ||
| 2099 | " WHEN (calls.flags = 2) THEN 'no return'" + text + | ||
| 2100 | " WHEN (calls.flags = 3) THEN 'no call/return'" + text + | ||
| 2101 | " ELSE ''" + text + | ||
| 2102 | " END AS flags" | ||
| 2103 | " FROM calls" | ||
| 2104 | " INNER JOIN call_paths ON calls.call_path_id = call_paths.id" | ||
| 2105 | " INNER JOIN symbols ON call_paths.symbol_id = symbols.id" | ||
| 2106 | " INNER JOIN dsos ON symbols.dso_id = dsos.id" | ||
| 2107 | " INNER JOIN comms ON calls.comm_id = comms.id" | ||
| 2108 | " INNER JOIN threads ON calls.thread_id = threads.id" + | ||
| 2109 | report_vars.where_clause + | ||
| 2110 | " ORDER BY elapsed_time DESC" + | ||
| 2111 | limit | ||
| 2112 | ) | ||
| 2113 | column_headers = ("Command", "PID", "TID", "Symbol", "Object", "Call Time", "Return Time", "Elapsed Time (ns)", "Branch Count", "Flags") | ||
| 2114 | self.alignment = (Qt.AlignLeft, Qt.AlignLeft, Qt.AlignLeft, Qt.AlignLeft, Qt.AlignLeft, Qt.AlignLeft, Qt.AlignLeft, Qt.AlignRight, Qt.AlignRight, Qt.AlignLeft) | ||
| 2115 | super(TopCallsModel, self).__init__(glb, sql, column_headers, parent) | ||
| 2116 | |||
| 2117 | def columnAlignment(self, column): | ||
| 2118 | return self.alignment[column] | ||
| 2119 | |||
| 2120 | # Top Calls report creation dialog | ||
| 2121 | |||
| 2122 | class TopCallsDialog(ReportDialogBase): | ||
| 2123 | |||
| 2124 | def __init__(self, glb, parent=None): | ||
| 2125 | title = "Top Calls by Elapsed Time" | ||
| 2126 | items = (lambda g, p: LineEditDataItem(g, "Report name:", "Enter a name to appear in the window title bar", p, "REPORTNAME"), | ||
| 2127 | lambda g, p: SQLTableDataItem(g, "Commands:", "Only calls with these commands will be included", "comms", "comm", "comm_id", "", p), | ||
| 2128 | lambda g, p: SQLTableDataItem(g, "PIDs:", "Only calls with these process IDs will be included", "threads", "pid", "thread_id", "", p), | ||
| 2129 | lambda g, p: SQLTableDataItem(g, "TIDs:", "Only calls with these thread IDs will be included", "threads", "tid", "thread_id", "", p), | ||
| 2130 | lambda g, p: SQLTableDataItem(g, "DSOs:", "Only calls with these DSOs will be included", "dsos", "short_name", "dso_id", "", p), | ||
| 2131 | lambda g, p: SQLTableDataItem(g, "Symbols:", "Only calls with these symbols will be included", "symbols", "name", "symbol_id", "", p), | ||
| 2132 | lambda g, p: LineEditDataItem(g, "Raw SQL clause: ", "Enter a raw SQL WHERE clause", p), | ||
| 2133 | lambda g, p: PositiveIntegerDataItem(g, "Record limit:", "Limit selection to this number of records", p, "LIMIT", "100")) | ||
| 2134 | super(TopCallsDialog, self).__init__(glb, title, items, False, parent) | ||
| 2135 | |||
| 2136 | # Top Calls window | ||
| 2137 | |||
| 2138 | class TopCallsWindow(QMdiSubWindow, ResizeColumnsToContentsBase): | ||
| 2139 | |||
| 2140 | def __init__(self, glb, report_vars, parent=None): | ||
| 2141 | super(TopCallsWindow, self).__init__(parent) | ||
| 2142 | |||
| 2143 | self.data_model = LookupCreateModel("Top Calls " + report_vars.UniqueId(), lambda: TopCallsModel(glb, report_vars)) | ||
| 2144 | self.model = self.data_model | ||
| 2145 | |||
| 2146 | self.view = QTableView() | ||
| 2147 | self.view.setModel(self.model) | ||
| 2148 | self.view.setEditTriggers(QAbstractItemView.NoEditTriggers) | ||
| 2149 | self.view.verticalHeader().setVisible(False) | ||
| 2150 | |||
| 2151 | self.ResizeColumnsToContents() | ||
| 2152 | |||
| 2153 | self.find_bar = FindBar(self, self, True) | ||
| 2154 | |||
| 2155 | self.finder = ChildDataItemFinder(self.model) | ||
| 2156 | |||
| 2157 | self.fetch_bar = FetchMoreRecordsBar(self.data_model, self) | ||
| 2158 | |||
| 2159 | self.vbox = VBox(self.view, self.find_bar.Widget(), self.fetch_bar.Widget()) | ||
| 2160 | |||
| 2161 | self.setWidget(self.vbox.Widget()) | ||
| 2162 | |||
| 2163 | AddSubWindow(glb.mainwindow.mdi_area, self, report_vars.name) | ||
| 2164 | |||
| 2165 | def Find(self, value, direction, pattern, context): | ||
| 2166 | self.view.setFocus() | ||
| 2167 | self.find_bar.Busy() | ||
| 2168 | self.finder.Find(value, direction, pattern, context, self.FindDone) | ||
| 2169 | |||
| 2170 | def FindDone(self, row): | ||
| 2171 | self.find_bar.Idle() | ||
| 2172 | if row >= 0: | ||
| 2173 | self.view.setCurrentIndex(self.model.index(row, 0, QModelIndex())) | ||
| 2174 | else: | ||
| 2175 | self.find_bar.NotFound() | ||
| 2176 | |||
| 2001 | # Action Definition | 2177 | # Action Definition |
| 2002 | 2178 | ||
| 2003 | def CreateAction(label, tip, callback, parent=None, shortcut=None): | 2179 | def CreateAction(label, tip, callback, parent=None, shortcut=None): |
| @@ -2101,6 +2277,7 @@ p.c2 { | |||
| 2101 | <p class=c2><a href=#callgraph>1.1 Context-Sensitive Call Graph</a></p> | 2277 | <p class=c2><a href=#callgraph>1.1 Context-Sensitive Call Graph</a></p> |
| 2102 | <p class=c2><a href=#allbranches>1.2 All branches</a></p> | 2278 | <p class=c2><a href=#allbranches>1.2 All branches</a></p> |
| 2103 | <p class=c2><a href=#selectedbranches>1.3 Selected branches</a></p> | 2279 | <p class=c2><a href=#selectedbranches>1.3 Selected branches</a></p> |
| 2280 | <p class=c2><a href=#topcallsbyelapsedtime>1.4 Top calls by elapsed time</a></p> | ||
| 2104 | <p class=c1><a href=#tables>2. Tables</a></p> | 2281 | <p class=c1><a href=#tables>2. Tables</a></p> |
| 2105 | <h1 id=reports>1. Reports</h1> | 2282 | <h1 id=reports>1. Reports</h1> |
| 2106 | <h2 id=callgraph>1.1 Context-Sensitive Call Graph</h2> | 2283 | <h2 id=callgraph>1.1 Context-Sensitive Call Graph</h2> |
| @@ -2176,6 +2353,10 @@ ms, us or ns. Also, negative values are relative to the end of trace. Examples: | |||
| 2176 | -10ms- The last 10ms | 2353 | -10ms- The last 10ms |
| 2177 | </pre> | 2354 | </pre> |
| 2178 | N.B. Due to the granularity of timestamps, there could be no branches in any given time range. | 2355 | N.B. Due to the granularity of timestamps, there could be no branches in any given time range. |
| 2356 | <h2 id=topcallsbyelapsedtime>1.4 Top calls by elapsed time</h2> | ||
| 2357 | The Top calls by elapsed time report displays calls in descending order of time elapsed between when the function was called and when it returned. | ||
| 2358 | The data is reduced by various selection criteria. A dialog box displays available criteria which are AND'ed together. | ||
| 2359 | If not all data is fetched, a Fetch bar is provided. Ctrl-F displays a Find bar. | ||
| 2179 | <h1 id=tables>2. Tables</h1> | 2360 | <h1 id=tables>2. Tables</h1> |
| 2180 | The Tables menu shows all tables and views in the database. Most tables have an associated view | 2361 | The Tables menu shows all tables and views in the database. Most tables have an associated view |
| 2181 | which displays the information in a more friendly way. Not all data for large tables is fetched | 2362 | which displays the information in a more friendly way. Not all data for large tables is fetched |
| @@ -2305,10 +2486,14 @@ class MainWindow(QMainWindow): | |||
| 2305 | edit_menu.addAction(CreateAction("&Enlarge Font", "Make text bigger", self.EnlargeFont, self, [QKeySequence("Ctrl++")])) | 2486 | edit_menu.addAction(CreateAction("&Enlarge Font", "Make text bigger", self.EnlargeFont, self, [QKeySequence("Ctrl++")])) |
| 2306 | 2487 | ||
| 2307 | reports_menu = menu.addMenu("&Reports") | 2488 | reports_menu = menu.addMenu("&Reports") |
| 2308 | reports_menu.addAction(CreateAction("Context-Sensitive Call &Graph", "Create a new window containing a context-sensitive call graph", self.NewCallGraph, self)) | 2489 | if IsSelectable(glb.db, "calls"): |
| 2490 | reports_menu.addAction(CreateAction("Context-Sensitive Call &Graph", "Create a new window containing a context-sensitive call graph", self.NewCallGraph, self)) | ||
| 2309 | 2491 | ||
| 2310 | self.EventMenu(GetEventList(glb.db), reports_menu) | 2492 | self.EventMenu(GetEventList(glb.db), reports_menu) |
| 2311 | 2493 | ||
| 2494 | if IsSelectable(glb.db, "calls"): | ||
| 2495 | reports_menu.addAction(CreateAction("&Top calls by elapsed time", "Create a new window displaying top calls by elapsed time", self.NewTopCalls, self)) | ||
| 2496 | |||
| 2312 | self.TableMenu(GetTableList(glb), menu) | 2497 | self.TableMenu(GetTableList(glb), menu) |
| 2313 | 2498 | ||
| 2314 | self.window_menu = WindowMenu(self.mdi_area, menu) | 2499 | self.window_menu = WindowMenu(self.mdi_area, menu) |
| @@ -2364,14 +2549,20 @@ class MainWindow(QMainWindow): | |||
| 2364 | def NewCallGraph(self): | 2549 | def NewCallGraph(self): |
| 2365 | CallGraphWindow(self.glb, self) | 2550 | CallGraphWindow(self.glb, self) |
| 2366 | 2551 | ||
| 2552 | def NewTopCalls(self): | ||
| 2553 | dialog = TopCallsDialog(self.glb, self) | ||
| 2554 | ret = dialog.exec_() | ||
| 2555 | if ret: | ||
| 2556 | TopCallsWindow(self.glb, dialog.report_vars, self) | ||
| 2557 | |||
| 2367 | def NewBranchView(self, event_id): | 2558 | def NewBranchView(self, event_id): |
| 2368 | BranchWindow(self.glb, event_id, "", "", self) | 2559 | BranchWindow(self.glb, event_id, ReportVars(), self) |
| 2369 | 2560 | ||
| 2370 | def NewSelectedBranchView(self, event_id): | 2561 | def NewSelectedBranchView(self, event_id): |
| 2371 | dialog = SelectedBranchDialog(self.glb, self) | 2562 | dialog = SelectedBranchDialog(self.glb, self) |
| 2372 | ret = dialog.exec_() | 2563 | ret = dialog.exec_() |
| 2373 | if ret: | 2564 | if ret: |
| 2374 | BranchWindow(self.glb, event_id, dialog.name, dialog.where_clause, self) | 2565 | BranchWindow(self.glb, event_id, dialog.report_vars, self) |
| 2375 | 2566 | ||
| 2376 | def NewTableView(self, table_name): | 2567 | def NewTableView(self, table_name): |
| 2377 | TableWindow(self.glb, table_name, self) | 2568 | TableWindow(self.glb, table_name, self) |
