-
Notifications
You must be signed in to change notification settings - Fork 16.8k
[lldb][Process/FreeBSDKernelCore] Add ppc64le support #180669
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
70838f6
[lldb][Process/FreeBSDKernel] Add ppc64le support
mchoo7 2b3319d
fixup! [lldb][Process/FreeBSDKernel] Add ppc64le support
mchoo7 6fe539f
fixup! [lldb][Process/FreeBSDKernel] Add ppc64le support
mchoo7 ba187e4
Merge main
mchoo7 4fb8bfe
fixup! [lldb][Process/FreeBSDKernel] Add ppc64le support
mchoo7 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
95 changes: 95 additions & 0 deletions
95
lldb/source/Plugins/Process/FreeBSD-Kernel-Core/RegisterContextFreeBSDKernelCore_ppc64le.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,95 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // 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 "RegisterContextFreeBSDKernelCore_ppc64le.h" | ||
|
|
||
| #include "lldb/Target/Process.h" | ||
| #include "lldb/Target/Thread.h" | ||
| #include "lldb/Utility/RegisterValue.h" | ||
| #include "llvm/Support/Endian.h" | ||
|
|
||
| using namespace lldb; | ||
| using namespace lldb_private; | ||
|
|
||
| RegisterContextFreeBSDKernelCore_ppc64le:: | ||
| RegisterContextFreeBSDKernelCore_ppc64le( | ||
| Thread &thread, lldb_private::RegisterInfoInterface *register_info, | ||
| lldb::addr_t pcb_addr) | ||
| : RegisterContextPOSIX_ppc64le(thread, 0, register_info), | ||
| m_pcb_addr(pcb_addr) {} | ||
|
|
||
| bool RegisterContextFreeBSDKernelCore_ppc64le::ReadRegister( | ||
| const RegisterInfo *reg_info, RegisterValue &value) { | ||
| if (m_pcb_addr == LLDB_INVALID_ADDRESS) | ||
| return false; | ||
|
|
||
| // https://cgit.freebsd.org/src/tree/sys/powerpc/include/pcb.h | ||
| struct { | ||
| llvm::support::ulittle64_t context[20]; | ||
| llvm::support::ulittle64_t cr; | ||
| llvm::support::ulittle64_t sp; | ||
| llvm::support::ulittle64_t toc; | ||
| llvm::support::ulittle64_t lr; | ||
| } pcb; | ||
|
|
||
| Status error; | ||
| size_t rd = | ||
| m_thread.GetProcess()->ReadMemory(m_pcb_addr, &pcb, sizeof(pcb), error); | ||
| if (rd != sizeof(pcb)) | ||
| return false; | ||
|
|
||
| uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB]; | ||
| switch (reg) { | ||
| case gpr_r1_ppc64le: | ||
| // r1 is saved in the sp field | ||
| value = pcb.sp; | ||
| break; | ||
| case gpr_r2_ppc64le: | ||
| // r2 is saved in the toc field | ||
| value = pcb.toc; | ||
| break; | ||
| case gpr_r12_ppc64le: | ||
| case gpr_r13_ppc64le: | ||
| case gpr_r14_ppc64le: | ||
| case gpr_r15_ppc64le: | ||
| case gpr_r16_ppc64le: | ||
| case gpr_r17_ppc64le: | ||
| case gpr_r18_ppc64le: | ||
| case gpr_r19_ppc64le: | ||
| case gpr_r20_ppc64le: | ||
| case gpr_r21_ppc64le: | ||
| case gpr_r22_ppc64le: | ||
| case gpr_r23_ppc64le: | ||
| case gpr_r24_ppc64le: | ||
| case gpr_r25_ppc64le: | ||
| case gpr_r26_ppc64le: | ||
| case gpr_r27_ppc64le: | ||
| case gpr_r28_ppc64le: | ||
| case gpr_r29_ppc64le: | ||
| case gpr_r30_ppc64le: | ||
| case gpr_r31_ppc64le: | ||
| value = pcb.context[reg - gpr_r12_ppc64le]; | ||
| break; | ||
| case gpr_pc_ppc64le: | ||
| case gpr_lr_ppc64le: | ||
| // The pc of crashing thread is stored in lr. | ||
| value = pcb.lr; | ||
| break; | ||
| case gpr_cr_ppc64le: | ||
| value = pcb.cr; | ||
| break; | ||
| default: | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| bool RegisterContextFreeBSDKernelCore_ppc64le::WriteRegister( | ||
| const RegisterInfo *reg_info, const RegisterValue &value) { | ||
| return false; | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
lldb/source/Plugins/Process/FreeBSD-Kernel-Core/RegisterContextFreeBSDKernelCore_ppc64le.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,33 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // 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_FREEBSDKERNEL_REGISTERCONTEXTFREEBSDKERNELCORE_PPC64LE_H | ||
| #define LLDB_SOURCE_PLUGINS_PROCESS_FREEBSDKERNEL_REGISTERCONTEXTFREEBSDKERNELCORE_PPC64LE_H | ||
|
|
||
| #include "Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h" | ||
| #include "Plugins/Process/elf-core/RegisterUtilities.h" | ||
|
|
||
| class RegisterContextFreeBSDKernelCore_ppc64le | ||
| : public RegisterContextPOSIX_ppc64le { | ||
| public: | ||
| RegisterContextFreeBSDKernelCore_ppc64le( | ||
| lldb_private::Thread &thread, | ||
| lldb_private::RegisterInfoInterface *register_info, | ||
| lldb::addr_t pcb_addr); | ||
|
|
||
| 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; | ||
|
|
||
| private: | ||
| lldb::addr_t m_pcb_addr; | ||
| }; | ||
|
|
||
| #endif // LLDB_SOURCE_PLUGINS_PROCESS_FREEBSDKERNEL_REGISTERCONTEXTFREEBSDKERNELCORE_PPC64LE_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
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.