--- freem/src/mdebug.c 2025/05/01 17:02:30 1.11 +++ freem/src/mdebug.c 2025/05/01 21:02:31 1.12 @@ -1,5 +1,5 @@ /* - * $Id: mdebug.c,v 1.11 2025/05/01 17:02:30 snw Exp $ + * $Id: mdebug.c,v 1.12 2025/05/01 21:02:31 snw Exp $ * debugger enhancements * * @@ -24,6 +24,9 @@ * along with FreeM. If not, see . * * $Log: mdebug.c,v $ + * Revision 1.12 2025/05/01 21:02:31 snw + * Documentation updates + * * Revision 1.11 2025/05/01 17:02:30 snw * Further debugging improvements * @@ -206,7 +209,7 @@ int debugger (int entry_mode, char *entr } snprintf (dbg_prompt, sizeof (dbg_prompt) - 1, "%s $STACK=%d [DEBUG]> ", rouname_buf, nstx); - + if (dbg_enable_watch && dbg_pending_watches) dbg_dump_watchlist (); dbg_buf = readline (dbg_prompt); if (!dbg_buf) continue; @@ -347,6 +350,48 @@ int debugger (int entry_mode, char *entr printf ("ZTRAP:\t%s\n", ecbuf); } + else if ((strcmp (dbg_cmd, "halt") == 0) || (strcmp (dbg_cmd, "h") == 0)) { + printf ("debug: forcing halt\n"); + exit (0); + } + else if ((strcmp (dbg_cmd, "watch") == 0) || (strcmp (dbg_cmd, "w") == 0)) { + char watchmode; + char *glvn; + + if (dbg_argc == 1) { + switch (dbg_enable_watch) { + case 0: + dbg_enable_watch = 1; + printf ("debug: watchpoints enabled\n"); + break; + case 1: + dbg_enable_watch = 0; + printf ("debug: watchpoints disabled\n"); + break; + } + } + else { + watchmode = dbarg[0]; + glvn = &(dbarg[1]); + + switch (watchmode) { + case '+': + dbg_add_watch (glvn); + break; + case '-': + dbg_remove_watch (glvn); + break; + case '?': + dbg_dump_watch (glvn); + break; + default: + printf ("debug: watch mode must be +, -, or ?\n"); + break; + } + + set_io (UNIX); + } + } else { printf ("DEBUG: invalid command\r\n"); } @@ -390,7 +435,7 @@ dbg_watch *dbg_add_watch (char *varnam) return NULL; } - if ((dbg_watchlist[index].varnam = (char *) malloc (256 * sizeof (char))) == NULL) { + if ((dbg_watchlist[index].varnam = (char *) calloc (256, sizeof (char))) == NULL) { set_io (UNIX); fprintf (stderr, "Could not allocate memory for the new watchlist entry.\n"); set_io (MUMPS); @@ -402,7 +447,7 @@ dbg_watch *dbg_add_watch (char *varnam) dbg_watchlist[index].chgct = 0; set_io (UNIX); - fprintf (stderr, "Added '%s' to the watchlist.\n", dbg_get_watch_name (varnam)); + fprintf (stderr, "Added '%s' to the watchlist.\n", varnam); set_io (MUMPS); return NULL;