|
21 | 21 | import sys |
22 | 22 |
|
23 | 23 | class Allocation(object): |
24 | | - def __init__(self, stack, size): |
| 24 | + def __init__(self, stack, size, type_index): |
25 | 25 | self.stack = stack |
26 | 26 | self.count = 1 |
27 | 27 | self.size = size |
| 28 | + self.type_index = type_index |
28 | 29 |
|
29 | 30 | def update(self, size): |
30 | 31 | self.count += 1 |
@@ -154,6 +155,7 @@ def run_command_get_pid(command): |
154 | 155 | u64 size; |
155 | 156 | u64 timestamp_ns; |
156 | 157 | int stack_id; |
| 158 | + u32 type_index; |
157 | 159 | }; |
158 | 160 |
|
159 | 161 | struct combined_alloc_info_t { |
@@ -243,6 +245,7 @@ def run_command_get_pid(command): |
243 | 245 | if (address != 0) { |
244 | 246 | info.timestamp_ns = bpf_ktime_get_ns(); |
245 | 247 | info.stack_id = stack_traces.get_stackid(ctx, STACK_FLAGS); |
| 248 | + info.type_index = type_index |
246 | 249 | allocs.update(&address, &info); |
247 | 250 | update_statistics_add(info.stack_id, info.size); |
248 | 251 | } |
@@ -549,14 +552,15 @@ def print_outstanding(): |
549 | 552 | combined.append(('0x'+format(addr, '016x')+'\t').encode('utf-8') + bpf.sym(addr, pid, |
550 | 553 | show_module=True, show_offset=True)) |
551 | 554 | alloc_info[info.stack_id] = Allocation(combined, |
552 | | - info.size) |
| 555 | + info.size, |
| 556 | + info.type_index) |
553 | 557 | if args.show_allocs: |
554 | 558 | print("\taddr = %x size = %s" % |
555 | 559 | (address.value, info.size)) |
556 | 560 | to_show = sorted(alloc_info.values(), key=alloc_sort_map[sort_key])[-top_stacks:] |
557 | 561 | for alloc in to_show: |
558 | | - print("\t%d bytes in %d allocations from stack\n\t\t%s" % |
559 | | - (alloc.size, alloc.count, |
| 562 | + print("\t%d bytes in %d allocations of type %d from stack\n\t\t%s" % |
| 563 | + (alloc.size, alloc.count, alloc.type_index |
560 | 564 | b"\n\t\t".join(alloc.stack).decode("ascii"))) |
561 | 565 |
|
562 | 566 | def print_outstanding_combined(): |
|
0 commit comments