10#ifndef __WSLUA_DEBUGGER_H__
11#define __WSLUA_DEBUGGER_H__
13#include "ws_symbol_export.h"
17typedef struct lua_State lua_State;
30 WSLUA_DEBUGGER_RUNNING,
33 } wslua_debugger_state_t;
40 WSLUA_DEBUGGER_THEME_AUTO = 0,
41 WSLUA_DEBUGGER_THEME_DARK = 1,
42 WSLUA_DEBUGGER_THEME_LIGHT = 2
43 } wslua_debugger_theme_t;
57 WSLUA_HIT_COUNT_MODE_FROM = 0,
59 WSLUA_HIT_COUNT_MODE_EVERY = 1,
61 WSLUA_HIT_COUNT_MODE_ONCE = 2,
62 } wslua_hit_count_mode_t;
108 WS_DLL_PUBLIC
void wslua_debugger_init(lua_State *L);
114 WS_DLL_PUBLIC
bool wslua_debugger_is_enabled(
void);
120 WS_DLL_PUBLIC
void wslua_debugger_set_enabled(
bool enabled);
132 wslua_debugger_set_user_explicitly_disabled(
bool user_wants_debugger_stay_off);
141 wslua_debugger_may_auto_enable_for_breakpoints(
void);
148 WS_DLL_PUBLIC
void wslua_debugger_renounce_restore_after_reload(
void);
155 typedef void (*wslua_debugger_ui_update_cb_t)(
const char *file_path,
163 wslua_debugger_register_ui_callback(wslua_debugger_ui_update_cb_t cb);
168 WS_DLL_PUBLIC
void wslua_debugger_continue(
void);
176 WS_DLL_PUBLIC
void wslua_debugger_step_in(
void);
184 WS_DLL_PUBLIC
void wslua_debugger_step_over(
void);
192 WS_DLL_PUBLIC
void wslua_debugger_step_out(
void);
202 WS_DLL_PUBLIC
void wslua_debugger_set_variable_stack_level(int32_t level);
208 WS_DLL_PUBLIC int32_t wslua_debugger_get_variable_stack_level(
void);
218 WS_DLL_PUBLIC int32_t wslua_debugger_find_stack_level_for_watch_spec(
226 WS_DLL_PUBLIC
void wslua_debugger_run_to_line(
const char *file_path,
234 WS_DLL_PUBLIC
void wslua_debugger_add_breakpoint(
const char *file_path,
242 WS_DLL_PUBLIC
void wslua_debugger_remove_breakpoint(
const char *file_path,
252 wslua_debugger_set_breakpoint_active(
const char *file_path, int64_t line,
258 WS_DLL_PUBLIC
void wslua_debugger_clear_breakpoints(
void);
275 wslua_debugger_set_breakpoint_condition(
const char *file_path, int64_t line,
276 const char *condition);
290 wslua_debugger_set_breakpoint_hit_count_target(
const char *file_path,
303 wslua_debugger_set_breakpoint_hit_count_mode(
const char *file_path,
305 wslua_hit_count_mode_t mode);
319 wslua_debugger_set_breakpoint_log_message(
const char *file_path,
321 const char *message);
333 wslua_debugger_set_breakpoint_log_also_pause(
const char *file_path,
341 wslua_debugger_reset_breakpoint_hit_count(
const char *file_path,
347 WS_DLL_PUBLIC
void wslua_debugger_reset_all_breakpoint_hit_counts(
void);
363 wslua_debugger_check_condition_syntax(
const char *expression,
382 wslua_debugger_set_breakpoint_condition_error(
const char *file_path,
384 const char *err_msg);
392 WS_DLL_PUBLIC int32_t
393 wslua_debugger_get_breakpoint_state(
const char *file_path, int64_t line);
406 WS_DLL_PUBLIC int32_t
407 wslua_debugger_get_breakpoint_state_canonical(
408 const char *canonical_path, int64_t line);
415 WS_DLL_PUBLIC
char *wslua_debugger_canonical_path(
const char *file_path);
450 wslua_debugger_get_stack(int32_t *frame_count);
458 int32_t frame_count);
469 wslua_debugger_get_variables(
const char *path, int32_t *variable_count);
477 int32_t variable_count);
483 WS_DLL_PUBLIC
unsigned wslua_debugger_get_breakpoint_count(
void);
493 WS_DLL_PUBLIC
bool wslua_debugger_get_breakpoint(
unsigned idx,
494 const char **file_path,
507 WS_DLL_PUBLIC
bool wslua_debugger_get_breakpoint_extended(
508 unsigned idx,
const char **file_path, int64_t *line,
bool *active,
509 const char **condition, int64_t *hit_count_target,
510 int64_t *hit_count,
bool *condition_error,
511 const char **log_message,
512 wslua_hit_count_mode_t *hit_count_mode,
513 bool *log_also_pause);
533 wslua_debugger_get_breakpoint_condition_error_message(
unsigned idx);
548 WS_DLL_PUBLIC int32_t
549 wslua_debugger_get_breakpoint_state_canonical_ex(
const char *canonical_path,
563 typedef void (*wslua_debugger_log_emit_callback_t)(
const char *file_path,
565 const char *message);
570 WS_DLL_PUBLIC
void wslua_debugger_register_log_emit_callback(
571 wslua_debugger_log_emit_callback_t callback);
579 typedef void (*wslua_debugger_reload_callback_t)(void);
592 WS_DLL_PUBLIC
void wslua_debugger_register_reload_callback(
593 wslua_debugger_reload_callback_t callback);
609 WS_DLL_PUBLIC
bool wslua_debugger_notify_reload(
void);
617 typedef void (*wslua_debugger_post_reload_callback_t)(void);
629 WS_DLL_PUBLIC
void wslua_debugger_register_post_reload_callback(
630 wslua_debugger_post_reload_callback_t callback);
639 WS_DLL_PUBLIC
void wslua_debugger_notify_post_reload(
void);
647 WS_DLL_PUBLIC
void wslua_debugger_restore_after_reload(
void);
664 WS_DLL_PUBLIC
char *wslua_debugger_evaluate(
const char *expression,
671 WS_DLL_PUBLIC
bool wslua_debugger_is_paused(
void);
682 typedef void (*wslua_debugger_script_loaded_callback_t)(
683 const char *file_path);
693 WS_DLL_PUBLIC
void wslua_debugger_register_script_loaded_callback(
694 wslua_debugger_script_loaded_callback_t callback);
705 wslua_debugger_notify_script_loaded(
const char *file_path);
713 typedef void (*wslua_debugger_loaded_script_callback_t)(
714 const char *file_path,
void *user_data);
729 WS_DLL_PUBLIC
void wslua_debugger_foreach_loaded_script(
730 wslua_debugger_loaded_script_callback_t callback,
void *user_data);
742#define WSLUA_WATCH_MAX_PATH_SEGMENTS 32
754 WS_DLL_PUBLIC
bool wslua_debugger_watch_spec_uses_path_resolution(
762 WS_DLL_PUBLIC
char *wslua_debugger_watch_variable_path_for_spec(
775 WS_DLL_PUBLIC
char *wslua_debugger_watch_resolved_variable_path_for_spec(
789 WS_DLL_PUBLIC
bool wslua_debugger_watch_read_root(
790 const char *spec,
char **value_out,
char **type_out,
791 bool *can_expand_out,
char **error_msg);
818 WS_DLL_PUBLIC
bool wslua_debugger_read_variable_value_full(
819 const char *variable_path,
char **value_out,
char **error_msg);
848 WS_DLL_PUBLIC
bool wslua_debugger_watch_expr_read_root(
849 const char *spec,
char **value_out,
char **type_out,
850 bool *can_expand_out,
char **error_msg);
863 WS_DLL_PUBLIC
bool wslua_debugger_watch_expr_read_subpath(
864 const char *spec,
const char *subpath,
char **value_out,
865 char **type_out,
bool *can_expand_out,
char **error_msg);
880 WS_DLL_PUBLIC
bool wslua_debugger_watch_expr_get_variables(
881 const char *spec,
const char *subpath,
895 WS_DLL_PUBLIC
bool wslua_debugger_watch_expr_read_full(
896 const char *spec,
const char *subpath,
char **value_out,
Breakpoint structure for in-memory storage.
Definition wslua_debugger.h:80
char * log_message
Definition wslua_debugger.h:95
wslua_hit_count_mode_t hit_count_mode
Definition wslua_debugger.h:87
int64_t hit_count
Definition wslua_debugger.h:86
bool condition_error
Definition wslua_debugger.h:91
char * condition_error_msg
Definition wslua_debugger.h:92
int64_t hit_count_target
Definition wslua_debugger.h:85
bool active
Definition wslua_debugger.h:83
bool log_also_pause
Definition wslua_debugger.h:96
char * condition
Definition wslua_debugger.h:84
char * file_path
Definition wslua_debugger.h:81
int64_t last_fired_us
Definition wslua_debugger.h:101
int64_t line
Definition wslua_debugger.h:82
Stack frame structure.
Definition wslua_debugger.h:432
int64_t linedefined
Definition wslua_debugger.h:435
char * source
Definition wslua_debugger.h:433
int64_t line
Definition wslua_debugger.h:434
char * name
Definition wslua_debugger.h:440
Variable structure for inspection.
Definition wslua_debugger.h:421
char * value
Definition wslua_debugger.h:423
char * name
Definition wslua_debugger.h:422
char * type
Definition wslua_debugger.h:424
bool can_expand
Definition wslua_debugger.h:425