| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
FileInfo Class Reference
Collaboration diagram for FileInfo:
[legend]

## Classes
struct | CacheItem
struct | CacheItemComparator

## Public Types
typedef int | Offset

## Public Member Functions
| FileInfo (void)
| FileInfo (const std::string &name, bool useGdb)
const char * | symbolByOffset (Offset offset)
Offset | next (Offset offset)

## Public Attributes
std::string | NAME

## Private Types
typedef std::vector< CacheItem > | SymbolCache

## Private Member Functions
void | createOffsetMap (void)

## Private Attributes
SymbolCache | m_symbolCache

## Detailed Description

Definition at line 164 of file pfm_gen_analysis.cpp.

## Member Typedef Documentation

typedef int FileInfo::Offset

Definition at line 167 of file pfm_gen_analysis.cpp.

typedef std::vector<CacheItem> FileInfo::SymbolCache
| private

Definition at line 219 of file pfm_gen_analysis.cpp.

## Constructor & Destructor Documentation

FileInfo::FileInfo | ( | void |  | ) |
| inline

Definition at line 169 of file pfm_gen_analysis.cpp.

169 : NAME("<dynamically generated>") {}
FileInfo::NAME
std::string NAME
Definition: pfm_gen_analysis.cpp:168

FileInfo::FileInfo | ( | const std::string & | name,
|  | bool | useGdb
| ) |  |
| inline

Definition at line 170 of file pfm_gen_analysis.cpp.

170 : NAME(name)
171 {
172 if(useGdb)
173 {
174 this->createOffsetMap();
175 }
176 }
FileInfo::NAME
std::string NAME
Definition: pfm_gen_analysis.cpp:168
FileInfo::createOffsetMap
void createOffsetMap(void)
Definition: pfm_gen_analysis.cpp:234

## Member Function Documentation

void FileInfo::createOffsetMap | ( | void |  | ) |
| inline private

Definition at line 234 of file pfm_gen_analysis.cpp.

235 {
236 std::string commandLine = "objdump -p " + NAME;
237 PipeReader objdump(commandLine.c_str());
238 std::string oldname;
239 std::string suffix;
240 int vmbase = 0;
241 bool matched = false;
242 while(objdump.output())
243 {
244 // Checks the following regexp
245 //
246 // LOAD\\s+off\\s+(0x[0-9A-Fa-f]+)\\s+vaddr\\s+(0x[0-9A-Fa-f]+)
247 //
248 // and sets vmbase to be $2 - $1 of the first matched entry.
249
250 std::string line;
251 std::getline(objdump.output(), line);
252
253 if(!objdump.output()) break;
254 if(line.empty()) continue;
255 const char *lineptr = line.c_str();
256 if(!skipWhitespaces(lineptr, &lineptr)) continue;
257 if(!skipString("LOAD", lineptr, &lineptr)) continue;
258 if(!skipWhitespaces(lineptr, &lineptr)) continue;
259 if(!skipString("off", lineptr, &lineptr)) continue;
260 char *endptr = 0;
261 int initialBase = strtol(lineptr, &endptr, 16);
262 if(lineptr == endptr) continue;
263 lineptr = endptr;
264 if(!skipWhitespaces(lineptr, &lineptr)) continue;
265 if(!skipString("vaddr", lineptr, &lineptr)) continue;
266 if(!skipWhitespaces(lineptr, &lineptr)) continue;
267 int finalBase = strtol(lineptr, &endptr, 16);
268 if(lineptr == endptr) continue;
269 vmbase=finalBase - initialBase;
270 matched = true;
271 break;
272 }
273 if(!matched)
274 {
275 fprintf(stderr, "Cannot determine VM base address for %s\n", NAME.c_str());
276 fprintf(stderr, "Error while running `objdump -p %s`\n", NAME.c_str());
277 exit(1);
278 }
279 std::string commandLine2 = "nm -t d -n " + NAME;
280 PipeReader nm(commandLine2.c_str());
281 while(nm.output())
282 {
283 std::string line;
284 std::getline(nm.output(), line);
285 if(!nm.output()) break;
286 if(line.empty()) continue;
287 // If line does not match "^(\\d+)[ ]\\S[ ](\S+)$", exit.
288 const char *begin = line.c_str();
289 char *endptr = 0;
290 int address = strtol(begin, &endptr, 10);
291 if(endptr == begin) continue;
292 if(*endptr++ != ' ') continue;
293 if(isspace(*endptr++)) continue;
294 if(*endptr++ != ' ') continue;
295 char *symbolName = endptr;
296 while(*endptr && !isspace(*endptr)) endptr++;
297 if(*endptr != 0) continue;
298 // If line starts with '.' forget about it.
299 if(symbolName[0] == '.') continue;
300 // Create a new symbol with the given fileoffset.
301 // The symbol is automatically saved in the FileInfo cache by offset.
302 // If a symbol with the same offset is already there, the new one
303 // replaces the old one.
304 int offset = address-vmbase;
305 if(m_symbolCache.size() && (m_symbolCache.back().OFFSET == offset)) m_symbolCache.back().NAME = symbolName;
306 else m_symbolCache.push_back(CacheItem(address-vmbase, symbolName));
307 }
308 }
std::string::empty
T empty(T...args)
skipString
bool skipString(const char *strptr, const char *srcbuffer, const char **dstbuffer)
Definition: pfm_gen_analysis.cpp:154
std::getline
T getline(T...args)
FileInfo::NAME
std::string NAME
Definition: pfm_gen_analysis.cpp:168
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:48
std::string
STL class.
std::vector::push_back
T push_back(T...args)
PipeReader
Definition: pfm_gen_analysis.cpp:89
std::exit
T exit(T...args)
Gaudi::Units::nm
constexpr double nm
Definition: SystemOfUnits.h:82
std::vector::size
T size(T...args)
FileInfo::CacheItem::NAME
std::string NAME
Definition: pfm_gen_analysis.cpp:216
FileInfo::m_symbolCache
SymbolCache m_symbolCache
Definition: pfm_gen_analysis.cpp:220
std::string::c_str
T c_str(T...args)
std::strtol
T strtol(T...args)
FileInfo::CacheItem::OFFSET
Offset OFFSET
Definition: pfm_gen_analysis.cpp:214
std::vector::back
T back(T...args)
skipWhitespaces
bool skipWhitespaces(const char *srcbuffer, const char **destbuffer)
Definition: pfm_gen_analysis.cpp:133
std::fprintf
T fprintf(T...args)
std::isspace
T isspace(T...args)
plotSpeedupsPyRoot.line
line
Definition: plotSpeedupsPyRoot.py:164

