Home | History | Annotate | Line # | Download | only in gdb
disasm.h revision 1.9.2.1
      1      1.1  christos /* Disassemble support for GDB.
      2  1.9.2.1  perseant    Copyright (C) 2002-2023 Free Software Foundation, Inc.
      3      1.1  christos 
      4      1.1  christos    This file is part of GDB.
      5      1.1  christos 
      6      1.1  christos    This program is free software; you can redistribute it and/or modify
      7      1.1  christos    it under the terms of the GNU General Public License as published by
      8      1.1  christos    the Free Software Foundation; either version 3 of the License, or
      9      1.1  christos    (at your option) any later version.
     10      1.1  christos 
     11      1.1  christos    This program is distributed in the hope that it will be useful,
     12      1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     13      1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14      1.1  christos    GNU General Public License for more details.
     15      1.1  christos 
     16      1.1  christos    You should have received a copy of the GNU General Public License
     17      1.1  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     18      1.1  christos 
     19      1.1  christos #ifndef DISASM_H
     20      1.1  christos #define DISASM_H
     21      1.1  christos 
     22      1.3  christos #include "dis-asm.h"
     23  1.9.2.1  perseant #include "disasm-flags.h"
     24      1.1  christos 
     25      1.3  christos struct gdbarch;
     26      1.1  christos struct ui_out;
     27      1.1  christos struct ui_file;
     28      1.1  christos 
     29  1.9.2.1  perseant #if __cplusplus >= 201703L
     30  1.9.2.1  perseant #define LIBOPCODE_CALLBACK_NOEXCEPT noexcept
     31  1.9.2.1  perseant #else
     32  1.9.2.1  perseant #define LIBOPCODE_CALLBACK_NOEXCEPT
     33  1.9.2.1  perseant #endif
     34      1.9  christos 
     35  1.9.2.1  perseant /* A wrapper around a disassemble_info and a gdbarch.  This is the core
     36  1.9.2.1  perseant    set of data that all disassembler sub-classes will need.  This class
     37  1.9.2.1  perseant    doesn't actually implement the disassembling process, that is something
     38  1.9.2.1  perseant    that sub-classes will do, with each sub-class doing things slightly
     39  1.9.2.1  perseant    differently.
     40  1.9.2.1  perseant 
     41  1.9.2.1  perseant    The constructor of this class is protected, you should not create
     42  1.9.2.1  perseant    instances of this class directly, instead create an instance of an
     43  1.9.2.1  perseant    appropriate sub-class.  */
     44      1.9  christos 
     45  1.9.2.1  perseant struct gdb_disassemble_info
     46  1.9.2.1  perseant {
     47  1.9.2.1  perseant   DISABLE_COPY_AND_ASSIGN (gdb_disassemble_info);
     48      1.7  christos 
     49  1.9.2.1  perseant   /* Return the gdbarch we are disassembling for.  */
     50      1.7  christos   struct gdbarch *arch ()
     51      1.7  christos   { return m_gdbarch; }
     52      1.7  christos 
     53  1.9.2.1  perseant   /* Return a pointer to the disassemble_info, this will be needed for
     54  1.9.2.1  perseant      passing into the libopcodes disassembler.  */
     55  1.9.2.1  perseant   struct disassemble_info *disasm_info ()
     56  1.9.2.1  perseant   { return &m_di; }
     57  1.9.2.1  perseant 
     58      1.7  christos protected:
     59      1.7  christos 
     60  1.9.2.1  perseant   /* Types for the function callbacks within m_di.  The actual function
     61  1.9.2.1  perseant      signatures here are taken from include/dis-asm.h.  The noexcept macro
     62  1.9.2.1  perseant      expands to 'noexcept' for C++17 and later, otherwise, it expands to
     63  1.9.2.1  perseant      nothing.  This is because including noexcept was ignored for function
     64  1.9.2.1  perseant      types before C++17, but both GCC and Clang warn that the noexcept
     65  1.9.2.1  perseant      will become relevant when you switch to C++17, and this warning
     66  1.9.2.1  perseant      causes the build to fail.  */
     67  1.9.2.1  perseant   using read_memory_ftype
     68  1.9.2.1  perseant     = int (*) (bfd_vma, bfd_byte *, unsigned int, struct disassemble_info *)
     69  1.9.2.1  perseant 	LIBOPCODE_CALLBACK_NOEXCEPT;
     70  1.9.2.1  perseant   using memory_error_ftype
     71  1.9.2.1  perseant     = void (*) (int, bfd_vma, struct disassemble_info *)
     72  1.9.2.1  perseant 	LIBOPCODE_CALLBACK_NOEXCEPT;
     73  1.9.2.1  perseant   using print_address_ftype
     74  1.9.2.1  perseant     = void (*) (bfd_vma, struct disassemble_info *)
     75  1.9.2.1  perseant 	LIBOPCODE_CALLBACK_NOEXCEPT;
     76  1.9.2.1  perseant   using fprintf_ftype
     77  1.9.2.1  perseant     = int (*) (void *, const char *, ...)
     78  1.9.2.1  perseant 	LIBOPCODE_CALLBACK_NOEXCEPT;
     79  1.9.2.1  perseant   using fprintf_styled_ftype
     80  1.9.2.1  perseant     = int (*) (void *, enum disassembler_style, const char *, ...)
     81  1.9.2.1  perseant 	LIBOPCODE_CALLBACK_NOEXCEPT;
     82  1.9.2.1  perseant 
     83  1.9.2.1  perseant   /* Constructor, many fields in m_di are initialized from GDBARCH.  The
     84  1.9.2.1  perseant      remaining arguments are function callbacks that are written into m_di.
     85  1.9.2.1  perseant      Of these function callbacks FPRINTF_FUNC and FPRINTF_STYLED_FUNC must
     86  1.9.2.1  perseant      not be nullptr.  If READ_MEMORY_FUNC, MEMORY_ERROR_FUNC, or
     87  1.9.2.1  perseant      PRINT_ADDRESS_FUNC are nullptr, then that field within m_di is left
     88  1.9.2.1  perseant      with its default value (see the libopcodes function
     89  1.9.2.1  perseant      init_disassemble_info for the defaults).  */
     90  1.9.2.1  perseant   gdb_disassemble_info (struct gdbarch *gdbarch,
     91  1.9.2.1  perseant 			read_memory_ftype read_memory_func,
     92  1.9.2.1  perseant 			memory_error_ftype memory_error_func,
     93  1.9.2.1  perseant 			print_address_ftype print_address_func,
     94  1.9.2.1  perseant 			fprintf_ftype fprintf_func,
     95  1.9.2.1  perseant 			fprintf_styled_ftype fprintf_styled_func);
     96      1.7  christos 
     97  1.9.2.1  perseant   /* Destructor.  */
     98  1.9.2.1  perseant   virtual ~gdb_disassemble_info ();
     99      1.7  christos 
    100      1.7  christos   /* Stores data required for disassembling instructions in
    101      1.7  christos      opcodes.  */
    102      1.7  christos   struct disassemble_info m_di;
    103      1.8  christos 
    104  1.9.2.1  perseant private:
    105  1.9.2.1  perseant   /* The architecture we are disassembling for.  */
    106  1.9.2.1  perseant   struct gdbarch *m_gdbarch;
    107  1.9.2.1  perseant 
    108      1.8  christos   /* If we own the string in `m_di.disassembler_options', we do so
    109      1.8  christos      using this field.  */
    110      1.8  christos   std::string m_disassembler_options_holder;
    111  1.9.2.1  perseant };
    112  1.9.2.1  perseant 
    113  1.9.2.1  perseant /* A wrapper around gdb_disassemble_info.  This class adds default
    114  1.9.2.1  perseant    print functions that are supplied to the disassemble_info within the
    115  1.9.2.1  perseant    parent class.  These default print functions write to the stream, which
    116  1.9.2.1  perseant    is also contained in the parent class.
    117  1.9.2.1  perseant 
    118  1.9.2.1  perseant    As with the parent class, the constructor for this class is protected,
    119  1.9.2.1  perseant    you should not create instances of this class, but create an
    120  1.9.2.1  perseant    appropriate sub-class instead.  */
    121  1.9.2.1  perseant 
    122  1.9.2.1  perseant struct gdb_printing_disassembler : public gdb_disassemble_info
    123  1.9.2.1  perseant {
    124  1.9.2.1  perseant   DISABLE_COPY_AND_ASSIGN (gdb_printing_disassembler);
    125      1.8  christos 
    126  1.9.2.1  perseant protected:
    127  1.9.2.1  perseant 
    128  1.9.2.1  perseant   /* The stream that disassembler output is being written too.  */
    129  1.9.2.1  perseant   struct ui_file *stream ()
    130  1.9.2.1  perseant   { return m_stream; }
    131  1.9.2.1  perseant 
    132  1.9.2.1  perseant   /* Constructor.  All the arguments are just passed to the parent class.
    133  1.9.2.1  perseant      We also add the two print functions to the arguments passed to the
    134  1.9.2.1  perseant      parent.  See gdb_disassemble_info for a description of how the
    135  1.9.2.1  perseant      arguments are handled.  */
    136  1.9.2.1  perseant   gdb_printing_disassembler (struct gdbarch *gdbarch,
    137  1.9.2.1  perseant 			     struct ui_file *stream,
    138  1.9.2.1  perseant 			     read_memory_ftype read_memory_func,
    139  1.9.2.1  perseant 			     memory_error_ftype memory_error_func,
    140  1.9.2.1  perseant 			     print_address_ftype print_address_func)
    141  1.9.2.1  perseant     : gdb_disassemble_info (gdbarch, read_memory_func,
    142  1.9.2.1  perseant 			    memory_error_func, print_address_func,
    143  1.9.2.1  perseant 			    fprintf_func, fprintf_styled_func),
    144  1.9.2.1  perseant       m_stream (stream)
    145  1.9.2.1  perseant   {
    146  1.9.2.1  perseant     gdb_assert (stream != nullptr);
    147  1.9.2.1  perseant   }
    148  1.9.2.1  perseant 
    149  1.9.2.1  perseant   /* Callback used as the disassemble_info's fprintf_func callback.  The
    150  1.9.2.1  perseant      DIS_INFO pointer is a pointer to a gdb_printing_disassembler object.
    151  1.9.2.1  perseant      Content is written to the m_stream extracted from DIS_INFO.  */
    152  1.9.2.1  perseant   static int fprintf_func (void *dis_info, const char *format, ...) noexcept
    153  1.9.2.1  perseant     ATTRIBUTE_PRINTF(2,3);
    154  1.9.2.1  perseant 
    155  1.9.2.1  perseant   /* Callback used as the disassemble_info's fprintf_styled_func callback.
    156  1.9.2.1  perseant      The DIS_INFO pointer is a pointer to a gdb_printing_disassembler
    157  1.9.2.1  perseant      object.  Content is written to the m_stream extracted from DIS_INFO.  */
    158  1.9.2.1  perseant   static int fprintf_styled_func (void *dis_info,
    159  1.9.2.1  perseant 				  enum disassembler_style style,
    160  1.9.2.1  perseant 				  const char *format, ...) noexcept
    161  1.9.2.1  perseant     ATTRIBUTE_PRINTF(3,4);
    162  1.9.2.1  perseant 
    163  1.9.2.1  perseant   /* Return true if the disassembler is considered inside a comment, false
    164  1.9.2.1  perseant      otherwise.  */
    165  1.9.2.1  perseant   bool in_comment_p () const
    166  1.9.2.1  perseant   { return m_in_comment; }
    167  1.9.2.1  perseant 
    168  1.9.2.1  perseant   /* Set whether the disassembler should be considered as within comment
    169  1.9.2.1  perseant      text or not.  */
    170  1.9.2.1  perseant   void set_in_comment (bool c)
    171  1.9.2.1  perseant   { m_in_comment = c; }
    172  1.9.2.1  perseant 
    173  1.9.2.1  perseant private:
    174      1.7  christos 
    175  1.9.2.1  perseant   /* When libopcodes calls the fprintf_func and fprintf_styled_func
    176  1.9.2.1  perseant      callbacks, a 'void *' argument is passed.  We arrange, through our
    177  1.9.2.1  perseant      call to init_disassemble_info that this argument will be a pointer to
    178  1.9.2.1  perseant      a gdb_disassemble_info sub-class, specifically, a
    179  1.9.2.1  perseant      gdb_printing_disassembler pointer.  This helper function casts
    180  1.9.2.1  perseant      DIS_INFO to the correct type (with some asserts), and then returns the
    181  1.9.2.1  perseant      m_stream member variable.  */
    182  1.9.2.1  perseant   static ui_file *stream_from_gdb_disassemble_info (void *dis_info);
    183  1.9.2.1  perseant 
    184  1.9.2.1  perseant   /* The stream to which output should be sent.  */
    185  1.9.2.1  perseant   struct ui_file *m_stream;
    186  1.9.2.1  perseant 
    187  1.9.2.1  perseant   /* Are we inside a comment?  This will be set true if the disassembler
    188  1.9.2.1  perseant      uses styled output and emits a start of comment character.  It is up
    189  1.9.2.1  perseant      to the code that uses this disassembler class to reset this flag back
    190  1.9.2.1  perseant      to false at a suitable time (e.g. at the end of every line).  */
    191  1.9.2.1  perseant   bool m_in_comment = false;
    192  1.9.2.1  perseant };
    193  1.9.2.1  perseant 
    194  1.9.2.1  perseant /* A basic disassembler that doesn't actually print anything.  */
    195  1.9.2.1  perseant 
    196  1.9.2.1  perseant struct gdb_non_printing_disassembler : public gdb_disassemble_info
    197  1.9.2.1  perseant {
    198  1.9.2.1  perseant   gdb_non_printing_disassembler (struct gdbarch *gdbarch,
    199  1.9.2.1  perseant 				 read_memory_ftype read_memory_func)
    200  1.9.2.1  perseant     : gdb_disassemble_info (gdbarch,
    201  1.9.2.1  perseant 			    read_memory_func,
    202  1.9.2.1  perseant 			    nullptr /* memory_error_func */,
    203  1.9.2.1  perseant 			    nullptr /* print_address_func */,
    204  1.9.2.1  perseant 			    null_fprintf_func,
    205  1.9.2.1  perseant 			    null_fprintf_styled_func)
    206  1.9.2.1  perseant   { /* Nothing.  */ }
    207  1.9.2.1  perseant 
    208  1.9.2.1  perseant private:
    209  1.9.2.1  perseant 
    210  1.9.2.1  perseant   /* Callback used as the disassemble_info's fprintf_func callback, this
    211  1.9.2.1  perseant      doesn't write anything to STREAM, but just returns 0.  */
    212  1.9.2.1  perseant   static int null_fprintf_func (void *stream, const char *format, ...) noexcept
    213  1.9.2.1  perseant     ATTRIBUTE_PRINTF(2,3);
    214  1.9.2.1  perseant 
    215  1.9.2.1  perseant   /* Callback used as the disassemble_info's fprintf_styled_func callback,
    216  1.9.2.1  perseant      , this doesn't write anything to STREAM, but just returns 0.  */
    217  1.9.2.1  perseant   static int null_fprintf_styled_func (void *stream,
    218  1.9.2.1  perseant 				       enum disassembler_style style,
    219  1.9.2.1  perseant 				       const char *format, ...) noexcept
    220  1.9.2.1  perseant     ATTRIBUTE_PRINTF(3,4);
    221  1.9.2.1  perseant };
    222  1.9.2.1  perseant 
    223  1.9.2.1  perseant /* This is a helper class, for use as an additional base-class, by some of
    224  1.9.2.1  perseant    the disassembler classes below.  This class just defines a static method
    225  1.9.2.1  perseant    for reading from target memory, which can then be used by the various
    226  1.9.2.1  perseant    disassembler sub-classes.  */
    227  1.9.2.1  perseant 
    228  1.9.2.1  perseant struct gdb_disassembler_memory_reader
    229  1.9.2.1  perseant {
    230  1.9.2.1  perseant   /* Implements the read_memory_func disassemble_info callback.  */
    231      1.7  christos   static int dis_asm_read_memory (bfd_vma memaddr, gdb_byte *myaddr,
    232      1.7  christos 				  unsigned int len,
    233  1.9.2.1  perseant 				  struct disassemble_info *info) noexcept;
    234  1.9.2.1  perseant };
    235  1.9.2.1  perseant 
    236  1.9.2.1  perseant /* A non-printing disassemble_info management class.  The disassemble_info
    237  1.9.2.1  perseant    setup by this class will not print anything to the output stream (there
    238  1.9.2.1  perseant    is no output stream), and the instruction to be disassembled will be
    239  1.9.2.1  perseant    read from target memory.  */
    240  1.9.2.1  perseant 
    241  1.9.2.1  perseant struct gdb_non_printing_memory_disassembler
    242  1.9.2.1  perseant   : public gdb_non_printing_disassembler,
    243  1.9.2.1  perseant     private gdb_disassembler_memory_reader
    244  1.9.2.1  perseant {
    245  1.9.2.1  perseant   /* Constructor.  GDBARCH is the architecture to disassemble for.  */
    246  1.9.2.1  perseant   gdb_non_printing_memory_disassembler (struct gdbarch *gdbarch)
    247  1.9.2.1  perseant     :gdb_non_printing_disassembler (gdbarch, dis_asm_read_memory)
    248  1.9.2.1  perseant   { /* Nothing.  */ }
    249  1.9.2.1  perseant };
    250  1.9.2.1  perseant 
    251  1.9.2.1  perseant /* A dissassembler class that provides 'print_insn', a method for
    252  1.9.2.1  perseant    disassembling a single instruction to the output stream.  */
    253  1.9.2.1  perseant 
    254  1.9.2.1  perseant struct gdb_disassembler : public gdb_printing_disassembler,
    255  1.9.2.1  perseant 			  private gdb_disassembler_memory_reader
    256  1.9.2.1  perseant {
    257  1.9.2.1  perseant   gdb_disassembler (struct gdbarch *gdbarch, struct ui_file *file)
    258  1.9.2.1  perseant     : gdb_disassembler (gdbarch, file, dis_asm_read_memory)
    259  1.9.2.1  perseant   { /* Nothing.  */ }
    260  1.9.2.1  perseant 
    261  1.9.2.1  perseant   DISABLE_COPY_AND_ASSIGN (gdb_disassembler);
    262  1.9.2.1  perseant 
    263  1.9.2.1  perseant   /* Disassemble a single instruction at MEMADDR to the ui_file* that was
    264  1.9.2.1  perseant      passed to the constructor.  If a memory error occurs while
    265  1.9.2.1  perseant      disassembling this instruction then an error will be thrown.  */
    266  1.9.2.1  perseant   int print_insn (CORE_ADDR memaddr, int *branch_delay_insns = NULL);
    267  1.9.2.1  perseant 
    268  1.9.2.1  perseant protected:
    269  1.9.2.1  perseant   gdb_disassembler (struct gdbarch *gdbarch, struct ui_file *file,
    270  1.9.2.1  perseant 		    read_memory_ftype func);
    271  1.9.2.1  perseant 
    272  1.9.2.1  perseant private:
    273  1.9.2.1  perseant   /* This member variable is given a value by calling dis_asm_memory_error.
    274  1.9.2.1  perseant      If after calling into the libopcodes disassembler we get back a
    275  1.9.2.1  perseant      negative value (which indicates an error), then, if this variable has
    276  1.9.2.1  perseant      a value, we report a memory error to the user, otherwise, we report a
    277  1.9.2.1  perseant      non-memory error.  */
    278  1.9.2.1  perseant   gdb::optional<CORE_ADDR> m_err_memaddr;
    279  1.9.2.1  perseant 
    280  1.9.2.1  perseant   /* The stream to which disassembler output will be written.  */
    281  1.9.2.1  perseant   ui_file *m_dest;
    282  1.9.2.1  perseant 
    283  1.9.2.1  perseant   /* Disassembler output is built up into this buffer.  Whether this
    284  1.9.2.1  perseant      string_file is created with styling support or not depends on the
    285  1.9.2.1  perseant      value of use_ext_lang_colorization_p, as well as whether disassembler
    286  1.9.2.1  perseant      styling in general is turned on, and also, whether *m_dest supports
    287  1.9.2.1  perseant      styling or not.  */
    288  1.9.2.1  perseant   string_file m_buffer;
    289  1.9.2.1  perseant 
    290  1.9.2.1  perseant   /* When true, m_buffer will be created without styling support,
    291  1.9.2.1  perseant      otherwise, m_buffer will be created with styling support.
    292  1.9.2.1  perseant 
    293  1.9.2.1  perseant      This field will initially be true, but will be set to false if
    294  1.9.2.1  perseant      ext_lang_colorize_disasm fails to add styling at any time.
    295  1.9.2.1  perseant 
    296  1.9.2.1  perseant      If the extension language is going to add the styling then m_buffer
    297  1.9.2.1  perseant      should be created without styling support, the extension language will
    298  1.9.2.1  perseant      then add styling at the end of the disassembly process.
    299  1.9.2.1  perseant 
    300  1.9.2.1  perseant      If the extension language is not going to add the styling, then we
    301  1.9.2.1  perseant      create m_buffer with styling support, and GDB will add minimal styling
    302  1.9.2.1  perseant      (currently just to addresses and symbols) as it goes.  */
    303  1.9.2.1  perseant   static bool use_ext_lang_colorization_p;
    304  1.9.2.1  perseant 
    305      1.7  christos   static void dis_asm_memory_error (int err, bfd_vma memaddr,
    306  1.9.2.1  perseant 				    struct disassemble_info *info) noexcept;
    307      1.7  christos   static void dis_asm_print_address (bfd_vma addr,
    308  1.9.2.1  perseant 				     struct disassemble_info *info) noexcept;
    309  1.9.2.1  perseant 
    310  1.9.2.1  perseant   /* Return true if we should use the extension language to apply
    311  1.9.2.1  perseant      disassembler styling.  This requires disassembler styling to be on
    312  1.9.2.1  perseant      (i.e. 'set style disassembler enabled on'), the output stream needs to
    313  1.9.2.1  perseant      support styling, and libopcode styling needs to be either off, or not
    314  1.9.2.1  perseant      supported for the current architecture (libopcodes is used in
    315  1.9.2.1  perseant      preference to the extension language method).  */
    316  1.9.2.1  perseant   bool use_ext_lang_for_styling () const;
    317  1.9.2.1  perseant 
    318  1.9.2.1  perseant   /* Return true if we should use libopcodes to apply disassembler styling.
    319  1.9.2.1  perseant      This requires disassembler styling to be on (i.e. 'set style
    320  1.9.2.1  perseant      disassembler enabled on'), the output stream needs to support styling,
    321  1.9.2.1  perseant      and libopcodes styling needs to be supported for the current
    322  1.9.2.1  perseant      architecture, and not disabled by the user.  */
    323  1.9.2.1  perseant   bool use_libopcodes_for_styling () const;
    324      1.7  christos };
    325      1.7  christos 
    326      1.6  christos /* An instruction to be disassembled.  */
    327      1.6  christos 
    328      1.6  christos struct disasm_insn
    329      1.6  christos {
    330      1.6  christos   /* The address of the memory containing the instruction.  */
    331      1.6  christos   CORE_ADDR addr;
    332      1.6  christos 
    333      1.6  christos   /* An optional instruction number.  If non-zero, it is printed first.  */
    334      1.6  christos   unsigned int number;
    335      1.6  christos 
    336      1.6  christos   /* True if the instruction was executed speculatively.  */
    337      1.6  christos   unsigned int is_speculative:1;
    338      1.6  christos };
    339      1.6  christos 
    340      1.1  christos extern void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
    341      1.8  christos 			     gdb_disassembly_flags flags, int how_many,
    342      1.1  christos 			     CORE_ADDR low, CORE_ADDR high);
    343      1.1  christos 
    344      1.1  christos /* Print the instruction at address MEMADDR in debugged memory,
    345      1.1  christos    on STREAM.  Returns the length of the instruction, in bytes,
    346      1.1  christos    and, if requested, the number of branch delay slot instructions.  */
    347      1.1  christos 
    348      1.1  christos extern int gdb_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
    349      1.1  christos 			   struct ui_file *stream, int *branch_delay_insns);
    350      1.1  christos 
    351      1.7  christos /* Class used to pretty-print instructions.  */
    352      1.7  christos 
    353      1.7  christos class gdb_pretty_print_disassembler
    354      1.7  christos {
    355      1.7  christos public:
    356      1.9  christos   explicit gdb_pretty_print_disassembler (struct gdbarch *gdbarch,
    357      1.9  christos 					  struct ui_out *uiout)
    358      1.9  christos     : m_uiout (uiout),
    359      1.9  christos       m_insn_stb (uiout->can_emit_style_escape ()),
    360      1.9  christos       m_di (gdbarch, &m_insn_stb)
    361      1.7  christos   {}
    362      1.7  christos 
    363      1.9  christos   /* Prints the instruction INSN into the saved ui_out and returns the
    364      1.9  christos      length of the printed instruction in bytes.  */
    365      1.9  christos   int pretty_print_insn (const struct disasm_insn *insn,
    366      1.8  christos 			 gdb_disassembly_flags flags);
    367      1.7  christos 
    368      1.7  christos private:
    369      1.7  christos   /* Returns the architecture used for disassembling.  */
    370      1.7  christos   struct gdbarch *arch () { return m_di.arch (); }
    371      1.7  christos 
    372      1.9  christos   /* The ui_out that is used by pretty_print_insn.  */
    373      1.9  christos   struct ui_out *m_uiout;
    374      1.7  christos 
    375      1.7  christos   /* The buffer used to build the instruction string.  The
    376      1.7  christos      disassembler is initialized with this stream.  */
    377      1.7  christos   string_file m_insn_stb;
    378      1.7  christos 
    379      1.9  christos   /* The disassembler used for instruction printing.  */
    380      1.9  christos   gdb_disassembler m_di;
    381      1.9  christos 
    382      1.7  christos   /* The buffer used to build the raw opcodes string.  */
    383      1.7  christos   string_file m_opcode_stb;
    384  1.9.2.1  perseant 
    385  1.9.2.1  perseant   /* The buffer used to hold the opcode bytes (if required).  */
    386  1.9.2.1  perseant   gdb::byte_vector m_opcode_data;
    387      1.7  christos };
    388      1.7  christos 
    389      1.1  christos /* Return the length in bytes of the instruction at address MEMADDR in
    390      1.1  christos    debugged memory.  */
    391      1.1  christos 
    392      1.1  christos extern int gdb_insn_length (struct gdbarch *gdbarch, CORE_ADDR memaddr);
    393      1.1  christos 
    394      1.1  christos /* Return the length in bytes of INSN, originally at MEMADDR.  MAX_LEN
    395      1.1  christos    is the size of the buffer containing INSN.  */
    396      1.1  christos 
    397      1.1  christos extern int gdb_buffered_insn_length (struct gdbarch *gdbarch,
    398      1.1  christos 				     const gdb_byte *insn, int max_len,
    399      1.1  christos 				     CORE_ADDR memaddr);
    400      1.1  christos 
    401      1.7  christos /* Returns GDBARCH's disassembler options.  */
    402      1.7  christos 
    403      1.7  christos extern char *get_disassembler_options (struct gdbarch *gdbarch);
    404      1.7  christos 
    405      1.7  christos /* Sets the active gdbarch's disassembler options to OPTIONS.  */
    406      1.7  christos 
    407  1.9.2.1  perseant extern void set_disassembler_options (const char *options);
    408      1.7  christos 
    409      1.1  christos #endif
    410