Skip to content

[lldb] Additional pieces towards OpenBSD support #74198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lldb/source/Core/FormatEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1245,9 +1245,10 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
llvm::Triple::OSType ostype = arch.IsValid()
? arch.GetTriple().getOS()
: llvm::Triple::UnknownOS;
if ((ostype == llvm::Triple::FreeBSD) ||
(ostype == llvm::Triple::Linux) ||
(ostype == llvm::Triple::NetBSD)) {
if (ostype == llvm::Triple::FreeBSD ||
ostype == llvm::Triple::Linux ||
ostype == llvm::Triple::NetBSD ||
ostype == llvm::Triple::OpenBSD) {
format = "%" PRIu64;
}
} else {
Expand Down
6 changes: 4 additions & 2 deletions lldb/source/Host/common/SocketAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ static socklen_t GetFamilyLength(sa_family_t family) {
}

socklen_t SocketAddress::GetLength() const {
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__)
return m_socket_addr.sa.sa_len;
#else
return GetFamilyLength(GetFamily());
Expand All @@ -128,7 +129,8 @@ sa_family_t SocketAddress::GetFamily() const {

void SocketAddress::SetFamily(sa_family_t family) {
m_socket_addr.sa.sa_family = family;
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__)
m_socket_addr.sa.sa_len = GetFamilyLength(family);
#endif
}
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Host/posix/DomainSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ static bool SetSockAddr(llvm::StringRef name, const size_t name_offset,
saddr_un_len =
offsetof(struct sockaddr_un, sun_path) + name_offset + name.size();

#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__)
saddr_un->sun_len = saddr_un_len;
#endif

Expand Down
6 changes: 4 additions & 2 deletions lldb/source/Initialization/SystemInitializerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include "lldb/Utility/Timer.h"
#include "lldb/Version/Version.h"

#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__)
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#endif

Expand Down Expand Up @@ -77,7 +78,8 @@ llvm::Error SystemInitializerCommon::Initialize() {

process_gdb_remote::ProcessGDBRemoteLog::Initialize();

#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__)
ProcessPOSIXLog::Initialize();
#endif
#if defined(_WIN32)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ bool DYLDRendezvous::SOEntryIsMainExecutable(const SOEntry &entry) {
switch (triple.getOS()) {
case llvm::Triple::FreeBSD:
case llvm::Triple::NetBSD:
case llvm::Triple::OpenBSD:
return entry.file_spec == m_exe_file_spec;
case llvm::Triple::Linux:
if (triple.isAndroid())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ DynamicLoader *DynamicLoaderPOSIXDYLD::CreateInstance(Process *process,
process->GetTarget().GetArchitecture().GetTriple();
if (triple_ref.getOS() == llvm::Triple::FreeBSD ||
triple_ref.getOS() == llvm::Triple::Linux ||
triple_ref.getOS() == llvm::Triple::NetBSD)
triple_ref.getOS() == llvm::Triple::NetBSD ||
triple_ref.getOS() == llvm::Triple::OpenBSD)
create = true;
}

Expand Down
3 changes: 2 additions & 1 deletion lldb/test/API/api/multithreaded/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class multithreaded_queue {

/// Allocates a char buffer with the current working directory
inline char* get_working_dir() {
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__)
return getwd(0);
#else
return get_current_dir_name();
Expand Down
5 changes: 5 additions & 0 deletions lldb/test/API/tools/lldb-server/thread-name/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include <pthread.h>
#if defined(__OpenBSD__)
#include <pthread_np.h>
#endif
#include <signal.h>

void set_thread_name(const char *name) {
Expand All @@ -8,6 +11,8 @@ void set_thread_name(const char *name) {
::pthread_setname_np(::pthread_self(), name);
#elif defined(__NetBSD__)
::pthread_setname_np(::pthread_self(), "%s", const_cast<char *>(name));
#elif defined(__OpenBSD__)
::pthread_set_name_np(::pthread_self(), name);
#endif
}

Expand Down