]> git.sesse.net Git - casparcg/commitdiff
* Fixed CEF compilation error in debug mode.
authorHelge Norberg <helge.norberg@svt.se>
Tue, 19 May 2015 15:58:00 +0000 (17:58 +0200)
committerHelge Norberg <helge.norberg@svt.se>
Tue, 19 May 2015 15:58:00 +0000 (17:58 +0200)
* Reenabled text producer.
* Upgraded StackWalker and increased STACKWALK_MAX_NAMELEN from 1024 to 4096 (crashes on long function names otherwise).
* Added psd documents as STILL media type in CLS and CINF.

13 files changed:
common/CMakeLists.txt
common/compiler/vs/StackWalker.cpp [moved from common/compiler/vs/stack_walker.cpp with 77% similarity]
common/compiler/vs/StackWalker.h [moved from common/compiler/vs/stack_walker.h with 69% similarity]
common/os/windows/stack_trace.cpp
core/producer/text/utils/texture_font.cpp
dependencies64/cef/lib/win32/debug/libcef.lib [new file with mode: 0644]
dependencies64/cef/lib/win32/debug/libcef_dll_wrapper.lib [new file with mode: 0644]
dependencies64/cef/lib/win32/release/libcef.lib [moved from dependencies64/cef/lib/win32/libcef.lib with 100% similarity]
dependencies64/cef/lib/win32/release/libcef_dll_wrapper.lib [moved from dependencies64/cef/lib/win32/libcef_dll_wrapper.lib with 100% similarity]
modules/html/CMakeLists.txt
modules/psd/psd_scene_producer.cpp
protocol/amcp/AMCPCommandsImpl.cpp
shell/server.cpp

