[Lldb-commits] [lldb] 459cfa5 - [LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan

Slava Gurevich via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 20 14:51:12 PDT 2022


Author: Slava Gurevich
Date: 2022-07-20T14:50:48-07:00
New Revision: 459cfa5e94d75b08aa421b79765ba1cd2126c4a4

URL: https://github.com/llvm/llvm-project/commit/459cfa5e94d75b08aa421b79765ba1cd2126c4a4
DIFF: https://github.com/llvm/llvm-project/commit/459cfa5e94d75b08aa421b79765ba1cd2126c4a4.diff

LOG: [LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan

Improve LLDB reliability by fixing the following "uninitialized variables" static code inspection warnings from
scan.coverity.com:

1094796 1095721 1095728 1095737 1095741
1095756 1095779 1095789 1095805 1214552
1229457 1232475 1274006 1274010 1293427
1364800 1364802 1364804 1364812 1364816
1374902 1374909 1384975 1399312 1420451
1431704 1454230 1454554 1454615 1454579
1454594 1454832 1457759 1458696 1461909
1467658 1487814 1487830 1487845

Differential Revision: https://reviews.llvm.org/D130098

Added: 
    

Modified: 
    lldb/include/lldb/Core/EmulateInstruction.h
    lldb/include/lldb/DataFormatters/TypeCategory.h
    lldb/include/lldb/DataFormatters/TypeSynthetic.h
    lldb/source/Commands/CommandObjectMemory.cpp
    lldb/source/Commands/CommandObjectTarget.cpp
    lldb/source/Commands/CommandObjectThread.cpp
    lldb/source/Commands/CommandObjectType.cpp
    lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
    lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
    lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
    lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
    lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
    lldb/source/Plugins/Language/ObjC/CFBasicHash.h
    lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
    lldb/source/Plugins/Language/ObjC/NSError.cpp
    lldb/source/Plugins/Language/ObjC/NSSet.cpp
    lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
    lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
    lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
    lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
    lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
    lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
    lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
    lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
    lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
    lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
    lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
    lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
    lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h
index f50fee095a8bb..e5421e5e91d1a 100644
--- a/lldb/include/lldb/Core/EmulateInstruction.h
+++ b/lldb/include/lldb/Core/EmulateInstruction.h
@@ -179,7 +179,7 @@ class EmulateInstruction : public PluginInterface {
     eInfoTypeISAAndImmediateSigned,
     eInfoTypeISA,
     eInfoTypeNoArgs
-  } InfoType;
+  };
 
   struct Context {
     ContextType type = eContextInvalid;

diff  --git a/lldb/include/lldb/DataFormatters/TypeCategory.h b/lldb/include/lldb/DataFormatters/TypeCategory.h
index 2c93059018372..16255f9488bda 100644
--- a/lldb/include/lldb/DataFormatters/TypeCategory.h
+++ b/lldb/include/lldb/DataFormatters/TypeCategory.h
@@ -331,7 +331,7 @@ class TypeCategoryImpl {
 
   std::vector<lldb::LanguageType> m_languages;
 
-  uint32_t m_enabled_position;
+  uint32_t m_enabled_position = 0;
 
   void Enable(bool value, uint32_t position);
 

diff  --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index 3f58297a529b3..890a6eb4f4487 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -266,7 +266,7 @@ class SyntheticChildren {
   uint32_t &GetRevision() { return m_my_revision; }
 
 protected:
-  uint32_t m_my_revision;
+  uint32_t m_my_revision = 0;
   Flags m_flags;
 
 private:

diff  --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index 3c07d19b35b26..ca0384cf9453d 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -275,7 +275,7 @@ class OptionGroupReadMemory : public OptionGroup {
   OptionValueUInt64 m_num_per_line;
   bool m_output_as_binary = false;
   OptionValueString m_view_as_type;
-  bool m_force;
+  bool m_force = false;
   OptionValueUInt64 m_offset;
   OptionValueLanguage m_language_for_type;
 };

diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index fdb57623077c6..3dcb35557bfe2 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -4616,7 +4616,7 @@ class CommandObjectTargetStopHookAdd : public CommandObjectParsed,
       m_class_name.clear();
       m_function_name.clear();
       m_line_start = 0;
-      m_line_end = UINT_MAX;
+      m_line_end = LLDB_INVALID_LINE_NUMBER;
       m_file_name.clear();
       m_module_name.clear();
       m_func_name_type_mask = eFunctionNameTypeAuto;
@@ -4637,23 +4637,23 @@ class CommandObjectTargetStopHookAdd : public CommandObjectParsed,
     std::string m_class_name;
     std::string m_function_name;
     uint32_t m_line_start = 0;
-    uint32_t m_line_end;
+    uint32_t m_line_end = LLDB_INVALID_LINE_NUMBER;
     std::string m_file_name;
     std::string m_module_name;
     uint32_t m_func_name_type_mask =
         eFunctionNameTypeAuto; // A pick from lldb::FunctionNameType.
-    lldb::tid_t m_thread_id;
-    uint32_t m_thread_index;
+    lldb::tid_t m_thread_id = LLDB_INVALID_THREAD_ID;
+    uint32_t m_thread_index = UINT32_MAX;
     std::string m_thread_name;
     std::string m_queue_name;
     bool m_sym_ctx_specified = false;
-    bool m_no_inlines;
+    bool m_no_inlines = false;
     bool m_thread_specified = false;
     // Instance variables to hold the values for one_liner options.
     bool m_use_one_liner = false;
     std::vector<std::string> m_one_liner;
 
-    bool m_auto_continue;
+    bool m_auto_continue = false;
   };
 
   CommandObjectTargetStopHookAdd(CommandInterpreter &interpreter)

diff  --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index d38427d8c2bc2..1371b9dbda1e2 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -877,8 +877,8 @@ class CommandObjectThreadUntil : public CommandObjectParsed {
       return llvm::makeArrayRef(g_thread_until_options);
     }
 
-    uint32_t m_step_thread_idx;
-    bool m_stop_others;
+    uint32_t m_step_thread_idx = LLDB_INVALID_THREAD_ID;
+    bool m_stop_others = false;
     std::vector<lldb::addr_t> m_until_addrs;
 
     // Instance variables to hold the values for command options.

diff  --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index 05759fe9e0021..e74d1188ee4b1 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -120,12 +120,12 @@ class CommandObjectTypeSummaryAdd : public CommandObjectParsed,
     // Instance variables to hold the values for command options.
 
     TypeSummaryImpl::Flags m_flags;
-    bool m_regex;
+    bool m_regex = false;
     std::string m_format_string;
     ConstString m_name;
     std::string m_python_script;
     std::string m_python_function;
-    bool m_is_add_script;
+    bool m_is_add_script = false;
     std::string m_category;
   };
 

diff  --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
index 5e2a866adb225..5dbbd209bd9b6 100644
--- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
@@ -49,6 +49,10 @@ HexagonDYLDRendezvous::HexagonDYLDRendezvous(Process *process)
     : m_process(process), m_rendezvous_addr(LLDB_INVALID_ADDRESS), m_current(),
       m_previous(), m_soentries(), m_added_soentries(), m_removed_soentries() {
   m_thread_info.valid = false;
+  m_thread_info.dtv_offset = 0;
+  m_thread_info.dtv_slot_size = 0;
+  m_thread_info.modid_offset = 0;
+  m_thread_info.tls_offset = 0;
 
   // Cache a copy of the executable path
   if (m_process) {

diff  --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
index 8b167dd347ad7..c877724a9d305 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
@@ -91,7 +91,8 @@ class EmulateInstructionARM : public EmulateInstruction {
 
   EmulateInstructionARM(const ArchSpec &arch)
       : EmulateInstruction(arch), m_arm_isa(0), m_opcode_mode(eModeInvalid),
-        m_opcode_cpsr(0), m_it_session(), m_ignore_conditions(false) {
+        m_opcode_cpsr(0), m_new_inst_cpsr(0), m_it_session(),
+        m_ignore_conditions(false) {
     SetArchitecture(arch);
   }
 

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 019b73780037c..db87aae6656ba 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -409,12 +409,12 @@ class ManglingSubstitutor
 private:
   /// Input character until which we have constructed the respective output
   /// already.
-  const char *Written;
+  const char *Written = "";
 
   llvm::SmallString<128> Result;
 
   /// Whether we have performed any substitutions.
-  bool Substituted;
+  bool Substituted = false;
 
   const char *currentParserPos() const { return this->First; }
 

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
index 9f5624de4e632..a1953a1c7a227 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -119,16 +119,16 @@ class AbstractListFrontEnd : public SyntheticChildrenFrontEnd {
   AbstractListFrontEnd(ValueObject &valobj)
       : SyntheticChildrenFrontEnd(valobj) {}
 
-  size_t m_count;
-  ValueObject *m_head;
+  size_t m_count = 0;
+  ValueObject *m_head = nullptr;
 
   static constexpr bool g_use_loop_detect = true;
-  size_t m_loop_detected; // The number of elements that have had loop detection
-                          // run over them.
+  size_t m_loop_detected = 0; // The number of elements that have had loop
+                              // detection run over them.
   ListEntry m_slow_runner; // Used for loop detection
   ListEntry m_fast_runner; // Used for loop detection
 
-  size_t m_list_capping_size;
+  size_t m_list_capping_size = 0;
   CompilerType m_element_type;
   std::map<size_t, ListIterator> m_iterators;
 

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index 4aae524e37015..ca6f92d003ad9 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -165,8 +165,8 @@ class MapIterator {
   }
 
   MapEntry m_entry;
-  size_t m_max_depth;
-  bool m_error;
+  size_t m_max_depth = 0;
+  bool m_error = false;
 };
 
 namespace lldb_private {

diff  --git a/lldb/source/Plugins/Language/ObjC/CFBasicHash.h b/lldb/source/Plugins/Language/ObjC/CFBasicHash.h
index fd30f5f7845ff..f850c50342a30 100644
--- a/lldb/source/Plugins/Language/ObjC/CFBasicHash.h
+++ b/lldb/source/Plugins/Language/ObjC/CFBasicHash.h
@@ -68,7 +68,7 @@ class CFBasicHash {
   ExecutionContextRef m_exe_ctx_ref;
   bool m_mutable = true;
   bool m_multi = false;
-  HashType m_type;
+  HashType m_type = HashType::set;
 };
 
 } // namespace lldb_private

diff  --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index 2c6998451ad60..e5e62b534560a 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -137,7 +137,7 @@ class NSDictionaryISyntheticFrontEnd : public SyntheticChildrenFrontEnd {
   lldb::ByteOrder m_order = lldb::eByteOrderInvalid;
   DataDescriptor_32 *m_data_32 = nullptr;
   DataDescriptor_64 *m_data_64 = nullptr;
-  lldb::addr_t m_data_ptr;
+  lldb::addr_t m_data_ptr = LLDB_INVALID_ADDRESS;
   CompilerType m_pair_type;
   std::vector<DictionaryItemDescriptor> m_children;
 };

diff  --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp
index 937c7204d3c4b..4f237824c4b06 100644
--- a/lldb/source/Plugins/Language/ObjC/NSError.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSError.cpp
@@ -177,7 +177,7 @@ class NSErrorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
   // values to leak if the latter, then I need to store a SharedPointer to it -
   // so that it only goes away when everyone else in the cluster goes away oh
   // joy!
-  ValueObject *m_child_ptr;
+  ValueObject *m_child_ptr = nullptr;
   ValueObjectSP m_child_sp;
 };
 

diff  --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
index 0a6b445d97c86..b5c8e849abccb 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
@@ -76,7 +76,7 @@ class NSSetISyntheticFrontEnd : public SyntheticChildrenFrontEnd {
   uint8_t m_ptr_size = 8;
   DataDescriptor_32 *m_data_32 = nullptr;
   DataDescriptor_64 *m_data_64 = nullptr;
-  lldb::addr_t m_data_ptr;
+  lldb::addr_t m_data_ptr = LLDB_INVALID_ADDRESS;
   std::vector<SetItemDescriptor> m_children;
 };
 

diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
index 7ba957940ae7b..0c6eccab9f27c 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
@@ -347,12 +347,12 @@ class ClassDescriptorV2Tagged : public ObjCLanguageRuntime::ClassDescriptor {
 
 private:
   ConstString m_name;
-  uint8_t m_pointer_size;
-  bool m_valid;
-  uint64_t m_info_bits;
-  uint64_t m_value_bits;
-  int64_t m_value_bits_signed;
-  uint64_t m_payload;
+  uint8_t m_pointer_size = 0;
+  bool m_valid = false;
+  uint64_t m_info_bits = 0;
+  uint64_t m_value_bits = 0;
+  int64_t m_value_bits_signed = 0;
+  uint64_t m_payload = 0;
 };
 
 } // namespace lldb_private

diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index f9ccaf0115a20..18e1d12ef9809 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -578,7 +578,8 @@ AppleObjCTrampolineHandler::AppleObjCTrampolineHandler(
     : m_process_wp(), m_objc_module_sp(objc_module_sp),
       m_impl_fn_addr(LLDB_INVALID_ADDRESS),
       m_impl_stret_fn_addr(LLDB_INVALID_ADDRESS),
-      m_msg_forward_addr(LLDB_INVALID_ADDRESS) {
+      m_msg_forward_addr(LLDB_INVALID_ADDRESS),
+      m_msg_forward_stret_addr(LLDB_INVALID_ADDRESS) {
   if (process_sp)
     m_process_wp = process_sp;
   // Look up the known resolution functions:
@@ -780,10 +781,8 @@ AppleObjCTrampolineHandler::FindDispatchFunction(lldb::addr_t addr) {
   return nullptr;
 }
 
-void
-AppleObjCTrampolineHandler::ForEachDispatchFunction(
-    std::function<void(lldb::addr_t, 
-                       const DispatchFunction &)> callback) {
+void AppleObjCTrampolineHandler::ForEachDispatchFunction(
+    std::function<void(lldb::addr_t, const DispatchFunction &)> callback) {
   for (auto elem : m_msgSend_map) {
     callback(elem.first, g_dispatch_functions[elem.second]);
   }

diff  --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index bc8e43764af69..0c032f8a7c88f 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -4163,7 +4163,7 @@ class CommandObjectRenderScriptRuntimeReductionBreakpointSet
     int m_kernel_types = RSReduceBreakpointResolver::eKernelTypeAll;
     llvm::StringRef m_reduce_name;
     RSCoordinate m_coord;
-    bool m_have_coord;
+    bool m_have_coord = false;
   };
 
   Options *GetOptions() override { return &m_options; }
@@ -4268,7 +4268,7 @@ class CommandObjectRenderScriptRuntimeKernelBreakpointSet
     }
 
     RSCoordinate m_coord;
-    bool m_have_coord;
+    bool m_have_coord = false;
   };
 
   bool DoExecute(Args &command, CommandReturnObject &result) override {

diff  --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
index 4ddf996dedb2f..bc460706fd295 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -171,7 +171,8 @@ struct RSReductionDescriptor {
                         llvm::StringRef halter_name = ".")
       : m_module(module), m_reduce_name(name), m_init_name(init_name),
         m_accum_name(accum_name), m_comb_name(comb_name),
-        m_outc_name(outc_name), m_halter_name(halter_name) {
+        m_outc_name(outc_name), m_halter_name(halter_name), m_accum_sig(0),
+        m_accum_data_size(0), m_comb_name_generated(false) {
     // TODO Check whether the combiner is an autogenerated name, and track
     // this
   }

diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index a27e64d158ae2..4323f83ea3e6f 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1302,7 +1302,7 @@ bool ObjectFileMachO::IsStripped() {
       for (uint32_t i = 0; i < m_header.ncmds; ++i) {
         const lldb::offset_t load_cmd_offset = offset;
 
-        llvm::MachO::load_command lc;
+        llvm::MachO::load_command lc = {};
         if (m_data.GetU32(&offset, &lc.cmd, 2) == nullptr)
           break;
         if (lc.cmd == LC_DYSYMTAB) {
@@ -5421,7 +5421,7 @@ std::string ObjectFileMachO::GetIdentifierString() {
     lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
     for (uint32_t i = 0; i < m_header.ncmds; ++i) {
       const uint32_t cmd_offset = offset;
-      llvm::MachO::load_command lc;
+      llvm::MachO::load_command lc = {};
       if (m_data.GetU32(&offset, &lc.cmd, 2) == nullptr)
         break;
       if (lc.cmd == LC_NOTE) {
@@ -5488,7 +5488,7 @@ addr_t ObjectFileMachO::GetAddressMask() {
     lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
     for (uint32_t i = 0; i < m_header.ncmds; ++i) {
       const uint32_t cmd_offset = offset;
-      llvm::MachO::load_command lc;
+      llvm::MachO::load_command lc = {};
       if (m_data.GetU32(&offset, &lc.cmd, 2) == nullptr)
         break;
       if (lc.cmd == LC_NOTE) {
@@ -5535,7 +5535,7 @@ bool ObjectFileMachO::GetCorefileMainBinaryInfo(addr_t &value,
     lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
     for (uint32_t i = 0; i < m_header.ncmds; ++i) {
       const uint32_t cmd_offset = offset;
-      llvm::MachO::load_command lc;
+      llvm::MachO::load_command lc = {};
       if (m_data.GetU32(&offset, &lc.cmd, 2) == nullptr)
         break;
       if (lc.cmd == LC_NOTE) {
@@ -5945,7 +5945,7 @@ llvm::VersionTuple ObjectFileMachO::GetMinimumOSVersion() {
     for (uint32_t i = 0; i < m_header.ncmds; ++i) {
       const lldb::offset_t load_cmd_offset = offset;
 
-      llvm::MachO::version_min_command lc;
+      llvm::MachO::version_min_command lc = {};
       if (m_data.GetU32(&offset, &lc.cmd, 2) == nullptr)
         break;
       if (lc.cmd == llvm::MachO::LC_VERSION_MIN_MACOSX ||
@@ -6006,7 +6006,7 @@ llvm::VersionTuple ObjectFileMachO::GetSDKVersion() {
     for (uint32_t i = 0; i < m_header.ncmds; ++i) {
       const lldb::offset_t load_cmd_offset = offset;
 
-      llvm::MachO::version_min_command lc;
+      llvm::MachO::version_min_command lc = {};
       if (m_data.GetU32(&offset, &lc.cmd, 2) == nullptr)
         break;
       if (lc.cmd == llvm::MachO::LC_VERSION_MIN_MACOSX ||
@@ -6035,7 +6035,7 @@ llvm::VersionTuple ObjectFileMachO::GetSDKVersion() {
       for (uint32_t i = 0; i < m_header.ncmds; ++i) {
         const lldb::offset_t load_cmd_offset = offset;
 
-        llvm::MachO::version_min_command lc;
+        llvm::MachO::version_min_command lc = {};
         if (m_data.GetU32(&offset, &lc.cmd, 2) == nullptr)
           break;
         if (lc.cmd == llvm::MachO::LC_BUILD_VERSION) {
@@ -6864,7 +6864,7 @@ ObjectFileMachO::GetCorefileAllImageInfos() {
   lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
   for (uint32_t i = 0; i < m_header.ncmds; ++i) {
     const uint32_t cmd_offset = offset;
-    llvm::MachO::load_command lc;
+    llvm::MachO::load_command lc = {};
     if (m_data.GetU32(&offset, &lc.cmd, 2) == nullptr)
       break;
     if (lc.cmd == LC_NOTE) {

diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
index b4f4ba6242a16..150b39486381b 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
@@ -271,8 +271,8 @@ class ObjectFileMachO : public lldb_private::ObjectFile {
   typedef lldb_private::RangeVector<uint32_t, uint32_t> FileRangeArray;
   lldb_private::Address m_entry_point_address;
   FileRangeArray m_thread_context_offsets;
-  lldb::offset_t m_linkedit_original_offset;
-  lldb::addr_t m_text_address;
+  lldb::offset_t m_linkedit_original_offset = 0;
+  lldb::addr_t m_text_address = LLDB_INVALID_ADDRESS;
   bool m_thread_context_offsets_valid;
   lldb_private::FileSpecList m_reexported_dylibs;
   bool m_allow_assembly_emulation_unwind_plans;

diff  --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 516bcb21b0193..acb131b8a775a 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -349,6 +349,7 @@ llvm::support::ulittle64_t read_register_u64(RegisterContext *reg_ctx,
 lldb_private::minidump::MinidumpContext_x86_64
 GetThreadContext_64(RegisterContext *reg_ctx) {
   lldb_private::minidump::MinidumpContext_x86_64 thread_context;
+  thread_context.p1_home = {};
   thread_context.context_flags = static_cast<uint32_t>(
       lldb_private::minidump::MinidumpContext_x86_64_Flags::x86_64_Flag |
       lldb_private::minidump::MinidumpContext_x86_64_Flags::Control |

diff  --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 45593e95863a2..800bd9d6e1e39 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -414,22 +414,18 @@ ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
                                    lldb::offset_t file_offset,
                                    lldb::offset_t length)
     : ObjectFile(module_sp, file, file_offset, length, data_sp, data_offset),
-      m_dos_header(), m_coff_header(), m_sect_headers(),
-      m_entry_point_address(), m_deps_filespec() {
-  ::memset(&m_dos_header, 0, sizeof(m_dos_header));
-  ::memset(&m_coff_header, 0, sizeof(m_coff_header));
-}
+      m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(),
+      m_image_base(LLDB_INVALID_ADDRESS), m_entry_point_address(),
+      m_deps_filespec() {}
 
 ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
                                    WritableDataBufferSP header_data_sp,
                                    const lldb::ProcessSP &process_sp,
                                    addr_t header_addr)
     : ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
-      m_dos_header(), m_coff_header(), m_sect_headers(),
-      m_entry_point_address(), m_deps_filespec() {
-  ::memset(&m_dos_header, 0, sizeof(m_dos_header));
-  ::memset(&m_coff_header, 0, sizeof(m_coff_header));
-}
+      m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(),
+      m_image_base(LLDB_INVALID_ADDRESS), m_entry_point_address(),
+      m_deps_filespec() {}
 
 ObjectFilePECOFF::~ObjectFilePECOFF() = default;
 

diff  --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
index b22dee1033f74..ca1a61735879a 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -153,40 +153,40 @@ class ObjectFilePECOFF : public lldb_private::ObjectFile {
   bool NeedsEndianSwap() const;
 
   typedef struct dos_header { // DOS .EXE header
-    uint16_t e_magic;         // Magic number
-    uint16_t e_cblp;          // Bytes on last page of file
-    uint16_t e_cp;            // Pages in file
-    uint16_t e_crlc;          // Relocations
-    uint16_t e_cparhdr;       // Size of header in paragraphs
-    uint16_t e_minalloc;      // Minimum extra paragraphs needed
-    uint16_t e_maxalloc;      // Maximum extra paragraphs needed
-    uint16_t e_ss;            // Initial (relative) SS value
-    uint16_t e_sp;            // Initial SP value
-    uint16_t e_csum;          // Checksum
-    uint16_t e_ip;            // Initial IP value
-    uint16_t e_cs;            // Initial (relative) CS value
-    uint16_t e_lfarlc;        // File address of relocation table
-    uint16_t e_ovno;          // Overlay number
+    uint16_t e_magic = 0;     // Magic number
+    uint16_t e_cblp = 0;      // Bytes on last page of file
+    uint16_t e_cp = 0;        // Pages in file
+    uint16_t e_crlc = 0;      // Relocations
+    uint16_t e_cparhdr = 0;   // Size of header in paragraphs
+    uint16_t e_minalloc = 0;  // Minimum extra paragraphs needed
+    uint16_t e_maxalloc = 0;  // Maximum extra paragraphs needed
+    uint16_t e_ss = 0;        // Initial (relative) SS value
+    uint16_t e_sp = 0;        // Initial SP value
+    uint16_t e_csum = 0;      // Checksum
+    uint16_t e_ip = 0;        // Initial IP value
+    uint16_t e_cs = 0;        // Initial (relative) CS value
+    uint16_t e_lfarlc = 0;    // File address of relocation table
+    uint16_t e_ovno = 0;      // Overlay number
     uint16_t e_res[4];        // Reserved words
-    uint16_t e_oemid;         // OEM identifier (for e_oeminfo)
-    uint16_t e_oeminfo;       // OEM information; e_oemid specific
-    uint16_t e_res2[10];      // Reserved words
-    uint32_t e_lfanew;        // File address of new exe header
+    uint16_t e_oemid = 0;     // OEM identifier (for e_oeminfo)
+    uint16_t e_oeminfo = 0;   // OEM information; e_oemid specific
+    uint16_t e_res2[10] = {}; // Reserved words
+    uint32_t e_lfanew = 0;    // File address of new exe header
   } dos_header_t;
 
   typedef struct coff_header {
-    uint16_t machine;
-    uint16_t nsects;
-    uint32_t modtime;
-    uint32_t symoff;
-    uint32_t nsyms;
-    uint16_t hdrsize;
-    uint16_t flags;
+    uint16_t machine = 0;
+    uint16_t nsects = 0;
+    uint32_t modtime = 0;
+    uint32_t symoff = 0;
+    uint32_t nsyms = 0;
+    uint16_t hdrsize = 0;
+    uint16_t flags = 0;
   } coff_header_t;
 
   typedef struct data_directory {
-    uint32_t vmaddr;
-    uint32_t vmsize;
+    uint32_t vmaddr = 0;
+    uint32_t vmsize = 0;
   } data_directory_t;
 
   typedef struct coff_opt_header {
@@ -232,39 +232,39 @@ class ObjectFilePECOFF : public lldb_private::ObjectFile {
   };
 
   typedef struct section_header {
-    char name[8];
-    uint32_t vmsize;  // Virtual Size
-    uint32_t vmaddr;  // Virtual Addr
-    uint32_t size;    // File size
-    uint32_t offset;  // File offset
-    uint32_t reloff;  // Offset to relocations
-    uint32_t lineoff; // Offset to line table entries
-    uint16_t nreloc;  // Number of relocation entries
-    uint16_t nline;   // Number of line table entries
-    uint32_t flags;
+    char name[8] = {};
+    uint32_t vmsize = 0;  // Virtual Size
+    uint32_t vmaddr = 0;  // Virtual Addr
+    uint32_t size = 0;    // File size
+    uint32_t offset = 0;  // File offset
+    uint32_t reloff = 0;  // Offset to relocations
+    uint32_t lineoff = 0; // Offset to line table entries
+    uint16_t nreloc = 0;  // Number of relocation entries
+    uint16_t nline = 0;   // Number of line table entries
+    uint32_t flags = 0;
   } section_header_t;
 
   typedef struct coff_symbol {
-    char name[8];
-    uint32_t value;
-    uint16_t sect;
-    uint16_t type;
-    uint8_t storage;
-    uint8_t naux;
+    char name[8] = {};
+    uint32_t value = 0;
+    uint16_t sect = 0;
+    uint16_t type = 0;
+    uint8_t storage = 0;
+    uint8_t naux = 0;
   } coff_symbol_t;
 
   typedef struct export_directory_entry {
-    uint32_t characteristics;
-    uint32_t time_date_stamp;
-    uint16_t major_version;
-    uint16_t minor_version;
-    uint32_t name;
-    uint32_t base;
-    uint32_t number_of_functions;
-    uint32_t number_of_names;
-    uint32_t address_of_functions;
-    uint32_t address_of_names;
-    uint32_t address_of_name_ordinals;
+    uint32_t characteristics = 0;
+    uint32_t time_date_stamp = 0;
+    uint16_t major_version = 0;
+    uint16_t minor_version = 0;
+    uint32_t name = 0;
+    uint32_t base = 0;
+    uint32_t number_of_functions = 0;
+    uint32_t number_of_names = 0;
+    uint32_t address_of_functions = 0;
+    uint32_t address_of_names = 0;
+    uint32_t address_of_name_ordinals = 0;
   } export_directory_entry;
 
   static bool ParseDOSHeader(lldb_private::DataExtractor &data,

diff  --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
index 67e03ff1ea39c..40f70e8a0a75f 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
@@ -444,6 +444,7 @@ RegisterContextPOSIX_x86::RegisterContextPOSIX_x86(
   }
 
   ::memset(&m_fpr, 0, sizeof(FPR));
+  ::memset(&m_ymm_set, 0, sizeof(YMM));
 
   m_fpr_type = eNotValid;
 }

diff  --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index e5461c1899ec8..755b8220c49ea 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -67,8 +67,8 @@ GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name,
       m_packet_timeout(1),
 #endif
       m_echo_number(0), m_supports_qEcho(eLazyBoolCalculate), m_history(512),
-      m_send_acks(true), m_compression_type(CompressionType::None),
-      m_listen_url() {
+      m_send_acks(true), m_is_platform(false),
+      m_compression_type(CompressionType::None), m_listen_url() {
 }
 
 // Destructor
@@ -1266,7 +1266,7 @@ GDBRemoteCommunication::ConnectLocally(GDBRemoteCommunication &client,
 
 GDBRemoteCommunication::ScopedTimeout::ScopedTimeout(
     GDBRemoteCommunication &gdb_comm, std::chrono::seconds timeout)
-    : m_gdb_comm(gdb_comm), m_timeout_modified(false) {
+    : m_gdb_comm(gdb_comm), m_saved_timeout(0), m_timeout_modified(false) {
   auto curr_timeout = gdb_comm.GetPacketTimeout();
   // Only update the timeout if the timeout is greater than the current
   // timeout. If the current timeout is larger, then just use that.

diff  --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
index 88c36a5b0af32..dbe2ed85c8bdc 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
@@ -174,6 +174,14 @@ class SystemRuntimeMacOSX : public lldb_private::SystemRuntime {
       dqo_target_queue = UINT16_MAX;
       dqo_target_queue = UINT16_MAX;
       dqo_priority = UINT16_MAX;
+      dqo_label_size = 0;
+      dqo_flags_size = 0;
+      dqo_serialnum_size = 0;
+      dqo_width_size = 0;
+      dqo_running_size = 0;
+      dqo_suspend_cnt_size = 0;
+      dqo_target_queue_size = 0;
+      dqo_priority_size = 0;
     }
 
     bool IsValid() { return dqo_version != UINT16_MAX; }

diff  --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
index 97cb04e51408e..796e7e50a8b90 100644
--- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
+++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
@@ -64,8 +64,8 @@ class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssembly {
                               lldb_private::EmulateInstruction *inst_emulator)
       : UnwindAssembly(arch), m_inst_emulator_up(inst_emulator),
         m_range_ptr(nullptr), m_unwind_plan_ptr(nullptr), m_curr_row(),
-        m_cfa_reg_info(), m_fp_is_cfa(false), m_register_values(),
-        m_pushed_regs(), m_curr_row_modified(false),
+        m_initial_sp(0), m_cfa_reg_info(), m_fp_is_cfa(false),
+        m_register_values(), m_pushed_regs(), m_curr_row_modified(false),
         m_forward_branch_offset(0) {
     if (m_inst_emulator_up.get()) {
       m_inst_emulator_up->SetBaton(this);

diff  --git a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
index 36e7b90cad24e..92eec139e07c9 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -24,11 +24,12 @@ x86AssemblyInspectionEngine::x86AssemblyInspectionEngine(const ArchSpec &arch)
     : m_cur_insn(nullptr), m_machine_ip_regnum(LLDB_INVALID_REGNUM),
       m_machine_sp_regnum(LLDB_INVALID_REGNUM),
       m_machine_fp_regnum(LLDB_INVALID_REGNUM),
+      m_machine_alt_fp_regnum(LLDB_INVALID_REGNUM),
       m_lldb_ip_regnum(LLDB_INVALID_REGNUM),
       m_lldb_sp_regnum(LLDB_INVALID_REGNUM),
       m_lldb_fp_regnum(LLDB_INVALID_REGNUM),
-
-      m_reg_map(), m_arch(arch), m_cpu(k_cpu_unspecified), m_wordsize(-1),
+      m_lldb_alt_fp_regnum(LLDB_INVALID_REGNUM), m_reg_map(), m_arch(arch),
+      m_cpu(k_cpu_unspecified), m_wordsize(-1),
       m_register_map_initialized(false), m_disasm_context() {
   m_disasm_context =
       ::LLVMCreateDisasm(arch.GetTriple().getTriple().c_str(), nullptr,


        


More information about the lldb-commits mailing list