[lldb-dev] Supporting FreeBSD kernel debugging project

Greg Clayton gclayton at apple.com
Thu May 22 09:39:42 PDT 2014


Your project will be great! Below I will outline a few things to keep you on track:

Core file kernel debugging:
- You shouldn't have to do too much to the current ProcessELFCore except help it to locate hint address for the list of shared libraries and the main kernel file in memory. This is done in:

    virtual lldb::addr_t
    ProcessELFCore::GetImageInfoAddress ();

- Most of the work will be done in your DynamicLoader subclass that then uses the hint from the ProcessELFCore::GetImageInfoAddress() as to where the shared libraries are. This new DynamicLoader subclass will be used for both live kernel debugging and for Core file debugging and should be able to track down all kernel extensions that are loaded.

Live kernel debugging:
- You will make a new process subclass like you were saying unless the GDB remote protocol is used to talk to the kernel?
- You should re-use your dynamic loader from the Core file step here

Extra credit:
- Get threads that are context switched in memory to show up. In the MacOSX kernel debugger we have the notion of 1 core we can talk to through the KDP interface which is the code that runs the debugger. There are tons of threads in the kernel that are sitting in memory. We have a python plugin that will supply a list of memory threads back to lldb. So even though the kernel debug interface only supports N cores, we might also be able to show M number of memory threads and see their backtraces, registers, etc. The MacOSX kernel implements this using python code that can use kernel globals to get the list of in memory threads and create them on the fly. There is a very simple example of this in:

svn cat http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/operating_system.py

Let us know if you have any questions as far as implementation and architecture goes. The MacOSX kernel process subclass does things correctly so keep an eye on that plug-in when you have questions or need guidance.

Greg Clayton


> On May 22, 2014, at 2:03 AM, Mike Ma <mikemandarine at gmail.com> wrote:
> 
> Hi there,
> 
> I'm a google summer of code student this year, on FreeBSD part.
> 
> And I'm writing to introduce my project, we are aiming to support kernel debugging on FreeBSD for LLDB.
> Ed Maste (emaste at freebsd.org) is my mentor for this project, I'll be working closely with him.
> 
> Here is the project page:
> https://wiki.freebsd.org/SummerOfCode2014/LLDB_KernelDebugging
> 
> This is my LLDB fork:
> https://github.com/cosql/lldb
> 
> Any comments are more than welcome. 
> 
> -- 
> Cheers,
> Mike
> _______________________________________________
> 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