diff options
Diffstat (limited to 'lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp index 9ea1a16b8785..0420d00e39d6 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -136,7 +136,8 @@ NativeProcessNetBSD::Factory::Attach( NativeProcessNetBSD::Extension NativeProcessNetBSD::Factory::GetSupportedExtensions() const { return Extension::multiprocess | Extension::fork | Extension::vfork | - Extension::pass_signals | Extension::auxv | Extension::libraries_svr4; + Extension::pass_signals | Extension::auxv | Extension::libraries_svr4 | + Extension::savecore; } // Public Instance Methods @@ -1073,3 +1074,27 @@ void NativeProcessNetBSD::MonitorClone(::pid_t child_pid, bool is_vfork, } } } + +llvm::Expected<std::string> +NativeProcessNetBSD::SaveCore(llvm::StringRef path_hint) { + llvm::SmallString<128> path{path_hint}; + Status error; + + // Try with the suggested path first. + if (!path.empty()) { + error = PtraceWrapper(PT_DUMPCORE, GetID(), path.data(), path.size()); + if (!error.Fail()) + return path.str().str(); + + // If the request errored, fall back to a generic temporary file. + } + + if (std::error_code errc = + llvm::sys::fs::createTemporaryFile("lldb", "core", path)) + return llvm::createStringError(errc, "Unable to create a temporary file"); + + error = PtraceWrapper(PT_DUMPCORE, GetID(), path.data(), path.size()); + if (error.Fail()) + return error.ToError(); + return path.str().str(); +} |
