-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[lldb][RISCV] Add RegisterContextPOSIXCore for RISC-V 64 #93297
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
d30c3b7
Add RegisterContextPOSIXCore for RISC-V 64
AlexeyMerzlyakov 7239f62
Meet review items
AlexeyMerzlyakov 73386d9
Optimize flags initialization
AlexeyMerzlyakov 183f76d
Add FPR check to registers test
AlexeyMerzlyakov 041f572
Fix formatting
AlexeyMerzlyakov 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
82 changes: 82 additions & 0 deletions
82
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.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,82 @@ | ||
//===-- RegisterContextPOSIXCore_riscv64.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_riscv64.h" | ||
|
||
#include "lldb/Utility/DataBufferHeap.h" | ||
|
||
using namespace lldb_private; | ||
|
||
std::unique_ptr<RegisterContextCorePOSIX_riscv64> | ||
RegisterContextCorePOSIX_riscv64::Create(Thread &thread, const ArchSpec &arch, | ||
const DataExtractor &gpregset, | ||
llvm::ArrayRef<CoreNote> notes) { | ||
return std::unique_ptr<RegisterContextCorePOSIX_riscv64>( | ||
DavidSpickett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
new RegisterContextCorePOSIX_riscv64( | ||
thread, std::make_unique<RegisterInfoPOSIX_riscv64>(arch, Flags()), | ||
gpregset, notes)); | ||
} | ||
|
||
RegisterContextCorePOSIX_riscv64::RegisterContextCorePOSIX_riscv64( | ||
Thread &thread, std::unique_ptr<RegisterInfoPOSIX_riscv64> register_info, | ||
const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes) | ||
: RegisterContextPOSIX_riscv64(thread, std::move(register_info)) { | ||
|
||
m_gpr_buffer = std::make_shared<DataBufferHeap>(gpregset.GetDataStart(), | ||
gpregset.GetByteSize()); | ||
m_gpr.SetData(m_gpr_buffer); | ||
m_gpr.SetByteOrder(gpregset.GetByteOrder()); | ||
|
||
ArchSpec arch = m_register_info_up->GetTargetArchitecture(); | ||
DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc); | ||
m_fpr_buffer = std::make_shared<DataBufferHeap>(fpregset.GetDataStart(), | ||
DavidSpickett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fpregset.GetByteSize()); | ||
m_fpr.SetData(m_fpr_buffer); | ||
m_fpr.SetByteOrder(fpregset.GetByteOrder()); | ||
} | ||
|
||
RegisterContextCorePOSIX_riscv64::~RegisterContextCorePOSIX_riscv64() = default; | ||
|
||
bool RegisterContextCorePOSIX_riscv64::ReadGPR() { return true; } | ||
|
||
bool RegisterContextCorePOSIX_riscv64::ReadFPR() { return true; } | ||
|
||
bool RegisterContextCorePOSIX_riscv64::WriteGPR() { | ||
assert(false && "Writing registers is not allowed for core dumps"); | ||
return false; | ||
} | ||
|
||
bool RegisterContextCorePOSIX_riscv64::WriteFPR() { | ||
assert(false && "Writing registers is not allowed for core dumps"); | ||
return false; | ||
} | ||
|
||
bool RegisterContextCorePOSIX_riscv64::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_riscv64::WriteRegister( | ||
const RegisterInfo *reg_info, const RegisterValue &value) { | ||
return false; | ||
} |
60 changes: 60 additions & 0 deletions
60
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.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,60 @@ | ||
//===-- RegisterContextPOSIXCore_riscv64.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_RISCV64_H | ||
#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_RISCV64_H | ||
|
||
#include "Plugins/Process/Utility/RegisterContextPOSIX_riscv64.h" | ||
#include "Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.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_riscv64 : public RegisterContextPOSIX_riscv64 { | ||
public: | ||
static std::unique_ptr<RegisterContextCorePOSIX_riscv64> | ||
Create(lldb_private::Thread &thread, const lldb_private::ArchSpec &arch, | ||
const lldb_private::DataExtractor &gpregset, | ||
llvm::ArrayRef<lldb_private::CoreNote> notes); | ||
|
||
~RegisterContextCorePOSIX_riscv64() 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_riscv64( | ||
lldb_private::Thread &thread, | ||
std::unique_ptr<RegisterInfoPOSIX_riscv64> 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::DataBufferSP m_gpr_buffer; | ||
lldb::DataBufferSP m_fpr_buffer; | ||
|
||
lldb_private::DataExtractor m_gpr; | ||
lldb_private::DataExtractor m_fpr; | ||
}; | ||
|
||
#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_RISCV64_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 not shown.
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.