<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 1, 2014 at 11:06 PM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><br>
On Apr 1, 2014, at 12:34 PM, Eran Ifrah <<a href="mailto:eran.ifrah@gmail.com">eran.ifrah@gmail.com</a>> wrote:<br>
<br>
> Thanks. I decided to debug it and see where it fails. So I built liblldb.3.5.0.dylib in debug mode and debugged the Launch function...<br>
><br>
> It turns out that it requires the debugserver and it assumes that it exists under LLDB.framework/<br>
> however, I have no such directory within my cmake build :P<br>
><br>
> Now, "my" debugserver executable terminates immediately after execution:<br>
><br>
> $debugserver<br>
> killed: 9<br>
> $<br>
> Running it under the debugger shows nothing significant (I will try to dig into this later also...)<br>
><br>
> However, if set this environment variable ( which I learnt about while debugging ) within codelite:<br>
> LLDB_DEBUGSERVER_PATH=/Path/To/CommandLineTools/PrivateFrameworks/LLDB.framework/Resources/debugserver<br>
><br>
> The process launches successfully and I get a valid process ID (Hooray!)<br>
><br>
><br>
> So a question to you guys:<br>
> How do I create a framework out of the build?<br>
<br>
</div>Don't use cmake, use xcodebuild:<br>
<br>
svn co ...<br>
cd lldb<br>
xcodebuild -configuration Release<br>
<br></blockquote><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">I tried building it from the GUI as described by your build.html page (selected the proper schema lldb-tool) and hit build</div>

<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">However, it fails during the checkout phase (it is sometimes happens, when svn aborts.. simple svn cleanup & svn up fixes this)</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">

</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Then in the build results will be in "./build/Release" and all needed executables will be in "./build/Release/LLDB.framework". The rpath for things linking against LLDB.framework is set be "@rpath/LLDB.framework/LLDB". So you will need to modify the LLDB plug-in that loads LLDB.framework to have a relative path to the LLDB.framework using linker flags ("Other Linker Flags" in your plug-in build, or "OTHER_LDFLAGS")<br>


<br></blockquote><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">The process I used is similar to how I distribute codelite: I copy the plugin at the end of the build process into their (LLDBDebugger.dylib + liblldb.3.5.0.dylib) respective location within codelite's bundle ("codelite.app") folder, afterwards I run install_name_tool which makes everything relative to the executable using @executable_path</div>

<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The lldb-tool in the Xcode project builds with multiple rpath linker settings:<br>
<br>
-Wl,-rpath,@loader_path/../../Library/PrivateFrameworks/<br>
-Wl,-rpath,@loader_path/../../../SharedFrameworks<br>
-Wl,-rpath,@loader_path/../../System/Library/PrivateFrameworks<br>
-Wl,-rpath,@loader_path/../../Library/PrivateFrameworks<br>
<br>
@loader_path is the location of your codelight LLDB plug-in that needs to link against LLDB. The path can be relative and I would suggest you put a copy of LLDB.framework inside your codelight LLDB plugin bundle.<br>
<div class=""><br>
<br>
<br>
> Is this done manually? (i.e. should I simply create the directory structure and copy the relevant files to their respective location?)<br>
<br>
</div>No, let Xcode build the framework for you.<br>
<div class=""><br>
> Sorry for all the noobish questions, its just my OSX knowledge is very limited compared to Linux/Windows<br>
> But I am working on it ;)<br>
<br>
</div>Just think of frameworks as the dylib + header files + any other files needed (debugserver, lldb-platform, and more) by the framework. It solves the issue of having to have multiple directories for includes (/usr/local/include/lldb), support files (/usr/local/lldb), and for the dylib (/usr/lib/liblldb.so) and keeps all files together and easily lets you have more than one LLDB.framework on your system without everyone having to fight over locations like "/usr/local/include/lldb".<br>


<div class=""><br></div></blockquote><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">I thought I achieve this by distributing my application as a bundle (everything is built with rpath and "fixed" using install_name_tool)</div>

<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">This is how I distributed codelite for several years now with many OSX happy users ;)</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">

</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
><br>
> P.S.<br>
> This is how I built LLDB ( I am using the command line and not Xcode for that purpose) :<br>
><br>
> - svn checkout llvm<br>
> - cd llvm/tools<br>
> - svn checkout lldb<br>
> - svn checkout clang<br>
> - mkdir build-debug && cd build-debug<br>
> - cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug<br>
> - ninja<br>
><br>
> I also followed the signing process as described here <a href="http://llvm.org/svn/llvm-project/lldb/trunk/docs/code-signing.txt" target="_blank">http://llvm.org/svn/llvm-project/lldb/trunk/docs/code-signing.txt</a><br>


<br>
</div>On MacOSX, just download LLDB only and let LLDB build the llvm and clang it requires:<br>
<br>
svn co <a href="http://llvm.org/svn/llvm-project/lldb/trunk" target="_blank">http://llvm.org/svn/llvm-project/lldb/trunk</a> lldb<br>
cd lldb<br>
xcodebuild -configuration Release<br>
<br>
The build process will automagically download the right LLVM (into "lldb/llvm") and clang (into "lldb/llvm/tools/clang") and then build llvm and clang into a LLVM specific build folder ("lldb/llvm-build") for all required architectures (i386 and x86_64).<br>


