Index: c/src/tests/samples/cdtest/main.cc
===================================================================
--- c/src/tests/samples/cdtest/main.cc	(revision 44dd8a611657c4bc94513d12bb4903c3809a3f2a)
+++ c/src/tests/samples/cdtest/main.cc	(revision fcf17a4f69b7580e87524559e9c87f48446a0814)
@@ -17,6 +17,13 @@
  *  http://www.OARcorp.com/rtems/license.html.
  *
+ *
+ *  by Rosimildo da Silva:
+ *  Modified the test a bit to indicate when an instance is
+ *  global or not, and added code to test C++ exception.
+ *
+ *
  *  $Id$
  */
+// #define RTEMS_TEST_IO_STREAM
 
 #include <rtems.h>
@@ -27,5 +34,7 @@
 #endif
 
-extern "C" {
+extern "C" 
+{
+#include <tmacros.h>
 extern rtems_task main_task(rtems_task_argument);
 }
@@ -35,11 +44,10 @@
 class A {
 public:
-    A(void)
+  A(const char *p = "LOCAL" ) : ptr( p )
     {
         num_inst++;
         printf(
-          "Hey I'm in base class constructor number %d for %p.\n",
-          num_inst,
-          this
+          "%s: Hey I'm in base class constructor number %d for %p.\n",
+          p, num_inst, this
         );
 
@@ -55,7 +63,6 @@
     {
         printf(
-          "Hey I'm in base class destructor number %d for %p.\n",
-          num_inst,
-          this
+          "%s: Hey I'm in base class destructor number %d for %p.\n",
+          ptr, num_inst, this
         );
 	print();
@@ -67,15 +74,15 @@
 protected:
     char  *string;
+    const char *ptr;
 };
 
 class B : public A {
 public:
-    B(void)
+  B(const char *p = "LOCAL" ) : A( p ) 
     {
         num_inst++;
         printf(
-          "Hey I'm in derived class constructor number %d for %p.\n",
-          num_inst,
-          this
+          "%s: Hey I'm in derived class constructor number %d for %p.\n",
+          p, num_inst,  this
         );
 
@@ -91,6 +98,6 @@
     {
         printf(
-          "Hey I'm in derived class destructor number %d for %p.\n",
-          num_inst,
+          "%s: Hey I'm in derived class destructor number %d for %p.\n",
+          ptr, num_inst,
           this
         );
@@ -103,6 +110,32 @@
 
 
-A foo;
-B foobar;
+class RtemsException 
+{
+public:
+    
+    RtemsException( char *module, int ln, int err = 0 )
+    : error( err ), line( ln ), file( module )
+    {
+      printf( "RtemsException raised=File:%s, Line:%d, Error=%X\n",
+               file, line, error ); 
+    }
+
+    void show()
+    {
+      printf( "RtemsException ---> File:%s, Line:%d, Error=%X\n",
+               file, line, error ); 
+    }
+
+private:
+   int  error;
+   int  line;
+   char *file;
+
+};
+
+
+
+A foo( "GLOBAL" );
+B foobar( "GLOBAL" );
 
 void
@@ -117,6 +150,6 @@
     printf("IO Stream not tested\n");
 #endif
-
     bar = blech;
+    rtems_task_wake_after( 5 * get_ticks_per_second() );
 }
 
@@ -128,4 +161,16 @@
 //
 
+static void foo_function()
+{
+    try 
+    {
+      throw "foo_function() throw this exception";  
+    }
+    catch( const char *e )
+    {
+     printf( "foo_function() catch block called:\n   < %s  >\n", e );
+     throw "foo_function() re-throwing execption...";  
+    }
+}
 
 rtems_task main_task(
@@ -139,4 +184,32 @@
     printf( "*** END OF CONSTRUCTOR/DESTRUCTOR TEST ***\n\n\n" );
 
+
+    printf( "*** TESTING C++ EXCEPTIONS ***\n\n" );
+
+    try 
+    {
+      foo_function();
+    }
+    catch( const char *e )
+    {
+       printf( "Success catching a char * exception\n%s\n", e );
+    }
+    try 
+    {
+      printf( "throw an instance based exception\n" );
+		throw RtemsException( __FILE__, __LINE__, 0x55 ); 
+    }
+    catch( RtemsException & ex ) 
+    {
+       printf( "Success catching RtemsException...\n" );
+       ex.show();
+    }
+    catch(...) 
+    {
+      printf( "Caught another exception.\n" );
+    }
+    printf( "Exceptions are working properly.\n" );
+    rtems_task_wake_after( 5 * get_ticks_per_second() );
+    printf( "Global Dtors should be called after this line....\n" );
     exit(0);
 }
Index: testsuites/samples/cdtest/main.cc
===================================================================
--- testsuites/samples/cdtest/main.cc	(revision 44dd8a611657c4bc94513d12bb4903c3809a3f2a)
+++ testsuites/samples/cdtest/main.cc	(revision fcf17a4f69b7580e87524559e9c87f48446a0814)
@@ -17,6 +17,13 @@
  *  http://www.OARcorp.com/rtems/license.html.
  *
+ *
+ *  by Rosimildo da Silva:
+ *  Modified the test a bit to indicate when an instance is
+ *  global or not, and added code to test C++ exception.
+ *
+ *
  *  $Id$
  */
+// #define RTEMS_TEST_IO_STREAM
 
 #include <rtems.h>
@@ -27,5 +34,7 @@
 #endif
 
-extern "C" {
+extern "C" 
+{
+#include <tmacros.h>
 extern rtems_task main_task(rtems_task_argument);
 }
@@ -35,11 +44,10 @@
 class A {
 public:
-    A(void)
+  A(const char *p = "LOCAL" ) : ptr( p )
     {
         num_inst++;
         printf(
-          "Hey I'm in base class constructor number %d for %p.\n",
-          num_inst,
-          this
+          "%s: Hey I'm in base class constructor number %d for %p.\n",
+          p, num_inst, this
         );
 
@@ -55,7 +63,6 @@
     {
         printf(
-          "Hey I'm in base class destructor number %d for %p.\n",
-          num_inst,
-          this
+          "%s: Hey I'm in base class destructor number %d for %p.\n",
+          ptr, num_inst, this
         );
 	print();
@@ -67,15 +74,15 @@
 protected:
     char  *string;
+    const char *ptr;
 };
 
 class B : public A {
 public:
-    B(void)
+  B(const char *p = "LOCAL" ) : A( p ) 
     {
         num_inst++;
         printf(
-          "Hey I'm in derived class constructor number %d for %p.\n",
-          num_inst,
-          this
+          "%s: Hey I'm in derived class constructor number %d for %p.\n",
+          p, num_inst,  this
         );
 
@@ -91,6 +98,6 @@
     {
         printf(
-          "Hey I'm in derived class destructor number %d for %p.\n",
-          num_inst,
+          "%s: Hey I'm in derived class destructor number %d for %p.\n",
+          ptr, num_inst,
           this
         );
@@ -103,6 +110,32 @@
 
 
-A foo;
-B foobar;
+class RtemsException 
+{
+public:
+    
+    RtemsException( char *module, int ln, int err = 0 )
+    : error( err ), line( ln ), file( module )
+    {
+      printf( "RtemsException raised=File:%s, Line:%d, Error=%X\n",
+               file, line, error ); 
+    }
+
+    void show()
+    {
+      printf( "RtemsException ---> File:%s, Line:%d, Error=%X\n",
+               file, line, error ); 
+    }
+
+private:
+   int  error;
+   int  line;
+   char *file;
+
+};
+
+
+
+A foo( "GLOBAL" );
+B foobar( "GLOBAL" );
 
 void
@@ -117,6 +150,6 @@
     printf("IO Stream not tested\n");
 #endif
-
     bar = blech;
+    rtems_task_wake_after( 5 * get_ticks_per_second() );
 }
 
@@ -128,4 +161,16 @@
 //
 
+static void foo_function()
+{
+    try 
+    {
+      throw "foo_function() throw this exception";  
+    }
+    catch( const char *e )
+    {
+     printf( "foo_function() catch block called:\n   < %s  >\n", e );
+     throw "foo_function() re-throwing execption...";  
+    }
+}
 
 rtems_task main_task(
@@ -139,4 +184,32 @@
     printf( "*** END OF CONSTRUCTOR/DESTRUCTOR TEST ***\n\n\n" );
 
+
+    printf( "*** TESTING C++ EXCEPTIONS ***\n\n" );
+
+    try 
+    {
+      foo_function();
+    }
+    catch( const char *e )
+    {
+       printf( "Success catching a char * exception\n%s\n", e );
+    }
+    try 
+    {
+      printf( "throw an instance based exception\n" );
+		throw RtemsException( __FILE__, __LINE__, 0x55 ); 
+    }
+    catch( RtemsException & ex ) 
+    {
+       printf( "Success catching RtemsException...\n" );
+       ex.show();
+    }
+    catch(...) 
+    {
+      printf( "Caught another exception.\n" );
+    }
+    printf( "Exceptions are working properly.\n" );
+    rtems_task_wake_after( 5 * get_ticks_per_second() );
+    printf( "Global Dtors should be called after this line....\n" );
     exit(0);
 }
