llvm.org GIT mirror llvm / 587d544
Changes to display code view debug info type records in hex format git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366390 91177308-0d34-0410-b5e6-96231b3b80d8 Nilanjana Basu 3 months ago
7 changed file(s) with 150 addition(s) and 123 deletion(s). Raw diff Collapse all Expand all
133133 //// Represent a constant integer expression.
134134 class MCConstantExpr : public MCExpr {
135135 int64_t Value;
136
137 explicit MCConstantExpr(int64_t Value)
136 bool PrintInHex = false;
137
138 MCConstantExpr(int64_t Value)
138139 : MCExpr(MCExpr::Constant, SMLoc()), Value(Value) {}
139140
141 MCConstantExpr(int64_t Value, bool PrintInHex)
142 : MCExpr(MCExpr::Constant, SMLoc()), Value(Value),
143 PrintInHex(PrintInHex) {}
144
140145 public:
141146 /// \name Construction
142147 /// @{
143148
144 static const MCConstantExpr *create(int64_t Value, MCContext &Ctx);
149 static const MCConstantExpr *create(int64_t Value, MCContext &Ctx,
150 bool PrintInHex = false);
145151
146152 /// @}
147153 /// \name Accessors
148154 /// @{
149155
150156 int64_t getValue() const { return Value; }
157
158 bool useHexFormat() const { return PrintInHex; }
151159
152160 /// @}
153161
624624 /// Special case of EmitValue that avoids the client having
625625 /// to pass in a MCExpr for constant integers.
626626 virtual void EmitIntValue(uint64_t Value, unsigned Size);
627
628 /// Special case of EmitValue that avoids the client having to pass
629 /// in a MCExpr for constant integers & prints in Hex format for certain
630 /// modes.
631 virtual void EmitIntValueInHex(uint64_t Value, unsigned Size) {
632 EmitIntValue(Value, Size);
633 }
627634
628635 virtual void EmitULEB128Value(const MCExpr *Value);
629636
102102 void EmitBytes(StringRef Data) { OS->EmitBytes(Data); }
103103
104104 void EmitIntValue(uint64_t Value, unsigned Size) {
105 OS->EmitIntValue(Value, Size);
105 OS->EmitIntValueInHex(Value, Size);
106106 }
107107
108108 void EmitBinaryData(StringRef Data) { OS->EmitBinaryData(Data); }
305305 for (auto Name : Record.MethodNames)
306306 NamesLen += Name.size() + 1;
307307 }
308 error(IO.mapInteger(NamesLen, ""));
308 error(IO.mapInteger(NamesLen));
309309 error(IO.mapVectorTail(
310310 Record.MethodNames,
311311 [](CodeViewRecordIO &IO, StringRef &S) {
187187 void EmitValueImpl(const MCExpr *Value, unsigned Size,
188188 SMLoc Loc = SMLoc()) override;
189189 void EmitIntValue(uint64_t Value, unsigned Size) override;
190 void EmitIntValueInHex(uint64_t Value, unsigned Size) override;
190191
191192 void EmitULEB128Value(const MCExpr *Value) override;
192193
922923 EmitValue(MCConstantExpr::create(Value, getContext()), Size);
923924 }
924925
926 void MCAsmStreamer::EmitIntValueInHex(uint64_t Value, unsigned Size) {
927 EmitValue(MCConstantExpr::create(Value, getContext(), true), Size);
928 }
929
925930 void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
926931 SMLoc Loc) {
927932 assert(Size <= 8 && "Invalid size");
77
88 #include "llvm/MC/MCExpr.h"
99 #include "llvm/ADT/Statistic.h"
10 #include "llvm/ADT/StringExtras.h"
1011 #include "llvm/ADT/StringSwitch.h"
1112 #include "llvm/Config/llvm-config.h"
1213 #include "llvm/MC/MCAsmBackend.h"
4142 switch (getKind()) {
4243 case MCExpr::Target:
4344 return cast(this)->printImpl(OS, MAI);
44 case MCExpr::Constant:
45 OS << cast(*this).getValue();
45 case MCExpr::Constant: {
46 auto Value = cast(*this).getValue();
47 auto PrintInHex = cast(*this).useHexFormat();
48 if (PrintInHex)
49 OS << "0x" << Twine::utohexstr(Value);
50 else
51 OS << Value;
4652 return;
47
53 }
4854 case MCExpr::SymbolRef: {
4955 const MCSymbolRefExpr &SRE = cast(*this);
5056 const MCSymbol &Sym = SRE.getSymbol();
159165 return new (Ctx) MCUnaryExpr(Opc, Expr, Loc);
160166 }
161167
162 const MCConstantExpr *MCConstantExpr::create(int64_t Value, MCContext &Ctx) {
163 return new (Ctx) MCConstantExpr(Value);
168 const MCConstantExpr *MCConstantExpr::create(int64_t Value, MCContext &Ctx,
169 bool PrintInHex) {
170 return new (Ctx) MCConstantExpr(Value, PrintInHex);
164171 }
165172
166173 /* *** */
349349 ; ASM: .section .debug$T,"dr"
350350 ; ASM: .p2align 2
351351 ; ASM: .long 4 # Debug section magic
352 ; ASM: .short 18 # Record length
353 ; ASM: .short 4609 # Record kind: LF_ARGLIST
354 ; ASM: .long 3 # NumArgs
355 ; ASM: .long 64 # Argument
356 ; ASM: .long 65 # Argument
357 ; ASM: .long 19 # Argument
352 ; ASM: .short 0x12 # Record length
353 ; ASM: .short 0x1201 # Record kind: LF_ARGLIST
354 ; ASM: .long 0x3 # NumArgs
355 ; ASM: .long 0x40 # Argument
356 ; ASM: .long 0x41 # Argument
357 ; ASM: .long 0x13 # Argument
358358 ; ASM: # ArgList (0x1000) {
359359 ; ASM: # TypeLeafKind: LF_ARGLIST (0x1201)
360360 ; ASM: # NumArgs: 3
364364 ; ASM: # ArgType: __int64 (0x13)
365365 ; ASM: # ]
366366 ; ASM: # }
367 ; ASM: .short 14 # Record length
368 ; ASM: .short 4104 # Record kind: LF_PROCEDURE
369 ; ASM: .long 3 # ReturnType
370 ; ASM: .byte 0 # CallingConvention
371 ; ASM: .byte 0 # FunctionOptions
372 ; ASM: .short 3 # NumParameters
373 ; ASM: .long 4096 # ArgListType
367 ; ASM: .short 0xe # Record length
368 ; ASM: .short 0x1008 # Record kind: LF_PROCEDURE
369 ; ASM: .long 0x3 # ReturnType
370 ; ASM: .byte 0x0 # CallingConvention
371 ; ASM: .byte 0x0 # FunctionOptions
372 ; ASM: .short 0x3 # NumParameters
373 ; ASM: .long 0x1000 # ArgListType
374374 ; ASM: # Procedure (0x1001) {
375375 ; ASM: # TypeLeafKind: LF_PROCEDURE (0x1008)
376376 ; ASM: # ReturnType: void (0x3)
380380 ; ASM: # NumParameters: 3
381381 ; ASM: # ArgListType: (float, double, __int64) (0x1000)
382382 ; ASM: # }
383 ; ASM: .short 14 # Record length
384 ; ASM: .short 5633 # Record kind: LF_FUNC_ID
385 ; ASM: .long 0 # ParentScope
386 ; ASM: .long 4097 # FunctionType
383 ; ASM: .short 0xe # Record length
384 ; ASM: .short 0x1601 # Record kind: LF_FUNC_ID
385 ; ASM: .long 0x0 # ParentScope
386 ; ASM: .long 0x1001 # FunctionType
387387 ; ASM: .asciz "f" # Name
388388 ; ASM: .byte 242
389389 ; ASM: .byte 241
393393 ; ASM: # FunctionType: void (float, double, __int64) (0x1001)
394394 ; ASM: # Name: f
395395 ; ASM: # }
396 ; ASM: .short 10 # Record length
397 ; ASM: .short 4097 # Record kind: LF_MODIFIER
398 ; ASM: .long 116 # ModifiedType
399 ; ASM: .short 1 # Modifiers
396 ; ASM: .short 0xa # Record length
397 ; ASM: .short 0x1001 # Record kind: LF_MODIFIER
398 ; ASM: .long 0x74 # ModifiedType
399 ; ASM: .short 0x1 # Modifiers
400400 ; ASM: .byte 242
401401 ; ASM: .byte 241
402402 ; ASM: # Modifier (0x1003) {
406406 ; ASM: # Const (0x1)
407407 ; ASM: # ]
408408 ; ASM: # }
409 ; ASM: .short 10 # Record length
410 ; ASM: .short 4098 # Record kind: LF_POINTER
411 ; ASM: .long 4099 # PointeeType
412 ; ASM: .long 65548 # Attributes
409 ; ASM: .short 0xa # Record length
410 ; ASM: .short 0x1002 # Record kind: LF_POINTER
411 ; ASM: .long 0x1003 # PointeeType
412 ; ASM: .long 0x1000c # Attributes
413413 ; ASM: # Pointer (0x1004) {
414414 ; ASM: # TypeLeafKind: LF_POINTER (0x1002)
415415 ; ASM: # PointeeType: const int (0x1003)
424424 ; ASM: # IsThisPtr&&: 0
425425 ; ASM: # SizeOf: 8
426426 ; ASM: # }
427 ; ASM: .short 22 # Record length
428 ; ASM: .short 5381 # Record kind: LF_STRUCTURE
429 ; ASM: .short 0 # MemberCount
430 ; ASM: .short 128 # Properties
431 ; ASM: .long 0 # FieldList
432 ; ASM: .long 0 # DerivedFrom
433 ; ASM: .long 0 # VShape
434 ; ASM: .short 0 # SizeOf
427 ; ASM: .short 0x16 # Record length
428 ; ASM: .short 0x1505 # Record kind: LF_STRUCTURE
429 ; ASM: .short 0x0 # MemberCount
430 ; ASM: .short 0x80 # Properties
431 ; ASM: .long 0x0 # FieldList
432 ; ASM: .long 0x0 # DerivedFrom
433 ; ASM: .long 0x0 # VShape
434 ; ASM: .short 0x0 # SizeOf
435435 ; ASM: .asciz "A" # Name
436436 ; ASM: # Struct (0x1005) {
437437 ; ASM: # TypeLeafKind: LF_STRUCTURE (0x1505)
445445 ; ASM: # SizeOf: 0
446446 ; ASM: # Name: A
447447 ; ASM: # }
448 ; ASM: .short 18 # Record length
449 ; ASM: .short 4098 # Record kind: LF_POINTER
450 ; ASM: .long 116 # PointeeType
451 ; ASM: .long 32844 # Attributes
452 ; ASM: .long 4101 # ClassType
453 ; ASM: .short 4 # Representation
448 ; ASM: .short 0x12 # Record length
449 ; ASM: .short 0x1002 # Record kind: LF_POINTER
450 ; ASM: .long 0x74 # PointeeType
451 ; ASM: .long 0x804c # Attributes
452 ; ASM: .long 0x1005 # ClassType
453 ; ASM: .short 0x4 # Representation
454454 ; ASM: .byte 242
455455 ; ASM: .byte 241
456456 ; ASM: # Pointer (0x1006) {
469469 ; ASM: # ClassType: A (0x1005)
470470 ; ASM: # Representation: GeneralData (0x4)
471471 ; ASM: # }
472 ; ASM: .short 10 # Record length
473 ; ASM: .short 4098 # Record kind: LF_POINTER
474 ; ASM: .long 4101 # PointeeType
475 ; ASM: .long 66572 # Attributes
472 ; ASM: .short 0xa # Record length
473 ; ASM: .short 0x1002 # Record kind: LF_POINTER
474 ; ASM: .long 0x1005 # PointeeType
475 ; ASM: .long 0x1040c # Attributes
476476 ; ASM: # Pointer (0x1007) {
477477 ; ASM: # TypeLeafKind: LF_POINTER (0x1002)
478478 ; ASM: # PointeeType: A (0x1005)
487487 ; ASM: # IsThisPtr&&: 0
488488 ; ASM: # SizeOf: 8
489489 ; ASM: # }
490 ; ASM: .short 6 # Record length
491 ; ASM: .short 4609 # Record kind: LF_ARGLIST
492 ; ASM: .long 0 # NumArgs
490 ; ASM: .short 0x6 # Record length
491 ; ASM: .short 0x1201 # Record kind: LF_ARGLIST
492 ; ASM: .long 0x0 # NumArgs
493493 ; ASM: # ArgList (0x1008) {
494494 ; ASM: # TypeLeafKind: LF_ARGLIST (0x1201)
495495 ; ASM: # NumArgs: 0
496496 ; ASM: # Arguments [
497497 ; ASM: # ]
498498 ; ASM: # }
499 ; ASM: .short 26 # Record length
500 ; ASM: .short 4105 # Record kind: LF_MFUNCTION
501 ; ASM: .long 3 # ReturnType
502 ; ASM: .long 4101 # ClassType
503 ; ASM: .long 4103 # ThisType
504 ; ASM: .byte 0 # CallingConvention
505 ; ASM: .byte 0 # FunctionOptions
506 ; ASM: .short 0 # NumParameters
507 ; ASM: .long 4104 # ArgListType
508 ; ASM: .long 0 # ThisAdjustment
499 ; ASM: .short 0x1a # Record length
500 ; ASM: .short 0x1009 # Record kind: LF_MFUNCTION
501 ; ASM: .long 0x3 # ReturnType
502 ; ASM: .long 0x1005 # ClassType
503 ; ASM: .long 0x1007 # ThisType
504 ; ASM: .byte 0x0 # CallingConvention
505 ; ASM: .byte 0x0 # FunctionOptions
506 ; ASM: .short 0x0 # NumParameters
507 ; ASM: .long 0x1008 # ArgListType
508 ; ASM: .long 0x0 # ThisAdjustment
509509 ; ASM: # MemberFunction (0x1009) {
510510 ; ASM: # TypeLeafKind: LF_MFUNCTION (0x1009)
511511 ; ASM: # ReturnType: void (0x3)
518518 ; ASM: # ArgListType: () (0x1008)
519519 ; ASM: # ThisAdjustment: 0
520520 ; ASM: # }
521 ; ASM: .short 30 # Record length
522 ; ASM: .short 4611 # Record kind: LF_FIELDLIST
521 ; ASM: .short 0x1e # Record length
522 ; ASM: .short 0x1203 # Record kind: LF_FIELDLIST
523523 ; ASM: .byte 0x0d, 0x15, 0x03, 0x00
524524 ; ASM: .byte 0x74, 0x00, 0x00, 0x00
525525 ; ASM: .byte 0x00, 0x00, 0x61, 0x00
543543 ; ASM: # Name: A::f
544544 ; ASM: # }
545545 ; ASM: # }
546 ; ASM: .short 22 # Record length
547 ; ASM: .short 5381 # Record kind: LF_STRUCTURE
548 ; ASM: .short 2 # MemberCount
549 ; ASM: .short 0 # Properties
550 ; ASM: .long 4106 # FieldList
551 ; ASM: .long 0 # DerivedFrom
552 ; ASM: .long 0 # VShape
553 ; ASM: .short 4 # SizeOf
546 ; ASM: .short 0x16 # Record length
547 ; ASM: .short 0x1505 # Record kind: LF_STRUCTURE
548 ; ASM: .short 0x2 # MemberCount
549 ; ASM: .short 0x0 # Properties
550 ; ASM: .long 0x100a # FieldList
551 ; ASM: .long 0x0 # DerivedFrom
552 ; ASM: .long 0x0 # VShape
553 ; ASM: .short 0x4 # SizeOf
554554 ; ASM: .asciz "A" # Name
555555 ; ASM: # Struct (0x100B) {
556556 ; ASM: # TypeLeafKind: LF_STRUCTURE (0x1505)
563563 ; ASM: # SizeOf: 4
564564 ; ASM: # Name: A
565565 ; ASM: # }
566 ; ASM: .short 30 # Record length
567 ; ASM: .short 5637 # Record kind: LF_STRING_ID
568 ; ASM: .long 0 # Id
566 ; ASM: .short 0x1e # Record length
567 ; ASM: .short 0x1605 # Record kind: LF_STRING_ID
568 ; ASM: .long 0x0 # Id
569569 ; ASM: .asciz "D:\\src\\llvm\\build\\t.cpp" # StringData
570570 ; ASM: # StringId (0x100C) {
571571 ; ASM: # TypeLeafKind: LF_STRING_ID (0x1605)
572572 ; ASM: # Id: 0x0
573573 ; ASM: # StringData: D:\src\llvm\build\t.cpp
574574 ; ASM: # }
575 ; ASM: .short 14 # Record length
576 ; ASM: .short 5638 # Record kind: LF_UDT_SRC_LINE
577 ; ASM: .long 4107 # UDT
578 ; ASM: .long 4108 # SourceFile
579 ; ASM: .long 1 # LineNumber
575 ; ASM: .short 0xe # Record length
576 ; ASM: .short 0x1606 # Record kind: LF_UDT_SRC_LINE
577 ; ASM: .long 0x100b # UDT
578 ; ASM: .long 0x100c # SourceFile
579 ; ASM: .long 0x1 # LineNumber
580580 ; ASM: # UdtSourceLine (0x100D) {
581581 ; ASM: # TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
582582 ; ASM: # UDT: A (0x100B)
583583 ; ASM: # SourceFile: D:\src\llvm\build\t.cpp (0x100C)
584584 ; ASM: # LineNumber: 1
585585 ; ASM: # }
586 ; ASM: .short 18 # Record length
587 ; ASM: .short 4098 # Record kind: LF_POINTER
588 ; ASM: .long 4105 # PointeeType
589 ; ASM: .long 65644 # Attributes
590 ; ASM: .long 4101 # ClassType
591 ; ASM: .short 8 # Representation
586 ; ASM: .short 0x12 # Record length
587 ; ASM: .short 0x1002 # Record kind: LF_POINTER
588 ; ASM: .long 0x1009 # PointeeType
589 ; ASM: .long 0x1006c # Attributes
590 ; ASM: .long 0x1005 # ClassType
591 ; ASM: .short 0x8 # Representation
592592 ; ASM: .byte 242
593593 ; ASM: .byte 241
594594 ; ASM: # Pointer (0x100E) {
607607 ; ASM: # ClassType: A (0x1005)
608608 ; ASM: # Representation: GeneralFunction (0x8)
609609 ; ASM: # }
610 ; ASM: .short 10 # Record length
611 ; ASM: .short 4097 # Record kind: LF_MODIFIER
612 ; ASM: .long 3 # ModifiedType
613 ; ASM: .short 1 # Modifiers
610 ; ASM: .short 0xa # Record length
611 ; ASM: .short 0x1001 # Record kind: LF_MODIFIER
612 ; ASM: .long 0x3 # ModifiedType
613 ; ASM: .short 0x1 # Modifiers
614614 ; ASM: .byte 242
615615 ; ASM: .byte 241
616616 ; ASM: # Modifier (0x100F) {
620620 ; ASM: # Const (0x1)
621621 ; ASM: # ]
622622 ; ASM: # }
623 ; ASM: .short 10 # Record length
624 ; ASM: .short 4098 # Record kind: LF_POINTER
625 ; ASM: .long 4111 # PointeeType
626 ; ASM: .long 65548 # Attributes
623 ; ASM: .short 0xa # Record length
624 ; ASM: .short 0x1002 # Record kind: LF_POINTER
625 ; ASM: .long 0x100f # PointeeType
626 ; ASM: .long 0x1000c # Attributes
627627 ; ASM: # Pointer (0x1010) {
628628 ; ASM: # TypeLeafKind: LF_POINTER (0x1002)
629629 ; ASM: # PointeeType: const void (0x100F)
638638 ; ASM: # IsThisPtr&&: 0
639639 ; ASM: # SizeOf: 8
640640 ; ASM: # }
641 ; ASM: .short 14 # Record length
642 ; ASM: .short 4104 # Record kind: LF_PROCEDURE
643 ; ASM: .long 3 # ReturnType
644 ; ASM: .byte 0 # CallingConvention
645 ; ASM: .byte 0 # FunctionOptions
646 ; ASM: .short 0 # NumParameters
647 ; ASM: .long 4104 # ArgListType
641 ; ASM: .short 0xe # Record length
642 ; ASM: .short 0x1008 # Record kind: LF_PROCEDURE
643 ; ASM: .long 0x3 # ReturnType
644 ; ASM: .byte 0x0 # CallingConvention
645 ; ASM: .byte 0x0 # FunctionOptions
646 ; ASM: .short 0x0 # NumParameters
647 ; ASM: .long 0x1008 # ArgListType
648648 ; ASM: # Procedure (0x1011) {
649649 ; ASM: # TypeLeafKind: LF_PROCEDURE (0x1008)
650650 ; ASM: # ReturnType: void (0x3)
654654 ; ASM: # NumParameters: 0
655655 ; ASM: # ArgListType: () (0x1008)
656656 ; ASM: # }
657 ; ASM: .short 22 # Record length
658 ; ASM: .short 5633 # Record kind: LF_FUNC_ID
659 ; ASM: .long 0 # ParentScope
660 ; ASM: .long 4113 # FunctionType
657 ; ASM: .short 0x16 # Record length
658 ; ASM: .short 0x1601 # Record kind: LF_FUNC_ID
659 ; ASM: .long 0x0 # ParentScope
660 ; ASM: .long 0x1011 # FunctionType
661661 ; ASM: .asciz "CharTypes" # Name
662662 ; ASM: .byte 242
663663 ; ASM: .byte 241
667667 ; ASM: # FunctionType: void () (0x1011)
668668 ; ASM: # Name: CharTypes
669669 ; ASM: # }
670 ; ASM: .short 26 # Record length
671 ; ASM: .short 5637 # Record kind: LF_STRING_ID
672 ; ASM: .long 0 # Id
670 ; ASM: .short 0x1a # Record length
671 ; ASM: .short 0x1605 # Record kind: LF_STRING_ID
672 ; ASM: .long 0x0 # Id
673673 ; ASM: .asciz "D:\\src\\llvm\\build" # StringData
674674 ; ASM: .byte 242
675675 ; ASM: .byte 241
678678 ; ASM: # Id: 0x0
679679 ; ASM: # StringData: D:\src\llvm\build
680680 ; ASM: # }
681 ; ASM: .short 14 # Record length
682 ; ASM: .short 5637 # Record kind: LF_STRING_ID
683 ; ASM: .long 0 # Id
681 ; ASM: .short 0xe # Record length
682 ; ASM: .short 0x1605 # Record kind: LF_STRING_ID
683 ; ASM: .long 0x0 # Id
684684 ; ASM: .asciz "t.cpp" # StringData
685685 ; ASM: .byte 242
686686 ; ASM: .byte 241
689689 ; ASM: # Id: 0x0
690690 ; ASM: # StringData: t.cpp
691691 ; ASM: # }
692 ; ASM: .short 26 # Record length
693 ; ASM: .short 5635 # Record kind: LF_BUILDINFO
694 ; ASM: .short 5 # NumArgs
695 ; ASM: .long 4115 # Argument
696 ; ASM: .long 0 # Argument
697 ; ASM: .long 4116 # Argument
698 ; ASM: .long 0 # Argument
699 ; ASM: .long 0 # Argument
692 ; ASM: .short 0x1a # Record length
693 ; ASM: .short 0x1603 # Record kind: LF_BUILDINFO
694 ; ASM: .short 0x5 # NumArgs
695 ; ASM: .long 0x1013 # Argument
696 ; ASM: .long 0x0 # Argument
697 ; ASM: .long 0x1014 # Argument
698 ; ASM: .long 0x0 # Argument
699 ; ASM: .long 0x0 # Argument
700700 ; ASM: .byte 242
701701 ; ASM: .byte 241
702702 ; ASM: # BuildInfo (0x1015) {