2001-10-18 20:19:09 +00:00
|
|
|
//===- llvm/Transforms/Instrumentation/TraceValues.h - Tracing ---*- C++ -*--=//
|
|
|
|
//
|
|
|
|
// Support for inserting LLVM code to print values at basic block and method
|
|
|
|
// exits.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-10-14 23:19:02 +00:00
|
|
|
|
|
|
|
#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_TRACEVALUES_H
|
|
|
|
#define LLVM_TRANSFORMS_INSTRUMENTATION_TRACEVALUES_H
|
|
|
|
|
2001-10-18 20:19:09 +00:00
|
|
|
#include "llvm/Pass.h"
|
2001-12-14 16:23:53 +00:00
|
|
|
class Method;
|
2001-10-15 17:30:18 +00:00
|
|
|
|
2002-01-21 07:31:50 +00:00
|
|
|
class InsertTraceCode : public MethodPass {
|
2001-10-15 17:30:18 +00:00
|
|
|
bool TraceBasicBlockExits, TraceMethodExits;
|
2001-12-14 16:23:53 +00:00
|
|
|
Method *PrintfMeth;
|
2001-10-15 17:30:18 +00:00
|
|
|
public:
|
|
|
|
InsertTraceCode(bool traceBasicBlockExits, bool traceMethodExits)
|
|
|
|
: TraceBasicBlockExits(traceBasicBlockExits),
|
|
|
|
TraceMethodExits(traceMethodExits) {}
|
|
|
|
|
2001-12-14 16:23:53 +00:00
|
|
|
// Add a prototype for printf if it is not already in the program.
|
|
|
|
//
|
2002-01-21 07:31:50 +00:00
|
|
|
bool doInitialization(Module *M);
|
2001-10-18 05:22:27 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
// Function InsertCodeToTraceValues
|
|
|
|
//
|
|
|
|
// Inserts tracing code for all live values at basic block and/or method exits
|
|
|
|
// as specified by `traceBasicBlockExits' and `traceMethodExits'.
|
2001-10-18 20:19:09 +00:00
|
|
|
//
|
2001-12-14 16:23:53 +00:00
|
|
|
static bool doit(Method *M, bool traceBasicBlockExits,
|
|
|
|
bool traceMethodExits, Method *Printf);
|
2001-10-18 05:22:27 +00:00
|
|
|
|
2002-01-21 07:31:50 +00:00
|
|
|
// runOnMethod - This method does the work. Always successful.
|
2001-10-15 17:30:18 +00:00
|
|
|
//
|
2002-01-21 07:31:50 +00:00
|
|
|
bool runOnMethod(Method *M) {
|
2001-12-14 16:23:53 +00:00
|
|
|
return doit(M, TraceBasicBlockExits, TraceMethodExits, PrintfMeth);
|
2001-10-15 17:30:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2001-12-14 16:23:53 +00:00
|
|
|
#endif
|