github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/include/jit/jit-debugger.h (about)

     1  /*
     2   * jit-debugger.h - Helper routines for single-step debugging of programs.
     3   *
     4   * Copyright (C) 2004  Southern Storm Software, Pty Ltd.
     5   *
     6   * The libjit library is free software: you can redistribute it and/or
     7   * modify it under the terms of the GNU Lesser General Public License
     8   * as published by the Free Software Foundation, either version 2.1 of
     9   * the License, or (at your option) any later version.
    10   *
    11   * The libjit library is distributed in the hope that it will be useful,
    12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    14   * Lesser General Public License for more details.
    15   *
    16   * You should have received a copy of the GNU Lesser General Public
    17   * License along with the libjit library.  If not, see
    18   * <http://www.gnu.org/licenses/>.
    19   */
    20  
    21  #ifndef	_JIT_DEBUGGER_H
    22  #define	_JIT_DEBUGGER_H
    23  
    24  #include <jit/jit-common.h>
    25  
    26  #ifdef	__cplusplus
    27  extern	"C" {
    28  #endif
    29  
    30  typedef struct jit_debugger *jit_debugger_t;
    31  typedef jit_nint jit_debugger_thread_id_t;
    32  typedef jit_nint jit_debugger_breakpoint_id_t;
    33  
    34  typedef struct jit_debugger_event
    35  {
    36  	int								type;
    37  	jit_debugger_thread_id_t		thread;
    38  	jit_function_t					function;
    39  	jit_nint						data1;
    40  	jit_nint						data2;
    41  	jit_debugger_breakpoint_id_t	id;
    42  	jit_stack_trace_t				trace;
    43  
    44  } jit_debugger_event_t;
    45  
    46  #define	JIT_DEBUGGER_TYPE_QUIT				0
    47  #define	JIT_DEBUGGER_TYPE_HARD_BREAKPOINT	1
    48  #define	JIT_DEBUGGER_TYPE_SOFT_BREAKPOINT	2
    49  #define	JIT_DEBUGGER_TYPE_USER_BREAKPOINT	3
    50  #define	JIT_DEBUGGER_TYPE_ATTACH_THREAD		4
    51  #define	JIT_DEBUGGER_TYPE_DETACH_THREAD		5
    52  
    53  typedef struct jit_debugger_breakpoint_info
    54  {
    55  	int								flags;
    56  	jit_debugger_thread_id_t		thread;
    57  	jit_function_t					function;
    58  	jit_nint						data1;
    59  	jit_nint						data2;
    60  
    61  } *jit_debugger_breakpoint_info_t;
    62  
    63  #define	JIT_DEBUGGER_FLAG_THREAD		(1 << 0)
    64  #define	JIT_DEBUGGER_FLAG_FUNCTION		(1 << 1)
    65  #define	JIT_DEBUGGER_FLAG_DATA1			(1 << 2)
    66  #define	JIT_DEBUGGER_FLAG_DATA2			(1 << 3)
    67  
    68  #define	JIT_DEBUGGER_DATA1_FIRST		10000
    69  #define	JIT_DEBUGGER_DATA1_LINE			10000
    70  #define	JIT_DEBUGGER_DATA1_ENTER		10001
    71  #define	JIT_DEBUGGER_DATA1_LEAVE		10002
    72  #define	JIT_DEBUGGER_DATA1_THROW		10003
    73  
    74  typedef void (*jit_debugger_hook_func)
    75  	(jit_function_t func, jit_nint data1, jit_nint data2);
    76  
    77  int jit_debugging_possible(void) JIT_NOTHROW;
    78  
    79  jit_debugger_t jit_debugger_create(jit_context_t context) JIT_NOTHROW;
    80  void jit_debugger_destroy(jit_debugger_t dbg) JIT_NOTHROW;
    81  
    82  jit_context_t jit_debugger_get_context(jit_debugger_t dbg) JIT_NOTHROW;
    83  jit_debugger_t jit_debugger_from_context(jit_context_t context) JIT_NOTHROW;
    84  
    85  jit_debugger_thread_id_t jit_debugger_get_self(jit_debugger_t dbg) JIT_NOTHROW;
    86  jit_debugger_thread_id_t jit_debugger_get_thread
    87  		(jit_debugger_t dbg, const void *native_thread) JIT_NOTHROW;
    88  int jit_debugger_get_native_thread
    89  		(jit_debugger_t dbg, jit_debugger_thread_id_t thread,
    90  		 void *native_thread) JIT_NOTHROW;
    91  void jit_debugger_set_breakable
    92  		(jit_debugger_t dbg, const void *native_thread, int flag) JIT_NOTHROW;
    93  
    94  void jit_debugger_attach_self
    95  		(jit_debugger_t dbg, int stop_immediately) JIT_NOTHROW;
    96  void jit_debugger_detach_self(jit_debugger_t dbg) JIT_NOTHROW;
    97  
    98  int jit_debugger_wait_event
    99  		(jit_debugger_t dbg, jit_debugger_event_t *event,
   100  		 jit_int timeout) JIT_NOTHROW;
   101  
   102  jit_debugger_breakpoint_id_t jit_debugger_add_breakpoint
   103  		(jit_debugger_t dbg, jit_debugger_breakpoint_info_t info) JIT_NOTHROW;
   104  void jit_debugger_remove_breakpoint
   105  		(jit_debugger_t dbg, jit_debugger_breakpoint_id_t id) JIT_NOTHROW;
   106  void jit_debugger_remove_all_breakpoints(jit_debugger_t dbg) JIT_NOTHROW;
   107  
   108  int jit_debugger_is_alive
   109  		(jit_debugger_t dbg, jit_debugger_thread_id_t thread) JIT_NOTHROW;
   110  int jit_debugger_is_running
   111  		(jit_debugger_t dbg, jit_debugger_thread_id_t thread) JIT_NOTHROW;
   112  void jit_debugger_run
   113  		(jit_debugger_t dbg, jit_debugger_thread_id_t thread) JIT_NOTHROW;
   114  void jit_debugger_step
   115  		(jit_debugger_t dbg, jit_debugger_thread_id_t thread) JIT_NOTHROW;
   116  void jit_debugger_next
   117  		(jit_debugger_t dbg, jit_debugger_thread_id_t thread) JIT_NOTHROW;
   118  void jit_debugger_finish
   119  		(jit_debugger_t dbg, jit_debugger_thread_id_t thread) JIT_NOTHROW;
   120  
   121  void jit_debugger_break(jit_debugger_t dbg) JIT_NOTHROW;
   122  
   123  void jit_debugger_quit(jit_debugger_t dbg) JIT_NOTHROW;
   124  
   125  jit_debugger_hook_func jit_debugger_set_hook
   126  		(jit_context_t context, jit_debugger_hook_func hook);
   127  
   128  #ifdef	__cplusplus
   129  };
   130  #endif
   131  
   132  #endif	/* _JIT_DEBUGGER_H */