Skip to content

Commit 8ef5a14

Browse files
committed
First steps of a "debug mode", for logging the state of BMDebug.
1 parent 3a116a3 commit 8ef5a14

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

‎source/bmdebug.c‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
53155323
static 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

‎source/makefile.dep‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ bmcommon.obj : bmcommon.h bmp-scan.h specialfolder.h
77
bmdebug.obj : armdisasm.h bmcommon.h bmp-scan.h bmp-script.h demangle.h \
88
dwarf.h guidriver.h nuklear.h nuklear_config.h mcu-info.h memdump.h \
99
noc_file_dialog.h nuklear_mousepointer.h nuklear_style.h \
10-
nuklear_splitter.h nuklear_tooltip.h minIni.h minGlue.h serialmon.h \
11-
specialfolder.h svd-support.h tcpip.h parsetsdl.h decodectf.h \
10+
nuklear_splitter.h nuklear_tooltip.h minIni.h minGlue.h pathsearch.h \
11+
serialmon.h specialfolder.h svd-support.h tcpip.h parsetsdl.h decodectf.h \
1212
swotrace.h
1313
bmflash.obj : guidriver.h nuklear.h nuklear_config.h noc_file_dialog.h \
1414
nuklear_style.h nuklear_tooltip.h bmcommon.h bmp-scan.h bmp-script.h \
@@ -47,6 +47,7 @@ nuklear_splitter.obj : nuklear_splitter.h nuklear.h nuklear_config.h
4747
nuklear_style.obj : nuklear_style.h nuklear.h nuklear_config.h
4848
nuklear_tooltip.obj : nuklear_tooltip.h nuklear.h nuklear_config.h
4949
parsetsdl.obj : parsetsdl.h
50+
pathsearch.obj : pathsearch.h
5051
picoro.obj : c11threads.h
5152
rs232.obj : rs232.h
5253
serialmon.obj : bmp-scan.h guidriver.h nuklear.h nuklear_config.h \
@@ -66,8 +67,8 @@ bmcommon.o : bmcommon.h bmp-scan.h specialfolder.h
6667
bmdebug.o : armdisasm.h bmcommon.h bmp-scan.h bmp-script.h demangle.h \
6768
dwarf.h elf.h guidriver.h nuklear.h nuklear_config.h mcu-info.h \
6869
memdump.h minIni.h minGlue.h noc_file_dialog.h nuklear_mousepointer.h \
69-
nuklear_style.h nuklear_splitter.h nuklear_tooltip.h serialmon.h \
70-
specialfolder.h svd-support.h tcpip.h parsetsdl.h decodectf.h \
70+
nuklear_style.h nuklear_splitter.h nuklear_tooltip.h pathsearch.h \
71+
serialmon.h specialfolder.h svd-support.h tcpip.h parsetsdl.h decodectf.h \
7172
swotrace.h res/icon_debug_64.h
7273
bmflash.o : guidriver.h nuklear.h nuklear_config.h noc_file_dialog.h \
7374
nuklear_mousepointer.h nuklear_style.h nuklear_tooltip.h bmcommon.h \
@@ -115,6 +116,7 @@ nuklear_splitter.o : nuklear_splitter.h nuklear.h nuklear_config.h
115116
nuklear_style.o : nuklear_style.h nuklear.h nuklear_config.h
116117
nuklear_tooltip.o : nuklear_tooltip.h nuklear.h nuklear_config.h
117118
parsetsdl.o : parsetsdl.h
119+
pathsearch.o : pathsearch.h
118120
picoro.o : c11threads.h
119121
rs232.o : rs232.h
120122
serialmon.o : bmp-scan.h guidriver.h nuklear.h nuklear_config.h rs232.h \

0 commit comments

Comments
 (0)