index cd3c646a1c136e96398cbcedff74c9175f7111fd..7daa4c492217ab44be0509718829e84e483c8a3d 100644 (file)
@@ -17,8 +17,8 @@ set(SOURCES
 if (MSVC)
        set(OS_SPECIFIC_SOURCES
                        compiler/vs/disable_silly_warnings.h
-                       compiler/vs/stack_walker.cpp
-                       compiler/vs/stack_walker.h
+                       compiler/vs/StackWalker.cpp
+                       compiler/vs/StackWalker.h
 
                        os/windows/current_version.h
                        os/windows/filesystem.cpp
similarity index 77%
rename from common/compiler/vs/stack_walker.cpp
rename to common/compiler/vs/StackWalker.cpp
index ad494cb2c599b867c1daa189aa818eb8824f183d..904b13f32240cd22d8d65be79538050f4480f6d3 100644 (file)
@@ -1,11 +1,12 @@
 /**********************************************************************
  * 
- * stack_walker.cpp
+ * StackWalker.cpp
+ * http://stackwalker.codeplex.com/
  *
  *
  * History:
  *  2005-07-27   v1    - First public release on http://www.codeproject.com/
- *                       http://www.codeproject.com/threads/stack_walker.asp
+ *                       http://www.codeproject.com/threads/StackWalker.asp
  *  2005-07-28   v2    - Changed the params of the constructor and ShowCallstack
  *                       (to simplify the usage)
  *  2005-08-01   v3    - Changed to use 'CONTEXT_FULL' instead of CONTEXT_ALL 
  *                     - Added example for doing an exception-callstack-walking in main.cpp
  *                       (thanks to owillebo: http://www.codeproject.com/script/profile/whos_who.asp?id=536268)
  *  2005-08-05   v5    - Removed most Lint (http://www.gimpel.com/) errors... thanks to Okko Willeboordse!
+ *  2008-08-04   v6    - Fixed Bug: Missing LEAK-end-tag
+ *                       http://www.codeproject.com/KB/applications/leakfinder.aspx?msg=2502890#xx2502890xx
+ *                       Fixed Bug: Compiled with "WIN32_LEAN_AND_MEAN"
+ *                       http://www.codeproject.com/KB/applications/leakfinder.aspx?msg=1824718#xx1824718xx
+ *                       Fixed Bug: Compiling with "/Wall"
+ *                       http://www.codeproject.com/KB/threads/StackWalker.aspx?msg=2638243#xx2638243xx
+ *                       Fixed Bug: Now checking SymUseSymSrv
+ *                       http://www.codeproject.com/KB/threads/StackWalker.aspx?msg=1388979#xx1388979xx
+ *                       Fixed Bug: Support for recursive function calls
+ *                       http://www.codeproject.com/KB/threads/StackWalker.aspx?msg=1434538#xx1434538xx
+ *                       Fixed Bug: Missing FreeLibrary call in "GetModuleListTH32"
+ *                       http://www.codeproject.com/KB/threads/StackWalker.aspx?msg=1326923#xx1326923xx
+ *                       Fixed Bug: SymDia is number 7, not 9!
+ *  2008-09-11   v7      For some (undocumented) reason, dbhelp.h is needing a packing of 8!
+ *                       Thanks to Teajay which reported the bug...
+ *                       http://www.codeproject.com/KB/applications/leakfinder.aspx?msg=2718933#xx2718933xx
+ *  2008-11-27   v8      Debugging Tools for Windows are now stored in a different directory
+ *                       Thanks to Luiz Salamon which reported this "bug"...
+ *                       http://www.codeproject.com/KB/threads/StackWalker.aspx?msg=2822736#xx2822736xx
+ *  2009-04-10   v9      License slihtly corrected (<ORGANIZATION> replaced)
+ *  2009-11-01   v10     Moved to http://stackwalker.codeplex.com/
+ *  2009-11-02   v11     Now try to use IMAGEHLP_MODULE64_V3 if available
+ *  2010-04-15   v12     Added support for VS2010 RTM
+ *  2010-05-25   v13     Now using secure MyStrcCpy. Thanks to luke.simon:
+ *                       http://www.codeproject.com/KB/applications/leakfinder.aspx?msg=3477467#xx3477467xx
+ *  2013-01-07   v14     Runtime Check Error VS2010 Debug Builds fixed:
+ *                       http://stackwalker.codeplex.com/workitem/10511
+ *
+ *
+ * LICENSE (http://www.opensource.org/licenses/bsd-license.php)
+ *
+ *   Copyright (c) 2005-2013, Jochen Kalmbach
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without modification, 
+ *   are permitted provided that the following conditions are met:
+ *
+ *   Redistributions of source code must retain the above copyright notice, 
+ *   this list of conditions and the following disclaimer. 
+ *   Redistributions in binary form must reproduce the above copyright notice, 
+ *   this list of conditions and the following disclaimer in the documentation 
+ *   and/or other materials provided with the distribution. 
+ *   Neither the name of Jochen Kalmbach nor the names of its contributors may be 
+ *   used to endorse or promote products derived from this software without 
+ *   specific prior written permission. 
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+ *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
+ *   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ *   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
+ *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
+ *   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ *   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
+ *   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
+ *   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  **********************************************************************/
+#include <windows.h>
 #include <tchar.h>
 #include <stdio.h>
 #include <stdlib.h>
-
-#pragma warning(push, 1)
-
 #pragma comment(lib, "version.lib")  // for "VerQueryValue"
+#pragma warning(disable:4826)
+
+#include "StackWalker.h"
 
-#include "stack_walker.h"
 
 // If VC7 and later, then use the shipped 'dbghelp.h'-file
+#pragma pack(push,8)
 #if _MSC_VER >= 1300
 #include <dbghelp.h>
 #else
@@ -163,6 +220,7 @@ DWORD64
 #define UNDNAME_COMPLETE                 (0x0000)  // Enable full undecoration
 #define UNDNAME_NAME_ONLY                (0x1000)  // Crack only the name for primary declaration;
 #endif  // _MSC_VER < 1300
+#pragma pack(pop)
 
 // Some missing defines (for VC5/6):
 #ifndef INVALID_FILE_ATTRIBUTES
@@ -172,20 +230,28 @@ DWORD64
 
 // secure-CRT_functions are only available starting with VC8
 #if _MSC_VER < 1400
-#define strcpy_s strcpy
+#define strcpy_s(dst, len, src) strcpy(dst, src)
+#define strncpy_s(dst, len, src, maxLen) strncpy(dst, len, src)
 #define strcat_s(dst, len, src) strcat(dst, src)
 #define _snprintf_s _snprintf
 #define _tcscat_s _tcscat
 #endif
 
+static void MyStrCpy(char* szDest, size_t nMaxDestSize, const char* szSrc)
+{
+  if (nMaxDestSize <= 0) return;
+  strncpy_s(szDest, nMaxDestSize, szSrc, _TRUNCATE);
+  szDest[nMaxDestSize-1] = 0;  // INFO: _TRUNCATE will ensure that it is nul-terminated; but with older compilers (<1400) it uses "strncpy" and this does not!)
+}  // MyStrCpy
+
 // Normally it should be enough to use 'CONTEXT_FULL' (better would be 'CONTEXT_ALL')
 #define USED_CONTEXT_FLAGS CONTEXT_FULL
 
 
-class stack_walkerInternal
+class StackWalkerInternal
 {
 public:
-  stack_walkerInternal(stack_walker *parent, HANDLE hProcess)
+  StackWalkerInternal(StackWalker *parent, HANDLE hProcess)
   {
     m_parent = parent;
     m_hDbhHelp = NULL;
@@ -205,7 +271,7 @@ public:
     pUDSN = NULL;
     pSGSP = NULL;
   }
-  ~stack_walkerInternal()
+  ~StackWalkerInternal()
   {
     if (pSC != NULL)
       pSC(m_hProcess);  // SymCleanup
@@ -231,7 +297,40 @@ public:
       if (GetFileAttributes(szTemp) == INVALID_FILE_ATTRIBUTES)
       {
         // ".local" file does not exist, so we can try to load the dbghelp.dll from the "Debugging Tools for Windows"
-        if (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0)
+        // Ok, first try the new path according to the archtitecture:
+#ifdef _M_IX86
+        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
+        {
+          _tcscat_s(szTemp, _T("\\Debugging Tools for Windows (x86)\\dbghelp.dll"));
+          // now check if the file exists:
+          if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES)
+          {
+            m_hDbhHelp = LoadLibrary(szTemp);
+          }
+        }
+#elif _M_X64
+        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
+        {
+          _tcscat_s(szTemp, _T("\\Debugging Tools for Windows (x64)\\dbghelp.dll"));
+          // now check if the file exists:
+          if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES)
+          {
+            m_hDbhHelp = LoadLibrary(szTemp);
+          }
+        }
+#elif _M_IA64
+        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
+        {
+          _tcscat_s(szTemp, _T("\\Debugging Tools for Windows (ia64)\\dbghelp.dll"));
+          // now check if the file exists:
+          if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES)
+          {
+            m_hDbhHelp = LoadLibrary(szTemp);
+          }
+        }
+#endif
+        // If still not found, try the old directories...
+        if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
         {
           _tcscat_s(szTemp, _T("\\Debugging Tools for Windows\\dbghelp.dll"));
           // now check if the file exists:
@@ -240,7 +339,8 @@ public:
             m_hDbhHelp = LoadLibrary(szTemp);
           }
         }
-          // Still not found? Then try to load the 64-Bit version:
+#if defined _M_X64 || defined _M_IA64
+        // Still not found? Then try to load the (old) 64-Bit version:
         if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
         {
           _tcscat_s(szTemp, _T("\\Debugging Tools for Windows 64-Bit\\dbghelp.dll"));
@@ -249,6 +349,7 @@ public:
             m_hDbhHelp = LoadLibrary(szTemp);
           }
         }
+#endif
       }
     }
     if (m_hDbhHelp == NULL)  // if not already loaded, try to load a default-one
@@ -266,7 +367,6 @@ public:
     pSGLFA = (tSGLFA) GetProcAddress(m_hDbhHelp, "SymGetLineFromAddr64" );
     pSGMB = (tSGMB) GetProcAddress(m_hDbhHelp, "SymGetModuleBase64" );
     pSGMI = (tSGMI) GetProcAddress(m_hDbhHelp, "SymGetModuleInfo64" );
-    //pSGMI_V3 = (tSGMI_V3) GetProcAddress(m_hDbhHelp, "SymGetModuleInfo64" );
     pSGSFA = (tSGSFA) GetProcAddress(m_hDbhHelp, "SymGetSymFromAddr64" );
     pUDSN = (tUDSN) GetProcAddress(m_hDbhHelp, "UnDecorateSymbolName" );
     pSLM = (tSLM) GetProcAddress(m_hDbhHelp, "SymLoadModule64" );
