From bedd14d2ea48d753309bd55726fac5c4a9339e5f Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 12 May 2025 23:34:02 +0200 Subject: [PATCH] Add a breakpoint when command 'stop' is used after tran simulation has already started --- src/frontend/breakp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/frontend/breakp.c b/src/frontend/breakp.c index 83eab7771..c1fa63785 100644 --- a/src/frontend/breakp.c +++ b/src/frontend/breakp.c @@ -12,6 +12,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice/ftedefs.h" #include "ngspice/dvec.h" #include "ngspice/ftedebug.h" +#include "ngspice/cktdefs.h" #include "breakp.h" #include "breakp2.h" #include "runcoms2.h" @@ -186,6 +187,19 @@ com_stop(wordlist *wl) (void) sprintf(buf, "%d", debugnumber); cp_addkword(CT_DBNUMS, buf); debugnumber++; + /* If com_stop is called after tran simulation has already started, set a breakpoint + if not in the past */ + if ((thisone->db_type == DB_STOPWHEN) && cieq(thisone->db_nodename1, "time")) { + if (thisone->db_value2 > ft_curckt->ci_ckt->CKTtime) { + CKTsetBreak(ft_curckt->ci_ckt, thisone->db_value2); + if (ft_ngdebug) + printf("breakpoint set to time = %g\n", thisone->db_value2); + } + else { + fprintf(stderr, "\nWarning: command 'stop' would set breakpoint in the past, ignored!\n" + " time: %g, bkpt: %e\n\n", ft_curckt->ci_ckt->CKTtime, thisone->db_value2); + } + } } return;