Commit 02e690ba authored by Michał Górny's avatar Michał Górny
Browse files

[lldb] [FreeBSD] Fix building on systems without PT_COREDUMP

PT_COREDUMP is a relatively recent addition.  Use an #ifdef to skip it
if the underlying system does not support it.

Differential Revision: https://reviews.llvm.org/D111214
parent 576ab15b
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -130,9 +130,12 @@ NativeProcessFreeBSD::Factory::Attach(

NativeProcessFreeBSD::Extension
NativeProcessFreeBSD::Factory::GetSupportedExtensions() const {
  return Extension::multiprocess | Extension::fork | Extension::vfork |
         Extension::pass_signals | Extension::auxv | Extension::libraries_svr4 |
         Extension::savecore;
  return
#if defined(PT_COREDUMP)
      Extension::savecore |
#endif
      Extension::multiprocess | Extension::fork | Extension::vfork |
      Extension::pass_signals | Extension::auxv | Extension::libraries_svr4;
}

// Public Instance Methods
@@ -1013,6 +1016,7 @@ void NativeProcessFreeBSD::MonitorClone(::pid_t child_pid, bool is_vfork,

llvm::Expected<std::string>
NativeProcessFreeBSD::SaveCore(llvm::StringRef path_hint) {
#if defined(PT_COREDUMP)
  using namespace llvm::sys::fs;

  llvm::SmallString<128> path{path_hint};
@@ -1036,4 +1040,9 @@ NativeProcessFreeBSD::SaveCore(llvm::StringRef path_hint) {
    return llvm::createStringError(
        close_err, "Unable to close the core dump after writing");
  return path.str().str();
#else // !defined(PT_COREDUMP)
  return llvm::createStringError(
      llvm::inconvertibleErrorCode(),
      "PT_COREDUMP not supported in the FreeBSD version used to build LLDB");
#endif
}
+2 −1
Original line number Diff line number Diff line
@@ -15,7 +15,8 @@ class TestGdbSaveCore(gdbremote_testcase.GdbRemoteTestCaseBase):
        procs = self.prep_debug_monitor_and_inferior()
        self.add_qSupported_packets()
        ret = self.expect_gdbremote_sequence()
        self.assertIn("qSaveCore+", ret["qSupported_response"])
        if "qSaveCore+" not in ret["qSupported_response"]:
            self.skipTest("qSaveCore not supported by lldb-server")
        self.reset_test_sequence()

        packet = "$qSaveCore"