tracefw/tracecompiler/test/TracesInHeadersApps/singlemmp_diffnames_tracesplus/console/src/HelloTraceConsole.cpp
changeset 56 aa2539c91954
parent 54 a151135b0cf9
child 60 e54443a6878c
child 62 1c2bb2fc7c87
equal deleted inserted replaced
54:a151135b0cf9 56:aa2539c91954
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32cons.h>			// Console
       
    20 
       
    21 #include "HelloTraceConsole.h"
       
    22 #include "HelloTraceExample.h"
       
    23 
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "HelloTraceConsoleTraces.h"
       
    27 #endif
       
    28 
       
    29 
       
    30 _LIT(KTextConsoleTitle, "HelloTrace");
       
    31 _LIT(KTextPressAnyKey, " [press any key]\n");
       
    32 
       
    33 LOCAL_D CConsoleBase* console; // write all messages to this
       
    34 
       
    35 LOCAL_C void DoExamples()
       
    36     {
       
    37     TInt err = KErrNone;
       
    38 
       
    39     console->Printf(_L("Before main tracing examples ...\n"));
       
    40 
       
    41     console->Printf(_L(" Before type examples ..."));
       
    42     console->Printf(KTextPressAnyKey);
       
    43     console->Getch();
       
    44     TRAP(err, HelloTraceExample::JustTypes());    
       
    45     if (err)
       
    46         console->Printf(_L(" Failed with error %d\n"), err);
       
    47 
       
    48     console->Printf(_L(" Before Interface examples ..."));
       
    49     console->Printf(KTextPressAnyKey);
       
    50     console->Getch();
       
    51     TRAP(err, HelloTraceExample::Interface());    
       
    52     if (err)
       
    53         console->Printf(_L(" Failed with error %d\n"), err);
       
    54     
       
    55     console->Printf(_L(" Before FnEntryExit examples ..."));
       
    56     console->Printf(KTextPressAnyKey);
       
    57     console->Getch();
       
    58     TRAP(err, HelloTraceExample::FnEntryExit());    
       
    59     if (err)
       
    60         console->Printf(_L(" Failed with error %d\n"), err);    
       
    61     }
       
    62 
       
    63 LOCAL_C void DoStartL()
       
    64     {
       
    65     // Create active scheduler (to run active objects)
       
    66     CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
       
    67     CleanupStack::PushL(scheduler);
       
    68     CActiveScheduler::Install(scheduler);
       
    69 
       
    70     DoExamples();
       
    71     
       
    72     // Delete active scheduler
       
    73     CleanupStack::PopAndDestroy(scheduler);
       
    74     }
       
    75 
       
    76 //  Global Functions
       
    77 
       
    78 GLDEF_C TInt E32Main()
       
    79     {
       
    80     OstTraceFunctionEntry0( E32MAIN_ENTRY );
       
    81     
       
    82     // Create cleanup stack
       
    83     __UHEAP_MARK;
       
    84     CTrapCleanup* cleanup = CTrapCleanup::New();
       
    85 
       
    86     // Create output console
       
    87     TRAPD(createError, 
       
    88           console = Console::NewL(KTextConsoleTitle, 
       
    89                                   TSize(KConsFullScreen, KConsFullScreen)));    
       
    90     if (createError)
       
    91         {
       
    92         delete cleanup;
       
    93         OstTrace1( TRACE_ERROR, E32MAIN_CREATE_ERROR, "Failed to create console error: %d", createError);
       
    94         OstTraceFunctionExit0( E32MAIN_EXIT_ERR );
       
    95         return createError;
       
    96         }
       
    97 
       
    98     TRAPD(mainError, DoStartL());    
       
    99     if (mainError)
       
   100         {
       
   101         OstTrace1( TRACE_ERROR, E32MAIN_START_ERROR, "DoStartL failed with error: %d", mainError);
       
   102         console->Printf(_L("DoStartL failed with error: %d\n\n"), mainError);
       
   103         }
       
   104     else 
       
   105         {
       
   106         console->Printf(_L("Before panic tracing example ..."));
       
   107         console->Printf(KTextPressAnyKey);
       
   108         console->Getch();
       
   109     
       
   110         OstTrace0( TRACE_FLOW, E32MAIN_BEFORE_PANIC, "About to cause a panic ..." );
       
   111         HelloTraceExample::PanicTrace();
       
   112         
       
   113         console->Printf(KTextPressAnyKey);
       
   114         console->Getch();
       
   115         }
       
   116 
       
   117     delete console;
       
   118     delete cleanup;
       
   119     __UHEAP_MARKEND;
       
   120     
       
   121     OstTraceFunctionExit0( E32MAIN_EXIT );
       
   122     return KErrNone;
       
   123     }
       
   124