Print this page
libdtrace: attempt to resolve FORWARD types to concrete types


  24  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  25  * Use is subject to license terms.
  26  */
  27 
  28 /*
  29  * Copyright (c) 2012 by Delphix. All rights reserved.
  30  */
  31 
  32 #include <sys/types.h>
  33 #include <sys/sysmacros.h>
  34 #include <sys/isa_defs.h>
  35 
  36 #include <strings.h>
  37 #include <stdlib.h>
  38 #include <setjmp.h>
  39 #include <assert.h>
  40 #include <errno.h>
  41 
  42 #include <dt_impl.h>
  43 #include <dt_grammar.h>

  44 #include <dt_parser.h>
  45 #include <dt_provider.h>
  46 
  47 static void dt_cg_node(dt_node_t *, dt_irlist_t *, dt_regset_t *);
  48 
  49 static dt_irnode_t *
  50 dt_cg_node_alloc(uint_t label, dif_instr_t instr)
  51 {
  52         dt_irnode_t *dip = malloc(sizeof (dt_irnode_t));
  53 
  54         if (dip == NULL)
  55                 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
  56 
  57         dip->di_label = label;
  58         dip->di_instr = instr;
  59         dip->di_extern = NULL;
  60         dip->di_next = NULL;
  61 
  62         return (dip);
  63 }
  64 
  65 /*
  66  * Code generator wrapper function for ctf_member_info.  If we are given a
  67  * reference to a forward declaration tag, search the entire type space for
  68  * the actual definition and then call ctf_member_info on the result.
  69  */
  70 static ctf_file_t *
  71 dt_cg_membinfo(ctf_file_t *fp, ctf_id_t type, const char *s, ctf_membinfo_t *mp)
  72 {
  73         while (ctf_type_kind(fp, type) == CTF_K_FORWARD) {
  74                 char n[DT_TYPE_NAMELEN];
  75                 dtrace_typeinfo_t dtt;
  76 
  77                 if (ctf_type_name(fp, type, n, sizeof (n)) == NULL ||
  78                     dt_type_lookup(n, &dtt) == -1 || (
  79                     dtt.dtt_ctfp == fp && dtt.dtt_type == type))
  80                         break; /* unable to improve our position */
  81 
  82                 fp = dtt.dtt_ctfp;
  83                 type = ctf_type_resolve(fp, dtt.dtt_type);
  84         }
  85 
  86         if (ctf_member_info(fp, type, s, mp) == CTF_ERR)
  87                 return (NULL); /* ctf_errno is set for us */
  88 
  89         return (fp);
  90 }
  91 
  92 static void
  93 dt_cg_xsetx(dt_irlist_t *dlp, dt_ident_t *idp, uint_t lbl, int reg, uint64_t x)
  94 {
  95         int flag = idp != NULL ? DT_INT_PRIVATE : DT_INT_SHARED;
  96         int intoff = dt_inttab_insert(yypcb->pcb_inttab, x, flag);
  97         dif_instr_t instr = DIF_INSTR_SETX((uint_t)intoff, reg);
  98 
  99         if (intoff == -1)
 100                 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
 101 
 102         if (intoff > DIF_INTOFF_MAX)
 103                 longjmp(yypcb->pcb_jmpbuf, EDT_INT2BIG);
 104 




  24  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  25  * Use is subject to license terms.
  26  */
  27 
  28 /*
  29  * Copyright (c) 2012 by Delphix. All rights reserved.
  30  */
  31 
  32 #include <sys/types.h>
  33 #include <sys/sysmacros.h>
  34 #include <sys/isa_defs.h>
  35 
  36 #include <strings.h>
  37 #include <stdlib.h>
  38 #include <setjmp.h>
  39 #include <assert.h>
  40 #include <errno.h>
  41 
  42 #include <dt_impl.h>
  43 #include <dt_grammar.h>
  44 #include <dt_module.h>
  45 #include <dt_parser.h>
  46 #include <dt_provider.h>
  47 
  48 static void dt_cg_node(dt_node_t *, dt_irlist_t *, dt_regset_t *);
  49 
  50 static dt_irnode_t *
  51 dt_cg_node_alloc(uint_t label, dif_instr_t instr)
  52 {
  53         dt_irnode_t *dip = malloc(sizeof (dt_irnode_t));
  54 
  55         if (dip == NULL)
  56                 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
  57 
  58         dip->di_label = label;
  59         dip->di_instr = instr;
  60         dip->di_extern = NULL;
  61         dip->di_next = NULL;
  62 
  63         return (dip);
  64 }
  65 
  66 /*
  67  * Code generator wrapper function for ctf_member_info.  If we are given a
  68  * reference to a forward declaration tag, search the entire type space for
  69  * the actual definition and then call ctf_member_info on the result.
  70  */
  71 static ctf_file_t *
  72 dt_cg_membinfo(ctf_file_t *fp, ctf_id_t type, const char *s, ctf_membinfo_t *mp)
  73 {
  74         dt_resolve_forward_decl(&fp, &type);











  75 
  76         if (ctf_member_info(fp, type, s, mp) == CTF_ERR)
  77                 return (NULL); /* ctf_errno is set for us */
  78 
  79         return (fp);
  80 }
  81 
  82 static void
  83 dt_cg_xsetx(dt_irlist_t *dlp, dt_ident_t *idp, uint_t lbl, int reg, uint64_t x)
  84 {
  85         int flag = idp != NULL ? DT_INT_PRIVATE : DT_INT_SHARED;
  86         int intoff = dt_inttab_insert(yypcb->pcb_inttab, x, flag);
  87         dif_instr_t instr = DIF_INSTR_SETX((uint_t)intoff, reg);
  88 
  89         if (intoff == -1)
  90                 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
  91 
  92         if (intoff > DIF_INTOFF_MAX)
  93                 longjmp(yypcb->pcb_jmpbuf, EDT_INT2BIG);
  94