@@ -295,10 +395,10 @@ public:
     // SymSetOptions
     symOptions = this->pSSO(symOptions);
 
-    char buf[stack_walker::STACKWALK_MAX_NAMELEN] = {0};
+    char buf[StackWalker::STACKWALK_MAX_NAMELEN] = {0};
     if (this->pSGSP != NULL)
     {
-      if (this->pSGSP(m_hProcess, buf, stack_walker::STACKWALK_MAX_NAMELEN) == FALSE)
+      if (this->pSGSP(m_hProcess, buf, StackWalker::STACKWALK_MAX_NAMELEN) == FALSE)
         this->m_parent->OnDbgHelpErr("SymGetSearchPath", GetLastError(), 0);
     }
     char szUserName[1024] = {0};
@@ -309,13 +409,14 @@ public:
     return TRUE;
   }
 
-  stack_walker *m_parent;
+  StackWalker *m_parent;
 
   HMODULE m_hDbhHelp;
   HANDLE m_hProcess;
   LPSTR m_szSymPath;
 
-/*typedef struct IMAGEHLP_MODULE64_V3 {
+#pragma pack(push,8)
+typedef struct IMAGEHLP_MODULE64_V3 {
     DWORD    SizeOfStruct;           // set to sizeof(IMAGEHLP_MODULE64)
     DWORD64  BaseOfImage;            // base load address of module
     DWORD    ImageSize;              // virtual size of the loaded module
@@ -325,11 +426,11 @@ public:
     SYM_TYPE SymType;                // type of symbols loaded
     CHAR     ModuleName[32];         // module name
     CHAR     ImageName[256];         // image name
-    // new elements: 07-Jun-2002
     CHAR     LoadedImageName[256];   // symbol file name
+    // new elements: 07-Jun-2002
     CHAR     LoadedPdbName[256];     // pdb file name
     DWORD    CVSig;                  // Signature of the CV record in the debug directories
-    CHAR         CVData[MAX_PATH * 3];   // Contents of the CV record
+    CHAR     CVData[MAX_PATH * 3];   // Contents of the CV record
     DWORD    PdbSig;                 // Signature of PDB
     GUID     PdbSig70;               // Signature of PDB (VC 7 and up)
     DWORD    PdbAge;                 // DBI age of pdb
@@ -342,7 +443,7 @@ public:
     BOOL     SourceIndexed;          // pdb supports source server
     BOOL     Publics;                // contains public symbols
 };
-*/
+
 typedef struct IMAGEHLP_MODULE64_V2 {
     DWORD    SizeOfStruct;           // set to sizeof(IMAGEHLP_MODULE64)
     DWORD64  BaseOfImage;            // base load address of module
@@ -355,6 +456,7 @@ typedef struct IMAGEHLP_MODULE64_V2 {
     CHAR     ImageName[256];         // image name
     CHAR     LoadedImageName[256];   // symbol file name
 };
+#pragma pack(pop)
 
 
   // SymCleanup()
@@ -375,13 +477,9 @@ typedef struct IMAGEHLP_MODULE64_V2 {
   tSGMB pSGMB;
 
   // SymGetModuleInfo64()
-  typedef BOOL (__stdcall *tSGMI)( IN HANDLE hProcess, IN DWORD64 dwAddr, OUT IMAGEHLP_MODULE64_V2 *ModuleInfo );
+  typedef BOOL (__stdcall *tSGMI)( IN HANDLE hProcess, IN DWORD64 dwAddr, OUT IMAGEHLP_MODULE64_V3 *ModuleInfo );
   tSGMI pSGMI;
 
-//  // SymGetModuleInfo64()
-//  typedef BOOL (__stdcall *tSGMI_V3)( IN HANDLE hProcess, IN DWORD64 dwAddr, OUT IMAGEHLP_MODULE64_V3 *ModuleInfo );
-//  tSGMI_V3 pSGMI_V3;
-
   // SymGetOptions()
   typedef DWORD (__stdcall *tSGO)( VOID );
   tSGO pSGO;
@@ -489,7 +587,10 @@ private:
 
     hSnap = pCT32S( TH32CS_SNAPMODULE, pid );
     if (hSnap == (HANDLE) -1)
+    {
+      FreeLibrary(hToolhelp);
       return FALSE;
+    }
 
     keepGoing = !!pM32F( hSnap, &me );
     int cnt = 0;
@@ -555,7 +656,7 @@ private:
       return FALSE;
     }
 
-    hMods = (HMODULE*) malloc(sizeof(HMODULE) * (TTBUFLEN / sizeof HMODULE));
+    hMods = (HMODULE*) malloc(sizeof(HMODULE) * (TTBUFLEN / sizeof(HMODULE)));
     tt = (char*) malloc(sizeof(char) * TTBUFLEN);
     tt2 = (char*) malloc(sizeof(char) * TTBUFLEN);
     if ( (hMods == NULL) || (tt == NULL) || (tt2 == NULL) )
@@ -573,10 +674,10 @@ private:
       goto cleanup;
     }
 
