[PATCH] D85707: [DWARFYAML] Let the address size of line tables inferred from the object file.
Xing GUO via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 07:46:12 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d4bc08ce43c: [DWARFYAML] Let the address size of line tables inferred from the object file. (authored by Higuoxing).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85707/new/
https://reviews.llvm.org/D85707
Files:
llvm/lib/ObjectYAML/DWARFEmitter.cpp
llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml
Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml
===================================================================
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-line.yaml
@@ -317,3 +317,56 @@
IncludeDirs: []
Files: []
Opcodes: []
+
+## h) Test that the address size is inferred from the target machine.
+
+# RUN: yaml2obj --docnum=8 -DBITS=64 -DADDR=0x1234567890abcdef %s -o %t8.64-bit.o
+# RUN: llvm-readelf --hex-dump=.debug_line %t8.64-bit.o | \
+# RUN: FileCheck %s --check-prefix=ADDRSIZE -DADDR="efcdab90 78563412"
+
+# ADDRSIZE: Hex dump of section '.debug_line':
+# ADDRSIZE-NEXT: 0x00000000 34120000 02003412 00000101 010e0d00 4.....4.........
+## ^------- unit_length (4-byte)
+## ^--- version (2-byte)
+## ^-------- header_length (4-byte)
+## ^- minimum_instruction_length (1-byte)
+## ^- default_is_stmt (1-byte)
+## ^- line_base (1-byte)
+## ^- line_range (1-byte)
+## ^- opcode_base (1-byte)
+## ^- null byte for terminating include_directories
+# ADDRSIZE-NEXT: 0x00000010 00000902 [[ADDR]]
+## ^- null byte for terminating file_names
+## ^- DW_LNS_extended_op
+## ^- extended op length (ULEB128) 0x09
+## ^- DW_LNE_set_address
+## ^------- address
+
+# RUN: yaml2obj --docnum=8 -DBITS=32 -DADDR=0x12345678 %s -o %t8.32-bit.o
+# RUN: llvm-readelf --hex-dump=.debug_line %t8.32-bit.o | \
+# RUN: FileCheck %s --check-prefix=ADDRSIZE -DADDR="78563412"
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS[[BITS]]
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+DWARF:
+ debug_line:
+ - Length: 0x1234
+ Version: 2
+ PrologueLength: 0x1234
+ MinInstLength: 1
+ DefaultIsStmt: 1
+ LineBase: 1
+ LineRange: 14
+ OpcodeBase: 13
+ StandardOpcodeLengths: []
+ IncludeDirs: []
+ Files: []
+ Opcodes:
+ - Opcode: DW_LNS_extended_op
+ ExtLen: 9
+ SubOpcode: DW_LNE_set_address
+ Data: [[ADDR]]
Index: llvm/lib/ObjectYAML/DWARFEmitter.cpp
===================================================================
--- llvm/lib/ObjectYAML/DWARFEmitter.cpp
+++ llvm/lib/ObjectYAML/DWARFEmitter.cpp
@@ -461,6 +461,8 @@
emitFileEntry(OS, File);
OS.write('\0');
+ uint8_t AddrSize = DI.Is64BitAddrSize ? 8 : 4;
+
for (auto Op : LineTable.Opcodes) {
writeInteger((uint8_t)Op.Opcode, OS, DI.IsLittleEndian);
if (Op.Opcode == 0) {
@@ -469,10 +471,9 @@
switch (Op.SubOpcode) {
case dwarf::DW_LNE_set_address:
case dwarf::DW_LNE_set_discriminator:
- // TODO: Test this error.
- if (Error Err = writeVariableSizedInteger(
- Op.Data, DI.CompileUnits[0].AddrSize, OS, DI.IsLittleEndian))
- return Err;
+ // FIXME: The operand of set_discriminator is not an address.
+ cantFail(writeVariableSizedInteger(Op.Data, AddrSize, OS,
+ DI.IsLittleEndian));
break;
case dwarf::DW_LNE_define_file:
emitFileEntry(OS, Op.FileEntry);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85707.284724.patch
Type: text/x-patch
Size: 4062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200811/7b19f56e/attachment.bin>
More information about the llvm-commits
mailing list