mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Bug 1438866 - Add some utility code to help with debugging. r=emilio
This adds an RAII class and macro that can be quickly added in functions to log entry/exit from the function. This is useful to debugging. MozReview-Commit-ID: 4Ud8jLOxI0R --HG-- extra : rebase_source : 518d30fe44dff67bffb186e23c1eb858c02280af
This commit is contained in:
parent
31c634d913
commit
87bfbc06cf
@ -69,6 +69,20 @@ static bool isValidIdentifier(std::string Input) {
|
||||
return true;
|
||||
}
|
||||
|
||||
struct RAIITracer {
|
||||
RAIITracer(const char *log) : mLog(log) {
|
||||
printf("<%s>\n", mLog);
|
||||
}
|
||||
|
||||
~RAIITracer() {
|
||||
printf("</%s>\n", mLog);
|
||||
}
|
||||
|
||||
const char* mLog;
|
||||
};
|
||||
|
||||
#define TRACEFUNC RAIITracer tracer(__FUNCTION__);
|
||||
|
||||
class IndexConsumer;
|
||||
|
||||
// For each C++ file seen by the analysis (.cpp or .h), we track a
|
||||
@ -444,6 +458,10 @@ public:
|
||||
// in different ways are analyzed completely.
|
||||
char Buffer[65536];
|
||||
FILE *Fp = Lock.openFile("r");
|
||||
if (!Fp) {
|
||||
fprintf(stderr, "Unable to open input file %s\n", Filename.c_str());
|
||||
exit(1);
|
||||
}
|
||||
while (fgets(Buffer, sizeof(Buffer), Fp)) {
|
||||
Lines.push_back(std::string(Buffer));
|
||||
}
|
||||
@ -460,6 +478,10 @@ public:
|
||||
// Overwrite the output file with the merged data. Since we have the lock,
|
||||
// this will happen atomically.
|
||||
Fp = Lock.openFile("w");
|
||||
if (!Fp) {
|
||||
fprintf(stderr, "Unable to open output file %s\n", Filename.c_str());
|
||||
exit(1);
|
||||
}
|
||||
size_t Length = 0;
|
||||
for (std::string &Line : Nodupes) {
|
||||
Length += Line.length();
|
||||
|
Loading…
x
Reference in New Issue
Block a user