| The Gaudi Framework v27r1

- 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 163 of file pfm_gen_analysis.cpp.

## Member Typedef Documentation

typedef int FileInfo::Offset

Definition at line 166 of file pfm_gen_analysis.cpp.

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

Definition at line 218 of file pfm_gen_analysis.cpp.

## Constructor & Destructor Documentation

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

Definition at line 168 of file pfm_gen_analysis.cpp.

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

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

Definition at line 169 of file pfm_gen_analysis.cpp.

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

## Member Function Documentation

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

Definition at line 233 of file pfm_gen_analysis.cpp.

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

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

Definition at line 200 of file pfm_gen_analysis.cpp.

201 {
202 SymbolCache::iterator i = upper_bound(m_symbolCache.begin(), m_symbolCache.end(), offset, CacheItemComparator());
203 if(i == m_symbolCache.end())
204 {
205 return 0;
206 }
207 return i->OFFSET;
208 }
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:219
ana.i
list i
Definition: ana.py:128

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

Definition at line 177 of file pfm_gen_analysis.cpp.

178 {
179 if(m_symbolCache.empty())
180 {
181 return 0;
182 }
183
184 SymbolCache::iterator i = lower_bound(m_symbolCache.begin(), m_symbolCache.end(), offset, CacheItemComparator());
185 if(i->OFFSET == offset)
186 {
187 return i->NAME.c_str();
188 }
189
190 if(i == m_symbolCache.begin())
191 {
192 return m_symbolCache.begin()->NAME.c_str();
193 }
194
195 --i;
196
197 return i->NAME.c_str();
198 }
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:215
std::vector::begin
T begin(T...args)
FileInfo::m_symbolCache
SymbolCache m_symbolCache
Definition: pfm_gen_analysis.cpp:219
std::string::c_str
T c_str(T...args)
ana.i
list i
Definition: ana.py:128

## Member Data Documentation

SymbolCache FileInfo::m_symbolCache
| private

Definition at line 219 of file pfm_gen_analysis.cpp.

std::string FileInfo::NAME

Definition at line 167 of file pfm_gen_analysis.cpp.

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

- GaudiProfiling/src/app/pfm_gen_analysis.cpp