[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan. Part 3
Improve LLDB reliability by fixing the following "uninitialized variables" static code inspection warnings from
scan.coverity.com/projects/llvm:
1355854, 1347549, 1316348, 1372028, 1431625,
1315634, 1315637, 1355855, 1364803, 1420505,
1420563, 1420685, 1366014, 1203966, 1204029,
1204031, 1204032, 1328411, 1325969, 1325968,
1374921, 1094809
Differential Revision: https://reviews.llvm.org/D130602
GitOrigin-RevId: 24301569f080d60f644d7a69496596cbd65079ce
diff --git a/include/lldb/Core/LoadedModuleInfoList.h b/include/lldb/Core/LoadedModuleInfoList.h
index 6ff4565..537a2b0 100644
--- a/include/lldb/Core/LoadedModuleInfoList.h
+++ b/include/lldb/Core/LoadedModuleInfoList.h
@@ -95,10 +95,10 @@
protected:
bool m_has[e_num];
std::string m_name;
- lldb::addr_t m_link_map;
- lldb::addr_t m_base;
- bool m_base_is_offset;
- lldb::addr_t m_dynamic;
+ lldb::addr_t m_link_map = LLDB_INVALID_ADDRESS;
+ lldb::addr_t m_base = LLDB_INVALID_ADDRESS;
+ bool m_base_is_offset = false;
+ lldb::addr_t m_dynamic = LLDB_INVALID_ADDRESS;
};
LoadedModuleInfoList() = default;
diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h
index 30bc8cb..a826410 100644
--- a/include/lldb/DataFormatters/TypeSummary.h
+++ b/include/lldb/DataFormatters/TypeSummary.h
@@ -263,7 +263,7 @@
typedef std::shared_ptr<TypeSummaryImpl> SharedPointer;
protected:
- uint32_t m_my_revision;
+ uint32_t m_my_revision = 0;
Flags m_flags;
TypeSummaryImpl(Kind kind, const TypeSummaryImpl::Flags &flags);
diff --git a/include/lldb/Symbol/DebugMacros.h b/include/lldb/Symbol/DebugMacros.h
index 0ea70f5..fbc5be0 100644
--- a/include/lldb/Symbol/DebugMacros.h
+++ b/include/lldb/Symbol/DebugMacros.h
@@ -39,7 +39,7 @@
static DebugMacroEntry
CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp);
- DebugMacroEntry() : m_type(INVALID) {}
+ DebugMacroEntry() : m_type(INVALID), m_line(0), m_debug_line_file_idx(0) {}
~DebugMacroEntry() = default;
diff --git a/include/lldb/Target/ProcessStructReader.h b/include/lldb/Target/ProcessStructReader.h
index 8046ef4..4af51ca 100644
--- a/include/lldb/Target/ProcessStructReader.h
+++ b/include/lldb/Target/ProcessStructReader.h
@@ -39,7 +39,8 @@
public:
ProcessStructReader(Process *process, lldb::addr_t base_addr,
- CompilerType struct_type) {
+ CompilerType struct_type)
+ : m_byte_order(lldb::eByteOrderInvalid), m_addr_byte_size(0) {
if (!process)
return;
if (base_addr == 0 || base_addr == LLDB_INVALID_ADDRESS)
diff --git a/include/lldb/Utility/Args.h b/include/lldb/Utility/Args.h
index cecf6b1..7c20288 100644
--- a/include/lldb/Utility/Args.h
+++ b/include/lldb/Utility/Args.h
@@ -39,7 +39,7 @@
friend struct llvm::yaml::MappingTraits<Args::ArgEntry>;
std::unique_ptr<char[]> ptr;
- char quote;
+ char quote = '\0';
char *data() { return ptr.get(); }
@@ -395,7 +395,7 @@
return lldb_private::Args::ArgEntry(value, quote);
}
StringRef value;
- uint8_t quote;
+ uint8_t quote = '\0';
};
static void mapping(IO &io, lldb_private::Args::ArgEntry &v);
};
diff --git a/include/lldb/Utility/RegisterValue.h b/include/lldb/Utility/RegisterValue.h
index 1ece4f0..a0bd493 100644
--- a/include/lldb/Utility/RegisterValue.h
+++ b/include/lldb/Utility/RegisterValue.h
@@ -263,8 +263,8 @@
mutable uint8_t
bytes[kMaxRegisterByteSize]; // This must be big enough to hold any
// register for any supported target.
- uint16_t length;
- lldb::ByteOrder byte_order;
+ uint16_t length = 0;
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid;
} buffer;
};
diff --git a/include/lldb/Utility/StringExtractorGDBRemote.h b/include/lldb/Utility/StringExtractorGDBRemote.h
index d869950..86a3a39 100644
--- a/include/lldb/Utility/StringExtractorGDBRemote.h
+++ b/include/lldb/Utility/StringExtractorGDBRemote.h
@@ -215,7 +215,7 @@
protected:
ResponseValidatorCallback m_validator = nullptr;
- void *m_validator_baton;
+ void *m_validator_baton = nullptr;
};
#endif // LLDB_UTILITY_STRINGEXTRACTORGDBREMOTE_H
diff --git a/source/Breakpoint/BreakpointOptions.cpp b/source/Breakpoint/BreakpointOptions.cpp
index 6fc6948..31779fb 100644
--- a/source/Breakpoint/BreakpointOptions.cpp
+++ b/source/Breakpoint/BreakpointOptions.cpp
@@ -115,7 +115,8 @@
: m_callback(BreakpointOptions::NullCallback),
m_baton_is_command_baton(false), m_callback_is_synchronous(false),
m_enabled(true), m_one_shot(false), m_ignore_count(0),
- m_condition_text_hash(0), m_auto_continue(false), m_set_flags(0) {
+ m_condition_text_hash(0), m_inject_condition(false),
+ m_auto_continue(false), m_set_flags(0) {
if (all_flags_set)
m_set_flags.Set(~((Flags::ValueType)0));
}
@@ -125,11 +126,9 @@
bool auto_continue)
: m_callback(nullptr), m_baton_is_command_baton(false),
m_callback_is_synchronous(false), m_enabled(enabled),
- m_one_shot(one_shot), m_ignore_count(ignore),
- m_condition_text_hash(0), m_auto_continue(auto_continue)
-{
- m_set_flags.Set(eEnabled | eIgnoreCount | eOneShot
- | eAutoContinue);
+ m_one_shot(one_shot), m_ignore_count(ignore), m_condition_text_hash(0),
+ m_inject_condition(false), m_auto_continue(auto_continue) {
+ m_set_flags.Set(eEnabled | eIgnoreCount | eOneShot | eAutoContinue);
if (condition && *condition != '\0') {
SetCondition(condition);
}
@@ -141,8 +140,8 @@
m_baton_is_command_baton(rhs.m_baton_is_command_baton),
m_callback_is_synchronous(rhs.m_callback_is_synchronous),
m_enabled(rhs.m_enabled), m_one_shot(rhs.m_one_shot),
- m_ignore_count(rhs.m_ignore_count), m_auto_continue(rhs.m_auto_continue),
- m_set_flags(rhs.m_set_flags) {
+ m_ignore_count(rhs.m_ignore_count), m_inject_condition(false),
+ m_auto_continue(rhs.m_auto_continue), m_set_flags(rhs.m_set_flags) {
if (rhs.m_thread_spec_up != nullptr)
m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
m_condition_text = rhs.m_condition_text;
@@ -163,6 +162,7 @@
m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
m_condition_text = rhs.m_condition_text;
m_condition_text_hash = rhs.m_condition_text_hash;
+ m_inject_condition = rhs.m_inject_condition;
m_auto_continue = rhs.m_auto_continue;
m_set_flags = rhs.m_set_flags;
return *this;
diff --git a/source/Core/Debugger.cpp b/source/Core/Debugger.cpp
index 62857c1..d034905 100644
--- a/source/Core/Debugger.cpp
+++ b/source/Core/Debugger.cpp
@@ -201,7 +201,7 @@
}
TargetSP target_sp;
- LoadScriptFromSymFile load_script_old_value;
+ LoadScriptFromSymFile load_script_old_value = eLoadScriptFromSymFileFalse;
if (is_load_script && exe_ctx->GetTargetSP()) {
target_sp = exe_ctx->GetTargetSP();
load_script_old_value =
diff --git a/source/Core/IOHandlerCursesGUI.cpp b/source/Core/IOHandlerCursesGUI.cpp
index 0151255..e9073c8 100644
--- a/source/Core/IOHandlerCursesGUI.cpp
+++ b/source/Core/IOHandlerCursesGUI.cpp
@@ -588,9 +588,10 @@
}
Window(const char *name, const Rect &bounds)
- : Surface(Surface::Type::Window), m_name(name), m_parent(nullptr),
- m_subwindows(), m_delegate_sp(), m_curr_active_window_idx(UINT32_MAX),
- m_prev_active_window_idx(UINT32_MAX), m_delete(true),
+ : Surface(Surface::Type::Window), m_name(name), m_panel(nullptr),
+ m_parent(nullptr), m_subwindows(), m_delegate_sp(),
+ m_curr_active_window_idx(UINT32_MAX),
+ m_prev_active_window_idx(UINT32_MAX), m_delete(false),
m_needs_update(true), m_can_activate(true), m_is_subwin(false) {
Reset(::newwin(bounds.size.height, bounds.size.width, bounds.origin.y,
bounds.origin.y));
@@ -5702,8 +5703,8 @@
uint32_t m_selected_row_idx = 0;
uint32_t m_first_visible_row = 0;
uint32_t m_num_rows = 0;
- int m_min_x;
- int m_min_y;
+ int m_min_x = 0;
+ int m_min_y = 0;
int m_max_x = 0;
int m_max_y = 0;
diff --git a/source/Expression/FunctionCaller.cpp b/source/Expression/FunctionCaller.cpp
index 307bed1..fdbaa91 100644
--- a/source/Expression/FunctionCaller.cpp
+++ b/source/Expression/FunctionCaller.cpp
@@ -44,7 +44,8 @@
m_function_return_type(return_type),
m_wrapper_function_name("__lldb_caller_function"),
m_wrapper_struct_name("__lldb_caller_struct"), m_wrapper_args_addrs(),
- m_struct_valid(false), m_arg_values(arg_value_list), m_compiled(false),
+ m_struct_valid(false), m_struct_size(0), m_return_size(0),
+ m_return_offset(0), m_arg_values(arg_value_list), m_compiled(false),
m_JITted(false) {
m_jit_process_wp = lldb::ProcessWP(exe_scope.CalculateProcess());
// Can't make a FunctionCaller without a process.
diff --git a/source/Expression/LLVMUserExpression.cpp b/source/Expression/LLVMUserExpression.cpp
index d676608..6d11abb 100644
--- a/source/Expression/LLVMUserExpression.cpp
+++ b/source/Expression/LLVMUserExpression.cpp
@@ -48,8 +48,8 @@
m_stack_frame_bottom(LLDB_INVALID_ADDRESS),
m_stack_frame_top(LLDB_INVALID_ADDRESS), m_allow_cxx(false),
m_allow_objc(false), m_transformed_text(), m_execution_unit_sp(),
- m_materializer_up(), m_jit_module_wp(), m_can_interpret(false),
- m_materialized_address(LLDB_INVALID_ADDRESS) {}
+ m_materializer_up(), m_jit_module_wp(), m_target(nullptr),
+ m_can_interpret(false), m_materialized_address(LLDB_INVALID_ADDRESS) {}
LLVMUserExpression::~LLVMUserExpression() {
if (m_target) {
diff --git a/source/Host/common/MainLoop.cpp b/source/Host/common/MainLoop.cpp
index 8e384c9..473a3c7 100644
--- a/source/Host/common/MainLoop.cpp
+++ b/source/Host/common/MainLoop.cpp
@@ -255,7 +255,7 @@
}
#endif
-MainLoop::MainLoop() {
+MainLoop::MainLoop() : m_terminate_request(false) {
#if HAVE_SYS_EVENT_H
m_kqueue = kqueue();
assert(m_kqueue >= 0);
diff --git a/source/Interpreter/OptionGroupFormat.cpp b/source/Interpreter/OptionGroupFormat.cpp
index a2ca9ff..f44f82c 100644
--- a/source/Interpreter/OptionGroupFormat.cpp
+++ b/source/Interpreter/OptionGroupFormat.cpp
@@ -37,7 +37,7 @@
: m_format(default_format, default_format),
m_byte_size(default_byte_size, default_byte_size),
m_count(default_count, default_count), m_prev_gdb_format('x'),
- m_prev_gdb_size('w') {
+ m_prev_gdb_size('w'), m_has_gdb_format(false) {
// Copy the default option definitions.
std::copy(std::begin(g_default_option_definitions),
std::end(g_default_option_definitions),
diff --git a/source/Interpreter/OptionGroupVariable.cpp b/source/Interpreter/OptionGroupVariable.cpp
index 20a521b..fb92c51 100644
--- a/source/Interpreter/OptionGroupVariable.cpp
+++ b/source/Interpreter/OptionGroupVariable.cpp
@@ -67,8 +67,10 @@
}
OptionGroupVariable::OptionGroupVariable(bool show_frame_options)
- : include_frame_options(show_frame_options), summary(ValidateNamedSummary),
- summary_string(ValidateSummaryString) {}
+ : include_frame_options(show_frame_options), show_args(false),
+ show_recognized_args(false), show_locals(false), show_globals(false),
+ use_regex(false), show_scope(false), show_decl(false),
+ summary(ValidateNamedSummary), summary_string(ValidateSummaryString) {}
Status
OptionGroupVariable::SetOptionValue(uint32_t option_idx,