This is an archive of the discontinued LLVM Phabricator instance.

Implement WindowsDYLD::DidAttach for querying the load address with a gdb-remote
ClosedPublic

Authored by lanza on Dec 4 2018, 4:56 PM.

Details

Reviewers
Hui
zturner
Summary
Windows lldb debugging currently uses a process plugin to handle
launching and attaching to a process. Launching a process via a debug
server (e.g. ds2) and attaching to it with `gdb-remote port` currently
doesn't communicate address information of the executable properly.

Implement DynamicLoaderWindowsDYLD::DidAttach to obtain the proper
address information.

Event Timeline

lanza created this revision.Dec 4 2018, 4:56 PM
lanza added a comment.Dec 4 2018, 5:42 PM

This fixes the broken patch from https://reviews.llvm.org/D54544

DynamicLoaderWindowsDYLD::DidLaunch is called right after ProcessWindows::DidLaunch in Process::Launch, so the previous patch was breaking the standard ProcessWindows pipeline for launching an inferior. DynamicLoaderWindowsDYLD::DidAttach is not called.

This patch's purpose is to fix debugging via

C:\> ds2 g 9021 C:\path\to\test.exe

// in another terminal
C:\> lldb C:\path\to\test.exe
(lldb) gdb-remote 9021

The code path used for attaching to a gdb-remote on Windows is the same as used on Linux & Darwin and thus DynamicLoaderWindowsDYLD::DidAttach gets called via Process::CompleteAttach but DynamicLoaderWindowsDYLD::DidLaunch does not get called.

So to fix the previous bug the logic was moved from DidLaunch to DidAttach.

However, a test for this change can't be added without modifying the python test suite to teach it how to check for availability of ds2 and then to test with it. I toyed around with that a bit but it would require quite a few changes to lldb/packages/Python/lldbsuite/test/tools/lldb-server to be Windows compatible or just building a bunch of new infrastructure. Though I do plan on integrating ds2 into the test-suite and possibly as a tool in lldb/tools to ease the test process at some point.

lanza updated this revision to Diff 176752.Dec 4 2018, 6:38 PM

Rewrite commit message

lanza retitled this revision from Implement basic DidAttach for DynamicLoaderWindowsDYLD for use with ds2 to Implement WindowsDYLD::DidAttach for querying the load address with a gdb-remote.Dec 4 2018, 6:41 PM
lanza edited the summary of this revision. (Show Details)
lanza added a comment.Dec 6 2018, 12:47 PM

@zturner I copied the win-py3-buildbot as best I could and found no regressions. Cool to land this?

zturner accepted this revision.Dec 6 2018, 1:10 PM

Looks good if the tests pass. If something comes up (fingers crossed) we can always revert again.

This revision is now accepted and ready to land.Dec 6 2018, 1:10 PM
lanza added a subscriber: davide.Dec 6 2018, 3:12 PM

@davide The review was here, not sure why this didn't get attached to the commit:

Landed in revision: https://llvm.org/svn/llvm-project/lldb/trunk@348526

lanza closed this revision.Dec 6 2018, 3:12 PM
davide added a comment.Dec 6 2018, 3:21 PM

@davide The review was here, not sure why this didn't get attached to the commit:

Landed in revision: https://llvm.org/svn/llvm-project/lldb/trunk@348526

Sure, thanks for the explanation, Nathan!