I just have nowhere near enough CTF knowledge to even try to comment.

but if it makes cpu_t print, I'm all for it.  Style-wise, it doesn't look 
ugly at all to me.

John Levon wrote:
> On Sat, Nov 04, 2006 at 06:38:26PM +0000, John Levon wrote:
> 
>> In theory it's not hard to fix, I believe we'd have to make
>> mdb_ctf_type_resolve() iterate through all the ctf's for each module.
> 
> Looking a little harder, that won't do. The main problem is that ::print uses
> ctf_type_visit(); since this can't know about our other CTF containers, it
> won't be able to visit the cpu_m node usefully.
> 
> It won't win me any awards for style, but the patch below at least allows
> ::print cpu_t cpu_m to work. An alternative would be to re-implement
> ctf_type_visit() in MDB, unless someone else has a good suggestion...
> 
> regards
> john
> 
> 
> ------- usr/src/cmd/mdb/common/mdb/mdb_print.c -------
> 
> Index: usr/src/cmd/mdb/common/mdb/mdb_print.c
> --- /ws/onnv-clone/usr/src/cmd/mdb/common/mdb/mdb_print.c     Thu Aug 24 
> 23:02:24 2006
> +++ /builds/johnlev/onnv-johnlev/usr/src/cmd/mdb/common/mdb/mdb_print.c       
> Mon Nov  6 12:51:58 2006
> @@ -1754,6 +1754,26 @@
>  }
>  
>  /*
> + * If we only resolved as far as a forward declaration, try to look it up in
> + * the other target objects, so ::print cpu_t cpu_m does something useful.
> + */ 
> +static void
> +resolve_forward(mdb_ctf_id_t *idp, int *kindp)
> +{
> +     char buf[MDB_SYM_NAMLEN];
> +     mdb_ctf_id_t fwd;
> +
> +     if (mdb_ctf_type_name(*idp, buf, MDB_SYM_NAMLEN) == NULL)
> +             return;
> +
> +     if (mdb_ctf_lookup_by_name(buf, &fwd) != 0)
> +             return;
> +
> +     *idp = fwd;
> +     *kindp = mdb_ctf_type_kind(fwd);
> +}
> +
> +/*
>   * Recursively descend a print a given data structure.  We create a struct of
>   * the relevant print arguments and then call mdb_ctf_type_visit() to do the
>   * traversal, using elt_print() as the callback for each element.
> @@ -1909,6 +1929,12 @@
>                                       goto out;
>                               }
>  
> +                             (void) mdb_ctf_type_resolve(mid, &rid);
> +                             kind = mdb_ctf_type_kind(rid);
> +
> +                             if (kind == CTF_K_FORWARD)
> +                                     resolve_forward(&mid, &kind);
> +
>                               /*
>                                * If the member string ends with a "[0]"
>                                * (last_deref * is true) and the type is a
> @@ -1915,8 +1941,6 @@
>                                * structure or union, * print "->" rather
>                                * than "[0]." in elt_print.
>                                */
> -                             (void) mdb_ctf_type_resolve(mid, &rid);
> -                             kind = mdb_ctf_type_kind(rid);
>                               if (last_deref && IS_SOU(kind)) {
>                                       char *end;
>                                       (void) mdb_snprintf(buf, sizeof (buf),


Reply via email to