Skip to content
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
64 changes: 35 additions & 29 deletions lldb/include/lldb/Utility/GPUGDBRemotePackets.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct SymbolValue {
/// If the optional doesn't have a value, then the symbol was not available.
std::optional<uint64_t> value;
};
bool fromJSON(const llvm::json::Value &value, SymbolValue &data,
bool fromJSON(const llvm::json::Value &value, SymbolValue &data,
llvm::json::Path path);

llvm::json::Value toJSON(const SymbolValue &data);
Expand Down Expand Up @@ -71,7 +71,7 @@ llvm::json::Value toJSON(const GPUBreakpointByAddress &data);
///
/// Clients should either fill in the \a name_info or the \a addr_info. If the
/// breakpoint callback needs some symbols from the native process, they can
/// fill in the array of symbol names with any symbol names that are needed.
/// fill in the array of symbol names with any symbol names that are needed.
/// These symbol values will be delivered in the breakpoint callback to the GPU
/// plug-in.
///-----------------------------------------------------------------------------
Expand All @@ -86,16 +86,20 @@ struct GPUBreakpointInfo {
};

bool fromJSON(const llvm::json::Value &value, GPUBreakpointInfo &data,
llvm::json::Path path);
llvm::json::Path path);

llvm::json::Value toJSON(const GPUBreakpointInfo &data);

struct GPUPluginBreakpointHitArgs {
GPUPluginBreakpointHitArgs() = default;
GPUPluginBreakpointHitArgs(llvm::StringRef plugin_name)
: plugin_name(plugin_name) {}

std::string plugin_name;
GPUBreakpointInfo breakpoint;
std::vector<SymbolValue> symbol_values;

std::optional<uint64_t> GetSymbolValue(llvm::StringRef symbol_name);
std::optional<uint64_t> GetSymbolValue(llvm::StringRef symbol_name) const;
};

