<div dir="ltr">I think this all sounds great Ashok.<div><br></div><div>> The main goal is to ensure a strict LLDB protocol when available while maintaining some level of support for the myriad of applications that implement the gdb-server protocol.<br>
<div class="gmail_extra"><br></div><div class="gmail_extra">We use gdbserver with valgrind. Super useful, and being able to connect with lldb would be fantastic.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
Looking forward to all this for all the other reasons too. Thanks!</div><div class="gmail_extra"> -Mike</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 27, 2013 at 1:46 PM, Thirumurthi, Ashok <span dir="ltr"><<a href="mailto:ashok.thirumurthi@intel.com" target="_blank">ashok.thirumurthi@intel.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="">A large task remains to re-factor LLDB to generalize remote and native local debugging. This refactoring has been suggested by Greg Clayton and here I’m summarizing the rationale and the high-level refactoring for comment. There are a
few goals:<u></u><u></u></p>
<p><u></u><span style="font-family:Symbol"><span>·<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span></span><u></u>Platform-independent remote debugging.<u></u><u></u></p>
<p><u></u><span style="font-family:Symbol"><span>·<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span></span><u></u>Same source code for tasks common to native local and remote debugging (i.e. related to process, threads and registers).
<u></u><u></u></p>
<p><u></u><span style="font-family:Symbol"><span>·<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span></span><u></u>Native local debugging that does not require packet preparation and parsing. The main goal is to ensure that the details of packet preparation and parsing don’t affect native local debugging. This keeps debug logs simple and
allows problems specific to packet handling to be diagnosed independently of generic issues.<u></u><u></u></p>
<p><u></u><span style="font-family:Symbol"><span>·<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span></span><u></u>Separation between the communication required to support gdb-server versus LLDB extensions. The main goal is to ensure a strict LLDB protocol when available while maintaining some level of support for the myriad of applications
that implement the gdb-server protocol.<u></u><u></u></p>
<p class=""><u></u> <u></u></p>
<p class="">So, the refactoring is aimed at replacing debugserver with a new binary that reuses functionality common to native local and remote debugging. Replacing debugserver is preferable since debugserver isn’t platform independent and it is a
mix of communication and process/thread/register smarts. In more detail:<u></u><u></u></p>
<p><u></u><span>1.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>New lldb-host library containing Host::Process and Host::Thread at the top level. This is a platform-independent service layer used for both native local and remote debugging. In general, the service layer implements basic tasks and
assumes that the caller has already established a valid context for the operation. For instance, when enumerating the threads for a process, it assumes that a process attach has completed. For this reason, this is not intended to be a low-level debugger
API for public consumption.<u></u><u></u></p>
<p style="margin-left:1in">
<u></u><span>a.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>Host::Process implements basic tasks like attach and thread enumeration.
<u></u><u></u></p>
<p style="margin-left:1in">
<u></u><span>b.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>Host::Thread implements basic tasks like manipulating the thread state and
<span style="color:rgb(31,73,125)">uses Host::RegisterContext to manipulate </span>the register set.<u></u><u></u></p>
<p style="margin-left:1in">
<u></u><span>c.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>This Host layer will delegate to platform-specific classes analogous to the POSIX ProcessMonitor. As a result, it will only maintain state when required for performance optimization. For instance, the register set could be cached to
service queries as long as the current frame has not changed.<u></u><u></u></p>
<p style="margin-left:1in">
<u></u><span>d.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>The functionality of the Host layer is analogous to the ‘C’ interface in DNB.h used by debugserver.
<u></u><u></u></p>
<p><u></u><span>2.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>New ProcessNative class derived from lldb::private::Process. This new Process plug-in will start off as a sibling for ProcessPOSIX but eventually replace
<span style="color:rgb(31,73,125)">derivatives</span> of lldb_private::Process used for native local and remote debugging with a single ProcessNative class whose implementation is delegated to Host::Process. This stateful class will represent per-process
<span style="color:rgb(31,73,125)">context </span>needed to implement the LLDB API.<u></u><u></u></p>
<p><u></u><span>3.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>New ThreadNative class derived from lldb::private::Thread. This new Thread plug-in will start off as a sibling for POSIXThread, but eventually replace
<span style="color:rgb(31,73,125)">derivatives</span> of lldb_private::Thread that are used for native local and remote debugging with a single ThreadNative class whose implementation is delegated to Host::Thread. This stateful class will represent per-thread
<span style="color:rgb(31,73,125)">context</span> needed to implement the LLDB API.<u></u><u></u></p>
<p><u></u><span>4.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>Improved GDBRemoteCommunicationServer class to implement the gdb-server protocol. This class, in development for lldb-platform, will be extended to handle as many packets as the current debugserver. For instance, packets related to
the register set. This class will use the new lldb-host library to implement remote debugging.<u></u><u></u></p>
<p><u></u><span>5.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>New LLDBRemoteCommunicationServer class (derived from GDBRemoteCommunicationServer) to implement the extensions to the gdb-server protocol required by lldb (i.e. for multi-threaded debugging). The goal here is to maintain compatibility
with applications that implement the gdb-server protocol with clear separation for extensions such as a proposed sequence number for packets (to avoid race conditions with asynchronous communications). The LLDBRemoteCommunicationServer will be a strict implementation
of LLDB extensions to the gdb-server protocol.<u></u><u></u></p>
<p><u></u><span>6.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>Reuse the GDBRemoteCommunicationClient class to prepare and parse packets as required to implement the LLDB command set. Again, the LLDBRemoteCommunicationClient will derive from and delegate most of its work to GDBRemoteCommunicationClient.<u></u><u></u></p>
<p><u></u><span>7.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>New tools/lldb-server applet to eventually replace debugserver across platforms. This application will use LLDB/GDBRemoteCommunicationServer classes for communication and an API in development for platform discovery (future SBPlatform).
Specifically, lldb-server can optionally use a platform API to simplify the remote launch, lldb-platform can be used independent of a debug target, and lldb-server will use the LLDB protocol (gdb-server protocol with extensions) by default.<u></u><u></u></p>
<p class=""><u></u> <u></u></p>
<p class="">Since the new classes can be implemented without impacting the current functionality, we propose doing this work in trunk. Note that Greg’s platform branch was recently merged. Cheers,<span class=""><font color="#888888"><u></u><u></u></font></span></p>
<span class=""><font color="#888888">
<p class=""><u></u> <u></u></p>
<p><u></u><span>-<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:'Times New Roman'">
</span></span><u></u>Ashok<u></u><u></u></p>
<p class=""><u></u> <u></u></p>
</font></span></div>
</div>
<br>_______________________________________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
<br></blockquote></div><br></div></div></div>