<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I don’t think we are disagreeing, probably I was just being a little too terse.  What I’m saying is that to PRESENT a mutex in some detail, we need an OS specific data formatter, so in that case, we just need some agent, either the Platform or the SystemRuntime (but the Platform seems better to me for this) to provide the OS specific data formatters.  But we don’t need a new facility for that, just a way to dial up the right OS-specific instances.  And if we can reuse more general features to present this sort of OS specific info we are better off; it reduces lldb’s surface area and provides facilities we might find other neat ways to use.<div class=""><br class=""></div><div class="">OTOH, for a runtime feature like “Gather all the mutexes currently in flight” we would need some new code.  There’s nothing in lldb that does that sort of job.  The SystemRuntime seems like the right place for that code to go.<div class=""><br class=""></div><div class="">Jim</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 1, 2018, at 1:25 AM, Alexander Polyakov <<a href="mailto:polyakov.alx@gmail.com" class="">polyakov.alx@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family: arial, helvetica, sans-serif; font-size: small;">I'm new in plugin ecosystem, so I have some misunderstanding. You wrote that to comprehend mutexes we just need a data formatter, but how can we get the raw data of all mutexes in our OS? I thought I was supposed to write a generic code that will use a user-defined (specific for each OS) way to collect all mutexes and then use some data formatter to show them.</div></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Nov 1, 2018 at 2:31 AM Jim Ingham <<a href="mailto:jingham@apple.com" target="_blank" class="">jingham@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">As Jason pointed out, we also have the SystemRuntime Plugin.  That is intended to provide extra runtime available information based on the current system.  For instance, on Darwin we use it to present the libdispatch queue view of threads on the system, and to decorate threads that are doing work on behalf of some queue with the state of the thread that enqueued the work at the time the work  item was enqueued.<br class="">
<br class="">
If for instance you had a way to gather all the locks in the process (something we've been asked to do but I don't know how to do it on Darwin...), that would be the place to put that functionality.<br class="">
<br class="">
Jim<br class="">
<br class="">
<br class="">
> On Oct 31, 2018, at 4:05 PM, Jim Ingham via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" target="_blank" class="">lldb-dev@lists.llvm.org</a>> wrote:<br class="">
> <br class="">
> Right now, the OS plugin only supports the job of adding threads.  And that makes more sense as a plugin, because for instance if you had a cooperative threading scheme that you were laying on top of the system threads in a User Space process, you can use the Operating System plugin to show you the cooperative threads.  This is not an abstract example...  I think it should stay with just that job.<br class="">
> <br class="">
> The place where lldb holds this sort of knowledge is supposed to be in the Platform class.  So for instance, to comprehend mutexes you really just need a data formatter.  The trick is that it has to be a data formatter that is provided by the platform.  Similarly you want to have frame recognizers for interesting lower-level calls in the system.  The machinery will shortly be there to do that, but loading the particular recognizers will either need to be done by hand, or coordinated by the Platform.  In general, I think most of the kinds of re-presentation you need to do to make OS objects and processes more comprehensible can be built as general mechanisms like the above.  Then the Platform can coordinate providing the set of more general transformations that are appropriate to the Platform you are targeting.<br class="">
> <br class="">
> Jim<br class="">
> <br class="">
> <br class="">
> <br class="">
>> On Oct 31, 2018, at 3:44 PM, Alexander Polyakov <<a href="mailto:polyakov.alx@gmail.com" target="_blank" class="">polyakov.alx@gmail.com</a>> wrote:<br class="">
>> <br class="">
>> So, if I understand you write, I can look at OS plugin and add a support of mutexes or memory pages for example?<br class="">
>> <br class="">
>> чт, 1 нояб. 2018 г. в 1:05, Jim Ingham <<a href="mailto:jingham@apple.com" target="_blank" class="">jingham@apple.com</a>>:<br class="">
>> lldb has one feature - the "Operating System Plugin" that is specifically designed for debugging threads in kernel contexts.  The OS plugin allows a kernel to present it's notion of threads into lldb_private::Threads.  The xnu kernel macros have an implementation of this, as do some other embedded OS'es.  lldb actually gets used pretty extensively for debugging xnu - the Darwin kernel.<br class="">
>> <br class="">
>> Kuba is adding the notion of "Frame recognizers" which can give significance to particular functions when they appear on the stack (for instance displaying the first argument of read, etc. as a file handle even if you have no debug information for it.)  That's another way that you could express your understanding of the OS you are running on for debugger users.  Greg wrote a data formatter for the Darwin implementation of pthread_mutex that shows the thread that has the lock and some other information like that.  So data formatters are also a way lldb can express knowledge of the host OS.<br class="">
>> <br class="">
>> Jim<br class="">
>> <br class="">
>>> On Oct 31, 2018, at 12:52 PM, Leonard Mosescu via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" target="_blank" class="">lldb-dev@lists.llvm.org</a>> wrote:<br class="">
>>> <br class="">
>>> Conceptually it's different levels of abstraction: a user-mode debugger handles processes, threads as first class concepts. In kernel-mode (or kernel land), these are just data structures that the code (the kernel) is managing. From a more pragmatic perspective, the difference is in where the debugging hooks are implemented and what interfaces are exposed (for example a kernel mode debugger can normally "poke" around any piece of memory and it has to be aware of things like VA mappings, while a user-mode debugger is only allowed to control a limited slice of the system - ex. control a sub-process through something like ptrace)<br class="">
>>> <br class="">
>>> Unless you're specifically looking at kernel debugging I'd stay away from that. For one thing, LLDB is mostly used as an user-mode debugger so the impact of any improvements would be bigger.<br class="">
>>> <br class="">
>>> Regarding the value of OS-awareness for user-mode debugging, I agree with Zach - for example windbg provides both kernel mode and user mode !locks commands. The only suggestion I'd add is to consider an expanded view of the "OS" to include runtime components which may not be technically part of what most people think of as the "OS": user-mode loaders and high level things like std::mutex, etc.<br class="">
>>> <br class="">
>>> On Wed, Oct 31, 2018 at 12:29 PM, Alexander Polyakov <<a href="mailto:polyakov.alx@gmail.com" target="_blank" class="">polyakov.alx@gmail.com</a>> wrote:<br class="">
>>> Looks like I don't completely understand what is the difference between user-mode and kernel-mode from the debugger's point of view. Could you please explain me this?<br class="">
>>> <br class="">
>>> On Wed, Oct 31, 2018 at 10:22 PM Zachary Turner <<a href="mailto:zturner@google.com" target="_blank" class="">zturner@google.com</a>> wrote:<br class="">
>>> I don’t totally agree with this. I think there are a lot of useful os awareness tasks in user mode. For example, you’re debugging a deadlock and want to understand the state of other mutexes, who owns them, etc. or you want to examine open file descriptors. In the case of a heap corruption you may wish to study the internal structures of your process’s heap, or even lower level, the os virtual memory page table structures.<br class="">
>>> <br class="">
>>> There’s quite a lot you can still do in user mode, but definitely there is more in kernel mode. As Leonard said, try put WinDbg as a lot of this stuff already exists so it’s a good reference <br class="">
>>> On Wed, Oct 31, 2018 at 12:08 PM Alexander Polyakov via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" target="_blank" class="">lldb-dev@lists.llvm.org</a>> wrote:<br class="">
>>> Hi Leonard,<br class="">
>>> <br class="">
>>> I think it will be kernel-mode debugging since debugging an application in user mode is not an OS awareness imo. Of course, some of kernel's modules might run in user-mode, but it will be ok I think.<br class="">
>>> <br class="">
>>> Thanks for your reference, I'll take a look at it. <br class="">
>>> <br class="">
>>> Also, I found out that ARM supports OS awareness in their DS-5 debugger. They have a mechanism for adding new operating systems. All you need to do is to describe OS' model (thread's or task's structure for example). I think that is how it might be done in LLDB.<br class="">
>>> <br class="">
>>> On Wed, Oct 31, 2018 at 9:26 PM Leonard Mosescu <<a href="mailto:mosescu@google.com" target="_blank" class="">mosescu@google.com</a>> wrote:<br class="">
>>> Hi Alexander, are you interested in user-mode, kernel-mode debugging or both?<br class="">
>>> <br class="">
>>> Fore reference, the current state of the art regarding OS-awareness debugging is debugging tools for windows (windbg & co.). This is not surprising since the tools were developed alongside Windows. Obviously they are specific to Windows, but it's good example of how the OS-awareness might look like.<br class="">
>>> <br class="">
>>> <br class="">
>>> On Mon, Oct 29, 2018 at 11:37 AM, Alexander Polyakov via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" target="_blank" class="">lldb-dev@lists.llvm.org</a>> wrote:<br class="">
>>> Hi lldb-dev,<br class="">
>>> <br class="">
>>> I'm a senior student at Saint Petersburg State University. The one of my possible diploma themes is "OS Awareness in LLDB". Generally, the OS awareness extends a debugger to provide a representation of the OS threads - or tasks - and other relevant data structures, typically semaphores, mutexes, or queues.<br class="">
>>> <br class="">
>>> I want to ask the community if OS awareness is interesting for LLDB users and developers? The main goal is to create some base on top of LLDB that can be extended to support awareness for different operating systems.<br class="">
>>> <br class="">
>>> Also, if you have a good article or other useful information about OS awareness, please share it with me.<br class="">
>>> <br class="">
>>> Thanks in advance!<br class="">
>>> <br class="">
>>> -- <br class="">
>>> Alexander<br class="">
>>> <br class="">
>>> _______________________________________________<br class="">
>>> lldb-dev mailing list<br class="">
>>> <a href="mailto:lldb-dev@lists.llvm.org" target="_blank" class="">lldb-dev@lists.llvm.org</a><br class="">
>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br class="">
>>> <br class="">
>>> <br class="">
>>> <br class="">
>>> <br class="">
>>> -- <br class="">
>>> Alexander<br class="">
>>> _______________________________________________<br class="">
>>> lldb-dev mailing list<br class="">
>>> <a href="mailto:lldb-dev@lists.llvm.org" target="_blank" class="">lldb-dev@lists.llvm.org</a><br class="">
>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br class="">
>>> <br class="">
>>> <br class="">
>>> -- <br class="">
>>> Alexander<br class="">
>>> <br class="">
>>> _______________________________________________<br class="">
>>> lldb-dev mailing list<br class="">
>>> <a href="mailto:lldb-dev@lists.llvm.org" target="_blank" class="">lldb-dev@lists.llvm.org</a><br class="">
>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br class="">
>> <br class="">
>> -- <br class="">
>> Alexander<br class="">
> <br class="">
> _______________________________________________<br class="">
> lldb-dev mailing list<br class="">
> <a href="mailto:lldb-dev@lists.llvm.org" target="_blank" class="">lldb-dev@lists.llvm.org</a><br class="">
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br class="">
<br class="">
</blockquote></div><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class="m_-3822131140158443250m_4515085222203841033gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><span style="font-family: arial, helvetica, sans-serif; font-size: 12.8px;" class="">Alexander</span><br class=""></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div></blockquote></div><br class=""></div></div></body></html>