[DTrace-devel] [PATCH 3/7] Add disassembler support for dynamic type vars

Eugene Loh eugene.loh at oracle.com
Fri May 27 02:24:50 UTC 2022


I do not really understand this code but what the heck:
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>

I assume this had no counterpart in DTv1?

Also, a test would be good.  Presumably a test would not yet work in 
this patch, but it could be added to patch 5.

Also, never mind my own preferences on this subject, but the indentation 
for the continuation line in dt_parser.c looks different from what I 
think you normally try to do.  Maybe it's a copy-and-paste from above, 
but you intended to indent more due to the "else"?  (Or possibly I'm 
totally misreading the indentation due to mailer whackiness.)

On 5/26/22 11:24, Kris Van Hees via DTrace-devel wrote:
> The args[] built-in variable is a special array where each element has
> its own datatype.  The overall datatype is considered the 'dynamic type'
> which is expressed as 'any'.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
>   include/dtrace/dif_defines.h | 3 ++-
>   libdtrace/dt_dis.c           | 3 +++
>   libdtrace/dt_parser.c        | 4 ++++
>   3 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/include/dtrace/dif_defines.h b/include/dtrace/dif_defines.h
> index 9f30e649..43824646 100644
> --- a/include/dtrace/dif_defines.h
> +++ b/include/dtrace/dif_defines.h
> @@ -2,7 +2,7 @@
>    * Licensed under the Universal Permissive License v 1.0 as shown at
>    * http://oss.oracle.com/licenses/upl.
>    *
> - * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
>    */
>   
>   /*
> @@ -263,6 +263,7 @@ typedef uint32_t	dif_instr_t;
>   
>   #define DIF_TYPE_CTF		0
>   #define DIF_TYPE_STRING		1
> +#define DIF_TYPE_ANY		2
>   
>   #define DIF_TF_BYREF		0x1
>   
> diff --git a/libdtrace/dt_dis.c b/libdtrace/dt_dis.c
> index 58c02fd5..9a365a6b 100644
> --- a/libdtrace/dt_dis.c
> +++ b/libdtrace/dt_dis.c
> @@ -471,6 +471,9 @@ dt_dis_typestr(const dtrace_diftype_t *t, char *buf, size_t len)
>   	case DIF_TYPE_STRING:
>   		strcpy(kind, "string");
>   		break;
> +	case DIF_TYPE_ANY:
> +		strcpy(kind, "any");
> +		break;
>   	default:
>   		snprintf(kind, sizeof(kind), "0x%x", t->dtdt_kind);
>   	}
> diff --git a/libdtrace/dt_parser.c b/libdtrace/dt_parser.c
> index 7c5c30c9..e410f993 100644
> --- a/libdtrace/dt_parser.c
> +++ b/libdtrace/dt_parser.c
> @@ -4810,6 +4810,10 @@ dt_node_diftype(dtrace_hdl_t *dtp, const dt_node_t *dnp, dtrace_diftype_t *tp)
>   	    dnp->dn_type == DT_STR_TYPE(dtp)) {
>   		tp->dtdt_kind = DIF_TYPE_STRING;
>   		tp->dtdt_ckind = CTF_K_UNKNOWN;
> +	} else if (dnp->dn_ctfp == DT_DYN_CTFP(dtp) &&
> +	    dnp->dn_type == DT_DYN_TYPE(dtp)) {
> +		tp->dtdt_kind = DIF_TYPE_ANY;
> +		tp->dtdt_ckind = CTF_K_UNKNOWN;
>   	} else {
>   		tp->dtdt_kind = DIF_TYPE_CTF;
>   		tp->dtdt_ckind = ctf_type_kind(dnp->dn_ctfp,



More information about the DTrace-devel mailing list