Skip to content

Commit

Permalink
Restore error message
Browse files Browse the repository at this point in the history
An error message was "#if 0"ed out during development,
producing behavior like this:
    # dtrace -n 'BEGIN {avg(1); exit(0)}'
    dt_cg_node() - FUNC aggregating function avg()
    dtrace: description 'BEGIN ' matched 1 probe
    BPF: call to invalid destination
    BPF: verification time 14 usec
    BPF: stack depth 0+0
    BPF: processed 0 insns (limit 1000000) max_states_per_insn 0 ...
    dtrace: could not enable tracing: BPF program load for 'dtrac...

Restore the message.  Add a test.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Dec 10, 2020
1 parent 5b459d0 commit c7f41f0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 0 additions & 4 deletions libdtrace/dt_cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2938,16 +2938,12 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)

switch (dnp->dn_kind) {
case DT_NODE_FUNC:
if ((idp = dnp->dn_ident)->di_kind != DT_IDENT_FUNC)
fprintf(stderr, "%s() - FUNC %s %s()\n", __func__, dt_idkind_name(idp->di_kind), idp->di_name);
#if 0
if ((idp = dnp->dn_ident)->di_kind != DT_IDENT_FUNC) {
dnerror(dnp, D_CG_EXPR, "%s %s( ) may not be "
"called from a D expression (D program "
"context required)\n",
dt_idkind_name(idp->di_kind), idp->di_name);
}
#endif

dt_cg_arglist(dnp->dn_ident, dnp->dn_args, dlp, drp);

Expand Down
21 changes: 21 additions & 0 deletions test/unittest/aggs/err.D_CG_EXPR.from_expr.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/

/*
* ASSERTION:
* Aggregations cannot be called from D expressions.
*
* SECTION: Aggregations/Clearing aggregations
*
*
*/

BEGIN
{
avg(1);
exit(0);
}

0 comments on commit c7f41f0

Please sign in to comment.