19 #include <QCoreApplication>
20 #include <QTextStream>
32 void showHelp(QTextStream& out,
bool fullHelp =
true)
34 out <<
"Show profiles from callgrind files. (C) 2010 J. Weidendorfer\n";
37 out <<
"Type 'cgview -h' for help." << endl;
39 out <<
"Usage: cgview [options] <file> ...\n\n"
41 " -h Show this help text\n"
42 " -e Sort list according to exclusive cost\n"
43 " -s <ev> Sort and show counters for event <ev>\n"
44 " -c Sort by call count\n"
45 " -b Show butterfly (callers and callees)\n"
46 " -n Do not detect recursive cycles" << endl;
52 int main(
int argc,
char** argv)
54 QCoreApplication app(argc, argv);
55 QTextStream out(stdout);
61 QStringList list = app.arguments();
63 if (list.isEmpty())
showHelp(out,
false);
65 bool sortByExcl =
false;
66 bool sortByCount =
false;
67 bool showCalls =
false;
71 for(
int arg = 0; arg<list.count(); arg++) {
72 if (list[arg] ==
"-h")
showHelp(out);
73 else if (list[arg] ==
"-e") sortByExcl =
true;
75 else if (list[arg] ==
"-b") showCalls =
true;
76 else if (list[arg] ==
"-c") sortByCount =
true;
77 else if (list[arg] ==
"-s") showEvent = list[++arg];
86 out <<
"Error: No event types found." << endl;
90 out <<
"\nTotals for event types:\n";
96 out.setFieldWidth(14);
97 out.setFieldAlignment(QTextStream::AlignRight);
100 out <<
" " << et->
longName() <<
" (" << et->
name() <<
")\n";
104 out.setFieldWidth(14);
105 out.setFieldAlignment(QTextStream::AlignRight);
107 out.setFieldWidth(0);
109 " (" << et->
name() <<
" = " << et->
formula() <<
")\n";
113 if (showEvent.isEmpty())
116 et = m->
type(showEvent);
118 out <<
"Error: event '" << showEvent <<
"' not found." << endl;
123 out <<
"Sorted by: " << (sortByExcl ?
"Exclusive ":
"Inclusive ")
129 TraceFunctionMap::Iterator it;
131 flist.append(&(*it));
147 out <<
"\n Inclusive Exclusive Called Function name (DSO)\n";
148 out <<
" ==================================================================\n";
150 out.setFieldAlignment(QTextStream::AlignRight);
155 if (i>0) out << endl;
158 out.setFieldWidth(14);
160 out.setFieldWidth(0);
162 out.setFieldWidth(13);
164 out.setFieldWidth(0);
169 out.setFieldWidth(14);
172 out.setFieldWidth(13);
174 out.setFieldWidth(0);
175 out <<
" " << f->
name() <<
" (" << f->
object()->
name() <<
")" << endl;
180 out.setFieldWidth(14);
182 out.setFieldWidth(0);
184 out.setFieldWidth(13);
186 out.setFieldWidth(0);
SubCost subCost(EventType *)
Returns a sub cost.
static void setStorage(ConfigStorage *)
const TraceCallList & callings(bool skipCycle=false) const
TraceFunction * caller(bool skipCycle=false) const
static void initLoaders()
TraceObject * object() const
static GlobalConfig * config()
EventTypeSet * eventTypes()
TraceCallList callers(bool skipCycle=false) const
static void setShowCycles(bool)
A class to calculate the ProfileCostArray items with highest cost.
int load(QStringList files)
Loads profile data files.
const TraceFunctionCycleList & functionCycles()
const QString & formula()
QString prettyCallCount()
This is an adapter class for different configuration backends.
virtual QString name() const
Returns dynamic name info (without type)
QString prettyName() const
Similar to name, but prettyfied = more descriptive to humans.
void showHelp(QTextStream &out, bool fullHelp=true)
void addCost(ProfileCostArray *, SubCost)
EventType * realType(int)
TraceFunction * called(bool skipCycle=false) const
const QString & longName()
QString pretty(char sep= ' ') const
Convert SubCost value into a QString, spaced every 3 digits.
A class for managing a set of event types.
TraceFunctionMap & functionMap()
This class holds profiling data of multiple tracefiles generated with cachegrind on one command...
EventType * derivedType(int)
A call from one to another function.
QString prettyCalledCount()
ProfileCostArray * inclusive()
int main(int argc, char **argv)