xref: /netbsd-src/external/gpl3/gdb/lib/libgdb/arch/mipsel/jit-reader.h (revision 22ebeae4b2252475e0ebe332f69734639cb946ea)
116d511cfSchristos /* This file is automatically generated.  DO NOT EDIT! */
2*22ebeae4Schristos /* Generated from: NetBSD: mknative-gdb,v 1.17 2024/08/18 03:47:55 rin Exp  */
30a362b83Schristos /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
416d511cfSchristos 
516d511cfSchristos /* JIT declarations for GDB, the GNU Debugger.
616d511cfSchristos 
7*22ebeae4Schristos    Copyright (C) 2011-2024 Free Software Foundation, Inc.
816d511cfSchristos 
916d511cfSchristos    This file is part of GDB.
1016d511cfSchristos 
1116d511cfSchristos    This program is free software; you can redistribute it and/or modify
1216d511cfSchristos    it under the terms of the GNU General Public License as published by
1316d511cfSchristos    the Free Software Foundation; either version 3 of the License, or
1416d511cfSchristos    (at your option) any later version.
1516d511cfSchristos 
1616d511cfSchristos    This program is distributed in the hope that it will be useful,
1716d511cfSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1816d511cfSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1916d511cfSchristos    GNU General Public License for more details.
2016d511cfSchristos 
2116d511cfSchristos    You should have received a copy of the GNU General Public License
2216d511cfSchristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
2316d511cfSchristos 
2416d511cfSchristos #ifndef GDB_JIT_READER_H
2516d511cfSchristos #define GDB_JIT_READER_H
2616d511cfSchristos 
2716d511cfSchristos #ifdef __cplusplus
2816d511cfSchristos extern "C" {
2916d511cfSchristos #endif
3016d511cfSchristos 
3116d511cfSchristos /* Versioning information.  See gdb_reader_funcs.  */
3216d511cfSchristos 
3316d511cfSchristos #define GDB_READER_INTERFACE_VERSION 1
3416d511cfSchristos 
3516d511cfSchristos /* Readers must be released under a GPL compatible license.  To
3616d511cfSchristos    declare that the reader is indeed released under a GPL compatible
3716d511cfSchristos    license, invoke the macro GDB_DECLARE_GPL_COMPATIBLE in a source
3816d511cfSchristos    file.  */
3916d511cfSchristos 
4016d511cfSchristos #ifdef __cplusplus
4116d511cfSchristos #define GDB_DECLARE_GPL_COMPATIBLE_READER       \
4216d511cfSchristos   extern "C" {                                  \
4316d511cfSchristos   extern int plugin_is_GPL_compatible (void);   \
4416d511cfSchristos   extern int plugin_is_GPL_compatible (void)    \
4516d511cfSchristos   {                                             \
4616d511cfSchristos     return 0;                                   \
4716d511cfSchristos   }                                             \
4816d511cfSchristos   }
4916d511cfSchristos 
5016d511cfSchristos #else
5116d511cfSchristos 
5216d511cfSchristos #define GDB_DECLARE_GPL_COMPATIBLE_READER       \
5316d511cfSchristos   extern int plugin_is_GPL_compatible (void);   \
5416d511cfSchristos   extern int plugin_is_GPL_compatible (void)    \
5516d511cfSchristos   {                                             \
5616d511cfSchristos     return 0;                                   \
5716d511cfSchristos   }
5816d511cfSchristos 
5916d511cfSchristos #endif
6016d511cfSchristos 
6116d511cfSchristos /* Represents an address on the target system.  */
6216d511cfSchristos 
6316d511cfSchristos typedef unsigned long long GDB_CORE_ADDR;
6416d511cfSchristos 
6516d511cfSchristos /* Return status codes.  */
6616d511cfSchristos 
6716d511cfSchristos enum gdb_status {
6816d511cfSchristos   GDB_FAIL = 0,
6916d511cfSchristos   GDB_SUCCESS = 1
7016d511cfSchristos };
7116d511cfSchristos 
7216d511cfSchristos struct gdb_object;
7316d511cfSchristos struct gdb_symtab;
7416d511cfSchristos struct gdb_block;
7516d511cfSchristos struct gdb_symbol_callbacks;
7616d511cfSchristos 
7716d511cfSchristos /* An array of these are used to represent a map from code addresses to line
7816d511cfSchristos    numbers in the source file.  */
7916d511cfSchristos 
8016d511cfSchristos struct gdb_line_mapping
8116d511cfSchristos {
8216d511cfSchristos   int line;
8316d511cfSchristos   GDB_CORE_ADDR pc;
8416d511cfSchristos };
8516d511cfSchristos 
8616d511cfSchristos /* Create a new GDB code object.  Each code object can have one or
8716d511cfSchristos    more symbol tables, each representing a compiled source file.  */
8816d511cfSchristos 
8916d511cfSchristos typedef struct gdb_object *(gdb_object_open) (struct gdb_symbol_callbacks *cb);
9016d511cfSchristos 
9116d511cfSchristos /* The callback used to create new symbol table.  CB is the
9216d511cfSchristos    gdb_symbol_callbacks which the structure is part of.  FILE_NAME is
9316d511cfSchristos    an (optionally NULL) file name to associate with this new symbol
9416d511cfSchristos    table.
9516d511cfSchristos 
9616d511cfSchristos    Returns a new instance to gdb_symtab that can later be passed to
9716d511cfSchristos    gdb_block_new, gdb_symtab_add_line_mapping and gdb_symtab_close.  */
9816d511cfSchristos 
9916d511cfSchristos typedef struct gdb_symtab *(gdb_symtab_open) (struct gdb_symbol_callbacks *cb,
10016d511cfSchristos                                               struct gdb_object *obj,
10116d511cfSchristos                                               const char *file_name);
10216d511cfSchristos 
10316d511cfSchristos /* Creates a new block in a given symbol table.  A symbol table is a
10416d511cfSchristos    forest of blocks, each block representing an code address range and
10516d511cfSchristos    a corresponding (optionally NULL) NAME.  In case the block
10616d511cfSchristos    corresponds to a function, the NAME passed should be the name of
10716d511cfSchristos    the function.
10816d511cfSchristos 
10916d511cfSchristos    If the new block to be created is a child of (i.e. is nested in)
11016d511cfSchristos    another block, the parent block can be passed in PARENT.  SYMTAB is
11116d511cfSchristos    the symbol table the new block is to belong in.  BEGIN, END is the
11216d511cfSchristos    code address range the block corresponds to.
11316d511cfSchristos 
11416d511cfSchristos    Returns a new instance of gdb_block, which, as of now, has no use.
11516d511cfSchristos    Note that the gdb_block returned must not be freed by the
11616d511cfSchristos    caller.  */
11716d511cfSchristos 
11816d511cfSchristos typedef struct gdb_block *(gdb_block_open) (struct gdb_symbol_callbacks *cb,
11916d511cfSchristos                                             struct gdb_symtab *symtab,
12016d511cfSchristos                                             struct gdb_block *parent,
12116d511cfSchristos                                             GDB_CORE_ADDR begin,
12216d511cfSchristos                                             GDB_CORE_ADDR end,
12316d511cfSchristos                                             const char *name);
12416d511cfSchristos 
12516d511cfSchristos /* Adds a PC to line number mapping for the symbol table SYMTAB.
12616d511cfSchristos    NLINES is the number of elements in LINES, each element
12716d511cfSchristos    corresponding to one (PC, line) pair.  */
12816d511cfSchristos 
12916d511cfSchristos typedef void (gdb_symtab_add_line_mapping) (struct gdb_symbol_callbacks *cb,
13016d511cfSchristos                                             struct gdb_symtab *symtab,
13116d511cfSchristos                                             int nlines,
13216d511cfSchristos                                             struct gdb_line_mapping *lines);
13316d511cfSchristos 
13416d511cfSchristos /* Close the symtab SYMTAB.  This signals to GDB that no more blocks
13516d511cfSchristos    will be opened on this symtab.  */
13616d511cfSchristos 
13716d511cfSchristos typedef void (gdb_symtab_close) (struct gdb_symbol_callbacks *cb,
13816d511cfSchristos                                  struct gdb_symtab *symtab);
13916d511cfSchristos 
14016d511cfSchristos 
14116d511cfSchristos /* Closes the gdb_object OBJ and adds the emitted information into
14216d511cfSchristos    GDB's internal structures.  Once this is done, the debug
14316d511cfSchristos    information will be picked up and used; this will usually be the
14416d511cfSchristos    last operation in gdb_read_debug_info.  */
14516d511cfSchristos 
14616d511cfSchristos typedef void (gdb_object_close) (struct gdb_symbol_callbacks *cb,
14716d511cfSchristos                                  struct gdb_object *obj);
14816d511cfSchristos 
14916d511cfSchristos /* Reads LEN bytes from TARGET_MEM in the target's virtual address
15016d511cfSchristos    space into GDB_BUF.
15116d511cfSchristos 
15216d511cfSchristos    Returns GDB_FAIL on failure, and GDB_SUCCESS on success.  */
15316d511cfSchristos 
15416d511cfSchristos typedef enum gdb_status (gdb_target_read) (GDB_CORE_ADDR target_mem,
15516d511cfSchristos                                            void *gdb_buf, int len);
15616d511cfSchristos 
15716d511cfSchristos /* The list of callbacks that are passed to read.  These callbacks are
15816d511cfSchristos    to be used to construct the symbol table.  The functions have been
15916d511cfSchristos    described above.  */
16016d511cfSchristos 
16116d511cfSchristos struct gdb_symbol_callbacks
16216d511cfSchristos {
16316d511cfSchristos   gdb_object_open *object_open;
16416d511cfSchristos   gdb_symtab_open *symtab_open;
16516d511cfSchristos   gdb_block_open *block_open;
16616d511cfSchristos   gdb_symtab_close *symtab_close;
16716d511cfSchristos   gdb_object_close *object_close;
16816d511cfSchristos 
16916d511cfSchristos   gdb_symtab_add_line_mapping *line_mapping_add;
17016d511cfSchristos   gdb_target_read *target_read;
17116d511cfSchristos 
17216d511cfSchristos   /* For internal use by GDB.  */
17316d511cfSchristos   void *priv_data;
17416d511cfSchristos };
17516d511cfSchristos 
17616d511cfSchristos /* Forward declaration.  */
17716d511cfSchristos 
17816d511cfSchristos struct gdb_reg_value;
17916d511cfSchristos 
18016d511cfSchristos /* A function of this type is used to free a gdb_reg_value.  See the
18116d511cfSchristos    comment on `free' in struct gdb_reg_value.  */
18216d511cfSchristos 
18316d511cfSchristos typedef void (gdb_reg_value_free) (struct gdb_reg_value *);
18416d511cfSchristos 
18516d511cfSchristos /* Denotes the value of a register.  */
18616d511cfSchristos 
18716d511cfSchristos struct gdb_reg_value
18816d511cfSchristos {
18916d511cfSchristos   /* The size of the register in bytes.  The reader need not set this
19016d511cfSchristos      field.  This will be set for (defined) register values being read
19116d511cfSchristos      from GDB using reg_get.  */
19216d511cfSchristos   int size;
19316d511cfSchristos 
19416d511cfSchristos   /* Set to non-zero if the value for the register is known.  The
19516d511cfSchristos      registers for which the reader does not call reg_set are also
19616d511cfSchristos      assumed to be undefined */
19716d511cfSchristos   int defined;
19816d511cfSchristos 
19916d511cfSchristos   /* Since gdb_reg_value is a variable sized structure, it will
20016d511cfSchristos      usually be allocated on the heap.  This function is expected to
20116d511cfSchristos      contain the corresponding "free" function.
20216d511cfSchristos 
20316d511cfSchristos      When a pointer to gdb_reg_value is being sent from GDB to the
20416d511cfSchristos      reader (via gdb_unwind_reg_get), the reader is expected to call
20516d511cfSchristos      this function (with the same gdb_reg_value as argument) once it
20616d511cfSchristos      is done with the value.
20716d511cfSchristos 
20816d511cfSchristos      When the function sends the a gdb_reg_value to GDB (via
20916d511cfSchristos      gdb_unwind_reg_set), it is expected to set this field to point to
21016d511cfSchristos      an appropriate cleanup routine (or to NULL if no cleanup is
21116d511cfSchristos      required).  */
21216d511cfSchristos   gdb_reg_value_free *free;
21316d511cfSchristos 
21416d511cfSchristos   /* The value of the register.  */
21516d511cfSchristos   unsigned char value[1];
21616d511cfSchristos };
21716d511cfSchristos 
21816d511cfSchristos /* get_frame_id in gdb_reader_funcs is to return a gdb_frame_id
21916d511cfSchristos    corresponding to the current frame.  The registers corresponding to
22016d511cfSchristos    the current frame can be read using reg_get.  Calling get_frame_id
22116d511cfSchristos    on a particular frame should return the same gdb_frame_id
22216d511cfSchristos    throughout its lifetime (i.e. till before it gets unwound).  One
22316d511cfSchristos    way to do this is by having the CODE_ADDRESS point to the
22416d511cfSchristos    function's first instruction and STACK_ADDRESS point to the value
22516d511cfSchristos    of the stack pointer when entering the function.  */
22616d511cfSchristos 
22716d511cfSchristos struct gdb_frame_id
22816d511cfSchristos {
22916d511cfSchristos   GDB_CORE_ADDR code_address;
23016d511cfSchristos   GDB_CORE_ADDR stack_address;
23116d511cfSchristos };
23216d511cfSchristos 
23316d511cfSchristos /* Forward declaration.  */
23416d511cfSchristos 
23516d511cfSchristos struct gdb_unwind_callbacks;
23616d511cfSchristos 
23716d511cfSchristos /* Returns the value of a particular register in the current frame.
23816d511cfSchristos    The current frame is the frame that needs to be unwound into the
23916d511cfSchristos    outer (earlier) frame.
24016d511cfSchristos 
24116d511cfSchristos    CB is the struct gdb_unwind_callbacks * the callback belongs to.
24216d511cfSchristos    REGNUM is the DWARF register number of the register that needs to
24316d511cfSchristos    be unwound.
24416d511cfSchristos 
24516d511cfSchristos    Returns the gdb_reg_value corresponding to the register requested.
24616d511cfSchristos    In case the value of the register has been optimized away or
24716d511cfSchristos    otherwise unavailable, the defined flag in the returned
24816d511cfSchristos    gdb_reg_value will be zero.  */
24916d511cfSchristos 
25016d511cfSchristos typedef struct gdb_reg_value *(gdb_unwind_reg_get)
25116d511cfSchristos                               (struct gdb_unwind_callbacks *cb, int regnum);
25216d511cfSchristos 
25316d511cfSchristos /* Sets the previous value of a particular register.  REGNUM is the
25416d511cfSchristos    (DWARF) register number whose value is to be set.  VAL is the value
25516d511cfSchristos    the register is to be set to.
25616d511cfSchristos 
25716d511cfSchristos    VAL is *not* copied, so the memory allocated to it cannot be
25816d511cfSchristos    reused.  Once GDB no longer needs the value, it is deallocated
25916d511cfSchristos    using the FREE function (see gdb_reg_value).
26016d511cfSchristos 
26116d511cfSchristos    A register can also be "set" to an undefined value by setting the
26216d511cfSchristos    defined in VAL to zero.  */
26316d511cfSchristos 
26416d511cfSchristos typedef void (gdb_unwind_reg_set) (struct gdb_unwind_callbacks *cb, int regnum,
26516d511cfSchristos                                    struct gdb_reg_value *val);
26616d511cfSchristos 
26716d511cfSchristos /* This struct is passed to unwind in gdb_reader_funcs, and is to be
26816d511cfSchristos    used to unwind the current frame (current being the frame whose
26916d511cfSchristos    registers can be read using reg_get) into the earlier frame.  The
27016d511cfSchristos    functions have been described above.  */
27116d511cfSchristos 
27216d511cfSchristos struct gdb_unwind_callbacks
27316d511cfSchristos {
27416d511cfSchristos   gdb_unwind_reg_get *reg_get;
27516d511cfSchristos   gdb_unwind_reg_set *reg_set;
27616d511cfSchristos   gdb_target_read *target_read;
27716d511cfSchristos 
27816d511cfSchristos   /* For internal use by GDB.  */
27916d511cfSchristos   void *priv_data;
28016d511cfSchristos };
28116d511cfSchristos 
28216d511cfSchristos /* Forward declaration.  */
28316d511cfSchristos 
28416d511cfSchristos struct gdb_reader_funcs;
28516d511cfSchristos 
28616d511cfSchristos /* Parse the debug info off a block of memory, pointed to by MEMORY
28716d511cfSchristos    (already copied to GDB's address space) and MEMORY_SZ bytes long.
28816d511cfSchristos    The implementation has to use the functions in CB to actually emit
28916d511cfSchristos    the parsed data into GDB.  SELF is the same structure returned by
29016d511cfSchristos    gdb_init_reader.
29116d511cfSchristos 
29216d511cfSchristos    Return GDB_FAIL on failure and GDB_SUCCESS on success.  */
29316d511cfSchristos 
29416d511cfSchristos typedef enum gdb_status (gdb_read_debug_info) (struct gdb_reader_funcs *self,
29516d511cfSchristos                                                struct gdb_symbol_callbacks *cb,
29616d511cfSchristos                                                void *memory, long memory_sz);
29716d511cfSchristos 
29816d511cfSchristos /* Unwind the current frame, CB is the set of unwind callbacks that
29916d511cfSchristos    are to be used to do this.
30016d511cfSchristos 
30116d511cfSchristos    Return GDB_FAIL on failure and GDB_SUCCESS on success.  */
30216d511cfSchristos 
30316d511cfSchristos typedef enum gdb_status (gdb_unwind_frame) (struct gdb_reader_funcs *self,
30416d511cfSchristos                                             struct gdb_unwind_callbacks *cb);
30516d511cfSchristos 
30616d511cfSchristos /* Return the frame ID corresponding to the current frame, using C to
30716d511cfSchristos    read the current register values.  See the comment on struct
30816d511cfSchristos    gdb_frame_id.  */
30916d511cfSchristos 
31016d511cfSchristos typedef struct gdb_frame_id (gdb_get_frame_id) (struct gdb_reader_funcs *self,
31116d511cfSchristos                                                 struct gdb_unwind_callbacks *c);
31216d511cfSchristos 
31316d511cfSchristos /* Called when a reader is being unloaded.  This function should also
31416d511cfSchristos    free SELF, if required.  */
31516d511cfSchristos 
31616d511cfSchristos typedef void (gdb_destroy_reader) (struct gdb_reader_funcs *self);
31716d511cfSchristos 
31816d511cfSchristos /* Called when the reader is loaded.  Must either return a properly
31916d511cfSchristos    populated gdb_reader_funcs or NULL.  The memory allocated for the
32016d511cfSchristos    gdb_reader_funcs is to be managed by the reader itself (i.e. if it
32116d511cfSchristos    is allocated from the heap, it must also be freed in
32216d511cfSchristos    gdb_destroy_reader).  */
32316d511cfSchristos 
32416d511cfSchristos extern struct gdb_reader_funcs *gdb_init_reader (void);
32516d511cfSchristos 
32616d511cfSchristos /* Pointer to the functions which implement the reader's
32716d511cfSchristos    functionality.  The individual functions have been documented
32816d511cfSchristos    above.
32916d511cfSchristos 
33016d511cfSchristos    None of the fields are optional.  */
33116d511cfSchristos 
33216d511cfSchristos struct gdb_reader_funcs
33316d511cfSchristos {
33416d511cfSchristos   /* Must be set to GDB_READER_INTERFACE_VERSION.  */
33516d511cfSchristos   int reader_version;
33616d511cfSchristos 
33716d511cfSchristos   /* For use by the reader.  */
33816d511cfSchristos   void *priv_data;
33916d511cfSchristos 
34016d511cfSchristos   gdb_read_debug_info *read;
34116d511cfSchristos   gdb_unwind_frame *unwind;
34216d511cfSchristos   gdb_get_frame_id *get_frame_id;
34316d511cfSchristos   gdb_destroy_reader *destroy;
34416d511cfSchristos };
34516d511cfSchristos 
34616d511cfSchristos #ifdef __cplusplus
34716d511cfSchristos } /* extern "C" */
34816d511cfSchristos #endif
34916d511cfSchristos 
35016d511cfSchristos #endif
351