Changeset 101942 in vbox for trunk/src/libs/xpcom18a4/xpcom
- Timestamp:
- Nov 7, 2023 1:50:07 PM (15 months ago)
- Location:
- trunk/src/libs/xpcom18a4/xpcom/components
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/xpcom/components/xcDll.cpp
r101803 r101942 57 57 #include "nsModule.h" 58 58 #ifdef DEBUG 59 #if defined(VMS) 60 #include <lib$routines.h> 61 #include <ssdef.h> 62 #elif defined(XP_MACOSX) 59 #if defined(XP_MACOSX) 63 60 #include <signal.h> 64 61 #endif … … 66 63 67 64 #include "nsTraceRefcntImpl.h" 68 69 #define UNLOAD_DEPENDENT_LIBS70 #ifdef HPUX71 #undef UNLOAD_DEPENDENT_LIBS72 #endif73 65 74 66 #include "nsNativeComponentLoader.h" … … 149 141 // on the dependent libraries with the assumption that the 150 142 // component library holds a reference via the OS so loader. 151 152 #if defined(XP_UNIX)153 143 nsCOMPtr<nsIComponentLoaderManager> manager = do_QueryInterface(m_loader->mCompMgr); 154 144 if (!manager) … … 158 148 manager->GetOptionalData(m_dllSpec, nsnull, getter_Copies(extraData)); 159 149 160 #ifdef UNLOAD_DEPENDENT_LIBS161 150 nsVoidArray dependentLibArray; 162 #endif163 151 164 152 // if there was any extra data, treat it as a listing of dependent libs … … 180 168 file->AppendNative(NS_LITERAL_CSTRING("dummy")); 181 169 182 # ifdef VBOX_USE_IPRT_IN_XPCOM183 170 char *buffer = (char *)nsMemory::Clone(extraData, strlen(extraData) + 1); 184 # else185 char *buffer = strdup(extraData);186 # endif187 171 if (!buffer) 188 172 return NS_ERROR_OUT_OF_MEMORY; … … 227 211 // can. Now just let us fail later if this really was a required 228 212 // dependency. 229 #ifdef UNLOAD_DEPENDENT_LIBS230 213 if (lib) 231 214 dependentLibArray.AppendElement((void*)lib); 232 #endif233 215 234 216 token = nsCRT::strtok(newStr, " ", &newStr); 235 217 } 236 # ifdef VBOX_USE_IPRT_IN_XPCOM237 218 nsMemory::Free(buffer); 238 # else 239 free(buffer); 240 # endif 241 } 242 #endif 219 } 243 220 244 221 // load the component … … 247 224 lf->Load(&m_instance); 248 225 249 #if defined(XP_UNIX)250 226 // Unload any of library dependencies we loaded earlier. The assumption 251 227 // here is that the component will have a "internal" reference count to 252 228 // the dependency library we just loaded. 253 229 // XXX should we unload later - or even at all? 254 255 #ifdef UNLOAD_DEPENDENT_LIBS256 230 if (extraData != nsnull) 257 231 { … … 260 234 PR_UnloadLibrary((PRLibrary*)dependentLibArray.ElementAt(index)); 261 235 } 262 #endif263 #endif264 236 265 237 #ifdef NS_BUILD_REFCNT_LOGGING … … 275 247 } 276 248 277 #ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD278 // Debugging help for components. Component dlls need to have their279 // symbols loaded before we can put a breakpoint in the debugger.280 // This will help figureing out the point when the dll was loaded.281 nsXPIDLCString displayPath;282 GetDisplayPath(displayPath);283 BreakAfterLoad(displayPath.get());284 #endif285 286 249 return ((m_instance == NULL) ? PR_FALSE : PR_TRUE); 287 250 } … … 376 339 } 377 340 378 379 // These are used by BreakAfterLoad, below.380 #ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD381 static nsCString *sBreakList[16];382 static int sBreakListCount = 0;383 #endif384 385 341 nsresult nsDll::Shutdown(void) 386 342 { … … 392 348 NS_ASSERTION(refcnt == 0, "Dll moduleObject refcount non zero"); 393 349 } 394 #ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD 395 for (int i = 0; i < sBreakListCount; i++) 396 { 397 delete sBreakList[i]; 398 sBreakList[i] = nsnull; 399 } 400 sBreakListCount = 0; 401 #endif 350 402 351 return NS_OK; 403 352 404 353 } 405 #ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD 406 void nsDll::BreakAfterLoad(const char *nsprPath) 407 { 408 static PRBool firstTime = PR_TRUE; 409 410 // return if invalid input 411 if (!nsprPath || !*nsprPath) return; 412 413 // return if nothing to break on 414 if (!firstTime && sBreakListCount == 0) return; 415 416 if (firstTime) 417 { 418 firstTime = PR_FALSE; 419 // Form the list of dlls to break on load 420 nsCAutoString envList(getenv("XPCOM_BREAK_ON_LOAD")); 421 if (envList.IsEmpty()) return; 422 PRInt32 ofset = 0; 423 PRInt32 start = 0; 424 do 425 { 426 ofset = envList.FindChar(':', start); 427 sBreakList[sBreakListCount] = new nsCString(); 428 envList.Mid(*(sBreakList[sBreakListCount]), start, ofset); 429 sBreakListCount++; 430 start = ofset + 1; 431 } 432 while (ofset != -1 && 16 > sBreakListCount); // avoiding vc6.0 compiler issue. count < thinks it is starting a template 433 } 434 435 // Find the dllname part of the string 436 nsCString currentPath(nsprPath); 437 PRInt32 lastSep = currentPath.RFindCharInSet(":\\/"); 438 439 for (int i=0; i<sBreakListCount; i++) 440 if (currentPath.Find(*(sBreakList[i]), PR_TRUE, lastSep) > 0) 441 { 442 // Loading a dll that we want to break on 443 // Put your breakpoint here 444 fprintf(stderr, "...Loading module %s\n", nsprPath); 445 // Break in the debugger here. 446 #if defined(__i386) && defined(__GNUC__) 447 asm("int $3"); 448 #elif defined(VMS) 449 lib$signal(SS$_DEBUG); 450 #elif defined(XP_MACOSX) 451 raise(SIGTRAP); 452 #endif 453 } 454 return; 455 } 456 #endif /* SHOULD_IMPLEMENT_BREAKAFTERLOAD */ 354 -
trunk/src/libs/xpcom18a4/xpcom/components/xcDll.h
r1 r101942 56 56 class nsNativeComponentLoader; 57 57 58 #if defined(DEBUG) && !defined(XP_BEOS)59 #define SHOULD_IMPLEMENT_BREAKAFTERLOAD60 #endif61 62 58 class nsIModule; 63 59 class nsIServiceManager; … … 82 78 83 79 void Init(nsIFile *dllSpec); 84 85 #ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD86 void BreakAfterLoad(const char *nsprPath);87 #endif88 80 89 81 public:
Note:
See TracChangeset
for help on using the changeset viewer.