Print this page
6068 libdisasm: previnstr arch op should have a sane default
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>
6067 libdisasm: use C99 designated initializers for arch ops
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdisasm/common/dis_sparc.c
          +++ new/usr/src/lib/libdisasm/common/dis_sparc.c
↓ open down ↓ 189 lines elided ↑ open up ↑
 190  190          return (4);
 191  191  }
 192  192  
 193  193  /* ARGSUSED */
 194  194  static int
 195  195  dis_sparc_min_instrlen(dis_handle_t *dhp)
 196  196  {
 197  197          return (4);
 198  198  }
 199  199  
 200      -/*
 201      - * The dis_i386.c comment for this says it returns the previous instruction,
 202      - * however, I'm fairly sure it's actually returning the _address_ of the
 203      - * nth previous instruction.
 204      - */
 205  200  /* ARGSUSED */
 206  201  static uint64_t
 207  202  dis_sparc_previnstr(dis_handle_t *dhp, uint64_t pc, int n)
 208  203  {
 209  204          if (n <= 0)
 210  205                  return (pc);
 211  206  
 212  207          if (pc < n)
 213  208                  return (pc);
 214  209  
↓ open down ↓ 126 lines elided ↑ open up ↑
 341  336          int archflags = flags & DIS_ARCH_MASK;
 342  337  
 343  338          if (archflags == DIS_SPARC_V8 ||
 344  339              (archflags & (DIS_SPARC_V9 | DIS_SPARC_V8)) == DIS_SPARC_V9)
 345  340                  return (1);
 346  341  
 347  342          return (0);
 348  343  }
 349  344  
 350  345  const dis_arch_t dis_arch_sparc = {
 351      -        dis_sparc_supports_flags,
 352      -        dis_sparc_handle_attach,
 353      -        dis_sparc_handle_detach,
 354      -        dis_sparc_disassemble,
 355      -        dis_sparc_previnstr,
 356      -        dis_sparc_min_instrlen,
 357      -        dis_sparc_max_instrlen,
 358      -        dis_sparc_instrlen
      346 +        .da_supports_flags      = dis_sparc_supports_flags,
      347 +        .da_handle_attach       = dis_sparc_handle_attach,
      348 +        .da_handle_detach       = dis_sparc_handle_detach,
      349 +        .da_disassemble         = dis_sparc_disassemble,
      350 +        .da_previnstr           = dis_sparc_previnstr,
      351 +        .da_min_instrlen        = dis_sparc_min_instrlen,
      352 +        .da_max_instrlen        = dis_sparc_max_instrlen,
      353 +        .da_instrlen            = dis_sparc_instrlen
 359  354  };
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX