aboutsummaryrefslogtreecommitdiff
path: root/scripts/gdb/kstd/vector.py
blob: b42aeae7d6127e847b22ed21e58861884e4aff78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gdb


class KstdVectorPrinter:

    def __init__(self, val):
        self.val = val
        self.type = val.type.template_argument(0)

    def to_string(self):
        size = int(self.val(["m_size"]))
        capacity = int(self.val(["m_capacity"]))
        return f"kstd::vector<{self.type}> of length {size}, capacity {capacity}"

    def children(self):
        size = int(self.val["m_size"])
        data_pointer = self.val["m_data"]
        for i in range(size):
            yield (f"[{i}]", (data_pointer + i).dereference())

    def display_hint(self):
        return "array"