-    for ( i = 0; i < cbNeeded / sizeof hMods[0]; i++ )
+    for ( i = 0; i < cbNeeded / sizeof(hMods[0]); i++ )
     {
       // base address, size
-      pGMI(hProcess, hMods[i], &mi, sizeof mi );
+      pGMI(hProcess, hMods[i], &mi, sizeof(mi));
       // image file name
       tt[0] = 0;
       pGMFNE(hProcess, hMods[i], tt, TTBUFLEN );
@@ -615,7 +716,7 @@ private:
     if ( (m_parent != NULL) && (szImg != NULL) )
     {
       // try to retrive the file-version:
-      if ( (this->m_parent->m_options & stack_walker::RetrieveFileVersion) != 0)
+      if ( (this->m_parent->m_options & StackWalker::RetrieveFileVersion) != 0)
       {
         VS_FIXEDFILEINFO *fInfo = NULL;
         DWORD dwHandle;
@@ -642,7 +743,7 @@ private:
       }
 
       // Retrive some additional-infos about the module
-      IMAGEHLP_MODULE64_V2 Module;
+      IMAGEHLP_MODULE64_V3 Module;
       const char *szSymType = "-unknown-";
       if (this->GetModuleInfo(hProcess, baseAddr, &Module) != FALSE)
       {
@@ -651,33 +752,36 @@ private:
           case SymNone:
             szSymType = "-nosymbols-";
             break;
-          case SymCoff:
+          case SymCoff:  // 1
             szSymType = "COFF";
             break;
-          case SymCv:
+          case SymCv:  // 2
             szSymType = "CV";
             break;
-          case SymPdb:
+          case SymPdb:  // 3
             szSymType = "PDB";
             break;
-          case SymExport:
+          case SymExport:  // 4
             szSymType = "-exported-";
             break;
-          case SymDeferred:
+          case SymDeferred:  // 5
             szSymType = "-deferred-";
             break;
-          case SymSym:
+          case SymSym:  // 6
             szSymType = "SYM";
             break;
+          case 7: // SymDia:
+            szSymType = "DIA";
+            break;
           case 8: //SymVirtual:
             szSymType = "Virtual";
             break;
-          case 9: // SymDia:
-            szSymType = "DIA";
-            break;
         }
       }
-      this->m_parent->OnLoadModule(img, mod, baseAddr, size, result, szSymType, Module.LoadedImageName, fileVersion);
+      LPCSTR pdbName = Module.LoadedImageName;
+      if (Module.LoadedPdbName[0] != 0)
+        pdbName = Module.LoadedPdbName;
+      this->m_parent->OnLoadModule(img, mod, baseAddr, size, result, szSymType, pdbName, fileVersion);
     }
     if (szImg != NULL) free(szImg);
     if (szMod != NULL) free(szMod);
@@ -694,34 +798,41 @@ public:
   }
 
 
-  BOOL GetModuleInfo(HANDLE hProcess, DWORD64 baseAddr, IMAGEHLP_MODULE64_V2 *pModuleInfo)
+  BOOL GetModuleInfo(HANDLE hProcess, DWORD64 baseAddr, IMAGEHLP_MODULE64_V3 *pModuleInfo)
   {
+    memset(pModuleInfo, 0, sizeof(IMAGEHLP_MODULE64_V3));
     if(this->pSGMI == NULL)
     {
       SetLastError(ERROR_DLL_INIT_FAILED);
       return FALSE;
     }
     // First try to use the larger ModuleInfo-Structure
-//    memset(pModuleInfo, 0, sizeof(IMAGEHLP_MODULE64_V3));
-//    pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V3);
-//    if (this->pSGMI_V3 != NULL)
-//    {
-//      if (this->pSGMI_V3(hProcess, baseAddr, pModuleInfo) != FALSE)
-//        return TRUE;
-//      // check if the parameter was wrong (size is bad...)
-//      if (GetLastError() != ERROR_INVALID_PARAMETER)
-//        return FALSE;
-//    }
-    // could not retrive the bigger structure, try with the smaller one (as defined in VC7.1)...
-    pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V2);
+    pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V3);
     void *pData = malloc(4096); // reserve enough memory, so the bug in v6.3.5.1 does not lead to memory-overwrites...
     if (pData == NULL)
     {
       SetLastError(ERROR_NOT_ENOUGH_MEMORY);
       return FALSE;
     }
+    memcpy(pData, pModuleInfo, sizeof(IMAGEHLP_MODULE64_V3));
+    static bool s_useV3Version = true;
+    if (s_useV3Version)
+    {
+      if (this->pSGMI(hProcess, baseAddr, (IMAGEHLP_MODULE64_V3*) pData) != FALSE)
+      {
+        // only copy as much memory as is reserved...
+        memcpy(pModuleInfo, pData, sizeof(IMAGEHLP_MODULE64_V3));
+        pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V3);
+        free(pData);
+        return TRUE;
+      }
+      s_useV3Version = false;  // to prevent unneccessarry calls with the larger struct...
+    }
+
+    // could not retrive the bigger structure, try with the smaller one (as defined in VC7.1)...
+    pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V2);
     memcpy(pData, pModuleInfo, sizeof(IMAGEHLP_MODULE64_V2));
-    if (this->pSGMI(hProcess, baseAddr, (IMAGEHLP_MODULE64_V2*) pData) != FALSE)
+    if (this->pSGMI(hProcess, baseAddr, (IMAGEHLP_MODULE64_V3*) pData) != FALSE)
     {
       // only copy as much memory as is reserved...
       memcpy(pModuleInfo, pData, sizeof(IMAGEHLP_MODULE64_V2));
@@ -736,21 +847,22 @@ public:
 };
 
 // #############################################################
-stack_walker::stack_walker(DWORD dwProcessId, HANDLE hProcess)
+StackWalker::StackWalker(DWORD dwProcessId, HANDLE hProcess)
 {
   this->m_options = OptionsAll;
   this->m_modulesLoaded = FALSE;
   this->m_hProcess = hProcess;
-  this->m_sw = new stack_walkerInternal(this, this->m_hProcess);
+  this->m_sw = new StackWalkerInternal(this, this->m_hProcess);
   this->m_dwProcessId = dwProcessId;
   this->m_szSymPath = NULL;
+  this->m_MaxRecursionCount = 1000;
 }
