Changeset 102184 in vbox
- Timestamp:
- Nov 21, 2023 10:08:22 AM (12 months ago)
- Location:
- trunk/src/libs/xpcom18a4/xpcom/reflect/xptinfo/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp
r102174 r102184 137 137 AssertRC(vrc); RT_NOREF(vrc); 138 138 139 const char* statsFilename = RTEnvGet("MOZILLA_XPTI_STATS"); 140 if(statsFilename) 141 { 142 mStatsLogFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); 143 if(mStatsLogFile && 144 NS_SUCCEEDED(mStatsLogFile->InitWithNativePath(nsDependentCString(statsFilename)))) 145 { 146 printf("* Logging xptinfo stats to: %s\n", statsFilename); 147 } 148 else 149 { 150 printf("* Failed to create xptinfo stats file: %s\n", statsFilename); 151 mStatsLogFile = nsnull; 152 } 153 } 154 155 const char* autoRegFilename = RTEnvGet("MOZILLA_XPTI_REGLOG"); 156 if(autoRegFilename) 157 { 158 mAutoRegLogFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); 159 if(mAutoRegLogFile && 160 NS_SUCCEEDED(mAutoRegLogFile->InitWithNativePath(nsDependentCString(autoRegFilename)))) 161 { 162 printf("* Logging xptinfo autoreg to: %s\n", autoRegFilename); 163 } 164 else 165 { 166 printf("* Failed to create xptinfo autoreg file: %s\n", autoRegFilename); 167 mAutoRegLogFile = nsnull; 168 } 169 } 139 mStatsLogFile = RTEnvGet("MOZILLA_XPTI_STATS"); 140 if (mStatsLogFile) 141 printf("* Logging xptinfo stats to: %s\n", mStatsLogFile); 142 143 mAutoRegLogFile = RTEnvGet("MOZILLA_XPTI_REGLOG"); 144 if (mAutoRegLogFile) 145 printf("* Logging xptinfo autoreg to: %s\n", mAutoRegLogFile); 170 146 } 171 147 … … 1624 1600 return; 1625 1601 1626 PR FileDesc*fd = gInterfaceInfoManager->GetOpenLogFile();1602 PRTSTREAM fd = gInterfaceInfoManager->GetOpenLogFile(); 1627 1603 if(fd) 1628 1604 { 1629 1605 va_list ap; 1630 1606 va_start(ap, fmt); 1631 PR_vfprintf(fd, fmt, ap);1607 RTStrmPrintfV(fd, fmt, ap); 1632 1608 va_end(ap); 1633 1609 } … … 1644 1620 { 1645 1621 xptiWorkingSet* aWorkingSet = mgr->GetWorkingSet(); 1646 PR FileDesc*fd = mgr->GetOpenLogFile();1622 PRTSTREAM fd = mgr->GetOpenLogFile(); 1647 1623 1648 1624 const xptiTypelib& typelib = entry->GetTypelibRecord(); … … 1654 1630 const char* zipItemName = 1655 1631 aWorkingSet->GetZipItemAt(typelib.GetZipItemIndex()).GetName(); 1656 PR_fprintf(fd, "xpti used interface: %s from %s::%s\n",1657 entry->GetTheName(), filename, zipItemName);1632 RTStrmPrintf(fd, "xpti used interface: %s from %s::%s\n", 1633 entry->GetTheName(), filename, zipItemName); 1658 1634 } 1659 1635 else 1660 1636 { 1661 PR_fprintf(fd, "xpti used interface: %s from %s\n",1662 entry->GetTheName(), filename);1637 RTStrmPrintf(fd, "xpti used interface: %s from %s\n", 1638 entry->GetTheName(), filename); 1663 1639 } 1664 1640 } … … 1674 1650 xptiAutoLog autoLog(this, mStatsLogFile, PR_FALSE); 1675 1651 1676 PR FileDesc*fd = GetOpenLogFile();1652 PRTSTREAM fd = GetOpenLogFile(); 1677 1653 if(!fd) 1678 1654 return; … … 1686 1662 xptiFile& f = mWorkingSet.GetFileAt(i); 1687 1663 if(f.GetGuts()) 1688 PR_fprintf(fd, "xpti used file: %s\n", f.GetName());1689 } 1690 1691 PR_fprintf(fd, "\n");1664 RTStrmPrintf(fd, "xpti used file: %s\n", f.GetName()); 1665 } 1666 1667 RTStrmPrintf(fd, "\n"); 1692 1668 1693 1669 // Show names of xptfiles loaded from zips from which at least … … 1699 1675 xptiZipItem& zi = mWorkingSet.GetZipItemAt(i); 1700 1676 if(zi.GetGuts()) 1701 PR_fprintf(fd, "xpti used file from zip: %s\n", zi.GetName());1702 } 1703 1704 PR_fprintf(fd, "\n");1677 RTStrmPrintf(fd, "xpti used file from zip: %s\n", zi.GetName()); 1678 } 1679 1680 RTStrmPrintf(fd, "\n"); 1705 1681 1706 1682 // Show name of each interface that was fully resolved and the name -
trunk/src/libs/xpcom18a4/xpcom/reflect/xptinfo/src/xptiMisc.cpp
r102177 r102184 40 40 /* Implementation of misc. xpti stuff. */ 41 41 42 #include <iprt/file.h> 42 43 #include <iprt/time.h> 43 44 … … 77 78 78 79 xptiAutoLog::xptiAutoLog(xptiInterfaceInfoManager* mgr, 79 nsILocalFile*logfile, PRBool append)80 const char *logfile, PRBool append) 80 81 : mMgr(nsnull), mOldFileDesc(nsnull) 81 82 { … … 84 85 if(mgr && logfile) 85 86 { 86 PRFileDesc* fd; 87 if(NS_SUCCEEDED(logfile-> 88 OpenNSPRFileDesc(PR_WRONLY | PR_CREATE_FILE | PR_APPEND | 89 (append ? 0 : PR_TRUNCATE), 90 0600, &fd)) && fd) 87 RTFILE hFile = NIL_RTFILE; 88 PRTSTREAM pStream = NULL; 89 int vrc = RTFileOpen(&hFile, logfile, 90 RTFILE_O_OPEN_CREATE | RTFILE_O_WRITE | RTFILE_O_APPEND | RTFILE_O_DENY_NONE 91 | (append ? 0 : RTFILE_O_TRUNCATE) 92 | (0600 << RTFILE_O_CREATE_MODE_SHIFT)); 93 if (RT_SUCCESS(vrc)) 94 vrc = RTStrmOpenFileHandle(hFile, "at", 0 /*fFlags*/, &pStream); 95 96 if (RT_SUCCESS(vrc)) 91 97 { 92 98 #ifdef DEBUG 93 m_DEBUG_FileDesc = fd;99 m_DEBUG_FileDesc = pStream; 94 100 #endif 95 101 mMgr = mgr; 96 mOldFileDesc = mMgr->SetOpenLogFile( fd);97 if (append)98 PR_Seek(fd, 0, PR_SEEK_END);99 WriteTimestamp( fd, "++++ start logging ");102 mOldFileDesc = mMgr->SetOpenLogFile(pStream); 103 if (append) 104 RTStrmSeek(pStream, 0, RTFILE_SEEK_END); 105 WriteTimestamp(pStream, "++++ start logging "); 100 106 101 107 } … … 103 109 { 104 110 #ifdef DEBUG 105 printf("xpti failed to open log file for writing\n");111 printf("xpti failed to open log file for writing\n"); 106 112 #endif 113 if (hFile != NIL_RTFILE) 114 RTFileClose(hFile); 115 hFile = NIL_RTFILE; 107 116 } 108 117 } … … 115 124 if(mMgr) 116 125 { 117 PR FileDesc*fd = mMgr->SetOpenLogFile(mOldFileDesc);126 PRTSTREAM fd = mMgr->SetOpenLogFile(mOldFileDesc); 118 127 NS_ASSERTION(fd == m_DEBUG_FileDesc, "bad unravel"); 119 128 if(fd) 120 129 { 121 130 WriteTimestamp(fd, "---- end logging "); 122 PR_Close(fd);131 RTStrmClose(fd); 123 132 } 124 133 } 125 134 } 126 135 127 void xptiAutoLog::WriteTimestamp(PR FileDesc* fd, const char* msg)136 void xptiAutoLog::WriteTimestamp(PRTSTREAM pStream, const char* msg) 128 137 { 129 138 RTTIMESPEC TimeSpec; … … 135 144 char time[128]; 136 145 RTTimeToString(&Time, time, sizeof(time)); 137 PR_fprintf(fd, "\n%s %s\n\n", msg, time);146 RTStrmPrintf(pStream, "\n%s %s\n\n", msg, time); 138 147 } 139 148 -
trunk/src/libs/xpcom18a4/xpcom/reflect/xptinfo/src/xptiprivate.h
r101963 r102184 43 43 #define xptiprivate_h___ 44 44 45 #include <iprt/stream.h> 46 45 47 #include "nscore.h" 46 48 #include "nsISupports.h" … … 843 845 xptiAutoLog(); // not implemented 844 846 xptiAutoLog(xptiInterfaceInfoManager* mgr, 845 nsILocalFile*logfile, PRBool append);847 const char *logfile, PRBool append); 846 848 ~xptiAutoLog(); 847 849 private: 848 void WriteTimestamp(PR FileDesc* fd, const char* msg);850 void WriteTimestamp(PRTSTREAM pStream, const char* msg); 849 851 850 852 xptiInterfaceInfoManager* mMgr; 851 PR FileDesc*mOldFileDesc;853 PRTSTREAM mOldFileDesc; 852 854 #ifdef DEBUG 853 PR FileDesc*m_DEBUG_FileDesc;855 PRTSTREAM m_DEBUG_FileDesc; 854 856 #endif 855 857 }; … … 876 878 877 879 xptiWorkingSet* GetWorkingSet() {return &mWorkingSet;} 878 PR FileDesc*GetOpenLogFile() {return mOpenLogFile;}879 PR FileDesc* SetOpenLogFile(PRFileDesc* fd)880 {PR FileDesc* temp = mOpenLogFile; mOpenLogFile = fd; return temp;}880 PRTSTREAM GetOpenLogFile() {return mOpenLogFile;} 881 PRTSTREAM SetOpenLogFile(PRTSTREAM pStream) 882 {PRTSTREAM temp = mOpenLogFile; mOpenLogFile = pStream; return temp;} 881 883 882 884 PRBool LoadFile(const xptiTypelib& aTypelibRecord, … … 958 960 private: 959 961 xptiWorkingSet mWorkingSet; 960 nsCOMPtr<nsILocalFile>mStatsLogFile;961 nsCOMPtr<nsILocalFile>mAutoRegLogFile;962 PR FileDesc*mOpenLogFile;962 const char *mStatsLogFile; 963 const char *mAutoRegLogFile; 964 PRTSTREAM mOpenLogFile; 963 965 RTSEMFASTMUTEX mResolveLock; 964 966 RTSEMFASTMUTEX mAutoRegLock;
Note:
See TracChangeset
for help on using the changeset viewer.