Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
46478c5
lldb-server with GPU plugins.
clayborg Mar 20, 2025
f09c0df
Made the mock GPU plug-in functional.
clayborg Apr 2, 2025
8946364
Add missing file.
clayborg Apr 2, 2025
b84fbdb
Moved LLDBServerPlugin into LLDB library.
clayborg Apr 9, 2025
1665da9
Flesh out plugin system.
clayborg Apr 11, 2025
a620f15
Add a JSON response to jGPUPluginBreakpointHit
clayborg Apr 11, 2025
9b64691
Add StreamGDBRemote methods to facilitate sending JSON.
clayborg Apr 11, 2025
d521487
Many fixes listed below.
clayborg Apr 12, 2025
24f5a1b
Add arch and target triple support for AMD and NVidia GPUs.
clayborg Apr 16, 2025
540d71b
Changes to the plug-in models.
clayborg Apr 23, 2025
3bdc47d
Clean up the register context code for the Mock GPU.
clayborg Apr 29, 2025
6bf8d91
Added the ability for GPU plug-ins to return shared libraries.
clayborg Apr 30, 2025
0870cfc
Add dynamic loader support for GPUs.
clayborg Apr 30, 2025
d285bba
Get dynamic loader working and hooked up.
clayborg May 1, 2025
14e0945
Added logging to GPU dynamic loader and fixed load address to be sent.
clayborg May 2, 2025
857f067
Add the ability to set breakpoints by address.
clayborg May 5, 2025
3671889
Added "bool load_libraries;" to the GPUActions structure.
clayborg May 6, 2025
b3f5dfc
Add a stop reason class for the dynamic loader.
clayborg May 7, 2025
8dcd0fa
Fix typo in comment.
clayborg May 7, 2025
a279671
Add the GDBRemoteCommunication this pointer to log.
clayborg May 7, 2025
cf14232
Add gpu plug-ins as an extension.
clayborg May 7, 2025
8fc2ae4
Rename some features and enums for gpu plug-ins and dyld.
clayborg May 7, 2025
26b4ad0
Allow GPUActions to auto resume the GPU process.
clayborg May 8, 2025
5b6202d
Make module loading work within a file.
clayborg May 8, 2025
6238a86
Add the ability to halt the native process from the GPU plug-in.
clayborg May 9, 2025
ca7512b
Added the ability to have the native process wait for the GPU process to
clayborg May 22, 2025
d20f49a
Fix ProcessGDBRemote::HandleGPUActions() to return an error.
clayborg May 28, 2025
90a97c0
[To upstream] Add a name to server comm channels and include them in …
walter-erquinigo Jun 9, 2025
052a344
[To upstream] minor changes in the packets files
walter-erquinigo Jun 5, 2025
e9858b8
[To upstream] Add proper error handling for GPU packets
walter-erquinigo Jun 5, 2025
00d2082
Check object offset in ModuleSpec matching
Jun 10, 2025
dff4bdc
AMD GPU plugin v0
Jun 2, 2025
61b29e0
Feedback from Greg
Jun 10, 2025
f24f12e
Some refactoring
Jun 12, 2025
15e8b75
Fix compile errors
dmpots Jul 1, 2025
c4934b3
Merge pull request #8 from dmpots/fix-compile
dmpots Jul 1, 2025
276d172
[LLDB][GPU] Handle GPUAction errors
walter-erquinigo Jun 26, 2025
668cdc8
[To upstream][LLDB] Connect synchronously to the gpu process
walter-erquinigo Jun 27, 2025
864d5dc
[LLDB][GPU] Add a comment warning the assumptions in HandleGPUActons
walter-erquinigo Jul 2, 2025
9ce3e95
[amd] Remove mock gpu example breakpoint (#13)
dmpots Jul 3, 2025
25c92ff
Fix AMD module path parsing to work for memory modules.
clayborg Jul 4, 2025
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
17 changes: 15 additions & 2 deletions lldb/include/lldb/Host/common/NativeProcessProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/Iterable.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/GPUGDBRemotePackets.h"
#include "lldb/Utility/TraceGDBRemotePackets.h"
#include "lldb/Utility/UnimplementedError.h"
#include "lldb/lldb-private-forward.h"
Expand Down Expand Up @@ -179,6 +180,9 @@ class NativeProcessProtocol {
// Accessors
lldb::pid_t GetID() const { return m_pid; }

// Get process info
virtual bool GetProcessInfo(ProcessInstanceInfo &proc_info);

lldb::StateType GetState() const;

bool IsRunning() const {
Expand All @@ -187,7 +191,9 @@ class NativeProcessProtocol {

bool IsStepping() const { return m_state == lldb::eStateStepping; }

bool CanResume() const { return m_state == lldb::eStateStopped; }
bool IsStopped() const { return m_state == lldb::eStateStopped; }

bool CanResume() const { return IsStopped(); }

lldb::ByteOrder GetByteOrder() const {
return GetArchitecture().GetByteOrder();
Expand Down Expand Up @@ -252,6 +258,11 @@ class NativeProcessProtocol {
virtual Status GetFileLoadAddress(const llvm::StringRef &file_name,
lldb::addr_t &load_addr) = 0;

virtual std::optional<GPUDynamicLoaderResponse>
GetGPUDynamicLoaderLibraryInfos(const GPUDynamicLoaderArgs &args) {
return std::nullopt;
}

/// Extension flag constants, returned by Manager::GetSupportedExtensions()
/// and passed to SetEnabledExtension()
enum class Extension {
Expand All @@ -264,8 +275,10 @@ class NativeProcessProtocol {
memory_tagging = (1u << 6),
savecore = (1u << 7),
siginfo_read = (1u << 8),
gpu_plugins = (1u << 9),
gpu_dyld = (1u << 10),

LLVM_MARK_AS_BITMASK_ENUM(siginfo_read)
LLVM_MARK_AS_BITMASK_ENUM(gpu_dyld)
};

class Manager {
Expand Down
11 changes: 11 additions & 0 deletions lldb/include/lldb/Target/DynamicLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ class DynamicLoader : public PluginInterface {
/// loader often knows what the program entry point is. So the process and
/// the dynamic loader can work together to detect this.
virtual bool ProcessDidExec() { return false; }

/// A function that allows dynamic loader to handle eStopReasonDynammicLoader
/// stop reasons. This is intended for dynamic loaders that aren't able to
/// set a breakpoint in the process, but rely on being notified by a driver or
/// debug services that shared libraries are available.
///
/// \returns True if handled, false otherwise.
virtual bool HandleStopReasonDynammicLoader() {
return false;
}

/// Get whether the process should stop when images change.
///
/// When images (executables and shared libraries) get loaded or unloaded,
Expand Down
15 changes: 15 additions & 0 deletions lldb/include/lldb/Target/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,21 @@ class Process : public std::enable_shared_from_this<Process>,
SelectMostRelevant select_most_relevant =
DoNoSelectMostRelevantFrame);

/// Wait for the process to resume.
///
/// Given the current ProcessModID that identifies a current state, wait for
/// the process to resume.
///
/// \param[in] curr_resume_id
/// The resume ID that identifies the resume ID from a stopped state.
///
/// \param[in] timeout_sec
/// The maximum time in seconds to wait for the process to transition to
/// the eStateRunning state. If no timeout is supplied, block and wait
/// indefinitely.
Status WaitForNextResume(const uint32_t curr_resume_id,
std::optional<uint32_t> timeout_sec);

uint32_t GetIOHandlerID() const { return m_iohandler_sync.GetValue(); }

/// Waits for the process state to be running within a given msec timeout.
Expand Down
3 changes: 3 additions & 0 deletions lldb/include/lldb/Target/StopInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ class StopInfo : public std::enable_shared_from_this<StopInfo> {
static lldb::StopInfoSP
CreateStopReasonHistoryBoundary(Thread &thread, const char *description);

static lldb::StopInfoSP
CreateStopReasonDyld(Thread &thread, const char *description = nullptr);

static lldb::StopInfoSP CreateStopReasonFork(Thread &thread,
lldb::pid_t child_pid,
lldb::tid_t child_tid);
Expand Down
23 changes: 23 additions & 0 deletions lldb/include/lldb/Target/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,21 @@ class Target : public std::enable_shared_from_this<Target>,
/// Print all the signals set in this target.
void PrintDummySignals(Stream &strm, Args &signals);


lldb::TargetSP GetGPUPluginTarget(llvm::StringRef plugin_name) {
return m_gpu_plugin_targets.lookup(plugin_name).lock();
}

void SetGPUPluginTarget(llvm::StringRef plugin_name,
lldb::TargetSP target_sp) {
m_native_target_gpu_wp = shared_from_this();
m_gpu_plugin_targets[plugin_name] = target_sp;
}

lldb::TargetSP GetNativeTargetForGPU() {
return m_native_target_gpu_wp.lock();
}

protected:
/// Implementing of ModuleList::Notifier.

Expand Down Expand Up @@ -1650,6 +1665,14 @@ class Target : public std::enable_shared_from_this<Target>,
/// signals you will have.
llvm::StringMap<DummySignalValues> m_dummy_signals;

/// If a process spawns another target for a GPU plug-in, this map tracks the
/// associated plug-in targets so they can be accessed.
llvm::StringMap<lldb::TargetWP> m_gpu_plugin_targets;
/// If a target has a parent target, this can be used to synchronize the two
/// targets. For example if a GPU target wants to resume but it requires its
/// native target to resume as well, we can use this to make this happen.
lldb::TargetWP m_native_target_gpu_wp;

static void ImageSearchPathsChanged(const PathMappingList &path_list,
void *baton);

Expand Down
6 changes: 6 additions & 0 deletions lldb/include/lldb/Utility/ArchSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ class ArchSpec {

eCore_wasm32,

eCore_amd_gpu_r600,
eCore_amd_gpu_gcn,

eCore_nvidia_nvptx,
eCore_nvidia_nvptx64,

kNumCores,

kCore_invalid,
Expand Down
58 changes: 57 additions & 1 deletion lldb/include/lldb/Utility/GDBRemote.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-public.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/JSON.h"

#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>

namespace lldb_private {

Expand All @@ -43,6 +43,62 @@ class StreamGDBRemote : public StreamString {
/// Number of bytes written.
// TODO: Convert this function to take ArrayRef<uint8_t>
int PutEscapedBytes(const void *s, size_t src_len);

/// Convert an object into JSON and add the JSON text to the packet.
///
/// Any special characters in the JSON will be escaped to make sure it doesn't
/// interfere with the GDB remote protocol packet format.
///
/// \param[in] obj
/// The object to convert to JSON which must have a method written that
/// converts the object to a llvm::json::Value:
///
/// \code llvm::json::Value toJSON(const T &obj);
///
/// \param[in] hex_ascii
/// If \a true then encode JSON as hex ASCII bytes. If \a false, then
/// encode as an escaped string value.
///
/// \return
/// Number of bytes written.
template<class T> int PutAsJSON(const T &obj, bool hex_ascii) {
std::string json_string;
llvm::raw_string_ostream os(json_string);
os << toJSON(obj);
if (hex_ascii)
return PutStringAsRawHex8(json_string);
else
return PutEscapedBytes(json_string.c_str(), json_string.size());
}
/// Convert an array of objects into JSON and add the JSON text to the packet.
///
/// Any special characters in the JSON will be escaped to make sure it doesn't
/// interfere with the GDB remote protocol packet format.
///
/// \param[in] array
/// An array of objects to convert to JSON. The object't type must have a
/// method written that converts the object to a llvm::json::Value:
///
/// \code llvm::json::Value toJSON(const T &obj);
///
/// \return
/// Number of bytes written.
template<class T> int PutAsJSONArray(const std::vector<T> &array) {
std::string json_string;
llvm::raw_string_ostream os(json_string);
bool first = true;
os << "[";
for (auto &obj: array) {
if (first)
first = false;
else
os << ",";
os << toJSON(obj);
}
os << "]";
return PutEscapedBytes(json_string.data(), json_string.size());
}

};

/// GDB remote packet as used by the GDB remote communication history. Packets
Expand Down
Loading
Loading