-stack_walker::stack_walker(int options, LPCSTR szSymPath, DWORD dwProcessId, HANDLE hProcess)
+StackWalker::StackWalker(int options, LPCSTR szSymPath, DWORD dwProcessId, HANDLE hProcess)
 {
   this->m_options = options;
   this->m_modulesLoaded = FALSE;
   this->m_hProcess = hProcess;
-  this->m_sw = new stack_walkerInternal(this, this->m_hProcess);
+  this->m_sw = new StackWalkerInternal(this, this->m_hProcess);
   this->m_dwProcessId = dwProcessId;
   if (szSymPath != NULL)
   {
@@ -759,9 +871,10 @@ stack_walker::stack_walker(int options, LPCSTR szSymPath, DWORD dwProcessId, HAN
   }
   else
     this->m_szSymPath = NULL;
+  this->m_MaxRecursionCount = 1000;
 }
 
-stack_walker::~stack_walker()
+StackWalker::~StackWalker()
 {
   if (m_szSymPath != NULL)
     free(m_szSymPath);
@@ -771,7 +884,7 @@ stack_walker::~stack_walker()
   this->m_sw = NULL;
 }
 
-BOOL stack_walker::LoadModules()
+BOOL StackWalker::LoadModules()
 {
   if (this->m_sw == NULL)
   {
@@ -854,7 +967,7 @@ BOOL stack_walker::LoadModules()
       strcat_s(szSymPath, nSymPathLen, ";");
     }
 
-    if ( (this->m_options & SymBuildPath) != 0)
+    if ( (this->m_options & SymUseSymSrv) != 0)
     {
       if (GetEnvironmentVariableA("SYSTEMDRIVE", szTemp, nTempLen) > 0)
       {
@@ -867,7 +980,7 @@ BOOL stack_walker::LoadModules()
       else
         strcat_s(szSymPath, nSymPathLen, "SRV*c:\\websymbols*http://msdl.microsoft.com/download/symbols;");
     }
-  }
+  }  // if SymBuildPath
 
   // First Init the whole stuff...
   BOOL bRet = this->m_sw->Init(szSymPath);
@@ -890,17 +1003,19 @@ BOOL stack_walker::LoadModules()
 // This has to be done due to a problem with the "hProcess"-parameter in x64...
 // Because this class is in no case multi-threading-enabled (because of the limitations 
 // of dbghelp.dll) it is "safe" to use a static-variable
-static stack_walker::PReadProcessMemoryRoutine s_readMemoryFunction = NULL;
+static StackWalker::PReadProcessMemoryRoutine s_readMemoryFunction = NULL;
 static LPVOID s_readMemoryFunction_UserData = NULL;
 
-BOOL stack_walker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadProcessMemoryRoutine readMemoryFunction, LPVOID pUserData)
+BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadProcessMemoryRoutine readMemoryFunction, LPVOID pUserData)
 {
-  CONTEXT c;;
+  CONTEXT c;
   CallstackEntry csEntry;
   IMAGEHLP_SYMBOL64 *pSym = NULL;
-  stack_walkerInternal::IMAGEHLP_MODULE64_V2 Module;
+  StackWalkerInternal::IMAGEHLP_MODULE64_V3 Module;
   IMAGEHLP_LINE64 Line;
   int frameNum;
+  bool bLastEntryCalled = true;
+  int curRecursionCount = 0;
 
   if (m_modulesLoaded == FALSE)
     this->LoadModules();  // ignore the result...
@@ -917,9 +1032,15 @@ BOOL stack_walker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPr
   if (context == NULL)
   {
     // If no context is provided, capture the context
+    // See: https://stackwalker.codeplex.com/discussions/446958
+#if _WIN32_WINNT <= 0x0501
+      // If we need to support XP, we need to use the "old way", because "GetThreadId" is not available!
     if (hThread == GetCurrentThread())
+#else
+    if (GetThreadId(hThread) == GetCurrentThreadId())
+#endif
     {
-      GET_CURRENT_CONTEXT(c, USED_CONTEXT_FLAGS);
+      GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, USED_CONTEXT_FLAGS);
     }
     else
     {
@@ -992,7 +1113,8 @@ BOOL stack_walker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPr
     // CONTEXT need not to be suplied if imageTyp is IMAGE_FILE_MACHINE_I386!
     if ( ! this->m_sw->pSW(imageType, this->m_hProcess, hThread, &s, &c, myReadProcMem, this->m_sw->pSFTA, this->m_sw->pSGMB, NULL) )
     {
-      this->OnDbgHelpErr("StackWalk64", GetLastError(), s.AddrPC.Offset);
+      // INFO: "StackWalk64" does not set "GetLastError"...
+      this->OnDbgHelpErr("StackWalk64", 0, s.AddrPC.Offset);
       break;
     }
 
@@ -1008,17 +1130,22 @@ BOOL stack_walker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPr
     csEntry.moduleName[0] = 0;
     if (s.AddrPC.Offset == s.AddrReturn.Offset)
     {
-      this->OnDbgHelpErr("StackWalk64-Endless-Callstack!", 0, s.AddrPC.Offset);
-      break;
+      if ( (this->m_MaxRecursionCount > 0) && (curRecursionCount > m_MaxRecursionCount) )
+      {
+        this->OnDbgHelpErr("StackWalk64-Endless-Callstack!", 0, s.AddrPC.Offset);
+        break;
+      }
+      curRecursionCount++;
     }
+    else
+      curRecursionCount = 0;
     if (s.AddrPC.Offset != 0)
     {
       // we seem to have a valid PC
       // show procedure info (SymGetSymFromAddr64())
       if (this->m_sw->pSGSFA(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromSmybol), pSym) != FALSE)
       {
-        // TODO: Mache dies sicher...!
-        strcpy_s(csEntry.name, pSym->Name);
+        MyStrCpy(csEntry.name, STACKWALK_MAX_NAMELEN, pSym->Name);
         // UnDecorateSymbolName()
         this->m_sw->pUDSN( pSym->Name, csEntry.undName, STACKWALK_MAX_NAMELEN, UNDNAME_NAME_ONLY );
         this->m_sw->pUDSN( pSym->Name, csEntry.undFullName, STACKWALK_MAX_NAMELEN, UNDNAME_COMPLETE );
@@ -1034,8 +1161,7 @@ BOOL stack_walker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPr
         if (this->m_sw->pSGLFA(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromLine), &Line) != FALSE)
         {
           csEntry.lineNumber = Line.LineNumber;
-          // TODO: Mache dies sicher...!
-          strcpy_s(csEntry.lineFileName, Line.FileName);
+          MyStrCpy(csEntry.lineFileName, STACKWALK_MAX_NAMELEN, Line.FileName);
         }
         else
         {
@@ -1078,15 +1204,14 @@ BOOL stack_walker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPr
           csEntry.symTypeString = "Virtual";
           break;
         default:
-          //_snprintf( ty, sizeof ty, "symtype=%ld", (long) Module.SymType );
+          //_snprintf( ty, sizeof(ty), "symtype=%ld", (long) Module.SymType );
           csEntry.symTypeString = NULL;
           break;
         }
 
-        // TODO: Mache dies sicher...!
-        strcpy_s(csEntry.moduleName, Module.ModuleName);
+        MyStrCpy(csEntry.moduleName, STACKWALK_MAX_NAMELEN, Module.ModuleName);
         csEntry.baseOfImage = Module.BaseOfImage;
-        strcpy_s(csEntry.loadedImageName, Module.LoadedImageName);
+        MyStrCpy(csEntry.loadedImageName, STACKWALK_MAX_NAMELEN, Module.LoadedImageName);
       } // got module info OK
       else
       {
@@ -1097,10 +1222,12 @@ BOOL stack_walker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPr
     CallstackEntryType et = nextEntry;
     if (frameNum == 0)
       et = firstEntry;
+    bLastEntryCalled = false;
     this->OnCallstackEntry(et, csEntry);
     
     if (s.AddrReturn.Offset == 0)
     {
+      bLastEntryCalled = true;
       this->OnCallstackEntry(lastEntry, csEntry);
       SetLastError(ERROR_SUCCESS);
       break;
@@ -1110,13 +1237,16 @@ BOOL stack_walker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPr
   cleanup:
     if (pSym) free( pSym );
 
+  if (bLastEntryCalled == false)
+      this->OnCallstackEntry(lastEntry, csEntry);
+
   if (context == NULL)
     ResumeThread(hThread);
 
   return TRUE;
 }
 
-BOOL __stdcall stack_walker::myReadProcMem(
+BOOL __stdcall StackWalker::myReadProcMem(
     HANDLE      hProcess,
     DWORD64     qwBaseAddress,
     PVOID       lpBuffer,
@@ -1138,54 +1268,55 @@ BOOL __stdcall stack_walker::myReadProcMem(
   }
 }
 
-void stack_walker::OnLoadModule(LPCSTR img, LPCSTR mod, DWORD64 baseAddr, DWORD size, DWORD result, LPCSTR symType, LPCSTR pdbName, ULONGLONG fileVersion)
+void StackWalker::OnLoadModule(LPCSTR img, LPCSTR mod, DWORD64 baseAddr, DWORD size, DWORD result, LPCSTR symType, LPCSTR pdbName, ULONGLONG fileVersion)
 {
   CHAR buffer[STACKWALK_MAX_NAMELEN];
   if (fileVersion == 0)
     _snprintf_s(buffer, STACKWALK_MAX_NAMELEN, "%s:%s (%p), size: %d (result: %d), SymType: '%s', PDB: '%s'\n", img, mod, (LPVOID) baseAddr, size, result, symType, pdbName);
   else
   {
-    DWORD v4 = (DWORD) fileVersion & 0xFFFF;
-    DWORD v3 = (DWORD) (fileVersion>>16) & 0xFFFF;
-    DWORD v2 = (DWORD) (fileVersion>>32) & 0xFFFF;
-    DWORD v1 = (DWORD) (fileVersion>>48) & 0xFFFF;
+    DWORD v4 = (DWORD) (fileVersion & 0xFFFF);
+    DWORD v3 = (DWORD) ((fileVersion>>16) & 0xFFFF);
+    DWORD v2 = (DWORD) ((fileVersion>>32) & 0xFFFF);
+    DWORD v1 = (DWORD) ((fileVersion>>48) & 0xFFFF);
     _snprintf_s(buffer, STACKWALK_MAX_NAMELEN, "%s:%s (%p), size: %d (result: %d), SymType: '%s', PDB: '%s', fileVersion: %d.%d.%d.%d\n", img, mod, (LPVOID) baseAddr, size, result, symType, pdbName, v1, v2, v3, v4);
   }
   OnOutput(buffer);
 }
 
-void stack_walker::OnCallstackEntry(CallstackEntryType eType, CallstackEntry &entry)
+void StackWalker::OnCallstackEntry(CallstackEntryType eType, CallstackEntry &entry)
 {
   CHAR buffer[STACKWALK_MAX_NAMELEN];
   if ( (eType != lastEntry) && (entry.offset != 0) )
   {
     if (entry.name[0] == 0)
-      strcpy_s(entry.name, "(function-name not available)");
+      MyStrCpy(entry.name, STACKWALK_MAX_NAMELEN, "(function-name not available)");
     if (entry.undName[0] != 0)
-      strcpy_s(entry.name, entry.undName);
+      MyStrCpy(entry.name, STACKWALK_MAX_NAMELEN, entry.undName);
     if (entry.undFullName[0] != 0)
-      strcpy_s(entry.name, entry.undFullName);
+      MyStrCpy(entry.name, STACKWALK_MAX_NAMELEN, entry.undFullName);
     if (entry.lineFileName[0] == 0)
     {
-      strcpy_s(entry.lineFileName, "(filename not available)");
+      MyStrCpy(entry.lineFileName, STACKWALK_MAX_NAMELEN, "(filename not available)");
       if (entry.moduleName[0] == 0)
-        strcpy_s(entry.moduleName, "(module-name not available)");
+        MyStrCpy(entry.moduleName, STACKWALK_MAX_NAMELEN, "(module-name not available)");
       _snprintf_s(buffer, STACKWALK_MAX_NAMELEN, "%p (%s): %s: %s\n", (LPVOID) entry.offset, entry.moduleName, entry.lineFileName, entry.name);
     }
     else
       _snprintf_s(buffer, STACKWALK_MAX_NAMELEN, "%s (%d): %s\n", entry.lineFileName, entry.lineNumber, entry.name);
+    buffer[STACKWALK_MAX_NAMELEN-1] = 0;
     OnOutput(buffer);
   }
 }
 
-void stack_walker::OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr)
+void StackWalker::OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr)
 {
   CHAR buffer[STACKWALK_MAX_NAMELEN];
   _snprintf_s(buffer, STACKWALK_MAX_NAMELEN, "ERROR: %s, GetLastError: %d (Address: %p)\n", szFuncName, gle, (LPVOID) addr);
   OnOutput(buffer);
 }
 
-void stack_walker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName)
+void StackWalker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName)
 {
   CHAR buffer[STACKWALK_MAX_NAMELEN];
   _snprintf_s(buffer, STACKWALK_MAX_NAMELEN, "SymInit: Symbol-SearchPath: '%s', symOptions: %d, UserName: '%s'\n", szSearchPath, symOptions, szUserName);
@@ -1216,7 +1347,7 @@ void stack_walker::OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUse
 #endif
 }
 
