Skip to content

Commit 6ab495f

Browse files
QuzarDCQuzarDC
authored andcommitted
example: Clean up assert handler example.
Ensure that we override any optimization and use debug level `Og` so that the assert stack trace that was just fixed works as expected. Additionally update the comments in the example to drop references to the old frame pointers tracing and providing the modern way to use $KOS_ADDR2LINE
1 parent d8619ba commit 6ab495f

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

examples/dreamcast/basic/asserthnd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ rm-elf:
1717
-rm -f $(TARGET)
1818

1919
$(TARGET): $(OBJS)
20-
kos-cc -o $(TARGET) $(OBJS)
20+
kos-cc -Og -o $(TARGET) $(OBJS)
2121

2222
run: $(TARGET)
2323
$(KOS_LOADER) $(TARGET)

examples/dreamcast/basic/asserthnd/asserthnd.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,25 @@
1212
This example shows off how to setup an assert handler (for example for
1313
a custom crash screen, or some other debug method, or even ignoring
1414
asserts selectively). It also demonstrates the default assert handler.
15-
If you compiled with -DFRAME_POINTERS and without -fomit-frame-pointer
16-
then you'll get something like this:
15+
You'll get something like this:
1716
1817
*** ASSERTION FAILURE ***
1918
Assertion "a != 5" failed at asserthnd.c:40 in `func2': This is a test message!
2019
2120
-------- Stack Trace (innermost first) ---------
22-
8c01016a
23-
8c0101e0
24-
8c010478
25-
8c010062
21+
8c010170
22+
8c0101ca
23+
8c0111f2
24+
8c010086
2625
-------------- End Stack Trace -----------------
2726
2827
You can punch those numbers into addr2line to get a nice stack traceback,
2928
assuming you compiled your program with -g:
3029
31-
>] dc-addr2line -e asserthnd.elf 8c01016a 8c0101e0 8c010478
32-
/usr/local/home/bard/prj/kos/examples/dreamcast/basic/asserthnd/asserthnd.c:46
33-
/usr/local/home/bard/prj/kos/examples/dreamcast/basic/asserthnd/asserthnd.c:69
34-
/usr/local/home/bard/prj/kos/kernel/arch/dreamcast/kernel/main.c:129
30+
>] $KOS_ADDR2LINE -e asserthnd.elf 8c010170 8c0101ca 8c0111f2
31+
/opt/toolchains/dc/kos/examples/dreamcast/basic/asserthnd/asserthnd.c:45 (discriminator 1)
32+
/opt/toolchains/dc/kos/examples/dreamcast/basic/asserthnd/asserthnd.c:73
33+
/opt/toolchains/dc/kos/kernel/arch/dreamcast/kernel/init.c:311
3534
3635
*/
3736

0 commit comments

Comments
 (0)