[lldb-dev] Native windows debugging support

jingham at apple.com jingham at apple.com
Wed Jul 2 16:36:06 PDT 2014


One thing to keep in mind is that the same lldb session could be simultaneously debugging a MacOS app, and a Windows app.  So if you have command options that differ based on the platform (for example), then those will switch as the user switches from one target to another.  If you want to tailor options to platforms it can't be static, it will have to be determined based on the currently selected platform.  As an aside, for sanities sake if we should really try not to overlap option shortnames for different things on the different platforms.

Then the way command objects work is that their options are baked into the object handed to the command interpreter when they are added to the interpreter.  There's one command object for a given command name registered at startup.  I'm not sure how excited I am about swapping these things in and out as the currently selected Platform/Target/Process changes.  For instance, if you could very well be running a command for with TargetA currently selected in the main lldb interpreter, and at the same time the process in TargetB could hit a breakpoint and want to run some commands for its breakpoint action...  It would be a pain to juggle that sort of thing...  It would be much simpler to keep all the options in one command object, and have the context in which the command is running determine the validity of the commands options.

OTOH, it would not be too hard to add "option validators" that would ask an execution context to vote yea or nay on an option, and then the generic interpreter command argument parsing could consult this and reject currently invalid options.  The commands do get invoked with an execution context so all the right information would be there.  Or we might go the static route and mark the option table with what platform/target/process they support, though we'd have to be careful not to make the option tables annoying to read and maintain.  Also we would have to do something like this because the help text is currently auto-generated from the command objects, and you'd need to mark currently invalid options in the help text output.

Jim


> On Jul 2, 2014, at 3:51 PM, Zachary Turner <zturner at google.com> wrote:
> 
> I'm not sure why I didn't get the original email from Greg here (?)  I'm only seeing this copied in Todd's response.
> 
> In any case, Windows' concept of a user id and group id is a Security Identifier, as Todd mentioned (usually called a SID).  Generally though I don't think it's necessary to pass around the SID, because the target can figure out the SID given a username.
> 
> Still, it feels a little awkward having a single class store everything that might be needed for any platform.  Normally I'd expect to use polymorphic types in this scenario.  A NativeProcessLinux, for example, could freely cast a UserId to a PosixUserId, and a NativeWindowsProcess could cast a UserId to a WindowsUserId.
> 
> There's also the issue of command options, as I mentioned in the response to Jim.  Basically, "platform process list" doesn't even need a -U option on Windows.  Or maybe even a stronger statement, it shouldn't have a -U option.  It's easy to come up with scenarios where platforms differ significantly enough that the same set of options don't even make sense, or where a certain platform provides sets of functionality not available on other platforms.  For those cases, it would be nice for the debugger commands to be tailored to that specific platform.
> 
> So maybe my first task should be to work on the command options system a little bit to enable this type of abstraction.  Thoughts?
> 
> 
> On Wed, Jul 2, 2014 at 3:44 PM, Todd Fiala <tfiala at google.com> wrote:
> We'll probably end up needing to support something like this:
> https://en.wikipedia.org/wiki/Security_Identifier
> 
> Most of the access control on Windows ends up revolving around those.
> 
> 
> On Wed, Jul 2, 2014 at 3:37 PM, Greg Clayton <gclayton at apple.com> wrote:
> 
> > On Jul 2, 2014, at 2:52 PM, Zachary Turner <zturner at google.com> wrote:
> >
> > I've started experimenting with adding support to LLDB for debugging native Windows executables on Windows.  So windows host, windows target.  I've done a few little cleanup tasks here and there and fixed some low-hanging fruit, and I'd like to move onto something more meaty.
> >
> > I took a look at what it would take to get "platform process list" to work.  The first thing I notice is that all of the Process info objects contain the notion of a UID and GID, a concept which doesn't really exist on Windows.  An analagous concept exists, but it's represented completely differently.
> >
> > My question is: How best to abstract out this functionality?  I'm still not totally clear on where I'm allowed to use platform specific types / APIs and where it needs to be platform agnostic.  My first thought is to remove UID and GID from the ProcessInfo class, and replace them with a instance a "ProcessUserId" class, then provide a PosixProcessUserId and a WindowsProcessUserId, which abstracts away the differences.
> >
> > Assuming this approach is logical, where is the best place for this code to go?  Host or Target?
> >
> > Anything else I should be aware of?
> 
> Can we just make a UserID class and GroupID class which contains both an integer and a string (and anything else that is required) and use that? What does windows have as far as UID and GID goes? Will strings suffice? Does it need more? As you can tell we are very unix centric right now, but we do want to abstract. So I would go the route of making a UserID and a GroupID class, everyone uses these classes and these classes need to be able to store everything that all of our classes require. My simple guess would be:
> 
> class UserID {
>    std::string m_name;
>    lldb::user_id_t m_identifier;
> };
> 
> Same for kind of thing for GroupID.
> 
> Greg
> 
> 
> 
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
> 
> 
> 
> -- 
> Todd Fiala |	 Software Engineer |	 tfiala at google.com |	 650-943-3180
> 
> 
> _______________________________________________
> 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