[lldb-dev] Unifying source/Host (Mac/Linux/BSD)

Jay L. T. Cornwall jay at jcornwall.me.uk
Sat Sep 4 16:09:07 PDT 2010


Hi,

A couple of months ago LLDB had skeleton Linux support. The status of 
this port has degraded to unbuildable through flux in program interfaces 
and through changes to unnecessarily duplicated code.

This affects two main areas: source/Host and source/Plugins/Process.

To reverse this decline, and to begin extending support to the BSD 
family, I propose a restructuring of source/Host. It currently looks 
like this:

Host/linux/{Host.cpp,Symbols.cpp,TimeValue.cpp}
Host/macosx/{cfcpp,Host.mm,Symbols.cpp,TimeValue.cpp}
Host/posix/{Condition.cpp,Mutex.cpp}

Large pieces of code in Host.cpp/Host.mm were identical but have drifted 
with development on the Mac side. I propose:

Host/common/{Condition.cpp,Host.cpp,Mutex.cpp,Symbols.cpp,TimeValue.cpp}
Host/macosx/{cfcpp,Host.mm}

As much common code as possible is factored into Host.cpp, with Host.mm 
containing Obj C++ and cfcpp code. Preprocessor guards are used to 
insert platform-specific code into largely platform-independent 
functions. Factoring into API-specific directories (like POSIX, 4.4BSD, 
portable, etc.) became unwieldy when I tried it, to no real advantage.

I have a patch which implements this (~160KB, mostly moving functions 
around, so I didn't attach it but see [1]) for Mac OS X, Linux and 
FreeBSD. This patch is a prerequisite for other patches that I'm working 
on to restore and improve cross-platform functionality. Together these 
build LLDB with very limited functionality on all platforms.

Is this patch of interest, or would you be able to suggest a better way 
to begin tackling this problem?

Thanks,

[1] http://www.jcornwall.me.uk/temp/lldb-host-unify.patch
(requires manual SVN removal of dead files/directories if applied)

-- 
Jay L. T. Cornwall
http://www.jcornwall.me.uk/



More information about the lldb-dev mailing list