Skip to content

Commit bfdb4dc

Browse files
authored
Merge pull request #959 from fredriss/platform-delete-dest-file
[lldb/PlatformDarwin] Always delete destination file first in PutFile
2 parents 3b80523 + 363723e commit bfdb4dc

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ PlatformDarwin::PlatformDarwin(bool is_host)
5858
/// inherited from by the plug-in instance.
5959
PlatformDarwin::~PlatformDarwin() {}
6060

61+
lldb_private::Status
62+
PlatformDarwin::PutFile(const lldb_private::FileSpec &source,
63+
const lldb_private::FileSpec &destination, uint32_t uid,
64+
uint32_t gid) {
65+
// Unconditionally unlink the destination. If it is an executable,
66+
// simply opening it and truncating its contents would invalidate
67+
// its cached code signature.
68+
Unlink(destination);
69+
return PlatformPOSIX::PutFile(source, destination, uid, gid);
70+
}
71+
6172
FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
6273
Target *target, Module &module, Stream *feedback_stream) {
6374
FileSpecList file_list;

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class PlatformDarwin : public PlatformPOSIX {
2626

2727
~PlatformDarwin() override;
2828

29+
lldb_private::Status PutFile(const lldb_private::FileSpec &source,
30+
const lldb_private::FileSpec &destination,
31+
uint32_t uid = UINT32_MAX,
32+
uint32_t gid = UINT32_MAX) override;
33+
2934
// lldb_private::Platform functions
3035
lldb_private::Status
3136
ResolveSymbolFile(lldb_private::Target &target,

0 commit comments

Comments
 (0)