# HG changeset patch # User Slion # Date 1272408254 -7200 # Node ID 428c5911a502f1b013a7f0ee8f39e6c0f6d16bcb # Parent f561f9ae805b168c49f7548b51253b91a4ea5413 Fixing issue with default C++ delete operator being called instead of Symbian C++ delete replacement with CBase derived classes from euser. Getting ride of SEH stuff used for WINS fixes our trap/leave runtime issues. diff -r f561f9ae805b -r 428c5911a502 kernel/eka/euser/CMakeLists.txt --- a/kernel/eka/euser/CMakeLists.txt Tue Apr 27 20:22:55 2010 +0200 +++ b/kernel/eka/euser/CMakeLists.txt Wed Apr 28 00:44:14 2010 +0200 @@ -78,7 +78,7 @@ set (sourcepath ../common/win32/) add_source( atomics.cpp -seh.cpp +#seh.cpp ) #Adding the sources from maths @@ -100,6 +100,7 @@ uc_utl.cpp uc_dll.cpp #uc_exec.cpp +scppnwdl.cpp ) #Adding the sources from epoc/symc @@ -232,8 +233,6 @@ ) - - #define our target ### EMULATOR: used by euser and kernel for emulation @@ -242,12 +241,9 @@ #set_target_properties(emulator PROPERTIES COMPILE_FLAGS "/Zl") #No default library #set_target_properties(emulator PROPERTIES LINK_FLAGS "/ENTRY:_Win32DllMain") #Change the entry point -### -add_library (scppnwdl STATIC ../euser/epoc/win32/scppnwdl.cpp) - ### EUSER: many user library add_library (euser SHARED ${source}) -add_dependencies(euser genexec emulator scppnwdl) +add_dependencies(euser genexec emulator) target_link_libraries(euser emulator) #set_target_properties(euser PROPERTIES COMPILE_DEFINITIONS "__DLL__") @@ -278,7 +274,7 @@ #set_target_properties(epoc PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup /SUBSYSTEM:WINDOWS") #set_target_properties(epoc PROPERTIES LINK_FLAGS "/NODEFAULTLIB") - #set_target_properties(target1 target2 ... PROPERTIES prop1 value1 prop2 value2 ...) +#set_target_properties(target1 target2 ... PROPERTIES prop1 value1 prop2 value2 ...) #No need for emulator here diff -r f561f9ae805b -r 428c5911a502 kernel/eka/euser/epoc/symc/uc_exec.cpp --- a/kernel/eka/euser/epoc/symc/uc_exec.cpp Tue Apr 27 20:22:55 2010 +0200 +++ b/kernel/eka/euser/epoc/symc/uc_exec.cpp Wed Apr 28 00:44:14 2010 +0200 @@ -32,7 +32,8 @@ enum TSymcExecPanic { ESymcExecPanicHeapAlreadyExists, - ESymcExecPanicCreateHeapFailed + ESymcExecPanicCreateHeapFailed, + ESymcExecPanicNotUsed }; void Panic(TInt aReason) @@ -368,8 +369,8 @@ CActiveScheduler* iActiveScheduler; //Current active scheduler for this thread. Used. TTrapHandler* iHandler; //This is our cleanup stack. Used. //No idea why we need that trap stack - TTrap* iTrapStack[KTrapStackSize]; - TInt iTrapCount; + //TTrap* iTrapStack[KTrapStackSize]; + //TInt iTrapCount; }; /* @@ -391,7 +392,7 @@ void TProcess::CreateHeap() { - iThread.iTrapCount=0; + //iThread.iTrapCount=0; //Define the size of our heap const TInt KHeapMaxSize=1024*1024*10; // 10 Mo for now __ASSERT_ALWAYS(iAllocator==NULL && iBase==NULL,Panic(ESymcExecPanicHeapAlreadyExists)); @@ -433,17 +434,21 @@ __EXECDECL__ TTrapHandler* Exec::PushTrapFrame(TTrap* aTrap) { + Panic(ESymcExecPanicNotUsed); + return NULL; //FAST_EXEC1(EFastExecPushTrapFrame); - ASSERT(gProcess.iThread.iTrapCount<=KTrapStackSize); - gProcess.iThread.iTrapStack[gProcess.iThread.iTrapCount++]=aTrap; - return gProcess.iThread.iHandler; + //ASSERT(gProcess.iThread.iTrapCount<=KTrapStackSize); + //gProcess.iThread.iTrapStack[gProcess.iThread.iTrapCount++]=aTrap; + //return gProcess.iThread.iHandler; } __EXECDECL__ TTrap* Exec::PopTrapFrame() { + Panic(ESymcExecPanicNotUsed); + return NULL; //FAST_EXEC0(EFastExecPopTrapFrame); - ASSERT(gProcess.iThread.iTrapCount>0); - return gProcess.iThread.iTrapStack[gProcess.iThread.iTrapCount--]; + //ASSERT(gProcess.iThread.iTrapCount>0); + //return gProcess.iThread.iTrapStack[gProcess.iThread.iTrapCount--]; } __EXECDECL__ CActiveScheduler* Exec::ActiveScheduler() diff -r f561f9ae805b -r 428c5911a502 kernel/eka/euser/epoc/win32/uc_epoc.cpp --- a/kernel/eka/euser/epoc/win32/uc_epoc.cpp Tue Apr 27 20:22:55 2010 +0200 +++ b/kernel/eka/euser/epoc/win32/uc_epoc.cpp Wed Apr 28 00:44:14 2010 +0200 @@ -28,11 +28,21 @@ //For now we use this for basic testing on our SYMC implementation -GLDEF_C void MainL() +class CBaseTest: public CBase { + }; + + +GLDEF_C void MainL() + { + + CBase* other=new(ELeave) CBase(); + CleanupStack::PushL(other); CBase* base=new(ELeave) CBase(); - delete base; + CleanupStack::PushL(base); + CleanupStack::PopAndDestroy(2,other); + //delete base; //Testing cleanup stack TRAPD(err, @@ -50,7 +60,10 @@ ); ASSERT(err==KErrNoMemory); - + + //Testing unbalanced cleanup stack + //base=new(ELeave) CBase(); + //CleanupStack::PushL(base); } @@ -64,6 +77,15 @@ CBase* base=new CBase(); delete base; + CBaseTest* baseTest=new CBaseTest(); + delete baseTest; + + HBufC* buf=HBufC::New(10); + delete buf; + + CArrayFix* active=new CArrayFixFlat(10); + delete active; + TUint8* test=new TUint8[1024*9]; delete[] test; @@ -73,7 +95,8 @@ return KErrNoMemory; } - TRAPD(err,MainL()); + TInt err=KErrNone; + TRAP(err,MainL()); delete cleanupStack; diff -r f561f9ae805b -r 428c5911a502 kernel/eka/euser/epoc/win32/uc_utl.cpp --- a/kernel/eka/euser/epoc/win32/uc_utl.cpp Tue Apr 27 20:22:55 2010 +0200 +++ b/kernel/eka/euser/epoc/win32/uc_utl.cpp Wed Apr 28 00:44:14 2010 +0200 @@ -36,6 +36,24 @@ IMPORT_C static void UnTrap(); }; + +#ifdef __SYMC__ + +EXPORT_C TInt TTrap::Trap(TInt&) + { + /* + TTrapHandler* h = Exec::PushTrapFrame(this); + if (h != NULL) + h->Trap(); +*/ + return 0; + } + +EXPORT_C void TTrap::UnTrap() + { + } + +#else EXPORT_C TInt TTrap::Trap(TInt&) { return 0; @@ -44,6 +62,7 @@ EXPORT_C void TTrap::UnTrap() { } +#endif #endif diff -r f561f9ae805b -r 428c5911a502 kernel/eka/euser/us_trp.cpp --- a/kernel/eka/euser/us_trp.cpp Tue Apr 27 20:22:55 2010 +0200 +++ b/kernel/eka/euser/us_trp.cpp Wed Apr 28 00:44:14 2010 +0200 @@ -91,6 +91,16 @@ return KErrNone; #endif //__SUPPORT_CPP_EXCEPTIONS__ } +#elif defined(__LEAVE_EQUALS_THROW__) && defined(__SYMC__) +EXPORT_C TInt XLeaveException::GetReason() const + { +#ifdef __SUPPORT_CPP_EXCEPTIONS__ + Exec::LeaveEnd(); + return iR; +#else // !__SUPPORT_CPP_EXCEPTIONS__ + return KErrNone; +#endif //__SUPPORT_CPP_EXCEPTIONS__ + } #endif // !defined(__LEAVE_EQUALS_THROW__) || !defined(__WINS__) EXPORT_C void User::LeaveNoMemory() diff -r f561f9ae805b -r 428c5911a502 kernel/eka/include/e32cmn.h --- a/kernel/eka/include/e32cmn.h Tue Apr 27 20:22:55 2010 +0200 +++ b/kernel/eka/include/e32cmn.h Wed Apr 28 00:44:14 2010 +0200 @@ -5884,7 +5884,7 @@ #else //__LEAVE_EQUALS_THROW__ -#ifdef __WINS__ +#if defined(__WINS__) && !defined(__SYMC__) /** @internalComponent */ #define __WIN32SEHTRAP TWin32SEHTrap __trap; __trap.Trap(); /** @internalComponent */