-void stack_walker::OnOutput(LPCSTR buffer)
+void StackWalker::OnOutput(LPCSTR buffer)
 {
   OutputDebugStringA(buffer);
 }
similarity index 69%
rename from common/compiler/vs/stack_walker.h
rename to common/compiler/vs/StackWalker.h
index 0e6a7017c5030aa7cdcc842cbe5cc3ed8bab1385..4b9337b7c3662f2d6e5d75f7d692fe4e10fd3275 100644 (file)
@@ -1,13 +1,37 @@
 /**********************************************************************
  * 
- * stack_walker.h
+ * StackWalker.h
  *
  *
- * History:
- *  2005-07-27   v1    - First public release on http://www.codeproject.com/
- *  (for additional changes see History in 'stack_walker.cpp'!
  *
- **********************************************************************/
+ * LICENSE (http://www.opensource.org/licenses/bsd-license.php)
+ *
+ *   Copyright (c) 2005-2009, Jochen Kalmbach
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without modification, 
+ *   are permitted provided that the following conditions are met:
+ *
+ *   Redistributions of source code must retain the above copyright notice, 
+ *   this list of conditions and the following disclaimer. 
+ *   Redistributions in binary form must reproduce the above copyright notice, 
+ *   this list of conditions and the following disclaimer in the documentation 
+ *   and/or other materials provided with the distribution. 
+ *   Neither the name of Jochen Kalmbach nor the names of its contributors may be 
+ *   used to endorse or promote products derived from this software without 
+ *   specific prior written permission. 
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+ *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
+ *   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ *   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
+ *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
+ *   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ *   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
+ *   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
+ *   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * **********************************************************************/
 // #pragma once is supported starting with _MCS_VER 1000, 
 // so we need not to check the version (because we only support _MSC_VER >= 1100)!
 #pragma once
@@ -24,8 +48,8 @@ typedef unsigned long SIZE_T, *PSIZE_T;
 #endif
 #endif  // _MSC_VER < 1300
 
-class stack_walkerInternal;  // forward
-class stack_walker
+class StackWalkerInternal;  // forward
+class StackWalker
 {
 public:
   typedef enum StackWalkOptions
@@ -62,14 +86,14 @@ public:
     OptionsAll = 0x3F
   } StackWalkOptions;
 
-  stack_walker(
+  StackWalker(
     int options = OptionsAll, // 'int' is by design, to combine the enum-flags
     LPCSTR szSymPath = NULL, 
     DWORD dwProcessId = GetCurrentProcessId(), 
     HANDLE hProcess = GetCurrentProcess()
     );
-  stack_walker(DWORD dwProcessId, HANDLE hProcess);
-  virtual ~stack_walker();
+  StackWalker(DWORD dwProcessId, HANDLE hProcess);
+  virtual ~StackWalker();
 
   typedef BOOL (__stdcall *PReadProcessMemoryRoutine)(
     HANDLE      hProcess,
@@ -94,7 +118,7 @@ public:
 // in older compilers in order to use it... starting with VC7 we can declare it as "protected"
 protected:
 #endif
-       enum { STACKWALK_MAX_NAMELEN = 1024 }; // max name length for found symbols
+       enum { STACKWALK_MAX_NAMELEN = 4096 }; // max name length for found symbols
 
 protected:
   // Entry for each Callstack-Entry
@@ -123,18 +147,19 @@ protected:
   virtual void OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr);
   virtual void OnOutput(LPCSTR szText);
 
-  stack_walkerInternal *m_sw;
+  StackWalkerInternal *m_sw;
   HANDLE m_hProcess;
   DWORD m_dwProcessId;
   BOOL m_modulesLoaded;
   LPSTR m_szSymPath;
 
   int m_options;
+  int m_MaxRecursionCount;
 
   static BOOL __stdcall myReadProcMem(HANDLE hProcess, DWORD64 qwBaseAddress, PVOID lpBuffer, DWORD nSize, LPDWORD lpNumberOfBytesRead);
 
-  friend stack_walkerInternal;
-};
+  friend StackWalkerInternal;
+};  // class StackWalker
 
 
 // The "ugly" assembler-implementation is needed for systems before XP
