Home | History | Annotate | Line # | Download | only in riscv64
jit-reader.h revision 1.1.1.1
      1      1.1     skrll /* This file is automatically generated.  DO NOT EDIT! */
      2  1.1.1.1  christos /* Generated from: NetBSD: mknative-gdb,v 1.16 2023/07/31 17:09:59 christos Exp  */
      3      1.1     skrll /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
      4      1.1     skrll 
      5      1.1     skrll /* JIT declarations for GDB, the GNU Debugger.
      6      1.1     skrll 
      7  1.1.1.1  christos    Copyright (C) 2011-2023 Free Software Foundation, Inc.
      8      1.1     skrll 
      9      1.1     skrll    This file is part of GDB.
     10      1.1     skrll 
     11      1.1     skrll    This program is free software; you can redistribute it and/or modify
     12      1.1     skrll    it under the terms of the GNU General Public License as published by
     13      1.1     skrll    the Free Software Foundation; either version 3 of the License, or
     14      1.1     skrll    (at your option) any later version.
     15      1.1     skrll 
     16      1.1     skrll    This program is distributed in the hope that it will be useful,
     17      1.1     skrll    but WITHOUT ANY WARRANTY; without even the implied warranty of
     18      1.1     skrll    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19      1.1     skrll    GNU General Public License for more details.
     20      1.1     skrll 
     21      1.1     skrll    You should have received a copy of the GNU General Public License
     22      1.1     skrll    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     23      1.1     skrll 
     24      1.1     skrll #ifndef GDB_JIT_READER_H
     25      1.1     skrll #define GDB_JIT_READER_H
     26      1.1     skrll 
     27      1.1     skrll #ifdef __cplusplus
     28      1.1     skrll extern "C" {
     29      1.1     skrll #endif
     30      1.1     skrll 
     31      1.1     skrll /* Versioning information.  See gdb_reader_funcs.  */
     32      1.1     skrll 
     33      1.1     skrll #define GDB_READER_INTERFACE_VERSION 1
     34      1.1     skrll 
     35      1.1     skrll /* Readers must be released under a GPL compatible license.  To
     36      1.1     skrll    declare that the reader is indeed released under a GPL compatible
     37      1.1     skrll    license, invoke the macro GDB_DECLARE_GPL_COMPATIBLE in a source
     38      1.1     skrll    file.  */
     39      1.1     skrll 
     40      1.1     skrll #ifdef __cplusplus
     41      1.1     skrll #define GDB_DECLARE_GPL_COMPATIBLE_READER       \
     42      1.1     skrll   extern "C" {                                  \
     43      1.1     skrll   extern int plugin_is_GPL_compatible (void);   \
     44      1.1     skrll   extern int plugin_is_GPL_compatible (void)    \
     45      1.1     skrll   {                                             \
     46      1.1     skrll     return 0;                                   \
     47      1.1     skrll   }                                             \
     48      1.1     skrll   }
     49      1.1     skrll 
     50      1.1     skrll #else
     51      1.1     skrll 
     52      1.1     skrll #define GDB_DECLARE_GPL_COMPATIBLE_READER       \
     53      1.1     skrll   extern int plugin_is_GPL_compatible (void);   \
     54      1.1     skrll   extern int plugin_is_GPL_compatible (void)    \
     55      1.1     skrll   {                                             \
     56      1.1     skrll     return 0;                                   \
     57      1.1     skrll   }
     58      1.1     skrll 
     59      1.1     skrll #endif
     60      1.1     skrll 
     61      1.1     skrll /* Represents an address on the target system.  */
     62      1.1     skrll 
     63      1.1     skrll typedef unsigned long GDB_CORE_ADDR;
     64      1.1     skrll 
     65      1.1     skrll /* Return status codes.  */
     66      1.1     skrll 
     67      1.1     skrll enum gdb_status {
     68      1.1     skrll   GDB_FAIL = 0,
     69      1.1     skrll   GDB_SUCCESS = 1
     70      1.1     skrll };
     71      1.1     skrll 
     72      1.1     skrll struct gdb_object;
     73      1.1     skrll struct gdb_symtab;
     74      1.1     skrll struct gdb_block;
     75      1.1     skrll struct gdb_symbol_callbacks;
     76      1.1     skrll 
     77      1.1     skrll /* An array of these are used to represent a map from code addresses to line
     78      1.1     skrll    numbers in the source file.  */
     79      1.1     skrll 
     80      1.1     skrll struct gdb_line_mapping
     81      1.1     skrll {
     82      1.1     skrll   int line;
     83      1.1     skrll   GDB_CORE_ADDR pc;
     84      1.1     skrll };
     85      1.1     skrll 
     86      1.1     skrll /* Create a new GDB code object.  Each code object can have one or
     87      1.1     skrll    more symbol tables, each representing a compiled source file.  */
     88      1.1     skrll 
     89      1.1     skrll typedef struct gdb_object *(gdb_object_open) (struct gdb_symbol_callbacks *cb);
     90      1.1     skrll 
     91      1.1     skrll /* The callback used to create new symbol table.  CB is the
     92      1.1     skrll    gdb_symbol_callbacks which the structure is part of.  FILE_NAME is
     93      1.1     skrll    an (optionally NULL) file name to associate with this new symbol
     94      1.1     skrll    table.
     95      1.1     skrll 
     96      1.1     skrll    Returns a new instance to gdb_symtab that can later be passed to
     97      1.1     skrll    gdb_block_new, gdb_symtab_add_line_mapping and gdb_symtab_close.  */
     98      1.1     skrll 
     99      1.1     skrll typedef struct gdb_symtab *(gdb_symtab_open) (struct gdb_symbol_callbacks *cb,
    100      1.1     skrll                                               struct gdb_object *obj,
    101      1.1     skrll                                               const char *file_name);
    102      1.1     skrll 
    103      1.1     skrll /* Creates a new block in a given symbol table.  A symbol table is a
    104      1.1     skrll    forest of blocks, each block representing an code address range and
    105      1.1     skrll    a corresponding (optionally NULL) NAME.  In case the block
    106      1.1     skrll    corresponds to a function, the NAME passed should be the name of
    107      1.1     skrll    the function.
    108      1.1     skrll 
    109      1.1     skrll    If the new block to be created is a child of (i.e. is nested in)
    110      1.1     skrll    another block, the parent block can be passed in PARENT.  SYMTAB is
    111      1.1     skrll    the symbol table the new block is to belong in.  BEGIN, END is the
    112      1.1     skrll    code address range the block corresponds to.
    113      1.1     skrll 
    114      1.1     skrll    Returns a new instance of gdb_block, which, as of now, has no use.
    115      1.1     skrll    Note that the gdb_block returned must not be freed by the
    116      1.1     skrll    caller.  */
    117      1.1     skrll 
    118      1.1     skrll typedef struct gdb_block *(gdb_block_open) (struct gdb_symbol_callbacks *cb,
    119      1.1     skrll                                             struct gdb_symtab *symtab,
    120      1.1     skrll                                             struct gdb_block *parent,
    121      1.1     skrll                                             GDB_CORE_ADDR begin,
    122      1.1     skrll                                             GDB_CORE_ADDR end,
    123      1.1     skrll                                             const char *name);
    124      1.1     skrll 
    125      1.1     skrll /* Adds a PC to line number mapping for the symbol table SYMTAB.
    126      1.1     skrll    NLINES is the number of elements in LINES, each element
    127      1.1     skrll    corresponding to one (PC, line) pair.  */
    128      1.1     skrll 
    129      1.1     skrll typedef void (gdb_symtab_add_line_mapping) (struct gdb_symbol_callbacks *cb,
    130      1.1     skrll                                             struct gdb_symtab *symtab,
    131      1.1     skrll                                             int nlines,
    132      1.1     skrll                                             struct gdb_line_mapping *lines);
    133      1.1     skrll 
    134      1.1     skrll /* Close the symtab SYMTAB.  This signals to GDB that no more blocks
    135      1.1     skrll    will be opened on this symtab.  */
    136      1.1     skrll 
    137      1.1     skrll typedef void (gdb_symtab_close) (struct gdb_symbol_callbacks *cb,
    138      1.1     skrll                                  struct gdb_symtab *symtab);
    139      1.1     skrll 
    140      1.1     skrll 
    141      1.1     skrll /* Closes the gdb_object OBJ and adds the emitted information into
    142      1.1     skrll    GDB's internal structures.  Once this is done, the debug
    143      1.1     skrll    information will be picked up and used; this will usually be the
    144      1.1     skrll    last operation in gdb_read_debug_info.  */
    145      1.1     skrll 
    146      1.1     skrll typedef void (gdb_object_close) (struct gdb_symbol_callbacks *cb,
    147      1.1     skrll                                  struct gdb_object *obj);
    148      1.1     skrll 
    149      1.1     skrll /* Reads LEN bytes from TARGET_MEM in the target's virtual address
    150      1.1     skrll    space into GDB_BUF.
    151      1.1     skrll 
    152      1.1     skrll    Returns GDB_FAIL on failure, and GDB_SUCCESS on success.  */
    153      1.1     skrll 
    154      1.1     skrll typedef enum gdb_status (gdb_target_read) (GDB_CORE_ADDR target_mem,
    155      1.1     skrll                                            void *gdb_buf, int len);
    156      1.1     skrll 
    157      1.1     skrll /* The list of callbacks that are passed to read.  These callbacks are
    158      1.1     skrll    to be used to construct the symbol table.  The functions have been
    159      1.1     skrll    described above.  */
    160      1.1     skrll 
    161      1.1     skrll struct gdb_symbol_callbacks
    162      1.1     skrll {
    163      1.1     skrll   gdb_object_open *object_open;
    164      1.1     skrll   gdb_symtab_open *symtab_open;
    165      1.1     skrll   gdb_block_open *block_open;
    166      1.1     skrll   gdb_symtab_close *symtab_close;
    167      1.1     skrll   gdb_object_close *object_close;
    168      1.1     skrll 
    169      1.1     skrll   gdb_symtab_add_line_mapping *line_mapping_add;
    170      1.1     skrll   gdb_target_read *target_read;
    171      1.1     skrll 
    172      1.1     skrll   /* For internal use by GDB.  */
    173      1.1     skrll   void *priv_data;
    174      1.1     skrll };
    175      1.1     skrll 
    176      1.1     skrll /* Forward declaration.  */
    177      1.1     skrll 
    178      1.1     skrll struct gdb_reg_value;
    179      1.1     skrll 
    180      1.1     skrll /* A function of this type is used to free a gdb_reg_value.  See the
    181      1.1     skrll    comment on `free' in struct gdb_reg_value.  */
    182      1.1     skrll 
    183      1.1     skrll typedef void (gdb_reg_value_free) (struct gdb_reg_value *);
    184      1.1     skrll 
    185      1.1     skrll /* Denotes the value of a register.  */
    186      1.1     skrll 
    187      1.1     skrll struct gdb_reg_value
    188      1.1     skrll {
    189      1.1     skrll   /* The size of the register in bytes.  The reader need not set this
    190      1.1     skrll      field.  This will be set for (defined) register values being read
    191      1.1     skrll      from GDB using reg_get.  */
    192      1.1     skrll   int size;
    193      1.1     skrll 
    194      1.1     skrll   /* Set to non-zero if the value for the register is known.  The
    195      1.1     skrll      registers for which the reader does not call reg_set are also
    196      1.1     skrll      assumed to be undefined */
    197      1.1     skrll   int defined;
    198      1.1     skrll 
    199      1.1     skrll   /* Since gdb_reg_value is a variable sized structure, it will
    200      1.1     skrll      usually be allocated on the heap.  This function is expected to
    201      1.1     skrll      contain the corresponding "free" function.
    202      1.1     skrll 
    203      1.1     skrll      When a pointer to gdb_reg_value is being sent from GDB to the
    204      1.1     skrll      reader (via gdb_unwind_reg_get), the reader is expected to call
    205      1.1     skrll      this function (with the same gdb_reg_value as argument) once it
    206      1.1     skrll      is done with the value.
    207      1.1     skrll 
    208      1.1     skrll      When the function sends the a gdb_reg_value to GDB (via
    209      1.1     skrll      gdb_unwind_reg_set), it is expected to set this field to point to
    210      1.1     skrll      an appropriate cleanup routine (or to NULL if no cleanup is
    211      1.1     skrll      required).  */
    212      1.1     skrll   gdb_reg_value_free *free;
    213      1.1     skrll 
    214      1.1     skrll   /* The value of the register.  */
    215      1.1     skrll   unsigned char value[1];
    216      1.1     skrll };
    217      1.1     skrll 
    218      1.1     skrll /* get_frame_id in gdb_reader_funcs is to return a gdb_frame_id
    219      1.1     skrll    corresponding to the current frame.  The registers corresponding to
    220      1.1     skrll    the current frame can be read using reg_get.  Calling get_frame_id
    221      1.1     skrll    on a particular frame should return the same gdb_frame_id
    222      1.1     skrll    throughout its lifetime (i.e. till before it gets unwound).  One
    223      1.1     skrll    way to do this is by having the CODE_ADDRESS point to the
    224      1.1     skrll    function's first instruction and STACK_ADDRESS point to the value
    225      1.1     skrll    of the stack pointer when entering the function.  */
    226      1.1     skrll 
    227      1.1     skrll struct gdb_frame_id
    228      1.1     skrll {
    229      1.1     skrll   GDB_CORE_ADDR code_address;
    230      1.1     skrll   GDB_CORE_ADDR stack_address;
    231      1.1     skrll };
    232      1.1     skrll 
    233      1.1     skrll /* Forward declaration.  */
    234      1.1     skrll 
    235      1.1     skrll struct gdb_unwind_callbacks;
    236      1.1     skrll 
    237      1.1     skrll /* Returns the value of a particular register in the current frame.
    238      1.1     skrll    The current frame is the frame that needs to be unwound into the
    239      1.1     skrll    outer (earlier) frame.
    240      1.1     skrll 
    241      1.1     skrll    CB is the struct gdb_unwind_callbacks * the callback belongs to.
    242      1.1     skrll    REGNUM is the DWARF register number of the register that needs to
    243      1.1     skrll    be unwound.
    244      1.1     skrll 
    245      1.1     skrll    Returns the gdb_reg_value corresponding to the register requested.
    246      1.1     skrll    In case the value of the register has been optimized away or
    247      1.1     skrll    otherwise unavailable, the defined flag in the returned
    248      1.1     skrll    gdb_reg_value will be zero.  */
    249      1.1     skrll 
    250      1.1     skrll typedef struct gdb_reg_value *(gdb_unwind_reg_get)
    251      1.1     skrll                               (struct gdb_unwind_callbacks *cb, int regnum);
    252      1.1     skrll 
    253      1.1     skrll /* Sets the previous value of a particular register.  REGNUM is the
    254      1.1     skrll    (DWARF) register number whose value is to be set.  VAL is the value
    255      1.1     skrll    the register is to be set to.
    256      1.1     skrll 
    257      1.1     skrll    VAL is *not* copied, so the memory allocated to it cannot be
    258      1.1     skrll    reused.  Once GDB no longer needs the value, it is deallocated
    259      1.1     skrll    using the FREE function (see gdb_reg_value).
    260      1.1     skrll 
    261      1.1     skrll    A register can also be "set" to an undefined value by setting the
    262      1.1     skrll    defined in VAL to zero.  */
    263      1.1     skrll 
    264      1.1     skrll typedef void (gdb_unwind_reg_set) (struct gdb_unwind_callbacks *cb, int regnum,
    265      1.1     skrll                                    struct gdb_reg_value *val);
    266      1.1     skrll 
    267      1.1     skrll /* This struct is passed to unwind in gdb_reader_funcs, and is to be
    268      1.1     skrll    used to unwind the current frame (current being the frame whose
    269      1.1     skrll    registers can be read using reg_get) into the earlier frame.  The
    270      1.1     skrll    functions have been described above.  */
    271      1.1     skrll 
    272      1.1     skrll struct gdb_unwind_callbacks
    273      1.1     skrll {
    274      1.1     skrll   gdb_unwind_reg_get *reg_get;
    275      1.1     skrll   gdb_unwind_reg_set *reg_set;
    276      1.1     skrll   gdb_target_read *target_read;
    277      1.1     skrll 
    278      1.1     skrll   /* For internal use by GDB.  */
    279      1.1     skrll   void *priv_data;
    280      1.1     skrll };
    281      1.1     skrll 
    282      1.1     skrll /* Forward declaration.  */
    283      1.1     skrll 
    284      1.1     skrll struct gdb_reader_funcs;
    285      1.1     skrll 
    286      1.1     skrll /* Parse the debug info off a block of memory, pointed to by MEMORY
    287      1.1     skrll    (already copied to GDB's address space) and MEMORY_SZ bytes long.
    288      1.1     skrll    The implementation has to use the functions in CB to actually emit
    289      1.1     skrll    the parsed data into GDB.  SELF is the same structure returned by
    290      1.1     skrll    gdb_init_reader.
    291      1.1     skrll 
    292      1.1     skrll    Return GDB_FAIL on failure and GDB_SUCCESS on success.  */
    293      1.1     skrll 
    294      1.1     skrll typedef enum gdb_status (gdb_read_debug_info) (struct gdb_reader_funcs *self,
    295      1.1     skrll                                                struct gdb_symbol_callbacks *cb,
    296      1.1     skrll                                                void *memory, long memory_sz);
    297      1.1     skrll 
    298      1.1     skrll /* Unwind the current frame, CB is the set of unwind callbacks that
    299      1.1     skrll    are to be used to do this.
    300      1.1     skrll 
    301      1.1     skrll    Return GDB_FAIL on failure and GDB_SUCCESS on success.  */
    302      1.1     skrll 
    303      1.1     skrll typedef enum gdb_status (gdb_unwind_frame) (struct gdb_reader_funcs *self,
    304      1.1     skrll                                             struct gdb_unwind_callbacks *cb);
    305      1.1     skrll 
    306      1.1     skrll /* Return the frame ID corresponding to the current frame, using C to
    307      1.1     skrll    read the current register values.  See the comment on struct
    308      1.1     skrll    gdb_frame_id.  */
    309      1.1     skrll 
    310      1.1     skrll typedef struct gdb_frame_id (gdb_get_frame_id) (struct gdb_reader_funcs *self,
    311      1.1     skrll                                                 struct gdb_unwind_callbacks *c);
    312      1.1     skrll 
    313      1.1     skrll /* Called when a reader is being unloaded.  This function should also
    314      1.1     skrll    free SELF, if required.  */
    315      1.1     skrll 
    316      1.1     skrll typedef void (gdb_destroy_reader) (struct gdb_reader_funcs *self);
    317      1.1     skrll 
    318      1.1     skrll /* Called when the reader is loaded.  Must either return a properly
    319      1.1     skrll    populated gdb_reader_funcs or NULL.  The memory allocated for the
    320      1.1     skrll    gdb_reader_funcs is to be managed by the reader itself (i.e. if it
    321      1.1     skrll    is allocated from the heap, it must also be freed in
    322      1.1     skrll    gdb_destroy_reader).  */
    323      1.1     skrll 
    324      1.1     skrll extern struct gdb_reader_funcs *gdb_init_reader (void);
    325      1.1     skrll 
    326      1.1     skrll /* Pointer to the functions which implement the reader's
    327      1.1     skrll    functionality.  The individual functions have been documented
    328      1.1     skrll    above.
    329      1.1     skrll 
    330      1.1     skrll    None of the fields are optional.  */
    331      1.1     skrll 
    332      1.1     skrll struct gdb_reader_funcs
    333      1.1     skrll {
    334      1.1     skrll   /* Must be set to GDB_READER_INTERFACE_VERSION.  */
    335      1.1     skrll   int reader_version;
    336      1.1     skrll 
    337      1.1     skrll   /* For use by the reader.  */
    338      1.1     skrll   void *priv_data;
    339      1.1     skrll 
    340      1.1     skrll   gdb_read_debug_info *read;
    341      1.1     skrll   gdb_unwind_frame *unwind;
    342      1.1     skrll   gdb_get_frame_id *get_frame_id;
    343      1.1     skrll   gdb_destroy_reader *destroy;
    344      1.1     skrll };
    345      1.1     skrll 
    346      1.1     skrll #ifdef __cplusplus
    347      1.1     skrll } /* extern "C" */
    348      1.1     skrll #endif
    349      1.1     skrll 
    350      1.1     skrll #endif
    351