Ver código fonte

Add load library error to dxc exception handler; add header with exception error codes (#3639)

* Add load library error to dxc exception handler
* Add header with exception error codes
Helena Kotas 4 anos atrás
pai
commit
555ca24474
2 arquivos alterados com 40 adições e 0 exclusões
  1. 29 0
      include/dxc/dxcerrors.h
  2. 11 0
      tools/clang/tools/dxclib/dxc.cpp

+ 29 - 0
include/dxc/dxcerrors.h

@@ -0,0 +1,29 @@
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// dxcerror.h                                                                //
+// Copyright (C) Microsoft Corporation. All rights reserved.                 //
+// This file is distributed under the University of Illinois Open Source     //
+// License. See LICENSE.TXT for details.                                     //
+//                                                                           //
+// Provides definition of error codes.                                        //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DXC_ERRORS__
+#define __DXC_ERRORS__
+
+#ifndef FACILITY_GRAPHICS
+#define FACILITY_GRAPHICS 36
+#endif
+
+#define DXC_EXCEPTION_CODE(name, status)                                 \
+    static constexpr DWORD EXCEPTION_##name =                 \
+    (0xc0000000u | (FACILITY_GRAPHICS << 16) | (0xff00u | (status & 0xffu)));
+
+DXC_EXCEPTION_CODE(LOAD_LIBRARY_FAILED, 0x00u)
+DXC_EXCEPTION_CODE(NO_HMODULE,          0x01u)
+DXC_EXCEPTION_CODE(GET_PROC_FAILED,     0x02u)
+
+#undef DXC_EXCEPTION_CODE
+
+#endif

+ 11 - 0
tools/clang/tools/dxclib/dxc.cpp

@@ -41,6 +41,7 @@
 #include "dxc/Support/Unicode.h"
 #include "dxc/Support/Unicode.h"
 #include "dxc/Support/WinIncludes.h"
 #include "dxc/Support/WinIncludes.h"
 #include "dxc/Support/WinFunctions.h"
 #include "dxc/Support/WinFunctions.h"
+#include "dxc/dxcerrors.h"
 #include "dxc.h"
 #include "dxc.h"
 #include <vector>
 #include <vector>
 #include <string>
 #include <string>
@@ -1257,6 +1258,16 @@ static LONG CALLBACK ExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo)
   case STATUS_LLVM_FATAL:
   case STATUS_LLVM_FATAL:
     fputs("LLVM Fatal Error\n", stderr);
     fputs("LLVM Fatal Error\n", stderr);
     break;
     break;
+  case EXCEPTION_LOAD_LIBRARY_FAILED:
+    if (pExceptionInfo->ExceptionRecord->ExceptionInformation[0]) {
+      fputs("cannot not load ", stderr);
+      fputws((const wchar_t*)pExceptionInfo->ExceptionRecord->ExceptionInformation[0], stderr);
+      fputs(" library.\n", stderr);
+    }
+    else{
+      fputs("cannot not load library.\n", stderr);
+    }
+    break;
   default:
   default:
     fputs("Terminal Error ", stderr);
     fputs("Terminal Error ", stderr);
     sprintf_s(scratch, _countof(scratch), "0x%08x\n", pExceptionInfo->ExceptionRecord->ExceptionCode);
     sprintf_s(scratch, _countof(scratch), "0x%08x\n", pExceptionInfo->ExceptionRecord->ExceptionCode);