Print this page
4474 DTrace Userland CTF Support
4475 DTrace userland Keyword
4476 DTrace tests should be better citizens
4479 pid provider types
4480 dof emulation missing checks
Reviewed by: Bryan Cantrill <bryan@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdtrace/common/dt_print.c
          +++ new/usr/src/lib/libdtrace/common/dt_print.c
↓ open down ↓ 641 lines elided ↑ open up ↑
 642  642   */
 643  643  int
 644  644  dtrace_print(dtrace_hdl_t *dtp, FILE *fp, const char *typename,
 645  645      caddr_t addr, size_t len)
 646  646  {
 647  647          const char *s;
 648  648          char *object;
 649  649          dt_printarg_t pa;
 650  650          ctf_id_t id;
 651  651          dt_module_t *dmp;
      652 +        ctf_file_t *ctfp;
      653 +        int libid;
 652  654  
 653  655          /*
 654  656           * Split the fully-qualified type ID (module`id).  This should
 655  657           * always be the format, but if for some reason we don't find the
 656  658           * expected value, return 0 to fall back to the generic trace()
 657      -         * behavior.
      659 +         * behavior. In the case of userland CTF modules this will actually be
      660 +         * of the format (module`lib`id). This is due to the fact that those
      661 +         * modules have multiple CTF containers which `lib` identifies.
 658  662           */
 659  663          for (s = typename; *s != '\0' && *s != '`'; s++)
 660  664                  ;
 661  665  
 662  666          if (*s != '`')
 663  667                  return (0);
 664  668  
 665  669          object = alloca(s - typename + 1);
 666  670          bcopy(typename, object, s - typename);
 667  671          object[s - typename] = '\0';
      672 +        dmp = dt_module_lookup_by_name(dtp, object);
      673 +        if (dmp == NULL)
      674 +                return (0);
      675 +
      676 +        if (dmp->dm_pid != 0) {
      677 +                libid = atoi(s + 1);
      678 +                s = strchr(s + 1, '`');
      679 +                if (s == NULL || libid > dmp->dm_nctflibs)
      680 +                        return (0);
      681 +                ctfp = dmp->dm_libctfp[libid];
      682 +        } else {
      683 +                ctfp = dt_module_getctf(dtp, dmp);
      684 +        }
      685 +
 668  686          id = atoi(s + 1);
 669  687  
 670  688          /*
 671  689           * Try to get the CTF kind for this id.  If something has gone horribly
 672  690           * wrong and we can't resolve the ID, bail out and let trace() do the
 673  691           * work.
 674  692           */
 675      -        dmp = dt_module_lookup_by_name(dtp, object);
 676      -        if (dmp == NULL || ctf_type_kind(dt_module_getctf(dtp, dmp),
 677      -            id) == CTF_ERR) {
      693 +        if (ctfp == NULL || ctf_type_kind(ctfp, id) == CTF_ERR)
 678  694                  return (0);
 679      -        }
 680  695  
 681  696          /* setup the print structure and kick off the main print routine */
 682  697          pa.pa_dtp = dtp;
 683  698          pa.pa_addr = addr;
 684      -        pa.pa_ctfp = dt_module_getctf(dtp, dmp);
      699 +        pa.pa_ctfp = ctfp;
 685  700          pa.pa_nest = 0;
 686  701          pa.pa_depth = 0;
 687  702          pa.pa_file = fp;
 688  703          (void) ctf_type_visit(pa.pa_ctfp, id, dt_print_member, &pa);
 689  704  
 690  705          dt_print_trailing_braces(&pa, 0);
 691  706  
 692  707          return (len);
 693  708  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX