From 25f84e043bebd9bcc56464cd86fd8d2eaa351435 Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Thu, 16 Jan 2003 19:25:47 +0000 Subject: [PATCH] Enabling GRE support in the mozilla client. r=chak, sr=darin, b=173262 git-svn-id: svn://10.0.0.236/trunk@136423 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpfe/bootstrap/Makefile.in | 59 ++++++++++++------- mozilla/xpfe/bootstrap/nsAppRunner.cpp | 50 +++++++++------- .../xpfe/bootstrap/nsNativeAppSupportOS2.cpp | 15 +++-- .../xpfe/bootstrap/nsNativeAppSupportWin.cpp | 16 +++-- mozilla/xpfe/bootstrap/nsSigHandlers.cpp | 3 +- 5 files changed, 91 insertions(+), 52 deletions(-) diff --git a/mozilla/xpfe/bootstrap/Makefile.in b/mozilla/xpfe/bootstrap/Makefile.in index 15ca609b6fa..6f71e4ef91d 100644 --- a/mozilla/xpfe/bootstrap/Makefile.in +++ b/mozilla/xpfe/bootstrap/Makefile.in @@ -36,6 +36,8 @@ MOZ_WINCONSOLE=0 endif endif +DEFINES += -DXPCOM_GLUE + MODULE = apprunner REQUIRES = xpcom \ xpconnect \ @@ -91,26 +93,25 @@ CPPSRCS = \ showOSAlert.cpp \ $(NULL) -ifneq ($(OS_ARCH),WINNT) -CPPSRCS += nsSigHandlers.cpp -endif -XP_LIBS = \ - $(EXTRA_DSO_LDOPTS) \ - $(EXTRA_DSO_LIBS) \ +ifneq ($(OS_ARCH),WINNT) +STACKWALK_SRC_LCSRCS = \ + nsStackFrameUnix.cpp \ + nsStackFrameUnix.h \ $(NULL) -ifndef BUILD_STATIC_LIBS +STACKWALK_CPPSRCS := $(addprefix $(topsrcdir)/xpcom/base/, $(STACKWALK_SRC_LCSRCS)) -EXTRA_DSO_LIBS += gkgfx -ifdef MOZ_OJI -ifeq ($(OS_ARCH),WINNT) -EXTRA_DSO_LIBS += jsj$(MOZ_BITS)$(VERSION_NUMBER) -else -EXTRA_DSO_LIBS += jsj -endif +CPPSRCS += nsSigHandlers.cpp nsStackFrameUnix.cpp endif +LIBS = $(EXTRA_DSO_LDOPTS) \ + $(EXTRA_DSO_LIBS) \ + $(NULL) + + +ifndef BUILD_STATIC_LIBS + ifdef NS_TRACE_MALLOC EXTRA_DSO_LIBS += tracemalloc endif @@ -128,26 +129,32 @@ EXTRA_DSO_LDOPTS+= -L$(DEPTH)/dist/lib/components endif # !WINNT EXTRA_DSO_LIBS += $(STATIC_EXTRA_DSO_LIBS) REQUIRES += $(STATIC_REQUIRES) -XP_LIBS += $(STATIC_EXTRA_LIBS) +LIBS += $(STATIC_EXTRA_LIBS) endif -XP_LIBS += \ +# If you change anything that mozilla links to, please talk to dougt@netscape.com +LIBS += \ $(MOZ_JS_LIBS) \ - $(XPCOM_LIBS) \ + $(DIST)/lib/$(LIB_PREFIX)string_s.$(LIB_SUFFIX) \ + $(DIST)/lib/$(LIB_PREFIX)string_obsolete_s.$(LIB_SUFFIX) \ + $(DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX) \ + $(DIST)/lib/$(LIB_PREFIX)embedstring.$(LIB_SUFFIX) \ $(NSPR_LIBS) \ $(NULL) ifdef MOZ_JPROF -XP_LIBS += -ljprof +LIBS += -ljprof endif -LIBS = $(XP_LIBS) - ifdef GC_LEAK_DETECTOR LIBS += -lboehm endif +ifdef MOZ_DEMANGLE_SYMBOLS +LIBS += -liberty +endif + ifeq ($(MOZ_WIDGET_TOOLKIT),beos) BEOS_PROGRAM_RESOURCE = $(srcdir)/apprunner-beos.rsrc CPPSRCS += nsNativeAppSupportBeOS.cpp @@ -251,8 +258,19 @@ endif endif endif +SRCS_IN_OBJDIR=1 + +ifneq ($(OS_ARCH),WINNT) +GARBAGE += $(STACKWALK_SRC_LCSRCS) $(wildcard *.$(OBJ_SUFFIX)) +endif + include $(topsrcdir)/config/rules.mk +ifneq ($(OS_ARCH),WINNT) +export:: $(STACKWALK_CPPSRCS) + $(INSTALL) $^ . +endif + ifdef BUILD_STATIC_LIBS include $(topsrcdir)/config/static-rules.mk endif @@ -382,3 +400,4 @@ README_FILE = $(topsrcdir)/README.txt libs:: $(INSTALL) $(README_FILE) $(DIST)/bin $(INSTALL) $(topsrcdir)/LICENSE $(DIST)/bin + diff --git a/mozilla/xpfe/bootstrap/nsAppRunner.cpp b/mozilla/xpfe/bootstrap/nsAppRunner.cpp index 051abac217a..3bfeb5696bc 100644 --- a/mozilla/xpfe/bootstrap/nsAppRunner.cpp +++ b/mozilla/xpfe/bootstrap/nsAppRunner.cpp @@ -36,10 +36,12 @@ * * ***** END LICENSE BLOCK ***** */ +#include "nsXPCOMGlue.h" #include "nsIServiceManager.h" #include "nsIComponentManager.h" #include "nsIGenericFactory.h" +#include "nsIComponentRegistrar.h" #include "nsIURI.h" #include "nsNetUtil.h" @@ -407,7 +409,6 @@ static nsresult GetNativeAppSupport(nsINativeAppSupport** aNativeApp) return *aNativeApp ? NS_OK : NS_ERROR_FAILURE; } - /* * This routine translates the nsresult into a platform specific return * code for the application... @@ -930,6 +931,14 @@ static nsresult ConvertToUnicode(nsString& aCharset, const char* inString, nsASt return rv; } +static PRBool IsAscii(const char *aString) { + while(*aString) { + if( 0x80 & *aString) + return PR_FALSE; + aString++; + } + return PR_TRUE; +} static nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width) { @@ -955,7 +964,7 @@ static nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width) #endif /* DEBUG_CMD_LINE */ nsAutoString url; - if (nsCRT::IsAscii(urlToLoad)) { + if (IsAscii(urlToLoad)) { url.AssignWithConversion(urlToLoad); } else { @@ -1358,11 +1367,12 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) // _Always_ autoreg if we're in a debug build, under the assumption // that people are busily modifying components and will be angry if // their changes aren't noticed. - nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, - nsnull /* default */); + nsCOMPtr registrar; + NS_GetComponentRegistrar(getter_AddRefs(registrar)); + registrar->AutoRegister(nsnull); + registrar = nsnull; #endif - NS_TIMELINE_ENTER("startupNotifier"); // Start up the core services: @@ -1841,12 +1851,22 @@ int main(int argc, char* argv[]) #ifdef MOZ_JPROF setupProfilingStuff(); #endif + + NS_TIMELINE_MARK("GRE_Startup..."); + nsresult rv = GRE_Startup(); + NS_TIMELINE_MARK("...GRE_Startup done"); + + if (NS_FAILED(rv)) { + // We should be displaying a dialog here with the reason why we failed. + NS_WARNING("GRE_Startup failed"); + return 1; + } // Try to allocate "native app support." // Note: this object is not released here. It is passed to main1 which // has responsibility to release it. nsINativeAppSupport *nativeApp = 0; - nsresult rv = NS_CreateNativeAppSupport(&nativeApp); + rv = NS_CreateNativeAppSupport(&nativeApp); // See if we can run. if (nativeApp) @@ -1880,13 +1900,6 @@ int main(int argc, char* argv[]) splash->Show(); } - NS_TIMELINE_MARK("InitXPCom..."); - - rv = NS_InitXPCOM2(nsnull, nsnull, nsnull); - NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed"); - - NS_TIMELINE_MARK("...InitXPCOM done"); - #ifdef MOZ_ENABLE_XREMOTE // handle -remote now that xpcom is fired up int remoterv; @@ -1894,10 +1907,9 @@ int main(int argc, char* argv[]) // argused will be true if someone tried to use a -remote flag. We // always exit in that case. remoterv = HandleRemoteArguments(argc, argv, &argused); + if (argused) { - if (NS_SUCCEEDED(rv)) // only call NS_ShutdownXPCOM if Init succeeded. - NS_ShutdownXPCOM(nsnull); - return remoterv; + GRE_Shutdown(); } #endif @@ -1909,10 +1921,8 @@ int main(int argc, char* argv[]) NS_ASSERTION(NS_SUCCEEDED(rv), "DoOnShutdown failed"); } - if (NS_SUCCEEDED(rv)) { // only call NS_ShutdownXPCOM if Init succeeded. - rv = NS_ShutdownXPCOM(nsnull); - NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); - } + rv = GRE_Shutdown(); + NS_ASSERTION(NS_SUCCEEDED(rv), "GRE_Shutdown failed"); return TranslateReturnValue(mainResult); } diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp index b4c8b822db7..e2ec877c3be 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp @@ -56,6 +56,7 @@ #include "nsIPromptService.h" #include "nsNetCID.h" #include "nsIObserverService.h" +#include "nsXPCOM.h" #include "nsPaletteOS2.h" // These are needed to load a URL in a browser window. @@ -2053,10 +2054,14 @@ nsNativeAppSupportOS2::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu // OK, now create nsICmdLineService object from argc/argv. static NS_DEFINE_CID( kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID ); - rv = nsComponentManager::CreateInstance( kCmdLineServiceCID, - 0, - NS_GET_IID( nsICmdLineService ), - (void**)aResult ); + + nsCOMPtr compMgr; + NS_GetComponentManager(getter_AddRefs(compMgr)); + rv = compMgr->CreateInstance( kCmdLineServiceCID, + 0, + NS_GET_IID( nsICmdLineService ), + (void**)aResult ); + if ( NS_FAILED( rv ) || NS_FAILED( ( rv = (*aResult)->Initialize( argc, argv ) ) ) ) { #if MOZ_DEBUG_DDE printf( "Error creating command line service = 0x%08X (argc=%d, argv=0x%08X)\n", (int)rv, (int)argc, (void*)argv ); @@ -2302,7 +2307,7 @@ nsNativeAppSupportOS2::StartServerMode() { // Create the array for the arguments. nsCOMPtr argArray; - NS_NewISupportsArray( getter_AddRefs( argArray ) ); + nsCOMPtr argArray = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); if ( !argArray ) { return NS_OK; } diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp index bd75435c5a3..021a497fd0a 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -68,6 +68,7 @@ #include "nsIPromptService.h" #include "nsNetCID.h" #include "nsIObserverService.h" +#include "nsXPCOM.h" // These are needed to load a URL in a browser window. #include "nsIDOMLocation.h" @@ -2009,10 +2010,14 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu // OK, now create nsICmdLineService object from argc/argv. static NS_DEFINE_CID( kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID ); - rv = nsComponentManager::CreateInstance( kCmdLineServiceCID, - 0, - NS_GET_IID( nsICmdLineService ), - (void**)aResult ); + + nsCOMPtr compMgr; + NS_GetComponentManager(getter_AddRefs(compMgr)); + rv = compMgr->CreateInstance( kCmdLineServiceCID, + 0, + NS_GET_IID( nsICmdLineService ), + (void**)aResult ); + if ( NS_FAILED( rv ) || NS_FAILED( ( rv = (*aResult)->Initialize( argc, argv ) ) ) ) { #if MOZ_DEBUG_DDE printf( "Error creating command line service = 0x%08X (argc=%d, argv=0x%08X)\n", (int)rv, (int)argc, (void*)argv ); @@ -2491,8 +2496,7 @@ nsNativeAppSupportWin::StartServerMode() { } // Create the array for the arguments. - nsCOMPtr argArray; - NS_NewISupportsArray( getter_AddRefs( argArray ) ); + nsCOMPtr argArray = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID); if ( !argArray ) { return NS_OK; } diff --git a/mozilla/xpfe/bootstrap/nsSigHandlers.cpp b/mozilla/xpfe/bootstrap/nsSigHandlers.cpp index 800cbdabe21..19d6b8ec222 100644 --- a/mozilla/xpfe/bootstrap/nsSigHandlers.cpp +++ b/mozilla/xpfe/bootstrap/nsSigHandlers.cpp @@ -114,6 +114,7 @@ void abnormal_exit_handler(int signum) #include #include "nsISupportsUtils.h" +#include "nsStackFrameUnix.h" void ah_crap_handler(int signum) @@ -134,7 +135,7 @@ ah_crap_handler(int signum) #endif printf("Stack:\n"); - nsTraceRefcnt::WalkTheStack(stdout); + DumpStackToFile(stdout); printf("Sleeping for 5 minutes.\n"); printf("Type 'gdb %s %d' to attatch your debugger to this thread.\n",