Skip to content

Commit 8dbe2fc

Browse files
George Hukusmour
authored andcommitted
Bug fix, reload modules before getting thread local storage
Summary: Debugged locally with 2 scenario: * Load core only, and then auto-load-debuginfo, then can reproduce the error: ``` (lldb) target var HPHP::s_stackSize (size_t) HPHP::s_stackSize = <No TLS data currently exists for this thread.> ``` * Load core with executable manually, thread local variable is able to be show: ``` (lldb) target var HPHP::s_stackSize (size_t) HPHP::s_stackSize = 0 ``` The root cause is that the [link_map](https://www.internalfb.com/code/osmeta-external-llvm-project/[toolchain%2Fllvm-sand%2Fmain%3A55d44adeadd8500af2335ac99a9b10d1414f47e4]/lldb/source/Plugins/DynamicLoader/ModuleList-DYLD/DynamicLoaderDumpWithModuleList.cpp?lines=284) in the first scenario was 0. Because when the target was created, [DYLDRenzdevous can not be resolved](https://www.internalfb.com/code/osmeta-external-llvm-project/[toolchain%2Fllvm-sand%2Fmain%3A55d44adeadd8500af2335ac99a9b10d1414f47e4]/lldb/source/Plugins/DynamicLoader/ModuleList-DYLD/DynamicLoaderDumpWithModuleList.cpp?lines=120) because of lacking main executable. After auto-load-debuginfo, even we called target module replace, we never have a chance to call DYLDRenzdevous again to resolve and update link map address. So calling DidAttach() if m_rendezvous is not valid at the very beginning of GetThreadLocalData function is the easiest fix, to have a chance to update the link_map_addr in m_loaded_modules after we have the executable object file replaced by the auto-load-debuginfo command. Test Plan: Before this diff: ``` (lldb) target create --core "k9vc79dn9h6pe2y9" Core file '/home/hyubo/test/k9vc79dn9h6pe2y9' (x86_64) was loaded. (lldb) auto-load-debuginfo ... (lldb) target var HPHP::s_stackSize (size_t) HPHP::s_stackSize = <No TLS data currently exists for this thread.> ``` After this diff: ``` (lldb) target create --core "k9vc79dn9h6pe2y9" Core file '/home/hyubo/test/k9vc79dn9h6pe2y9' (x86_64) was loaded. (lldb) auto-load-debuginfo ... (lldb) target var HPHP::s_stackSize (size_t) HPHP::s_stackSize = 0 ``` Reviewers: jeffreytan, gclayton, #lldb_team Reviewed By: jeffreytan Subscribers: michristensen, #lldb_team Differential Revision: https://phabricator.intern.facebook.com/D56793922 Tasks: T186207554 Tags: accept2ship
1 parent 6740d00 commit 8dbe2fc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lldb/source/Commands/CommandObjectTarget.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "lldb/Symbol/UnwindPlan.h"
4343
#include "lldb/Symbol/VariableList.h"
4444
#include "lldb/Target/ABI.h"
45+
#include "lldb/Target/DynamicLoader.h"
4546
#include "lldb/Target/Process.h"
4647
#include "lldb/Target/RegisterContext.h"
4748
#include "lldb/Target/SectionLoadList.h"
@@ -2943,8 +2944,14 @@ class CommandObjectTargetModulesReplace : public CommandObjectParsed {
29432944

29442945
if (flush) {
29452946
ProcessSP process = target.GetProcessSP();
2946-
if (process)
2947+
if (process) {
29472948
process->Flush();
2949+
// DYLD rendezvous might not be resolved, try to load all modules again
2950+
// as we might have main executable replaced.
2951+
DynamicLoader *dyld = process->GetDynamicLoader();
2952+
if (dyld)
2953+
dyld->DidAttach();
2954+
}
29482955
}
29492956
return;
29502957
}

0 commit comments

Comments
 (0)