Hello, Here are a few changes that try to address some logic error bugs reported by running scan-build over the LLDB code base.
I have no background in compiler technology and I may have been trying to fix false positives; here is a quick overview of what scan-build reported, let me know if the fixes are relevant: Bug Group: Dead store Bug Type: Dead assignment Files: source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp Bug Group: Logic error Bug Type: Called C++ object pointer is null Files: source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp Bug Group: Logic error Bug Type: Called C++ object pointer is null Files: source/API/SBThread.cpp Bug group: Logic error Bug Type: Branch condition evaluates to a garbage value Files: source/Core/DynamicLoader.cpp Bug Group: API Bug Type: Argument with 'nonnull' attribute passed null Files: source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp Cheers. -- Apelete
diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp index 015a42d..34a9f15 100644 --- a/source/API/SBThread.cpp +++ b/source/API/SBThread.cpp @@ -960,7 +960,7 @@ SBThread::StepOutOfFrame (lldb::SBFrame &sb_frame) bool abort_other_plans = false; bool stop_other_threads = false; Thread *thread = exe_ctx.GetThreadPtr(); - if (sb_frame.GetThread().GetThreadID() != thread->GetID()) + if (sb_frame.GetThread().GetThreadID() != thread->GetID() && log) { log->Printf("SBThread(%p)::StepOutOfFrame passed a frame from another thread (0x%" PRIx64 " vrs. 0x%" PRIx64 ", returning.", static_cast<void*>(exe_ctx.GetThreadPtr()), diff --git a/source/Core/DynamicLoader.cpp b/source/Core/DynamicLoader.cpp index 0edc8c0..f41ff4a 100644 --- a/source/Core/DynamicLoader.cpp +++ b/source/Core/DynamicLoader.cpp @@ -194,7 +194,7 @@ DynamicLoader::LoadModuleAtAddress(const FileSpec &file, { // Try to fetch the load address of the file from the process as we need absolute load // address to read the file out of the memory instead of a load bias. - bool is_loaded; + bool is_loaded = false; lldb::addr_t load_addr; Error error = m_process->GetFileLoadAddress(file, is_loaded, load_addr); if (error.Success() && is_loaded) diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp index 7074671..5c92f60 100644 --- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp +++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp @@ -306,23 +306,27 @@ ABISysV_mips64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb if (num_bytes <= 16) { - const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0); + const RegisterInfo *r2_info = nullptr; + + if (reg_ctx) + r2_info = reg_ctx->GetRegisterInfoByName("r2", 0); + if (num_bytes <= 8) { uint64_t raw_value = data.GetMaxU64(&offset, num_bytes); - if (!reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value)) + if (reg_ctx && !reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value)) error.SetErrorString ("failed to write register r2"); } else { uint64_t raw_value = data.GetMaxU64(&offset, 8); - if (reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value)) + if (reg_ctx && reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value)) { const RegisterInfo *r3_info = reg_ctx->GetRegisterInfoByName("r3", 0); raw_value = data.GetMaxU64(&offset, num_bytes - offset); - if (!reg_ctx->WriteRegisterFromUnsigned (r3_info, raw_value)) + if (reg_ctx && !reg_ctx->WriteRegisterFromUnsigned (r3_info, raw_value)) error.SetErrorString ("failed to write register r3"); } else diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp b/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp index 1bb1079..378b84f 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp @@ -468,7 +468,6 @@ DWARFASTParserJava::ParseChildMembers(const DWARFDIE &parent_die, CompilerType & DWARFFormValue encoding_uid; uint32_t member_byte_offset = UINT32_MAX; DWARFExpression member_location_expression(dwarf_cu); - bool artificial = true; DWARFAttributes attributes; size_t num_attributes = die.GetAttributes(attributes); @@ -494,7 +493,7 @@ DWARFASTParserJava::ParseChildMembers(const DWARFDIE &parent_die, CompilerType & member_byte_offset = form_value.Unsigned(); break; case DW_AT_artificial: - artificial = form_value.Boolean(); + // TODO: Handle when needed break; case DW_AT_accessibility: // TODO: Handle when needed @@ -506,7 +505,7 @@ DWARFASTParserJava::ParseChildMembers(const DWARFDIE &parent_die, CompilerType & } } - if (strcmp(name, ".dynamic_type") == 0) + if (name && strcmp(name, ".dynamic_type") == 0) m_ast.SetDynamicTypeId(compiler_type, member_location_expression); else {
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits