2016-01-15 03:25:04 +08:00
|
|
|
//===-- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h ----*- C++ -*--===//
|
2014-01-30 09:39:17 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2016-01-15 03:25:04 +08:00
|
|
|
// This file contains support for writing Microsoft CodeView debug info.
|
2014-01-30 09:39:17 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-01-15 03:25:04 +08:00
|
|
|
#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_CODEVIEWDEBUG_H
|
|
|
|
#define LLVM_LIB_CODEGEN_ASMPRINTER_CODEVIEWDEBUG_H
|
2014-01-30 09:39:17 +08:00
|
|
|
|
|
|
|
#include "AsmPrinterHandler.h"
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
#include "llvm/ADT/StringMap.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
2014-03-04 18:07:28 +08:00
|
|
|
#include "llvm/CodeGen/LexicalScopes.h"
|
2014-01-30 09:39:17 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
2014-03-06 08:46:21 +08:00
|
|
|
#include "llvm/IR/DebugInfo.h"
|
2014-03-05 18:30:38 +08:00
|
|
|
#include "llvm/IR/DebugLoc.h"
|
2014-01-30 09:39:17 +08:00
|
|
|
#include "llvm/MC/MCStreamer.h"
|
|
|
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
/// \brief Collects and handles line tables information in a CodeView format.
|
2016-01-15 03:25:04 +08:00
|
|
|
class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public AsmPrinterHandler {
|
2014-01-30 09:39:17 +08:00
|
|
|
AsmPrinter *Asm;
|
|
|
|
DebugLoc PrevInstLoc;
|
|
|
|
|
|
|
|
// For each function, store a vector of labels to its instructions, as well as
|
|
|
|
// to the end of the function.
|
|
|
|
struct FunctionInfo {
|
2016-01-16 08:09:09 +08:00
|
|
|
DebugLoc LastLoc;
|
2016-01-29 08:49:42 +08:00
|
|
|
MCSymbol *End = nullptr;
|
|
|
|
unsigned FuncId = 0;
|
|
|
|
unsigned LastFileId;
|
|
|
|
bool HaveLineInfo = false;
|
2016-01-16 08:09:09 +08:00
|
|
|
};
|
|
|
|
FunctionInfo *CurFn;
|
2014-01-30 09:39:17 +08:00
|
|
|
|
2016-01-29 08:49:42 +08:00
|
|
|
unsigned NextFuncId = 0;
|
|
|
|
|
|
|
|
/// Remember some debug info about each function. Keep it in a stable order to
|
|
|
|
/// emit at the end of the TU.
|
|
|
|
MapVector<const Function *, FunctionInfo> FnDebugInfo;
|
|
|
|
|
|
|
|
/// Map from DIFile to .cv_file id.
|
|
|
|
DenseMap<const DIFile *, unsigned> FileIdMap;
|
2014-01-30 09:39:17 +08:00
|
|
|
|
2016-01-16 08:09:09 +08:00
|
|
|
typedef std::map<const DIFile *, std::string> FileToFilepathMapTy;
|
|
|
|
FileToFilepathMapTy FileToFilepathMap;
|
|
|
|
StringRef getFullFilepath(const DIFile *S);
|
2014-01-30 09:39:17 +08:00
|
|
|
|
2016-01-29 08:49:42 +08:00
|
|
|
unsigned maybeRecordFile(const DIFile *F);
|
|
|
|
|
2014-01-30 09:39:17 +08:00
|
|
|
void maybeRecordLocation(DebugLoc DL, const MachineFunction *MF);
|
|
|
|
|
|
|
|
void clear() {
|
2014-04-28 12:05:08 +08:00
|
|
|
assert(CurFn == nullptr);
|
2016-01-29 08:49:42 +08:00
|
|
|
FileIdMap.clear();
|
|
|
|
FnDebugInfo.clear();
|
|
|
|
FileToFilepathMap.clear();
|
2014-01-30 09:39:17 +08:00
|
|
|
}
|
|
|
|
|
2016-01-29 08:49:42 +08:00
|
|
|
void emitDebugInfoForFunction(const Function *GV, FunctionInfo &FI);
|
2014-01-30 09:39:17 +08:00
|
|
|
|
|
|
|
public:
|
2016-01-15 03:25:04 +08:00
|
|
|
CodeViewDebug(AsmPrinter *Asm);
|
2014-01-30 09:39:17 +08:00
|
|
|
|
2014-03-08 14:31:39 +08:00
|
|
|
void setSymbolSize(const llvm::MCSymbol *, uint64_t) override {}
|
2014-01-30 09:39:17 +08:00
|
|
|
|
|
|
|
/// \brief Emit the COFF section that holds the line table information.
|
2014-03-08 14:31:39 +08:00
|
|
|
void endModule() override;
|
2014-01-30 09:39:17 +08:00
|
|
|
|
|
|
|
/// \brief Gather pre-function debug information.
|
2014-03-08 14:31:39 +08:00
|
|
|
void beginFunction(const MachineFunction *MF) override;
|
2014-01-30 09:39:17 +08:00
|
|
|
|
|
|
|
/// \brief Gather post-function debug information.
|
2014-03-08 14:31:39 +08:00
|
|
|
void endFunction(const MachineFunction *) override;
|
2014-01-30 09:39:17 +08:00
|
|
|
|
|
|
|
/// \brief Process beginning of an instruction.
|
2014-03-08 14:31:39 +08:00
|
|
|
void beginInstruction(const MachineInstr *MI) override;
|
2014-01-30 09:39:17 +08:00
|
|
|
|
|
|
|
/// \brief Process end of an instruction.
|
2014-03-08 14:31:39 +08:00
|
|
|
void endInstruction() override {}
|
2014-01-30 09:39:17 +08:00
|
|
|
};
|
|
|
|
} // End of namespace llvm
|
|
|
|
|
|
|
|
#endif
|