<div dir="ltr">Hey Zachary,<div><br></div><div>On this part:</div><div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">> 3) Make a HostThread instantiatable, non-static class, which represents a thread inside of a process on the Host OS. Move code from Host.cpp over there.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">We have a lower-level NativeThreadProtocol and NativeProcessProtocol concept that we're developing. They are low-level pieces that can be instantiated for supported platforms (currently Linux x86_64, soon others, including eventually Apple-specific when they go to llgs). Right now lldb-gdbserver (llgs) is the user of these. If we were going to keep local Linux debugging with ProcessLinux/ProcessMonitor, those would be rewritten in terms of NativeProcessProtocol/NativeThreadProtocol/NativeRegisterContext, but as it stands we'll be deprecating those when we have local Linux debugging through llgs running on all the Linux variants that the other approach currently supports.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Just wanted to mention this since it seems like there may be some cross-talk over that area you mentioned in #3.</div>
</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Note NativeThreadProtocol is a lower-level concept than Thread and likewise for NativeProcessProtocol and Process. Thread and Process intertwine with some heavier, higher-level lldb concepts like thread plans, public/private state, etc. The Native* classes are very low level and don't perform all the services that LLDB would use all by itself - it will build on top of that.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Right now the Native* classes only get used by llgs.</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">Greg might have more thoughts on this.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
-Todd</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 25, 2014 at 11:42 AM, Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I've had some questions (both privately and in responses to other messages on-list) about Host and HostInfo. So I'll explain here in hopes of answering for everyone.<div>
<br></div><div>First, the rationale: Host was getting too big and was starting to turn into something like "well, I need to call a platform-specific API, I'll make it a static method in Host.cpp". As the platform matrix grows, so does the complexity of managing this file. Second, there was no attempt in Host.cpp to group logically similar methods together in classes. There were filesystem methods, process spawning methods, thread manipulation methods, methods to query the value of various os magic numbers, etc. As I started thinking about what will need to happen to support various things on Windows, I imagined this file exploding in complexity. Even with HostWindows.cpp, you can see from looking at Host.cpp that it's not always possible or easy to separate platform-specific logic into the platform specific Host files.</div>
<div><br></div><div>So this refactor attempts to address all of these issues.</div><div><br></div><div>So far I've been focused on (and mostly completed) moving code from Host into two different classes: Filesystem and HostInfo. </div>
<div><br></div><div>HostInfo - answers queries about the operating system that LLDB is running on. Think of this class as being "const". It doesn't modify your OS. If you want to know how much memory is available, or the page size, or the path to lldb.exe, you ask HostInfo. Instead of #include "Host.h" and writing Host::method(), you #include "HostInfo.h" and write HostInfo::method(). When adding new methods, put your method in the least-derived class possible where it makes sense and will compile on all corresponding platforms. </div>
<div><br></div><div>The advantage to this approach is that </div><div>a) No matter what host OS you're on, you always have all the functionality of that host OS available to you through static binding (e.g. no casting to a derived type)</div>
<div>b) Almost zero pre-processor complexity</div><div><br></div><div>FileSystem - Has methods like MakeDirectory, RemoveDirectory, GetPermissions, etc. Where before you would #include "Host.h" and write Host::MakeDirectory(), now you #include "FileSystem.h" and write FileSystem::MakeDirectory(...).</div>
<div><br></div><div>Remaining work to be done:</div><div>1) Nuke DynamicLibrary and use LLVM's</div><div>2) Make a HostProcess instantiatable, non-static class, which represents a process which is running on the Host OS. Move code from Host.cpp over there.</div>
<div>3) Make a HostThread instantiatable, non-static class, which represents a thread inside of a process on the Host OS. Move code from Host.cpp over there.</div><div>4) Make a HostProcessLauncher class, of which derived implementations would be WindowsProcessLauncher, PosixSpawnProcessLauncher, XpcProcessLauncher, etc. Move code from Host.cpp over there.</div>
<div>5) Update Process plugins to use the appropriate HostProcessLauncher classes</div><div>6) Delete Host.cpp, as there will be no code left in it anymore.</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><br clear="all"><div><br></div>-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small">
<td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">tfiala@google.com</span></a> |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><font color="#1155cc"> <a>650-943-3180</a></font></td></tr></tbody></table><br></div>
</div>