Skip to content

Commit fc833ca

Browse files
authored
succeed qModuleInfo when ELF file has no build ID (#165)
## Overview The ds2 implementation for handling the `qModuleInfo` packet fails when it is unable to retrieve an ELF build ID from the module. This failure causes `lldb` to stop fetching info for subsequent modules. This PR addresses the issue by making `qModuleInfo` succeed in this case and excluding the `uuid` field from the response. ## Validation GitHub build & test Locally verified debugging a Swift test that imports modules w/out build IDs. Images for all modules with build IDs load and symbols resolve correctly.
1 parent 0e60f81 commit fc833ca

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

Sources/GDBRemote/Mixins/FileOperationsMixin.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,23 +130,23 @@ ErrorCode FileOperationsMixin<T>::onQueryModuleInfo(Session &session,
130130
std::string &triple,
131131
ModuleInfo &info) const {
132132
ByteVector buildId;
133-
if (!Platform::GetExecutableFileBuildID(path, buildId))
134-
return kErrorUnknown;
133+
if (Platform::GetExecutableFileBuildID(path, buildId)) {
134+
// format the uuid as an upper-case string with two hex chars per byte
135+
std::ostringstream ss;
136+
for(const auto b : buildId)
137+
ss << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << int(b);
138+
139+
info.uuid = ss.str();
140+
}
135141

136142
// TODO(andrurogerz): Not all executable files contain an embedded build ID.
137143
// If GetExecutableFileBuildID fails, calculate an md5 hash of the file
138144
// contents and return that as an "md5" field instead of the "uuid" field.
139145

140-
// send the uuid as a hex-encoded, upper-case string
141-
std::ostringstream ss;
142-
for(const auto b : buildId)
143-
ss << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << int(b);
144-
145146
auto error = File::fileSize(path, info.file_size);
146147
if (error != kSuccess)
147148
return error;
148149

149-
info.uuid = ss.str();
150150
info.triple = triple;
151151
info.file_path = path;
152152
info.file_offset = 0;

Sources/GDBRemote/Structures.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,8 @@ std::string ProgramResult::encode() const {
847847

848848
std::string ModuleInfo::encode() const {
849849
std::ostringstream ss;
850-
ss << "uuid:" << ToHex(uuid) << ";";
850+
if (!uuid.empty())
851+
ss << "uuid:" << ToHex(uuid) << ";";
851852
ss << "triple:" << ToHex(triple) << ";";
852853
ss << "file_path:" << ToHex(file_path) << ";";
853854
ss << "file_offset:" << HEX(16) << file_offset << ";";

0 commit comments

Comments
 (0)