@@ -3679,8 +3679,8 @@ enum {
36793679 STATE_TARGET_EXT ,
36803680 STATE_PROBE_TYPE ,
36813681 STATE_PROBE_CMDS ,
3682- STATE_MON_TPWR ,
36833682 STATE_CONNECT_SRST ,
3683+ STATE_MON_TPWR ,
36843684 STATE_MON_SCAN ,
36853685 STATE_ASYNC_MODE ,
36863686 STATE_ATTACH ,
@@ -5172,8 +5172,8 @@ static void version(void)
51725172 freopen ("CONOUT$" , "wb" , stdout );
51735173 freopen ("CONOUT$" , "wb" , stderr );
51745174 }
5175- printf ("Fortify: [%d] %s\n" , type , str );
51765175# endif
5176+ printf ("Fortify: [%d] %s\n" , type , str );
51775177 }
51785178#endif
51795179
@@ -5214,6 +5214,7 @@ typedef struct tagAPPSTATE {
52145214 int curstate ; /**< current (or new) state */
52155215 int prevstate ; /**< previous state (to detect state changes) */
52165216 int nextstate ; /**< on occasion, follow-up state depends on logic */
5217+ bool debugmode ; /**< for extra debug logging */
52175218 unsigned long gdbversion ; /**< version of GDB, xx.yy.zzzz */
52185219 int stateparam [3 ]; /**< parameters for state change */
52195220 int refreshflags ; /**< flags for refresh of various views */
@@ -5306,12 +5307,19 @@ enum {
53065307
53075308#define CMD_BUFSIZE 2048
53085309
5309- #define RESETSTATE (app , state ) ((app)->prevstate = (app)->nextstate = -1, (app)->waitidle = nk_false, (app)->curstate = (state))
5310- #define MOVESTATE (app , state ) ((app)->waitidle = nk_false, (app)->curstate = (state))
5310+ #define RESETSTATE (app , state ) ((app)->prevstate = (app)->nextstate = -1, (app)->waitidle = nk_false, (app)->curstate = (state), log_state(app) )
5311+ #define MOVESTATE (app , state ) ((app)->waitidle = nk_false, (app)->curstate = (state), log_state(app) )
53115312#define STATESWITCH (app ) ((app)->curstate != (app)->prevstate)
53125313#define MARKSTATE (app ) ((app)->prevstate = (app)->curstate)
53135314
53145315
5316+ static int log_state (const APPSTATE * state )
5317+ {
5318+ if (state -> debugmode )
5319+ printf ("State: %d (moved from %d)\n" , state -> curstate , state -> prevstate );
5320+ return state -> curstate ;
5321+ }
5322+
53155323static void help_popup (struct nk_context * ctx , APPSTATE * state , float canvas_width , float canvas_height )
53165324{
53175325 assert (ctx != NULL );
@@ -7800,6 +7808,9 @@ int main(int argc, char *argv[])
78007808 case 'h' :
78017809 usage (NULL );
78027810 return EXIT_SUCCESS ;
7811+ case 'd' :
7812+ appstate .debugmode = true;
7813+ break ;
78037814 case 'f' :
78047815 ptr = & argv [idx ][2 ];
78057816 if (* ptr == '=' || * ptr == ':' )
@@ -8072,6 +8083,7 @@ int main(int argc, char *argv[])
80728083 stringlist_clear (& consolestring_root );
80738084 stringlist_clear (& appstate .consoleedit_root );
80748085 stringlist_clear (& semihosting_root );
8086+ tracelog_statusclear ();
80758087 breakpoint_clear ();
80768088 svd_clear ();
80778089 locals_clear ();
@@ -8083,6 +8095,10 @@ int main(int argc, char *argv[])
80838095 disasm_cleanup (& appstate .armstate );
80848096 tcpip_cleanup ();
80858097 sermon_close ();
8098+ # if defined FORTIFY
8099+ Fortify_CheckAllMemory ();
8100+ Fortify_ListAllMemory ();
8101+ # endif
80868102 return exitcode ;
80878103}
80888104
0 commit comments