Changes to display code view debug info type records in hex format

llvm-svn: 366390
This commit is contained in:
Nilanjana Basu 2019-07-17 23:43:58 +00:00
parent 749f556bbd
commit 4e22770219
7 changed files with 149 additions and 122 deletions

View File

@ -134,15 +134,21 @@ inline raw_ostream &operator<<(raw_ostream &OS, const MCExpr &E) {
//// Represent a constant integer expression.
class MCConstantExpr : public MCExpr {
int64_t Value;
bool PrintInHex = false;
explicit MCConstantExpr(int64_t Value)
MCConstantExpr(int64_t Value)
: MCExpr(MCExpr::Constant, SMLoc()), Value(Value) {}
MCConstantExpr(int64_t Value, bool PrintInHex)
: MCExpr(MCExpr::Constant, SMLoc()), Value(Value),
PrintInHex(PrintInHex) {}
public:
/// \name Construction
/// @{
static const MCConstantExpr *create(int64_t Value, MCContext &Ctx);
static const MCConstantExpr *create(int64_t Value, MCContext &Ctx,
bool PrintInHex = false);
/// @}
/// \name Accessors
@ -150,6 +156,8 @@ public:
int64_t getValue() const { return Value; }
bool useHexFormat() const { return PrintInHex; }
/// @}
static bool classof(const MCExpr *E) {

View File

@ -626,6 +626,13 @@ public:
/// to pass in a MCExpr for constant integers.
virtual void EmitIntValue(uint64_t Value, unsigned Size);
/// Special case of EmitValue that avoids the client having to pass
/// in a MCExpr for constant integers & prints in Hex format for certain
/// modes.
virtual void EmitIntValueInHex(uint64_t Value, unsigned Size) {
EmitIntValue(Value, Size);
}
virtual void EmitULEB128Value(const MCExpr *Value);
virtual void EmitSLEB128Value(const MCExpr *Value);

View File

@ -103,7 +103,7 @@ public:
void EmitBytes(StringRef Data) { OS->EmitBytes(Data); }
void EmitIntValue(uint64_t Value, unsigned Size) {
OS->EmitIntValue(Value, Size);
OS->EmitIntValueInHex(Value, Size);
}
void EmitBinaryData(StringRef Data) { OS->EmitBinaryData(Data); }

View File

@ -306,7 +306,7 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, VFTableRecord &Record) {
for (auto Name : Record.MethodNames)
NamesLen += Name.size() + 1;
}
error(IO.mapInteger(NamesLen, ""));
error(IO.mapInteger(NamesLen));
error(IO.mapVectorTail(
Record.MethodNames,
[](CodeViewRecordIO &IO, StringRef &S) {

View File

@ -188,6 +188,7 @@ public:
void EmitValueImpl(const MCExpr *Value, unsigned Size,
SMLoc Loc = SMLoc()) override;
void EmitIntValue(uint64_t Value, unsigned Size) override;
void EmitIntValueInHex(uint64_t Value, unsigned Size) override;
void EmitULEB128Value(const MCExpr *Value) override;
@ -923,6 +924,10 @@ void MCAsmStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
EmitValue(MCConstantExpr::create(Value, getContext()), Size);
}
void MCAsmStreamer::EmitIntValueInHex(uint64_t Value, unsigned Size) {
EmitValue(MCConstantExpr::create(Value, getContext(), true), Size);
}
void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
SMLoc Loc) {
assert(Size <= 8 && "Invalid size");

View File

@ -8,6 +8,7 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/MC/MCAsmBackend.h"
@ -42,10 +43,15 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens) const {
switch (getKind()) {
case MCExpr::Target:
return cast<MCTargetExpr>(this)->printImpl(OS, MAI);
case MCExpr::Constant:
OS << cast<MCConstantExpr>(*this).getValue();
case MCExpr::Constant: {
auto Value = cast<MCConstantExpr>(*this).getValue();
auto PrintInHex = cast<MCConstantExpr>(*this).useHexFormat();
if (PrintInHex)
OS << "0x" << Twine::utohexstr(Value);
else
OS << Value;
return;
}
case MCExpr::SymbolRef: {
const MCSymbolRefExpr &SRE = cast<MCSymbolRefExpr>(*this);
const MCSymbol &Sym = SRE.getSymbol();
@ -160,8 +166,9 @@ const MCUnaryExpr *MCUnaryExpr::create(Opcode Opc, const MCExpr *Expr,
return new (Ctx) MCUnaryExpr(Opc, Expr, Loc);
}
const MCConstantExpr *MCConstantExpr::create(int64_t Value, MCContext &Ctx) {
return new (Ctx) MCConstantExpr(Value);
const MCConstantExpr *MCConstantExpr::create(int64_t Value, MCContext &Ctx,
bool PrintInHex) {
return new (Ctx) MCConstantExpr(Value, PrintInHex);
}
/* *** */

View File

@ -350,12 +350,12 @@
; ASM: .section .debug$T,"dr"
; ASM: .p2align 2
; ASM: .long 4 # Debug section magic
; ASM: .short 18 # Record length
; ASM: .short 4609 # Record kind: LF_ARGLIST
; ASM: .long 3 # NumArgs
; ASM: .long 64 # Argument
; ASM: .long 65 # Argument
; ASM: .long 19 # Argument
; ASM: .short 0x12 # Record length
; ASM: .short 0x1201 # Record kind: LF_ARGLIST
; ASM: .long 0x3 # NumArgs
; ASM: .long 0x40 # Argument
; ASM: .long 0x41 # Argument
; ASM: .long 0x13 # Argument
; ASM: # ArgList (0x1000) {
; ASM: # TypeLeafKind: LF_ARGLIST (0x1201)
; ASM: # NumArgs: 3
@ -365,13 +365,13 @@
; ASM: # ArgType: __int64 (0x13)
; ASM: # ]
; ASM: # }
; ASM: .short 14 # Record length
; ASM: .short 4104 # Record kind: LF_PROCEDURE
; ASM: .long 3 # ReturnType
; ASM: .byte 0 # CallingConvention
; ASM: .byte 0 # FunctionOptions
; ASM: .short 3 # NumParameters
; ASM: .long 4096 # ArgListType
; ASM: .short 0xe # Record length
; ASM: .short 0x1008 # Record kind: LF_PROCEDURE
; ASM: .long 0x3 # ReturnType
; ASM: .byte 0x0 # CallingConvention
; ASM: .byte 0x0 # FunctionOptions
; ASM: .short 0x3 # NumParameters
; ASM: .long 0x1000 # ArgListType
; ASM: # Procedure (0x1001) {
; ASM: # TypeLeafKind: LF_PROCEDURE (0x1008)
; ASM: # ReturnType: void (0x3)
@ -381,10 +381,10 @@
; ASM: # NumParameters: 3
; ASM: # ArgListType: (float, double, __int64) (0x1000)
; ASM: # }
; ASM: .short 14 # Record length
; ASM: .short 5633 # Record kind: LF_FUNC_ID
; ASM: .long 0 # ParentScope
; ASM: .long 4097 # FunctionType
; ASM: .short 0xe # Record length
; ASM: .short 0x1601 # Record kind: LF_FUNC_ID
; ASM: .long 0x0 # ParentScope
; ASM: .long 0x1001 # FunctionType
; ASM: .asciz "f" # Name
; ASM: .byte 242
; ASM: .byte 241
@ -394,10 +394,10 @@
; ASM: # FunctionType: void (float, double, __int64) (0x1001)
; ASM: # Name: f
; ASM: # }
; ASM: .short 10 # Record length
; ASM: .short 4097 # Record kind: LF_MODIFIER
; ASM: .long 116 # ModifiedType
; ASM: .short 1 # Modifiers
; ASM: .short 0xa # Record length
; ASM: .short 0x1001 # Record kind: LF_MODIFIER
; ASM: .long 0x74 # ModifiedType
; ASM: .short 0x1 # Modifiers
; ASM: .byte 242
; ASM: .byte 241
; ASM: # Modifier (0x1003) {
@ -407,10 +407,10 @@
; ASM: # Const (0x1)
; ASM: # ]
; ASM: # }
; ASM: .short 10 # Record length
; ASM: .short 4098 # Record kind: LF_POINTER
; ASM: .long 4099 # PointeeType
; ASM: .long 65548 # Attributes
; ASM: .short 0xa # Record length
; ASM: .short 0x1002 # Record kind: LF_POINTER
; ASM: .long 0x1003 # PointeeType
; ASM: .long 0x1000c # Attributes
; ASM: # Pointer (0x1004) {
; ASM: # TypeLeafKind: LF_POINTER (0x1002)
; ASM: # PointeeType: const int (0x1003)
@ -425,14 +425,14 @@
; ASM: # IsThisPtr&&: 0
; ASM: # SizeOf: 8
; ASM: # }
; ASM: .short 22 # Record length
; ASM: .short 5381 # Record kind: LF_STRUCTURE
; ASM: .short 0 # MemberCount
; ASM: .short 128 # Properties
; ASM: .long 0 # FieldList
; ASM: .long 0 # DerivedFrom
; ASM: .long 0 # VShape
; ASM: .short 0 # SizeOf
; ASM: .short 0x16 # Record length
; ASM: .short 0x1505 # Record kind: LF_STRUCTURE
; ASM: .short 0x0 # MemberCount
; ASM: .short 0x80 # Properties
; ASM: .long 0x0 # FieldList
; ASM: .long 0x0 # DerivedFrom
; ASM: .long 0x0 # VShape
; ASM: .short 0x0 # SizeOf
; ASM: .asciz "A" # Name
; ASM: # Struct (0x1005) {
; ASM: # TypeLeafKind: LF_STRUCTURE (0x1505)
@ -446,12 +446,12 @@
; ASM: # SizeOf: 0
; ASM: # Name: A
; ASM: # }
; ASM: .short 18 # Record length
; ASM: .short 4098 # Record kind: LF_POINTER
; ASM: .long 116 # PointeeType
; ASM: .long 32844 # Attributes
; ASM: .long 4101 # ClassType
; ASM: .short 4 # Representation
; ASM: .short 0x12 # Record length
; ASM: .short 0x1002 # Record kind: LF_POINTER
; ASM: .long 0x74 # PointeeType
; ASM: .long 0x804c # Attributes
; ASM: .long 0x1005 # ClassType
; ASM: .short 0x4 # Representation
; ASM: .byte 242
; ASM: .byte 241
; ASM: # Pointer (0x1006) {
@ -470,10 +470,10 @@
; ASM: # ClassType: A (0x1005)
; ASM: # Representation: GeneralData (0x4)
; ASM: # }
; ASM: .short 10 # Record length
; ASM: .short 4098 # Record kind: LF_POINTER
; ASM: .long 4101 # PointeeType
; ASM: .long 66572 # Attributes
; ASM: .short 0xa # Record length
; ASM: .short 0x1002 # Record kind: LF_POINTER
; ASM: .long 0x1005 # PointeeType
; ASM: .long 0x1040c # Attributes
; ASM: # Pointer (0x1007) {
; ASM: # TypeLeafKind: LF_POINTER (0x1002)
; ASM: # PointeeType: A (0x1005)
@ -488,25 +488,25 @@
; ASM: # IsThisPtr&&: 0
; ASM: # SizeOf: 8
; ASM: # }
; ASM: .short 6 # Record length
; ASM: .short 4609 # Record kind: LF_ARGLIST
; ASM: .long 0 # NumArgs
; ASM: .short 0x6 # Record length
; ASM: .short 0x1201 # Record kind: LF_ARGLIST
; ASM: .long 0x0 # NumArgs
; ASM: # ArgList (0x1008) {
; ASM: # TypeLeafKind: LF_ARGLIST (0x1201)
; ASM: # NumArgs: 0
; ASM: # Arguments [
; ASM: # ]
; ASM: # }
; ASM: .short 26 # Record length
; ASM: .short 4105 # Record kind: LF_MFUNCTION
; ASM: .long 3 # ReturnType
; ASM: .long 4101 # ClassType
; ASM: .long 4103 # ThisType
; ASM: .byte 0 # CallingConvention
; ASM: .byte 0 # FunctionOptions
; ASM: .short 0 # NumParameters
; ASM: .long 4104 # ArgListType
; ASM: .long 0 # ThisAdjustment
; ASM: .short 0x1a # Record length
; ASM: .short 0x1009 # Record kind: LF_MFUNCTION
; ASM: .long 0x3 # ReturnType
; ASM: .long 0x1005 # ClassType
; ASM: .long 0x1007 # ThisType
; ASM: .byte 0x0 # CallingConvention
; ASM: .byte 0x0 # FunctionOptions
; ASM: .short 0x0 # NumParameters
; ASM: .long 0x1008 # ArgListType
; ASM: .long 0x0 # ThisAdjustment
; ASM: # MemberFunction (0x1009) {
; ASM: # TypeLeafKind: LF_MFUNCTION (0x1009)
; ASM: # ReturnType: void (0x3)
@ -519,8 +519,8 @@
; ASM: # ArgListType: () (0x1008)
; ASM: # ThisAdjustment: 0
; ASM: # }
; ASM: .short 30 # Record length
; ASM: .short 4611 # Record kind: LF_FIELDLIST
; ASM: .short 0x1e # Record length
; ASM: .short 0x1203 # Record kind: LF_FIELDLIST
; ASM: .byte 0x0d, 0x15, 0x03, 0x00
; ASM: .byte 0x74, 0x00, 0x00, 0x00
; ASM: .byte 0x00, 0x00, 0x61, 0x00
@ -544,14 +544,14 @@
; ASM: # Name: A::f
; ASM: # }
; ASM: # }
; ASM: .short 22 # Record length
; ASM: .short 5381 # Record kind: LF_STRUCTURE
; ASM: .short 2 # MemberCount
; ASM: .short 0 # Properties
; ASM: .long 4106 # FieldList
; ASM: .long 0 # DerivedFrom
; ASM: .long 0 # VShape
; ASM: .short 4 # SizeOf
; ASM: .short 0x16 # Record length
; ASM: .short 0x1505 # Record kind: LF_STRUCTURE
; ASM: .short 0x2 # MemberCount
; ASM: .short 0x0 # Properties
; ASM: .long 0x100a # FieldList
; ASM: .long 0x0 # DerivedFrom
; ASM: .long 0x0 # VShape
; ASM: .short 0x4 # SizeOf
; ASM: .asciz "A" # Name
; ASM: # Struct (0x100B) {
; ASM: # TypeLeafKind: LF_STRUCTURE (0x1505)
@ -564,32 +564,32 @@
; ASM: # SizeOf: 4
; ASM: # Name: A
; ASM: # }
; ASM: .short 30 # Record length
; ASM: .short 5637 # Record kind: LF_STRING_ID
; ASM: .long 0 # Id
; ASM: .short 0x1e # Record length
; ASM: .short 0x1605 # Record kind: LF_STRING_ID
; ASM: .long 0x0 # Id
; ASM: .asciz "D:\\src\\llvm\\build\\t.cpp" # StringData
; ASM: # StringId (0x100C) {
; ASM: # TypeLeafKind: LF_STRING_ID (0x1605)
; ASM: # Id: 0x0
; ASM: # StringData: D:\src\llvm\build\t.cpp
; ASM: # }
; ASM: .short 14 # Record length
; ASM: .short 5638 # Record kind: LF_UDT_SRC_LINE
; ASM: .long 4107 # UDT
; ASM: .long 4108 # SourceFile
; ASM: .long 1 # LineNumber
; ASM: .short 0xe # Record length
; ASM: .short 0x1606 # Record kind: LF_UDT_SRC_LINE
; ASM: .long 0x100b # UDT
; ASM: .long 0x100c # SourceFile
; ASM: .long 0x1 # LineNumber
; ASM: # UdtSourceLine (0x100D) {
; ASM: # TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
; ASM: # UDT: A (0x100B)
; ASM: # SourceFile: D:\src\llvm\build\t.cpp (0x100C)
; ASM: # LineNumber: 1
; ASM: # }
; ASM: .short 18 # Record length
; ASM: .short 4098 # Record kind: LF_POINTER
; ASM: .long 4105 # PointeeType
; ASM: .long 65644 # Attributes
; ASM: .long 4101 # ClassType
; ASM: .short 8 # Representation
; ASM: .short 0x12 # Record length
; ASM: .short 0x1002 # Record kind: LF_POINTER
; ASM: .long 0x1009 # PointeeType
; ASM: .long 0x1006c # Attributes
; ASM: .long 0x1005 # ClassType
; ASM: .short 0x8 # Representation
; ASM: .byte 242
; ASM: .byte 241
; ASM: # Pointer (0x100E) {
@ -608,10 +608,10 @@
; ASM: # ClassType: A (0x1005)
; ASM: # Representation: GeneralFunction (0x8)
; ASM: # }
; ASM: .short 10 # Record length
; ASM: .short 4097 # Record kind: LF_MODIFIER
; ASM: .long 3 # ModifiedType
; ASM: .short 1 # Modifiers
; ASM: .short 0xa # Record length
; ASM: .short 0x1001 # Record kind: LF_MODIFIER
; ASM: .long 0x3 # ModifiedType
; ASM: .short 0x1 # Modifiers
; ASM: .byte 242
; ASM: .byte 241
; ASM: # Modifier (0x100F) {
@ -621,10 +621,10 @@
; ASM: # Const (0x1)
; ASM: # ]
; ASM: # }
; ASM: .short 10 # Record length
; ASM: .short 4098 # Record kind: LF_POINTER
; ASM: .long 4111 # PointeeType
; ASM: .long 65548 # Attributes
; ASM: .short 0xa # Record length
; ASM: .short 0x1002 # Record kind: LF_POINTER
; ASM: .long 0x100f # PointeeType
; ASM: .long 0x1000c # Attributes
; ASM: # Pointer (0x1010) {
; ASM: # TypeLeafKind: LF_POINTER (0x1002)
; ASM: # PointeeType: const void (0x100F)
@ -639,13 +639,13 @@
; ASM: # IsThisPtr&&: 0
; ASM: # SizeOf: 8
; ASM: # }
; ASM: .short 14 # Record length
; ASM: .short 4104 # Record kind: LF_PROCEDURE
; ASM: .long 3 # ReturnType
; ASM: .byte 0 # CallingConvention
; ASM: .byte 0 # FunctionOptions
; ASM: .short 0 # NumParameters
; ASM: .long 4104 # ArgListType
; ASM: .short 0xe # Record length
; ASM: .short 0x1008 # Record kind: LF_PROCEDURE
; ASM: .long 0x3 # ReturnType
; ASM: .byte 0x0 # CallingConvention
; ASM: .byte 0x0 # FunctionOptions
; ASM: .short 0x0 # NumParameters
; ASM: .long 0x1008 # ArgListType
; ASM: # Procedure (0x1011) {
; ASM: # TypeLeafKind: LF_PROCEDURE (0x1008)
; ASM: # ReturnType: void (0x3)
@ -655,10 +655,10 @@
; ASM: # NumParameters: 0
; ASM: # ArgListType: () (0x1008)
; ASM: # }
; ASM: .short 22 # Record length
; ASM: .short 5633 # Record kind: LF_FUNC_ID
; ASM: .long 0 # ParentScope
; ASM: .long 4113 # FunctionType
; ASM: .short 0x16 # Record length
; ASM: .short 0x1601 # Record kind: LF_FUNC_ID
; ASM: .long 0x0 # ParentScope
; ASM: .long 0x1011 # FunctionType
; ASM: .asciz "CharTypes" # Name
; ASM: .byte 242
; ASM: .byte 241
@ -668,9 +668,9 @@
; ASM: # FunctionType: void () (0x1011)
; ASM: # Name: CharTypes
; ASM: # }
; ASM: .short 26 # Record length
; ASM: .short 5637 # Record kind: LF_STRING_ID
; ASM: .long 0 # Id
; ASM: .short 0x1a # Record length
; ASM: .short 0x1605 # Record kind: LF_STRING_ID
; ASM: .long 0x0 # Id
; ASM: .asciz "D:\\src\\llvm\\build" # StringData
; ASM: .byte 242
; ASM: .byte 241
@ -679,9 +679,9 @@
; ASM: # Id: 0x0
; ASM: # StringData: D:\src\llvm\build
; ASM: # }
; ASM: .short 14 # Record length
; ASM: .short 5637 # Record kind: LF_STRING_ID
; ASM: .long 0 # Id
; ASM: .short 0xe # Record length
; ASM: .short 0x1605 # Record kind: LF_STRING_ID
; ASM: .long 0x0 # Id
; ASM: .asciz "t.cpp" # StringData
; ASM: .byte 242
; ASM: .byte 241
@ -690,14 +690,14 @@
; ASM: # Id: 0x0
; ASM: # StringData: t.cpp
; ASM: # }
; ASM: .short 26 # Record length
; ASM: .short 5635 # Record kind: LF_BUILDINFO
; ASM: .short 5 # NumArgs
; ASM: .long 4115 # Argument
; ASM: .long 0 # Argument
; ASM: .long 4116 # Argument
; ASM: .long 0 # Argument
; ASM: .long 0 # Argument
; ASM: .short 0x1a # Record length
; ASM: .short 0x1603 # Record kind: LF_BUILDINFO
; ASM: .short 0x5 # NumArgs
; ASM: .long 0x1013 # Argument
; ASM: .long 0x0 # Argument
; ASM: .long 0x1014 # Argument
; ASM: .long 0x0 # Argument
; ASM: .long 0x0 # Argument
; ASM: .byte 242
; ASM: .byte 241
; ASM: # BuildInfo (0x1015) {