forked from OSchip/llvm-project
[DebugInfo] Dump raw data in a case of decoding error of an expression.
It looks like that was an initial intention, but some code paths in `DWARFExpression::Operation::extract()` did not initialize `EndOffset` properly. Differential Revision: https://reviews.llvm.org/D79622
This commit is contained in:
parent
c90e198107
commit
c6ed1fcf24
|
@ -120,13 +120,12 @@ static DWARFExpression::Operation::Description getOpDesc(unsigned OpCode) {
|
||||||
bool DWARFExpression::Operation::extract(DataExtractor Data,
|
bool DWARFExpression::Operation::extract(DataExtractor Data,
|
||||||
uint8_t AddressSize, uint64_t Offset,
|
uint8_t AddressSize, uint64_t Offset,
|
||||||
Optional<DwarfFormat> Format) {
|
Optional<DwarfFormat> Format) {
|
||||||
|
EndOffset = Offset;
|
||||||
Opcode = Data.getU8(&Offset);
|
Opcode = Data.getU8(&Offset);
|
||||||
|
|
||||||
Desc = getOpDesc(Opcode);
|
Desc = getOpDesc(Opcode);
|
||||||
if (Desc.Version == Operation::DwarfNA) {
|
if (Desc.Version == Operation::DwarfNA)
|
||||||
EndOffset = Offset;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned Operand = 0; Operand < 2; ++Operand) {
|
for (unsigned Operand = 0; Operand < 2; ++Operand) {
|
||||||
unsigned Size = Desc.Op[Operand];
|
unsigned Size = Desc.Op[Operand];
|
||||||
|
@ -135,7 +134,6 @@ bool DWARFExpression::Operation::extract(DataExtractor Data,
|
||||||
if (Size == Operation::SizeNA)
|
if (Size == Operation::SizeNA)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
EndOffset = Offset;
|
|
||||||
switch (Size & ~Operation::SignBit) {
|
switch (Size & ~Operation::SignBit) {
|
||||||
case Operation::Size1:
|
case Operation::Size1:
|
||||||
Operands[Operand] = Data.getU8(&Offset);
|
Operands[Operand] = Data.getU8(&Offset);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
# CHECK: .debug_loc contents:
|
# CHECK: .debug_loc contents:
|
||||||
# CHECK-NEXT: 0x00000000:
|
# CHECK-NEXT: 0x00000000:
|
||||||
# CHECK-NEXT: (0x0000000000000000, 0x0000000000000015): <decoding error>
|
# CHECK-NEXT: (0x0000000000000000, 0x0000000000000015): <decoding error> 9a ff 00 00 00
|
||||||
|
|
||||||
.section .debug_loc, "", @progbits
|
.section .debug_loc, "", @progbits
|
||||||
.quad 0 # Beginning address offset
|
.quad 0 # Beginning address offset
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
## Check we don't crash when parsing invalid expression opcode.
|
## Check we don't crash when parsing invalid expression opcode.
|
||||||
# RUN: llvm-dwarfdump %t | FileCheck %s
|
# RUN: llvm-dwarfdump %t | FileCheck %s
|
||||||
# CHECK: DW_TAG_GNU_call_site_parameter
|
# CHECK: DW_TAG_GNU_call_site_parameter
|
||||||
# CHECK-NEXT: DW_AT_location (<decoding error>)
|
# CHECK-NEXT: DW_AT_location (<decoding error> ff)
|
||||||
|
|
||||||
## Check verifier reports an error.
|
## Check verifier reports an error.
|
||||||
# RUN: not llvm-dwarfdump -verify %t 2>&1 | FileCheck %s --check-prefix=VERIFY
|
# RUN: not llvm-dwarfdump -verify %t 2>&1 | FileCheck %s --check-prefix=VERIFY
|
||||||
# VERIFY: DIE contains invalid DWARF expression:
|
# VERIFY: DIE contains invalid DWARF expression:
|
||||||
# VERIFY: DW_TAG_GNU_call_site_parameter
|
# VERIFY: DW_TAG_GNU_call_site_parameter
|
||||||
# VERIFY-NEXT: DW_AT_location (<decoding error>)
|
# VERIFY-NEXT: DW_AT_location (<decoding error> ff)
|
||||||
|
|
||||||
.section .debug_info,"",@progbits
|
.section .debug_info,"",@progbits
|
||||||
.long 0x12
|
.long 0x12
|
||||||
|
|
Loading…
Reference in New Issue