Exemplo n.º 1
0
    def _add_child_to_owner_addrs(self, addrs_to_owner_addrs, owner_obj, child):
        parent_obj = None

        if type(child) is model.ChildGroup:
            # do not change the current owner object since this is
            # a child group, not a child containing an actual object
            parent_obj = child
        else:
            if btautils.bt_obj_has_addr(child.object):
                if child.object.addr.value not in addrs_to_owner_addrs:
                    addrs_to_owner_addrs[child.object.addr.value] = set()

                if child.is_owned:
                    # strong reference to child
                    self._addrs_to_owner_addrs_add(addrs_to_owner_addrs,
                                                   owner_obj.addr,
                                                   child.object.addr)

                if not child.object.addr.is_null:
                    parent_obj = child.object
                    owner_obj = child.object

        if isinstance(parent_obj, model.BtObject) or isinstance(parent_obj, model.ChildGroup):
            for ch in parent_obj.children:
                self._add_child_to_owner_addrs(addrs_to_owner_addrs,
                                               owner_obj, ch)
Exemplo n.º 2
0
    def _update_owners(self, bt_obj):
        self._owners_tree_widget.clear()

        if not btautils.bt_obj_has_addr(bt_obj):
            self._owners_tree_box.setEnabled(False)
            return

        self._owners_tree_box.setEnabled(True)
        self._fill_owners_tree(bt_obj)
        _resize_column_to_contents(self._owners_tree_widget, 0)
Exemplo n.º 3
0
    def _get_row(self, child, addrs_to_owner_addrs):
        if type(child) is model.Child:
            bt_obj = child.object
        else:
            bt_obj = None

        type_name = ''
        addr = ''
        refs = ''
        owners = ''
        flags = ''
        name = ''
        id = ''
        summary = ''

        if bt_obj is not None:
            summary = bt_obj.summary

        flags = self._get_flags_string(child)

        if isinstance(bt_obj, model.BtObject):
            refs = bt_obj.refs

        if hasattr(bt_obj, 'type_name'):
            type_name = bt_obj.type_name

        if hasattr(bt_obj, 'id'):
            id = bt_obj.id

        if btautils.bt_obj_has_addr(bt_obj):
            addr = bt_obj.addr

            if addr.value in addrs_to_owner_addrs:
                owners = len(addrs_to_owner_addrs[addr.value])
            else:
                owners = 0

        if child.name:
            name = child.name

        return [
            name,
            type_name,
            str(id),
            str(addr),
            str(refs),
            str(owners),
            flags,
            summary,
        ]
Exemplo n.º 4
0
    def _copy_casted_address(self):
        current_objs_tree_wi = self._objs_tree_widget.currentItem()
        bt_obj = _bt_obj_from_widget_item(current_objs_tree_wi)

        if not btautils.bt_obj_has_addr(bt_obj):
            return

        if hasattr(bt_obj, 'c_type'):
            to_copy = '(({}) {})'.format(bt_obj.c_type, bt_obj.addr)
        else:
            to_copy = str(bt_obj.addr)

        clipboard = Qt.QApplication.instance().clipboard()
        clipboard.setText(to_copy)
Exemplo n.º 5
0
    def _update_stack(self, bt_obj):
        self._stack_tree_widget.clear()

        if not btautils.bt_obj_has_addr(bt_obj) or bt_obj.addr.is_null:
            return

        for frame_index, frame in enumerate(self._backtrace.frames):
            frame_name = '#{} {}'.format(frame_index, frame.name)
            row = [frame_name, '', '']
            frame_wi = Qt.QTreeWidgetItem(self._stack_tree_widget, row)

            for block_index, block in enumerate(frame.blocks):
                if len(frame.blocks) == 1:
                    parent_wi = frame_wi
                else:
                    row = [str(block_index), '', '', '']
                    parent_wi = Qt.QTreeWidgetItem(frame_wi, row)

                for var in block.variables:
                    if var.value != bt_obj.addr.value:
                        continue

                    row = [
                        var.name,
                        var.type,
                        '0x{:x}'.format(var.value),
                    ]
                    var_wi = Qt.QTreeWidgetItem(parent_wi, row)
                    self._set_stack_tree_wi_font(var_wi)
                    var_wi.setFont(0, self._bold_mono_font)

                self._set_stack_tree_wi_font(parent_wi)
                parent_wi.setExpanded(True)

            self._set_stack_tree_wi_font(frame_wi)
            frame_wi.setExpanded(True)

        _resize_all_columns_to_contents(self._stack_tree_widget)