aboutsummaryrefslogtreecommitdiff
path: root/lldb/include/lldb/Host
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/include/lldb/Host')
-rw-r--r--lldb/include/lldb/Host/Debug.h6
-rw-r--r--lldb/include/lldb/Host/Editline.h85
-rw-r--r--lldb/include/lldb/Host/File.h25
-rw-r--r--lldb/include/lldb/Host/FileAction.h6
-rw-r--r--lldb/include/lldb/Host/FileCache.h4
-rw-r--r--lldb/include/lldb/Host/FileSystem.h8
-rw-r--r--lldb/include/lldb/Host/Host.h2
-rw-r--r--lldb/include/lldb/Host/HostInfoBase.h14
-rw-r--r--lldb/include/lldb/Host/HostNativeProcessBase.h2
-rw-r--r--lldb/include/lldb/Host/HostNativeThreadBase.h8
-rw-r--r--lldb/include/lldb/Host/MainLoop.h13
-rw-r--r--lldb/include/lldb/Host/MainLoopBase.h4
-rw-r--r--lldb/include/lldb/Host/ProcessLaunchInfo.h34
-rw-r--r--lldb/include/lldb/Host/ProcessLauncher.h2
-rw-r--r--lldb/include/lldb/Host/ProcessRunLock.h10
-rw-r--r--lldb/include/lldb/Host/PseudoTerminal.h4
-rw-r--r--lldb/include/lldb/Host/SafeMachO.h50
-rw-r--r--lldb/include/lldb/Host/SocketAddress.h2
-rw-r--r--lldb/include/lldb/Host/StringConvert.h4
-rw-r--r--lldb/include/lldb/Host/Terminal.h9
-rw-r--r--lldb/include/lldb/Host/Time.h2
-rw-r--r--lldb/include/lldb/Host/XML.h4
-rw-r--r--lldb/include/lldb/Host/common/NativeProcessProtocol.h194
-rw-r--r--lldb/include/lldb/Host/common/NativeThreadProtocol.h2
-rw-r--r--lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h2
25 files changed, 285 insertions, 211 deletions
diff --git a/lldb/include/lldb/Host/Debug.h b/lldb/include/lldb/Host/Debug.h
index 402325c4c166..7da59dd04a66 100644
--- a/lldb/include/lldb/Host/Debug.h
+++ b/lldb/include/lldb/Host/Debug.h
@@ -144,6 +144,12 @@ struct ThreadStopInfo {
uint32_t data_count;
lldb::addr_t data[8];
} exception;
+
+ // eStopReasonFork / eStopReasonVFork
+ struct {
+ lldb::pid_t child_pid;
+ lldb::tid_t child_tid;
+ } fork;
} details;
};
}
diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h
index a37ad1b9d106..876f6052311e 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -38,12 +38,9 @@
#include <sstream>
#include <vector>
-#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/lldb-private.h"
-#if defined(_WIN32)
-#include "lldb/Host/windows/editlinewin.h"
-#elif !defined(__ANDROID__)
+#if !defined(_WIN32) && !defined(__ANDROID__)
#include <histedit.h>
#endif
@@ -56,6 +53,9 @@
#include "lldb/Utility/CompletionRequest.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Predicate.h"
+#include "lldb/Utility/StringList.h"
+
+#include "llvm/ADT/FunctionExtras.h"
namespace lldb_private {
namespace line_editor {
@@ -81,27 +81,26 @@ using EditLineGetCharType = wchar_t;
using EditLineGetCharType = char;
#endif
-typedef int (*EditlineGetCharCallbackType)(::EditLine *editline,
- EditLineGetCharType *c);
-typedef unsigned char (*EditlineCommandCallbackType)(::EditLine *editline,
- int ch);
-typedef const char *(*EditlinePromptCallbackType)(::EditLine *editline);
+using EditlineGetCharCallbackType = int (*)(::EditLine *editline,
+ EditLineGetCharType *c);
+using EditlineCommandCallbackType = unsigned char (*)(::EditLine *editline,
+ int ch);
+using EditlinePromptCallbackType = const char *(*)(::EditLine *editline);
class EditlineHistory;
-typedef std::shared_ptr<EditlineHistory> EditlineHistorySP;
+using EditlineHistorySP = std::shared_ptr<EditlineHistory>;
-typedef bool (*IsInputCompleteCallbackType)(Editline *editline,
- StringList &lines, void *baton);
+using IsInputCompleteCallbackType =
+ llvm::unique_function<bool(Editline *, StringList &)>;
-typedef int (*FixIndentationCallbackType)(Editline *editline,
- const StringList &lines,
- int cursor_position, void *baton);
+using FixIndentationCallbackType =
+ llvm::unique_function<int(Editline *, StringList &, int)>;
-typedef llvm::Optional<std::string> (*SuggestionCallbackType)(
- llvm::StringRef line, void *baton);
+using SuggestionCallbackType =
+ llvm::unique_function<llvm::Optional<std::string>(llvm::StringRef)>;
-typedef void (*CompleteCallbackType)(CompletionRequest &request, void *baton);
+using CompleteCallbackType = llvm::unique_function<void(CompletionRequest &)>;
/// Status used to decide when and how to start editing another line in
/// multi-line sessions
@@ -188,21 +187,28 @@ public:
bool Cancel();
/// Register a callback for autosuggestion.
- void SetSuggestionCallback(SuggestionCallbackType callback, void *baton);
+ void SetSuggestionCallback(SuggestionCallbackType callback) {
+ m_suggestion_callback = std::move(callback);
+ }
/// Register a callback for the tab key
- void SetAutoCompleteCallback(CompleteCallbackType callback, void *baton);
+ void SetAutoCompleteCallback(CompleteCallbackType callback) {
+ m_completion_callback = std::move(callback);
+ }
/// Register a callback for testing whether multi-line input is complete
- void SetIsInputCompleteCallback(IsInputCompleteCallbackType callback,
- void *baton);
+ void SetIsInputCompleteCallback(IsInputCompleteCallbackType callback) {
+ m_is_input_complete_callback = std::move(callback);
+ }
/// Register a callback for determining the appropriate indentation for a line
/// when creating a newline. An optional set of insertable characters can
- /// also
- /// trigger the callback.
- bool SetFixIndentationCallback(FixIndentationCallbackType callback,
- void *baton, const char *indent_chars);
+ /// also trigger the callback.
+ void SetFixIndentationCallback(FixIndentationCallbackType callback,
+ const char *indent_chars) {
+ m_fix_indentation_callback = std::move(callback);
+ m_fix_indentation_callback_chars = indent_chars;
+ }
/// Prompts for and reads a single line of user input.
bool GetLine(std::string &line, bool &interrupted);
@@ -338,6 +344,16 @@ private:
void ApplyTerminalSizeChange();
+ // The following set various editline parameters. It's not any less
+ // verbose to put the editline calls into a function, but it
+ // provides type safety, since the editline functions take varargs
+ // parameters.
+ void AddFunctionToEditLine(const EditLineCharType *command,
+ const EditLineCharType *helptext,
+ EditlineCommandCallbackType callbackFn);
+ void SetEditLinePromptCallback(EditlinePromptCallbackType callbackFn);
+ void SetGetCharacterFunction(EditlineGetCharCallbackType callbackFn);
+
#if LLDB_EDITLINE_USE_WCHAR
std::wstring_convert<std::codecvt_utf8<wchar_t>> m_utf8conv;
#endif
@@ -365,15 +381,16 @@ private:
FILE *m_output_file;
FILE *m_error_file;
ConnectionFileDescriptor m_input_connection;
- IsInputCompleteCallbackType m_is_input_complete_callback = nullptr;
- void *m_is_input_complete_callback_baton = nullptr;
- FixIndentationCallbackType m_fix_indentation_callback = nullptr;
- void *m_fix_indentation_callback_baton = nullptr;
+
+ IsInputCompleteCallbackType m_is_input_complete_callback;
+
+ FixIndentationCallbackType m_fix_indentation_callback;
const char *m_fix_indentation_callback_chars = nullptr;
- CompleteCallbackType m_completion_callback = nullptr;
- void *m_completion_callback_baton = nullptr;
- SuggestionCallbackType m_suggestion_callback = nullptr;
- void *m_suggestion_callback_baton = nullptr;
+
+ CompleteCallbackType m_completion_callback;
+
+ SuggestionCallbackType m_suggestion_callback;
+
std::size_t m_previous_autosuggestion_size = 0;
std::mutex m_output_mutex;
};
diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h
index d205a3fe6911..d364d954a1c1 100644
--- a/lldb/include/lldb/Host/File.h
+++ b/lldb/include/lldb/Host/File.h
@@ -15,9 +15,9 @@
#include "lldb/lldb-private.h"
#include "llvm/ADT/BitmaskEnum.h"
+#include <cstdarg>
+#include <cstdio>
#include <mutex>
-#include <stdarg.h>
-#include <stdio.h>
#include <sys/types.h>
namespace lldb_private {
@@ -65,10 +65,7 @@ public:
static llvm::Expected<const char *>
GetStreamOpenModeFromOptions(OpenOptions options);
- File()
- : IOObject(eFDTypeFile), m_is_interactive(eLazyBoolCalculate),
- m_is_real_terminal(eLazyBoolCalculate),
- m_supports_colors(eLazyBoolCalculate){};
+ File() : IOObject(eFDTypeFile){};
/// Read bytes from a file from the current file position into buf.
///
@@ -360,9 +357,9 @@ public:
static bool classof(const File *file) { return file->isA(&ID); }
protected:
- LazyBool m_is_interactive;
- LazyBool m_is_real_terminal;
- LazyBool m_supports_colors;
+ LazyBool m_is_interactive = eLazyBoolCalculate;
+ LazyBool m_is_real_terminal = eLazyBoolCalculate;
+ LazyBool m_supports_colors = eLazyBoolCalculate;
void CalculateInteractiveAndTerminal();
@@ -373,9 +370,7 @@ private:
class NativeFile : public File {
public:
- NativeFile()
- : m_descriptor(kInvalidDescriptor), m_own_descriptor(false),
- m_stream(kInvalidStream), m_options(), m_own_stream(false) {}
+ NativeFile() : m_descriptor(kInvalidDescriptor), m_stream(kInvalidStream) {}
NativeFile(FILE *fh, bool transfer_ownership)
: m_descriptor(kInvalidDescriptor), m_own_descriptor(false), m_stream(fh),
@@ -422,10 +417,10 @@ protected:
// Member variables
int m_descriptor;
- bool m_own_descriptor;
+ bool m_own_descriptor = false;
FILE *m_stream;
- OpenOptions m_options;
- bool m_own_stream;
+ OpenOptions m_options{};
+ bool m_own_stream = false;
std::mutex offset_access_mutex;
private:
diff --git a/lldb/include/lldb/Host/FileAction.h b/lldb/include/lldb/Host/FileAction.h
index 4d333bb327a5..d3166c16a585 100644
--- a/lldb/include/lldb/Host/FileAction.h
+++ b/lldb/include/lldb/Host/FileAction.h
@@ -46,9 +46,9 @@ public:
void Dump(Stream &stream) const;
protected:
- Action m_action; // The action for this file
- int m_fd; // An existing file descriptor
- int m_arg; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate
+ Action m_action = eFileActionNone; // The action for this file
+ int m_fd = -1; // An existing file descriptor
+ int m_arg = -1; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate
FileSpec
m_file_spec; // A file spec to use for opening after fork or posix_spawn
};
diff --git a/lldb/include/lldb/Host/FileCache.h b/lldb/include/lldb/Host/FileCache.h
index df0d9a88c6df..1bf5f0ca80e2 100644
--- a/lldb/include/lldb/Host/FileCache.h
+++ b/lldb/include/lldb/Host/FileCache.h
@@ -8,8 +8,8 @@
#ifndef LLDB_HOST_FILECACHE_H
#define LLDB_HOST_FILECACHE_H
+#include <cstdint>
#include <map>
-#include <stdint.h>
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
@@ -21,7 +21,7 @@
namespace lldb_private {
class FileCache {
private:
- FileCache() {}
+ FileCache() = default;
typedef std::map<lldb::user_id_t, lldb::FileUP> FDToFileMap;
diff --git a/lldb/include/lldb/Host/FileSystem.h b/lldb/include/lldb/Host/FileSystem.h
index 02ff5f301336..93563d4d26e3 100644
--- a/lldb/include/lldb/Host/FileSystem.h
+++ b/lldb/include/lldb/Host/FileSystem.h
@@ -21,8 +21,8 @@
#include "lldb/lldb-types.h"
-#include <stdint.h>
-#include <stdio.h>
+#include <cstdint>
+#include <cstdio>
#include <sys/stat.h>
namespace lldb_private {
@@ -33,7 +33,7 @@ public:
FileSystem()
: m_fs(llvm::vfs::getRealFileSystem()), m_collector(nullptr),
- m_home_directory(), m_mapped(false) {}
+ m_home_directory() {}
FileSystem(std::shared_ptr<llvm::FileCollectorBase> collector)
: m_fs(llvm::vfs::getRealFileSystem()), m_collector(std::move(collector)),
m_home_directory(), m_mapped(false) {}
@@ -201,7 +201,7 @@ private:
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs;
std::shared_ptr<llvm::FileCollectorBase> m_collector;
std::string m_home_directory;
- bool m_mapped;
+ bool m_mapped = false;
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h
index 76792cc6eab5..1fdf7eab7eb8 100644
--- a/lldb/include/lldb/Host/Host.h
+++ b/lldb/include/lldb/Host/Host.h
@@ -17,8 +17,8 @@
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-private.h"
#include <cerrno>
+#include <cstdarg>
#include <map>
-#include <stdarg.h>
#include <string>
#include <type_traits>
diff --git a/lldb/include/lldb/Host/HostInfoBase.h b/lldb/include/lldb/Host/HostInfoBase.h
index 15bb168aad97..eeed881101d0 100644
--- a/lldb/include/lldb/Host/HostInfoBase.h
+++ b/lldb/include/lldb/Host/HostInfoBase.h
@@ -17,7 +17,7 @@
#include "lldb/lldb-enumerations.h"
#include "llvm/ADT/StringRef.h"
-#include <stdint.h>
+#include <cstdint>
#include <string>
@@ -33,11 +33,17 @@ struct SharedCacheImageInfo {
class HostInfoBase {
private:
// Static class, unconstructable.
- HostInfoBase() {}
- ~HostInfoBase() {}
+ HostInfoBase() = default;
+ ~HostInfoBase() = default;
public:
- static void Initialize();
+ /// A helper function for determining the liblldb location. It receives a
+ /// FileSpec with the location of file containing _this_ code. It can
+ /// (optionally) replace it with a file spec pointing to a more canonical
+ /// copy.
+ using SharedLibraryDirectoryHelper = void(FileSpec &this_file);
+
+ static void Initialize(SharedLibraryDirectoryHelper *helper = nullptr);
static void Terminate();
/// Gets the host target triple.
diff --git a/lldb/include/lldb/Host/HostNativeProcessBase.h b/lldb/include/lldb/Host/HostNativeProcessBase.h
index 642c63443c20..5469f8a50e26 100644
--- a/lldb/include/lldb/Host/HostNativeProcessBase.h
+++ b/lldb/include/lldb/Host/HostNativeProcessBase.h
@@ -27,7 +27,7 @@ public:
HostNativeProcessBase() : m_process(LLDB_INVALID_PROCESS) {}
explicit HostNativeProcessBase(lldb::process_t process)
: m_process(process) {}
- virtual ~HostNativeProcessBase() {}
+ virtual ~HostNativeProcessBase() = default;
virtual Status Terminate() = 0;
virtual Status GetMainModule(FileSpec &file_spec) const = 0;
diff --git a/lldb/include/lldb/Host/HostNativeThreadBase.h b/lldb/include/lldb/Host/HostNativeThreadBase.h
index 0dfd363cc8fb..bfd70d745593 100644
--- a/lldb/include/lldb/Host/HostNativeThreadBase.h
+++ b/lldb/include/lldb/Host/HostNativeThreadBase.h
@@ -27,9 +27,9 @@ class HostNativeThreadBase {
const HostNativeThreadBase &operator=(const HostNativeThreadBase &) = delete;
public:
- HostNativeThreadBase();
+ HostNativeThreadBase() = default;
explicit HostNativeThreadBase(lldb::thread_t thread);
- virtual ~HostNativeThreadBase() {}
+ virtual ~HostNativeThreadBase() = default;
virtual Status Join(lldb::thread_result_t *result) = 0;
virtual Status Cancel() = 0;
@@ -45,8 +45,8 @@ protected:
static lldb::thread_result_t THREAD_ROUTINE
ThreadCreateTrampoline(lldb::thread_arg_t arg);
- lldb::thread_t m_thread;
- lldb::thread_result_t m_result;
+ lldb::thread_t m_thread = LLDB_INVALID_HOST_THREAD;
+ lldb::thread_result_t m_result = 0;
};
}
diff --git a/lldb/include/lldb/Host/MainLoop.h b/lldb/include/lldb/Host/MainLoop.h
index 9ca5040b60a8..06785bbdbe24 100644
--- a/lldb/include/lldb/Host/MainLoop.h
+++ b/lldb/include/lldb/Host/MainLoop.h
@@ -13,6 +13,7 @@
#include "lldb/Host/MainLoopBase.h"
#include "llvm/ADT/DenseMap.h"
#include <csignal>
+#include <list>
#if !HAVE_PPOLL && !HAVE_SYS_EVENT_H && !defined(__ANDROID__)
#define SIGNAL_POLLING_UNSUPPORTED 1
@@ -68,7 +69,7 @@ public:
protected:
void UnregisterReadObject(IOObject::WaitableHandle handle) override;
- void UnregisterSignal(int signo);
+ void UnregisterSignal(int signo, std::list<Callback>::iterator callback_it);
private:
void ProcessReadObject(IOObject::WaitableHandle handle);
@@ -76,14 +77,16 @@ private:
class SignalHandle {
public:
- ~SignalHandle() { m_mainloop.UnregisterSignal(m_signo); }
+ ~SignalHandle() { m_mainloop.UnregisterSignal(m_signo, m_callback_it); }
private:
- SignalHandle(MainLoop &mainloop, int signo)
- : m_mainloop(mainloop), m_signo(signo) {}
+ SignalHandle(MainLoop &mainloop, int signo,
+ std::list<Callback>::iterator callback_it)
+ : m_mainloop(mainloop), m_signo(signo), m_callback_it(callback_it) {}
MainLoop &m_mainloop;
int m_signo;
+ std::list<Callback>::iterator m_callback_it;
friend class MainLoop;
SignalHandle(const SignalHandle &) = delete;
@@ -91,7 +94,7 @@ private:
};
struct SignalInfo {
- Callback callback;
+ std::list<Callback> callbacks;
#if HAVE_SIGACTION
struct sigaction old_action;
#endif
diff --git a/lldb/include/lldb/Host/MainLoopBase.h b/lldb/include/lldb/Host/MainLoopBase.h
index fa8cc77a94ba..67857b26ac70 100644
--- a/lldb/include/lldb/Host/MainLoopBase.h
+++ b/lldb/include/lldb/Host/MainLoopBase.h
@@ -33,8 +33,8 @@ private:
class ReadHandle;
public:
- MainLoopBase() {}
- virtual ~MainLoopBase() {}
+ MainLoopBase() = default;
+ virtual ~MainLoopBase() = default;
typedef std::unique_ptr<ReadHandle> ReadHandleUP;
diff --git a/lldb/include/lldb/Host/ProcessLaunchInfo.h b/lldb/include/lldb/Host/ProcessLaunchInfo.h
index ee9755580825..3ed21637de7f 100644
--- a/lldb/include/lldb/Host/ProcessLaunchInfo.h
+++ b/lldb/include/lldb/Host/ProcessLaunchInfo.h
@@ -20,6 +20,7 @@
#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/ProcessInfo.h"
+#include "lldb/Utility/StructuredData.h"
namespace lldb_private {
@@ -146,6 +147,28 @@ public:
return m_flags.Test(lldb::eLaunchFlagDetachOnError);
}
+ bool IsScriptedProcess() const {
+ return !m_scripted_process_class_name.empty();
+ }
+
+ std::string GetScriptedProcessClassName() const {
+ return m_scripted_process_class_name;
+ }
+
+ void SetScriptedProcessClassName(std::string name) {
+ m_scripted_process_class_name = name;
+ }
+
+ lldb_private::StructuredData::DictionarySP
+ GetScriptedProcessDictionarySP() const {
+ return m_scripted_process_dictionary_sp;
+ }
+
+ void SetScriptedProcessDictionarySP(
+ lldb_private::StructuredData::DictionarySP dictionary_sp) {
+ m_scripted_process_dictionary_sp = dictionary_sp;
+ }
+
protected:
FileSpec m_working_dir;
std::string m_plugin_name;
@@ -153,14 +176,19 @@ protected:
Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags
std::vector<FileAction> m_file_actions; // File actions for any other files
std::shared_ptr<PseudoTerminal> m_pty;
- uint32_t m_resume_count; // How many times do we resume after launching
+ uint32_t m_resume_count = 0; // How many times do we resume after launching
Host::MonitorChildProcessCallback m_monitor_callback;
- void *m_monitor_callback_baton;
- bool m_monitor_signals;
+ void *m_monitor_callback_baton = nullptr;
+ bool m_monitor_signals = false;
std::string m_event_data; // A string passed to the plugin launch, having no
// meaning to the upper levels of lldb.
lldb::ListenerSP m_listener_sp;
lldb::ListenerSP m_hijack_listener_sp;
+ std::string m_scripted_process_class_name; // The name of the class that will
+ // manage a scripted process.
+ StructuredData::DictionarySP
+ m_scripted_process_dictionary_sp; // A dictionary that holds key/value
+ // pairs passed to the scripted process.
};
}
diff --git a/lldb/include/lldb/Host/ProcessLauncher.h b/lldb/include/lldb/Host/ProcessLauncher.h
index 9467b2c009b7..33dbfd72d1e5 100644
--- a/lldb/include/lldb/Host/ProcessLauncher.h
+++ b/lldb/include/lldb/Host/ProcessLauncher.h
@@ -17,7 +17,7 @@ class HostProcess;
class ProcessLauncher {
public:
- virtual ~ProcessLauncher() {}
+ virtual ~ProcessLauncher() = default;
virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info,
Status &error) = 0;
};
diff --git a/lldb/include/lldb/Host/ProcessRunLock.h b/lldb/include/lldb/Host/ProcessRunLock.h
index 43463d144de3..b5b5328b4a33 100644
--- a/lldb/include/lldb/Host/ProcessRunLock.h
+++ b/lldb/include/lldb/Host/ProcessRunLock.h
@@ -9,8 +9,8 @@
#ifndef LLDB_HOST_PROCESSRUNLOCK_H
#define LLDB_HOST_PROCESSRUNLOCK_H
-#include <stdint.h>
-#include <time.h>
+#include <cstdint>
+#include <ctime>
#include "lldb/lldb-defines.h"
@@ -35,7 +35,7 @@ public:
class ProcessRunLocker {
public:
- ProcessRunLocker() : m_lock(nullptr) {}
+ ProcessRunLocker() = default;
~ProcessRunLocker() { Unlock(); }
@@ -64,7 +64,7 @@ public:
}
}
- ProcessRunLock *m_lock;
+ ProcessRunLock *m_lock = nullptr;
private:
ProcessRunLocker(const ProcessRunLocker &) = delete;
@@ -73,7 +73,7 @@ public:
protected:
lldb::rwlock_t m_rwlock;
- bool m_running;
+ bool m_running = false;
private:
ProcessRunLock(const ProcessRunLock &) = delete;
diff --git a/lldb/include/lldb/Host/PseudoTerminal.h b/lldb/include/lldb/Host/PseudoTerminal.h
index 350f926dcac1..bd1e2f56241b 100644
--- a/lldb/include/lldb/Host/PseudoTerminal.h
+++ b/lldb/include/lldb/Host/PseudoTerminal.h
@@ -175,8 +175,8 @@ public:
protected:
// Member variables
- int m_primary_fd; ///< The file descriptor for the primary.
- int m_secondary_fd; ///< The file descriptor for the secondary.
+ int m_primary_fd = invalid_fd; ///< The file descriptor for the primary.
+ int m_secondary_fd = invalid_fd; ///< The file descriptor for the secondary.
private:
PseudoTerminal(const PseudoTerminal &) = delete;
diff --git a/lldb/include/lldb/Host/SafeMachO.h b/lldb/include/lldb/Host/SafeMachO.h
index d7c376d23a4a..0540383b8c52 100644
--- a/lldb/include/lldb/Host/SafeMachO.h
+++ b/lldb/include/lldb/Host/SafeMachO.h
@@ -23,6 +23,7 @@
#undef CPU_ARCH_MASK
#undef CPU_ARCH_ABI64
+#undef CPU_ARCH_ABI64_32
#undef CPU_TYPE_ANY
#undef CPU_TYPE_X86
@@ -31,12 +32,13 @@
#undef CPU_TYPE_MC98000
#undef CPU_TYPE_ARM
#undef CPU_TYPE_ARM64
+#undef CPU_TYPE_ARM64_32
#undef CPU_TYPE_SPARC
#undef CPU_TYPE_POWERPC
#undef CPU_TYPE_POWERPC64
-#undef CPU_SUB_TYPE_MASK
-#undef CPU_SUB_TYPE_LIB64
+#undef CPU_SUBTYPE_MASK
+#undef CPU_SUBTYPE_LIB64
#undef CPU_SUBTYPE_MULTIPLE
@@ -88,6 +90,9 @@
#undef CPU_SUBTYPE_ARM_V7M
#undef CPU_SUBTYPE_ARM_V7EM
+#undef CPU_SUBTYPE_ARM64E
+#undef CPU_SUBTYPE_ARM64_32_V8
+#undef CPU_SUBTYPE_ARM64_V8
#undef CPU_SUBTYPE_ARM64_ALL
#undef CPU_SUBTYPE_SPARC_ALL
@@ -110,6 +115,47 @@
#undef CPU_SUBTYPE_MC980000_ALL
#undef CPU_SUBTYPE_MC98601
+#undef VM_PROT_READ
+#undef VM_PROT_WRITE
+#undef VM_PROT_EXECUTE
+
+#undef ARM_DEBUG_STATE
+#undef ARM_EXCEPTION_STATE
+#undef ARM_EXCEPTION_STATE64
+#undef ARM_EXCEPTION_STATE64_COUNT
+#undef ARM_THREAD_STATE
+#undef ARM_THREAD_STATE64
+#undef ARM_THREAD_STATE64_COUNT
+#undef ARM_THREAD_STATE_COUNT
+#undef ARM_VFP_STATE
+#undef ARN_THREAD_STATE_NONE
+#undef PPC_EXCEPTION_STATE
+#undef PPC_EXCEPTION_STATE64
+#undef PPC_FLOAT_STATE
+#undef PPC_THREAD_STATE
+#undef PPC_THREAD_STATE64
+#undef PPC_THREAD_STATE_NONE
+#undef PPC_VECTOR_STATE
+#undef x86_DEBUG_STATE
+#undef x86_DEBUG_STATE32
+#undef x86_DEBUG_STATE64
+#undef x86_EXCEPTION_STATE
+#undef x86_EXCEPTION_STATE32
+#undef x86_EXCEPTION_STATE64
+#undef x86_EXCEPTION_STATE64_COUNT
+#undef x86_EXCEPTION_STATE_COUNT
+#undef x86_FLOAT_STATE
+#undef x86_FLOAT_STATE32
+#undef x86_FLOAT_STATE64
+#undef x86_FLOAT_STATE64_COUNT
+#undef x86_FLOAT_STATE_COUNT
+#undef x86_THREAD_STATE
+#undef x86_THREAD_STATE32
+#undef x86_THREAD_STATE32_COUNT
+#undef x86_THREAD_STATE64
+#undef x86_THREAD_STATE64_COUNT
+#undef x86_THREAD_STATE_COUNT
+
#include "llvm/BinaryFormat/MachO.h"
#endif // LLDB_HOST_SAFEMACHO_H
diff --git a/lldb/include/lldb/Host/SocketAddress.h b/lldb/include/lldb/Host/SocketAddress.h
index 862e1104a084..c88cc1260654 100644
--- a/lldb/include/lldb/Host/SocketAddress.h
+++ b/lldb/include/lldb/Host/SocketAddress.h
@@ -9,7 +9,7 @@
#ifndef LLDB_HOST_SOCKETADDRESS_H
#define LLDB_HOST_SOCKETADDRESS_H
-#include <stdint.h>
+#include <cstdint>
#ifdef _WIN32
#include "lldb/Host/windows/windows.h"
diff --git a/lldb/include/lldb/Host/StringConvert.h b/lldb/include/lldb/Host/StringConvert.h
index ad629ff30429..33608a85ff42 100644
--- a/lldb/include/lldb/Host/StringConvert.h
+++ b/lldb/include/lldb/Host/StringConvert.h
@@ -9,9 +9,7 @@
#ifndef LLDB_HOST_STRINGCONVERT_H
#define LLDB_HOST_STRINGCONVERT_H
-#include <stdint.h>
-
-
+#include <cstdint>
namespace lldb_private {
diff --git a/lldb/include/lldb/Host/Terminal.h b/lldb/include/lldb/Host/Terminal.h
index 61993223ea06..ca91d6b59720 100644
--- a/lldb/include/lldb/Host/Terminal.h
+++ b/lldb/include/lldb/Host/Terminal.h
@@ -21,7 +21,7 @@ class Terminal {
public:
Terminal(int fd = -1) : m_fd(fd) {}
- ~Terminal() {}
+ ~Terminal() = default;
bool IsATerminal() const;
@@ -116,12 +116,12 @@ protected:
// Member variables
Terminal m_tty; ///< A terminal
- int m_tflags; ///< Cached tflags information.
+ int m_tflags = -1; ///< Cached tflags information.
#if LLDB_ENABLE_TERMIOS
std::unique_ptr<struct termios>
m_termios_up; ///< Cached terminal state information.
#endif
- lldb::pid_t m_process_group; ///< Cached process group information.
+ lldb::pid_t m_process_group = -1; ///< Cached process group information.
};
/// \class TerminalStateSwitcher Terminal.h "lldb/Host/Terminal.h"
@@ -171,7 +171,8 @@ public:
protected:
// Member variables
- mutable uint32_t m_currentState; ///< The currently active TTY state index.
+ mutable uint32_t m_currentState =
+ UINT32_MAX; ///< The currently active TTY state index.
TerminalState
m_ttystates[2]; ///< The array of TTY states that holds saved TTY info.
};
diff --git a/lldb/include/lldb/Host/Time.h b/lldb/include/lldb/Host/Time.h
index 83b76ec0f9d1..aee4c43247c5 100644
--- a/lldb/include/lldb/Host/Time.h
+++ b/lldb/include/lldb/Host/Time.h
@@ -19,7 +19,7 @@
#include <time64.h>
extern time_t timegm(struct tm *t);
#else
-#include <time.h>
+#include <ctime>
#endif
#endif // LLDB_HOST_TIME_H
diff --git a/lldb/include/lldb/Host/XML.h b/lldb/include/lldb/Host/XML.h
index a80f1e9e4d26..9edf46bf09df 100644
--- a/lldb/include/lldb/Host/XML.h
+++ b/lldb/include/lldb/Host/XML.h
@@ -107,7 +107,7 @@ public:
void ForEachAttribute(AttributeCallback const &callback) const;
protected:
- XMLNodeImpl m_node;
+ XMLNodeImpl m_node = nullptr;
};
class XMLDocument {
@@ -138,7 +138,7 @@ public:
static bool XMLEnabled();
protected:
- XMLDocumentImpl m_document;
+ XMLDocumentImpl m_document = nullptr;
StreamString m_errors;
};
diff --git a/lldb/include/lldb/Host/common/NativeProcessProtocol.h b/lldb/include/lldb/Host/common/NativeProcessProtocol.h
index 5be9cb657382..770149e3fb28 100644
--- a/lldb/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/lldb/include/lldb/Host/common/NativeProcessProtocol.h
@@ -16,7 +16,7 @@
#include "lldb/Host/MainLoop.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/Status.h"
-#include "lldb/Utility/TraceOptions.h"
+#include "lldb/Utility/TraceGDBRemotePackets.h"
#include "lldb/Utility/UnimplementedError.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-types.h"
@@ -30,6 +30,8 @@
#include <vector>
namespace lldb_private {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+
class MemoryRegionInfo;
class ResumeActionList;
@@ -44,7 +46,7 @@ struct SVR4LibraryInfo {
// NativeProcessProtocol
class NativeProcessProtocol {
public:
- virtual ~NativeProcessProtocol() {}
+ virtual ~NativeProcessProtocol() = default;
virtual Status Resume(const ResumeActionList &resume_actions) = 0;
@@ -85,6 +87,12 @@ public:
Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size,
size_t &bytes_read);
+ virtual Status ReadMemoryTags(int32_t type, lldb::addr_t addr, size_t len,
+ std::vector<uint8_t> &tags);
+
+ virtual Status WriteMemoryTags(int32_t type, lldb::addr_t addr, size_t len,
+ const std::vector<uint8_t> &tags);
+
/// Reads a null terminated string from memory.
///
/// Reads up to \p max_size bytes of memory until it finds a '\0'.
@@ -212,7 +220,7 @@ public:
// Callbacks for low-level process state changes
class NativeDelegate {
public:
- virtual ~NativeDelegate() {}
+ virtual ~NativeDelegate() = default;
virtual void InitializeDelegate(NativeProcessProtocol *process) = 0;
@@ -220,37 +228,11 @@ public:
lldb::StateType state) = 0;
virtual void DidExec(NativeProcessProtocol *process) = 0;
- };
-
- /// Register a native delegate.
- ///
- /// Clients can register nofication callbacks by passing in a
- /// NativeDelegate impl and passing it into this function.
- ///
- /// Note: it is required that the lifetime of the
- /// native_delegate outlive the NativeProcessProtocol.
- ///
- /// \param[in] native_delegate
- /// A NativeDelegate impl to be called when certain events
- /// happen within the NativeProcessProtocol or related threads.
- ///
- /// \return
- /// true if the delegate was registered successfully;
- /// false if the delegate was already registered.
- ///
- /// \see NativeProcessProtocol::NativeDelegate.
- bool RegisterNativeDelegate(NativeDelegate &native_delegate);
- /// Unregister a native delegate previously registered.
- ///
- /// \param[in] native_delegate
- /// A NativeDelegate impl previously registered with this process.
- ///
- /// \return Returns \b true if the NativeDelegate was
- /// successfully removed from the process, \b false otherwise.
- ///
- /// \see NativeProcessProtocol::NativeDelegate
- bool UnregisterNativeDelegate(NativeDelegate &native_delegate);
+ virtual void
+ NewSubprocess(NativeProcessProtocol *parent_process,
+ std::unique_ptr<NativeProcessProtocol> child_process) = 0;
+ };
virtual Status GetLoadedModuleFileSpec(const char *module_path,
FileSpec &file_spec) = 0;
@@ -258,6 +240,20 @@ public:
virtual Status GetFileLoadAddress(const llvm::StringRef &file_name,
lldb::addr_t &load_addr) = 0;
+ /// Extension flag constants, returned by Factory::GetSupportedExtensions()
+ /// and passed to SetEnabledExtension()
+ enum class Extension {
+ multiprocess = (1u << 0),
+ fork = (1u << 1),
+ vfork = (1u << 2),
+ pass_signals = (1u << 3),
+ auxv = (1u << 4),
+ libraries_svr4 = (1u << 5),
+ memory_tagging = (1u << 6),
+
+ LLVM_MARK_AS_BITMASK_ENUM(memory_tagging)
+ };
+
class Factory {
public:
virtual ~Factory();
@@ -304,99 +300,75 @@ public:
virtual llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Attach(lldb::pid_t pid, NativeDelegate &native_delegate,
MainLoop &mainloop) const = 0;
+
+ /// Get the bitmask of extensions supported by this process plugin.
+ ///
+ /// \return
+ /// A NativeProcessProtocol::Extension bitmask.
+ virtual Extension GetSupportedExtensions() const { return {}; }
};
- /// StartTracing API for starting a tracing instance with the
- /// TraceOptions on a specific thread or process.
+ /// Start tracing a process or its threads.
///
- /// \param[in] config
- /// The configuration to use when starting tracing.
+ /// \param[in] json_params
+ /// JSON object with the information of what and how to trace.
+ /// In the case of gdb-remote, this object should conform to the
+ /// jLLDBTraceStart packet.
///
- /// \param[out] error
- /// Status indicates what went wrong.
+ /// This object should have a string entry called "type", which is the
+ /// tracing technology name.
///
- /// \return
- /// The API returns a user_id which can be used to get trace
- /// data, trace configuration or stopping the trace instance.
- /// The user_id is a key to identify and operate with a tracing
- /// instance. It may refer to the complete process or a single
- /// thread.
- virtual lldb::user_id_t StartTrace(const TraceOptions &config,
- Status &error) {
- error.SetErrorString("Not implemented");
- return LLDB_INVALID_UID;
- }
-
- /// StopTracing API as the name suggests stops a tracing instance.
- ///
- /// \param[in] traceid
- /// The user id of the trace intended to be stopped. Now a
- /// user_id may map to multiple threads in which case this API
- /// could be used to stop the tracing for a specific thread by
- /// supplying its thread id.
- ///
- /// \param[in] thread
- /// Thread is needed when the complete process is being traced
- /// and the user wishes to stop tracing on a particular thread.
+ /// \param[in] type
+ /// Tracing technology type, as described in the \a json_params.
///
/// \return
- /// Status indicating what went wrong.
- virtual Status StopTrace(lldb::user_id_t traceid,
- lldb::tid_t thread = LLDB_INVALID_THREAD_ID) {
- return Status("Not implemented");
+ /// \a llvm::Error::success if the operation was successful, or an
+ /// \a llvm::Error otherwise.
+ virtual llvm::Error TraceStart(llvm::StringRef json_params,
+ llvm::StringRef type) {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Unsupported tracing type '%s'",
+ type.data());
}
- /// This API provides the trace data collected in the form of raw
- /// data.
- ///
- /// \param[in] traceid thread
- /// The traceid and thread provide the context for the trace
- /// instance.
- ///
- /// \param[in] buffer
- /// The buffer provides the destination buffer where the trace
- /// data would be read to. The buffer should be truncated to the
- /// filled length by this function.
- ///
- /// \param[in] offset
- /// There is possibility to read partially the trace data from
- /// a specified offset where in such cases the buffer provided
- /// may be smaller than the internal trace collection container.
- ///
- /// \return
- /// The size of the data actually read.
- virtual Status GetData(lldb::user_id_t traceid, lldb::tid_t thread,
- llvm::MutableArrayRef<uint8_t> &buffer,
- size_t offset = 0) {
- return Status("Not implemented");
+ /// \copydoc Process::TraceStop(const TraceStopRequest &)
+ virtual llvm::Error TraceStop(const TraceStopRequest &request) {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Unsupported tracing type '%s'",
+ request.type.data());
}
- /// Similar API as above except it aims to provide any extra data
- /// useful for decoding the actual trace data.
- virtual Status GetMetaData(lldb::user_id_t traceid, lldb::tid_t thread,
- llvm::MutableArrayRef<uint8_t> &buffer,
- size_t offset = 0) {
- return Status("Not implemented");
+ /// \copydoc Process::TraceGetState(llvm::StringRef type)
+ virtual llvm::Expected<llvm::json::Value>
+ TraceGetState(llvm::StringRef type) {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Unsupported tracing type '%s'",
+ type.data());
}
- /// API to query the TraceOptions for a given user id
- ///
- /// \param[in] traceid
- /// The user id of the tracing instance.
- ///
- /// \param[out] config
- /// The configuration being used for tracing.
- ///
- /// \return A status indicating what went wrong.
- virtual Status GetTraceConfig(lldb::user_id_t traceid, TraceOptions &config) {
- return Status("Not implemented");
+ /// \copydoc Process::TraceGetBinaryData(const TraceGetBinaryDataRequest &)
+ virtual llvm::Expected<std::vector<uint8_t>>
+ TraceGetBinaryData(const TraceGetBinaryDataRequest &request) {
+ return llvm::createStringError(
+ llvm::inconvertibleErrorCode(),
+ "Unsupported data kind '%s' for the '%s' tracing technology",
+ request.kind.c_str(), request.type.c_str());
}
- /// \copydoc Process::GetSupportedTraceType()
- virtual llvm::Expected<TraceTypeInfo> GetSupportedTraceType() {
+ /// \copydoc Process::TraceSupported()
+ virtual llvm::Expected<TraceSupportedResponse> TraceSupported() {
return llvm::make_error<UnimplementedError>();
}
+ /// Method called in order to propagate the bitmap of protocol
+ /// extensions supported by the client.
+ ///
+ /// \param[in] flags
+ /// The bitmap of enabled extensions.
+ virtual void SetEnabledExtensions(Extension flags) {
+ m_enabled_extensions = flags;
+ }
+
protected:
struct SoftwareBreakpoint {
uint32_t ref_count;
@@ -416,8 +388,7 @@ protected:
llvm::Optional<WaitStatus> m_exit_status;
- std::recursive_mutex m_delegates_mutex;
- std::vector<NativeDelegate *> m_delegates;
+ NativeDelegate &m_delegate;
NativeWatchpointList m_watchpoint_list;
HardwareBreakpointMap m_hw_breakpoints_map;
int m_terminal_fd;
@@ -427,6 +398,9 @@ protected:
// stopping it.
llvm::DenseSet<int> m_signals_to_ignore;
+ // Extensions enabled per the last SetEnabledExtensions() call.
+ Extension m_enabled_extensions;
+
// lldb_private::Host calls should be used to launch a process for debugging,
// and then the process should be attached to. When attaching to a process
// lldb_private::Host calls should be used to locate the process to attach
diff --git a/lldb/include/lldb/Host/common/NativeThreadProtocol.h b/lldb/include/lldb/Host/common/NativeThreadProtocol.h
index 8d4c03549bb9..5cf26bd95939 100644
--- a/lldb/include/lldb/Host/common/NativeThreadProtocol.h
+++ b/lldb/include/lldb/Host/common/NativeThreadProtocol.h
@@ -21,7 +21,7 @@ class NativeThreadProtocol {
public:
NativeThreadProtocol(NativeProcessProtocol &process, lldb::tid_t tid);
- virtual ~NativeThreadProtocol() {}
+ virtual ~NativeThreadProtocol() = default;
virtual std::string GetName() = 0;
diff --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index 3ee8f9d9133e..42be989dfa7b 100644
--- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -108,7 +108,7 @@ protected:
std::atomic<bool> m_shutting_down; // This marks that we are shutting down so
// if we get woken up from
// BytesAvailable to disconnect, we won't try to read again.
- bool m_waiting_for_accept;
+ bool m_waiting_for_accept = false;
bool m_child_processes_inherit;
std::string m_uri;