-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[lldb] Properly handle locate module callback when Target change arch #143793
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
Conversation
|
@llvm/pr-subscribers-lldb Author: None (GeorgeHuyubo) ChangesSince this PR: #141670 We start to override the Platform/Arch for a target if needed. However we may have already registered locate module callback with the old platform. So this fix will just ensure to set the callback to the new platform object. Full diff: https://github.com/llvm/llvm-project/pull/143793.diff 1 Files Affected:
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 9660fc97970b0..45a9e1196a049 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1706,6 +1706,8 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, bool set_platform,
if (PlatformSP arch_platform_sp =
GetDebugger().GetPlatformList().GetOrCreate(other, {},
&platform_arch)) {
+ arch_platform_sp->SetLocateModuleCallback(
+ platform_sp->GetLocateModuleCallback());
SetPlatform(arch_platform_sp);
if (platform_arch.IsValid())
other = platform_arch;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me. Let's update the PR description to explain whenever Target changes architecture we mvoe any corresponding platform Module callback, because that wasn't really apparent to me from reading the summary.
…llvm#143793) Since this PR: llvm#141670 We started to override the Platform/Arch for a target if needed. However we may have already registered locate module callback with the old platform. This PR will move the locate module callback to the new Platform whenever Target changes architecture. Co-authored-by: George Hu <[email protected]>
| arch_platform_sp->SetLocateModuleCallback( | ||
| platform_sp->GetLocateModuleCallback()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This almost seems like the SetLocateModuleCallback should be on the target instead of on the platform. But this will work around the issue for sure.
…llvm#143793) Since this PR: llvm#141670 We started to override the Platform/Arch for a target if needed. However we may have already registered locate module callback with the old platform. This PR will move the locate module callback to the new Platform whenever Target changes architecture. Co-authored-by: George Hu <[email protected]>
Since this PR: #141670 We started to override the Platform/Arch for a target if needed. However we may have already registered locate module callback with the old platform.
This PR will move the locate module callback to the new Platform whenever Target changes architecture.