mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-13 01:38:19 +03:00
Allow disabling debugger at run time
For running compiler tests.
This commit is contained in:
@@ -18,6 +18,10 @@
|
||||
#define SYSTEM4_DEBUGGER_H
|
||||
#ifdef DEBUGGER_ENABLED
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool dbg_enabled;
|
||||
|
||||
void dbg_init(void);
|
||||
void dbg_fini(void);
|
||||
void dbg_repl(void);
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "vm/heap.h"
|
||||
#include "vm/page.h"
|
||||
|
||||
bool dbg_enabled = true;
|
||||
|
||||
struct variable {
|
||||
enum ain_data_type data_type;
|
||||
int struct_type;
|
||||
@@ -123,6 +125,8 @@ static sexp dbg_ctx;
|
||||
|
||||
void dbg_init(void)
|
||||
{
|
||||
if (!dbg_enabled)
|
||||
return;
|
||||
dbg_ctx = sexp_make_eval_context(NULL, NULL, NULL, 0, 0);
|
||||
sexp_load_standard_env(dbg_ctx, NULL, SEXP_SEVEN);
|
||||
sexp_load_standard_ports(dbg_ctx, NULL, stdin, stdout, stderr, 1);
|
||||
@@ -136,10 +140,14 @@ void dbg_init(void)
|
||||
|
||||
void dbg_fini(void)
|
||||
{
|
||||
if (!dbg_enabled)
|
||||
return;
|
||||
sexp_destroy_context(dbg_ctx);
|
||||
}
|
||||
|
||||
void dbg_repl(void)
|
||||
{
|
||||
if (!dbg_enabled)
|
||||
return;
|
||||
sexp_eval_string(dbg_ctx, "(repl 'escape: #\\\\ 'make-prompt: repl-make-prompt)", -1, NULL);
|
||||
}
|
||||
|
||||
+9
-2
@@ -267,6 +267,7 @@ static void usage(void)
|
||||
enum {
|
||||
LOPT_HELP = 256,
|
||||
LOPT_AUDIT,
|
||||
LOPT_NODEBUG,
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -279,8 +280,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (1) {
|
||||
static struct option long_options[] = {
|
||||
{ "help", no_argument, 0, LOPT_HELP },
|
||||
{ "audit", no_argument, 0, LOPT_AUDIT },
|
||||
{ "help", no_argument, 0, LOPT_HELP },
|
||||
{ "audit", no_argument, 0, LOPT_AUDIT },
|
||||
{ "nodebug", no_argument, 0, LOPT_NODEBUG },
|
||||
};
|
||||
int option_index = 0;
|
||||
int c = getopt_long(argc, argv, "ha", long_options, &option_index);
|
||||
@@ -296,6 +298,11 @@ int main(int argc, char *argv[])
|
||||
case LOPT_AUDIT:
|
||||
audit = true;
|
||||
break;
|
||||
case LOPT_NODEBUG:
|
||||
#ifdef DEBUGGER_ENABLED
|
||||
dbg_enabled = false;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
|
||||
Reference in New Issue
Block a user