<div class=""><br>
><br>
> P.P.S<br>
> I really hope that this mailing list is archived somewhere on the web so someone else who wishes to implement LLDB plugin for <choose the IDE name> will benefit for my noob questions<br>
<br>
</div>Anything that isn't clear from our "<a href="http://lldb.llvm.org/build.html" target="_blank">http://lldb.llvm.org/build.html</a>" page should be updated. Feel free to suggest any improvements to these instructions.<br>


<br>
The main problem you will run into is that you won't be able to distribute your "LLDB.framework" to others as the lldb_codesign is only valid for your machine. One thing you can do is to download the latest Xcode (5.1)</blockquote>

<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Done</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

 from the AppStore and copy the /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/debugserver. It will contain a "debugserver" which is codesigned by Apple and won't run into the lldb_codesign issues on other MacOSX systems. "debugserver" is the only thing that requires the special code signing because it does the debugging and requires special privileges. </blockquote>

<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Thanks, will do this</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

So you can build the LLDB.framework and detailed above, then copy the debugserver from the latest Xcode release and place it into your LLDB.framework.<br>
<span class="HOEnZb"><font color="#888888"><br>
Greg<br>
</font></span><div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">I now got the plugin to control the process properly (step-in/step-over/step-out/continue/breakpoints management + backtrace)</div>

<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">I think that this was the biggest obstacle so far and I am hoping to finish the plugin (or at least to make it usable) by this weekend) - I have a waiting list for people who are anxious to try it out</div>

<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Since its open-source, other people can enjoy having a fully working code to copy/paste from ;)</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">

<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Thanks!</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb">

<div class="h5">
><br>
> Thanks,<br>
> Eran<br>
><br>
><br>
><br>
><br>
> On Tue, Apr 1, 2014 at 9:43 PM, Greg Clayton <<a href="mailto:gclayton@apple.com">gclayton@apple.com</a>> wrote:<br>
> The easiest way to see what is going on is to enable gdb-remote packet logging. Make sure you tell Codelight to source the init files when you create your debugger:<br>
><br>
> // Init LLDB<br>
> SBDebugger::Initialize();<br>
><br>
> // Create debugger<br>
> bool source_init_files = true;<br>
> SBDebugger debugger = SBDebugger::Create(source_init_files);<br>
><br>
> Then add the following line to your ~/.lldbinit file:<br>
><br>
> log enable -f /tmp/packets.txt gdb-remote packets<br>
><br>
> Then run and watch your pid come back with zero. Quit code light and attach the packets.txt file to a reply email and we can see what is going on.<br>
><br>
> Did you follow the code signing instructions? You might want to verify that your command line LLDB can indeed debug something:<br>
><br>
> % ./lldb /bin/ls<br>
> (lldb) process launch<br>
><br>
><br>
> Make sure it completes successfully.<br>
><br>
><br>
><br>
> On Apr 1, 2014, at 1:19 AM, Eran Ifrah <<a href="mailto:eran.ifrah@gmail.com">eran.ifrah@gmail.com</a>> wrote:<br>
><br>
> > Hello,<br>
> ><br>
> > I have passed most of the barriers I had in order to integrate lldb within codeite and I have started testing the code on OSX.<br>
> > I have OSX 10.9 and I compiled lldb (btw, an enforcement in CMake to ensure that Xcode is installed would be nice)<br>
> > When I start debugging from within codelite using lldb, the call to m_target.Launch(...) where (m_target is of type SBTarget) returns a valid SBProcess, i.e. m_target.Launch().IsValid() is true<br>
> ><br>
> > However, calling m_target.GetProcess().GetProcessID() returns 0<br>
> > Doing "ps -ef|grep TestLLDB" in the Terminal.app shows that the debuggee process was indeed launched ( I can confirm that the parent process is codelite)<br>
> ><br>
> > Any ideas why it may return 0?<br>
> ><br>
> > TIA,<br>
> ><br>
> > --<br>
> > Eran Ifrah<br>
> > Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org" target="_blank">http://www.codelite.org</a><br>
> > wxCrafter, a wxWidgets RAD: <a href="http://wxcrafter.codelite.org" target="_blank">http://wxcrafter.codelite.org</a><br>
> > _______________________________________________<br>
> > lldb-dev mailing list<br>
> > <a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
><br>
><br>
><br>
><br>
> --<br>
> Eran Ifrah<br>
> Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org" target="_blank">http://www.codelite.org</a><br>
> wxCrafter, a wxWidgets RAD: <a href="http://wxcrafter.codelite.org" target="_blank">http://wxcrafter.codelite.org</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Eran Ifrah<br>Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org" target="_blank">http://www.codelite.org</a><br>

<div>wxCrafter, a wxWidgets RAD: http://<a href="http://wxcrafter.codelite.org" target="_blank">wxcrafter.codelite.org</a></div></div>
</div></div>