@@ -152,7 +177,7 @@ protected:
 #ifdef CURRENT_THREAD_VIA_EXCEPTION
 // TODO: The following is not a "good" implementation, 
 // because the callstack is only valid in the "__except" block...
-#define GET_CURRENT_CONTEXT(c, contextFlags) \
+#define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \
   do { \
     memset(&c, 0, sizeof(CONTEXT)); \
     EXCEPTION_POINTERS *pExp = NULL; \
@@ -165,7 +190,7 @@ protected:
   } while(0);
 #else
 // The following should be enough for walking the callstack...
-#define GET_CURRENT_CONTEXT(c, contextFlags) \
+#define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \
   do { \
     memset(&c, 0, sizeof(CONTEXT)); \
     c.ContextFlags = contextFlags; \
@@ -180,7 +205,7 @@ protected:
 #else
 
 // The following is defined for x86 (XP and higher), x64 and IA64:
-#define GET_CURRENT_CONTEXT(c, contextFlags) \
+#define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \
   do { \
     memset(&c, 0, sizeof(CONTEXT)); \
     c.ContextFlags = contextFlags; \
index 804e4425973e380680a1fb8d5d355465d7dcab96..c01d06acbe87624488ef9ec8ff98fd5734fb768e 100644 (file)
@@ -24,7 +24,7 @@
 #include "../stack_trace.h"
 #include "../../utf.h"
 
-#include "../../compiler/vs/stack_walker.h"
+#include "../../compiler/vs/StackWalker.h"
 
 #include <utility>
 
@@ -34,31 +34,31 @@ namespace caspar {
 
 std::wstring get_call_stack()
 {
-       class log_call_stack_walker : public stack_walker
+       class log_call_stack_walker : public StackWalker
        {
                std::string str_;
        public:
-               log_call_stack_walker() : stack_walker() {}
+               log_call_stack_walker() : StackWalker() {}
 
                std::string flush()
                {
                        return std::move(str_);
                }
        protected:
-               virtual void OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName)
+               virtual void OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName) override
                {
                }
-               virtual void OnLoadModule(LPCSTR img, LPCSTR mod, DWORD64 baseAddr, DWORD size, DWORD result, LPCSTR symType, LPCSTR pdbName, ULONGLONG fileVersion)
+               virtual void OnLoadModule(LPCSTR img, LPCSTR mod, DWORD64 baseAddr, DWORD size, DWORD result, LPCSTR symType, LPCSTR pdbName, ULONGLONG fileVersion) override
                {
                }
-               virtual void OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr)
+               virtual void OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr) override
                {
                }
-               virtual void OnOutput(LPCSTR szText)
+               virtual void OnOutput(LPCSTR szText) override
                {
                        std::string str = szText;
 
-                       if(str.find("internal::get_call_stack") == std::string::npos && str.find("stack_walker::ShowCallstack") == std::string::npos)
+                       if(str.find("caspar::get_call_stack") == std::string::npos && str.find("StackWalker::ShowCallstack") == std::string::npos)
                                str_ += std::move(str);
                }
        };
