diff --git a/lisa/_assets/kmodules/lisa/introspect_header.py b/lisa/_assets/kmodules/lisa/introspect_header.py index c173fb1e9d9f69dad477fc668f2cb59ee43669ff..6654a0b0217e4ae3fbd7b5cd6c89b067f6aa1cfe 100755 --- a/lisa/_assets/kmodules/lisa/introspect_header.py +++ b/lisa/_assets/kmodules/lisa/introspect_header.py @@ -30,7 +30,7 @@ import re import lisa._btf as btf -def process_btf(out, path, introspect, internal_type_prefix, define_typ_names): +def process_btf(out, path, introspect, internal_type_prefix, define_typ_names, define_tp_vtable): internal_type_prefix = internal_type_prefix or '' with open(path, 'rb') as f: data = f.read() @@ -131,8 +131,50 @@ def process_btf(out, path, introspect, internal_type_prefix, define_typ_names): if isinstance(typ, named_classes) and typ.name: typ.name = rename_internal_typ(typ) + if define_tp_vtable: + def process_typ(typ): + if isinstance(typ, btf.BTFPtr) and isinstance(typ.typ, btf.BTFStruct): + typ.typ = btf._LinkedForwardDecl(typ.typ) + + return typ + + def process_param(param): + typ = param.typ + param.typ = process_typ(typ) + return param + + def process_member(member): + typ = member.typ + if isinstance(typ, btf.BTFPtr) and isinstance(typ.typ, btf.BTFFuncProto): + proto = typ.typ + # Process each parameter of the function + for param in proto.params: + process_param(param) + # Also process the return type of the function + proto.typ = process_typ(proto.typ) + return member + + def process_vtable(typ): + for member in typ.members: + process_member(member) + return typ + + def select(typ): + if isinstance(typ, btf.BTFStruct): + return typ.name in define_tp_vtable + else: + return False + + vtable_typs = set(filter(select, typs)) + for vtable_typ in vtable_typs: + process_vtable(vtable_typ) + else: + vtable_typs = set() + + to_dump = reachable_typs | vtable_typs + # Dump declaration for all the types we are interested in - btf.dump_c(reachable_typs, fileobj=out, introspection=False, decls=True) + btf.dump_c(to_dump, fileobj=out, introspection=False, decls=True) def is_exported_symbol(code): @@ -280,7 +322,14 @@ def main(): try: if args.btf: - process_btf(out, args.btf, args.introspect, args.internal_type_prefix, conf.get('btf-types', [])) + process_btf( + out=out, + path=args.btf, + introspect=args.introspect, + internal_type_prefix=args.internal_type_prefix, + define_typ_names=conf.get('btf-types', []), + define_tp_vtable=conf.get('tracepoint-vtables'), + ) if args.kallsyms and args.introspect: dump_records(process_kallsyms_introspection(args.kallsyms)) diff --git a/lisa/_assets/kmodules/lisa/introspection.json b/lisa/_assets/kmodules/lisa/introspection.json index b3fc671f89b9eb9630c1acfdfcf1ffec11aa626f..e1f32b6e67bbb15d10cd861a50aa51f7fca363b2 100644 --- a/lisa/_assets/kmodules/lisa/introspection.json +++ b/lisa/_assets/kmodules/lisa/introspection.json @@ -6,6 +6,9 @@ "task_group", "autogroup" ], + "tracepoint-vtables": [ + "trace_probe_callbacks" + ], "kernel-features": { "RQ_CAPACITY": "HAS_MEMBER(struct, rq, cpu_capacity)", "RQ_NR_RUNNING": "HAS_MEMBER(struct, rq, nr_running)",