[cfe-dev] [RFC] New ClangDebuggerSupport Library

Sean Callanan via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 16 14:09:46 PST 2016


Better join this thread late than never.

I have a testing tool under development (up for preliminary review in the next few days!) that would use the functionality you propose.  The tool parses expressions that have references to external types, does some user-configurable logging, and optionally emits the resulting LLVM IR.  It is intended to provide better coverage for ExternalASTSource and ASTImporter, and to generate more representative uses of the code paths that LLDB exercises.  Once it is cleaned up and works the way we want it to, the heart of it ("Parse expression E with respect to DeclContexts D1, D2, D3, ... in ASTContexts A1, A2, A3, ...") would be very much at home in a library like the one you describe.

Currently the testing tool is intended to generate external types by feeding source files to separate CompilerInstances.  It then uses the ExternalASTSource and ASTImporter to pull them in as necessary to the main expression's ASTContext.  If your functionality can provide a pair of [ASTContext, FileManager] (so that source locations could actually come from files!) then those could just be plugged into my tool, no problem.  I could see the DWARF->AST function and the (Expression, [AST]) -> IR function acting as "eval" for Clang, allowing Clang to provide embedded expression parsing functionality independent of LLDB.  We'd also need to figure out how to JIT the IR in a way that makes it actually access the variables where they are in the target program.  That's a problem I intend to tackle in the future.

LLDB could then adopt all of these functions as a client, and the interface to LLDB would be – as you've mentioned – significantly simplified.  I see a bigger benefit to Clang's clients, though: this provides the beginnings of a more dynamic compilation model, allowing both new runtime features and separate analysis tools.

Sean

> On Nov 9, 2016, at 2:26 PM, Chris Bieneman via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> Hello cfe-dev,
> 
> I would like to propose a new Clang library for implementing functionality that is used by LLDB. I see this as the first step in a long process of refactoring the language interfaces for LLDB.
> 
> The short-term goal is for this library is to be a place for us to rebuild functionality that exists in LLDB today and relies heavily on the implementation of Clang. As we rebuild the functionality we will build a suite of testing tools in Clang that exercise this library and more general Clang functionality in the same ways that LLDB will. 
> 
> As bits of functionality become fully implemented and tested, we will migrate LLDB to using the Clang implementations, allowing LLDB to remove its own copies. This will provide the Clang community with a higher confidence that changes in Clang do not break LLDB, and it will provide LLDB with better test coverage of the Clang functionality.
> 
> The long-term goal of this library is to provide the implementation for what could some day become a defined debugger<->frontend interface for providing modularized (maybe even plugin-based) language debugging support in LLDB. In the distant future I could see us being able to tell people building new frontends that we have a defined interface they need to implement for the debugger, and once implemented the debugger should “Just Work”.
> 
> The first bit of functionality that I would like to build up into the ClangDebuggerSupport library is materialization of Clang AST types from DWARF. To support this development I intend to add a new tool in Clang that reads DWARF types, generates a Clang AST, and prints the AST. I will also add DWARF support to obj2yaml and yaml2obj, so we will be able to write YAML LIT tests for the functionality.
> 
> If people are in favor of this general approach I’ll begin working in this direction, and I’ll probably add the new library sometime next month.
> 
> Thoughts?
> -Chris
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list