<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Aug 29, 2014 at 9:54 AM, <span dir="ltr"><<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class=""><br></div>
> SystemLog<br>
> ThreadDetach<br>
> ThreadCancel<br>
<br>
There must be some way on Windows to tell a thread to exit at the next cancellation point? Can you really not cancel a worker thread's operation?<br></blockquote><div> </div><div>Not an arbitrary thread, no. You can forcefully terminate it (with caveats, and it may not work and/or have unexpected behavior, so it is strongly discouraged), but generally if you want to gracefully cancel a thread, the thread has to have specific code in its run loop to make that possible. So it might work for threads that we create inside the lldb process, since we control the thread routine, but it wouldn't be meaningful for threads in other process. The reason for this discrepancy is that there is no concept of signals on Windows, which I assume is how thread cancellation is implemented behind the scenes on posix platforms.</div>
<div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class=""><br>
> GetAuxvData<br>
><br>
> Before my original HostInfo refactor, it also had these methods:<br>
><br>
> GetUserID<br>
> GetGroupID<br>
> GetEffectiveUserID<br>
> GetEffectiveGroupID<br>
><br>
> Those methods were just as accessible to anyone writing generic code. They are *less* accessible now, because they are on HostInfoPosix. And this happened without needing to introduce any platform specific pre-processor defines into generic LLDB. There was maybe one exception, which Jason Molenda pointed out earlier, which was the GetOSBuildString. And that only happened because GetOSBuildString is not a generic concept! The design worked exactly as intended, exposing a place where code that was intended to be generic actually wasn't as generic as it thought it was. Everywhere else, the GetUserID, GetGroupID, etc methods were only being called from specific code (which is how it should work), but after my change this is now enforced by the compiler.<br>
><br>
><br>
<br>
</div>But again, if I'm writing code it seems like a real pain to have to answer the question "is this an interface I can use in generic code" be:<br>
<br>
For now you can if it exists in all the HostThreadXXX.h files, but of course if somebody introduces another platform and decides that they don't want to implement this function then you can't use it anymore and have to put<br>
<br>
#if defined<br>
<br>
guards around the usage. Instead, we should look at the host interfaces and say there are three classes of things:<br>
<br>
1) Things you must implement in order to port lldb to a host<br>
These should be pure virtual methods in HostFeature.h<br>
2) Things you can optionally implement, but there's a reasonable "couldn't do that" fallback<br>
These should be virtual methods in HostFeature.h<br>
3) Things that are purely host specific.<br>
These should be methods in HostFeatureMyHost.h, and can only be used in HostOtherFeatureMyHost.h, but never in generic code.<br>
<br>
This would make the job of folks working in generic code clear, and also make it obvious to the next porter (OpenVMS, anyone?) what they have to do.<br></blockquote><div><br></div><div>I'm ok with doing all of this. I'm all for having the compiler catch things for you, and if one of the things it can catch for you is "you need to implement this method" then that's great. That said, I'm still rather fond of the idea of typedefing HostFeature to HostFeatureMyHost and then having everyone use HostFeature. No matter if you do it or don't, it's still equally easy to write specific code from generic code. You could just do this:</div>
<div><br></div><div>#if defined(__APPLE__)</div><div>((HostFeatureMacOSX&)feature).AppleSpecificMethod();</div><div>#endif</div><div><br></div><div>as opposed to this</div><div><br></div><div>#if defined(__APPLE__)</div>
<div>feature.AppleSpecificMethod();</div><div>#endif</div><div><br></div><div>In both cases though, the person has felt strongly enough about it to put it in a pre-processor guard, so the decision has already been made. And the second method has the benefit that when you're writing specific code (which I anticipate to write alot of for Windows), you just always have the type you need.</div>
</div></div></div>