Offset FileInfo::next | ( | Offset | offset | ) |
| inline

Definition at line 201 of file pfm_gen_analysis.cpp.

202 {
203 SymbolCache::iterator i = upper_bound(m_symbolCache.begin(), m_symbolCache.end(), offset, CacheItemComparator());
204 if(i == m_symbolCache.end())
205 {
206 return 0;
207 }
208 return i->OFFSET;
209 }
std::upper_bound
T upper_bound(T...args)
std::vector::end
T end(T...args)
std::vector::begin
T begin(T...args)
FileInfo::m_symbolCache
SymbolCache m_symbolCache
Definition: pfm_gen_analysis.cpp:220

const char* FileInfo::symbolByOffset | ( | Offset | offset | ) |
| inline

Definition at line 178 of file pfm_gen_analysis.cpp.

179 {
180 if(m_symbolCache.empty())
181 {
182 return 0;
183 }
184
185 SymbolCache::iterator i = lower_bound(m_symbolCache.begin(), m_symbolCache.end(), offset, CacheItemComparator());
186 if(i->OFFSET == offset)
187 {
188 return i->NAME.c_str();
189 }
190
191 if(i == m_symbolCache.begin())
192 {
193 return m_symbolCache.begin()->NAME.c_str();
194 }
195
196 --i;
197
198 return i->NAME.c_str();
199 }
std::vector::empty
T empty(T...args)
std::vector::end
T end(T...args)
std::lower_bound
T lower_bound(T...args)
FileInfo::CacheItem::NAME
std::string NAME
Definition: pfm_gen_analysis.cpp:216
std::vector::begin
T begin(T...args)
FileInfo::m_symbolCache
SymbolCache m_symbolCache
Definition: pfm_gen_analysis.cpp:220
std::string::c_str
T c_str(T...args)

## Member Data Documentation

SymbolCache FileInfo::m_symbolCache
| private

Definition at line 220 of file pfm_gen_analysis.cpp.

std::string FileInfo::NAME

Definition at line 168 of file pfm_gen_analysis.cpp.

The documentation for this class was generated from the following file:

- GaudiProfiling/src/app/pfm_gen_analysis.cpp