[Lldb-commits] [lldb] [lldb][dump-debug-info] Fix `image dump separate-debug-info` in Release. (PR #68940)

via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 12 17:07:18 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Tom Yang (zhyty)

<details>
<summary>Changes</summary>

Follow up to #<!-- -->66035.

@<!-- -->kazutakahirata noticed ([comment](https://github.com/llvm/llvm-project/commit/64d78d8b3cd09dff32c97fbefa56bcfc8b676406#r129848406)) that I was reading structured data in assert statements which were being removed when asserts are disabled. I've removed the assert statements, which only existed as a sanity check anyway.

---
Full diff: https://github.com/llvm/llvm-project/pull/68940.diff


1 Files Affected:

- (modified) lldb/source/Commands/CommandObjectTarget.cpp (+15-7) 


``````````diff
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 0c378b069086d03..e1f54b810486611 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -2679,15 +2679,23 @@ class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
                 return false;
               }
 
+              // We expect to see "type", "symfile", and
+              // "separate-debug-info-files" as fields in the dictionary, even
+              // if they're empty.
               llvm::StringRef type;
+              separate_debug_info_list->GetValueForKeyAsString("type", type);
               llvm::StringRef symfile;
-              StructuredData::Array *files;
-              assert(separate_debug_info_list->GetValueForKeyAsString("type",
-                                                                      type));
-              assert(separate_debug_info_list->GetValueForKeyAsString("symfile",
-                                                                      symfile));
-              assert(separate_debug_info_list->GetValueForKeyAsArray(
-                  "separate-debug-info-files", files));
+              separate_debug_info_list->GetValueForKeyAsString("symfile",
+                                                               symfile);
+              StructuredData::Array *files = nullptr;
+              separate_debug_info_list->GetValueForKeyAsArray(
+                  "separate-debug-info-files", files);
+              if (files == nullptr) {
+                result.AppendWarningWithFormat(
+                    "Expected \"separate-debug-info-files\" field in separate "
+                    "debug info dictionary");
+                return false;
+              }
 
               strm << "Symbol file: " << symfile;
               strm.EOL();

``````````

</details>


https://github.com/llvm/llvm-project/pull/68940


More information about the lldb-commits mailing list