plugin/qlibrary_unix.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9static QString qdlerror() -
10{ -
11 -
12 -
13 -
14 const char *err = dlerror(); -
15 -
16 -
17 -
18 return err ? QLatin1Char('(') + QString::fromLocal8Bit(err) + QLatin1Char(')'): QString();
executed: return err ? QLatin1Char('(') + QString::fromLocal8Bit(err) + QLatin1Char(')'): QString();
Execution Count:55
55
19} -
20 -
21QStringList QLibraryPrivate::suffixes_sys(const QString& fullVersion) -
22{ -
23 QStringList suffixes; -
24 if (!fullVersion.isEmpty()) {
evaluated: !fullVersion.isEmpty()
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:40
40-55
25 suffixes << QString::fromLatin1(".so.%1").arg(fullVersion); -
26 } else {
executed: }
Execution Count:55
55
27 suffixes << QLatin1String(".so"); -
28 }
executed: }
Execution Count:40
40
29 return suffixes;
executed: return suffixes;
Execution Count:95
95
30} -
31 -
32QStringList QLibraryPrivate::prefixes_sys() -
33{ -
34 return QStringList() << QLatin1String("lib");
executed: return QStringList() << QLatin1String("lib");
Execution Count:95
95
35} -
36 -
37bool QLibraryPrivate::load_sys() -
38{ -
39 QString attempt; -
40 -
41 QFileSystemEntry fsEntry(fileName); -
42 -
43 QString path = fsEntry.path(); -
44 QString name = fsEntry.fileName(); -
45 if (path == QLatin1String(".") && !fileName.startsWith(path))
evaluated: path == QLatin1String(".")
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:192
partially evaluated: !fileName.startsWith(path)
TRUEFALSE
yes
Evaluation Count:68
no
Evaluation Count:0
0-192
46 path.clear();
executed: path.clear();
Execution Count:68
68
47 else -
48 path += QLatin1Char('/');
executed: path += QLatin1Char('/');
Execution Count:192
192
49 -
50 QStringList suffixes; -
51 QStringList prefixes; -
52 if (pluginState != IsAPlugin) {
evaluated: pluginState != IsAPlugin
TRUEFALSE
yes
Evaluation Count:93
yes
Evaluation Count:167
93-167
53 prefixes = prefixes_sys(); -
54 suffixes = suffixes_sys(fullVersion); -
55 }
executed: }
Execution Count:93
93
56 int dlFlags = 0; -
57 if (loadHints & QLibrary::ResolveAllSymbolsHint) {
evaluated: loadHints & QLibrary::ResolveAllSymbolsHint
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:256
4-256
58 dlFlags |= 0x00002; -
59 } else {
executed: }
Execution Count:4
4
60 dlFlags |= 0x00001; -
61 }
executed: }
Execution Count:256
256
62 if (loadHints & QLibrary::ExportExternalSymbolsHint) {
partially evaluated: loadHints & QLibrary::ExportExternalSymbolsHint
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:260
0-260
63 dlFlags |= 0x00100; -
64 }
never executed: }
0
65 -
66 else { -
67 -
68 -
69 -
70 dlFlags |= 0; -
71 }
executed: }
Execution Count:260
260
72 if (loadHints & QLibrary::PreventUnloadHint) {
partially evaluated: loadHints & QLibrary::PreventUnloadHint
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:260
0-260
73 dlFlags |= 0x01000; -
74 }
never executed: }
0
75 if (fsEntry.isAbsolute()) {
evaluated: fsEntry.isAbsolute()
TRUEFALSE
yes
Evaluation Count:192
yes
Evaluation Count:68
68-192
76 suffixes.prepend(QString()); -
77 prefixes.prepend(QString()); -
78 } else {
executed: }
Execution Count:192
192
79 suffixes.append(QString()); -
80 prefixes.append(QString()); -
81 }
executed: }
Execution Count:68
68
82 -
83 bool retry = true; -
84 for(int prefix = 0; retry && !pHnd && prefix < prefixes.size(); prefix++) {
evaluated: retry
TRUEFALSE
yes
Evaluation Count:534
yes
Evaluation Count:3
evaluated: !pHnd
TRUEFALSE
yes
Evaluation Count:281
yes
Evaluation Count:253
evaluated: prefix < prefixes.size()
TRUEFALSE
yes
Evaluation Count:277
yes
Evaluation Count:4
3-534
85 for(int suffix = 0; retry && !pHnd && suffix < suffixes.size(); suffix++) {
evaluated: retry
TRUEFALSE
yes
Evaluation Count:585
yes
Evaluation Count:3
evaluated: !pHnd
TRUEFALSE
yes
Evaluation Count:332
yes
Evaluation Count:253
evaluated: suffix < suffixes.size()
TRUEFALSE
yes
Evaluation Count:311
yes
Evaluation Count:21
3-585
86 if (!prefixes.at(prefix).isEmpty() && name.startsWith(prefixes.at(prefix)))
evaluated: !prefixes.at(prefix).isEmpty()
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:210
partially evaluated: name.startsWith(prefixes.at(prefix))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:101
0-210
87 continue;
never executed: continue;
0
88 if (!suffixes.at(suffix).isEmpty() && name.endsWith(suffixes.at(suffix)))
evaluated: !suffixes.at(suffix).isEmpty()
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:210
partially evaluated: name.endsWith(suffixes.at(suffix))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:101
0-210
89 continue;
never executed: continue;
0
90 if (loadHints & QLibrary::LoadArchiveMemberHint) {
partially evaluated: loadHints & QLibrary::LoadArchiveMemberHint
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:311
0-311
91 attempt = name; -
92 int lparen = attempt.indexOf(QLatin1Char('(')); -
93 if (lparen == -1)
never evaluated: lparen == -1
0
94 lparen = attempt.count();
never executed: lparen = attempt.count();
0
95 attempt = path + prefixes.at(prefix) + attempt.insert(lparen, suffixes.at(suffix)); -
96 } else {
never executed: }
0
97 attempt = path + prefixes.at(prefix) + name + suffixes.at(suffix); -
98 }
executed: }
Execution Count:311
311
99 -
100 -
101 -
102 pHnd = dlopen(QFile::encodeName(attempt), dlFlags); -
103 -
104 -
105 if (!pHnd && fileName.startsWith(QLatin1Char('/')) && QFile::exists(attempt)) {
evaluated: !pHnd
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:253
evaluated: fileName.startsWith(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:4
evaluated: QFile::exists(attempt)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:51
3-253
106 -
107 -
108 -
109 -
110 retry = false; -
111 }
executed: }
Execution Count:3
3
112 }
executed: }
Execution Count:311
311
113 }
executed: }
Execution Count:277
277
114 if (!pHnd) {
evaluated: !pHnd
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:253
7-253
115 errorString = QLibrary::tr("Cannot load library %1: %2").arg(fileName).arg(qdlerror()); -
116 }
executed: }
Execution Count:7
7
117 if (pHnd) {
evaluated: pHnd
TRUEFALSE
yes
Evaluation Count:253
yes
Evaluation Count:7
7-253
118 qualifiedFileName = attempt; -
119 errorString.clear(); -
120 }
executed: }
Execution Count:253
253
121 return (pHnd != 0);
executed: return (pHnd != 0);
Execution Count:260
260
122} -
123 -
124bool QLibraryPrivate::unload_sys() -
125{ -
126 -
127 -
128 -
129 -
130 if (dlclose(pHnd)) {
partially evaluated: dlclose(pHnd)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:943
0-943
131 -
132 errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName).arg(qdlerror()); -
133 return false;
never executed: return false;
0
134 } -
135 -
136 errorString.clear(); -
137 return true;
executed: return true;
Execution Count:943
943
138} -
139 -
140 -
141__attribute__((visibility("default"))) QFunctionPointer qt_linux_find_symbol_sys(const char *symbol) -
142{ -
143 return QFunctionPointer(dlsym(((void *) 0), symbol));
never executed: return QFunctionPointer(dlsym(((void *) 0), symbol));
0
144} -
145QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol) -
146{ -
147 QFunctionPointer address = QFunctionPointer(dlsym(pHnd, symbol)); -
148 -
149 if (!address) {
evaluated: !address
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:3427
48-3427
150 errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg( -
151 QString::fromLatin1(symbol)).arg(fileName).arg(qdlerror()); -
152 } else {
executed: }
Execution Count:48
48
153 errorString.clear(); -
154 }
executed: }
Execution Count:3427
3427
155 return address;
executed: return address;
Execution Count:3475
3475
156} -
157 -
158 -
159 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial