Print this page
saveargs: let disasm do the lifting

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdisasm/i386/dis_i386.c
          +++ new/usr/src/lib/libdisasm/i386/dis_i386.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   27  #include <libdisasm.h>
  30   28  #include <stdlib.h>
  31   29  #include <stdio.h>
  32   30  
  33   31  #include "dis_tables.h"
  34   32  #include "libdisasm_impl.h"
  35   33  
  36   34  struct dis_handle {
  37   35          void            *dh_data;
  38   36          int             dh_flags;
↓ open down ↓ 199 lines elided ↑ open up ↑
 238  236                   */
 239  237                  goto done;
 240  238          }
 241  239  
 242  240          res = hist[(cur + n - MIN(n, nseen)) % n];
 243  241  
 244  242  done:
 245  243          dis_free(hist, sizeof (uint64_t) * n);
 246  244          return (res);
 247  245  }
      246 +
      247 +int
      248 +dis_instrlen(dis_handle_t *dhp, uint64_t pc)
      249 +{
      250 +        if (dis_disassemble(dhp, pc, NULL, 0) != 0)
      251 +                return (-1);
      252 +
      253 +        return (dhp->dh_addr - pc);
      254 +}
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX