mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
[lldb] [Mach-O] don't strip the end of the "kern ver str" LC_NOTE (#77538)
The "kern ver str" LC_NOTE gives lldb a kernel version string -- with a UUID and/or a load address (stext) to load it at. The LC_NOTE specifies a size of the identifier string in bytes. In ObjectFileMachO::GetIdentifierString, I copy that number of bytes into a std::string, and in case there were additional nul characters at the end of the sting for padding reasons, I tried to shrink the std::string to not include these extra nul's. However, I did this resizing without handling the case of an empty identifier string. I don't know why any corefile creator would do that, but of course at least one does. This patch removes the resizing altogether; I was solving something that hasn't ever shown to be a problem. I also added a test case for this, to check that lldb doesn't crash when given one of these corefiles. rdar://120390199
This commit is contained in:
@@ -5467,8 +5467,6 @@ std::string ObjectFileMachO::GetIdentifierString() {
|
||||
uint32_t strsize = payload_size - sizeof(uint32_t);
|
||||
std::string result(strsize, '\0');
|
||||
m_data.CopyData(payload_offset, strsize, result.data());
|
||||
while (result.back() == '\0')
|
||||
result.resize(result.size() - 1);
|
||||
LLDB_LOGF(log, "LC_NOTE 'kern ver str' found with text '%s'",
|
||||
result.c_str());
|
||||
return result;
|
||||
@@ -5488,8 +5486,6 @@ std::string ObjectFileMachO::GetIdentifierString() {
|
||||
std::string result(ident_command.cmdsize, '\0');
|
||||
if (m_data.CopyData(offset, ident_command.cmdsize, result.data()) ==
|
||||
ident_command.cmdsize) {
|
||||
while (result.back() == '\0')
|
||||
result.resize(result.size() - 1);
|
||||
LLDB_LOGF(log, "LC_IDENT found with text '%s'", result.c_str());
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user