summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-28 14:31:43 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-28 14:31:43 +0000
commit790d114cdedc208a53c51dde595b0e89e2203c5d (patch)
treee38c899d0fa2691ea86aa5732f1c2df4110aab31
parent2007-09-27 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadada-examples-790d114cdedc208a53c51dde595b0e89e2203c5d.tar.bz2
2007-09-28 Joel Sherrill <joel.sherrill@oarcorp.com>
* .cvsiginore, ChangeLog, Makefile, README, stack_check.adb: New files.
-rw-r--r--stack_check/.cvsiginore4
-rw-r--r--stack_check/ChangeLog4
-rw-r--r--stack_check/Makefile19
-rw-r--r--stack_check/README13
-rw-r--r--stack_check/stack_check.adb30
5 files changed, 70 insertions, 0 deletions
diff --git a/stack_check/.cvsiginore b/stack_check/.cvsiginore
new file mode 100644
index 0000000..345016e
--- /dev/null
+++ b/stack_check/.cvsiginore
@@ -0,0 +1,4 @@
+b~*.adb
+b~*.ads
+*.ali
+stack_check
diff --git a/stack_check/ChangeLog b/stack_check/ChangeLog
new file mode 100644
index 0000000..20e1acc
--- /dev/null
+++ b/stack_check/ChangeLog
@@ -0,0 +1,4 @@
+2007-09-28 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * .cvsiginore, ChangeLog, Makefile, README, stack_check.adb: New files.
+
diff --git a/stack_check/Makefile b/stack_check/Makefile
new file mode 100644
index 0000000..feb5aac
--- /dev/null
+++ b/stack_check/Makefile
@@ -0,0 +1,19 @@
+#
+# Makefile for Ada Dump URL example
+#
+# See README.Makefiles in the main ada-examples directory.
+#
+
+PROGRAM=stack_check
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+# stack size for the first Ada thread
+CFLAGS +=-DGNAT_MAIN_STACKSPACE=100
+
+# Turn on stack checking
+EXTRA_GNATFLAGS=-fstack-check
+
+include ../Makefile.shared
diff --git a/stack_check/README b/stack_check/README
new file mode 100644
index 0000000..6c042f4
--- /dev/null
+++ b/stack_check/README
@@ -0,0 +1,13 @@
+#
+# $Id$
+#
+
+This directory contains a simple example program to demonstrate
+the stack checking capabilities of the GNAT Run-Time System
+in conjunction with RTEMS. In this example, a recursive procedure
+is called until we run out of stack space. The GNAT RTS invokes
+the standard RTEMS dynamic stack checking routine,
+rtems_stack_checker_is_blown, which checks the current stack pointer
+and the pattern area for damage. If either indicates a blown
+stack, then a message is printed and an indication of the blown
+stack is returned to GNAT which raises an Ada exception.
diff --git a/stack_check/stack_check.adb b/stack_check/stack_check.adb
new file mode 100644
index 0000000..229b99f
--- /dev/null
+++ b/stack_check/stack_check.adb
@@ -0,0 +1,30 @@
+--
+-- Blow the stack
+--
+-- $Id$
+--
+
+with Text_IO; use Text_IO;
+
+procedure stack_check is
+
+ type UselessArrayType is array (1 .. 1024) of Natural;
+ UselessArray : UselessArrayType;
+
+ procedure BlowMe (
+ N : in Natural;
+ U : in out UselessArrayType
+ ) is
+ MyUselessArray : UselessArrayType;
+ begin
+ Text_IO.Put_Line ( "Call depth = " & Natural'Image(N) );
+ U(5) := N;
+ U(6) := N+1;
+ BlowMe (N + 1, MyUselessArray);
+ U(5) := MyUselessArray(10);
+ end BlowMe;
+
+begin
+ BlowMe (1, UselessArray);
+end stack_check;
+