llvm-project/lldb/source
Lirong Yuan 1267506ea5 [lldb] fix memory leak in "GetGDBServerRegisterInfoXMLAndProcess"
While running heap checker on a test that uses LLDB API, the following memory leak is found:

RAW: HeapChecker started...
RAW: Leak check _main_ detected leaks of 34 bytes in 4 objects
RAW: The 2 largest leaks:
RAW: Leak of 17 bytes in 2 objects allocated from:
@ 0x7fb93bd20166 NewHook()
@ 0x7fb929372a73 absl::base_internal::MallocHook::InvokeNewHookSlow()
@ 0x5600d1046093 libc_malloc
@ 0x7fb974529c03 xmlStrdup
@ 0x7fb9744c2a0b xmlGetProp
@ 0x7fb9749d9ed6 lldb_private::XMLNode::GetAttributeValue()
@ 0x7fb979043001 std::u::function::policy_invoker<>::__call_impl<>()
@ 0x7fb9749da06d lldb_private::XMLNode::ForEachChildElement()
@ 0x7fb97903c54d lldb_private::process_gdb_remote::ProcessGDBRemote::GetGDBServerRegisterInfoXMLAndProcess()
@ 0x7fb97902cfe4 lldb_private::process_gdb_remote::ProcessGDBRemote::GetGDBServerRegisterInfo()
@ 0x7fb97902c1d0 lldb_private::process_gdb_remote::ProcessGDBRemote::BuildDynamicRegisterInfo()
@ 0x7fb97902e92a lldb_private::process_gdb_remote::ProcessGDBRemote::SetThreadStopInfo()
@ 0x7fb97902db18 lldb_private::process_gdb_remote::ProcessGDBRemote::DoConnectRemote()
@ 0x7fb97584965e lldb_private::Process::ConnectRemote()
@ 0x7fb975839fa6 lldb_private::Platform::DoConnectProcess()
@ 0x7fb97583a39e lldb_private::Platform::ConnectProcessSynchronous()
@ 0x7fb97545b28b CommandObjectProcessConnect::DoExecute()
@ 0x7fb9755a70c9 lldb_private::CommandObjectParsed::Execute()
@ 0x7fb97559c0e9 lldb_private::CommandInterpreter::HandleCommand()
@ 0x7fb975460145 lldb_private::CommandObjectRegexCommand::DoExecute()
@ 0x7fb9755a72d2 lldb_private::CommandObjectRaw::Execute()
@ 0x7fb97559c0e9 lldb_private::CommandInterpreter::HandleCommand()
@ 0x7fb997a5f22e lldb::SBCommandInterpreter::HandleCommand()
@ 0x7fb997a5ef9b lldb::SBCommandInterpreter::HandleCommand()

This change fixes the memory leaks by freeing memory after it is no
longer in use. Tested with "ninja check-lldb".

Differential revision: https://reviews.llvm.org/D116707
2022-01-10 14:33:09 -08:00
..
API [lldb] Remove LLDB_RECORD_DUMMY_* macros 2022-01-10 12:05:54 -08:00
Breakpoint Fix bugprone argument comments. 2022-01-09 12:21:02 -08:00
Commands Revert "[lldb] Set result error state in 'frame variable'" 2022-01-09 14:12:47 -08:00
Core [lldb] Create a property to store the REPL language 2022-01-05 15:03:46 -08:00
DataFormatters [lldb] Remove summary for signed char * 2022-01-06 19:52:24 +01:00
Expression Fix bugprone argument comments. 2022-01-09 12:21:02 -08:00
Host [lldb] fix memory leak in "GetGDBServerRegisterInfoXMLAndProcess" 2022-01-10 14:33:09 -08:00
Initialization [lldb] Make lldbVersion a full fledged library 2021-12-08 15:14:34 -08:00
Interpreter [lldb] Compute fully qualified command names in FindCommandsForApropos 2022-01-09 12:11:32 -08:00
Plugins [lldb] fix memory leak in "GetGDBServerRegisterInfoXMLAndProcess" 2022-01-10 14:33:09 -08:00
Symbol Use true/false instead of 1/0 (NFC) 2022-01-09 12:21:06 -08:00
Target Use true/false instead of 1/0 (NFC) 2022-01-09 12:21:06 -08:00
Utility [lldb] Remove reproducer instrumentation 2022-01-09 21:40:55 -08:00
Version [lldb] Use LLDB_VERSION_STRING instead of CLANG_VERSION_STRING 2021-12-13 16:58:39 -08:00
CMakeLists.txt [lldb] Make lldbVersion a full fledged library 2021-12-08 15:14:34 -08:00