[lldb][Process/FreeBSDKernelCore] Rework DoLoadCore()#186626
Open
[lldb][Process/FreeBSDKernelCore] Rework DoLoadCore()#186626
Conversation
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
Member
|
@llvm/pr-subscribers-lldb Author: Minsoo Choo (mchoo7) ChangesCurrently Full diff: https://github.com/llvm/llvm-project/pull/186626.diff 2 Files Affected:
diff --git a/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/ProcessFreeBSDKernelCore.cpp b/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/ProcessFreeBSDKernelCore.cpp
index d1a4a1ebc47d7..ad94c86e5499a 100644
--- a/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/ProcessFreeBSDKernelCore.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/ProcessFreeBSDKernelCore.cpp
@@ -62,9 +62,8 @@ static PluginProperties &GetGlobalPluginProperties() {
ProcessFreeBSDKernelCore::ProcessFreeBSDKernelCore(lldb::TargetSP target_sp,
ListenerSP listener_sp,
- kvm_t *kvm,
const FileSpec &core_file)
- : PostMortemProcess(target_sp, listener_sp, core_file), m_kvm(kvm) {}
+ : PostMortemProcess(target_sp, listener_sp, core_file) {}
ProcessFreeBSDKernelCore::~ProcessFreeBSDKernelCore() {
if (m_kvm)
@@ -79,9 +78,11 @@ lldb::ProcessSP ProcessFreeBSDKernelCore::CreateInstance(
kvm_t *kvm =
kvm_open2(executable->GetFileSpec().GetPath().c_str(),
crash_file->GetPath().c_str(), O_RDONLY, nullptr, nullptr);
- if (kvm)
+ if (kvm) {
+ kvm_close(kvm);
return std::make_shared<ProcessFreeBSDKernelCore>(target_sp, listener_sp,
- kvm, *crash_file);
+ *crash_file);
+ }
}
return nullptr;
}
@@ -113,7 +114,21 @@ bool ProcessFreeBSDKernelCore::CanDebug(lldb::TargetSP target_sp,
}
Status ProcessFreeBSDKernelCore::DoLoadCore() {
- // The core is already loaded by CreateInstance().
+ ModuleSP executable = GetTarget().GetExecutableModule();
+ if (!executable)
+ return Status::FromErrorString(
+ "ProcessFreeBSDKernelCore: no executable module set on target");
+
+ m_kvm = kvm_open2(executable->GetFileSpec().GetPath().c_str(),
+ GetCoreFile().GetPath().c_str(), O_RDWR, nullptr, nullptr);
+
+ if (!m_kvm)
+ return Status::FromErrorStringWithFormat(
+ "ProcessFreeBSDKernelCore: kvm_open2 failed for core '%s' "
+ "with kernel '%s'",
+ GetCoreFile().GetPath().c_str(),
+ executable->GetFileSpec().GetPath().c_str());
+
SetKernelDisplacement();
return Status();
diff --git a/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/ProcessFreeBSDKernelCore.h b/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/ProcessFreeBSDKernelCore.h
index d82e55ea74bd9..77cb747fc95c1 100644
--- a/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/ProcessFreeBSDKernelCore.h
+++ b/lldb/source/Plugins/Process/FreeBSD-Kernel-Core/ProcessFreeBSDKernelCore.h
@@ -17,7 +17,7 @@
class ProcessFreeBSDKernelCore : public lldb_private::PostMortemProcess {
public:
ProcessFreeBSDKernelCore(lldb::TargetSP target_sp, lldb::ListenerSP listener,
- kvm_t *kvm, const lldb_private::FileSpec &core_file);
+ const lldb_private::FileSpec &core_file);
~ProcessFreeBSDKernelCore();
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently
ProcessFreeBSDKernelCoreis initialized and loads core at the same time by invokingkvm_open2()only once. But to implement minidump2elf based variant which inherits fromProcessElfCore, detecting and loading core file should be handled separately. Thus separate initialization and core load although the outcome is the same.