index 99db8f11942df934fbc427e1eb8117e9203b0ebd..d4f406976c7bf446a1ba49960add3f7f2a162c04 100644 (file)
 
 namespace caspar { namespace core { namespace text {
 
-struct freetype_exception : virtual caspar_exception
-{
-       freetype_exception() {}
-       explicit freetype_exception(const char* msg) : caspar_exception(msg) {}
-};
+struct freetype_exception : virtual caspar_exception { };
 
 struct unicode_range
 {
@@ -55,19 +51,19 @@ public:
                FT_Library lib;
                        
                if (FT_Init_FreeType(&lib))
-                       throw freetype_exception("Failed to initialize freetype");
+                       CASPAR_THROW_EXCEPTION(freetype_exception() << msg_info("Failed to initialize freetype"));
 
                lib_.reset(lib, [](FT_Library ptr) { FT_Done_FreeType(ptr); });
 
                FT_Face face;
                        
                if (FT_New_Face(lib_.get(), u8(info.font_file).c_str(), 0, &face))
-                       throw freetype_exception("Failed to load font");
+                       CASPAR_THROW_EXCEPTION(freetype_exception() << msg_info("Failed to load font"));
 
                face_.reset(face, [](FT_Face ptr) { FT_Done_Face(ptr); });
 
                if (FT_Set_Char_Size(face_.get(), static_cast<FT_F26Dot6>(size_*64), 0, 72, 72))
-                       throw freetype_exception("Failed to set font size");
+                       CASPAR_THROW_EXCEPTION(freetype_exception() << msg_info("Failed to set font size"));
        }
 
        void set_tracking(int tracking)
diff --git a/dependencies64/cef/lib/win32/debug/libcef.lib b/dependencies64/cef/lib/win32/debug/libcef.lib
new file mode 100644 (file)
index 0000000..3c4e9cc
Binary files /dev/null and b/dependencies64/cef/lib/win32/debug/libcef.lib differ
diff --git a/dependencies64/cef/lib/win32/debug/libcef_dll_wrapper.lib b/dependencies64/cef/lib/win32/debug/libcef_dll_wrapper.lib
new file mode 100644 (file)
index 0000000..e0881aa
Binary files /dev/null and b/dependencies64/cef/lib/win32/debug/libcef_dll_wrapper.lib differ
index 642606f53ce5f0ae94b8f0205bd46b08508ae9b4..330775a977daa371859d75363855d6f4b0baaaed 100644 (file)
@@ -34,8 +34,10 @@ if(MSVC)
                common
                core
 
-               libcef.lib
-               libcef_dll_wrapper.lib
+               optimized release/libcef
+               optimized release/libcef_dll_wrapper
+               debug debug/libcef
+               debug debug/libcef_dll_wrapper
        )
 else()
        target_link_libraries(html
index 0b20c6350cc6be5e4b048718ac4fd2073bd055fa..4e0f767891430d40f2fdfe46cd07a24898f842a9 100644 (file)
@@ -31,6 +31,7 @@
 #include <core/producer/scene/scene_producer.h>
 #include <core/producer/scene/const_producer.h>
 #include <core/producer/scene/hotswap_producer.h>
+#include <core/producer/media_info/media_info.h>
 #include <core/frame/draw_frame.h>
 
 #include <common/env.h>
@@ -396,6 +397,18 @@ spl::shared_ptr<core::frame_producer> create_psd_scene_producer(const spl::share
 void init(core::module_dependencies dependencies)
 {
        core::register_producer_factory(create_psd_scene_producer);
+       dependencies.media_info_repo->register_extractor(
+                       [](const std::wstring& file, const std::wstring& upper_case_extension, core::media_info& info)
+                       {
+                               if (upper_case_extension == L".PSD")
+                               {
+                                       info.clip_type = L"STILL";
+
+                                       return true;
+                               }
+
+                               return false;
+                       });
 }
 
 }}
index bc61b1656aef8f138e1792cb3156974730e33bfb..a4c3b469c49bebd568267f560eac8cda437572fc 100644 (file)
@@ -1417,8 +1417,8 @@ bool CinfCommand::DoExecute()
                for (boost::filesystem::recursive_directory_iterator itr(env::media_folder()), end; itr != end && info.empty(); ++itr)
                {
                        auto path = itr->path();
-                       auto file = path.replace_extension(L"").filename();
-                       if(boost::iequals(file.wstring(), parameters().at(0)))
+                       auto file = path.replace_extension(L"").filename().wstring();
+                       if(boost::iequals(file, parameters().at(0)))
                                info += MediaInfo(itr->path(), system_info_repo_) + L"\r\n";
                }
 
index 0f0eee45c8dd45623bd3a5155e810dd22ff3bd79..a7fd081bc068d867ad1b2ec8876f243462bbca05 100644 (file)
@@ -109,7 +109,7 @@ struct server::impl : boost::noncopyable
                                cg_registry_,
                                media_info_repo_));
 
-               //core::text::init();
+               core::text::init();
 
                register_producer_factory(&core::scene::create_dummy_scene_producer);
                register_producer_factory(&core::scene::create_xml_scene_producer);