[DTrace-devel] refactoring trampoline code generation

Eugene Loh eugene.loh at oracle.com
Tue Jun 9 16:42:13 PDT 2020


I'm thinking about a profile provider, but was considering some code 
refactoring in anticipation.

One of the current maintenance issues is that the various providers 
replicate so much code, notably in trampoline generation.  The various 
trampolines must all fill in the "struct dt_bpf_context", which 
basically means the EPID and args.  They must also step around those 
values, zero-filling the other contents of that context.  They then set 
up and call dt_program, finally exiting.  (Currently, regs are not 
copied, with some redesign of the BPF stack layout in the works.)

So really, the only difference among the trampolines is filling in the 
probe arguments.

How would it be if I were to submit a patch that adds a "static void 
dt_cg_trampoline(dt_pcb_t *pcb)" to dt_cg.c.  Then, dt_cg() would call 
this function instead of the provider-specific versions.  The function 
would generate most of the trampoline itself.  For probe arguments, it 
would call the provider-specific function 
pcb->pcb_probe->prov->impl->trampoline(). Common boiler-plate code 
generation would be removed from the provider-specific trampolines.

Let me know.  A simple patch that removes a bunch of replicated code.




More information about the DTrace-devel mailing list