[270] | 1 | /*
|
---|
| 2 | ** mruby/debug.h - mruby debug info
|
---|
| 3 | **
|
---|
| 4 | ** See Copyright Notice in mruby.h
|
---|
| 5 | */
|
---|
| 6 |
|
---|
| 7 | #ifndef MRUBY_DEBUG_H
|
---|
| 8 | #define MRUBY_DEBUG_H
|
---|
| 9 |
|
---|
| 10 | #include "mruby/common.h"
|
---|
| 11 |
|
---|
| 12 | /**
|
---|
| 13 | * MRuby Debugging.
|
---|
| 14 | */
|
---|
| 15 | MRB_BEGIN_DECL
|
---|
| 16 |
|
---|
| 17 | typedef enum mrb_debug_line_type {
|
---|
| 18 | mrb_debug_line_ary = 0,
|
---|
| 19 | mrb_debug_line_flat_map = 1
|
---|
| 20 | } mrb_debug_line_type;
|
---|
| 21 |
|
---|
| 22 | typedef struct mrb_irep_debug_info_line {
|
---|
| 23 | uint32_t start_pos;
|
---|
| 24 | uint16_t line;
|
---|
| 25 | } mrb_irep_debug_info_line;
|
---|
| 26 |
|
---|
| 27 | typedef struct mrb_irep_debug_info_file {
|
---|
| 28 | uint32_t start_pos;
|
---|
| 29 | const char *filename;
|
---|
| 30 | mrb_sym filename_sym;
|
---|
| 31 | uint32_t line_entry_count;
|
---|
| 32 | mrb_debug_line_type line_type;
|
---|
| 33 | union {
|
---|
| 34 | void *ptr;
|
---|
| 35 | mrb_irep_debug_info_line *flat_map;
|
---|
| 36 | uint16_t *ary;
|
---|
| 37 | } lines;
|
---|
| 38 | } mrb_irep_debug_info_file;
|
---|
| 39 |
|
---|
| 40 | typedef struct mrb_irep_debug_info {
|
---|
| 41 | uint32_t pc_count;
|
---|
| 42 | uint16_t flen;
|
---|
| 43 | mrb_irep_debug_info_file **files;
|
---|
| 44 | } mrb_irep_debug_info;
|
---|
| 45 |
|
---|
| 46 | /*
|
---|
| 47 | * get line from irep's debug info and program counter
|
---|
| 48 | * @return returns NULL if not found
|
---|
| 49 | */
|
---|
| 50 | MRB_API const char *mrb_debug_get_filename(mrb_irep *irep, uint32_t pc);
|
---|
| 51 |
|
---|
| 52 | /*
|
---|
| 53 | * get line from irep's debug info and program counter
|
---|
| 54 | * @return returns -1 if not found
|
---|
| 55 | */
|
---|
| 56 | MRB_API int32_t mrb_debug_get_line(mrb_irep *irep, uint32_t pc);
|
---|
| 57 |
|
---|
| 58 | MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
|
---|
| 59 | mrb_state *mrb, mrb_irep *irep,
|
---|
| 60 | uint32_t start_pos, uint32_t end_pos);
|
---|
| 61 | MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
|
---|
| 62 | MRB_API void mrb_debug_info_free(mrb_state *mrb, mrb_irep_debug_info *d);
|
---|
| 63 |
|
---|
| 64 | MRB_END_DECL
|
---|
| 65 |
|
---|
| 66 | #endif /* MRUBY_DEBUG_H */
|
---|