Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: runtime/bin/extensions_linux.cc

Issue 1403683007: Fix for issue 23908 - error message reports the exact error when a native extension fails to load. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h"
5 #include "platform/globals.h" 6 #include "platform/globals.h"
6 #if defined(TARGET_OS_LINUX) 7 #if defined(TARGET_OS_LINUX)
7 8
8 #include "bin/extensions.h" 9 #include "bin/extensions.h"
9 #include <dlfcn.h> // NOLINT 10 #include <dlfcn.h> // NOLINT
10 11
11 12
12 namespace dart { 13 namespace dart {
13 namespace bin { 14 namespace bin {
14 15
15 const char* kPrecompiledLibraryName = "libprecompiled.so"; 16 const char* kPrecompiledLibraryName = "libprecompiled.so";
16 const char* kPrecompiledSymbolName = "_kInstructionsSnapshot"; 17 const char* kPrecompiledSymbolName = "_kInstructionsSnapshot";
17 18
18 void* Extensions::LoadExtensionLibrary(const char* library_file) { 19 Dart_Handle Extensions::LoadExtensionLibrary(const char* library_file,
19 return dlopen(library_file, RTLD_LAZY); 20 void** library_handle) {
21 ASSERT(library_handle != NULL);
22 *library_handle = dlopen(library_file, RTLD_LAZY);
23 if (*library_handle == NULL) {
24 return Dart_NewApiError(dlerror());
25 }
26 return Dart_Null();
20 } 27 }
21 28
22 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { 29 Dart_Handle Extensions::ResolveSymbol(void* lib_handle,
30 const char* symbol,
31 void** init_function) {
32 ASSERT(init_function != NULL);
23 dlerror(); 33 dlerror();
24 void* result = dlsym(lib_handle, symbol); 34 *init_function = dlsym(lib_handle, symbol);
25 if (dlerror() != NULL) return NULL; 35 char* err_str = dlerror();
26 return result; 36 if (err_str != NULL) {
37 return Dart_NewApiError(err_str);
38 }
39 return Dart_Null();
27 } 40 }
28 41
29 } // namespace bin 42 } // namespace bin
30 } // namespace dart 43 } // namespace dart
31 44
32 #endif // defined(TARGET_OS_LINUX) 45 #endif // defined(TARGET_OS_LINUX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698