[lldb-dev] Why does Platform::DebugProcess always launch and then attach?

Greg Clayton gclayton at apple.com
Wed May 13 15:25:21 PDT 2015


The theory is to require platforms to implement the minimum number of functions. 

If you implement launch and attach, then you shouldn't need a third function to debug your process. 

This all hinges on your ability to stop your program at the entry point when the eLaunchFlagDebug launch flag is set. If you can do this, then you should be able to use launch followed by attach. If you can't do this, you will need to override the PlatformWindows::DebugProcess(...).

Greg

> On May 13, 2015, at 2:59 PM, Zachary Turner <zturner at google.com> wrote:
> 
> In particular this code:
> 
>     error = LaunchProcess (launch_info);
>     if (error.Success())
>     {
>         if (log)
>             log->Printf ("Platform::%s LaunchProcess() call succeeded (pid=%" PRIu64 ")", __FUNCTION__, launch_info.GetProcessID ());
>         if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID)
>         {
>             ProcessAttachInfo attach_info (launch_info);
>             process_sp = Attach (attach_info, debugger, target, error);
> 
> For Windows if you want to launch a program under the debugger the method you use launch to launch the process also does the attach at the same time.  Until recently, PlatformWindows::CanDebugProcess() had been returning false, so it was falling back to calling Process::DoLaunch(), which has been working fine.
> 
> I'm adding support for attaching to processes though, and this requires changing that function to return true.  So now both launches and attaches go through this path of launching first, and then attaching, which causes the launch codepath to break.
> 
> What is the correct way to handle this?  Could I add a method to Platform called SupportsAtomicLaunchAndAttach() that if true will just call Process::DoLaunch() directly, and if false will continue down the existing codepath?
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev





More information about the lldb-dev mailing list