| The Gaudi Framework v30r0 (c919700c)

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

## Member Typedef Documentation

typedef int FileInfo::Offset

Definition at line 159 of file pfm_gen_analysis.cpp.

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

Definition at line 205 of file pfm_gen_analysis.cpp.

## Constructor & Destructor Documentation

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

Definition at line 161 of file pfm_gen_analysis.cpp.

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

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

Definition at line 162 of file pfm_gen_analysis.cpp.

162 : NAME( name )
163 {
164 if ( useGdb ) {
165 this->createOffsetMap();
166 }
167 }
FileInfo::NAME
std::string NAME
Definition: pfm_gen_analysis.cpp:160
FileInfo::createOffsetMap
void createOffsetMap(void)
Definition: pfm_gen_analysis.cpp:213

## Member Function Documentation

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

Definition at line 213 of file pfm_gen_analysis.cpp.

214 {
215 std::string commandLine = "objdump -p " + NAME;
216 PipeReader objdump( commandLine.c_str() );
217 std::string oldname;
218 std::string suffix;
219 int vmbase = 0;
220 bool matched = false;
221 while ( objdump.output() ) {
222 // Checks the following regexp
223 //
224 // LOAD\\s+off\\s+(0x[0-9A-Fa-f]+)\\s+vaddr\\s+(0x[0-9A-Fa-f]+)
225 //
226 // and sets vmbase to be $2 - $1 of the first matched entry.
227
228 std::string line;
229 std::getline( objdump.output(), line );
230
231 if ( !objdump.output() ) break;
232 if ( line.empty() ) continue;
233 const char* lineptr = line.c_str();
234 if ( !skipWhitespaces( lineptr, &lineptr ) ) continue;
235 if ( !skipString( "LOAD", lineptr, &lineptr ) ) continue;
236 if ( !skipWhitespaces( lineptr, &lineptr ) ) continue;
237 if ( !skipString( "off", lineptr, &lineptr ) ) continue;
238 char* endptr = 0;
239 int initialBase = strtol( lineptr, &endptr, 16 );
240 if ( lineptr == endptr ) continue;
241 lineptr = endptr;
242 if ( !skipWhitespaces( lineptr, &lineptr ) ) continue;
243 if ( !skipString( "vaddr", lineptr, &lineptr ) ) continue;
244 if ( !skipWhitespaces( lineptr, &lineptr ) ) continue;
245 int finalBase = strtol( lineptr, &endptr, 16 );
246 if ( lineptr == endptr ) continue;
247 vmbase = finalBase - initialBase;
248 matched = true;
249 break;
250 }
251 if ( !matched ) {
252 fprintf( stderr, "Cannot determine VM base address for %s\n", NAME.c_str() );
253 fprintf( stderr, "Error while running `objdump -p %s`\n", NAME.c_str() );
254 exit( 1 );
255 }
256 std::string commandLine2 = "nm -t d -n " + NAME;
257 PipeReader nm( commandLine2.c_str() );
258 while ( nm.output() ) {
259 std::string line;
260 std::getline( nm.output(), line );
261 if ( !nm.output() ) break;
262 if ( line.empty() ) continue;
263 // If line does not match "^(\\d+)[ ]\\S[ ](\S+)$", exit.
264 const char* begin = line.c_str();
265 char* endptr = 0;
266 int address = strtol( begin, &endptr, 10 );
267 if ( endptr == begin ) continue;
268 if ( *endptr++ != ' ' ) continue;
269 if ( isspace( *endptr++ ) ) continue;
270 if ( *endptr++ != ' ' ) continue;
271 char* symbolName = endptr;
272 while ( *endptr && !isspace( *endptr ) ) endptr++;
273 if ( *endptr != 0 ) continue;
274 // If line starts with '.' forget about it.
275 if ( symbolName[0] == '.' ) continue;
276 // Create a new symbol with the given fileoffset.
277 // The symbol is automatically saved in the FileInfo cache by offset.
278 // If a symbol with the same offset is already there, the new one
279 // replaces the old one.
280 int offset = address - vmbase;
281 if ( m_symbolCache.size() && ( m_symbolCache.back().OFFSET == offset ) )
282 m_symbolCache.back().NAME = symbolName;
283 else
284 m_symbolCache.push_back( CacheItem( address - vmbase, symbolName ) );
285 }
286 }
std::string::empty
T empty(T...args)
skipString
bool skipString(const char *strptr, const char *srcbuffer, const char **dstbuffer)
Definition: pfm_gen_analysis.cpp:147
std::getline
T getline(T...args)
FileInfo::NAME
std::string NAME
Definition: pfm_gen_analysis.cpp:160
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:58
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:83
std::vector::size
T size(T...args)
FileInfo::CacheItem::NAME
std::string NAME
Definition: pfm_gen_analysis.cpp:202
FileInfo::m_symbolCache
SymbolCache m_symbolCache
Definition: pfm_gen_analysis.cpp:206
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:200
std::vector::back
T back(T...args)
skipWhitespaces
bool skipWhitespaces(const char *srcbuffer, const char **destbuffer)
Definition: pfm_gen_analysis.cpp:128
std::fprintf
T fprintf(T...args)
std::isspace
T isspace(T...args)
plotSpeedupsPyRoot.line
line
Definition: plotSpeedupsPyRoot.py:172

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

Definition at line 189 of file pfm_gen_analysis.cpp.

190 {
191 SymbolCache::iterator i = upper_bound( m_symbolCache.begin(), m_symbolCache.end(), offset, CacheItemComparator() );
192 if ( i == m_symbolCache.end() ) {
193 return 0;
194 }
195 return i->OFFSET;
196 }
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:206

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

Definition at line 169 of file pfm_gen_analysis.cpp.

170 {
171 if ( m_symbolCache.empty() ) {
172 return 0;
173 }
174
175 SymbolCache::iterator i = lower_bound( m_symbolCache.begin(), m_symbolCache.end(), offset, CacheItemComparator() );
176 if ( i->OFFSET == offset ) {
177 return i->NAME.c_str();
178 }
179
180 if ( i == m_symbolCache.begin() ) {
181 return m_symbolCache.begin()->NAME.c_str();
182 }
183
184 --i;
185
186 return i->NAME.c_str();
187 }
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:202
std::vector::begin
T begin(T...args)
FileInfo::m_symbolCache
SymbolCache m_symbolCache
Definition: pfm_gen_analysis.cpp:206
std::string::c_str
T c_str(T...args)

## Member Data Documentation

SymbolCache FileInfo::m_symbolCache
| private

Definition at line 206 of file pfm_gen_analysis.cpp.

std::string FileInfo::NAME

Definition at line 160 of file pfm_gen_analysis.cpp.

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

- GaudiProfiling/src/app/pfm_gen_analysis.cpp