1 |
Author: haubi |
2 |
Date: 2008-05-06 17:07:58 +0000 (Tue, 06 May 2008) |
3 |
New Revision: 1629 |
4 |
|
5 |
Modified: |
6 |
trunk/aix-miscutils/ldd/Object.h |
7 |
trunk/aix-miscutils/ldd/ObjectKey.h |
8 |
trunk/aix-miscutils/ldd/ObjectReader.cc |
9 |
trunk/aix-miscutils/ldd/ObjectReader.h |
10 |
trunk/aix-miscutils/ldd/aixdll-query.cc |
11 |
trunk/aix-miscutils/ldd/ldd.cc |
12 |
Log: |
13 |
added cache for nonexistent/broken files (performance factor 10). |
14 |
various minor fixes. |
15 |
|
16 |
Modified: trunk/aix-miscutils/ldd/Object.h |
17 |
=================================================================== |
18 |
--- trunk/aix-miscutils/ldd/Object.h 2008-05-06 13:57:29 UTC (rev 1628) |
19 |
+++ trunk/aix-miscutils/ldd/Object.h 2008-05-06 17:07:58 UTC (rev 1629) |
20 |
@@ -64,7 +64,7 @@ |
21 |
) : key_(key) |
22 |
, flags_() |
23 |
, format_(format) |
24 |
- , resolved_("not found") |
25 |
+ , resolved_() |
26 |
{ |
27 |
std::string::const_iterator start = flags.begin(); |
28 |
std::string::const_iterator end = start; |
29 |
|
30 |
Modified: trunk/aix-miscutils/ldd/ObjectKey.h |
31 |
=================================================================== |
32 |
--- trunk/aix-miscutils/ldd/ObjectKey.h 2008-05-06 13:57:29 UTC (rev 1628) |
33 |
+++ trunk/aix-miscutils/ldd/ObjectKey.h 2008-05-06 17:07:58 UTC (rev 1629) |
34 |
@@ -17,7 +17,13 @@ |
35 |
public: |
36 |
~ObjectPath() {} |
37 |
|
38 |
- ObjectPath(std::string const& path) : std::string(path) {} |
39 |
+ ObjectPath(std::string const& path) |
40 |
+ : std::string(path) |
41 |
+ { |
42 |
+ if (length() > 0 && operator[](length() - 1) != '/') { |
43 |
+ append("/"); |
44 |
+ } |
45 |
+ } |
46 |
|
47 |
std::string const& asIdentifier() const { return *this; } |
48 |
std::string const& string() const { return *this; } |
49 |
|
50 |
Modified: trunk/aix-miscutils/ldd/ObjectReader.cc |
51 |
=================================================================== |
52 |
--- trunk/aix-miscutils/ldd/ObjectReader.cc 2008-05-06 13:57:29 UTC (rev 1628) |
53 |
+++ trunk/aix-miscutils/ldd/ObjectReader.cc 2008-05-06 17:07:58 UTC (rev 1629) |
54 |
@@ -63,15 +63,28 @@ |
55 |
|
56 |
class ObjectReader::Dumper { |
57 |
public: |
58 |
- Dumper(FILE* file) |
59 |
- : file_(file) |
60 |
- {} |
61 |
+ Dumper() : file_(0) {} |
62 |
|
63 |
~Dumper() |
64 |
{ |
65 |
+ close(); |
66 |
+ } |
67 |
+ |
68 |
+ bool open(std::string const& filename) |
69 |
+ { |
70 |
+ std::string dumpcommand = "/usr/bin/dump -Hov -X32_64 '"; |
71 |
+ dumpcommand += filename; |
72 |
+ dumpcommand += "' 2>/dev/null"; |
73 |
+ file_ = popen(dumpcommand.c_str(), "r"); |
74 |
+ return file_ ? true : false; |
75 |
+ } |
76 |
+ |
77 |
+ int close() |
78 |
+ { |
79 |
if (file_) { |
80 |
- pclose(file_); |
81 |
+ return pclose(file_); |
82 |
} |
83 |
+ return -1; |
84 |
} |
85 |
|
86 |
FILE* file() { return file_; } |
87 |
@@ -206,13 +219,17 @@ |
88 |
return rv; |
89 |
} |
90 |
|
91 |
- std::string dumpcommand = "/usr/bin/dump -Hov -X32_64 '"; |
92 |
- dumpcommand += filePath; |
93 |
- dumpcommand += base; |
94 |
- dumpcommand += "' 2>/dev/null"; |
95 |
+ if (brokenFilesCache_.find(filePath + base) != brokenFilesCache_.end()) { |
96 |
+ return 0; |
97 |
+ } |
98 |
|
99 |
- Dumper dumper(popen(dumpcommand.c_str(), "r")); |
100 |
+ Dumper dumper; |
101 |
|
102 |
+ if (! dumper.open(filePath + base)) { |
103 |
+ brokenFilesCache_[filePath + base] = true; |
104 |
+ return 0; |
105 |
+ } |
106 |
+ |
107 |
std::string line; |
108 |
|
109 |
enum { NoSection, ImportFileStrings, ObjectModuleHeader } section = NoSection; |
110 |
@@ -322,6 +339,10 @@ |
111 |
} |
112 |
} |
113 |
|
114 |
+ if (dumper.close() != 0 && rv == 0) { |
115 |
+ brokenFilesCache_[filePath + base] = true; |
116 |
+ } |
117 |
+ |
118 |
return rv; |
119 |
} |
120 |
|
121 |
|
122 |
Modified: trunk/aix-miscutils/ldd/ObjectReader.h |
123 |
=================================================================== |
124 |
--- trunk/aix-miscutils/ldd/ObjectReader.h 2008-05-06 13:57:29 UTC (rev 1628) |
125 |
+++ trunk/aix-miscutils/ldd/ObjectReader.h 2008-05-06 17:07:58 UTC (rev 1629) |
126 |
@@ -30,6 +30,7 @@ |
127 |
void parseRunpathDeplibs(Dumper *dumper, SharedObjectPtr &object) const; |
128 |
|
129 |
std::map<std::string, ObjectPtr> objectCache_; |
130 |
+ std::map<std::string, bool> brokenFilesCache_; |
131 |
|
132 |
typedef std::vector<std::string> LibraryMemberNameContainer; |
133 |
typedef std::map<std::string, LibraryMemberNameContainer> LibraryMemberCache; |
134 |
|
135 |
Modified: trunk/aix-miscutils/ldd/aixdll-query.cc |
136 |
=================================================================== |
137 |
--- trunk/aix-miscutils/ldd/aixdll-query.cc 2008-05-06 13:57:29 UTC (rev 1628) |
138 |
+++ trunk/aix-miscutils/ldd/aixdll-query.cc 2008-05-06 17:07:58 UTC (rev 1629) |
139 |
@@ -29,12 +29,13 @@ |
140 |
; o != objects.end() |
141 |
; o++ |
142 |
) { |
143 |
- if (questions.find("FILE") != questions.end()) std::cout |
144 |
- << " FILE='" |
145 |
- << (*o)->key()->path()->asIdentifier() |
146 |
- << (*o)->key()->name()->base() |
147 |
- << "';" |
148 |
- ; |
149 |
+ if (questions.find("FILE") != questions.end()) { |
150 |
+ std::cout << " FILE='"; |
151 |
+ if ((*o)->key()->path()) { |
152 |
+ std::cout << (*o)->key()->path()->asIdentifier(); |
153 |
+ } |
154 |
+ std::cout << (*o)->key()->name()->base() << "';"; |
155 |
+ } |
156 |
if (questions.find("MEMBER") != questions.end()) std::cout |
157 |
<< " MEMBER='" |
158 |
<< (*o)->key()->name()->member() |
159 |
|
160 |
Modified: trunk/aix-miscutils/ldd/ldd.cc |
161 |
=================================================================== |
162 |
--- trunk/aix-miscutils/ldd/ldd.cc 2008-05-06 13:57:29 UTC (rev 1628) |
163 |
+++ trunk/aix-miscutils/ldd/ldd.cc 2008-05-06 17:07:58 UTC (rev 1629) |
164 |
@@ -138,10 +138,21 @@ |
165 |
; r != resolved.end() |
166 |
; r++ |
167 |
) { |
168 |
- std::cout << " " << (*r)->key()->asIdentifier() |
169 |
- << " => " |
170 |
- << (*r)->getResolved() |
171 |
- << std::endl; |
172 |
+ std::cout << " "; // tab |
173 |
+ if ((*r)->getResolved().length() == 0) { |
174 |
+ std::cout |
175 |
+ << (*r)->key()->asIdentifier() |
176 |
+ << " => not found" |
177 |
+ ; |
178 |
+ } else |
179 |
+ if ((*r)->key()->path()) { |
180 |
+ std::cout << (*r)->getResolved(); |
181 |
+ } else { |
182 |
+ std::cout |
183 |
+ << (*r)->key()->asIdentifier() |
184 |
+ << " => " << (*r)->getResolved(); |
185 |
+ } |
186 |
+ std::cout << std::endl; |
187 |
} |
188 |
} |
189 |
|
190 |
|
191 |
-- |
192 |
gentoo-commits@l.g.o mailing list |