From ad1e84bff0ba79b8e055752807b1eed7e7140778 Mon Sep 17 00:00:00 2001 From: Daniel King Date: Sat, 9 May 2026 19:31:19 +0100 Subject: [PATCH 1/2] Test that exception propagation works on embedded runtimes --- tests/testcases/test_exceptions/opt.py | 9 ++++++++ tests/testcases/test_exceptions/test.adb | 27 ++++++++++++++++++++++++ tests/testcases/test_exceptions/test.out | 3 +++ 3 files changed, 39 insertions(+) create mode 100644 tests/testcases/test_exceptions/opt.py create mode 100644 tests/testcases/test_exceptions/test.adb create mode 100644 tests/testcases/test_exceptions/test.out diff --git a/tests/testcases/test_exceptions/opt.py b/tests/testcases/test_exceptions/opt.py new file mode 100644 index 0000000..7857c01 --- /dev/null +++ b/tests/testcases/test_exceptions/opt.py @@ -0,0 +1,9 @@ +import support.target_info +import pytest + + +def check_test_conditions(target_info: support.target_info.TargetInfo): + if target_info.runtime_profile != "embedded": + pytest.skip( + f"Test is not applicable for '{target_info.runtime_profile}' runtimes" + ) diff --git a/tests/testcases/test_exceptions/test.adb b/tests/testcases/test_exceptions/test.adb new file mode 100644 index 0000000..d724c5d --- /dev/null +++ b/tests/testcases/test_exceptions/test.adb @@ -0,0 +1,27 @@ +with Ada.Text_IO; +with Ada.Exceptions; + +-- Test with all the tasking stuff in the closure too + +with Ada.Real_Time; +pragma Unreferenced (Ada.Real_Time); + +procedure Test is + procedure Raise_Ex with No_Inline is + begin + raise Constraint_Error with "Hello"; + end Raise_Ex; +begin + Raise_Ex; + Ada.Text_IO.Put_Line ("Exception not caught!"); + Ada.Text_IO.Put_Line ("===TEST COMPLETE==="); + +exception + when Ex : Constraint_Error => + Ada.Text_IO.Put_Line ("Caught: " & Ada.Exceptions.Exception_Name (Ex)); + + Ada.Text_IO.Put_Line + ("Message: " & Ada.Exceptions.Exception_Message (Ex)); + + Ada.Text_IO.Put_Line ("===TEST COMPLETE==="); +end Test; diff --git a/tests/testcases/test_exceptions/test.out b/tests/testcases/test_exceptions/test.out new file mode 100644 index 0000000..f7cad5f --- /dev/null +++ b/tests/testcases/test_exceptions/test.out @@ -0,0 +1,3 @@ +Caught: CONSTRAINT_ERROR +Message: Hello +===TEST COMPLETE=== \ No newline at end of file From 74a7b2d4f9a844a9aa7dd0a30ed8290146efacb2 Mon Sep 17 00:00:00 2001 From: Daniel King Date: Sat, 9 May 2026 19:31:43 +0100 Subject: [PATCH 2/2] rp2040,rp2350: Don't enable interrupts during Initialize_Board The runtime does not expect interrupts to be enabled at this point, and the runtime will enable interrupts later once everything else is initialized. Having interrupts trigger early can cause a crash since the Interrupt_Wrapper will try to change task priorities before threads are initialized. Fixes community-bb-runtimes#27 --- rp2040_src/s-bbbosu.adb | 2 -- rp2350_src/s-bbbosu.adb | 2 -- 2 files changed, 4 deletions(-) diff --git a/rp2040_src/s-bbbosu.adb b/rp2040_src/s-bbbosu.adb index 71cde9f..a52876f 100644 --- a/rp2040_src/s-bbbosu.adb +++ b/rp2040_src/s-bbbosu.adb @@ -164,8 +164,6 @@ package body System.BB.Board_Support is Install_Trap_Handler (Interrupt_Handler'Address, Interrupt_Request_Vector); - - Enable_Interrupts (Priority'Last); end Initialize_Board; package body Time is diff --git a/rp2350_src/s-bbbosu.adb b/rp2350_src/s-bbbosu.adb index e77aaa4..11d33ed 100644 --- a/rp2350_src/s-bbbosu.adb +++ b/rp2350_src/s-bbbosu.adb @@ -199,8 +199,6 @@ package body System.BB.Board_Support is Install_Trap_Handler (Interrupt_Handler'Address, Interrupt_Request_Vector); - - Enable_Interrupts (Priority'Last); end Initialize_Board; package body Time is