-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[lldb][LoongArch64] Add support for LoongArch64 in elf-core for lldb #112296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ba485de
[LoongArch64]: Add support for LoongArch64 in elf-core for lldb
lawn123 355442e
Fix formatting and add two testcases in TestLinuxCore.py
lawn123 2cce5e7
Fix format
lawn123 bd8409d
Fix format and reduce the size of the core file
lawn123 884a82d
Fix CI fail and fcsr format issues
lawn123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_loongarch64.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
//===-- RegisterContextPOSIXCore_loongarch64.cpp --------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "RegisterContextPOSIXCore_loongarch64.h" | ||
|
||
#include "lldb/Utility/DataBufferHeap.h" | ||
|
||
using namespace lldb_private; | ||
|
||
std::unique_ptr<RegisterContextCorePOSIX_loongarch64> | ||
RegisterContextCorePOSIX_loongarch64::Create(Thread &thread, | ||
const ArchSpec &arch, | ||
const DataExtractor &gpregset, | ||
llvm::ArrayRef<CoreNote> notes) { | ||
return std::unique_ptr<RegisterContextCorePOSIX_loongarch64>( | ||
new RegisterContextCorePOSIX_loongarch64( | ||
thread, | ||
std::make_unique<RegisterInfoPOSIX_loongarch64>(arch, Flags()), | ||
gpregset, notes)); | ||
} | ||
|
||
RegisterContextCorePOSIX_loongarch64::RegisterContextCorePOSIX_loongarch64( | ||
Thread &thread, | ||
std::unique_ptr<RegisterInfoPOSIX_loongarch64> register_info, | ||
const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes) | ||
: RegisterContextPOSIX_loongarch64(thread, std::move(register_info)) { | ||
|
||
m_gpr.SetData(std::make_shared<DataBufferHeap>(gpregset.GetDataStart(), | ||
gpregset.GetByteSize())); | ||
m_gpr.SetByteOrder(gpregset.GetByteOrder()); | ||
|
||
ArchSpec arch = m_register_info_up->GetTargetArchitecture(); | ||
DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc); | ||
m_fpr.SetData(std::make_shared<DataBufferHeap>(fpregset.GetDataStart(), | ||
fpregset.GetByteSize())); | ||
m_fpr.SetByteOrder(fpregset.GetByteOrder()); | ||
} | ||
|
||
RegisterContextCorePOSIX_loongarch64::~RegisterContextCorePOSIX_loongarch64() = | ||
default; | ||
|
||
bool RegisterContextCorePOSIX_loongarch64::ReadGPR() { return true; } | ||
|
||
bool RegisterContextCorePOSIX_loongarch64::ReadFPR() { return true; } | ||
|
||
bool RegisterContextCorePOSIX_loongarch64::WriteGPR() { | ||
assert(false && "Writing registers is not allowed for core dumps"); | ||
return false; | ||
} | ||
|
||
bool RegisterContextCorePOSIX_loongarch64::WriteFPR() { | ||
assert(false && "Writing registers is not allowed for core dumps"); | ||
return false; | ||
} | ||
|
||
bool RegisterContextCorePOSIX_loongarch64::ReadRegister( | ||
const RegisterInfo *reg_info, RegisterValue &value) { | ||
const uint8_t *src = nullptr; | ||
lldb::offset_t offset = reg_info->byte_offset; | ||
|
||
if (IsGPR(reg_info->kinds[lldb::eRegisterKindLLDB])) { | ||
src = m_gpr.GetDataStart(); | ||
} else if (IsFPR(reg_info->kinds[lldb::eRegisterKindLLDB])) { | ||
src = m_fpr.GetDataStart(); | ||
offset -= GetGPRSize(); | ||
} else { | ||
return false; | ||
} | ||
|
||
Status error; | ||
value.SetFromMemoryData(*reg_info, src + offset, reg_info->byte_size, | ||
lldb::eByteOrderLittle, error); | ||
return error.Success(); | ||
} | ||
|
||
bool RegisterContextCorePOSIX_loongarch64::WriteRegister( | ||
const RegisterInfo *reg_info, const RegisterValue &value) { | ||
return false; | ||
} |
58 changes: 58 additions & 0 deletions
58
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_loongarch64.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//===-- RegisterContextPOSIXCore_loongarch64.h -------------------*- C++-*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_LOONGARCH64_H | ||
#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_LOONGARCH64_H | ||
|
||
#include "Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h" | ||
#include "Plugins/Process/Utility/RegisterInfoPOSIX_loongarch64.h" | ||
|
||
#include "Plugins/Process/elf-core/RegisterUtilities.h" | ||
#include "lldb/Target/Thread.h" | ||
#include "lldb/Utility/DataExtractor.h" | ||
#include "lldb/Utility/RegisterValue.h" | ||
|
||
#include <memory> | ||
|
||
class RegisterContextCorePOSIX_loongarch64 | ||
: public RegisterContextPOSIX_loongarch64 { | ||
public: | ||
static std::unique_ptr<RegisterContextCorePOSIX_loongarch64> | ||
Create(lldb_private::Thread &thread, const lldb_private::ArchSpec &arch, | ||
const lldb_private::DataExtractor &gpregset, | ||
llvm::ArrayRef<lldb_private::CoreNote> notes); | ||
|
||
~RegisterContextCorePOSIX_loongarch64() override; | ||
|
||
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, | ||
lldb_private::RegisterValue &value) override; | ||
|
||
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, | ||
const lldb_private::RegisterValue &value) override; | ||
|
||
protected: | ||
RegisterContextCorePOSIX_loongarch64( | ||
lldb_private::Thread &thread, | ||
std::unique_ptr<RegisterInfoPOSIX_loongarch64> register_info, | ||
const lldb_private::DataExtractor &gpregset, | ||
llvm::ArrayRef<lldb_private::CoreNote> notes); | ||
|
||
bool ReadGPR() override; | ||
|
||
bool ReadFPR() override; | ||
|
||
bool WriteGPR() override; | ||
|
||
bool WriteFPR() override; | ||
|
||
private: | ||
lldb_private::DataExtractor m_gpr; | ||
lldb_private::DataExtractor m_fpr; | ||
}; | ||
|
||
#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_LOONGARCH64_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+35.2 KB
lldb/test/API/functionalities/postmortem/elf-core/linux-loongarch64.core
Binary file not shown.
Binary file added
BIN
+2.88 KB
lldb/test/API/functionalities/postmortem/elf-core/linux-loongarch64.out
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.