[Lldb-commits] [lldb] [lldb] Support custom printf formatting for variables (PR #81196)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Feb 8 14:02:28 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Dave Lee (kastiglione)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/81196.diff
1 Files Affected:
- (modified) lldb/source/Core/FormatEntity.cpp (+23-2)
``````````diff
diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp
index fa5eadc6ff4e9a..0e929203935304 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -883,8 +883,29 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
}
if (!is_array_range) {
- LLDB_LOGF(log,
- "[Debugger::FormatPrompt] dumping ordinary printable output");
+ if (!entry.printf_format.empty()) {
+ auto type_info = target->GetTypeInfo();
+ if (type_info & eTypeIsInteger) {
+ if (type_info & eTypeIsSigned) {
+ bool success = false;
+ auto integer = target->GetValueAsSigned(0, &success);
+ if (success) {
+ LLDB_LOGF(log, "dumping using printf format");
+ s.Printf(entry.printf_format.c_str(), integer);
+ return true;
+ }
+ } else {
+ bool success = false;
+ auto integer = target->GetValueAsUnsigned(0, &success);
+ if (success) {
+ LLDB_LOGF(log, "dumping using printf format");
+ s.Printf(entry.printf_format.c_str(), integer);
+ return true;
+ }
+ }
+ }
+ }
+ LLDB_LOGF(log, "dumping ordinary printable output");
return target->DumpPrintableRepresentation(s, val_obj_display,
custom_format);
} else {
``````````
</details>
https://github.com/llvm/llvm-project/pull/81196
More information about the lldb-commits
mailing list