mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-24 23:19:03 +00:00
While printing annotations, print line number and variable name if debug info is present.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127470 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
LEVEL = ../..
|
LEVEL = ../..
|
||||||
|
|
||||||
TOOLNAME = llvm-dis
|
TOOLNAME = llvm-dis
|
||||||
LINK_COMPONENTS := bitreader
|
LINK_COMPONENTS := bitreader analysis
|
||||||
|
|
||||||
# This tool has no plugins, optimize startup time.
|
# This tool has no plugins, optimize startup time.
|
||||||
TOOL_NO_EXPORTS = 1
|
TOOL_NO_EXPORTS = 1
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
#include "llvm/LLVMContext.h"
|
#include "llvm/LLVMContext.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
|
#include "llvm/IntrinsicInst.h"
|
||||||
#include "llvm/Bitcode/ReaderWriter.h"
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
|
#include "llvm/Analysis/DebugInfo.h"
|
||||||
#include "llvm/Assembly/AssemblyAnnotationWriter.h"
|
#include "llvm/Assembly/AssemblyAnnotationWriter.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/FormattedStream.h"
|
#include "llvm/Support/FormattedStream.h"
|
||||||
@@ -50,6 +52,16 @@ ShowAnnotations("show-annotations",
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
static void printDebugLoc(const DebugLoc &DL, formatted_raw_ostream &OS) {
|
||||||
|
OS << DL.getLine() << ":" << DL.getCol();
|
||||||
|
if (MDNode *N = DL.getInlinedAt(getGlobalContext())) {
|
||||||
|
DebugLoc IDL = DebugLoc::getFromDILocation(N);
|
||||||
|
if (!IDL.isUnknown()) {
|
||||||
|
OS << "@";
|
||||||
|
printDebugLoc(IDL,OS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
class CommentWriter : public AssemblyAnnotationWriter {
|
class CommentWriter : public AssemblyAnnotationWriter {
|
||||||
public:
|
public:
|
||||||
void emitFunctionAnnot(const Function *F,
|
void emitFunctionAnnot(const Function *F,
|
||||||
@@ -58,10 +70,43 @@ public:
|
|||||||
OS << '\n';
|
OS << '\n';
|
||||||
}
|
}
|
||||||
void printInfoComment(const Value &V, formatted_raw_ostream &OS) {
|
void printInfoComment(const Value &V, formatted_raw_ostream &OS) {
|
||||||
if (V.getType()->isVoidTy()) return;
|
bool Padded = false;
|
||||||
|
if (!V.getType()->isVoidTy()) {
|
||||||
OS.PadToColumn(50);
|
OS.PadToColumn(50);
|
||||||
OS << "; [#uses=" << V.getNumUses() << ']'; // Output # uses
|
Padded = true;
|
||||||
|
OS << "; [#uses=" << V.getNumUses() << ']'; // Output # uses
|
||||||
|
}
|
||||||
|
if (const Instruction *I = dyn_cast<Instruction>(&V)) {
|
||||||
|
const DebugLoc &DL = I->getDebugLoc();
|
||||||
|
if (!DL.isUnknown()) {
|
||||||
|
if (!Padded) {
|
||||||
|
OS.PadToColumn(50);
|
||||||
|
Padded = true;
|
||||||
|
OS << ";";
|
||||||
|
}
|
||||||
|
OS << " [debug line = ";
|
||||||
|
printDebugLoc(DL,OS);
|
||||||
|
OS << "]";
|
||||||
|
}
|
||||||
|
if (const DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I)) {
|
||||||
|
DIVariable Var(DDI->getVariable());
|
||||||
|
if (!Padded) {
|
||||||
|
OS.PadToColumn(50);
|
||||||
|
Padded = true;
|
||||||
|
OS << ";";
|
||||||
|
}
|
||||||
|
OS << " [debug variable = " << Var.getName() << "]";
|
||||||
|
}
|
||||||
|
else if (const DbgValueInst *DVI = dyn_cast<DbgValueInst>(I)) {
|
||||||
|
DIVariable Var(DVI->getVariable());
|
||||||
|
if (!Padded) {
|
||||||
|
OS.PadToColumn(50);
|
||||||
|
Padded = true;
|
||||||
|
OS << ";";
|
||||||
|
}
|
||||||
|
OS << " [debug variable = " << Var.getName() << "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user