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>


 632 
 633         /* direct simple array members are not separated by newlines */
 634         if (!brief)
 635                 (void) fprintf(fp, "\n");
 636 
 637         return (0);
 638 }
 639 
 640 /*
 641  * Main print function invoked by dt_consume_cpu().
 642  */
 643 int
 644 dtrace_print(dtrace_hdl_t *dtp, FILE *fp, const char *typename,
 645     caddr_t addr, size_t len)
 646 {
 647         const char *s;
 648         char *object;
 649         dt_printarg_t pa;
 650         ctf_id_t id;
 651         dt_module_t *dmp;


 652 
 653         /*
 654          * Split the fully-qualified type ID (module`id).  This should
 655          * always be the format, but if for some reason we don't find the
 656          * expected value, return 0 to fall back to the generic trace()
 657          * behavior.


 658          */
 659         for (s = typename; *s != '\0' && *s != '`'; s++)
 660                 ;
 661 
 662         if (*s != '`')
 663                 return (0);
 664 
 665         object = alloca(s - typename + 1);
 666         bcopy(typename, object, s - typename);
 667         object[s - typename] = '\0';














 668         id = atoi(s + 1);
 669 
 670         /*
 671          * Try to get the CTF kind for this id.  If something has gone horribly
 672          * wrong and we can't resolve the ID, bail out and let trace() do the
 673          * work.
 674          */
 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) {
 678                 return (0);
 679         }
 680 
 681         /* setup the print structure and kick off the main print routine */
 682         pa.pa_dtp = dtp;
 683         pa.pa_addr = addr;
 684         pa.pa_ctfp = dt_module_getctf(dtp, dmp);
 685         pa.pa_nest = 0;
 686         pa.pa_depth = 0;
 687         pa.pa_file = fp;
 688         (void) ctf_type_visit(pa.pa_ctfp, id, dt_print_member, &pa);
 689 
 690         dt_print_trailing_braces(&pa, 0);
 691 
 692         return (len);
 693 }


 632 
 633         /* direct simple array members are not separated by newlines */
 634         if (!brief)
 635                 (void) fprintf(fp, "\n");
 636 
 637         return (0);
 638 }
 639 
 640 /*
 641  * Main print function invoked by dt_consume_cpu().
 642  */
 643 int
 644 dtrace_print(dtrace_hdl_t *dtp, FILE *fp, const char *typename,
 645     caddr_t addr, size_t len)
 646 {
 647         const char *s;
 648         char *object;
 649         dt_printarg_t pa;
 650         ctf_id_t id;
 651         dt_module_t *dmp;
 652         ctf_file_t *ctfp;
 653         int libid;
 654 
 655         /*
 656          * Split the fully-qualified type ID (module`id).  This should
 657          * always be the format, but if for some reason we don't find the
 658          * expected value, return 0 to fall back to the generic trace()
 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.
 662          */
 663         for (s = typename; *s != '\0' && *s != '`'; s++)
 664                 ;
 665 
 666         if (*s != '`')
 667                 return (0);
 668 
 669         object = alloca(s - typename + 1);
 670         bcopy(typename, object, s - typename);
 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 
 686         id = atoi(s + 1);
 687 
 688         /*
 689          * Try to get the CTF kind for this id.  If something has gone horribly
 690          * wrong and we can't resolve the ID, bail out and let trace() do the
 691          * work.
 692          */
 693         if (ctfp == NULL || ctf_type_kind(ctfp, id) == CTF_ERR)


 694                 return (0);

 695 
 696         /* setup the print structure and kick off the main print routine */
 697         pa.pa_dtp = dtp;
 698         pa.pa_addr = addr;
 699         pa.pa_ctfp = ctfp;
 700         pa.pa_nest = 0;
 701         pa.pa_depth = 0;
 702         pa.pa_file = fp;
 703         (void) ctf_type_visit(pa.pa_ctfp, id, dt_print_member, &pa);
 704 
 705         dt_print_trailing_braces(&pa, 0);
 706 
 707         return (len);
 708 }