aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
diff options
context:
space:
mode:
authorAlex Langford <alangford@apple.com>2024-01-22 10:46:20 -0800
committerGitHub <noreply@github.com>2024-01-22 10:46:20 -0800
commit0cea54a382f3187acbe3e81bd0fd7cf2cb1077b8 (patch)
treecb3e0712a25aa574f223099dd8b0a45dbd4795f9 /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
parent04952c5bec69c197ea6ffb718ae80fcf78c7828a (diff)
downloadllvm-0cea54a382f3187acbe3e81bd0fd7cf2cb1077b8.zip
llvm-0cea54a382f3187acbe3e81bd0fd7cf2cb1077b8.tar.gz
llvm-0cea54a382f3187acbe3e81bd0fd7cf2cb1077b8.tar.bz2
[lldb][NFCI] Remove EventData* param from BroadcastEvent (#78773)
BroadcastEvent currently takes its EventData* param and shoves it into an Event object, which takes ownership of the pointer and places it into a shared_ptr to manage the lifetime. Instead of relying on `new` and passing raw pointers around, I think it would make more sense to create the shared_ptr up front.
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 23834d4..eb42b9e 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1089,8 +1089,8 @@ Status ProcessGDBRemote::DoAttachToProcessWithID(
const int packet_len =
::snprintf(packet, sizeof(packet), "vAttach;%" PRIx64, attach_pid);
SetID(attach_pid);
- m_async_broadcaster.BroadcastEvent(
- eBroadcastBitAsyncContinue, new EventDataBytes(packet, packet_len));
+ auto data_sp = std::make_shared<EventDataBytes>(packet, packet_len);
+ m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue, data_sp);
} else
SetExitStatus(-1, error.AsCString());
}
@@ -1127,9 +1127,9 @@ Status ProcessGDBRemote::DoAttachToProcessWithName(
endian::InlHostByteOrder(),
endian::InlHostByteOrder());
- m_async_broadcaster.BroadcastEvent(
- eBroadcastBitAsyncContinue,
- new EventDataBytes(packet.GetString().data(), packet.GetSize()));
+ auto data_sp = std::make_shared<EventDataBytes>(packet.GetString().data(),
+ packet.GetSize());
+ m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue, data_sp);
} else
SetExitStatus(-1, error.AsCString());
@@ -1374,10 +1374,9 @@ Status ProcessGDBRemote::DoResume() {
return error;
}
- m_async_broadcaster.BroadcastEvent(
- eBroadcastBitAsyncContinue,
- new EventDataBytes(continue_packet.GetString().data(),
- continue_packet.GetSize()));
+ auto data_sp = std::make_shared<EventDataBytes>(
+ continue_packet.GetString().data(), continue_packet.GetSize());
+ m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue, data_sp);
if (!listener_sp->GetEvent(event_sp, std::chrono::seconds(5))) {
error.SetErrorString("Resume timed out.");