bool fromJSON(const llvm::json::Value &value, GPUPluginBreakpointHitArgs &data,
Expand All @@ -116,7 +120,7 @@ struct GPUPluginConnectionInfo {
std::optional<std::string> platform_name;
/// The target triple to use as the architecture when creating the target.
std::optional<std::string> triple;
/// The connection URL to use with "process connect <url>".
/// The connection URL to use with "process connect <url>".
std::string connect_url;
};

Expand All @@ -140,11 +144,11 @@ llvm::json::Value toJSON(const GPUPluginConnectionInfo &data);
/// native process in LLDB will call into the native process' GDB server and
/// have it call the GPU plug-in method:
///
/// GPUPluginBreakpointHitResponse
/// GPUPluginBreakpointHitResponse
/// LLDBServerPlugin::BreakpointWasHit(GPUPluginBreakpointHitArgs &args);
///
/// The GPUPluginBreakpointHitResponse contains a GPUActions member that will
/// be encoded and sent back to the ProcessGDBRemote for the native process.
/// be encoded and sent back to the ProcessGDBRemote for the native process.
///
/// - Anytime the native process stops, the native process' GDB server will ask
/// each GPU plug-in if there are any actions it would like to report, the
Expand All @@ -157,6 +161,9 @@ llvm::json::Value toJSON(const GPUPluginConnectionInfo &data);
/// native process.
///-----------------------------------------------------------------------------
struct GPUActions {
GPUActions() = default;
GPUActions(llvm::StringRef plugin_name) : plugin_name(plugin_name) {}

/// The name of the plugin.
std::string plugin_name;
/// New breakpoints to set. Nothing to set if this is empty.
Expand All @@ -165,8 +172,8 @@ struct GPUActions {
/// connect to the GPU GDB server as a separate process.
std::optional<GPUPluginConnectionInfo> connect_info;
/// Set this to true if the native plug-in should tell the ProcessGDBRemote
/// in LLDB for the GPU process to load libraries. This allows the native
/// process to be notified that it should query for the shared libraries on
/// in LLDB for the GPU process to load libraries. This allows the native
/// process to be notified that it should query for the shared libraries on
/// the GPU connection.
bool load_libraries = false;
/// Set this to true if the native plug-in resume the GPU process.
Expand All @@ -176,23 +183,21 @@ struct GPUActions {
bool wait_for_gpu_process_to_resume = false;
};

bool fromJSON(const llvm::json::Value &value,
GPUActions &data,
llvm::json::Path path);
bool fromJSON(const llvm::json::Value &value, GPUActions &data,
llvm::json::Path path);

llvm::json::Value toJSON(const GPUActions &data);


struct GPUSectionInfo {
/// Name of the section to load. If there are multiple sections, each section
/// will be looked up and then a child section within the previous section
/// will be looked up. This allows plug-ins to specify a hiearchy of sections
/// in the case where section names are not unique. A valid example looks
/// in the case where section names are not unique. A valid example looks
/// like: ["PT_LOAD[0]", ".text"]. If there is only one section name, LLDB
/// will find the first section that matches that name.
std::vector<std::string> names;
/// The load address of this section only. If this value is valid, then this
/// section is loaded at this address, else child sections can be loaded
/// section is loaded at this address, else child sections can be loaded
/// individually.
lldb::addr_t load_address;
};
Expand All @@ -212,30 +217,30 @@ struct GPUDynamicLoaderLibraryInfo {
bool load;
/// The address where the object file is loaded. If this member has a value
/// the object file is loaded at an address and all sections should be slid to
/// match this base address. If this member doesn't have a value, then
/// match this base address. If this member doesn't have a value, then
/// individual section's load address must be specified individually if
/// \a loaded_sections has a value. If this doesn't have a value and the
/// \a loaded_Section doesn't have a value, this library will be unloaded.
std::optional<lldb::addr_t> load_address;

/// If the object file specified by this structure has sections that get
/// If the object file specified by this structure has sections that get
/// loaded at different times then this will not be empty. If it is empty
/// the \a load_address must be specified if \a load is true.
std::vector<GPUSectionInfo> loaded_sections;

/// If this library is only available as an in memory image of an object file
/// in the native process, then this address holds the address from which the
/// in the native process, then this address holds the address from which the
/// image can be read.
std::optional<lldb::addr_t> native_memory_address;
/// If this library is only available as an in memory image of an object file
/// in the native process, then this size of the in memory image that starts
/// at \a native_memory_address.
std::optional<lldb::addr_t> native_memory_size;
/// If the library exists inside of a file at an offset, \a file_offset will
/// have a value that is the offset in bytes from the start of the file
/// If the library exists inside of a file at an offset, \a file_offset will
/// have a value that is the offset in bytes from the start of the file
/// specified by \a pathname.
std::optional<uint64_t> file_offset;
/// If the library exists inside of a file at an offset, \a file_size will
/// If the library exists inside of a file at an offset, \a file_size will
/// have a value that indicates the size in bytes of the object file.
std::optional<uint64_t> file_size;
};
Expand All @@ -245,30 +250,31 @@ bool fromJSON(const llvm::json::Value &value, GPUDynamicLoaderLibraryInfo &data,

llvm::json::Value toJSON(const GPUDynamicLoaderLibraryInfo &data);



///-----------------------------------------------------------------------------
/// GPUPluginBreakpointHitResponse
///
/// A response structure from the GPU plugin from hitting a native breakpoint
/// set by the GPU plugin.
///-----------------------------------------------------------------------------
struct GPUPluginBreakpointHitResponse {
GPUPluginBreakpointHitResponse() = default;
GPUPluginBreakpointHitResponse(llvm::StringRef plugin_name)
: actions(plugin_name) {}

///< Set to true if this berakpoint should be disabled.
bool disable_bp = false;
bool disable_bp = false;
/// Optional new breakpoints to set.
GPUActions actions;
};

bool fromJSON(const llvm::json::Value &value,
GPUPluginBreakpointHitResponse &data,
llvm::json::Path path);
bool fromJSON(const llvm::json::Value &value,
GPUPluginBreakpointHitResponse &data, llvm::json::Path path);

llvm::json::Value toJSON(const GPUPluginBreakpointHitResponse &data);

struct GPUDynamicLoaderArgs {
/// Set to true to get all shared library information. Set to false to get
/// only the libraries that were updated since the last call to
/// only the libraries that were updated since the last call to
/// the "jGPUPluginGetDynamicLoaderLibraryInfo" packet.
bool full;
};
Expand All @@ -280,7 +286,7 @@ llvm::json::Value toJSON(const GPUDynamicLoaderArgs &data);

struct GPUDynamicLoaderResponse {
/// Set to true to get all shared library information. Set to false to get
/// only the libraries that were updated since the last call to
/// only the libraries that were updated since the last call to
/// the "jGPUPluginGetDynamicLoaderLibraryInfo" packet.
std::vector<GPUDynamicLoaderLibraryInfo> library_infos;
};
Expand Down
Loading