2
2
#include " ll/api/utils/ErrorUtils.h"
3
3
#include " ll/core/LeviLamina.h"
4
4
5
+ #include < demangler/Demangle.h>
6
+ #include < pl/dependency/DependencyWalker.h>
7
+
5
8
#include " windows.h"
6
9
7
10
namespace ll ::plugin {
8
11
9
12
NativePluginManager::NativePluginManager () : PluginManager(NativePluginManagerName) {}
10
13
NativePluginManager::~NativePluginManager () = default ;
11
14
15
+ static void printDependencyError (
16
+ const std::unique_ptr<pl::dependency_walker::DependencyIssueItem>& item,
17
+ std::ostream& stream,
18
+ size_t depth = 0
19
+ ) {
20
+ std::string indent (depth * 3 + 3 , ' ' );
21
+ if (item->mContainsError ) {
22
+ stream << indent << fmt::format (" module: {}" , string_utils::u8str2str (item->mPath .u8string ())) << std::endl;
23
+ if (!item->mMissingModule .empty ()) {
24
+ stream << indent << " missing module:" << std::endl;
25
+ for (const auto & missingModule : item->mMissingModule ) {
26
+ stream << indent << " |- " << missingModule << std::endl;
27
+ }
28
+ }
29
+ if (!item->mMissingProcedure .empty ()) {
30
+ stream << indent << " missing procedure:" << std::endl;
31
+ for (const auto & [module, missingProcedure] : item->mMissingProcedure ) {
32
+ stream << indent << " |- " << module << std::endl;
33
+ for (const auto & procedure : missingProcedure) {
34
+ stream << indent << " |---- " << procedure << std::endl;
35
+
36
+ auto de = demangler::demangle (procedure);
37
+ if (de != procedure) stream << indent << " | " << de << std::endl;
38
+ }
39
+ }
40
+ }
41
+ if (!item->mDependencies .empty ()) {
42
+ for (const auto & [module, subItem] : item->mDependencies ) {
43
+ printDependencyError (subItem, stream, depth + 1 );
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ std::string diagnosticDependency (const std::filesystem::path& path) {
50
+ auto result = pl::dependency_walker::pl_diagnostic_dependency (path);
51
+ std::stringstream stream;
52
+ printDependencyError (result, stream);
53
+ return stream.str ();
54
+ }
55
+
12
56
bool NativePluginManager::load (Manifest manifest) {
13
57
auto l (lock ());
14
58
if (hasPlugin (manifest.name )) {
@@ -17,7 +61,11 @@ bool NativePluginManager::load(Manifest manifest) {
17
61
auto entry = getPluginsRoot () / manifest.name / manifest.entry ;
18
62
auto lib = LoadLibrary (entry.c_str ());
19
63
if (!lib) {
20
- error_utils::printException (logger, error_utils::getWinLastError ());
64
+ auto e = error_utils::getWinLastError ();
65
+ error_utils::printException (logger, e);
66
+ if (e.code ().value () == 126 || e.code ().value () == 127 ) {
67
+ logger.error (" Dependency diagnostic:\n {}" , diagnosticDependency (entry));
68
+ }
21
69
return false ;
22
70
}
23
71
auto plugin = std::make_shared<NativePlugin>(std::move (manifest), lib);
0 commit comments