Allow disabling debugger at run time

For running compiler tests.
This commit is contained in:
Nunuhara Cabbage
2020-06-22 16:00:09 -07:00
parent b6ca188a34
commit ad868aec86
3 changed files with 21 additions and 2 deletions
+4
View File
@@ -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);
+8
View File
@@ -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
View File
@@ -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;