[DTrace-devel] [PATCH 1/2] Add raise() support

Kris Van Hees kris.van.hees at oracle.com
Tue Jul 21 14:17:02 PDT 2020


On Fri, Jul 17, 2020 at 03:00:05PM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>

I added a comment block as a FIXME for future enhancement to handle the
failure mode that DTrace supports (ILLOP fault if sig is invalid).  I
also added a comment that we may consider adding additional failures
modes beyond what DTrace has supported in the past.

> ---
>  libdtrace/dt_cg.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> index 7e47ccfc..e78491b7 100644
> --- a/libdtrace/dt_cg.c
> +++ b/libdtrace/dt_cg.c
> @@ -698,9 +698,22 @@ dt_cg_act_printf(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>  static void
>  dt_cg_act_raise(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>  {
> -	dt_cg_node(dnp->dn_args, &pcb->pcb_ir, pcb->pcb_regs);
> -	dnerror(dnp, D_UNKNOWN, "raise() is not implemented (yet)\n");
> -	/* FIXME: Needs implementation */
> +	struct bpf_insn	instr;
> +	dt_irlist_t	*dlp = &pcb->pcb_ir;
> +	dt_regset_t	*drp = pcb->pcb_regs;
> +
> +	dt_cg_node(dnp->dn_args, &pcb->pcb_ir, drp);
> +
> +	if (dt_regset_xalloc_args(drp) == -1)
> +		longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
> +	instr = BPF_MOV_REG(BPF_REG_1, dnp->dn_args->dn_reg);
> +	dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
> +	dt_regset_free(drp, dnp->dn_args->dn_reg);
> +	dt_regset_xalloc(drp, BPF_REG_0);
> +	instr = BPF_CALL_HELPER(BPF_FUNC_send_signal);
> +	dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
> +	dt_regset_free_args(drp);
> +	dt_regset_free(drp, BPF_REG_0);
>  }
>  
>  static void
> -- 
> 2.18.2
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list