This commit implements basic DidAttach and DidLaunch for the windows
DynamicLoader plugin which allow us to load shared libraries from the
inferior.
This is an improved version of D12245 and should work much better.
Differential D39314
Implement basic DidAttach and DidLaunch for DynamicLoaderWindowsDYLD sas on Oct 25 2017, 6:19 PM. Authored by
Details
Diff Detail
Event TimelineComment Actions Wow. I didn't realize windows support didn't do any of this. Looks good. Zach will want to ok this as he is one of the main windows contributors. Comment Actions To be fully honest, I'm not 100% sure how I'm supposed to add tests for this. I looked through the directories containing unit tests and didn't find anything specific to DYLD testing. I'm going to try to sync with @zturner to see if he is still able to run unit tests on Windows. We exclusively debug Windows remotes from a macOS or Linux host, so I don't have any setup to run local windows tests. Comment Actions I understand. I'm not picking on you, of course, and I appreciate you trying to do that. Comment Actions Testing would include a test that dynamically loads a shared library and sets a breakpoint it in. We have these tests, but I am guessing they are disabled on windows probably because they might use "dlopen(...)" which is probably not available on windows? I know we have attach tests as well. Many tests are disabled on windows, but probably shouldn't be. So I would start looking for those tests. The code will need to be window-ized with #ifdefs and such, but it shouldn't be hard. The shared libraries tests will dynamically open a shared library and then verify we can hit a breakpoint in that shared library (a hint that the DYLD worked). So these tests don't need to be windows specific. Comment Actions A test would be something like this: // dll.cpp BOOL WINAPI DllMain(HINSTANCE h, DWORD reason, void* reserved) { return TRUE; } int __declspec(dllexport) DllFunc(int n) { int x = n * n; return x; // set breakpoint here } // main.cpp int __declspec(dllimport) DllFunc(int n); int main(int argc, char ** argv) { int x = DllFunc(4); int y = DllFunc(8); // set breakpoint here int z = DllFunc(16); return x + y + z; } Run main.exe in the debugger, when you're stopped at the breakpoint get the value of x and ensure that it's 4. Comment Actions Ahh, you might also run the exact same test again but where you've loaded this inside of main with LoadLibrary instead of relying on early binding by the loader. |