1 /*---------------------------------------------------------------------------* 2 Project: NitroSDK - OS - demos - callTrace-1 3 File: main.c 4 5 Copyright 2003-2008 Nintendo. All rights reserved. 6 7 $NoKeywords: $ 8 *---------------------------------------------------------------------------*/ 9 #include <nitro.h> 10 11 int test1(int a); 12 int test2(int a); 13 int test3(int a); 14 void test4(int a); 15 void test5(int a); 16 17 #define MYTRACEBUFFER_SIZE 0x300 18 u32 myTraceBuffer[MYTRACEBUFFER_SIZE / sizeof(u32)]; 19 __PROFILE_ENTRY(void)20SDK_WEAK_SYMBOL asm void __PROFILE_ENTRY( void ){ bx lr } __PROFILE_EXIT(void)21SDK_WEAK_SYMBOL asm void __PROFILE_EXIT( void ){ bx lr } 22 23 //================================================================ 24 25 //---------------------------------------------------------------- 26 // test1 27 // test1(int a)28int test1(int a) 29 { 30 return test2(a + 1); 31 } 32 33 //---------------------------------------------------------------- 34 // test2 35 // test2(int a)36int test2(int a) 37 { 38 return test3(a + 2); 39 } 40 41 //---------------------------------------------------------------- 42 // test3 43 // test3(int a)44int test3(int a) 45 { 46 OS_DumpCallTrace(); 47 return a + 4; 48 } 49 50 //---------------------------------------------------------------- 51 // test4 52 // test4(int a)53void test4(int a) 54 { 55 test5(a + 3); 56 return; 57 } 58 59 //---------------------------------------------------------------- 60 // test5 61 // test5(int a)62void test5(int a) 63 { 64 #pragma unused( a ) 65 return; 66 } 67 68 //================================================================================ 69 /*---------------------------------------------------------------------------* 70 Name: NitroMain 71 72 Description: main 73 74 Arguments: None 75 76 Returns: None 77 *---------------------------------------------------------------------------*/ 78 #pragma profile off NitroMain(void)79void NitroMain(void) 80 { 81 int n; 82 83 OS_Init(); 84 85 OS_Printf("---------------- stack mode demo of callTrace.\n"); 86 OS_InitCallTrace(&myTraceBuffer, MYTRACEBUFFER_SIZE, OS_CALLTRACE_STACK); 87 OS_Printf("buffer has %d lines to record callTrace.\n", 88 OS_CalcCallTraceLines(MYTRACEBUFFER_SIZE)); 89 90 OS_Printf("---- call test3.\n"); 91 n = test3(1); 92 OS_Printf("---- call test1.\n"); 93 n = test1(0x100); 94 95 OS_Printf("---------------- log mode demo of callTrace.\n"); 96 OS_InitCallTrace(&myTraceBuffer, MYTRACEBUFFER_SIZE, OS_CALLTRACE_LOG); 97 98 OS_Printf("---- call test4.\n"); 99 test4(1); 100 OS_Printf("---- call test4.\n"); 101 test4(0x100); 102 103 OS_DumpCallTrace(); 104 OS_Printf("==== Finish sample.\n"); 105 OS_Terminate(); 106 } 107 108 /*====== End of main.c ======*/ 109