summaryrefslogtreecommitdiff
path: root/frontends/calculator/CEdev/examples/debugging/src
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2019-04-10 15:14:00 -0400
committerAndrew Opalach <andrew@akon.city> 2019-04-10 15:14:00 -0400
commit60699af63f92f43cc4b4b9e3050fcdd2a8468281 (patch)
tree20a18af2774daa43ae7f4352dd032a24f7e06075 /frontends/calculator/CEdev/examples/debugging/src
parent4527bc20241068731c62101d0467d416119ec0c4 (diff)
downloadcetris-60699af63f92f43cc4b4b9e3050fcdd2a8468281.tar.gz
cetris-60699af63f92f43cc4b4b9e3050fcdd2a8468281.tar.bz2
cetris-60699af63f92f43cc4b4b9e3050fcdd2a8468281.zip
add opengl fronend, remove sdl frontend, refactor build system
Diffstat (limited to 'frontends/calculator/CEdev/examples/debugging/src')
-rw-r--r--frontends/calculator/CEdev/examples/debugging/src/main.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/frontends/calculator/CEdev/examples/debugging/src/main.c b/frontends/calculator/CEdev/examples/debugging/src/main.c
new file mode 100644
index 0000000..67b5bac
--- /dev/null
+++ b/frontends/calculator/CEdev/examples/debugging/src/main.c
@@ -0,0 +1,47 @@
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <tice.h>
+
+#include <assert.h>
+#include <debug.h>
+
+/*
+ * Even though debug.h has prototypes for Debugger, SetWriteWatchpoint, SetWatchpoint, RemoveWatchpoint, RemoveAllWatchpoints, RemoveAllBreakpoints...
+ * you have to use the dbg_ prefix as shown here:
+ */
+
+void main(void) {
+ /* Set the intial value of some variables */
+ int dbg_test_var_1 = 10;
+ uint8_t dbg_test_var_2 = 3;
+
+ /* Print a simple debugging string */
+ dbg_sprintf(dbgout, "This is the start of a CEmu debugging test\n");
+
+ /* You can enter the debugger manually */
+ dbg_Debugger();
+
+ /* Set a watchpoint that will break anytime we write/change this variable */
+ dbg_SetWriteWatchpoint(&dbg_test_var_1, sizeof dbg_test_var_1);
+
+ /* Set a non breaking watchpoint just so we can see what is in this variable at any given time */
+ dbg_SetWatchpoint(&dbg_test_var_2, sizeof dbg_test_var_2);
+
+ /* Now, let's write to the variable to see what happens (Go to the 'Watchpoints' tab in CEmu to view the status) */
+ dbg_test_var_1 = 5;
+
+ /* Remove the watchpoint that we had set */
+ dbg_RemoveWatchpoint(&dbg_test_var_1);
+ dbg_RemoveWatchpoint(&dbg_test_var_2);
+
+ /* We can also use those */
+ dbg_RemoveAllWatchpoints();
+ dbg_RemoveAllBreakpoints();
+
+ /* Set this value to zero */
+ dbg_test_var_2 = 0;
+
+ /* Fail this assertion */
+ assert(dbg_test_var_2);
+}