[Lldb-commits] [lldb] [lldb] Added a warning in case of instruction decode failure (PR #164413)
Timur Golubovich via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 22 04:19:42 PDT 2025
================
@@ -157,7 +157,9 @@ static lldb::offset_t DumpInstructions(const DataExtractor &DE, Stream *s,
exe_scope->CalculateExecutionContext(exe_ctx);
disassembler_sp->GetInstructionList().Dump(
s, show_address, show_bytes, show_control_flow_kind, &exe_ctx);
- }
+ } else if (number_of_instructions)
+ s->Printf("warning: failed to decode instructions at 0x%" PRIx64 ".",
+ addr);
----------------
tgs-sc wrote:
> Is there precedent for writing errors or warnings to this stream?
Actually, I saw printing warning in such way in `lldb/source/Process/Target` so I decided to do the same. In the DumpDataExtractor there is already such code, so I think there is no much diffrenece between warning and error
```cpp
case eFormatBoolean:
if (item_byte_size <= 8)
s->Printf("%s", DE.GetMaxU64Bitfield(&offset, item_byte_size,
item_bit_size, item_bit_offset)
? "true"
: "false");
else {
s->Printf("error: unsupported byte size (%" PRIu64
") for boolean format",
(uint64_t)item_byte_size);
return offset;
}
break;
```
> so we can write it to the dedicated error or warning stream
Yes, at the beginning I wanted to report this information in caller of `DumpDataExtractor`, but 1) There are many places and in some of them return value is ignored 2) Following the logic that an error/warning should be processed in the place where it was received, it should be processed right here.
```cpp
lldb::offset_t lldb_private::DumpDataExtractor(...)
...
if (item_format == eFormatInstruction)
return DumpInstructions(DE, s, exe_scope, start_offset, base_addr,
item_count);
...
```
https://github.com/llvm/llvm-project/pull/164413
More information about the lldb-commits
mailing list