--- freem/src/xecline.c 2025/04/28 19:38:55 1.17 +++ freem/src/xecline.c 2025/05/18 18:15:38 1.25 @@ -1,5 +1,5 @@ /* - * $Id: xecline.c,v 1.17 2025/04/28 19:38:55 snw Exp $ + * $Id: xecline.c,v 1.25 2025/05/18 18:15:38 snw Exp $ * freem interpreter proper * * @@ -24,6 +24,30 @@ * along with FreeM. If not, see . * * $Log: xecline.c,v $ + * Revision 1.25 2025/05/18 18:15:38 snw + * Add ZEDIT command for editing routines + * + * Revision 1.24 2025/05/14 12:22:04 snw + * Further work on shared memory + * + * Revision 1.23 2025/05/06 16:10:06 snw + * Add extra blank before readline call on NetBSD + * + * Revision 1.22 2025/05/05 14:53:17 snw + * Modify rpm spec to include documentation TODO + * + * Revision 1.21 2025/05/01 17:02:30 snw + * Further debugging improvements + * + * Revision 1.20 2025/04/30 17:19:16 snw + * Improve backtraces in debugger + * + * Revision 1.19 2025/04/30 14:41:03 snw + * Further debugger work + * + * Revision 1.18 2025/04/29 18:46:17 snw + * Begin work on interactive debugger + * * Revision 1.17 2025/04/28 19:38:55 snw * Add trace mode * @@ -168,7 +192,6 @@ int xecline(int typ) short new_and_set = FALSE; short new_object = FALSE; short destructor_run = FALSE; - short debug_mode = FALSE; short libcall = FALSE; char *namold; long rouoldc; @@ -191,6 +214,7 @@ int xecline(int typ) char *reeval_codptr; char reeval_code[512]; + char entryref[256]; int i; int j; @@ -240,7 +264,10 @@ int xecline(int typ) next_line: /* entry point for next command line */ - + if (debug_mode) { + debug_mode = debugger (DEBENTRY_LINE, entryref); + } + job_set_status (pid, JSTAT_INTERPRETER); if (then_ctr > 0) { @@ -288,6 +315,11 @@ next_line: /* entry point for n codptr = code; next_cmnd: /* continue line entry point */ + getraddress (entryref, nstx); + if (debug_mode) { + debug_mode = debugger (DEBENTRY_CMD, entryref); + } + if (sigint_in_for) goto for_quit; if (forsw && (forpost[forx][0] != '\0')) { @@ -2610,7 +2642,6 @@ quit0: printf ("CHECK 03 (Stack PUSH)\r\n"); #endif - if (++nstx > NESTLEVLS) { nstx--; merr_raise (STKOV); @@ -2636,7 +2667,7 @@ quit0: nestn[nstx] = 0; /* no overring of routine */ nestr[nstx] = roucur - rouptr; /* save roucur: only for $V(26) needed */ ztrap[nstx][0] = EOL; - + forsw = TRUE; ftyp = 0; /* no args is FOREVER */ @@ -4944,7 +4975,8 @@ open_socket: if (merr () > OK) break; } else { - halt:i = 0; +halt: + i = 0; } cleanup (); @@ -5143,24 +5175,37 @@ open_socket: expr (STRING); if (merr () > OK) break; - switch (intexpr (argptr)) { - - case 2: - DSM2err = TRUE; - break; /* enable DSM V 2 error processing */ - - case -2: - DSM2err = FALSE; - break; /* enable normal error processing */ - - case 0: - breakon = FALSE; - break; /* disable CTRL/C */ - - default: - breakon = TRUE; - break; /* enable CTRL/C */ + { + char brkstr[256]; + + stcpy (brkstr, argptr); + stcnv_m2c (brkstr); + + if (strcmp (brkstr, "DEBUG") == 0) { + debug_mode = TRUE; + } + else { + switch (intexpr (argptr)) { + + case 2: + DSM2err = TRUE; + break; /* enable DSM V 2 error processing */ + + case -2: + DSM2err = FALSE; + break; /* enable normal error processing */ + + case 0: + breakon = FALSE; + break; /* disable CTRL/C */ + + default: + breakon = TRUE; + break; /* enable CTRL/C */ + } + } } + break; case VIEW: @@ -5250,6 +5295,11 @@ open_socket: break; /* Z-COMMANDS */ + case ZEDIT: + merr_raise (cmd_zedit (&ra)); + MRESCHECK(ra); + break; + case ZGO: /* ZGO with arguments: same as GOTO but with BREAK on */ @@ -6725,8 +6775,7 @@ syn_evt_loop_bottom: if (ch != ',' && merr () == OK) { merr_raise (SPACER); } - else if ((ierr <= OK) || (debug_mode == TRUE)) { - if (debug_mode) goto direct_mode; + else if (ierr <= OK) { if (*++codptr != SP && *codptr != EOL) goto again; merr_raise (ARGLIST); @@ -6768,6 +6817,7 @@ err: } } + if (merr () > OK ) { char er_buf[ERRLEN]; @@ -6777,6 +6827,7 @@ err: stcpy (er_buf, errmes[merr ()]); stcnv_m2c (er_buf); + #if !defined(MSDOS) logprintf (FM_LOG_DEBUG, "xecline: interpreter error %d [%s]", ierr, er_buf); #endif @@ -7149,6 +7200,7 @@ restart: free (t_nsn); + } @@ -7210,9 +7262,6 @@ restore: goto next_cmnd; } - else { - if (debug_mode) goto direct_mode; - } if (libcall == TRUE) { /* library mode: don't go to direct mode, just return */ return merr (); @@ -7252,7 +7301,11 @@ direct_mode: set_io (UNIX); job_set_status (pid, JSTAT_DIRECTMODE); - + +#if defined(__NetBSD__) + printf ("\r\n"); +#endif + /* readline() does its own malloc() */ fmrl_buf = readline (fmrl_prompt); @@ -7263,6 +7316,7 @@ direct_mode: goto halt; } + if (strlen (fmrl_buf) > 0) { add_history (fmrl_buf); @@ -7289,13 +7343,6 @@ direct_mode: } } - else if (strcmp (fmrl_buf, "step") == 0) { - debug_mode = TRUE; - goto zgo; - } - else if ((strcmp (fmrl_buf, "cont") == 0) || (strcmp (fmrl_buf, "continue") == 0)) { - debug_mode = FALSE; - } else if (strcmp (fmrl_buf, "rbuf") == 0) { rbuf_dump (); }