[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92078)
via lldb-commits
lldb-commits at lists.llvm.org
Tue May 14 00:59:43 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff f8063ffe73a3a1d704b9738169bb76ebb0f8a5e0 6a84c484070d53515c7cc473b4a0c1d566342b0f -- lldb/include/lldb/Target/Process.h lldb/source/Commands/CommandObjectMemory.cpp lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp lldb/source/Plugins/Process/elf-core/ProcessElfCore.h lldb/source/Target/Process.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 9894349555..102fa5eef1 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -1689,11 +1689,13 @@ public:
///
/// \param[in] high The ending address of the memory region to be searched.
///
- /// \param[in] buffer A pointer to the buffer containing the string to be searched.
+ /// \param[in] buffer A pointer to the buffer containing the string to be
+ /// searched.
///
/// \param[in] buffer_size The size of the buffer in bytes.
///
- /// \return The address where the string was found or LLDB_INVALID_ADDRESS if not found.
+ /// \return The address where the string was found or LLDB_INVALID_ADDRESS if
+ /// not found.
lldb::addr_t FastSearch(lldb::addr_t low, lldb::addr_t high, uint8_t *buffer,
size_t buffer_size);
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index fd37465e92..574f1dafc2 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -1077,8 +1077,8 @@ protected:
found_location = low_addr;
bool ever_found = false;
while (count) {
- found_location = process->FastSearch(found_location, high_addr, buffer.GetBytes(),
- buffer.GetByteSize());
+ found_location = process->FastSearch(
+ found_location, high_addr, buffer.GetBytes(), buffer.GetByteSize());
if (found_location == LLDB_INVALID_ADDRESS) {
if (!ever_found) {
result.AppendMessage("data not found within the range.\n");
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 7dd2577408..4c1f265d07 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -996,34 +996,38 @@ llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment(
}
bool ProcessElfCore::IsElf(const NT_FILE_Entry entry) {
- const uint8_t elf_header[4] = {0x7f, 0x45, 0x4c, 0x46}; // ELF file begin with this 4 bytes
+ const uint8_t elf_header[4] = {0x7f, 0x45, 0x4c,
+ 0x46}; // ELF file begin with this 4 bytes
uint8_t buf[4];
Status error;
size_t byte_read = ReadMemory(entry.start, buf, 4, error);
if (byte_read == 4) {
return memcmp(elf_header, buf, 4) == 0;
- } else{
+ } else {
return false;
}
}
UUID ProcessElfCore::FindBuildId(const NT_FILE_Entry entry) {
- if(!IsElf(entry)) {
+ if (!IsElf(entry)) {
return UUID();
}
// Build ID is stored in the ELF file as a section named ".note.gnu.build-id"
- uint8_t gnu_build_id_bytes[8] = {0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00};
- lldb::addr_t gnu_build_id_addr = FastSearch(entry.start, entry.end , gnu_build_id_bytes, 8);
+ uint8_t gnu_build_id_bytes[8] = {0x03, 0x00, 0x00, 0x00,
+ 0x47, 0x4e, 0x55, 0x00};
+ lldb::addr_t gnu_build_id_addr =
+ FastSearch(entry.start, entry.end, gnu_build_id_bytes, 8);
if (load_addr == LLDB_INVALID_ADDRESS) {
return UUID();
}
uint8_t buf[36];
Status error;
size_t byte_read = ReadMemory(gnu_build_id_addr - 8, buf, 36, error);
- // .note.gnu.build-id starts with 04 00 00 00 {id_byte_size} 00 00 00 03 00 00 00 47 4e 55 00
+ // .note.gnu.build-id starts with 04 00 00 00 {id_byte_size} 00 00 00 03 00 00
+ // 00 47 4e 55 00
if (byte_read == 36) {
if (buf[0] == 0x04) {
- return UUID(llvm::ArrayRef<uint8_t>(buf + 16, buf[4]/*byte size*/));
+ return UUID(llvm::ArrayRef<uint8_t>(buf + 16, buf[4] /*byte size*/));
}
}
return UUID();
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
index 3d78991ed5..6f47aa28be 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -117,7 +117,8 @@ private:
lldb::addr_t end;
lldb::addr_t file_ofs;
std::string path;
- lldb_private::UUID uuid; // extracted from .note.gnu.build-id section from core file
+ lldb_private::UUID
+ uuid; // extracted from .note.gnu.build-id section from core file
};
// For ProcessElfCore only
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 7f8a19c7be..88fe62a674 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -3191,8 +3191,8 @@ Status Process::Halt(bool clear_thread_plans, bool use_run_lock) {
return Status();
}
-lldb::addr_t Process::FastSearch(lldb::addr_t low, lldb::addr_t high, uint8_t *buffer,
- size_t buffer_size) {
+lldb::addr_t Process::FastSearch(lldb::addr_t low, lldb::addr_t high,
+ uint8_t *buffer, size_t buffer_size) {
const size_t region_size = high - low;
if (region_size < buffer_size)
``````````
</details>
https://github.com/llvm/llvm-project/pull/92078
More information about the lldb-commits
mailing list